Use OptionSet more in editing code
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 15:29:23 +0000 (15:29 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 15:29:23 +0000 (15:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188500

Reviewed by Wenson Hsieh.

Typesafe flags.

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs):
* editing/Editor.cpp:
(WebCore::TemporarySelectionChange::TemporarySelectionChange):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::selectComposition):
(WebCore::Editor::changeSelectionAfterCommand):
(WebCore::Editor::respondToChangedSelection):
* editing/Editor.h:
(WebCore::TemporarySelectionChange::TemporarySelectionChange):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::moveWithoutValidationTo):
(WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
(WebCore::FrameSelection::setSelection):
(WebCore::FrameSelection::setSelectedRange):
* editing/FrameSelection.h:
(WebCore::FrameSelection::defaultSetSelectionOptions):
* editing/MoveSelectionCommand.cpp:
(WebCore::MoveSelectionCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand):
* editing/ReplaceSelectionCommand.h:
(WebCore::ReplaceSelectionCommand::create):
* editing/SetSelectionCommand.cpp:
(WebCore::SetSelectionCommand::SetSelectionCommand):
* editing/SetSelectionCommand.h:
(WebCore::SetSelectionCommand::create):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag):
* page/TextIndicator.cpp:
(WebCore::TextIndicator::createWithRange):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234801 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/FrameSelection.h
Source/WebCore/editing/MoveSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.h
Source/WebCore/editing/SetSelectionCommand.cpp
Source/WebCore/editing/SetSelectionCommand.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/TextIndicator.cpp
Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm
Source/WebKitLegacy/mac/WebView/WebFrame.mm

index 53b6825c468dc7d339856a618733fcc8d71af123..f76e3070c4621b0f9d3107018f69e0671892be68 100644 (file)
@@ -1,3 +1,47 @@
+2018-08-13  Antti Koivisto  <antti@apple.com>
+
+        Use OptionSet more in editing code
+        https://bugs.webkit.org/show_bug.cgi?id=188500
+
+        Reviewed by Wenson Hsieh.
+
+        Typesafe flags.
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphs):
+        * editing/Editor.cpp:
+        (WebCore::TemporarySelectionChange::TemporarySelectionChange):
+        (WebCore::Editor::replaceSelectionWithFragment):
+        (WebCore::Editor::appliedEditing):
+        (WebCore::Editor::selectComposition):
+        (WebCore::Editor::changeSelectionAfterCommand):
+        (WebCore::Editor::respondToChangedSelection):
+        * editing/Editor.h:
+        (WebCore::TemporarySelectionChange::TemporarySelectionChange):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::moveWithoutValidationTo):
+        (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
+        (WebCore::FrameSelection::setSelection):
+        (WebCore::FrameSelection::setSelectedRange):
+        * editing/FrameSelection.h:
+        (WebCore::FrameSelection::defaultSetSelectionOptions):
+        * editing/MoveSelectionCommand.cpp:
+        (WebCore::MoveSelectionCommand::doApply):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand):
+        * editing/ReplaceSelectionCommand.h:
+        (WebCore::ReplaceSelectionCommand::create):
+        * editing/SetSelectionCommand.cpp:
+        (WebCore::SetSelectionCommand::SetSelectionCommand):
+        * editing/SetSelectionCommand.h:
+        (WebCore::SetSelectionCommand::create):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+        * page/DragController.cpp:
+        (WebCore::DragController::concludeEditDrag):
+        * page/TextIndicator.cpp:
+        (WebCore::TextIndicator::createWithRange):
+
 2018-08-13  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][Floating] Add basic clearance support
index d6fd73c23acb31735d8c6d3af56a3ab7fb819268..ea15a0803c1ce83896ce40f142e43aa0eeee056a 100644 (file)
@@ -1489,7 +1489,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
 
     setEndingSelection(VisibleSelection(destination, originalIsDirectional));
     ASSERT(endingSelection().isCaretOrRange());
-    ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MovingParagraph;
+    OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::SelectReplacement, ReplaceSelectionCommand::MovingParagraph };
     if (!preserveStyle)
         options |= ReplaceSelectionCommand::MatchStyle;
     applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(fragment), options));
index 2ec089ee5ce582f0131241d8a23312cf0f1ed1b3..a317b5cf3b2ad49c55cfd504ec389cbcca9c8f6c 100644 (file)
@@ -190,7 +190,7 @@ using namespace HTMLNames;
 using namespace WTF;
 using namespace Unicode;
 
