Refactor WebCore::EditAction to be an 8-bit enum class
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 03:04:53 +0000 (03:04 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 03:04:53 +0000 (03:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189383

Reviewed by Dan Bernstein.

Source/WebCore:

Currently, EditAction.h defines an EditAction as an enum. This patch changes EditAction to instead be an 8-bit-
wide enum class, and renames all EditAction values from EditAction(*) to EditAction::(*).

No change in behavior.

* editing/ApplyStyleCommand.h:
(WebCore::ApplyStyleCommand::create):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::apply):
(WebCore::deleteSelectionEditingActionForEditingAction):
* editing/CompositeEditCommand.h:
(WebCore::EditCommandComposition::wasCreateLinkCommand const):
* editing/CreateLinkCommand.h:
* editing/DeleteFromTextNodeCommand.h:
(WebCore::DeleteFromTextNodeCommand::create):
* editing/DeleteSelectionCommand.h:
(WebCore::DeleteSelectionCommand::create):
* editing/DictationCommand.cpp:
(WebCore::DictationCommand::insertTextRunWithoutNewlines):
(WebCore::DictationCommand::insertParagraphSeparator):
* editing/EditAction.h:
(): Deleted.
* editing/EditCommand.cpp:
(WebCore::inputTypeNameForEditingAction):
* editing/EditCommand.h:
* editing/Editor.cpp:
(WebCore::inputEventDataForEditingStyleAndAction):
(WebCore::ClearTextCommand::editingAction const):
(WebCore::Editor::handleTextEvent):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::performCutOrCopy):
(WebCore::Editor::setBaseWritingDirection):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::changeBackToReplacedString):
(WebCore::Editor::transpose):
* editing/Editor.h:
* editing/EditorCommand.cpp:
(WebCore::applyCommandToFrame):
(WebCore::executeInsertFragment):
(WebCore::executeBackColor):
(WebCore::executeFontName):
(WebCore::executeFontSize):
(WebCore::executeFontSizeDelta):
(WebCore::executeForeColor):
(WebCore::executeJustifyCenter):
(WebCore::executeJustifyFull):
(WebCore::executeJustifyLeft):
(WebCore::executeJustifyRight):
(WebCore::executeMakeTextWritingDirectionLeftToRight):
(WebCore::executeMakeTextWritingDirectionNatural):
(WebCore::executeMakeTextWritingDirectionRightToLeft):
(WebCore::executeStrikethrough):
(WebCore::executeSubscript):
(WebCore::executeSuperscript):
(WebCore::executeToggleBold):
(WebCore::executeToggleItalic):
(WebCore::executeUnderline):
(WebCore::executeUnscript):
* editing/FormatBlockCommand.h:
* editing/IndentOutdentCommand.h:
* editing/InsertIntoTextNodeCommand.h:
(WebCore::InsertIntoTextNodeCommand::create):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::editingAction const):
* editing/InsertNodeBeforeCommand.h:
(WebCore::InsertNodeBeforeCommand::create):
* editing/InsertParagraphSeparatorCommand.h:
(WebCore::InsertParagraphSeparatorCommand::create):
* editing/InsertTextCommand.h:
(WebCore::InsertTextCommand::create):
(WebCore::InsertTextCommand::createWithMarkerSupplier):
* editing/MoveSelectionCommand.cpp:
(WebCore::MoveSelectionCommand::doApply):
(WebCore::MoveSelectionCommand::editingAction const):
* editing/RemoveFormatCommand.h:
* editing/RemoveNodeCommand.h:
(WebCore::RemoveNodeCommand::create):
* editing/ReplaceRangeWithTextCommand.cpp:
(WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):
(WebCore::ReplaceRangeWithTextCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::completeHTMLReplacement):
(WebCore::ReplaceSelectionCommand::performTrivialReplace):
* editing/ReplaceSelectionCommand.h:
(WebCore::ReplaceSelectionCommand::create):
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
(WebCore::SpellingCorrectionCommand::doApply):
* editing/TextInsertionBaseCommand.h:
* editing/TypingCommand.cpp:
(WebCore::editActionForTypingCommand):
(WebCore::editActionIsDeleteByTyping):
(WebCore::TypingCommand::isBeforeInputEventCancelable const):
(WebCore::TypingCommand::inputEventData const):
(WebCore::TypingCommand::inputEventDataTransfer const):
(WebCore::TypingCommand::insertTextRunWithoutNewlines):
(WebCore::TypingCommand::insertParagraphSeparator):
* editing/UnlinkCommand.h:
* editing/ios/DictationCommandIOS.cpp:
(WebCore::DictationCommandIOS::DictationCommandIOS):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::removeUnchangeableStyles):
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag):

Source/WebKit:

* UIProcess/WebEditCommandProxy.cpp:
(WebKit::WebEditCommandProxy::nameForEditAction):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::changeFontAttributes):
(WebKit::WebPage::changeFont):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.mm:
(undoNameForEditAction):
* WebView/WebHTMLView.mm:
(-[WebHTMLView pasteFont:]):
(-[WebHTMLView changeFont:]):
(-[WebHTMLView changeAttributes:]):
(-[WebHTMLView _undoActionFromColorPanelWithSelector:]):
(-[WebHTMLView changeColor:]):
* WebView/WebView.mm:
(-[WebView setTypingStyle:]):

Source/WebKitLegacy/win:

* WebCoreSupport/WebEditorClient.cpp:
(undoNameForEditAction):

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

43 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/ApplyStyleCommand.h
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/CreateLinkCommand.h
Source/WebCore/editing/DeleteFromTextNodeCommand.h
Source/WebCore/editing/DeleteSelectionCommand.h
Source/WebCore/editing/DictationCommand.cpp
Source/WebCore/editing/EditAction.h
Source/WebCore/editing/EditCommand.cpp
Source/WebCore/editing/EditCommand.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/FormatBlockCommand.h
Source/WebCore/editing/IndentOutdentCommand.h
Source/WebCore/editing/InsertIntoTextNodeCommand.h
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/InsertNodeBeforeCommand.h
Source/WebCore/editing/InsertParagraphSeparatorCommand.h
Source/WebCore/editing/InsertTextCommand.h
Source/WebCore/editing/MoveSelectionCommand.cpp
Source/WebCore/editing/RemoveFormatCommand.h
Source/WebCore/editing/RemoveNodeCommand.h
Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.h
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/TextInsertionBaseCommand.h
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/UnlinkCommand.h
Source/WebCore/editing/ios/DictationCommandIOS.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/page/DragController.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebEditCommandProxy.cpp
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp

index 39d5c3b..c34c8f5 100644 (file)
@@ -1,3 +1,115 @@
+2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor WebCore::EditAction to be an 8-bit enum class
+        https://bugs.webkit.org/show_bug.cgi?id=189383
+
+        Reviewed by Dan Bernstein.
+
+        Currently, EditAction.h defines an EditAction as an enum. This patch changes EditAction to instead be an 8-bit-
+        wide enum class, and renames all EditAction values from EditAction(*) to EditAction::(*).
+
+        No change in behavior.
+
+        * editing/ApplyStyleCommand.h:
+        (WebCore::ApplyStyleCommand::create):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::apply):
+        (WebCore::deleteSelectionEditingActionForEditingAction):
+        * editing/CompositeEditCommand.h:
+        (WebCore::EditCommandComposition::wasCreateLinkCommand const):
+        * editing/CreateLinkCommand.h:
+        * editing/DeleteFromTextNodeCommand.h:
+        (WebCore::DeleteFromTextNodeCommand::create):
+        * editing/DeleteSelectionCommand.h:
+        (WebCore::DeleteSelectionCommand::create):
+        * editing/DictationCommand.cpp:
+        (WebCore::DictationCommand::insertTextRunWithoutNewlines):
+        (WebCore::DictationCommand::insertParagraphSeparator):
+        * editing/EditAction.h:
+        (): Deleted.
+        * editing/EditCommand.cpp:
+        (WebCore::inputTypeNameForEditingAction):
+        * editing/EditCommand.h:
+        * editing/Editor.cpp:
+        (WebCore::inputEventDataForEditingStyleAndAction):
+        (WebCore::ClearTextCommand::editingAction const):
+        (WebCore::Editor::handleTextEvent):
+        (WebCore::Editor::replaceSelectionWithFragment):
+        (WebCore::Editor::performCutOrCopy):
+        (WebCore::Editor::setBaseWritingDirection):
+        (WebCore::Editor::markMisspellingsAfterTypingToWord):
+        (WebCore::Editor::changeBackToReplacedString):
+        (WebCore::Editor::transpose):
+        * editing/Editor.h:
+        * editing/EditorCommand.cpp:
+        (WebCore::applyCommandToFrame):
+        (WebCore::executeInsertFragment):
+        (WebCore::executeBackColor):
+        (WebCore::executeFontName):
+        (WebCore::executeFontSize):
+        (WebCore::executeFontSizeDelta):
+        (WebCore::executeForeColor):
+        (WebCore::executeJustifyCenter):
+        (WebCore::executeJustifyFull):
+        (WebCore::executeJustifyLeft):
+        (WebCore::executeJustifyRight):
+        (WebCore::executeMakeTextWritingDirectionLeftToRight):
+        (WebCore::executeMakeTextWritingDirectionNatural):
+        (WebCore::executeMakeTextWritingDirectionRightToLeft):
+        (WebCore::executeStrikethrough):
+        (WebCore::executeSubscript):
+        (WebCore::executeSuperscript):
+        (WebCore::executeToggleBold):
+        (WebCore::executeToggleItalic):
+        (WebCore::executeUnderline):
+        (WebCore::executeUnscript):
+        * editing/FormatBlockCommand.h:
+        * editing/IndentOutdentCommand.h:
+        * editing/InsertIntoTextNodeCommand.h:
+        (WebCore::InsertIntoTextNodeCommand::create):
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::editingAction const):
+        * editing/InsertNodeBeforeCommand.h:
+        (WebCore::InsertNodeBeforeCommand::create):
+        * editing/InsertParagraphSeparatorCommand.h:
+        (WebCore::InsertParagraphSeparatorCommand::create):
+        * editing/InsertTextCommand.h:
+        (WebCore::InsertTextCommand::create):
+        (WebCore::InsertTextCommand::createWithMarkerSupplier):
+        * editing/MoveSelectionCommand.cpp:
+        (WebCore::MoveSelectionCommand::doApply):
+        (WebCore::MoveSelectionCommand::editingAction const):
+        * editing/RemoveFormatCommand.h:
+        * editing/RemoveNodeCommand.h:
+        (WebCore::RemoveNodeCommand::create):
+        * editing/ReplaceRangeWithTextCommand.cpp:
+        (WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):
+        (WebCore::ReplaceRangeWithTextCommand::doApply):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::completeHTMLReplacement):
+        (WebCore::ReplaceSelectionCommand::performTrivialReplace):
+        * editing/ReplaceSelectionCommand.h:
+        (WebCore::ReplaceSelectionCommand::create):
+        * editing/SpellingCorrectionCommand.cpp:
+        (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
+        (WebCore::SpellingCorrectionCommand::doApply):
+        * editing/TextInsertionBaseCommand.h:
+        * editing/TypingCommand.cpp:
+        (WebCore::editActionForTypingCommand):
+        (WebCore::editActionIsDeleteByTyping):
+        (WebCore::TypingCommand::isBeforeInputEventCancelable const):
+        (WebCore::TypingCommand::inputEventData const):
+        (WebCore::TypingCommand::inputEventDataTransfer const):
+        (WebCore::TypingCommand::insertTextRunWithoutNewlines):
+        (WebCore::TypingCommand::insertParagraphSeparator):
+        * editing/UnlinkCommand.h:
+        * editing/ios/DictationCommandIOS.cpp:
+        (WebCore::DictationCommandIOS::DictationCommandIOS):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::removeUnchangeableStyles):
+        * page/DragController.cpp:
+        (WebCore::DragController::concludeEditDrag):
+
 2018-09-06  Simon Fraser  <simon.fraser@apple.com>
 
         Fix the build for non-Cocoa platforms after r235772.
