Changeset 238454 in webkit


Ignore:
Timestamp:
Nov 22, 2018 7:10:34 PM (5 years ago)
Author:
Wenson Hsieh
Message:

Address post-review feedback after r238438
https://bugs.webkit.org/show_bug.cgi?id=191913

Reviewed by Ryosuke Niwa.

Source/WebCore:

Replace bool arguments to FrameSelection::setSelectedRange, Editor::replaceSelectionWithText, and
Editor::replaceSelectionWithFragment with enum classes instead. In particular, introduce the following:

FrameSelection::ShouldCloseTyping { No, Yes }
Editor::SelectReplacement { No, Yes }
Editor::SmartReplace { No, Yes }
Editor::MatchStyle { No, Yes }

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::selectText):

  • editing/Editor.cpp:

(WebCore::Editor::handleTextEvent):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::replaceSelectionWithText):
(WebCore::Editor::setComposition):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::changeBackToReplacedString):
(WebCore::Editor::transpose):
(WebCore::Editor::insertAttachment):

At various call sites, replace boolean arguments with named enums.

  • editing/Editor.h:
  • editing/EditorCommand.cpp:

(WebCore::expandSelectionToGranularity):
(WebCore::executeDeleteToMark):
(WebCore::executeSelectToMark):

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::setSelectedRange):

  • editing/FrameSelection.h:
  • page/Page.cpp:

(WebCore::replaceRanges):

Avoid a bit of ref-count churn, and adjust a few functions to take const Vector&s instead of Vector&&s.

(WebCore::Page::replaceRangesWithText):
(WebCore::Page::replaceSelectionWithText):

  • page/Page.h:

Source/WebKit:

Replace boolean arguments to setSelectedRange, replaceSelectionWithText and replaceSelectionWithFragment with
enum flags, and tweak a couple of functions to take const Vector& instead of Vector&&.

  • WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:

(WKBundlePageReplaceStringMatches):

  • WebProcess/WebPage/FindController.cpp:

(WebKit::FindController::replaceMatches):

  • WebProcess/WebPage/FindController.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::replaceStringMatchesFromInjectedBundle):