-TemporarySelectionChange::TemporarySelectionChange(Frame& frame, std::optional<VisibleSelection> temporarySelection, TemporarySelectionOptions options)
+TemporarySelectionChange::TemporarySelectionChange(Frame& frame, std::optional<VisibleSelection> temporarySelection, OptionSet<TemporarySelectionOption> options)
     : m_frame(frame)
     , m_options(options)
     , m_wasIgnoringSelectionChanges(frame.editor().ignoreSelectionChanges())
@@ -635,7 +635,7 @@ void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selec
     if (AXObjectCache::accessibilityEnabled() && editingAction == EditActionPaste)
         replacedText = AccessibilityReplacedText(selection);
 
-    ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment;
+    OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::PreventNesting, ReplaceSelectionCommand::SanitizeFragment };
     if (selectReplacement)
         options |= ReplaceSelectionCommand::SelectReplacement;
     if (smartReplace)
@@ -1073,7 +1073,9 @@ void Editor::appliedEditing(CompositeEditCommand& command)
 
     if (command.isTopLevelCommand()) {
         // Don't clear the typing style with this selection change. We do those things elsewhere if necessary.
-        FrameSelection::SetSelectionOptions options = command.isDictationCommand() ? FrameSelection::DictationTriggered : 0;
+        OptionSet<FrameSelection::SetSelectionOption> options;
+        if (command.isDictationCommand())
+            options |= FrameSelection::DictationTriggered;
 
         changeSelectionAfterCommand(newSelection, options);
     }
@@ -1781,7 +1783,7 @@ void Editor::selectComposition()
     // See <http://bugs.webkit.org/show_bug.cgi?id=15781>
     VisibleSelection selection;
     selection.setWithoutValidation(range->startPosition(), range->endPosition());
-    m_frame.selection().setSelection(selection, 0);
+    m_frame.selection().setSelection(selection, { });
 }
 
 void Editor::confirmComposition()
@@ -2984,7 +2986,7 @@ void Editor::setIgnoreSelectionChanges(bool ignore, RevealSelection shouldReveal
 #if PLATFORM(IOS)
     // FIXME: Should suppress selection change notifications during a composition change <https://webkit.org/b/38830> 
     if (!ignore)
-        respondToChangedSelection(m_frame.selection().selection(), 0);
+        respondToChangedSelection(m_frame.selection().selection(), { });
 #endif
     if (!ignore && shouldRevealExistingSelection == RevealSelection::Yes)
         revealSelectionAfterEditingOperation(ScrollAlignment::alignToEdgeIfNeeded, RevealExtent);
@@ -3107,7 +3109,7 @@ void Editor::dismissCorrectionPanelAsIgnored()
     m_alternativeTextController->dismiss(ReasonForDismissingAlternativeTextIgnored);
 }
 
-void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions options)
+void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, OptionSet<FrameSelection::SetSelectionOption> options)
 {
     Ref<Frame> protection(m_frame);
 
@@ -3470,7 +3472,7 @@ void Editor::selectionWillChange()
 }
 #endif
 