index 409fccf..8694551 100644 (file)
@@ -47,19 +47,19 @@ public:
     enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement };
     typedef bool (*IsInlineElementToRemoveFunction)(const Element*);
 
-    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, EditAction action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault)
+    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, EditAction action = EditAction::ChangeAttributes, EPropertyLevel level = PropertyDefault)
     {
         return adoptRef(*new ApplyStyleCommand(document, style, action, level));
     }
-    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, const Position& start, const Position& end, EditAction action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault)
+    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, const Position& start, const Position& end, EditAction action = EditAction::ChangeAttributes, EPropertyLevel level = PropertyDefault)
     {
         return adoptRef(*new ApplyStyleCommand(document, style, start, end, action, level));
     }
-    static Ref<ApplyStyleCommand> create(Ref<Element>&& element, bool removeOnly = false, EditAction action = EditActionChangeAttributes)
+    static Ref<ApplyStyleCommand> create(Ref<Element>&& element, bool removeOnly = false, EditAction action = EditAction::ChangeAttributes)
     {
         return adoptRef(*new ApplyStyleCommand(WTFMove(element), removeOnly, action));
     }
-    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, EditAction action = EditActionChangeAttributes)
+    static Ref<ApplyStyleCommand> create(Document& document, const EditingStyle* style, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, EditAction action = EditAction::ChangeAttributes)
     {
         return adoptRef(*new ApplyStyleCommand(document, style, isInlineElementToRemoveFunction, action));
     }
index b45227b..e5f3392 100644 (file)
@@ -321,30 +321,30 @@ void CompositeEditCommand::apply()
 {
     if (!endingSelection().isContentRichlyEditable()) {
         switch (editingAction()) {
-        case EditActionTypingDeleteSelection:
-        case EditActionTypingDeleteBackward:
-        case EditActionTypingDeleteForward:
-        case EditActionTypingDeleteWordBackward:
-        case EditActionTypingDeleteWordForward:
-        case EditActionTypingDeleteLineBackward:
-        case EditActionTypingDeleteLineForward:
-        case EditActionTypingDeletePendingComposition:
-        case EditActionTypingDeleteFinalComposition:
-        case EditActionTypingInsertText:
-        case EditActionTypingInsertLineBreak:
-        case EditActionTypingInsertParagraph:
-        case EditActionTypingInsertPendingComposition:
-        case EditActionTypingInsertFinalComposition:
-        case EditActionPaste:
-        case EditActionDeleteByDrag:
-        case EditActionSetWritingDirection:
-        case EditActionCut:
-        case EditActionUnspecified:
-        case EditActionInsert:
-        case EditActionInsertReplacement:
-        case EditActionInsertFromDrop:
-        case EditActionDelete:
-        case EditActionDictation:
+        case EditAction::TypingDeleteSelection:
+        case EditAction::TypingDeleteBackward:
+        case EditAction::TypingDeleteForward:
+        case EditAction::TypingDeleteWordBackward:
+        case EditAction::TypingDeleteWordForward:
+        case EditAction::TypingDeleteLineBackward:
+        case EditAction::TypingDeleteLineForward:
+        case EditAction::TypingDeletePendingComposition:
+        case EditAction::TypingDeleteFinalComposition:
+        case EditAction::TypingInsertText:
+        case EditAction::TypingInsertLineBreak:
+        case EditAction::TypingInsertParagraph:
+        case EditAction::TypingInsertPendingComposition:
+        case EditAction::TypingInsertFinalComposition:
+        case EditAction::Paste:
+        case EditAction::DeleteByDrag:
+        case EditAction::SetWritingDirection:
+        case EditAction::Cut:
+        case EditAction::Unspecified:
+        case EditAction::Insert:
+        case EditAction::InsertReplacement:
+        case EditAction::InsertFromDrop:
+        case EditAction::Delete:
+        case EditAction::Dictation:
             break;
         default:
             ASSERT_NOT_REACHED();
@@ -819,10 +819,10 @@ void CompositeEditCommand::insertNodeAtTabSpanPosition(Ref<Node>&& node, const P
 static EditAction deleteSelectionEditingActionForEditingAction(EditAction editingAction)
 {
     switch (editingAction) {
-    case EditActionCut:
-        return EditActionCut;
+    case EditAction::Cut:
+        return EditAction::Cut;
     default:
-        return EditActionDelete;
+        return EditAction::Delete;
     }
 }
 
index d467bf1..4a424a1 100644 (file)
@@ -71,7 +71,7 @@ public:
     void reapply() override;
     EditAction editingAction() const override { return m_editAction; }
     void append(SimpleEditCommand*);
-    bool wasCreateLinkCommand() const { return m_editAction == EditActionCreateLink; }
+    bool wasCreateLinkCommand() const { return m_editAction == EditAction::CreateLink; }
 
     const VisibleSelection& startingSelection() const { return m_startingSelection; }
     const VisibleSelection& endingSelection() const { return m_endingSelection; }
@@ -122,7 +122,7 @@ public:
     virtual RefPtr<DataTransfer> inputEventDataTransfer() const;
 
 protected:
-    explicit CompositeEditCommand(Document&, EditAction = EditActionUnspecified);
+    explicit CompositeEditCommand(Document&, EditAction = EditAction::Unspecified);
 
     // If willApplyCommand returns false, we won't proceed with applying the command.
     virtual bool willApplyCommand();
@@ -136,8 +136,8 @@ protected:
     void appendNode(Ref<Node>&&, Ref<ContainerNode>&& parent);
     void applyCommandToComposite(Ref<EditCommand>&&);
     void applyCommandToComposite(Ref<CompositeEditCommand>&&, const VisibleSelection&);
-    void applyStyle(const EditingStyle*, EditAction = EditActionChangeAttributes);
-    void applyStyle(const EditingStyle*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes);
+    void applyStyle(const EditingStyle*, EditAction = EditAction::ChangeAttributes);
+    void applyStyle(const EditingStyle*, const Position& start, const Position& end, EditAction = EditAction::ChangeAttributes);
     void applyStyledElement(Ref<Element>&&);
     void removeStyledElement(Ref<Element>&&);
     void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true, bool sanitizeMarkup = true);
index 39b98d0..b17f231 100644 (file)
@@ -42,7 +42,7 @@ private:
     CreateLinkCommand(Document&, const String& linkURL);
 
     void doApply() override;
-    EditAction editingAction() const override { return EditActionCreateLink; }
+    EditAction editingAction() const override { return EditAction::CreateLink; }
 
     String m_url;
 };
index b81c62d..da1df6b 100644 (file)
@@ -33,7 +33,7 @@ class Text;
 
 class DeleteFromTextNodeCommand : public SimpleEditCommand {
 public:
-    static Ref<DeleteFromTextNodeCommand> create(Ref<Text>&& node, unsigned offset, unsigned count, EditAction editingAction = EditActionDelete)
+    static Ref<DeleteFromTextNodeCommand> create(Ref<Text>&& node, unsigned offset, unsigned count, EditAction editingAction = EditAction::Delete)
     {
         return adoptRef(*new DeleteFromTextNodeCommand(WTFMove(node), offset, count, editingAction));
     }
index 82cfe2a..233688b 100644 (file)
@@ -33,17 +33,17 @@ class EditingStyle;
 
 class DeleteSelectionCommand : public CompositeEditCommand { 
 public:
-    static Ref<DeleteSelectionCommand> create(Document& document, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true, EditAction editingAction = EditActionDelete)
+    static Ref<DeleteSelectionCommand> create(Document& document, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true, EditAction editingAction = EditAction::Delete)
     {
         return adoptRef(*new DeleteSelectionCommand(document, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup, editingAction));
     }
-    static Ref<DeleteSelectionCommand> create(const VisibleSelection& selection, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true, EditAction editingAction = EditActionDelete)
+    static Ref<DeleteSelectionCommand> create(const VisibleSelection& selection, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true, EditAction editingAction = EditAction::Delete)
     {
         return adoptRef(*new DeleteSelectionCommand(selection, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup, editingAction));
     }
 
 protected:
-    DeleteSelectionCommand(Document&, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool santizeMarkup, EditAction = EditActionDelete);
+    DeleteSelectionCommand(Document&, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool santizeMarkup, EditAction = EditAction::Delete);
 
 private:
     DeleteSelectionCommand(const VisibleSelection&, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup, EditAction);
index 282bdc9..975d41b 100644 (file)
@@ -117,7 +117,7 @@ void DictationCommand::insertTextRunWithoutNewlines(size_t lineStart, size_t lin
 {
     Vector<DictationAlternative> alternativesInLine;
     collectDictationAlternativesInRange(lineStart, lineLength, alternativesInLine);
-    auto command = InsertTextCommand::createWithMarkerSupplier(document(), m_textToInsert.substring(lineStart, lineLength), DictationMarkerSupplier::create(alternativesInLine), EditActionDictation);
+    auto command = InsertTextCommand::createWithMarkerSupplier(document(), m_textToInsert.substring(lineStart, lineLength), DictationMarkerSupplier::create(alternativesInLine), EditAction::Dictation);
     applyCommandToComposite(WTFMove(command), endingSelection());
 }
 
@@ -126,7 +126,7 @@ void DictationCommand::insertParagraphSeparator()
     if (!canAppendNewLineFeedToSelection(endingSelection()))
         return;
 
-    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionDictation));
+    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditAction::Dictation));
 }
 
 void DictationCommand::collectDictationAlternativesInRange(size_t rangeStart, size_t rangeLength, Vector<DictationAlternative>& alternatives)
index 0aba4a5..e812288 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Inc.  All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #pragma once
 
 namespace WebCore {
-    typedef enum {
-        EditActionUnspecified,
-        EditActionInsert,
-        EditActionInsertReplacement,
-        EditActionInsertFromDrop,
-        EditActionSetColor,
-        EditActionSetBackgroundColor,
-        EditActionTurnOffKerning,
-        EditActionTightenKerning,
-        EditActionLoosenKerning,
-        EditActionUseStandardKerning,
-        EditActionTurnOffLigatures,
-        EditActionUseStandardLigatures,
-        EditActionUseAllLigatures,
-        EditActionRaiseBaseline,
-        EditActionLowerBaseline,
-        EditActionSetTraditionalCharacterShape,
-        EditActionSetFont,
-        EditActionChangeAttributes,
-        EditActionAlignLeft,
-        EditActionAlignRight,
-        EditActionCenter,
-        EditActionJustify,
-        EditActionSetWritingDirection,
-        EditActionSubscript,
-        EditActionSuperscript,
-        EditActionUnderline,
-        EditActionOutline,
-        EditActionUnscript,
-        EditActionDeleteByDrag,
-        EditActionCut,
-        EditActionBold,
-        EditActionItalics,
-        EditActionDelete,
-        EditActionDictation,
-        EditActionPaste,
-        EditActionPasteFont,
-        EditActionPasteRuler,
-        EditActionTypingDeleteSelection,
-        EditActionTypingDeleteBackward,
-        EditActionTypingDeleteForward,
-        EditActionTypingDeleteWordBackward,
-        EditActionTypingDeleteWordForward,
-        EditActionTypingDeleteLineBackward,
-        EditActionTypingDeleteLineForward,
-        EditActionTypingDeletePendingComposition,
-        EditActionTypingDeleteFinalComposition,
-        EditActionTypingInsertText,
-        EditActionTypingInsertLineBreak,
-        EditActionTypingInsertParagraph,
-        EditActionTypingInsertPendingComposition,
-        EditActionTypingInsertFinalComposition,
-        EditActionCreateLink,
-        EditActionUnlink,
-        EditActionFormatBlock,
-        EditActionInsertOrderedList,
-        EditActionInsertUnorderedList,
-        EditActionIndent,
-        EditActionOutdent
-    } EditAction;    
+
+enum class EditAction : uint8_t {
+    Unspecified,
+    Insert,
+    InsertReplacement,
+    InsertFromDrop,
+    SetColor,
+    SetBackgroundColor,
+    TurnOffKerning,
+    TightenKerning,
+    LoosenKerning,
+    UseStandardKerning,
+    TurnOffLigatures,
+    UseStandardLigatures,
+    UseAllLigatures,
+    RaiseBaseline,
+    LowerBaseline,
+    SetTraditionalCharacterShape,
+    SetFont,
+    ChangeAttributes,
+    AlignLeft,
+    AlignRight,
+    Center,
+    Justify,
+    SetWritingDirection,
+    Subscript,
+    Superscript,
+    Underline,
+    Outline,
+    Unscript,
+    DeleteByDrag,
+    Cut,
+    Bold,
+    Italics,
+    Delete,
+    Dictation,
+    Paste,
+    PasteFont,
+    PasteRuler,
+    TypingDeleteSelection,
+    TypingDeleteBackward,
+    TypingDeleteForward,
+    TypingDeleteWordBackward,
+    TypingDeleteWordForward,
+    TypingDeleteLineBackward,
+    TypingDeleteLineForward,
+    TypingDeletePendingComposition,
+    TypingDeleteFinalComposition,
+    TypingInsertText,
+    TypingInsertLineBreak,
+    TypingInsertParagraph,
+    TypingInsertPendingComposition,
+    TypingInsertFinalComposition,
+    CreateLink,
+    Unlink,
+    FormatBlock,
+    InsertOrderedList,
+    InsertUnorderedList,
+    Indent,
+    Outdent
+};
+
 } // namespace WebCore