(WebKit::WebPage::replaceMatches):
(WebKit::WebPage::replaceSelectionWithText):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::selectWithGesture):
(WebKit::WebPage::updateSelectionWithTouches):
(WebKit::WebPage::selectWithTwoTouches):
(WebKit::WebPage::extendSelection):
(WebKit::WebPage::selectWordBackward):
(WebKit::WebPage::moveSelectionByOffset):
(WebKit::WebPage::selectPositionAtPoint):
(WebKit::WebPage::selectPositionAtBoundaryWithDirection):
(WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
(WebKit::WebPage::updateSelectionWithExtentPoint):
(WebKit::WebPage::replaceSelectedText):
(WebKit::WebPage::replaceDictatedText):
(WebKit::WebPage::syncApplyAutocorrection):

Source/WebKitLegacy/mac:

  • WebView/WebFrame.mm:

(-[WebFrame setSelectedDOMRange:affinity:closeTyping:]):
(-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):

  • WebView/WebView.mm:

(-[WebView setSelectedDOMRange:affinity:]):

Source/WebKitLegacy/win:

  • AccessibleTextImpl.cpp:

(AccessibleText::replaceText):

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238452 r238454  
     12018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Address post-review feedback after r238438
     4        https://bugs.webkit.org/show_bug.cgi?id=191913
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Replace `bool` arguments to `FrameSelection::setSelectedRange`, `Editor::replaceSelectionWithText`, and
     9        `Editor::replaceSelectionWithFragment` with `enum class`es instead. In particular, introduce the following:
     10
     11        FrameSelection::ShouldCloseTyping { No, Yes }
     12        Editor::SelectReplacement { No, Yes }
     13        Editor::SmartReplace { No, Yes }
     14        Editor::MatchStyle { No, Yes }
     15
     16        * accessibility/AccessibilityObject.cpp:
     17        (WebCore::AccessibilityObject::selectText):
     18        * editing/Editor.cpp:
     19        (WebCore::Editor::handleTextEvent):
     20        (WebCore::Editor::replaceSelectionWithFragment):
     21        (WebCore::Editor::replaceSelectionWithText):
     22        (WebCore::Editor::setComposition):
     23        (WebCore::Editor::markMisspellingsAfterTypingToWord):
     24        (WebCore::Editor::changeBackToReplacedString):
     25        (WebCore::Editor::transpose):
     26        (WebCore::Editor::insertAttachment):
     27
     28        At various call sites, replace boolean arguments with named enums.
     29
     30        * editing/Editor.h:
     31        * editing/EditorCommand.cpp:
     32        (WebCore::expandSelectionToGranularity):
     33        (WebCore::executeDeleteToMark):
     34        (WebCore::executeSelectToMark):
     35        * editing/FrameSelection.cpp:
     36        (WebCore::FrameSelection::setSelectedRange):
     37        * editing/FrameSelection.h:
     38        * page/Page.cpp:
     39        (WebCore::replaceRanges):
     40
     41        Avoid a bit of ref-count churn, and adjust a few functions to take `const Vector&`s instead of `Vector&&`s.
     42
     43        (WebCore::Page::replaceRangesWithText):
     44        (WebCore::Page::replaceSelectionWithText):
     45        * page/Page.h:
     46
    1472018-11-21  Ryosuke Niwa  <rniwa@webkit.org>
    248
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r237266 r238454  
    839839        String closestString = closestStringRange->text();
    840840        bool replaceSelection = false;
    841         if (frame->selection().setSelectedRange(closestStringRange.get(), DOWNSTREAM, true)) {
     841        if (frame->selection().setSelectedRange(closestStringRange.get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes)) {
    842842            switch (activity) {
    843843            case AccessibilitySelectTextActivity::FindAndCapitalize:
     
    872872            // return the replacement string when replacing, but the selected string if not.
    873873            if (replaceSelection) {
    874                 frame->editor().replaceSelectionWithText(replacementString, true, true);
     874                frame->editor().replaceSelectionWithText(replacementString, Editor::SelectReplacement::Yes, Editor::SmartReplace::Yes);
    875875                return replacementString;
    876876            }
  • trunk/Source/WebCore/editing/Editor.cpp

    r238440 r238454  
    311311                return true;
    312312#endif
    313             replaceSelectionWithFragment(*event.pastingFragment(), false, event.shouldSmartReplace(), event.shouldMatchStyle(), EditAction::Paste, event.mailBlockquoteHandling());
     313            replaceSelectionWithFragment(*event.pastingFragment(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, event.shouldMatchStyle() ? MatchStyle::Yes : MatchStyle::No, EditAction::Paste, event.mailBlockquoteHandling());
    314314        } else
    315             replaceSelectionWithText(event.data(), false, event.shouldSmartReplace(), EditAction::Paste);
     315            replaceSelectionWithText(event.data(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, EditAction::Paste);
    316316        return true;
    317317    }
     
    640640}
    641641
    642 void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selectReplacement, bool smartReplace, bool matchStyle, EditAction editingAction, MailBlockquoteHandling mailBlockquoteHandling)
     642void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, SelectReplacement selectReplacement, SmartReplace smartReplace, MatchStyle matchStyle, EditAction editingAction, MailBlockquoteHandling mailBlockquoteHandling)
    643643{
    644644    VisibleSelection selection = m_frame.selection().selection();
     
    651651
    652652    OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::PreventNesting, ReplaceSelectionCommand::SanitizeFragment };
    653     if (selectReplacement)
     653    if (selectReplacement == SelectReplacement::Yes)
    654654        options.add(ReplaceSelectionCommand::SelectReplacement);
    655     if (smartReplace)
     655    if (smartReplace == SmartReplace::Yes)
    656656        options.add(ReplaceSelectionCommand::SmartReplace);
    657     if (matchStyle)
     657    if (matchStyle == MatchStyle::Yes)
    658658        options.add(ReplaceSelectionCommand::MatchStyle);
    659659    if (mailBlockquoteHandling == MailBlockquoteHandling::IgnoreBlockquote)
     
    686686}
    687687
    688 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace, EditAction editingAction)
     688void Editor::replaceSelectionWithText(const String& text, SelectReplacement selectReplacement, SmartReplace smartReplace, EditAction editingAction)
    689689{
    690690    RefPtr<Range> range = selectedRange();
     
    692692        return;
    693693
    694     replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, true, editingAction);
     694    replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, MatchStyle::Yes, editingAction);
    695695}
    696696
     
    20242024            unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOffset);
    20252025            RefPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end);
    2026             m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, false);
     2026            m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::No);
    20272027        }
    20282028    }
     
    25182518        if (!m_frame.editor().shouldInsertText(autocorrectedString, misspellingRange.get(), EditorInsertAction::Typed))
    25192519            return;
    2520         m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false, EditAction::Insert);
     2520        m_frame.editor().replaceSelectionWithText(autocorrectedString, SelectReplacement::No, SmartReplace::No, EditAction::Insert);
    25212521
    25222522        // Reset the charet one character further.
     
    28762876    m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, replacedString, selection.get());
    28772877    TextCheckingParagraph paragraph(*selection);
    2878     replaceSelectionWithText(replacedString, false, false, EditAction::Insert);
     2878    replaceSelectionWithText(replacedString, SelectReplacement::No, SmartReplace::No, EditAction::Insert);
    28792879    auto changedRange = paragraph.subrange(paragraph.checkingStart(), replacedString.length());
    28802880    changedRange->startContainer().document().markers().addMarker(changedRange.ptr(), DocumentMarker::Replacement, String());
     
    31223122    if (!shouldInsertText(transposed, range.get(), EditorInsertAction::Typed))
    31233123        return;
    3124     replaceSelectionWithText(transposed, false, false, EditAction::Insert);
     3124    replaceSelectionWithText(transposed, SelectReplacement::No, SmartReplace::No, EditAction::Insert);
    31253125}
    31263126
     
    40994099    fragmentToInsert->appendChild(attachment.get());
    41004100
    4101     replaceSelectionWithFragment(fragmentToInsert.get(), false, false, true);
     4101    replaceSelectionWithFragment(fragmentToInsert.get(), SelectReplacement::No, SmartReplace::No, MatchStyle::Yes);
    41024102}
    41034103
  • trunk/Source/WebCore/editing/Editor.h

    r238440 r238454  
    439439    WEBCORE_EXPORT WritingDirection baseWritingDirectionForSelectionStart() const;
    440440
    441     WEBCORE_EXPORT void replaceSelectionWithFragment(DocumentFragment&, bool selectReplacement, bool smartReplace, bool matchStyle, EditAction = EditAction::Insert, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
    442     WEBCORE_EXPORT void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace, EditAction = EditAction::Insert);
     441    enum class SelectReplacement : bool { No, Yes };
     442    enum class SmartReplace : bool { No, Yes };
     443    enum class MatchStyle : bool { No, Yes };
     444    WEBCORE_EXPORT void replaceSelectionWithFragment(DocumentFragment&, SelectReplacement, SmartReplace, MatchStyle, EditAction = EditAction::Insert, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
     445    WEBCORE_EXPORT void replaceSelectionWithText(const String&, SelectReplacement, SmartReplace, EditAction = EditAction::Insert);
    443446    WEBCORE_EXPORT bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
    444447    void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r237976 r238454  
    186186    if (!frame.editor().client()->shouldChangeSelectedRange(oldRange.get(), newRange.get(), affinity, false))
    187187        return false;
    188     frame.selection().setSelectedRange(newRange.get(), affinity, true);
     188    frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection::ShouldCloseTyping::Yes);
    189189    return true;
    190190}
     
    356356    FrameSelection& selection = frame.selection();
    357357    if (mark && frame.editor().selectedRange()) {
    358         bool selected = selection.setSelectedRange(unionDOMRanges(*mark, *frame.editor().selectedRange()).get(), DOWNSTREAM, true);
     358        bool selected = selection.setSelectedRange(unionDOMRanges(*mark, *frame.editor().selectedRange()).get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes);
    359359        ASSERT(selected);
    360360        if (!selected)
     
    10311031        return false;
    10321032    }
    1033     frame.selection().setSelectedRange(unionDOMRanges(*mark, *selection).get(), DOWNSTREAM, true);
     1033    frame.selection().setSelectedRange(unionDOMRanges(*mark, *selection).get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes);
    10341034    return true;
    10351035}
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r238359 r238454  
    19801980}
    19811981
    1982 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool closeTyping, EUserTriggered userTriggered)
     1982bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, ShouldCloseTyping closeTyping, EUserTriggered userTriggered)
    19831983{
    19841984    if (!range)
     
    19951995
    19961996    OptionSet<SetSelectionOption> selectionOptions {  ClearTypingStyle };
    1997     if (closeTyping)
     1997    if (closeTyping == ShouldCloseTyping::Yes)
    19981998        selectionOptions.add(CloseTyping);
    19991999
  • trunk/Source/WebCore/editing/FrameSelection.h

    r237266 r238454  
    151151    const VisibleSelection& selection() const { return m_selection; }
    152152    WEBCORE_EXPORT void setSelection(const VisibleSelection&, OptionSet<SetSelectionOption> = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
    153     WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, bool closeTyping, EUserTriggered = NotUserTriggered);
     153
     154    enum class ShouldCloseTyping : bool { No, Yes };
     155    WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, ShouldCloseTyping, EUserTriggered = NotUserTriggered);
    154156    WEBCORE_EXPORT void selectAll();
    155157    WEBCORE_EXPORT void clear();
  • trunk/Source/WebCore/page/Page.cpp

    r238438 r238454  
    773773};
    774774
    775 static void replaceRanges(Page& page, Vector<FindReplacementRange>&& ranges, const String& replacementText)
     775static void replaceRanges(Page& page, const Vector<FindReplacementRange>& ranges, const String& replacementText)
    776776{
    777777    HashMap<RefPtr<ContainerNode>, Vector<FindReplacementRange>> rangesByContainerNode;
     
    820820    });
    821821
    822     for (auto container : containerNodesInOrderOfReplacement) {
     822    for (auto& container : containerNodesInOrderOfReplacement) {
    823823        auto frame = makeRefPtr(container->document().frame());
    824824        if (!frame)
     
    832832                continue;
    833833
    834             frame->selection().setSelectedRange(range.get(), DOWNSTREAM, true);
    835             frame->editor().replaceSelectionWithText(replacementText, true, false, EditAction::InsertReplacement);
     834            frame->selection().setSelectedRange(range.get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes);
     835            frame->editor().replaceSelectionWithText(replacementText, Editor::SelectReplacement::Yes, Editor::SmartReplace::No, EditAction::InsertReplacement);
    836836        }
    837837    }
    838838}
    839839
    840 uint32_t Page::replaceRangesWithText(Vector<Ref<Range>>&& rangesToReplace, const String& replacementText, bool selectionOnly)
     840uint32_t Page::replaceRangesWithText(const Vector<Ref<Range>>& rangesToReplace, const String& replacementText, bool selectionOnly)
    841841{
    842842    // FIXME: In the future, we should respect the `selectionOnly` flag by checking whether each range being replaced is
     
    867867    }
    868868
    869     replaceRanges(*this, WTFMove(replacementRanges), replacementText);
     869    replaceRanges(*this, replacementRanges, replacementText);
    870870    return rangesToReplace.size();
    871871}
     
    879879
    880880    auto editAction = selection.isRange() ? EditAction::InsertReplacement : EditAction::Insert;
    881     frame->editor().replaceSelectionWithText(replacementText, true, false, editAction);
     881    frame->editor().replaceSelectionWithText(replacementText, Editor::SelectReplacement::Yes, Editor::SmartReplace::No, editAction);
    882882    return 1;
    883883}
  • trunk/Source/WebCore/page/Page.h

    r238438 r238454  
    279279
    280280    WEBCORE_EXPORT bool findString(const String&, FindOptions, DidWrap* = nullptr);
    281     WEBCORE_EXPORT uint32_t replaceRangesWithText(Vector<Ref<Range>>&& rangesToReplace, const String& replacementText, bool selectionOnly);
     281    WEBCORE_EXPORT uint32_t replaceRangesWithText(const Vector<Ref<Range>>& rangesToReplace, const String& replacementText, bool selectionOnly);
    282282    WEBCORE_EXPORT uint32_t replaceSelectionWithText(const String& replacementText);
    283283
  • trunk/Source/WebKit/ChangeLog

    r238446 r238454  
     12018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Address post-review feedback after r238438
     4        https://bugs.webkit.org/show_bug.cgi?id=191913
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Replace boolean arguments to setSelectedRange, replaceSelectionWithText and replaceSelectionWithFragment with
     9        enum flags, and tweak a couple of functions to take `const Vector&` instead of `Vector&&`.
     10
     11        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
     12        (WKBundlePageReplaceStringMatches):
     13        * WebProcess/WebPage/FindController.cpp:
     14        (WebKit::FindController::replaceMatches):
     15        * WebProcess/WebPage/FindController.h:
     16        * WebProcess/WebPage/WebPage.cpp:
     17        (WebKit::WebPage::replaceStringMatchesFromInjectedBundle):
     18        (WebKit::WebPage::replaceMatches):
     19        (WebKit::WebPage::replaceSelectionWithText):
     20        * WebProcess/WebPage/WebPage.h:
     21        * WebProcess/WebPage/ios/WebPageIOS.mm:
     22        (WebKit::WebPage::selectWithGesture):
     23        (WebKit::WebPage::updateSelectionWithTouches):
     24        (WebKit::WebPage::selectWithTwoTouches):
     25        (WebKit::WebPage::extendSelection):
     26        (WebKit::WebPage::selectWordBackward):
     27        (WebKit::WebPage::moveSelectionByOffset):
     28        (WebKit::WebPage::selectPositionAtPoint):
     29        (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
     30        (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
     31        (WebKit::WebPage::selectTextWithGranularityAtPoint):
     32        (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
     33        (WebKit::WebPage::updateSelectionWithExtentPoint):
     34        (WebKit::WebPage::replaceSelectedText):
     35        (WebKit::WebPage::replaceDictatedText):
     36        (WebKit::WebPage::syncApplyAutocorrection):
     37
    1382018-11-22  Mark Lam  <mark.lam@apple.com>
    239
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

    r238438 r238454  
    462462    indices.reserveInitialCapacity(matchIndices->size());
    463463
    464     for (size_t arrayIndex = 0; arrayIndex < matchIndices->size(); ++arrayIndex) {
    465         if (auto* indexAsObject = matchIndices->at<API::UInt64>(arrayIndex))
     464    auto numberOfMatchIndices = matchIndices->size();
     465    for (size_t i = 0; i < numberOfMatchIndices; ++i) {
     466        if (auto* indexAsObject = matchIndices->at<API::UInt64>(i))
    466467            indices.uncheckedAppend(indexAsObject->value());
    467468    }
    468     toImpl(pageRef)->replaceStringMatchesFromInjectedBundle(WTFMove(indices), toWTFString(replacementText), selectionOnly);
     469    toImpl(pageRef)->replaceStringMatchesFromInjectedBundle(indices, toWTFString(replacementText), selectionOnly);
    469470}
    470471
  • trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp

    r238438 r238454  
    100100}
    101101
    102 uint32_t FindController::replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly)
     102uint32_t FindController::replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly)
    103103{
    104104    if (matchIndices.isEmpty())
     
    118118            break;
    119119    }
    120     return m_webPage->corePage()->replaceRangesWithText(WTFMove(rangesToReplace), replacementText, selectionOnly);
     120    return m_webPage->corePage()->replaceRangesWithText(rangesToReplace, replacementText, selectionOnly);
    121121}
    122122
  • trunk/Source/WebKit/WebProcess/WebPage/FindController.h

    r238438 r238454  
    6262    void hideFindUI();
    6363    void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
    64     uint32_t replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly);
     64    uint32_t replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly);
    6565   
    6666    void hideFindIndicator();
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r238438 r238454  
    37973797}
    37983798
    3799 void WebPage::replaceStringMatchesFromInjectedBundle(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly)
    3800 {
    3801     findController().replaceMatches(WTFMove(matchIndices), replacementText, selectionOnly);
     3799void WebPage::replaceStringMatchesFromInjectedBundle(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly)
     3800{
     3801    findController().replaceMatches(matchIndices, replacementText, selectionOnly);
    38023802}
    38033803
     
    38323832}
    38333833
    3834 void WebPage::replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly, CallbackID callbackID)
    3835 {
    3836     auto numberOfReplacements = findController().replaceMatches(WTFMove(matchIndices), replacementText, selectionOnly);
     3834void WebPage::replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID callbackID)
     3835{
     3836    auto numberOfReplacements = findController().replaceMatches(matchIndices, replacementText, selectionOnly);
    38373837    send(Messages::WebPageProxy::UnsignedCallback(numberOfReplacements, callbackID));
    38383838}
     
    40374037void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
    40384038{
    4039     bool selectReplacement = true;
    4040     bool smartReplace = false;
    4041     return frame->editor().replaceSelectionWithText(text, selectReplacement, smartReplace);
     4039    return frame->editor().replaceSelectionWithText(text, WebCore::Editor::SelectReplacement::Yes, WebCore::Editor::SmartReplace::No);
    40424040}
    40434041
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r238438 r238454  
    410410    bool findStringFromInjectedBundle(const String&, FindOptions);
    411411    void findStringMatchesFromInjectedBundle(const String&, FindOptions);
    412     void replaceStringMatchesFromInjectedBundle(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly);
     412    void replaceStringMatchesFromInjectedBundle(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly);
    413413
    414414    WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
     
    13071307    void hideFindUI();
    13081308    void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
    1309     void replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly, CallbackID);
     1309    void replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID);
    13101310
    13111311#if USE(COORDINATED_GRAPHICS)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r238146 r238454  
    12151215    }
    12161216    if (range)
    1217         frame.selection().setSelectedRange(range.get(), position.affinity(), true, UserTriggered);
     1217        frame.selection().setSelectedRange(range.get(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    12181218
    12191219    send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, static_cast<uint32_t>(flags), callbackID));
     
    13651365    }
    13661366    if (range)
    1367         frame.selection().setSelectedRange(range.get(), position.affinity(), true, UserTriggered);
     1367        frame.selection().setSelectedRange(range.get(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    13681368
    13691369    send(Messages::WebPageProxy::TouchesCallback(point, touches, flags, callbackID));
     
    13811381        else
    13821382            range = Range::create(*frame.document(), toPosition, fromPosition);
    1383         frame.selection().setSelectedRange(range.get(), fromPosition.affinity(), true, UserTriggered);
     1383        frame.selection().setSelectedRange(range.get(), fromPosition.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    13841384    }
    13851385
     
    13961396
    13971397    VisiblePosition position = frame.selection().selection().start();
    1398     frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), true, UserTriggered);
     1398    frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    13991399}
    14001400
     
    14081408    VisiblePosition startPosition = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionBackward);
    14091409    if (startPosition.isNotNull() && startPosition != position)
    1410         frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), true, UserTriggered);
     1410        frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    14111411}
    14121412
     
    14261426    }
    14271427    if (position.isNotNull() && startPosition != position)
    1428         frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true, UserTriggered);
     1428        frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    14291429    send(Messages::WebPageProxy::VoidCallback(callbackID));
    14301430}
     
    15461546   
    15471547    if (position.isNotNull())
    1548         frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true, UserTriggered);
     1548        frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    15491549    send(Messages::WebPageProxy::VoidCallback(callbackID));
    15501550}
     
    15581558        position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction));
    15591559        if (position.isNotNull())
    1560             frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, true, UserTriggered);
     1560            frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    15611561    }
    15621562    send(Messages::WebPageProxy::VoidCallback(callbackID));
     
    15721572        position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction));
    15731573        if (position.isNotNull())
    1574             frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, true, UserTriggered);
     1574            frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    15751575    }
    15761576    send(Messages::WebPageProxy::VoidCallback(callbackID));
     
    16291629
    16301630    if (range)
    1631         frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered);
     1631        frame.selection().setSelectedRange(range.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    16321632    m_initialSelection = range;
    16331633    send(Messages::WebPageProxy::VoidCallback(callbackID));
     
    16641664   
    16651665    if (range)
    1666         frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered);
     1666        frame.selection().setSelectedRange(range.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    16671667   
    16681668    send(Messages::WebPageProxy::UnsignedCallback(selectionStart == m_initialSelection->startPosition(), callbackID));
     
    17071707
    17081708    if (range)
    1709         frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered);
     1709        frame.selection().setSelectedRange(range.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    17101710
    17111711    send(Messages::WebPageProxy::UnsignedCallback(m_selectionAnchor == Start, callbackID));
     
    17701770   
    17711771    frame.editor().setIgnoreSelectionChanges(true);
    1772     frame.selection().setSelectedRange(wordRange.get(), UPSTREAM, true);
     1772    frame.selection().setSelectedRange(wordRange.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes);
    17731773    frame.editor().insertText(newText, 0);
    17741774    frame.editor().setIgnoreSelectionChanges(false);
     
    17971797    // We don't want to notify the client that the selection has changed until we are done inserting the new text.
    17981798    frame.editor().setIgnoreSelectionChanges(true);
    1799     frame.selection().setSelectedRange(range.get(), UPSTREAM, true);
     1799    frame.selection().setSelectedRange(range.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes);
    18001800    frame.editor().insertText(newText, 0);
    18011801    frame.editor().setIgnoreSelectionChanges(false);
     
    19311931        affinity = VisiblePosition(range->startPosition(), UPSTREAM).affinity();
    19321932   
    1933     frame.selection().setSelectedRange(range.get(), affinity, true);
     1933    frame.selection().setSelectedRange(range.get(), affinity, WebCore::FrameSelection::ShouldCloseTyping::Yes);
    19341934    if (correction.length())
    19351935        frame.editor().insertText(correction, 0, originalText.isEmpty() ? TextEventInputKeyboard : TextEventInputAutocompletion);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r238378 r238454  
     12018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Address post-review feedback after r238438
     4        https://bugs.webkit.org/show_bug.cgi?id=191913
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * WebView/WebFrame.mm:
     9        (-[WebFrame setSelectedDOMRange:affinity:closeTyping:]):
     10        (-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
     11        * WebView/WebView.mm:
     12        (-[WebView setSelectedDOMRange:affinity:]):
     13
    1142018-11-19  Joseph Pecoraro  <pecoraro@apple.com>
    215
  • trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm

    r237266 r238454  
    14831483    }
    14841484
    1485     frame->selection().setSelectedRange(core(range), (EAffinity)affinity, closeTyping);
     1485    frame->selection().setSelectedRange(core(range), (EAffinity)affinity, closeTyping ? FrameSelection::ShouldCloseTyping::Yes : FrameSelection::ShouldCloseTyping::No);
    14861486    if (!closeTyping)
    14871487        frame->editor().ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
     
    19531953    if (_private->coreFrame->selection().isNone() || !fragment)
    19541954        return;
    1955     _private->coreFrame->editor().replaceSelectionWithFragment(*core(fragment), selectReplacement, smartReplace, matchStyle);
     1955    _private->coreFrame->editor().replaceSelectionWithFragment(*core(fragment), selectReplacement ? Editor::SelectReplacement::Yes : Editor::SelectReplacement::No, smartReplace ? Editor::SmartReplace::Yes : Editor::SmartReplace::No, matchStyle ? Editor::MatchStyle::Yes : Editor::MatchStyle::No);
    19561956}
    19571957
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r238262 r238454  
    83528352            return;
    83538353
    8354         coreFrame->selection().setSelectedRange(core(range), core(selectionAffinity), true);
     8354        coreFrame->selection().setSelectedRange(core(range), core(selectionAffinity), WebCore::FrameSelection::ShouldCloseTyping::Yes);
    83558355    }
    83568356}
  • trunk/Source/WebKitLegacy/win/AccessibleTextImpl.cpp

    r213355 r238454  
    657657    addSelection(startOffset, endOffset);
    658658
    659     frame->editor().replaceSelectionWithText(*text, true, false);
     659    frame->editor().replaceSelectionWithText(*text, Editor::SelectReplacement::Yes, Editor::SmartReplace::No);
    660660    return S_OK;
    661661}
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r238378 r238454  
     12018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Address post-review feedback after r238438
     4        https://bugs.webkit.org/show_bug.cgi?id=191913
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * AccessibleTextImpl.cpp:
     9        (AccessibleText::replaceText):
     10
    1112018-11-19  Joseph Pecoraro  <pecoraro@apple.com>
    212
Note: See TracChangeset for help on using the changeset viewer.