Hi,

I'm trying to add this functionality which will allow us to execute arbitrary undoable content editing commands.

I've added new editing command interface like this:

@interface WebEditingCommand : NSObject {
}
- (void)apply;
- (void)unapply;
- (void)reapply;
@end

In WebKit/mac/WebView/WebView.h I've extended WebViewUndoableEditing like this:

@interface WebView (WebViewUndoableEditing)
- (void)replaceSelectionWithNode:(DOMNode *)node;
- (void)replaceSelectionWithText:(NSString *)text;
- (void)replaceSelectionWithMarkupString:(NSString *)markupString;
- (void)replaceSelectionWithArchive:(WebArchive *)archive;
- (void)deleteSelection;
- (void)applyStyle:(DOMCSSStyleDeclaration *)style;

// *** added this line:
- (void)applyEditingCommand:(WebEditingCommand *)command;
@end

Then I've added a new C++ class CustomWebCoreEditingCommand which is inherited from WebCore::SimpleEditCommand (please see attached files) and put it under WebKit/mac/WebCoreSupport. Also added these new files to XCode project.

Now then I compile the whole thing I get these linker errors:

Undefined symbols:
  "__ZNK7WebCore11EditCommand19isInsertTextCommandEv", referenced from:
      __ZTV27CustomWebCoreEditingCommand in CustomWebCoreEditingCommand.o
      __ZTVN7WebCore17SimpleEditCommandE in CustomWebCoreEditingCommand.o
  "__ZN7WebCore11EditCommand9doReapplyEv", referenced from:
      __ZTVN7WebCore17SimpleEditCommandE in CustomWebCoreEditingCommand.o
...
(more messages like this all related to WebCore::EditCommand::something)

For no obvious reason it complains about not being able to find these symbols from WebCore::EditCommand, while they are certainly there in the WebCore library... I even checked with nm tool to see if name mangling is the same, and it is.

I originally tried it with ObjC++ files which gave me exactly the same linking problem. So now I tried to separate C++ and ObjectiveC (square-bracket calls on WebEditingCommand interface moved to WebEditingCommandCppBridge.mm file), but to no avail.

Later I noticed there are several C++ classes in WebCoreSupport folder which inherit some WebCore class but use some ObjC syntax w/o any problem. Why doesn't this work for my class?

Am I missing something?

--
Regards,
Alex
#include "CustomWebCoreEditingCommand.h"
#include "WebEditingCommandCppBridge.h"

PassRefPtr<CustomWebCoreEditingCommand> 
CustomWebCoreEditingCommand::create(WebCore::Document* document, void* command)
{
    return adoptRef(new CustomWebCoreEditingCommand(document, command));
}

CustomWebCoreEditingCommand::CustomWebCoreEditingCommand(WebCore::Document* 
document, void* command)
    : SimpleEditCommand(document)
    , m_command(command)
{
}

void CustomWebCoreEditingCommand::doApply()
{
    applyWebEditingCommand(m_command);
}

void CustomWebCoreEditingCommand::doUnapply()
{
    unapplyWebEditingCommand(m_command);
}

void CustomWebCoreEditingCommand::doReapply()
{
    reapplyWebEditingCommand(m_command);
}
#ifndef CustomWebCoreEditingCommand_h
#define CustomWebCoreEditingCommand_h

#include <WebCore/EditCommand.h>

class CustomWebCoreEditingCommand : public WebCore::SimpleEditCommand {
public:
    static PassRefPtr<CustomWebCoreEditingCommand> create(WebCore::Document* 
document, void* command);

private:
    CustomWebCoreEditingCommand(WebCore::Document* document, void* command);

    virtual void doApply();
    virtual void doUnapply();
    virtual void doReapply();

    void* m_command;
};

#endif // CustomWebCoreEditingCommand_h
#import <Foundation/Foundation.h>

@interface WebEditingCommand : NSObject
{
}

- (void)apply;
- (void)unapply;
- (void)reapply;

@end
#ifndef WebEditingCommandCppBridge_h
#define WebEditingCommandCppBridge_h

void applyWebEditingCommand(void* command);

void unapplyWebEditingCommand(void* command);

void reapplyWebEditingCommand(void* command);

#endif // WebEditingCommandCppBridge_h
#import "WebEditingCommand.h"
#import "WebEditingCommandCppBridge.h"

void applyWebEditingCommand(void* command)
{
    [((WebEditingCommand*) command) apply];
}

void unapplyWebEditingCommand(void* command)
{
    [((WebEditingCommand*) command) unapply];
}

void reapplyWebEditingCommand(void* command)
{
    [((WebEditingCommand*) command) reapply];
}
_______________________________________________
webkit-help mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-help

Reply via email to