index db1f408..34c79c9 100644 (file)
@@ -42,75 +42,75 @@ namespace WebCore {
 String inputTypeNameForEditingAction(EditAction action)
 {
     switch (action) {
-    case EditActionJustify:
+    case EditAction::Justify:
         return "formatJustifyFull"_s;
-    case EditActionAlignLeft:
+    case EditAction::AlignLeft:
         return "formatJustifyLeft"_s;
-    case EditActionAlignRight:
+    case EditAction::AlignRight:
         return "formatJustifyRight"_s;
-    case EditActionCenter:
+    case EditAction::Center:
         return "formatJustifyCenter"_s;
-    case EditActionSubscript:
+    case EditAction::Subscript:
         return "formatSubscript"_s;
-    case EditActionSuperscript:
+    case EditAction::Superscript:
         return "formatSuperscript"_s;
-    case EditActionUnderline:
+    case EditAction::Underline:
         return "formatUnderline"_s;
-    case EditActionSetColor:
+    case EditAction::SetColor:
         return "formatFontColor"_s;
-    case EditActionDeleteByDrag:
+    case EditAction::DeleteByDrag:
         return "deleteByDrag"_s;
-    case EditActionCut:
+    case EditAction::Cut:
         return "deleteByCut"_s;
-    case EditActionBold:
+    case EditAction::Bold:
         return "formatBold"_s;
-    case EditActionItalics:
+    case EditAction::Italics:
         return "formatItalic"_s;
-    case EditActionPaste:
+    case EditAction::Paste:
         return "insertFromPaste"_s;
-    case EditActionDelete:
-    case EditActionTypingDeleteSelection:
+    case EditAction::Delete:
+    case EditAction::TypingDeleteSelection:
         return "deleteContent"_s;
-    case EditActionTypingDeleteBackward:
+    case EditAction::TypingDeleteBackward:
         return "deleteContentBackward"_s;
-    case EditActionTypingDeleteForward:
+    case EditAction::TypingDeleteForward:
         return "deleteContentForward"_s;
-    case EditActionTypingDeleteWordBackward:
+    case EditAction::TypingDeleteWordBackward:
         return "deleteWordBackward"_s;
-    case EditActionTypingDeleteWordForward:
+    case EditAction::TypingDeleteWordForward:
         return "deleteWordForward"_s;
-    case EditActionTypingDeleteLineBackward:
+    case EditAction::TypingDeleteLineBackward:
         return "deleteHardLineBackward"_s;
-    case EditActionTypingDeleteLineForward:
+    case EditAction::TypingDeleteLineForward:
         return "deleteHardLineForward"_s;
-    case EditActionTypingDeletePendingComposition:
+    case EditAction::TypingDeletePendingComposition:
         return "deleteCompositionText"_s;
-    case EditActionTypingDeleteFinalComposition:
+    case EditAction::TypingDeleteFinalComposition:
         return "deleteByComposition"_s;
-    case EditActionInsert:
-    case EditActionTypingInsertText:
+    case EditAction::Insert:
+    case EditAction::TypingInsertText:
         return "insertText"_s;
-    case EditActionInsertReplacement:
+    case EditAction::InsertReplacement:
         return "insertReplacementText"_s;
-    case EditActionInsertFromDrop:
+    case EditAction::InsertFromDrop:
         return "insertFromDrop"_s;
-    case EditActionTypingInsertLineBreak:
+    case EditAction::TypingInsertLineBreak:
         return "insertLineBreak"_s;
-    case EditActionTypingInsertParagraph:
+    case EditAction::TypingInsertParagraph:
         return "insertParagraph"_s;
-    case EditActionInsertOrderedList:
+    case EditAction::InsertOrderedList:
         return "insertOrderedList"_s;
-    case EditActionInsertUnorderedList:
+    case EditAction::InsertUnorderedList:
         return "insertUnorderedList"_s;
-    case EditActionTypingInsertPendingComposition:
+    case EditAction::TypingInsertPendingComposition:
         return "insertCompositionText"_s;
-    case EditActionTypingInsertFinalComposition:
+    case EditAction::TypingInsertFinalComposition:
         return "insertFromComposition"_s;
-    case EditActionIndent:
+    case EditAction::Indent:
         return "formatIndent"_s;
-    case EditActionOutdent:
+    case EditAction::Outdent:
         return "formatOutdent"_s;
-    case EditActionSetWritingDirection:
+    case EditAction::SetWritingDirection:
         return "formatSetInlineTextDirection"_s;
     default:
         return emptyString();
index 4fc0cb7..debcff0 100644 (file)
@@ -61,7 +61,7 @@ public:
     virtual void doApply() = 0;
 
 protected:
-    explicit EditCommand(Document&, EditAction = EditActionUnspecified);
+    explicit EditCommand(Document&, EditAction = EditAction::Unspecified);
     EditCommand(Document&, const VisibleSelection&, const VisibleSelection&);
 
     const Frame& frame() const;
@@ -82,7 +82,7 @@ private:
     VisibleSelection m_startingSelection;
     VisibleSelection m_endingSelection;
     CompositeEditCommand* m_parent { nullptr };
-    EditAction m_editingAction { EditActionUnspecified };
+    EditAction m_editingAction { EditAction::Unspecified };
 };
 
 enum ShouldAssumeContentIsAlwaysEditable {
@@ -100,7 +100,7 @@ public:
 #endif
 
 protected:
-    explicit SimpleEditCommand(Document&, EditAction = EditActionUnspecified);
+    explicit SimpleEditCommand(Document&, EditAction = EditAction::Unspecified);
 
 #ifndef NDEBUG
     void addNodeAndDescendants(Node*, HashSet<Node*>&);
index eb8f5d2..cf5da79 100644 (file)
@@ -139,9 +139,9 @@ static String inputEventDataForEditingStyleAndAction(const StyleProperties* styl
         return { };
 
     switch (action) {
-    case EditActionSetColor:
+    case EditAction::SetColor:
         return style->getPropertyValue(CSSPropertyColor);
-    case EditActionSetWritingDirection:
+    case EditAction::SetWritingDirection:
         return style->getPropertyValue(CSSPropertyDirection);
     default:
         return { };
@@ -169,7 +169,7 @@ ClearTextCommand::ClearTextCommand(Document& document)
 
 EditAction ClearTextCommand::editingAction() const
 {
-    return EditActionDelete;
+    return EditAction::Delete;
 }
 
 void ClearTextCommand::CreateAndApply(const RefPtr<Frame> frame)
@@ -296,9 +296,9 @@ bool Editor::handleTextEvent(TextEvent& event)
             if (client()->performsTwoStepPaste(event.pastingFragment()))
                 return true;
 #endif
-            replaceSelectionWithFragment(*event.pastingFragment(), false, event.shouldSmartReplace(), event.shouldMatchStyle(), EditActionPaste, event.mailBlockquoteHandling());
+            replaceSelectionWithFragment(*event.pastingFragment(), false, event.shouldSmartReplace(), event.shouldMatchStyle(), EditAction::Paste, event.mailBlockquoteHandling());
         } else
-            replaceSelectionWithText(event.data(), false, event.shouldSmartReplace(), EditActionPaste);
+            replaceSelectionWithText(event.data(), false, event.shouldSmartReplace(), EditAction::Paste);
         return true;
     }
 
@@ -629,7 +629,7 @@ void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selec
         return;
 
     AccessibilityReplacedText replacedText;
-    if (AXObjectCache::accessibilityEnabled() && editingAction == EditActionPaste)
+    if (AXObjectCache::accessibilityEnabled() && editingAction == EditAction::Paste)
         replacedText = AccessibilityReplacedText(selection);
 
     OptionSet<ReplaceSelectionCommand::CommandOption> options { ReplaceSelectionCommand::PreventNesting, ReplaceSelectionCommand::SanitizeFragment };
@@ -650,7 +650,7 @@ void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selec
     if (selection.isInPasswordField())
         return;
 
-    if (AXObjectCache::accessibilityEnabled() && editingAction == EditActionPaste) {
+    if (AXObjectCache::accessibilityEnabled() && editingAction == EditAction::Paste) {
         String text = AccessibilityObject::stringForVisiblePositionRange(command->visibleSelectionForInsertedText());
         replacedText.postTextStateChangeNotification(document().existingAXObjectCache(), AXTextEditTypePaste, text, m_frame.selection().selection());
         command->composition()->setRangeDeletedByUnapply(replacedText.replacedRange());
@@ -1384,7 +1384,7 @@ void Editor::performCutOrCopy(EditorActionSpecifier action)
         String text;
         if (AXObjectCache::accessibilityEnabled())
             text = AccessibilityObject::stringForVisiblePositionRange(m_frame.selection().selection());
-        deleteSelectionWithSmartDelete(canSmartCopyOrDelete(), EditActionCut);
+        deleteSelectionWithSmartDelete(canSmartCopyOrDelete(), EditAction::Cut);
         if (AXObjectCache::accessibilityEnabled())
             postTextStateChangeNotificationForCut(text, m_frame.selection().selection());
     }
@@ -1727,7 +1727,7 @@ void Editor::setBaseWritingDirection(WritingDirection direction)
 
         auto& focusedFormElement = downcast<HTMLTextFormControlElement>(*focusedElement);
         auto directionValue = direction == LeftToRightWritingDirection ? "ltr" : "rtl";
-        auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditActionSetWritingDirection);
+        auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditAction::SetWritingDirection);
         if (!dispatchBeforeInputEvent(focusedFormElement, writingDirectionInputTypeName, directionValue))
             return;
 
@@ -1739,7 +1739,7 @@ void Editor::setBaseWritingDirection(WritingDirection direction)
 
     RefPtr<MutableStyleProperties> style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyDirection, direction == LeftToRightWritingDirection ? "ltr" : direction == RightToLeftWritingDirection ? "rtl" : "inherit", false);
-    applyParagraphStyleToSelection(style.get(), EditActionSetWritingDirection);
+    applyParagraphStyleToSelection(style.get(), EditAction::SetWritingDirection);
 }
 
 WritingDirection Editor::baseWritingDirectionForSelectionStart() const
@@ -2460,7 +2460,7 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
 
         if (!m_frame.editor().shouldInsertText(autocorrectedString, misspellingRange.get(), EditorInsertAction::Typed))
             return;
-        m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false, EditActionInsert);
+        m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false, EditAction::Insert);
 
         // Reset the charet one character further.
         m_frame.selection().moveTo(m_frame.selection().selection().end());
@@ -2818,7 +2818,7 @@ void Editor::changeBackToReplacedString(const String& replacedString)
     
     m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, replacedString, selection.get());
     TextCheckingParagraph paragraph(*selection);
-    replaceSelectionWithText(replacedString, false, false, EditActionInsert);
+    replaceSelectionWithText(replacedString, false, false, EditAction::Insert);
     auto changedRange = paragraph.subrange(paragraph.checkingStart(), replacedString.length());
     changedRange->startContainer().document().markers().addMarker(changedRange.ptr(), DocumentMarker::Replacement, String());
     m_alternativeTextController->markReversed(changedRange);