-void Editor::respondToChangedSelection(const VisibleSelection&, FrameSelection::SetSelectionOptions options)
+void Editor::respondToChangedSelection(const VisibleSelection&, OptionSet<FrameSelection::SetSelectionOption> options)
 {
 #if PLATFORM(IOS)
     // FIXME: Should suppress selection change notifications during a composition change <https://webkit.org/b/38830> 
@@ -3492,9 +3494,8 @@ void Editor::respondToChangedSelection(const VisibleSelection&, FrameSelection::
         return;
 
     // Don't check spelling and grammar if the change of selection is triggered by spelling correction itself.
-    m_editorUIUpdateTimerShouldCheckSpellingAndGrammar = options & FrameSelection::CloseTyping
-        && !(options & FrameSelection::SpellCorrectionTriggered);
-    m_editorUIUpdateTimerWasTriggeredByDictation = options & FrameSelection::DictationTriggered;
+    m_editorUIUpdateTimerShouldCheckSpellingAndGrammar = options.contains(FrameSelection::CloseTyping) && !options.contains(FrameSelection::SpellCorrectionTriggered);
+    m_editorUIUpdateTimerWasTriggeredByDictation = options.contains(FrameSelection::DictationTriggered);
     scheduleEditorUIUpdate();
 }
 
index 17a86f26fb278f231cf6020e195e9b4270c3963a..8ad78820b2251fdd0cfe6e3e34b03903bc841b32 100644 (file)
@@ -99,9 +99,6 @@ struct AttachmentDisplayOptions;
 #endif
 
 enum TemporarySelectionOption : uint8_t {
-    // By default, no additional options are enabled.
-    TemporarySelectionOptionDefault = 0,
-
     // Scroll to reveal the selection.
     TemporarySelectionOptionRevealSelection = 1 << 0,
 
@@ -112,16 +109,14 @@ enum TemporarySelectionOption : uint8_t {
     TemporarySelectionOptionEnableAppearanceUpdates = 1 << 2
 };
 
-using TemporarySelectionOptions = uint8_t;
-
 class TemporarySelectionChange {
 public:
-    TemporarySelectionChange(Frame&, std::optional<VisibleSelection> = std::nullopt, TemporarySelectionOptions = TemporarySelectionOptionDefault);
+    TemporarySelectionChange(Frame&, std::optional<VisibleSelection> = std::nullopt, OptionSet<TemporarySelectionOption> = { });
     ~TemporarySelectionChange();
 
 private:
     Ref<Frame> m_frame;
-    TemporarySelectionOptions m_options;
+    OptionSet<TemporarySelectionOption> m_options;
     bool m_wasIgnoringSelectionChanges;
 #if PLATFORM(IOS)
     bool m_appearanceUpdatesWereEnabled;
@@ -414,7 +409,7 @@ public:
     WEBCORE_EXPORT IntRect firstRectForRange(Range*) const;
 
     void selectionWillChange();
-    void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
+    void respondToChangedSelection(const VisibleSelection& oldSelection, OptionSet<FrameSelection::SetSelectionOption>);
     WEBCORE_EXPORT void updateEditorUINowIfScheduled();
     bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const;
     WEBCORE_EXPORT unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches, Vector<RefPtr<Range>>*);
@@ -541,7 +536,7 @@ private:
     enum SetCompositionMode { ConfirmComposition, CancelComposition };
     void setComposition(const String&, SetCompositionMode);
 
-    void changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions);
+    void changeSelectionAfterCommand(const VisibleSelection& newSelection, OptionSet<FrameSelection::SetSelectionOption>);
 
     enum EditorActionSpecifier { CutAction, CopyAction };
     void performCutOrCopy(EditorActionSpecifier);
index 3bd394631950aad1f64165605e4902219084b42e..ce31fb96507791100c83c47206271777342a4e1f 100644 (file)
@@ -185,7 +185,7 @@ void FrameSelection::moveWithoutValidationTo(const Position& base, const Positio
     newSelection.setWithoutValidation(base, extent);
     newSelection.setIsDirectional(selectionHasDirection);
     AXTextStateChangeIntent newIntent = intent.type == AXTextStateChangeTypeUnknown ? AXTextStateChangeIntent(AXTextStateChangeTypeSelectionMove, AXTextSelection { AXTextSelectionDirectionDiscontiguous, AXTextSelectionGranularityUnknown, false }) : intent;
-    SetSelectionOptions options = defaultSetSelectionOptions();
+    auto options = defaultSetSelectionOptions();
     if (!shouldSetFocus)
         options |= DoNotSetFocus;
     switch (revealMode) {
@@ -291,10 +291,10 @@ void FrameSelection::setSelectionByMouseIfDifferent(const VisibleSelection& pass
     setSelection(newSelection, defaultSetSelectionOptions() | FireSelectEvent, intent, AlignCursorOnScrollIfNeeded, granularity);
 }
 
-bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelection& newSelectionPossiblyWithoutDirection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity)
+bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelection& newSelectionPossiblyWithoutDirection, OptionSet<SetSelectionOption> options, CursorAlignOnScroll align, TextGranularity granularity)
 {
-    bool closeTyping = options & CloseTyping;
-    bool shouldClearTypingStyle = options & ClearTypingStyle;
+    bool closeTyping = options.contains(CloseTyping);
+    bool shouldClearTypingStyle = options.contains(ClearTypingStyle);
 
     VisibleSelection newSelection = newSelectionPossiblyWithoutDirection;
     if (shouldAlwaysUseDirectionalSelection(m_frame))
@@ -338,7 +338,7 @@ bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelectio
 
     // Selection offsets should increase when LF is inserted before the caret in InsertLineBreakCommand. See <https://webkit.org/b/56061>.
     if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(newSelection.start()))
-        textControl->selectionChanged(options & FireSelectEvent);
+        textControl->selectionChanged(options.contains(FireSelectEvent));
 
     if (!didMutateSelection)
         return false;
@@ -358,7 +358,7 @@ bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelectio
     return true;
 }
 
