Bug 74249 - Push more member functions from EditCommand to CompositeEditCommand
Summary: Push more member functions from EditCommand to CompositeEditCommand
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on: 64414 74337
Blocks: 74490
  Show dependency treegraph
 
Reported: 2011-12-10 17:10 PST by Ryosuke Niwa
Modified: 2011-12-14 15:16 PST (History)
8 users (show)

See Also:


Attachments
work in progress (23.80 KB, patch)
2011-12-10 17:39 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Cleanup + regression fix (31.97 KB, patch)
2011-12-12 00:41 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Fixed per Enrica's comments (33.23 KB, patch)
2011-12-12 10:52 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
cleanup (26.41 KB, patch)
2011-12-14 00:41 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Fixed per Enrica's comment (28.16 KB, patch)
2011-12-14 13:12 PST, Ryosuke Niwa
enrica: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2011-12-10 17:10:10 PST
Right now EditCommand has many member functions that are overridden by CompositeEditCommand. However, some of them only make sense on CompositeEditCommand. We should move them to CompositeEditCommand since CompositeEditCommand now exists only at the time of initial application of the command.

Also, it doesn't make much sense for EditCommandComposition to share the same super class (EditCommand) with SimpleEditCommand and CompositeEditCommand.
Comment 1 Ryosuke Niwa 2011-12-10 17:39:07 PST
Created attachment 118700 [details]
work in progress
Comment 2 Ryosuke Niwa 2011-12-12 00:41:03 PST
Created attachment 118747 [details]
Cleanup + regression fix
Comment 3 Enrica Casucci 2011-12-12 10:33:02 PST
Comment on attachment 118747 [details]
Cleanup + regression fix

View in context: https://bugs.webkit.org/attachment.cgi?id=118747&action=review

> Source/WebCore/ChangeLog:15
> +        respondToUnappliedEditing exits early even when the unapplied command was a CreteLinkCommand.

Typo CreateLinkCommand.

> Source/WebCore/editing/CompositeEditCommand.cpp:74
> +    const VisibleSelection& startingSelection, const VisibleSelection endingSelection, bool wasCreateLink)

I suggest using was CreateLinkCommand as parameter name.

> Source/WebCore/editing/CompositeEditCommand.h:42
> +    static PassRefPtr<EditCommandComposition> create(Document*, const VisibleSelection&, const VisibleSelection, bool wasCreateLink);

Ditto.

> Source/WebCore/editing/CompositeEditCommand.h:48
> +    bool wasCreateLinkCommand() { return m_wasCreateLink; }

Again I would prefer m_wasCreateLinkCommand. It just feels more understandable.

> Source/WebCore/editing/CompositeEditCommand.h:55
> +    EditCommandComposition(Document* document, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, bool wasCreateLink)

Ditto.

> Source/WebCore/editing/CompositeEditCommand.h:62
> +    bool m_wasCreateLink;

Ditto.

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2246
> +    frame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);

I'm not sure this code is equivalent. The PreventNesting option seems to be lost.

> Source/WebKit/chromium/src/WebFrameImpl.cpp:1129
> +    frame()->editor()->replaceSelectionWithText(text, selectReplace, smartReplace);

Ditto.

> Source/WebKit/gtk/webkit/webkitwebframe.cpp:1001
> +    coreFrame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);

Ditto.

> Source/WebKit/mac/WebView/WebFrame.mm:1049
> +    _private->coreFrame->editor()->replaceSelectionWithFragment(core(fragment), selectReplacement, smartReplace, matchStyle);

Ditto.
Comment 4 Enrica Casucci 2011-12-12 10:35:48 PST
The patch shows build errors on mac.
It would be better to add layout tests for the fix relative to the spellchecker regression. If you want to write the test I could run it and validate it for you, if you want.
Comment 5 Ryosuke Niwa 2011-12-12 10:40:08 PST
(In reply to comment #3)
> (From update of attachment 118747 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=118747&action=review
> 
> > Source/WebCore/ChangeLog:15
> > +        respondToUnappliedEditing exits early even when the unapplied command was a CreteLinkCommand.
> 
> Typo CreateLinkCommand.

Will fix.

> > Source/WebCore/editing/CompositeEditCommand.cpp:74
> > +    const VisibleSelection& startingSelection, const VisibleSelection endingSelection, bool wasCreateLink)
> 
> I suggest using was CreateLinkCommand as parameter name.

Sure, will change.

> > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2246
> > +    frame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
> 
> I'm not sure this code is equivalent. The PreventNesting option seems to be lost.

PreventNesting is always set in Editor::replaceSelectionWithFragment.
Comment 6 Ryosuke Niwa 2011-12-12 10:52:48 PST
Created attachment 118817 [details]
Fixed per Enrica's comments
Comment 7 Ryosuke Niwa 2011-12-12 13:14:05 PST
Comment on attachment 118817 [details]
Fixed per Enrica's comments

Let me split this patch into 3 pieces:
1a - Remove dependency on ApplyCommand in WebKit
1b - Fix a regression in SpellingCorrectionController
2 - Push member functions from EditCommand to CompositeEditCommand.
Comment 8 Enrica Casucci 2011-12-12 13:17:37 PST
(In reply to comment #7)
> (From update of attachment 118817 [details])
> Let me split this patch into 3 pieces:
> 1a - Remove dependency on ApplyCommand in WebKit
> 1b - Fix a regression in SpellingCorrectionController
> 2 - Push member functions from EditCommand to CompositeEditCommand.

Sounds like a good plan to me.
Comment 9 Ryosuke Niwa 2011-12-14 00:41:28 PST
Created attachment 119173 [details]
cleanup
Comment 10 Enrica Casucci 2011-12-14 09:40:38 PST
Comment on attachment 119173 [details]
cleanup

View in context: https://bugs.webkit.org/attachment.cgi?id=119173&action=review

The changes look good, but there is a build failure. Please fix that.

> Source/WebCore/editing/Editor.cpp:871
> +    EditCommandComposition* composition = cmd->composition();

Nit. I would ASSERT composition directly.
Comment 11 Ryosuke Niwa 2011-12-14 13:12:39 PST
Created attachment 119282 [details]
Fixed per Enrica's comment
Comment 12 Enrica Casucci 2011-12-14 13:30:22 PST
Comment on attachment 119282 [details]
Fixed per Enrica's comment

Thanks!
Comment 13 Ryosuke Niwa 2011-12-14 13:31:10 PST
Great. Thanks for the review.
Comment 14 Ryosuke Niwa 2011-12-14 15:16:13 PST
Committed r102833: <http://trac.webkit.org/changeset/102833>