@@ -3064,7 +3064,7 @@ void Editor::transpose()
     // Insert the transposed characters.
     if (!shouldInsertText(transposed, range.get(), EditorInsertAction::Typed))
         return;
-    replaceSelectionWithText(transposed, false, false, EditActionInsert);
+    replaceSelectionWithText(transposed, false, false, EditAction::Insert);
 }
 
 void Editor::addRangeToKillRing(const Range& range, KillRingInsertionMode mode)
index ab77646..20cbbb6 100644 (file)
@@ -203,16 +203,16 @@ public:
 #endif
 
     WEBCORE_EXPORT bool deleteWithDirection(SelectionDirection, TextGranularity, bool killRing, bool isTypingAction);
-    WEBCORE_EXPORT void deleteSelectionWithSmartDelete(bool smartDelete, EditAction = EditActionDelete);
+    WEBCORE_EXPORT void deleteSelectionWithSmartDelete(bool smartDelete, EditAction = EditAction::Delete);
     void clearText();
 #if PLATFORM(IOS)
     WEBCORE_EXPORT void removeUnchangeableStyles();
 #endif
 
-    WEBCORE_EXPORT void applyStyle(StyleProperties*, EditAction = EditActionUnspecified);
+    WEBCORE_EXPORT void applyStyle(StyleProperties*, EditAction = EditAction::Unspecified);
     enum class ColorFilterMode { InvertColor, UseOriginalColor };
     void applyStyle(RefPtr<EditingStyle>&&, EditAction, ColorFilterMode);
-    void applyParagraphStyle(StyleProperties*, EditAction = EditActionUnspecified);
+    void applyParagraphStyle(StyleProperties*, EditAction = EditAction::Unspecified);
     WEBCORE_EXPORT void applyStyleToSelection(StyleProperties*, EditAction);
     WEBCORE_EXPORT void applyStyleToSelection(Ref<EditingStyle>&&, EditAction, ColorFilterMode);
     void applyParagraphStyleToSelection(StyleProperties*, EditAction);
@@ -400,8 +400,8 @@ public:
     const VisibleSelection& mark() const; // Mark, to be used as emacs uses it.
     void setMark(const VisibleSelection&);
 
-    void computeAndSetTypingStyle(EditingStyle& , EditAction = EditActionUnspecified);
-    WEBCORE_EXPORT void computeAndSetTypingStyle(StyleProperties& , EditAction = EditActionUnspecified);
+    void computeAndSetTypingStyle(EditingStyle& , EditAction = EditAction::Unspecified);
+    WEBCORE_EXPORT void computeAndSetTypingStyle(StyleProperties& , EditAction = EditAction::Unspecified);
     WEBCORE_EXPORT void applyEditingStyleToBodyElement() const;
     void applyEditingStyleToElement(Element*) const;
 
@@ -423,8 +423,8 @@ public:
     void textDidChangeInTextArea(Element*);
     WEBCORE_EXPORT WritingDirection baseWritingDirectionForSelectionStart() const;
 
-    WEBCORE_EXPORT void replaceSelectionWithFragment(DocumentFragment&, bool selectReplacement, bool smartReplace, bool matchStyle, EditAction = EditActionInsert, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
-    WEBCORE_EXPORT void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace, EditAction = EditActionInsert);
+    WEBCORE_EXPORT void replaceSelectionWithFragment(DocumentFragment&, bool selectReplacement, bool smartReplace, bool matchStyle, EditAction = EditAction::Insert, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
+    WEBCORE_EXPORT void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace, EditAction = EditAction::Insert);
     WEBCORE_EXPORT bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
     void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
     void deletedAutocorrectionAtPosition(const Position&, const String& originalString);
index 4c93d4a..cd9ef76 100644 (file)
@@ -105,7 +105,7 @@ static bool applyCommandToFrame(Frame& frame, EditorCommandSource source, EditAc
         return true;
     case CommandFromDOM:
     case CommandFromDOMWithUserInterface:
-        frame.editor().applyStyle(WTFMove(style), EditActionUnspecified, Editor::ColorFilterMode::UseOriginalColor);
+        frame.editor().applyStyle(WTFMove(style), EditAction::Unspecified, Editor::ColorFilterMode::UseOriginalColor);
         return true;
     }
     ASSERT_NOT_REACHED();