-void FrameSelection::setSelection(const VisibleSelection& selection, SetSelectionOptions options, AXTextStateChangeIntent intent, CursorAlignOnScroll align, TextGranularity granularity)
+void FrameSelection::setSelection(const VisibleSelection& selection, OptionSet<SetSelectionOption> options, AXTextStateChangeIntent intent, CursorAlignOnScroll align, TextGranularity granularity)
 {
     RefPtr<Frame> protectedFrame(m_frame);
     if (!setSelectionWithoutUpdatingAppearance(selection, options, align, granularity))
@@ -1993,15 +1993,22 @@ bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool clo
         return false;
 #endif
 
+    OptionSet<SetSelectionOption> selectionOptions {  ClearTypingStyle };
+    if (closeTyping)
+        selectionOptions |= CloseTyping;
+
     if (userTriggered == UserTriggered) {
         FrameSelection trialFrameSelection;
-        trialFrameSelection.setSelection(newSelection, ClearTypingStyle | (closeTyping ? CloseTyping : 0));
+
+        trialFrameSelection.setSelection(newSelection, selectionOptions);
 
         if (!shouldChangeSelection(trialFrameSelection.selection()))
             return false;
+
+        selectionOptions |= IsUserTriggered;
     }
 
-    setSelection(newSelection, ClearTypingStyle | (closeTyping ? CloseTyping : 0) | (userTriggered == UserTriggered ? IsUserTriggered : 0));
+    setSelection(newSelection, selectionOptions);
     return true;
 }
 
@@ -2690,7 +2697,8 @@ void FrameSelection::selectRangeOnElement(unsigned location, unsigned length, No
     resultRange->setStart(node, location);
     resultRange->setEnd(node, location + length);
     VisibleSelection selection = VisibleSelection(*resultRange, SEL_DEFAULT_AFFINITY);
-    setSelection(selection, true);
+    // FIXME: The second argument was "true" which implicitly converted to option "FireSelectEvent". Is this correct?
+    setSelection(selection, { FireSelectEvent });
 }
 
 VisibleSelection FrameSelection::wordSelectionContainingCaretSelection(const VisibleSelection& selection)
index 3c5c714cb10494ee3634ec38fb5abf08875008ab..2d1d918725337b33b71c19a720143038a883a8ad 100644 (file)
@@ -129,10 +129,12 @@ public:
         RevealSelection = 1 << 7,
         RevealSelectionUpToMainFrame = 1 << 8,
     };
-    typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOption and EUserTriggered
-    static inline SetSelectionOptions defaultSetSelectionOptions(EUserTriggered userTriggered = NotUserTriggered)
+    static constexpr OptionSet<SetSelectionOption> defaultSetSelectionOptions(EUserTriggered userTriggered = NotUserTriggered)
     {
-        return CloseTyping | ClearTypingStyle | (userTriggered ? (RevealSelection | FireSelectEvent | IsUserTriggered) : 0);
+        OptionSet<SetSelectionOption> options { CloseTyping, ClearTypingStyle };
+        if (userTriggered == UserTriggered)
+            options |= { RevealSelection, FireSelectEvent, IsUserTriggered };
+        return options;
     }
 
     WEBCORE_EXPORT explicit FrameSelection(Frame* = nullptr);
