Changeset 102627 in webkit


Ignore:
Timestamp:
Dec 12, 2011 2:53:34 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

WebKit code shouldn't be calling applyCommand directly
https://bugs.webkit.org/show_bug.cgi?id=74337

Reviewed by Darin Adler.

Source/WebCore:

Make WebKit-layer code call Editor::replaceSelectionWithFragment and Editor::replaceSelectionWithText
instead of manually creating and applying ReplaceSelectionCommand.

The only behavioral difference is that new code will end up checking for spell checks. However, this
difference appears to be unintentional since the code predates http://trac.webkit.org/changeset/73886,
which introduced an invocation of spellcheck code.

Unfortunately no tests since there doesn't seem to be anyway to test this change.

  • WebCore.exp.in:
  • editing/EditCommand.cpp:

(WebCore::applyCommand):

  • editing/EditCommand.h:
  • editing/Editor.h:

Source/WebKit/chromium:

  • src/WebFrameImpl.cpp:

(WebKit::WebFrameImpl::replaceSelection):

Source/WebKit/gtk:

  • webkit/webkitwebframe.cpp:

(webkit_web_frame_replace_selection):

Source/WebKit/mac:

  • WebView/WebFrame.mm:

(-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):

Source/WebKit2:

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::replaceSelectionWithText):

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102622 r102627  
     12011-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        WebKit code shouldn't be calling applyCommand directly
     4        https://bugs.webkit.org/show_bug.cgi?id=74337
     5
     6        Reviewed by Darin Adler.
     7
     8        Make WebKit-layer code call Editor::replaceSelectionWithFragment and Editor::replaceSelectionWithText
     9        instead of manually creating and applying ReplaceSelectionCommand.
     10
     11        The only behavioral difference is that new code will end up checking for spell checks. However, this
     12        difference appears to be unintentional since the code predates http://trac.webkit.org/changeset/73886,
     13        which introduced an invocation of spellcheck code.
     14
     15        Unfortunately no tests since there doesn't seem to be anyway to test this change.
     16
     17        * WebCore.exp.in:
     18        * editing/EditCommand.cpp:
     19        (WebCore::applyCommand):
     20        * editing/EditCommand.h:
     21        * editing/Editor.h:
     22
    1232011-11-26  Adam Barth  <abarth@webkit.org>
    224
  • trunk/Source/WebCore/WebCore.exp.in

    r102540 r102627  
    303303__ZN7WebCore12TextIteratorD1Ev
    304304__ZN7WebCore12WorkerThread17workerThreadCountEv
    305 __ZN7WebCore12applyCommandEN3WTF10PassRefPtrINS_11EditCommandEEE
    306305__ZN7WebCore12cacheStorageEv
    307306__ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsE
     
    639638__ZN7WebCore22externalRepresentationEPNS_7ElementEj
    640639__ZN7WebCore23AuthenticationChallengeC1ERKNS_15ProtectionSpaceERKNS_10CredentialEjRKNS_16ResourceResponseERKNS_13ResourceErrorE
    641 __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEjNS_10EditActionE
    642640__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
    643641__ZN7WebCore23getHostnamesWithCookiesERN3WTF7HashSetINS0_6StringENS0_10StringHashENS0_10HashTraitsIS2_EEEE
     
    842840__ZN7WebCore6Editor23setBaseWritingDirectionE16WritingDirection
    843841__ZN7WebCore6Editor24advanceToNextMisspellingEb
     842__ZN7WebCore6Editor24replaceSelectionWithTextERKN3WTF6StringEbb
    844843__ZN7WebCore6Editor24computeAndSetTypingStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
    845844__ZN7WebCore6Editor24isSelectionUngrammaticalEv
     
    849848__ZN7WebCore6Editor27handleCorrectionPanelResultERKN3WTF6StringE
    850849__ZN7WebCore6Editor27readSelectionFromPasteboardERKN3WTF6StringE
     850__ZN7WebCore6Editor28replaceSelectionWithFragmentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbb
    851851__ZN7WebCore6Editor29canDecreaseSelectionListLevelEv
    852852__ZN7WebCore6Editor29canIncreaseSelectionListLevelEv
  • trunk/Source/WebCore/editing/EditCommand.cpp

    r102527 r102627  
    260260#endif
    261261
    262 void applyCommand(PassRefPtr<EditCommand> command)
     262void applyCommand(PassRefPtr<CompositeEditCommand> command)
    263263{
    264264    command->apply();
  • trunk/Source/WebCore/editing/EditCommand.h

    r102527 r102627  
    9696    CompositeEditCommand* m_parent;
    9797
    98     friend void applyCommand(PassRefPtr<EditCommand>);
     98    friend void applyCommand(PassRefPtr<CompositeEditCommand>);
    9999};
    100100
     
    124124}
    125125
    126 void applyCommand(PassRefPtr<EditCommand>);
     126void applyCommand(PassRefPtr<CompositeEditCommand>);
    127127
    128128} // namespace WebCore
  • trunk/Source/WebCore/editing/Editor.h

    r102553 r102627  
    375375#endif
    376376
     377    void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle);
     378    void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace);
    377379    bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
    378380    void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
     
    404406    void pasteAsPlainTextWithPasteboard(Pasteboard*);
    405407    void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
    406     void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle);
    407     void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace);
    408408    void writeSelectionToPasteboard(Pasteboard*);
    409409    void revealSelectionAfterEditingOperation();
  • trunk/Source/WebKit/chromium/ChangeLog

    r102620 r102627  
     12011-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        WebKit code shouldn't be calling applyCommand directly
     4        https://bugs.webkit.org/show_bug.cgi?id=74337
     5
     6        Reviewed by Darin Adler.
     7
     8        * src/WebFrameImpl.cpp:
     9        (WebKit::WebFrameImpl::replaceSelection):
     10
    1112011-12-12  David Grogan  <dgrogan@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r102495 r102627  
    11231123void WebFrameImpl::replaceSelection(const WebString& text)
    11241124{
    1125     RefPtr<DocumentFragment> fragment = createFragmentFromText(
    1126         frame()->selection()->toNormalizedRange().get(), text);
    1127     applyCommand(ReplaceSelectionCommand::create(
    1128         frame()->document(), fragment.get(), ReplaceSelectionCommand::SmartReplace | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
     1125    bool selectReplacement = false;
     1126    bool smartReplace = true;
     1127    return frame()->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
    11291128}
    11301129
  • trunk/Source/WebKit/gtk/ChangeLog

    r102604 r102627  
     12011-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        WebKit code shouldn't be calling applyCommand directly
     4        https://bugs.webkit.org/show_bug.cgi?id=74337
     5
     6        Reviewed by Darin Adler.
     7
     8        * webkit/webkitwebframe.cpp:
     9        (webkit_web_frame_replace_selection):
     10
    1112011-12-12  Martin Robinson  <mrobinson@igalia.com>
    212
  • trunk/Source/WebKit/gtk/webkit/webkitwebframe.cpp

    r101049 r102627  
    997997{
    998998    Frame* coreFrame = core(frame);
    999     RefPtr<DocumentFragment> fragment = createFragmentFromText(
    1000         coreFrame->selection()->toNormalizedRange().get(), text);
    1001     applyCommand(ReplaceSelectionCommand::create(coreFrame->document(), fragment.get(),
    1002                                                  ReplaceSelectionCommand::SmartReplace | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
     999    bool selectReplacement = false;
     1000    bool smartReplace = true;
     1001    coreFrame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
    10031002}
    10041003
  • trunk/Source/WebKit/mac/ChangeLog

    r102619 r102627  
     12011-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        WebKit code shouldn't be calling applyCommand directly
     4        https://bugs.webkit.org/show_bug.cgi?id=74337
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebView/WebFrame.mm:
     9        (-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
     10
    1112011-12-12  Brady Eidson  <beidson@apple.com>
    212
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r99628 r102627  
    10491049    if (_private->coreFrame->selection()->isNone() || !fragment)
    10501050        return;
    1051     ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting;
    1052     if (selectReplacement)
    1053         options |= ReplaceSelectionCommand::SelectReplacement;
    1054     if (smartReplace)
    1055         options |= ReplaceSelectionCommand::SmartReplace;
    1056     if (matchStyle)
    1057         options |= ReplaceSelectionCommand::MatchStyle;
    1058     applyCommand(ReplaceSelectionCommand::create(_private->coreFrame->document(), core(fragment), options));
    1059     _private->coreFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
     1051    _private->coreFrame->editor()->replaceSelectionWithFragment(core(fragment), selectReplacement, smartReplace, matchStyle);
    10601052}
    10611053
  • trunk/Source/WebKit2/ChangeLog

    r102625 r102627  
     12011-12-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        WebKit code shouldn't be calling applyCommand directly
     4        https://bugs.webkit.org/show_bug.cgi?id=74337
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebProcess/WebPage/WebPage.cpp:
     9        (WebKit::WebPage::replaceSelectionWithText):
     10
    1112011-12-12  Sam Weinig  <sam@webkit.org>
    212
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r102619 r102627  
    22432243void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
    22442244{
    2245     if (frame->selection()->isNone())
    2246         return;
    2247 
    2248     RefPtr<DocumentFragment> textFragment = createFragmentFromText(frame->selection()->toNormalizedRange().get(), text);
    2249     applyCommand(ReplaceSelectionCommand::create(frame->document(), textFragment.release(), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
    2250     frame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
     2245    bool selectReplacement = true;
     2246    bool smartReplace = false;
     2247    return frame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
    22512248}
    22522249
Note: See TracChangeset for help on using the changeset viewer.