@@ -159,7 +159,7 @@ static bool executeApplyParagraphStyle(Frame& frame, EditorCommandSource source,
 static bool executeInsertFragment(Frame& frame, Ref<DocumentFragment>&& fragment)
 {
     ASSERT(frame.document());
-    ReplaceSelectionCommand::create(*frame.document(), WTFMove(fragment), ReplaceSelectionCommand::PreventNesting, EditActionInsert)->apply();
+    ReplaceSelectionCommand::create(*frame.document(), WTFMove(fragment), ReplaceSelectionCommand::PreventNesting, EditAction::Insert)->apply();
     return true;
 }
 
@@ -237,7 +237,7 @@ static RefPtr<Range> unionDOMRanges(Range& a, Range& b)
 
 static bool executeBackColor(Frame& frame, Event*, EditorCommandSource source, const String& value)
 {
-    return executeApplyStyle(frame, source, EditActionSetBackgroundColor, CSSPropertyBackgroundColor, value);
+    return executeApplyStyle(frame, source, EditAction::SetBackgroundColor, CSSPropertyBackgroundColor, value);
 }
 
 static bool executeCopy(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -383,7 +383,7 @@ static bool executeFindString(Frame& frame, Event*, EditorCommandSource, const S
 
 static bool executeFontName(Frame& frame, Event*, EditorCommandSource source, const String& value)
 {
-    return executeApplyStyle(frame, source, EditActionSetFont, CSSPropertyFontFamily, value);
+    return executeApplyStyle(frame, source, EditAction::SetFont, CSSPropertyFontFamily, value);
 }
 
 static bool executeFontSize(Frame& frame, Event*, EditorCommandSource source, const String& value)
@@ -391,17 +391,17 @@ static bool executeFontSize(Frame& frame, Event*, EditorCommandSource source, co
     CSSValueID size;
     if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))
         return false;
-    return executeApplyStyle(frame, source, EditActionChangeAttributes, CSSPropertyFontSize, size);
+    return executeApplyStyle(frame, source, EditAction::ChangeAttributes, CSSPropertyFontSize, size);
 }
 
 static bool executeFontSizeDelta(Frame& frame, Event*, EditorCommandSource source, const String& value)
 {
-    return executeApplyStyle(frame, source, EditActionChangeAttributes, CSSPropertyWebkitFontSizeDelta, value);
+    return executeApplyStyle(frame, source, EditAction::ChangeAttributes, CSSPropertyWebkitFontSizeDelta, value);
 }
 
 static bool executeForeColor(Frame& frame, Event*, EditorCommandSource source, const String& value)
 {
-    return executeApplyStyle(frame, source, EditActionSetColor, CSSPropertyColor, value);
+    return executeApplyStyle(frame, source, EditAction::SetColor, CSSPropertyColor, value);
 }
 
 static bool executeFormatBlock(Frame& frame, Event*, EditorCommandSource, const String& value)
@@ -539,22 +539,22 @@ static bool executeInsertUnorderedList(Frame& frame, Event*, EditorCommandSource
 
 static bool executeJustifyCenter(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeApplyParagraphStyle(frame, source, EditActionCenter, CSSPropertyTextAlign, "center"_s);
+    return executeApplyParagraphStyle(frame, source, EditAction::Center, CSSPropertyTextAlign, "center"_s);
 }
 
 static bool executeJustifyFull(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeApplyParagraphStyle(frame, source, EditActionJustify, CSSPropertyTextAlign, "justify"_s);
+    return executeApplyParagraphStyle(frame, source, EditAction::Justify, CSSPropertyTextAlign, "justify"_s);
 }
 
 static bool executeJustifyLeft(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeApplyParagraphStyle(frame, source, EditActionAlignLeft, CSSPropertyTextAlign, "left"_s);
+    return executeApplyParagraphStyle(frame, source, EditAction::AlignLeft, CSSPropertyTextAlign, "left"_s);
 }
 
 static bool executeJustifyRight(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeApplyParagraphStyle(frame, source, EditActionAlignRight, CSSPropertyTextAlign, "right"_s);
+    return executeApplyParagraphStyle(frame, source, EditAction::AlignRight, CSSPropertyTextAlign, "right"_s);
 }
 
 static bool executeMakeTextWritingDirectionLeftToRight(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -562,7 +562,7 @@ static bool executeMakeTextWritingDirectionLeftToRight(Frame& frame, Event*, Edi
     RefPtr<MutableStyleProperties> style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
     style->setProperty(CSSPropertyDirection, CSSValueLtr);
-    frame.editor().applyStyle(style.get(), EditActionSetWritingDirection);
+    frame.editor().applyStyle(style.get(), EditAction::SetWritingDirection);
     return true;
 }
 
@@ -570,7 +570,7 @@ static bool executeMakeTextWritingDirectionNatural(Frame& frame, Event*, EditorC
 {
     RefPtr<MutableStyleProperties> style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
-    frame.editor().applyStyle(style.get(), EditActionSetWritingDirection);
+    frame.editor().applyStyle(style.get(), EditAction::SetWritingDirection);
     return true;
 }
 
@@ -579,7 +579,7 @@ static bool executeMakeTextWritingDirectionRightToLeft(Frame& frame, Event*, Edi
     RefPtr<MutableStyleProperties> style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
     style->setProperty(CSSPropertyDirection, CSSValueRtl);
-    frame.editor().applyStyle(style.get(), EditActionSetWritingDirection);
+    frame.editor().applyStyle(style.get(), EditAction::SetWritingDirection);
     return true;
 }
 
@@ -1030,7 +1030,7 @@ static bool executeStrikethrough(Frame& frame, Event*, EditorCommandSource sourc
     Ref<EditingStyle> style = EditingStyle::create();
     style->setStrikeThroughChange(textDecorationChangeForToggling(frame.editor(), CSSPropertyWebkitTextDecorationsInEffect, "line-through"_s));
     // FIXME: Needs a new EditAction!
-    return applyCommandToFrame(frame, source, EditActionUnderline, WTFMove(style));
+    return applyCommandToFrame(frame, source, EditAction::Underline, WTFMove(style));
 }
 
 static bool executeStyleWithCSS(Frame& frame, Event*, EditorCommandSource, const String& value)
@@ -1047,12 +1047,12 @@ static bool executeUseCSS(Frame& frame, Event*, EditorCommandSource, const Strin
 
 static bool executeSubscript(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeToggleStyle(frame, source, EditActionSubscript, CSSPropertyVerticalAlign, "baseline"_s, "sub"_s);
+    return executeToggleStyle(frame, source, EditAction::Subscript, CSSPropertyVerticalAlign, "baseline"_s, "sub"_s);
 }
 
 static bool executeSuperscript(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeToggleStyle(frame, source, EditActionSuperscript, CSSPropertyVerticalAlign, "baseline"_s, "super"_s);
+    return executeToggleStyle(frame, source, EditAction::Superscript, CSSPropertyVerticalAlign, "baseline"_s, "super"_s);
 }
 
 static bool executeSwapWithMark(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -1079,12 +1079,12 @@ static bool executeTakeFindStringFromSelection(Frame& frame, Event*, EditorComma
 
 static bool executeToggleBold(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeToggleStyle(frame, source, EditActionBold, CSSPropertyFontWeight, "normal"_s, "bold"_s);
+    return executeToggleStyle(frame, source, EditAction::Bold, CSSPropertyFontWeight, "normal"_s, "bold"_s);
 }
 
 static bool executeToggleItalic(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeToggleStyle(frame, source, EditActionItalics, CSSPropertyFontStyle, "normal"_s, "italic"_s);
+    return executeToggleStyle(frame, source, EditAction::Italics, CSSPropertyFontStyle, "normal"_s, "italic"_s);
 }
 
 static bool executeTranspose(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -1098,7 +1098,7 @@ static bool executeUnderline(Frame& frame, Event*, EditorCommandSource source, c
     Ref<EditingStyle> style = EditingStyle::create();
     TextDecorationChange change = textDecorationChangeForToggling(frame.editor(), CSSPropertyWebkitTextDecorationsInEffect, "underline"_s);
     style->setUnderlineChange(change);
-    return applyCommandToFrame(frame, source, EditActionUnderline, WTFMove(style));
+    return applyCommandToFrame(frame, source, EditAction::Underline, WTFMove(style));
 }
 
 static bool executeUndo(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -1116,7 +1116,7 @@ static bool executeUnlink(Frame& frame, Event*, EditorCommandSource, const Strin
 
 static bool executeUnscript(Frame& frame, Event*, EditorCommandSource source, const String&)
 {
-    return executeApplyStyle(frame, source, EditActionUnscript, CSSPropertyVerticalAlign, "baseline"_s);
+    return executeApplyStyle(frame, source, EditAction::Unscript, CSSPropertyVerticalAlign, "baseline"_s);
 }
 
 static bool executeUnselect(Frame& frame, Event*, EditorCommandSource, const String&)
index 42e4571..79bedad 100644 (file)
@@ -54,7 +54,7 @@ private:
 
     void formatSelection(const VisiblePosition& startOfSelection, const VisiblePosition& endOfSelection) override;
     void formatRange(const Position& start, const Position& end, const Position& endOfSelection, RefPtr<Element>&) override;
-    EditAction editingAction() const override { return EditActionFormatBlock; }
+    EditAction editingAction() const override { return EditAction::FormatBlock; }
 
     bool m_didApply;
 };
index c30f743..90759ac 100644 (file)
@@ -43,7 +43,7 @@ public:
 private:
     IndentOutdentCommand(Document&, EIndentType);
 
-    EditAction editingAction() const override { return m_typeOfAction == Indent ? EditActionIndent : EditActionOutdent; }
+    EditAction editingAction() const override { return m_typeOfAction == Indent ? EditAction::Indent : EditAction::Outdent; }
 
     void indentRegion(const VisiblePosition&, const VisiblePosition&);
     void outdentRegion(const VisiblePosition&, const VisiblePosition&);
index 0d1905f..1196e60 100644 (file)
@@ -33,7 +33,7 @@ class Text;
 
 class InsertIntoTextNodeCommand : public SimpleEditCommand {
 public:
-    static Ref<InsertIntoTextNodeCommand> create(Ref<Text>&& node, unsigned offset, const String& text, EditAction editingAction = EditActionInsert)
+    static Ref<InsertIntoTextNodeCommand> create(Ref<Text>&& node, unsigned offset, const String& text, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new InsertIntoTextNodeCommand(WTFMove(node), offset, text, editingAction));
     }
index 97710be..c571be1 100644 (file)
@@ -192,7 +192,7 @@ void InsertListCommand::doApply()
 
 EditAction InsertListCommand::editingAction() const
 {
-    return m_type == OrderedList ? EditActionInsertOrderedList : EditActionInsertUnorderedList;
+    return m_type == OrderedList ? EditAction::InsertOrderedList : EditAction::InsertUnorderedList;
 }
 
 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection)
index c420596..25d343c 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 class InsertNodeBeforeCommand : public SimpleEditCommand {
 public:
     static Ref<InsertNodeBeforeCommand> create(Ref<Node>&& childToInsert, Node& childToInsertBefore,
-        ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction = EditActionInsert)
+        ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new InsertNodeBeforeCommand(WTFMove(childToInsert), childToInsertBefore, shouldAssumeContentIsAlwaysEditable, editingAction));
     }
index 0285ae7..689b283 100644 (file)
@@ -33,7 +33,7 @@ class EditingStyle;
 
 class InsertParagraphSeparatorCommand : public CompositeEditCommand {
 public:
-    static Ref<InsertParagraphSeparatorCommand> create(Document& document, bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false, EditAction editingAction = EditActionInsert)
+    static Ref<InsertParagraphSeparatorCommand> create(Document& document, bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new InsertParagraphSeparatorCommand(document, useDefaultParagraphElement, pasteBlockqutoeIntoUnquotedArea, editingAction));
     }
index 78c95da..2c3bcc4 100644 (file)
@@ -48,12 +48,12 @@ public:
     };
 
     static Ref<InsertTextCommand> create(Document& document, const String& text, bool selectInsertedText = false,
-        RebalanceType rebalanceType = RebalanceLeadingAndTrailingWhitespaces, EditAction editingAction = EditActionInsert)
+        RebalanceType rebalanceType = RebalanceLeadingAndTrailingWhitespaces, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new InsertTextCommand(document, text, selectInsertedText, rebalanceType, editingAction));
     }
 
-    static Ref<InsertTextCommand> createWithMarkerSupplier(Document& document, const String& text, Ref<TextInsertionMarkerSupplier>&& markerSupplier, EditAction editingAction = EditActionInsert)
+    static Ref<InsertTextCommand> createWithMarkerSupplier(Document& document, const String& text, Ref<TextInsertionMarkerSupplier>&& markerSupplier, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new InsertTextCommand(document, text, WTFMove(markerSupplier), editingAction));
     }
index 486d85a..5e50373 100644 (file)
@@ -61,7 +61,7 @@ void MoveSelectionCommand::doApply()
     }
 
     {
-        auto deleteSelection = DeleteSelectionCommand::create(document(), m_smartDelete, true, false, true, true, EditActionDeleteByDrag);
+        auto deleteSelection = DeleteSelectionCommand::create(document(), m_smartDelete, true, false, true, true, EditAction::DeleteByDrag);
         deleteSelection->setParent(this);
         deleteSelection->apply();
         m_commands.append(WTFMove(deleteSelection));
@@ -87,7 +87,7 @@ void MoveSelectionCommand::doApply()
         options.add(ReplaceSelectionCommand::SmartReplace);
 
     {
-        auto replaceSelection = ReplaceSelectionCommand::create(document(), WTFMove(m_fragment), options, EditActionInsertFromDrop);
+        auto replaceSelection = ReplaceSelectionCommand::create(document(), WTFMove(m_fragment), options, EditAction::InsertFromDrop);
         replaceSelection->setParent(this);
         replaceSelection->apply();
         m_commands.append(WTFMove(replaceSelection));
@@ -96,7 +96,7 @@ void MoveSelectionCommand::doApply()
 
 EditAction MoveSelectionCommand::editingAction() const
 {
-    return EditActionDeleteByDrag;
+    return EditAction::DeleteByDrag;
 }
 
 } // namespace WebCore
index a493b3a..6912038 100644 (file)
@@ -40,7 +40,7 @@ private:
     explicit RemoveFormatCommand(Document&);
 
     void doApply() override;
-    EditAction editingAction() const override { return EditActionUnspecified; }
+    EditAction editingAction() const override { return EditAction::Unspecified; }
 };
 
 } // namespace WebCore
index 0c74072..316e2a4 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
 
 class RemoveNodeCommand : public SimpleEditCommand {
 public:
-    static Ref<RemoveNodeCommand> create(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction = EditActionUnspecified)
+    static Ref<RemoveNodeCommand> create(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction = EditAction::Unspecified)
     {
         return adoptRef(*new RemoveNodeCommand(WTFMove(node), shouldAssumeContentIsAlwaysEditable, editingAction));
     }
index 5b34d06..73a8ce3 100644 (file)
@@ -41,7 +41,7 @@
 namespace WebCore {
 
 ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand(RefPtr<Range> rangeToBeReplaced, const String& text)
-    : CompositeEditCommand(rangeToBeReplaced->startContainer().document(), EditActionInsertReplacement)
+    : CompositeEditCommand(rangeToBeReplaced->startContainer().document(), EditAction::InsertReplacement)
     , m_rangeToBeReplaced(rangeToBeReplaced)
     , m_text(text)
 {
@@ -68,7 +68,7 @@ void ReplaceRangeWithTextCommand::doApply()
         return;
 
     applyCommandToComposite(SetSelectionCommand::create(selection, FrameSelection::defaultSetSelectionOptions()));
-    applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(m_textFragment), ReplaceSelectionCommand::MatchStyle, EditActionPaste));
+    applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(m_textFragment), ReplaceSelectionCommand::MatchStyle, EditAction::Paste));
 }
 
 String ReplaceRangeWithTextCommand::inputEventData() const
index 66d86ac..125eb3e 100644 (file)
@@ -1412,7 +1412,7 @@ void ReplaceSelectionCommand::completeHTMLReplacement(const Position &lastPositi
     else
         return;
 
-    if (AXObjectCache::accessibilityEnabled() && editingAction() == EditActionPaste)
+    if (AXObjectCache::accessibilityEnabled() && editingAction() == EditAction::Paste)
         m_visibleSelectionForInsertedText = VisibleSelection(start, end);
 
     if (m_selectReplacement)
@@ -1584,7 +1584,7 @@ bool ReplaceSelectionCommand::performTrivialReplace(const ReplacementFragment& f
 
     VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, end);
 
-    if (AXObjectCache::accessibilityEnabled() && editingAction() == EditActionPaste)
+    if (AXObjectCache::accessibilityEnabled() && editingAction() == EditAction::Paste)
         m_visibleSelectionForInsertedText = VisibleSelection(start, end);
 
     setEndingSelection(selectionAfterReplace);
index 58c7e94..a2581cb 100644 (file)
@@ -45,7 +45,7 @@ public:
         IgnoreMailBlockquote = 1 << 6,
     };
 
-    static Ref<ReplaceSelectionCommand> create(Document& document, RefPtr<DocumentFragment>&& fragment, OptionSet<CommandOption> options, EditAction editingAction = EditActionInsert)
+    static Ref<ReplaceSelectionCommand> create(Document& document, RefPtr<DocumentFragment>&& fragment, OptionSet<CommandOption> options, EditAction editingAction = EditAction::Insert)
     {
         return adoptRef(*new ReplaceSelectionCommand(document, WTFMove(fragment), options, editingAction));
     }
index 3357e0a..870d445 100644 (file)
@@ -84,7 +84,7 @@ private:
 #endif
 
 SpellingCorrectionCommand::SpellingCorrectionCommand(Range& rangeToBeCorrected, const String& correction)
-    : CompositeEditCommand(rangeToBeCorrected.startContainer().document(), EditActionInsertReplacement)
+    : CompositeEditCommand(rangeToBeCorrected.startContainer().document(), EditAction::InsertReplacement)
     , m_rangeToBeCorrected(rangeToBeCorrected)
     , m_selectionToBeCorrected(m_rangeToBeCorrected)
     , m_correction(correction)
@@ -111,7 +111,7 @@ void SpellingCorrectionCommand::doApply()
     applyCommandToComposite(SpellingCorrectionRecordUndoCommand::create(document(), m_corrected, m_correction));
 #endif
 
-    applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(m_correctionFragment), ReplaceSelectionCommand::MatchStyle, EditActionPaste));
+    applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(m_correctionFragment), ReplaceSelectionCommand::MatchStyle, EditAction::Paste));
 }
 
 String SpellingCorrectionCommand::inputEventData() const
index 10d9adb..67445f0 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual ~TextInsertionBaseCommand() { };
 
 protected:
-    explicit TextInsertionBaseCommand(Document&, EditAction = EditActionUnspecified);
+    explicit TextInsertionBaseCommand(Document&, EditAction = EditAction::Unspecified);
     static void applyTextInsertionCommand(Frame*, TextInsertionBaseCommand&, const VisibleSelection& selectionForInsertion, const VisibleSelection& endingSelection);
 };
 