@@ -147,7 +149,7 @@ public:
     void moveWithoutValidationTo(const Position&, const Position&, bool selectionHasDirection, bool shouldSetFocus, SelectionRevealMode, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
 
     const VisibleSelection& selection() const { return m_selection; }
-    WEBCORE_EXPORT void setSelection(const VisibleSelection&, SetSelectionOptions = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
+    WEBCORE_EXPORT void setSelection(const VisibleSelection&, OptionSet<SetSelectionOption> = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
     WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, bool closeTyping, EUserTriggered = NotUserTriggered);
     WEBCORE_EXPORT void selectAll();
     WEBCORE_EXPORT void clear();
@@ -282,7 +284,7 @@ private:
     void updateAndRevealSelection(const AXTextStateChangeIntent&);
     void updateDataDetectorsForSelection();
 
-    bool setSelectionWithoutUpdatingAppearance(const VisibleSelection&, SetSelectionOptions, CursorAlignOnScroll, TextGranularity);
+    bool setSelectionWithoutUpdatingAppearance(const VisibleSelection&, OptionSet<SetSelectionOption>, CursorAlignOnScroll, TextGranularity);
 
     void respondToNodeModification(Node&, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved);
     TextDirection directionOfEnclosingBlock();
index 9f1eee650686585f72353b6d9c223f80f91d3cd8..854a086f2fefb16dffd4ec9a88ac3d9a2ec7611d 100644 (file)
@@ -82,7 +82,7 @@ void MoveSelectionCommand::doApply()
         // Document was modified out from under us.
         return;
     }
-    ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
+    OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::SelectReplacement, ReplaceSelectionCommand::PreventNesting };
     if (m_smartInsert)
         options |= ReplaceSelectionCommand::SmartReplace;
 
index de97b5ca5d7c46ea3b5b77208c0dec88bafb1268..66d86ac15ceb12148960e691cc8aec4eb3914203 100644 (file)
@@ -377,7 +377,7 @@ inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node* node, N
         m_lastNodeInserted = newNode;
 }
 
-ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, RefPtr<DocumentFragment>&& fragment, CommandOptions options, EditAction editAction)
+ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, RefPtr<DocumentFragment>&& fragment, OptionSet<CommandOption> options, EditAction editAction)
     : CompositeEditCommand(document, editAction)
     , m_selectReplacement(options & SelectReplacement)
     , m_smartReplace(options & SmartReplace)
index c8d3695b6a40108c3dc88c4f8512161f2da2cfdd..58c7e94a48b9d7ce45f83f0cc9aba48ee31002df 100644 (file)
@@ -45,9 +45,7 @@ public:
         IgnoreMailBlockquote = 1 << 6,
     };
 
-    typedef unsigned CommandOptions;
-
-    static Ref<ReplaceSelectionCommand> create(Document& document, RefPtr<DocumentFragment>&& fragment, CommandOptions options, EditAction editingAction = EditActionInsert)
+    static Ref<ReplaceSelectionCommand> create(Document& document, RefPtr<DocumentFragment>&& fragment, OptionSet<CommandOption> options, EditAction editingAction = EditActionInsert)
     {
         return adoptRef(*new ReplaceSelectionCommand(document, WTFMove(fragment), options, editingAction));
     }
@@ -55,7 +53,7 @@ public:
     VisibleSelection visibleSelectionForInsertedText() const { return m_visibleSelectionForInsertedText; }
 
 private:
-    ReplaceSelectionCommand(Document&, RefPtr<DocumentFragment>&&, CommandOptions, EditAction);
+    ReplaceSelectionCommand(Document&, RefPtr<DocumentFragment>&&, OptionSet<CommandOption>, EditAction);
 
     String inputEventData() const final;
     RefPtr<DataTransfer> inputEventDataTransfer() const final;
