[webkit-help] Fwd: Problem extending WebViewUndoableEditing

Alexander Shulgin alexander.shulgin at yessoftware.com
Sat Aug 21 08:10:20 PDT 2010


On 20.08.2010 22:40, Ryosuke Niwa wrote:

[replying out of order]

> Try adding those methods you're using to WebCore.exp.in as well.

Thanks, that did the trick!

> Also, there has been a discussion on adding new APIs to allow implement
> custom editing commands in JavaScript.  So I'm curious to know if
> that'll suffice your need.  Could you tell us why you'd like to add this
> feature?

Specifically, we are embedding WebKit into .NET (C#) application which 
has to work on Windows and (with some changes) on Mac OS.

For content editing capabilities we've found that WebKit behavior is 
often surprising or plain broken.  So we've patched it (on Windows) to 
accept our custom editing commands through newly introduced COM 
interface.  Now, if we design the commands carefully we can enjoy 
arbitrary editing capabilities and undo/redo operations work smoothly.

That job is already done on Windows, and now it came to port it to Mac 
OS, where the outer layer (WebKit) is ObjectiveC as opposed to COM/C++ 
on Windows.

The JavaScript would be interesting, but unfortunately, we already have 
tons of C# code for our editing commands and we're unlikely to convert 
that to JavaScript.

 > But I'm afraid that you're sort of
 > breaking the abstraction layer here.  Why can't you put your
 > CustomWebCoreEditingCommand in WebCore and have it provide some
 > interface to WebKit?

I think I can, but that would be no different from my current approach. 
  And this will just complicate things further w/o the real need for it.

Trying to sketch this move of CustomEditingCommand to WebCore I see the 
strong need for some proxy object (or three separate ``functor 
objects'') to be passed from WebKit to WebCore:

WebCore (C++)
=============
class EditingCommandProxy
{
   virtual void apply() = 0;
   virtual void unapply() = 0;
   virtual void reapply() = 0;
}

class CustomEditingCommand : SimpleEditCommand
{
   CustomEditingCommand(EditingCommandProxy*);

   void doApply() { m_proxy->apply(); }
   void doUnapply() { ... }
   void doReapply() { ... }
}

WebKit (ObjC)
=============
class WebEditingCommandProxy : WebCore::EditingCommandProxy
{
    WebEditingCommandProxy(WebEditingCommand*);

    void apply() { [m_command apply]; }
    ...
}

- (void)applyEditingcommand:(WebEditingCommand*) command
{
   ...
   applyCommand(CustomEditingCommand::create(new 
WebEditingCommandProxy(command)));
}

Well, to me this looks uglier than necessary.  Or I've missed something 
again :)

--
Regards,
Alex


More information about the webkit-help mailing list