index b94df5a..6b14fd9 100644 (file)
@@ -83,58 +83,58 @@ static inline EditAction editActionForTypingCommand(TypingCommand::ETypingComman
 {
     if (compositionType == TypingCommand::TextCompositionPending) {
         if (command == TypingCommand::InsertText)
-            return EditActionTypingInsertPendingComposition;
+            return EditAction::TypingInsertPendingComposition;
         if (command == TypingCommand::DeleteSelection)
-            return EditActionTypingDeletePendingComposition;
+            return EditAction::TypingDeletePendingComposition;
         ASSERT_NOT_REACHED();
     }
 
     if (compositionType == TypingCommand::TextCompositionFinal) {
         if (command == TypingCommand::InsertText)
-            return EditActionTypingInsertFinalComposition;
+            return EditAction::TypingInsertFinalComposition;
         if (command == TypingCommand::DeleteSelection)
-            return EditActionTypingDeleteFinalComposition;
+            return EditAction::TypingDeleteFinalComposition;
         ASSERT_NOT_REACHED();
     }
 
     switch (command) {
     case TypingCommand::DeleteSelection:
-        return EditActionTypingDeleteSelection;
+        return EditAction::TypingDeleteSelection;
     case TypingCommand::DeleteKey: {
         if (granularity == WordGranularity)
-            return EditActionTypingDeleteWordBackward;
+            return EditAction::TypingDeleteWordBackward;
         if (granularity == LineBoundary)
-            return EditActionTypingDeleteLineBackward;
-        return EditActionTypingDeleteBackward;
+            return EditAction::TypingDeleteLineBackward;
+        return EditAction::TypingDeleteBackward;
     }
     case TypingCommand::ForwardDeleteKey:
         if (granularity == WordGranularity)
-            return EditActionTypingDeleteWordForward;
+            return EditAction::TypingDeleteWordForward;
         if (granularity == LineBoundary)
-            return EditActionTypingDeleteLineForward;
-        return EditActionTypingDeleteForward;
+            return EditAction::TypingDeleteLineForward;
+        return EditAction::TypingDeleteForward;
     case TypingCommand::InsertText:
-        return isAutocompletion ? EditActionInsertReplacement : EditActionTypingInsertText;
+        return isAutocompletion ? EditAction::InsertReplacement : EditAction::TypingInsertText;
     case TypingCommand::InsertLineBreak:
-        return EditActionTypingInsertLineBreak;
+        return EditAction::TypingInsertLineBreak;
     case TypingCommand::InsertParagraphSeparator:
     case TypingCommand::InsertParagraphSeparatorInQuotedContent:
-        return EditActionTypingInsertParagraph;
+        return EditAction::TypingInsertParagraph;
     default:
-        return EditActionUnspecified;
+        return EditAction::Unspecified;
     }
 }
 
 static inline bool editActionIsDeleteByTyping(EditAction action)
 {
     switch (action) {
-    case EditActionTypingDeleteSelection:
-    case EditActionTypingDeleteBackward:
-    case EditActionTypingDeleteWordBackward:
-    case EditActionTypingDeleteLineBackward:
-    case EditActionTypingDeleteForward:
-    case EditActionTypingDeleteWordForward:
-    case EditActionTypingDeleteLineForward:
+    case EditAction::TypingDeleteSelection:
+    case EditAction::TypingDeleteBackward:
+    case EditAction::TypingDeleteWordBackward:
+    case EditAction::TypingDeleteLineBackward:
+    case EditAction::TypingDeleteForward:
+    case EditAction::TypingDeleteWordForward:
+    case EditAction::TypingDeleteLineForward:
         return true;
     default:
         return false;
@@ -401,17 +401,17 @@ String TypingCommand::inputEventTypeName() const
 
 bool TypingCommand::isBeforeInputEventCancelable() const
 {
-    return m_currentTypingEditAction != EditActionTypingInsertPendingComposition && m_currentTypingEditAction != EditActionTypingDeletePendingComposition;
+    return m_currentTypingEditAction != EditAction::TypingInsertPendingComposition && m_currentTypingEditAction != EditAction::TypingDeletePendingComposition;
 }
 
 String TypingCommand::inputEventData() const
 {
     switch (m_currentTypingEditAction) {
-    case EditActionTypingInsertText:
-    case EditActionTypingInsertPendingComposition:
-    case EditActionTypingInsertFinalComposition:
+    case EditAction::TypingInsertText:
+    case EditAction::TypingInsertPendingComposition:
+    case EditAction::TypingInsertFinalComposition:
         return m_currentTextToInsert;
-    case EditActionInsertReplacement:
+    case EditAction::InsertReplacement:
         return isEditingTextAreaOrTextInput() ? m_currentTextToInsert : String();
     default:
         return CompositeEditCommand::inputEventData();
@@ -420,7 +420,7 @@ String TypingCommand::inputEventData() const
 
 RefPtr<DataTransfer> TypingCommand::inputEventDataTransfer() const
 {
-    if (m_currentTypingEditAction != EditActionInsertReplacement || isEditingTextAreaOrTextInput())
+    if (m_currentTypingEditAction != EditAction::InsertReplacement || isEditingTextAreaOrTextInput())
         return nullptr;
 
     StringBuilder htmlText;
@@ -548,7 +548,7 @@ void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool select
         return;
 
     auto command = InsertTextCommand::create(document(), text, selectInsertedText,
-        m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditActionTypingInsertText);
+        m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditAction::TypingInsertText);
 
     applyCommandToComposite(WTFMove(command), endingSelection());
 
@@ -583,7 +583,7 @@ void TypingCommand::insertParagraphSeparator()
     if (!willAddTypingToOpenCommand(InsertParagraphSeparator, ParagraphGranularity))
         return;
 
-    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionTypingInsertParagraph));
+    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditAction::TypingInsertParagraph));
     typingAddedToOpenCommand(InsertParagraphSeparator);
 }
 
index 17c50a9..188a531 100644 (file)
@@ -40,7 +40,7 @@ private:
     explicit UnlinkCommand(Document&);
 
     void doApply() override;
-    EditAction editingAction() const override { return EditActionUnlink; }
+    EditAction editingAction() const override { return EditAction::Unlink; }
 };
 
 } // namespace WebCore
index 632fdab..83ef19d 100644 (file)
@@ -40,7 +40,7 @@
 namespace WebCore {
 
 DictationCommandIOS::DictationCommandIOS(Document& document, Vector<Vector<String>>&& dictationPhrases, RetainPtr<id> metadata)
-    : CompositeEditCommand(document, EditActionDictation)
+    : CompositeEditCommand(document, EditAction::Dictation)
     , m_dictationPhrases(WTFMove(dictationPhrases))
     , m_metadata(WTFMove(metadata))
 {
index c99b1e4..a17892b 100644 (file)
@@ -163,8 +163,8 @@ void Editor::removeUnchangeableStyles()
     defaultStyle->removeProperty(CSSPropertyTextDecoration);
     defaultStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); // implements underline
 
-    // FIXME add EditActionMatchStlye <rdar://problem/9156507> Undo rich text's paste & match style should say "Undo Match Style"
-    applyStyleToSelection(defaultStyle.get(), EditActionChangeAttributes);
+    // FIXME add EditAction::MatchStlye <rdar://problem/9156507> Undo rich text's paste & match style should say "Undo Match Style"
+    applyStyleToSelection(defaultStyle.get(), EditAction::ChangeAttributes);
 }
 
 static void getImage(Element& imageElement, RefPtr<Image>& image, CachedImage*& cachedImage)
index 5d92746..f440705 100644 (file)
@@ -569,7 +569,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
         if (!innerFrame->editor().shouldApplyStyle(style.ptr(), innerRange.get()))
             return false;
         m_client.willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
-        innerFrame->editor().applyStyle(style.ptr(), EditActionSetColor);
+        innerFrame->editor().applyStyle(style.ptr(), EditAction::SetColor);
         return true;
     }
 
@@ -622,7 +622,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
                     options.add(ReplaceSelectionCommand::SmartReplace);
                 if (chosePlainText)
                     options.add(ReplaceSelectionCommand::MatchStyle);
-                ReplaceSelectionCommand::create(*m_documentUnderMouse, fragment.releaseNonNull(), options, EditActionInsertFromDrop)->apply();
+                ReplaceSelectionCommand::create(*m_documentUnderMouse, fragment.releaseNonNull(), options, EditAction::InsertFromDrop)->apply();
             }
         }
     } else {
@@ -639,7 +639,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 }, EditAction::InsertFromDrop)->apply();
     }
 
     if (rootEditableElement) {
index 4dcd39b..6cf3204 100644 (file)
@@ -1,3 +1,16 @@
+2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor WebCore::EditAction to be an 8-bit enum class
+        https://bugs.webkit.org/show_bug.cgi?id=189383
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/WebEditCommandProxy.cpp:
+        (WebKit::WebEditCommandProxy::nameForEditAction):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::changeFontAttributes):
+        (WebKit::WebPage::changeFont):
+
 2018-09-06  Megan Gardner  <megan_gardner@apple.com>
 
         Add Support for Conic Gradients