index 00a4d561d2be6db9825a415dcf346c3f863b28e9..c065c02ca13fd25170d6b21b1f898e9ba79be638 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace WebCore {
 
-SetSelectionCommand::SetSelectionCommand(const VisibleSelection& selection, FrameSelection::SetSelectionOptions options)
+SetSelectionCommand::SetSelectionCommand(const VisibleSelection& selection, OptionSet<FrameSelection::SetSelectionOption> options)
     : SimpleEditCommand(selection.base().anchorNode()->document())
     , m_options(options)
     , m_selectionToSet(selection)
index 897c4d9ace172cb109581db2fe074d889ff2daa3..f6c9f0630b5ff1b8ba1cd5924ced15cc39a3fbbe 100644 (file)
@@ -32,13 +32,13 @@ namespace WebCore {
 
 class SetSelectionCommand : public SimpleEditCommand {
 public:
-    static Ref<SetSelectionCommand> create(const VisibleSelection& selection, FrameSelection::SetSelectionOptions options)
+    static Ref<SetSelectionCommand> create(const VisibleSelection& selection, OptionSet<FrameSelection::SetSelectionOption> options)
     {
         return adoptRef(*new SetSelectionCommand(selection, options));
     }
 
 private:
-    SetSelectionCommand(const VisibleSelection&, FrameSelection::SetSelectionOptions);
+    SetSelectionCommand(const VisibleSelection&, OptionSet<FrameSelection::SetSelectionOption>);
 
     void doApply() override;
     void doUnapply() override;
@@ -47,7 +47,7 @@ private:
     void getNodesInCommand(HashSet<Node*>&) override { }
 #endif
 
-    FrameSelection::SetSelectionOptions m_options;
+    OptionSet<FrameSelection::SetSelectionOption> m_options;
     VisibleSelection m_selectionToSet;
 };
 
index 8cd84183d0af5c06b5daaeaaf9d9c0772a5585b0..e3656f06ab4ecbc4d7e565eddf96bc6d3c2170a0 100644 (file)
@@ -360,7 +360,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuAction action, co
     case ContextMenuItemTagSpellingGuess: {
         VisibleSelection selection = frame->selection().selection();
         if (frame->editor().shouldInsertText(title, selection.toNormalizedRange().get(), EditorInsertAction::Pasted)) {
-            ReplaceSelectionCommand::CommandOptions replaceOptions = ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting;
+            OptionSet<ReplaceSelectionCommand::CommandOption> replaceOptions { ReplaceSelectionCommand::MatchStyle, ReplaceSelectionCommand::PreventNesting };
 
             if (frame->editor().behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
                 ASSERT(selection.isCaretOrRange());
index 6eb63bb85521fe9b49cbcf64c5c06c4d2150cd67..6c49e66983452dfdd8d7064dda461290f559a2a7 100644 (file)
@@ -595,7 +595,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
             MoveSelectionCommand::create(fragment.releaseNonNull(), dragCaret.base(), smartInsert, smartDelete)->apply();
         } else {
             if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) {
-                ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
+                OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::SelectReplacement, ReplaceSelectionCommand::PreventNesting };
                 if (dragData.canSmartReplace())
                     options |= ReplaceSelectionCommand::SmartReplace;
                 if (chosePlainText)
@@ -617,7 +617,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
             return true;
 
         if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point))
-            ReplaceSelectionCommand::create(*m_documentUnderMouse, fragment.get(), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting, EditActionInsertFromDrop)->apply();
+            ReplaceSelectionCommand::create(*m_documentUnderMouse, fragment.get(), { ReplaceSelectionCommand::SelectReplacement, ReplaceSelectionCommand::MatchStyle, ReplaceSelectionCommand::PreventNesting }, EditActionInsertFromDrop)->apply();
     }
 
     if (rootEditableElement) {
index 611585d2d2719dea34f5903f0ca57ca036f2aa47..a3746e0f9730913778451839fbff1de84760bb95 100644 (file)
@@ -78,7 +78,7 @@ RefPtr<TextIndicator> TextIndicator::createWithRange(const Range& range, TextInd
     Ref<Frame> protector(*frame);
 
     VisibleSelection oldSelection = frame->selection().selection();
-    TemporarySelectionOptions temporarySelectionOptions = TemporarySelectionOptionDefault;
+    OptionSet<TemporarySelectionOption> temporarySelectionOptions;
 #if PLATFORM(IOS)
     temporarySelectionOptions |= TemporarySelectionOptionIgnoreSelectionChanges;
     temporarySelectionOptions |= TemporarySelectionOptionEnableAppearanceUpdates;
index 960eda8194a97605d01df33afdb0a4288a0bc360..509650ac913c6ad4dae0c8482d6ff4507cf1330d 100644 (file)
@@ -643,7 +643,7 @@ using namespace WebCore;
             break;
     }
     FrameSelection& frameSelection = _private->coreFrame->selection();
-    frameSelection.setSelection(frameSelection.selection(), wcGranularity);
+    frameSelection.setSelection(frameSelection.selection(), { }, { }, { }, wcGranularity);
 }
 
 static inline bool isAlphaNumericCharacter(UChar32 c)
index 81de2c08632c9dfbb9c671355e3b891e5eee4cb1..58d51368a08877cf72f1839fed2d957ef210fd64 100644 (file)
@@ -1247,7 +1247,7 @@ static WebFrameLoadType toWebFrameLoadType(FrameLoadType frameLoadType)
     RefPtr<Range> domRange = [self _convertToDOMRange:range];
     if (domRange) {
         const VisibleSelection& newSelection = VisibleSelection(*domRange, SEL_DEFAULT_AFFINITY);
-        _private->coreFrame->selection().setSelection(newSelection, 0);
+        _private->coreFrame->selection().setSelection(newSelection, { });
         
         _private->coreFrame->editor().ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
     }