index dfb11d7..6fd8df5 100644 (file)
@@ -72,104 +72,104 @@ String WebEditCommandProxy::nameForEditAction(EditAction editAction)
 {
     // FIXME: This is identical to code in WebKit's WebEditorClient class; would be nice to share the strings instead of having two copies.
     switch (editAction) {
-    case EditActionUnspecified:
-    case EditActionInsert:
-    case EditActionInsertReplacement:
-    case EditActionInsertFromDrop:
+    case EditAction::Unspecified:
+    case EditAction::Insert:
+    case EditAction::InsertReplacement:
+    case EditAction::InsertFromDrop:
         return String();
-    case EditActionSetColor:
+    case EditAction::SetColor:
         return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
-    case EditActionSetBackgroundColor:
+    case EditAction::SetBackgroundColor:
         return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
-    case EditActionTurnOffKerning:
+    case EditAction::TurnOffKerning:
         return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
-    case EditActionTightenKerning:
+    case EditAction::TightenKerning:
         return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
-    case EditActionLoosenKerning:
+    case EditAction::LoosenKerning:
         return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
-    case EditActionUseStandardKerning:
+    case EditAction::UseStandardKerning:
         return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
-    case EditActionTurnOffLigatures:
+    case EditAction::TurnOffLigatures:
         return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
-    case EditActionUseStandardLigatures:
+    case EditAction::UseStandardLigatures:
         return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
-    case EditActionUseAllLigatures:
+    case EditAction::UseAllLigatures:
         return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
-    case EditActionRaiseBaseline:
+    case EditAction::RaiseBaseline:
         return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
-    case EditActionLowerBaseline:
+    case EditAction::LowerBaseline:
         return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
-    case EditActionSetTraditionalCharacterShape:
+    case EditAction::SetTraditionalCharacterShape:
         return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
-    case EditActionSetFont:
+    case EditAction::SetFont:
         return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
-    case EditActionChangeAttributes:
+    case EditAction::ChangeAttributes:
         return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
-    case EditActionAlignLeft:
+    case EditAction::AlignLeft:
         return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
-    case EditActionAlignRight:
+    case EditAction::AlignRight:
         return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
-    case EditActionCenter:
+    case EditAction::Center:
         return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
-    case EditActionJustify:
+    case EditAction::Justify:
         return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
-    case EditActionSetWritingDirection:
+    case EditAction::SetWritingDirection:
         return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
-    case EditActionSubscript:
+    case EditAction::Subscript:
         return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
-    case EditActionSuperscript:
+    case EditAction::Superscript:
         return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
-    case EditActionUnderline:
+    case EditAction::Underline:
         return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
-    case EditActionOutline:
+    case EditAction::Outline:
         return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
-    case EditActionUnscript:
+    case EditAction::Unscript:
         return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
-    case EditActionDeleteByDrag:
+    case EditAction::DeleteByDrag:
         return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
-    case EditActionCut:
+    case EditAction::Cut:
         return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
-    case EditActionBold:
+    case EditAction::Bold:
         return WEB_UI_STRING_KEY("Bold", "Bold (Undo action name)", "Undo action name");
-    case EditActionItalics:
+    case EditAction::Italics:
         return WEB_UI_STRING_KEY("Italics", "Italics (Undo action name)", "Undo action name");
-    case EditActionDelete:
+    case EditAction::Delete:
         return WEB_UI_STRING_KEY("Delete", "Delete (Undo action name)", "Undo action name");
-    case EditActionDictation:
+    case EditAction::Dictation:
         return WEB_UI_STRING_KEY("Dictation", "Dictation (Undo action name)", "Undo action name");
-    case EditActionPaste:
+    case EditAction::Paste:
         return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
-    case EditActionPasteFont:
+    case EditAction::PasteFont:
         return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
-    case EditActionPasteRuler:
+    case EditAction::PasteRuler:
         return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
-    case EditActionTypingDeleteSelection:
-    case EditActionTypingDeleteBackward:
-    case EditActionTypingDeleteForward:
-    case EditActionTypingDeleteWordBackward:
-    case EditActionTypingDeleteWordForward:
-    case EditActionTypingDeleteLineBackward:
-    case EditActionTypingDeleteLineForward:
-    case EditActionTypingDeletePendingComposition:
-    case EditActionTypingDeleteFinalComposition:
-    case EditActionTypingInsertText:
-    case EditActionTypingInsertLineBreak:
-    case EditActionTypingInsertParagraph:
-    case EditActionTypingInsertPendingComposition:
-    case EditActionTypingInsertFinalComposition:
+    case EditAction::TypingDeleteSelection:
+    case EditAction::TypingDeleteBackward:
+    case EditAction::TypingDeleteForward:
+    case EditAction::TypingDeleteWordBackward:
+    case EditAction::TypingDeleteWordForward:
+    case EditAction::TypingDeleteLineBackward:
+    case EditAction::TypingDeleteLineForward:
+    case EditAction::TypingDeletePendingComposition:
+    case EditAction::TypingDeleteFinalComposition:
+    case EditAction::TypingInsertText:
+    case EditAction::TypingInsertLineBreak:
+    case EditAction::TypingInsertParagraph:
+    case EditAction::TypingInsertPendingComposition:
+    case EditAction::TypingInsertFinalComposition:
         return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
-    case EditActionCreateLink:
+    case EditAction::CreateLink:
         return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
-    case EditActionUnlink:
+    case EditAction::Unlink:
         return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
-    case EditActionInsertUnorderedList:
-    case EditActionInsertOrderedList:
+    case EditAction::InsertUnorderedList:
+    case EditAction::InsertOrderedList:
         return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
-    case EditActionFormatBlock:
+    case EditAction::FormatBlock:
         return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
-    case EditActionIndent:
+    case EditAction::Indent:
         return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
-    case EditActionOutdent:
+    case EditAction::Outdent:
         return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
     }
     return String();
index 8e2002d..2bdd08f 100644 (file)
@@ -1119,14 +1119,14 @@ void WebPage::changeFontAttributes(WebCore::FontAttributeChanges&& changes)
 {
     auto& frame = m_page->focusController().focusedOrMainFrame();
     if (frame.selection().selection().isContentEditable())
-        frame.editor().applyStyleToSelection(changes.createEditingStyle(), EditActionChangeAttributes, Editor::ColorFilterMode::InvertColor);
+        frame.editor().applyStyleToSelection(changes.createEditingStyle(), EditAction::ChangeAttributes, Editor::ColorFilterMode::InvertColor);
 }
 
 void WebPage::changeFont(WebCore::FontChanges&& changes)
 {
     auto& frame = m_page->focusController().focusedOrMainFrame();
     if (frame.selection().selection().isContentEditable())
-        frame.editor().applyStyleToSelection(changes.createEditingStyle(), EditActionSetFont, Editor::ColorFilterMode::InvertColor);
+        frame.editor().applyStyleToSelection(changes.createEditingStyle(), EditAction::SetFont, Editor::ColorFilterMode::InvertColor);
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
index c6e27ea..0ebf8f8 100644 (file)
@@ -1,3 +1,21 @@
+2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor WebCore::EditAction to be an 8-bit enum class
+        https://bugs.webkit.org/show_bug.cgi?id=189383
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (undoNameForEditAction):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView pasteFont:]):
+        (-[WebHTMLView changeFont:]):
+        (-[WebHTMLView changeAttributes:]):
+        (-[WebHTMLView _undoActionFromColorPanelWithSelector:]):
+        (-[WebHTMLView changeColor:]):
+        * WebView/WebView.mm:
+        (-[WebView setTypingStyle:]):
+
 2018-09-06  Frederic Wang  <fwang@igalia.com>
 
         Group options of scrollRectToVisible into a struct
index e28112d..5079ec3 100644 (file)
@@ -602,66 +602,66 @@ static NSString* undoNameForEditAction(EditAction editAction)
 {
     // FIXME: This is identical to code in WebKit2's WebEditCommandProxy class; would be nice to share the strings instead of having two copies.
     switch (editAction) {
-        case EditActionUnspecified: return nil;
-        case EditActionInsert: return nil;
-        case EditActionInsertReplacement: return nil;
-        case EditActionInsertFromDrop: return nil;
-        case EditActionSetColor: return UI_STRING_KEY_INTERNAL("Set Color", "Set Color (Undo action name)", "Undo action name");
-        case EditActionSetBackgroundColor: return UI_STRING_KEY_INTERNAL("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
-        case EditActionTurnOffKerning: return UI_STRING_KEY_INTERNAL("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
-        case EditActionTightenKerning: return UI_STRING_KEY_INTERNAL("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
-        case EditActionLoosenKerning: return UI_STRING_KEY_INTERNAL("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
-        case EditActionUseStandardKerning: return UI_STRING_KEY_INTERNAL("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
-        case EditActionTurnOffLigatures: return UI_STRING_KEY_INTERNAL("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
-        case EditActionUseStandardLigatures: return UI_STRING_KEY_INTERNAL("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
-        case EditActionUseAllLigatures: return UI_STRING_KEY_INTERNAL("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
-        case EditActionRaiseBaseline: return UI_STRING_KEY_INTERNAL("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
-        case EditActionLowerBaseline: return UI_STRING_KEY_INTERNAL("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
-        case EditActionSetTraditionalCharacterShape: return UI_STRING_KEY_INTERNAL("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
-        case EditActionSetFont: return UI_STRING_KEY_INTERNAL("Set Font", "Set Font (Undo action name)", "Undo action name");
-        case EditActionChangeAttributes: return UI_STRING_KEY_INTERNAL("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
-        case EditActionAlignLeft: return UI_STRING_KEY_INTERNAL("Align Left", "Align Left (Undo action name)", "Undo action name");
-        case EditActionAlignRight: return UI_STRING_KEY_INTERNAL("Align Right", "Align Right (Undo action name)", "Undo action name");
-        case EditActionCenter: return UI_STRING_KEY_INTERNAL("Center", "Center (Undo action name)", "Undo action name");
-        case EditActionJustify: return UI_STRING_KEY_INTERNAL("Justify", "Justify (Undo action name)", "Undo action name");
-        case EditActionSetWritingDirection: return UI_STRING_KEY_INTERNAL("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
-        case EditActionSubscript: return UI_STRING_KEY_INTERNAL("Subscript", "Subscript (Undo action name)", "Undo action name");
-        case EditActionSuperscript: return UI_STRING_KEY_INTERNAL("Superscript", "Superscript (Undo action name)", "Undo action name");
-        case EditActionUnderline: return UI_STRING_KEY_INTERNAL("Underline", "Underline (Undo action name)", "Undo action name");
-        case EditActionOutline: return UI_STRING_KEY_INTERNAL("Outline", "Outline (Undo action name)", "Undo action name");
-        case EditActionUnscript: return UI_STRING_KEY_INTERNAL("Unscript", "Unscript (Undo action name)", "Undo action name");
-        case EditActionDeleteByDrag: return UI_STRING_KEY_INTERNAL("Drag", "Drag (Undo action name)", "Undo action name");
-        case EditActionCut: return UI_STRING_KEY_INTERNAL("Cut", "Cut (Undo action name)", "Undo action name");
-        case EditActionPaste: return UI_STRING_KEY_INTERNAL("Paste", "Paste (Undo action name)", "Undo action name");
-        case EditActionPasteFont: return UI_STRING_KEY_INTERNAL("Paste Font", "Paste Font (Undo action name)", "Undo action name");
-        case EditActionPasteRuler: return UI_STRING_KEY_INTERNAL("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
-        case EditActionTypingDeleteSelection:
-        case EditActionTypingDeleteBackward:
-        case EditActionTypingDeleteForward:
-        case EditActionTypingDeleteWordBackward:
-        case EditActionTypingDeleteWordForward:
-        case EditActionTypingDeleteLineBackward:
-        case EditActionTypingDeleteLineForward:
-        case EditActionTypingDeletePendingComposition:
-        case EditActionTypingDeleteFinalComposition:
-        case EditActionTypingInsertText:
-        case EditActionTypingInsertLineBreak:
-        case EditActionTypingInsertParagraph:
-        case EditActionTypingInsertPendingComposition:
-        case EditActionTypingInsertFinalComposition:
-            return UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "Undo action name");
-        case EditActionCreateLink: return UI_STRING_KEY_INTERNAL("Create Link", "Create Link (Undo action name)", "Undo action name");
-        case EditActionUnlink: return UI_STRING_KEY_INTERNAL("Unlink", "Unlink (Undo action name)", "Undo action name");
-        case EditActionInsertOrderedList:
-        case EditActionInsertUnorderedList:
-            return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (Undo action name)", "Undo action name");
-        case EditActionFormatBlock: return UI_STRING_KEY_INTERNAL("Formatting", "Format Block (Undo action name)", "Undo action name");
-        case EditActionIndent: return UI_STRING_KEY_INTERNAL("Indent", "Indent (Undo action name)", "Undo action name");
-        case EditActionOutdent: return UI_STRING_KEY_INTERNAL("Outdent", "Outdent (Undo action name)", "Undo action name");
-        case EditActionBold: return UI_STRING_KEY_INTERNAL("Bold", "Bold (Undo action name)", "Undo action name");
-        case EditActionItalics: return UI_STRING_KEY_INTERNAL("Italics", "Italics (Undo action name)", "Undo action name");
-        case EditActionDelete: return UI_STRING_KEY_INTERNAL("Delete", "Delete (Undo action name)", "Undo action name");
-        case EditActionDictation: return UI_STRING_KEY_INTERNAL("Dictation", "Dictation (Undo action name)", "Undo action name");
+    case EditAction::Unspecified: return nil;
+    case EditAction::Insert: return nil;
+    case EditAction::InsertReplacement: return nil;
+    case EditAction::InsertFromDrop: return nil;
+    case EditAction::SetColor: return UI_STRING_KEY_INTERNAL("Set Color", "Set Color (Undo action name)", "Undo action name");
+    case EditAction::SetBackgroundColor: return UI_STRING_KEY_INTERNAL("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
+    case EditAction::TurnOffKerning: return UI_STRING_KEY_INTERNAL("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
+    case EditAction::TightenKerning: return UI_STRING_KEY_INTERNAL("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
+    case EditAction::LoosenKerning: return UI_STRING_KEY_INTERNAL("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
+    case EditAction::UseStandardKerning: return UI_STRING_KEY_INTERNAL("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
+    case EditAction::TurnOffLigatures: return UI_STRING_KEY_INTERNAL("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
+    case EditAction::UseStandardLigatures: return UI_STRING_KEY_INTERNAL("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
+    case EditAction::UseAllLigatures: return UI_STRING_KEY_INTERNAL("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
+    case EditAction::RaiseBaseline: return UI_STRING_KEY_INTERNAL("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
+    case EditAction::LowerBaseline: return UI_STRING_KEY_INTERNAL("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
+    case EditAction::SetTraditionalCharacterShape: return UI_STRING_KEY_INTERNAL("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
+    case EditAction::SetFont: return UI_STRING_KEY_INTERNAL("Set Font", "Set Font (Undo action name)", "Undo action name");
+    case EditAction::ChangeAttributes: return UI_STRING_KEY_INTERNAL("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
+    case EditAction::AlignLeft: return UI_STRING_KEY_INTERNAL("Align Left", "Align Left (Undo action name)", "Undo action name");
+    case EditAction::AlignRight: return UI_STRING_KEY_INTERNAL("Align Right", "Align Right (Undo action name)", "Undo action name");
+    case EditAction::Center: return UI_STRING_KEY_INTERNAL("Center", "Center (Undo action name)", "Undo action name");
+    case EditAction::Justify: return UI_STRING_KEY_INTERNAL("Justify", "Justify (Undo action name)", "Undo action name");
+    case EditAction::SetWritingDirection: return UI_STRING_KEY_INTERNAL("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
+    case EditAction::Subscript: return UI_STRING_KEY_INTERNAL("Subscript", "Subscript (Undo action name)", "Undo action name");
+    case EditAction::Superscript: return UI_STRING_KEY_INTERNAL("Superscript", "Superscript (Undo action name)", "Undo action name");
+    case EditAction::Underline: return UI_STRING_KEY_INTERNAL("Underline", "Underline (Undo action name)", "Undo action name");
+    case EditAction::Outline: return UI_STRING_KEY_INTERNAL("Outline", "Outline (Undo action name)", "Undo action name");
+    case EditAction::Unscript: return UI_STRING_KEY_INTERNAL("Unscript", "Unscript (Undo action name)", "Undo action name");
+    case EditAction::DeleteByDrag: return UI_STRING_KEY_INTERNAL("Drag", "Drag (Undo action name)", "Undo action name");
+    case EditAction::Cut: return UI_STRING_KEY_INTERNAL("Cut", "Cut (Undo action name)", "Undo action name");
+    case EditAction::Paste: return UI_STRING_KEY_INTERNAL("Paste", "Paste (Undo action name)", "Undo action name");
+    case EditAction::PasteFont: return UI_STRING_KEY_INTERNAL("Paste Font", "Paste Font (Undo action name)", "Undo action name");
+    case EditAction::PasteRuler: return UI_STRING_KEY_INTERNAL("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
+    case EditAction::TypingDeleteSelection:
+    case EditAction::TypingDeleteBackward:
+    case EditAction::TypingDeleteForward:
+    case EditAction::TypingDeleteWordBackward:
+    case EditAction::TypingDeleteWordForward:
+    case EditAction::TypingDeleteLineBackward:
+    case EditAction::TypingDeleteLineForward:
+    case EditAction::TypingDeletePendingComposition:
+    case EditAction::TypingDeleteFinalComposition:
+    case EditAction::TypingInsertText:
+    case EditAction::TypingInsertLineBreak:
+    case EditAction::TypingInsertParagraph:
+    case EditAction::TypingInsertPendingComposition:
+    case EditAction::TypingInsertFinalComposition:
+        return UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "Undo action name");
+    case EditAction::CreateLink: return UI_STRING_KEY_INTERNAL("Create Link", "Create Link (Undo action name)", "Undo action name");
+    case EditAction::Unlink: return UI_STRING_KEY_INTERNAL("Unlink", "Unlink (Undo action name)", "Undo action name");
+    case EditAction::InsertOrderedList:
+    case EditAction::InsertUnorderedList:
+        return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (Undo action name)", "Undo action name");
+    case EditAction::FormatBlock: return UI_STRING_KEY_INTERNAL("Formatting", "Format Block (Undo action name)", "Undo action name");
+    case EditAction::Indent: return UI_STRING_KEY_INTERNAL("Indent", "Indent (Undo action name)", "Undo action name");
+    case EditAction::Outdent: return UI_STRING_KEY_INTERNAL("Outdent", "Outdent (Undo action name)", "Undo action name");
+    case EditAction::Bold: return UI_STRING_KEY_INTERNAL("Bold", "Bold (Undo action name)", "Undo action name");
+    case EditAction::Italics: return UI_STRING_KEY_INTERNAL("Italics", "Italics (Undo action name)", "Undo action name");
+    case EditAction::Delete: return UI_STRING_KEY_INTERNAL("Delete", "Delete (Undo action name)", "Undo action name");
+    case EditAction::Dictation: return UI_STRING_KEY_INTERNAL("Dictation", "Dictation (Undo action name)", "Undo action name");
     }
     return nil;
 }
index fb85500..192e183 100644 (file)
@@ -5297,7 +5297,7 @@ static RefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
 
     // Read RTF with font attributes from the pasteboard.
     // Maybe later we should add a pasteboard type that contains CSS text for "native" copy and paste font.
-    [self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]] withUndoAction:EditActionPasteFont];
+    [self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]] withUndoAction:EditAction::PasteFont];
 }
 
 - (void)pasteAsRichText:(id)sender
@@ -5313,14 +5313,14 @@ static RefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
 {
     COMMAND_PROLOGUE
 
-    [self _applyEditingStyleToSelection:computedFontChanges(NSFontManager.sharedFontManager).createEditingStyle() withUndoAction:EditActionSetFont];
+    [self _applyEditingStyleToSelection:computedFontChanges(NSFontManager.sharedFontManager).createEditingStyle() withUndoAction:EditAction::SetFont];
 }
 
 - (void)changeAttributes:(id)sender
 {
     COMMAND_PROLOGUE
 
-    [self _applyEditingStyleToSelection:computedFontAttributeChanges(NSFontManager.sharedFontManager, sender).createEditingStyle() withUndoAction:EditActionChangeAttributes];
+    [self _applyEditingStyleToSelection:computedFontAttributeChanges(NSFontManager.sharedFontManager, sender).createEditingStyle() withUndoAction:EditAction::ChangeAttributes];
 }
 
 - (DOMCSSStyleDeclaration *)_styleFromColorPanelWithSelector:(SEL)selector
@@ -5336,8 +5336,8 @@ static RefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
 - (EditAction)_undoActionFromColorPanelWithSelector:(SEL)selector
 {
     if (selector == @selector(setBackgroundColor:))
-        return EditActionSetBackgroundColor;    
-    return EditActionSetColor;
+        return EditAction::SetBackgroundColor;
+    return EditAction::SetColor;
 }
 
 - (void)_changeCSSColorUsingSelector:(SEL)selector inRange:(DOMRange *)range
@@ -5381,8 +5381,7 @@ static RefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
     // AppKit will have to be revised to allow this to work with anything that isn't an 
     // NSTextView. However, this might not be required for Tiger, since the background-color 
     // changing box in the font panel doesn't work in Mail (3674481), though it does in TextEdit.
-    [self _applyStyleToSelection:[self _styleFromColorPanelWithSelector:@selector(setColor:)] 
-                  withUndoAction:EditActionSetColor];
+    [self _applyStyleToSelection:[self _styleFromColorPanelWithSelector:@selector(setColor:)] withUndoAction:EditAction::SetColor];
 }
 
 #endif // PLATFORM(MAC)
index 09d9a69..f24ea72 100644 (file)
@@ -8254,7 +8254,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
 {
     // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
     // change the API to allow this.
-    [[self _selectedOrMainFrame] _setTypingStyle:style withUndoAction:EditActionUnspecified];
+    [[self _selectedOrMainFrame] _setTypingStyle:style withUndoAction:EditAction::Unspecified];
 }
 
 - (DOMCSSStyleDeclaration *)typingStyle
index eebab74..5ed18a3 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor WebCore::EditAction to be an 8-bit enum class
+        https://bugs.webkit.org/show_bug.cgi?id=189383
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (undoNameForEditAction):
+
 2018-09-04  Frederic Wang  <fwang@igalia.com>
 
         Add basic support for ScrollIntoViewOptions
index 56e7cf0..b58de5b 100644 (file)
@@ -573,59 +573,59 @@ ULONG WebEditorUndoCommand::Release()
 static String undoNameForEditAction(EditAction editAction)
 {
     switch (editAction) {
-    case EditActionUnspecified:
-    case EditActionInsertReplacement:
+    case EditAction::Unspecified:
+    case EditAction::InsertReplacement:
         return String();
-    case EditActionSetColor: return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
-    case EditActionSetBackgroundColor: return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
-    case EditActionTurnOffKerning: return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
-    case EditActionTightenKerning: return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
-    case EditActionLoosenKerning: return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
-    case EditActionUseStandardKerning: return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
-    case EditActionTurnOffLigatures: return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
-    case EditActionUseStandardLigatures: return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
-    case EditActionUseAllLigatures: return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
-    case EditActionRaiseBaseline: return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
-    case EditActionLowerBaseline: return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
-    case EditActionSetTraditionalCharacterShape: return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
-    case EditActionSetFont: return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
-    case EditActionChangeAttributes: return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
-    case EditActionAlignLeft: return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
-    case EditActionAlignRight: return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
-    case EditActionCenter: return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
-    case EditActionJustify: return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
-    case EditActionSetWritingDirection: return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
-    case EditActionSubscript: return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
-    case EditActionSuperscript: return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
-    case EditActionBold: return WEB_UI_STRING_KEY("Bold", "Bold (Undo action name)", "Undo action name");
-    case EditActionItalics: return WEB_UI_STRING_KEY("Italics", "Italics (Undo action name)", "Undo action name");
-    case EditActionUnderline: return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
-    case EditActionOutline: return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
-    case EditActionUnscript: return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
-    case EditActionDeleteByDrag: return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
-    case EditActionCut: return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
-    case EditActionPaste: return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
-    case EditActionPasteFont: return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
-    case EditActionPasteRuler: return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
-    case EditActionTypingDeleteSelection:
-    case EditActionTypingDeleteBackward:
-    case EditActionTypingDeleteForward:
-    case EditActionTypingDeleteWordBackward:
-    case EditActionTypingDeleteWordForward:
-    case EditActionTypingDeleteLineBackward:
-    case EditActionTypingDeleteLineForward:
-    case EditActionTypingInsertText:
-    case EditActionTypingInsertLineBreak:
-    case EditActionTypingInsertParagraph:
+    case EditAction::SetColor: return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
+    case EditAction::SetBackgroundColor: return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
+    case EditAction::TurnOffKerning: return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
+    case EditAction::TightenKerning: return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
+    case EditAction::LoosenKerning: return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
+    case EditAction::UseStandardKerning: return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
+    case EditAction::TurnOffLigatures: return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
+    case EditAction::UseStandardLigatures: return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
+    case EditAction::UseAllLigatures: return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
+    case EditAction::RaiseBaseline: return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
+    case EditAction::LowerBaseline: return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
+    case EditAction::SetTraditionalCharacterShape: return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
+    case EditAction::SetFont: return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
+    case EditAction::ChangeAttributes: return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
+    case EditAction::AlignLeft: return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
+    case EditAction::AlignRight: return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
+    case EditAction::Center: return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
+    case EditAction::Justify: return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
+    case EditAction::SetWritingDirection: return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
+    case EditAction::Subscript: return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
+    case EditAction::Superscript: return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
+    case EditAction::Bold: return WEB_UI_STRING_KEY("Bold", "Bold (Undo action name)", "Undo action name");
+    case EditAction::Italics: return WEB_UI_STRING_KEY("Italics", "Italics (Undo action name)", "Undo action name");
+    case EditAction::Underline: return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
+    case EditAction::Outline: return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
+    case EditAction::Unscript: return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
+    case EditAction::DeleteByDrag: return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
+    case EditAction::Cut: return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
+    case EditAction::Paste: return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
+    case EditAction::PasteFont: return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
+    case EditAction::PasteRuler: return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
+    case EditAction::TypingDeleteSelection:
+    case EditAction::TypingDeleteBackward:
+    case EditAction::TypingDeleteForward:
+    case EditAction::TypingDeleteWordBackward:
+    case EditAction::TypingDeleteWordForward:
+    case EditAction::TypingDeleteLineBackward:
+    case EditAction::TypingDeleteLineForward:
+    case EditAction::TypingInsertText:
+    case EditAction::TypingInsertLineBreak:
+    case EditAction::TypingInsertParagraph:
         return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
-    case EditActionCreateLink: return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
-    case EditActionUnlink: return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
-    case EditActionInsertUnorderedList:
-    case EditActionInsertOrderedList:
+    case EditAction::CreateLink: return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
+    case EditAction::Unlink: return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
+    case EditAction::InsertUnorderedList:
+    case EditAction::InsertOrderedList:
         return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
-    case EditActionFormatBlock: return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
-    case EditActionIndent: return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
-    case EditActionOutdent: return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
+    case EditAction::FormatBlock: return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
+    case EditAction::Indent: return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
+    case EditAction::Outdent: return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
     }
     return String();
 }