Support InputEvent.inputType for the new InputEvent spec
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2016 03:11:20 +0000 (03:11 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2016 03:11:20 +0000 (03:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163025
<rdar://problem/28658092>

Reviewed by Darin Adler.

Source/WebCore:

Adds support for the inputType attribute of InputEvent. To do this, we introduce a helper to
map EditActions to inputType names, and also split out ambiguous EditActions (such as
EditActionTyping) into more specific subtypes (such as EditActionTypingDeleteBackward,
EditActionTypingInsertParagraph, etc.), each of which corresponds to an inputType.

In places where we create CompositeEditCommands, we now pass in these specific EditActions
where appropriate, and when dispatching `beforeinput` and `input` events, we ask the
CompositeEditCommand for its input type name, which it derives from its editingAction.

Tests: fast/events/before-input-prevent-biu.html
       fast/events/before-input-prevent-cut.html
       fast/events/before-input-prevent-paste.html
       fast/events/before-input-prevent-typing.html
       fast/events/before-input-prevent-undo.html

* dom/InputEvent.h:
* dom/Node.cpp:
(WebCore::Node::dispatchInputEvent):
* dom/Node.h:
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::apply):
(WebCore::CompositeEditCommand::inputEventTypeName):

Allows a CompositeEditCommand to specify the inputType its corresponding `beforeinput` and `input` events
should have.

* editing/CompositeEditCommand.h:
(WebCore::CompositeEditCommand::shouldStopCaretBlinking): Deleted.
* editing/EditAction.h:
* editing/EditCommand.cpp:
(WebCore::inputTypeNameForEditingAction):
* editing/EditCommand.h:
* editing/Editor.cpp:
(WebCore::Editor::willApplyEditing):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::willUnapplyEditing):
(WebCore::Editor::unappliedEditing):
(WebCore::Editor::willReapplyEditing):
(WebCore::Editor::reappliedEditing):
(WebCore::Editor::computeAndSetTypingStyle):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::editingAction):
* editing/InsertListCommand.h:
(WebCore::InsertListCommand::preservesTypingStyle): Deleted.
(WebCore::InsertListCommand::editingAction): Deleted.
* editing/ReplaceRangeWithTextCommand.cpp:
(WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
* editing/TypingCommand.cpp:
(WebCore::editActionForTypingCommand):
(WebCore::TypingCommand::TypingCommand):
(WebCore::TypingCommand::inputEventTypeName):

The editingAction() of a TypingCommand is the first editing action the TypingCommand was initialized using.
Since subsequent typing commands update the last open typing command, we override inputEventTypeName here to
use the last updated editing action rather than the default (initial) editing action.

(WebCore::TypingCommand::willAddTypingToOpenCommand):
(WebCore::TypingCommand::insertTextRunWithoutNewlines):
(WebCore::TypingCommand::insertParagraphSeparator):
* editing/TypingCommand.h:

Source/WebKit/mac:

Accounts for some changes to the EditAction enum in nameForEditAction. See WebCore ChangeLog
entry for more details.

* WebCoreSupport/WebEditorClient.mm:
(undoNameForEditAction):

Source/WebKit/win:

* WebCoreSupport/WebEditorClient.cpp:
(undoNameForEditAction):

Source/WebKit2:

Accounts for some changes to the EditAction enum in nameForEditAction. Some former edit
actions, such as EditActionTyping, have been split out into its more specific subtypes,
so we preserve shipping behavior by treating all of the new subtypes the same way as the
original type.

* UIProcess/WebEditCommandProxy.cpp:
(WebKit::WebEditCommandProxy::nameForEditAction):

LayoutTests:

Adds new layout tests to check that various actions, such as cutting, pasting and undoing can
be prevented via the InputEvent fired in a `beforechange` handler.

* fast/events/before-input-prevent-biu-expected.txt: Added.
* fast/events/before-input-prevent-biu.html: Added.
* fast/events/before-input-prevent-cut-expected.txt: Added.
* fast/events/before-input-prevent-cut.html: Added.
* fast/events/before-input-prevent-paste-expected.txt: Added.
* fast/events/before-input-prevent-paste.html: Added.
* fast/events/before-input-prevent-typing-expected.txt: Added.
* fast/events/before-input-prevent-typing.html: Added.
* fast/events/before-input-prevent-undo-expected.txt: Added.
* fast/events/before-input-prevent-undo.html: Added.
* platform/ios-simulator/TestExpectations:

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

34 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/before-input-prevent-biu-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-biu.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-cut-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-cut.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-paste-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-paste.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-typing-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-typing.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-undo-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-prevent-undo.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/InputEvent.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/EditAction.h
Source/WebCore/editing/EditCommand.cpp
Source/WebCore/editing/EditCommand.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/InsertListCommand.h
Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/TypingCommand.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebEditCommandProxy.cpp

index 69ee454..6ab1236 100644 (file)
@@ -1,3 +1,26 @@
+2016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Support InputEvent.inputType for the new InputEvent spec
+        https://bugs.webkit.org/show_bug.cgi?id=163025
+        <rdar://problem/28658092>
+
+        Reviewed by Darin Adler.
+
+        Adds new layout tests to check that various actions, such as cutting, pasting and undoing can
+        be prevented via the InputEvent fired in a `beforechange` handler.
+
+        * fast/events/before-input-prevent-biu-expected.txt: Added.
+        * fast/events/before-input-prevent-biu.html: Added.
+        * fast/events/before-input-prevent-cut-expected.txt: Added.
+        * fast/events/before-input-prevent-cut.html: Added.
+        * fast/events/before-input-prevent-paste-expected.txt: Added.
+        * fast/events/before-input-prevent-paste.html: Added.
+        * fast/events/before-input-prevent-typing-expected.txt: Added.
+        * fast/events/before-input-prevent-typing.html: Added.
+        * fast/events/before-input-prevent-undo-expected.txt: Added.
+        * fast/events/before-input-prevent-undo.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
 2016-10-09  Gyuyoung Kim  <gyuyoung.kim@navercorp.com>
 
         [EFL] Gardening timout tests, failure tests on Oct. 10th.
diff --git a/LayoutTests/fast/events/before-input-prevent-biu-expected.txt b/LayoutTests/fast/events/before-input-prevent-biu-expected.txt
new file mode 100644 (file)
index 0000000..6740680
--- /dev/null
@@ -0,0 +1,7 @@
+To manually test this, turn on bold, italic and underline via the context menu, and then type some text into the contenteditable. The text should be italicized and underlined, but not bold.
+
+after typing:
+| "abc"
+| <i>
+|   <u>
+|     "def<#selection-caret>"
diff --git a/LayoutTests/fast/events/before-input-prevent-biu.html b/LayoutTests/fast/events/before-input-prevent-biu.html
new file mode 100644 (file)
index 0000000..9f59372
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <div id="editable" contenteditable onbeforeinput=handleBeforeInput(event)></div>
+    <script src="../../resources/dump-as-markup.js"></script>
+    <script type="text/javascript">
+        Markup.description(`To manually test this, turn on bold, italic and underline via the context menu, and then type some text into the contenteditable. The text should be italicized and underlined, but not bold.`);
+
+        (function() {
+            if (!window.internals || !window.eventSender || !window.testRunner)
+                return;
+
+            internals.settings.setInputEventsEnabled(true);
+            document.querySelector("#editable").focus();
+
+            eventSender.keyDown("a", []);
+            eventSender.keyDown("b", []);
+            eventSender.keyDown("c", []);
+
+            testRunner.execCommand("ToggleBold");
+            testRunner.execCommand("ToggleItalic");
+            testRunner.execCommand("ToggleUnderline");
+
+            eventSender.keyDown("d", []);
+            eventSender.keyDown("e", []);
+            eventSender.keyDown("f", []);
+            Markup.dump("editable", "after typing");
+
+        })();
+
+        function handleBeforeInput(event)
+        {
+            if (event.inputType === "formatBold")
+                event.preventDefault();
+        }
+    </script>
+</body>
+
+</html>
diff --git a/LayoutTests/fast/events/before-input-prevent-cut-expected.txt b/LayoutTests/fast/events/before-input-prevent-cut-expected.txt
new file mode 100644 (file)
index 0000000..489baf1
--- /dev/null
@@ -0,0 +1,19 @@
+To manually test this, select the text in the input and attempt to cut. The value of the input should not change.
+
+initial value:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "helloworld"
+
+after prevented cut:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "helloworld"
+
+after allowed cut:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       <br>
diff --git a/LayoutTests/fast/events/before-input-prevent-cut.html b/LayoutTests/fast/events/before-input-prevent-cut.html
new file mode 100644 (file)
index 0000000..f6b4b4f
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input id="field" onfocus=handleFocus() value="helloworld" onbeforeinput=handleBeforeInput(event)></div>
+    <script src="../../resources/dump-as-markup.js"></script>
+    <script>
+        Markup.description(`To manually test this, select the text in the input and attempt to cut. The value of the input should not change.`);
+
+        var allowCut = false;
+        (function() {
+            if (!window.internals || !window.eventSender || !window.testRunner)
+                return;
+
+            internals.settings.setInputEventsEnabled(true);
+            document.querySelector("#field").focus();
+        })();
+
+        function handleBeforeInput(event)
+        {
+            if (allowCut)
+                return;
+
+            if (event.inputType === "deleteByCut")
+                event.preventDefault();
+        }
+
+        function handleFocus()
+        {
+            document.querySelector("#field").select();
+            Markup.dump("field", "initial value");
+
+            testRunner.execCommand("Cut");
+            Markup.dump("field", "after prevented cut");
+
+            allowCut = true;
+            testRunner.execCommand("Cut");
+            Markup.dump("field", "after allowed cut");
+        }
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/before-input-prevent-paste-expected.txt b/LayoutTests/fast/events/before-input-prevent-paste-expected.txt
new file mode 100644 (file)
index 0000000..e860be8
--- /dev/null
@@ -0,0 +1,26 @@
+To manually test this, copy any text and try to paste into the input field. The value of the input should not change.
+
+initial value:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "helloworld"
+
+after the cut:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       <br>
+
+after prevented paste:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       <br>
+
+after allowed paste:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "helloworld"
+|       <br>
diff --git a/LayoutTests/fast/events/before-input-prevent-paste.html b/LayoutTests/fast/events/before-input-prevent-paste.html
new file mode 100644 (file)
index 0000000..b5b44ec
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+    <input id="field" onfocus=handleFocus() value="helloworld" onbeforeinput=handleBeforeInput(event)></div>
+    <script src="../../resources/dump-as-markup.js"></script>
+    <script>
+        Markup.description(`To manually test this, copy any text and try to paste into the input field. The value of the input should not change.`);
+
+        var allowPaste = false;
+        (function() {
+            if (!window.internals || !window.eventSender || !window.testRunner)
+                return;
+
+            internals.settings.setInputEventsEnabled(true);
+            document.querySelector("input").focus();
+        })();
+
+        function handleBeforeInput(event)
+        {
+            if (allowPaste)
+                return;
+
+            if (event.inputType == "insertFromPaste")
+                event.preventDefault();
+        }
+
+        function handleFocus()
+        {
+            document.querySelector("input").select();
+
+            Markup.dump("field", "initial value");
+
+            testRunner.execCommand("Cut");
+            Markup.dump("field", "after the cut");
+
+            testRunner.execCommand("Paste");
+            Markup.dump("field", "after prevented paste");
+
+            allowPaste = true;
+            testRunner.execCommand("Paste");
+            Markup.dump("field", "after allowed paste");
+        }
+    </script>
+</body>
+
+</html>
diff --git a/LayoutTests/fast/events/before-input-prevent-typing-expected.txt b/LayoutTests/fast/events/before-input-prevent-typing-expected.txt
new file mode 100644 (file)
index 0000000..a86789c
--- /dev/null
@@ -0,0 +1,16 @@
+To manually test this, ensure that typing or attempting to delete text via the Delete key does not change the DOM.
+
+initially:
+| "<#selection-caret>def"
+
+after attempting to type (typing is allowed):
+| "abc<#selection-caret>def"
+
+after attempting to type (typing is prohibited):
+| "abc<#selection-caret>def"
+
+after attempting to delete (deleting is prohibited):
+| "abc<#selection-caret>def"
+
+after attempting to delete (deleting is allowed):
+| "a<#selection-caret>ef"
diff --git a/LayoutTests/fast/events/before-input-prevent-typing.html b/LayoutTests/fast/events/before-input-prevent-typing.html
new file mode 100644 (file)
index 0000000..dcfa57a
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <div id="editable" contenteditable onbeforeinput=handleBeforeInput(event)>def</div>
+    <script src="../../resources/dump-as-markup.js"></script>
+    <script type="text/javascript">
+        Markup.description(`To manually test this, ensure that typing or attempting to delete text via the Delete key does not change the DOM.`);
+
+        var allowTyping = !!window.eventSender;
+        (function() {
+            if (!window.internals || !window.eventSender || !window.testRunner)
+                return;
+
+            internals.settings.setInputEventsEnabled(true);
+            document.querySelector("#editable").focus();
+
+            Markup.dump("editable", "initially");
+
+            eventSender.keyDown("a", []);
+            eventSender.keyDown("b", []);
+            eventSender.keyDown("c", []);
+            Markup.dump("editable", "after attempting to type (typing is allowed)");
+
+            allowTyping = false;
+            eventSender.keyDown("d", []);
+            eventSender.keyDown("e", []);
+            eventSender.keyDown("f", []);
+            Markup.dump("editable", "after attempting to type (typing is prohibited)");
+
+            testRunner.execCommand("DeleteForward");
+            testRunner.execCommand("DeleteBackward");
+            testRunner.execCommand("DeleteForward");
+            Markup.dump("editable", "after attempting to delete (deleting is prohibited)");
+            allowTyping = true;
+
+            testRunner.execCommand("DeleteBackward");
+            testRunner.execCommand("DeleteForward");
+            testRunner.execCommand("DeleteBackward");
+            Markup.dump("editable", "after attempting to delete (deleting is allowed)");
+        })();
+
+        function handleBeforeInput(event)
+        {
+            if (allowTyping)
+                return;
+
+            if (event.inputType === "insertText" || event.inputType === "deleteContentBackward" || event.inputType === "deleteContentForward")
+                event.preventDefault();
+        }
+    </script>
+</body>
+
+</html>
diff --git a/LayoutTests/fast/events/before-input-prevent-undo-expected.txt b/LayoutTests/fast/events/before-input-prevent-undo-expected.txt
new file mode 100644 (file)
index 0000000..25e4869
--- /dev/null
@@ -0,0 +1,13 @@
+To manually test this, type some into the input field below and try to undo. The value of the text field should not change after attempting to undo.
+
+initial value:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "abc"
+
+after prevented undo:
+|   <shadow:root>
+|     <div>
+|       contenteditable="plaintext-only"
+|       "abc"
diff --git a/LayoutTests/fast/events/before-input-prevent-undo.html b/LayoutTests/fast/events/before-input-prevent-undo.html
new file mode 100644 (file)
index 0000000..f1ac6f6
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+    <input id="field" onbeforeinput=handleBeforeInput(event)></input>
+    <script src="../../resources/dump-as-markup.js"></script>
+    <script>
+        Markup.description(`To manually test this, type some into the input field below and try to undo. The value of the text field should not change after attempting to undo.`);
+
+        (function() {
+            if (!window.internals || !window.eventSender || !window.testRunner)
+                return;
+
+            internals.settings.setInputEventsEnabled(true);
+            document.querySelector("#field").focus();
+
+            eventSender.keyDown("a", []);
+            eventSender.keyDown("b", []);
+            eventSender.keyDown("c", []);
+            Markup.dump("field", "initial value");
+
+            testRunner.execCommand("Undo");
+            Markup.dump("field", "after prevented undo");
+        })();
+
+        function handleBeforeInput(event)
+        {
+            if (event.inputType === "historyUndo")
+                event.preventDefault();
+        }
+    </script>
+</body>
+
+</html>
index 8114633..229e6a4 100644 (file)
@@ -1201,6 +1201,11 @@ fast/events/input-events-fired-when-typing.html [ Failure ]
 fast/events/before-input-events-prevent-default.html [ Failure ]
 fast/events/before-input-events-prevent-default-in-textfield.html [ Failure ]
 fast/events/before-input-events-different-start-end-elements.html [ Failure ]
+fast/events/before-input-prevent-biu.html [ Failure ]
+fast/events/before-input-prevent-cut.html [ Failure ]
+fast/events/before-input-prevent-paste.html [ Failure ]
+fast/events/before-input-prevent-undo.html [ Failure ]
+fast/events/before-input-prevent-typing.html [ Failure ]
 fast/events/key-events-in-input-button.html [ Failure ]
 fast/events/keydown-1.html [ Failure ]
 fast/events/keydown-leftright-keys.html [ Failure ]
index 19b9240..d4af5b5 100644 (file)
@@ -1,3 +1,74 @@
+2016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Support InputEvent.inputType for the new InputEvent spec
+        https://bugs.webkit.org/show_bug.cgi?id=163025
+        <rdar://problem/28658092>
+
+        Reviewed by Darin Adler.
+
+        Adds support for the inputType attribute of InputEvent. To do this, we introduce a helper to
+        map EditActions to inputType names, and also split out ambiguous EditActions (such as
+        EditActionTyping) into more specific subtypes (such as EditActionTypingDeleteBackward,
+        EditActionTypingInsertParagraph, etc.), each of which corresponds to an inputType.
+
+        In places where we create CompositeEditCommands, we now pass in these specific EditActions
+        where appropriate, and when dispatching `beforeinput` and `input` events, we ask the
+        CompositeEditCommand for its input type name, which it derives from its editingAction.
+
+        Tests: fast/events/before-input-prevent-biu.html
+               fast/events/before-input-prevent-cut.html
+               fast/events/before-input-prevent-paste.html
+               fast/events/before-input-prevent-typing.html
+               fast/events/before-input-prevent-undo.html
+
+        * dom/InputEvent.h:
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchInputEvent):
+        * dom/Node.h:
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::apply):
+        (WebCore::CompositeEditCommand::inputEventTypeName):
+
+        Allows a CompositeEditCommand to specify the inputType its corresponding `beforeinput` and `input` events
+        should have.
+
+        * editing/CompositeEditCommand.h:
+        (WebCore::CompositeEditCommand::shouldStopCaretBlinking): Deleted.
+        * editing/EditAction.h:
+        * editing/EditCommand.cpp:
+        (WebCore::inputTypeNameForEditingAction):
+        * editing/EditCommand.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::willApplyEditing):
+        (WebCore::Editor::appliedEditing):
+        (WebCore::Editor::willUnapplyEditing):
+        (WebCore::Editor::unappliedEditing):
+        (WebCore::Editor::willReapplyEditing):
+        (WebCore::Editor::reappliedEditing):
+        (WebCore::Editor::computeAndSetTypingStyle):
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::editingAction):
+        * editing/InsertListCommand.h:
+        (WebCore::InsertListCommand::preservesTypingStyle): Deleted.
+        (WebCore::InsertListCommand::editingAction): Deleted.
+        * editing/ReplaceRangeWithTextCommand.cpp:
+        (WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):
+        * editing/SpellingCorrectionCommand.cpp:
+        (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
+        * editing/TypingCommand.cpp:
+        (WebCore::editActionForTypingCommand):
+        (WebCore::TypingCommand::TypingCommand):
+        (WebCore::TypingCommand::inputEventTypeName):
+
+        The editingAction() of a TypingCommand is the first editing action the TypingCommand was initialized using.
+        Since subsequent typing commands update the last open typing command, we override inputEventTypeName here to
+        use the last updated editing action rather than the default (initial) editing action.
+
+        (WebCore::TypingCommand::willAddTypingToOpenCommand):
+        (WebCore::TypingCommand::insertTextRunWithoutNewlines):
+        (WebCore::TypingCommand::insertParagraphSeparator):
+        * editing/TypingCommand.h:
+
 2016-10-09  Darin Adler  <darin@apple.com>
 
         Move ApplePaySession from legacy to new DOM exceptions
index a65d332..d009342 100644 (file)
@@ -55,10 +55,10 @@ public:
 
     bool isInputEvent() const override { return true; }
     EventInterface eventInterface() const final { return InputEventInterfaceType; }
-    String inputType() const { return m_inputType.string(); }
+    String inputType() const { return m_inputType; }
 
 private:
-    AtomicString m_inputType;
+    String m_inputType;
 };
 
 } // namespace WebCore
index 84eb585..f0a98d4 100644 (file)
@@ -2198,7 +2198,7 @@ bool Node::dispatchBeforeLoadEvent(const String& sourceURL)
     return !beforeLoadEvent->defaultPrevented();
 }
 
-void Node::dispatchInputEvent(const AtomicString& inputType)
+void Node::dispatchInputEvent(const String& inputType)
 {
     auto* settings = document().settings();
     if (settings && settings->inputEventsEnabled())
index ace7437..107fefe 100644 (file)
@@ -525,7 +525,7 @@ public:
 
     bool dispatchBeforeLoadEvent(const String& sourceURL);
 
-    virtual void dispatchInputEvent(const AtomicString& inputType);
+    virtual void dispatchInputEvent(const String& inputType);
 
     // Perform the default action for an event.
     virtual void defaultEventHandler(Event&);
index 61fa1f6..fc0850f 100644 (file)
@@ -326,13 +326,23 @@ void CompositeEditCommand::apply()
 {
     if (!endingSelection().isContentRichlyEditable()) {
         switch (editingAction()) {
-        case EditActionTyping:
+        case EditActionTypingDeleteSelection:
+        case EditActionTypingDeleteBackward:
+        case EditActionTypingDeleteForward:
+        case EditActionTypingDeleteWordBackward:
+        case EditActionTypingDeleteWordForward:
+        case EditActionTypingDeleteLineBackward:
+        case EditActionTypingDeleteLineForward:
+        case EditActionTypingInsertText:
+        case EditActionTypingInsertLineBreak:
+        case EditActionTypingInsertParagraph:
         case EditActionPaste:
         case EditActionDrag:
         case EditActionSetWritingDirection:
         case EditActionCut:
         case EditActionUnspecified:
         case EditActionInsert:
+        case EditActionInsertReplacement:
         case EditActionDelete:
         case EditActionDictation:
             break;
@@ -399,6 +409,11 @@ void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool)
 {
 }
 
+String CompositeEditCommand::inputEventTypeName() const
+{
+    return inputTypeNameForEditingAction(editingAction());
+}
+
 //
 // sugary-sweet convenience functions to help create and apply edit commands in composite commands
 //
index 147d274..0f287a4 100644 (file)
@@ -113,6 +113,7 @@ public:
     virtual bool shouldRetainAutocorrectionIndicator() const;
     virtual void setShouldRetainAutocorrectionIndicator(bool);
     virtual bool shouldStopCaretBlinking() const { return false; }
+    virtual String inputEventTypeName() const;
 
 protected:
     explicit CompositeEditCommand(Document&, EditAction = EditActionUnspecified);
index 6ef3506..ba3cc54 100644 (file)
@@ -30,6 +30,7 @@ namespace WebCore {
     typedef enum {
         EditActionUnspecified,
         EditActionInsert,
+        EditActionInsertReplacement,
         EditActionSetColor,
         EditActionSetBackgroundColor,
         EditActionTurnOffKerning,
@@ -63,11 +64,21 @@ namespace WebCore {
         EditActionPaste,
         EditActionPasteFont,
         EditActionPasteRuler,
-        EditActionTyping,
+        EditActionTypingDeleteSelection,
+        EditActionTypingDeleteBackward,
+        EditActionTypingDeleteForward,
+        EditActionTypingDeleteWordBackward,
+        EditActionTypingDeleteWordForward,
+        EditActionTypingDeleteLineBackward,
+        EditActionTypingDeleteLineForward,
+        EditActionTypingInsertText,
+        EditActionTypingInsertLineBreak,
+        EditActionTypingInsertParagraph,
         EditActionCreateLink,
         EditActionUnlink,
         EditActionFormatBlock,
-        EditActionInsertList,
+        EditActionInsertOrderedList,
+        EditActionInsertUnorderedList,
         EditActionIndent,
         EditActionOutdent
     } EditAction;    
index 545388f..7af58f9 100644 (file)
 
 namespace WebCore {
 
+String inputTypeNameForEditingAction(EditAction action)
+{
+    switch (action) {
+    case EditActionJustify:
+    case EditActionAlignLeft:
+        return ASCIILiteral("formatJustifyLeft");
+    case EditActionAlignRight:
+        return ASCIILiteral("formatJustifyRight");
+    case EditActionCenter:
+        return ASCIILiteral("formatJustifyCenter");
+    case EditActionSubscript:
+        return ASCIILiteral("formatSubscript");
+    case EditActionSuperscript:
+        return ASCIILiteral("formatSuperscript");
+    case EditActionUnderline:
+        return ASCIILiteral("formatUnderline");
+    case EditActionDrag:
+        return ASCIILiteral("deleteByDrag");
+    case EditActionCut:
+        return ASCIILiteral("deleteByCut");
+    case EditActionBold:
+        return ASCIILiteral("formatBold");
+    case EditActionItalics:
+        return ASCIILiteral("formatItalic");
+    case EditActionPaste:
+        return ASCIILiteral("insertFromPaste");
+    case EditActionDelete:
+    case EditActionTypingDeleteSelection:
+        return ASCIILiteral("deleteContent");
+    case EditActionTypingDeleteBackward:
+        return ASCIILiteral("deleteContentBackward");
+    case EditActionTypingDeleteForward:
+        return ASCIILiteral("deleteContentForward");
+    case EditActionTypingDeleteWordBackward:
+        return ASCIILiteral("deleteWordBackward");
+    case EditActionTypingDeleteWordForward:
+        return ASCIILiteral("deleteWordForward");
+    case EditActionTypingDeleteLineBackward:
+        return ASCIILiteral("deleteHardLineBackward");
+    case EditActionTypingDeleteLineForward:
+        return ASCIILiteral("deleteHardLineForward");
+    case EditActionInsert:
+    case EditActionTypingInsertText:
+        return ASCIILiteral("insertText");
+    case EditActionInsertReplacement:
+        return ASCIILiteral("insertReplacementText");
+    case EditActionTypingInsertLineBreak:
+        return ASCIILiteral("insertLineBreak");
+    case EditActionTypingInsertParagraph:
+        return ASCIILiteral("insertParagraph");
+    case EditActionInsertOrderedList:
+        return ASCIILiteral("insertOrderedList");
+    case EditActionInsertUnorderedList:
+        return ASCIILiteral("insertUnorderedList");
+    case EditActionIndent:
+        return ASCIILiteral("formatIndent");
+    case EditActionOutdent:
+        return ASCIILiteral("formatOutdent");
+    default:
+        return emptyString();
+    }
+}
+
 EditCommand::EditCommand(Document& document, EditAction editingAction)
     : m_document(document)
     , m_editingAction(editingAction)
index d1657f3..04850df 100644 (file)
@@ -41,13 +41,15 @@ class Document;
 class Element;
 class Frame;
 
+String inputTypeNameForEditingAction(EditAction);
+
 class EditCommand : public RefCounted<EditCommand> {
 public:
     virtual ~EditCommand();
 
     void setParent(CompositeEditCommand*);
 
-    EditAction editingAction() const;
+    virtual EditAction editingAction() const;
 
     const VisibleSelection& startingSelection() const { return m_startingSelection; }
     const VisibleSelection& endingSelection() const { return m_endingSelection; }
index 021148a..350e5ba 100644 (file)
@@ -1067,7 +1067,7 @@ bool Editor::willApplyEditing(CompositeEditCommand& command) const
     if (!composition)
         return true;
 
-    return dispatchBeforeInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString());
+    return dispatchBeforeInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), command.inputEventTypeName());
 }
 
 void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
@@ -1086,7 +1086,7 @@ void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
     FrameSelection::SetSelectionOptions options = cmd->isDictationCommand() ? FrameSelection::DictationTriggered : 0;
     
     changeSelectionAfterCommand(newSelection, options);
-    dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString());
+    dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), cmd->inputEventTypeName());
 
     updateEditorUINowIfScheduled();
     
@@ -1111,7 +1111,7 @@ void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
 
 bool Editor::willUnapplyEditing(const EditCommandComposition& composition) const
 {
-    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString());
+    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), "historyUndo");
 }
 
 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
@@ -1122,7 +1122,7 @@ void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
 
     VisibleSelection newSelection(cmd->startingSelection());
     changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions());
-    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString());
+    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), "historyUndo");
 
     updateEditorUINowIfScheduled();
 
@@ -1136,7 +1136,7 @@ void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
 
 bool Editor::willReapplyEditing(const EditCommandComposition& composition) const
 {
-    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString());
+    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), "historyRedo");
 }
 
 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd)
@@ -1147,7 +1147,7 @@ void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd)
 
     VisibleSelection newSelection(cmd->endingSelection());
     changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions());
-    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString());
+    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), "historyRedo");
     
     updateEditorUINowIfScheduled();
 
@@ -3097,8 +3097,9 @@ void Editor::computeAndSetTypingStyle(EditingStyle& style, EditAction editingAct
         return;
     }
 
+    String inputTypeName = inputTypeNameForEditingAction(editingAction);
     auto* element = m_frame.selection().selection().rootEditableElement();
-    if (element && !dispatchBeforeInputEvent(*element, emptyString()))
+    if (element && !dispatchBeforeInputEvent(*element, inputTypeName))
         return;
 
     // Calculate the current typing style.
@@ -3115,7 +3116,7 @@ void Editor::computeAndSetTypingStyle(EditingStyle& style, EditAction editingAct
         applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction));
 
     if (element)
-        element->dispatchInputEvent(emptyString());
+        element->dispatchInputEvent(inputTypeName);
 
     // Set the remaining style as the typing style.
     m_frame.selection().setTypingStyle(typingStyle);
index 641ea01..060ca8b 100644 (file)
@@ -193,6 +193,11 @@ void InsertListCommand::doApply()
     doApplyForSingleParagraph(false, listTag, endingSelection().firstRange().get());
 }
 
+EditAction InsertListCommand::editingAction() const
+{
+    return m_type == OrderedList ? EditActionInsertOrderedList : EditActionInsertUnorderedList;
+}
+
 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection)
 {
     // FIXME: This will produce unexpected results for a selection that starts just before a
index d938c34..67c5d5c 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 class HTMLElement;
 class HTMLQualifiedName;
 
-class InsertListCommand : public CompositeEditCommand {
+class InsertListCommand final : public CompositeEditCommand {
 public:
     enum Type { OrderedList, UnorderedList };
 
@@ -44,13 +44,13 @@ public:
 
     static RefPtr<HTMLElement> insertList(Document&, Type);
     
-    virtual bool preservesTypingStyle() const { return true; }
+    bool preservesTypingStyle() const final { return true; }
 
 private:
     InsertListCommand(Document&, Type);
 
-    virtual void doApply();
-    virtual EditAction editingAction() const { return EditActionInsertList; }
+    void doApply() final;
+    EditAction editingAction() const final;
 
     HTMLElement* fixOrphanedListChild(Node*);
     bool selectionHasListOfType(const VisibleSelection& selection, const QualifiedName&);
index 435ef47..986ee58 100644 (file)
@@ -39,7 +39,7 @@
 namespace WebCore {
 
 ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand(RefPtr<Range> rangeToBeReplaced, const String& text)
-    : CompositeEditCommand(rangeToBeReplaced->startContainer().document())
+    : CompositeEditCommand(rangeToBeReplaced->startContainer().document(), EditActionInsertReplacement)
     , m_rangeToBeReplaced(rangeToBeReplaced)
     , m_text(text)
 {
index 2325e77..a4287d4 100644 (file)
@@ -82,7 +82,7 @@ private:
 #endif
 
 SpellingCorrectionCommand::SpellingCorrectionCommand(PassRefPtr<Range> rangeToBeCorrected, const String& correction)
-    : CompositeEditCommand(rangeToBeCorrected->startContainer().document())
+    : CompositeEditCommand(rangeToBeCorrected->startContainer().document(), EditActionInsertReplacement)
     , m_rangeToBeCorrected(rangeToBeCorrected)
     , m_selectionToBeCorrected(*m_rangeToBeCorrected)
     , m_correction(correction)
index 1412711..e35f6d3 100644 (file)
@@ -76,8 +76,38 @@ private:
     const String& m_text;
 };
 
+static inline EditAction editActionForTypingCommand(TypingCommand::ETypingCommand command, TextGranularity granularity)
+{
+    switch (command) {
+    case TypingCommand::DeleteSelection:
+        return EditActionTypingDeleteSelection;
+    case TypingCommand::DeleteKey: {
+        if (granularity == WordGranularity)
+            return EditActionTypingDeleteWordBackward;
+        if (granularity == LineBoundary)
+            return EditActionTypingDeleteLineBackward;
+        return EditActionTypingDeleteBackward;
+    }
+    case TypingCommand::ForwardDeleteKey:
+        if (granularity == WordGranularity)
+            return EditActionTypingDeleteWordForward;
+        if (granularity == LineBoundary)
+            return EditActionTypingDeleteLineForward;
+        return EditActionTypingDeleteForward;
+    case TypingCommand::InsertText:
+        return EditActionTypingInsertText;
+    case TypingCommand::InsertLineBreak:
+        return EditActionTypingInsertLineBreak;
+    case TypingCommand::InsertParagraphSeparator:
+    case TypingCommand::InsertParagraphSeparatorInQuotedContent:
+        return EditActionTypingInsertParagraph;
+    default:
+        return EditActionUnspecified;
+    }
+}
+
 TypingCommand::TypingCommand(Document& document, ETypingCommand commandType, const String &textToInsert, Options options, TextGranularity granularity, TextCompositionType compositionType)
-    : TextInsertionBaseCommand(document, EditActionTyping)
+    : TextInsertionBaseCommand(document, editActionForTypingCommand(commandType, granularity))
     , m_commandType(commandType)
     , m_textToInsert(textToInsert)
     , m_openForMoreTyping(true)
@@ -90,6 +120,7 @@ TypingCommand::TypingCommand(Document& document, ETypingCommand commandType, con
     , m_shouldRetainAutocorrectionIndicator(options & RetainAutocorrectionIndicator)
     , m_shouldPreventSpellChecking(options & PreventSpellChecking)
 {
+    m_currentTypingEditAction = editingAction();
     updatePreservesTypingStyle(m_commandType);
 }
 
@@ -308,6 +339,11 @@ void TypingCommand::doApply()
     ASSERT_NOT_REACHED();
 }
 
+String TypingCommand::inputEventTypeName() const
+{
+    return inputTypeNameForEditingAction(m_currentTypingEditAction);
+}
+
 void TypingCommand::didApplyCommand()
 {
     // TypingCommands handle applied editing separately (see TypingCommand::typingAddedToOpenCommand).
@@ -368,13 +404,14 @@ void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType)
     }
 }
 
-bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand, TextGranularity)
+bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity)
 {
     if (m_isHandlingInitialTypingCommand)
         return true;
 
     // FIXME: Use the newly added typing command and granularity to ensure that an InputEvent with the
     // correct inputType is dispatched.
+    m_currentTypingEditAction = editActionForTypingCommand(commandType, granularity);
     return frame().editor().willApplyEditing(*this);
 }
 
@@ -423,7 +460,7 @@ void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool select
         return;
 
     RefPtr<InsertTextCommand> command = InsertTextCommand::create(document(), text, selectInsertedText,
-        m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditActionTyping);
+        m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditActionTypingInsertText);
 
     applyCommandToComposite(command, endingSelection());
 
@@ -458,7 +495,7 @@ void TypingCommand::insertParagraphSeparator()
     if (!willAddTypingToOpenCommand(InsertParagraphSeparator, ParagraphGranularity))
         return;
 
-    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionTyping));
+    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionTypingInsertParagraph));
     typingAddedToOpenCommand(InsertParagraphSeparator);
 }
 
index 15684bd..cdd6ae6 100644 (file)
@@ -116,6 +116,8 @@ private:
     bool shouldStopCaretBlinking() const { return true; }
     void setShouldPreventSpellChecking(bool prevent) { m_shouldPreventSpellChecking = prevent; }
 
+    String inputEventTypeName() const final;
+
     static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*);
 
     void updatePreservesTypingStyle(ETypingCommand);
@@ -134,6 +136,7 @@ private:
     void didApplyCommand();
 
     ETypingCommand m_commandType;
+    EditAction m_currentTypingEditAction;
     String m_textToInsert;
     bool m_openForMoreTyping;
     bool m_selectInsertedText;
index 8162299..15b6d41 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Support InputEvent.inputType for the new InputEvent spec
+        https://bugs.webkit.org/show_bug.cgi?id=163025
+        <rdar://problem/28658092>
+
+        Reviewed by Darin Adler.
+
+        Accounts for some changes to the EditAction enum in nameForEditAction. See WebCore ChangeLog
+        entry for more details.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (undoNameForEditAction):
+
 2016-10-06  Darin Adler  <darin@apple.com>
 
         Next step on moving to modern way to return DOM exceptions
index f8262e8..782f3c8 100644 (file)
@@ -563,6 +563,7 @@ static NSString* undoNameForEditAction(EditAction editAction)
     switch (editAction) {
         case EditActionUnspecified: return nil;
         case EditActionInsert: return nil;
+        case EditActionInsertReplacement: 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");
@@ -592,10 +593,22 @@ static NSString* undoNameForEditAction(EditAction editAction)
         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 EditActionTyping: return UI_STRING_KEY_INTERNAL("Typing", "Typing (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:
+            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 EditActionInsertList: return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (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");
index 9dc3a62..c9eaf92 100644 (file)
@@ -1,3 +1,14 @@
+2016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Support InputEvent.inputType for the new InputEvent spec
+        https://bugs.webkit.org/show_bug.cgi?id=163025
+        <rdar://problem/28658092>
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (undoNameForEditAction):
+
 2016-10-04  Brent Fulgham  <bfulgham@apple.com>
 
         [Win][Direct2D] Connect WebCore/WebKit Drawing
index 2aac714..42fe551 100644 (file)
@@ -563,7 +563,9 @@ ULONG WebEditorUndoCommand::Release()
 static String undoNameForEditAction(EditAction editAction)
 {
     switch (editAction) {
-    case EditActionUnspecified: return String();
+    case EditActionUnspecified:
+    case EditActionInsertReplacement:
+        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");
@@ -595,10 +597,22 @@ static String undoNameForEditAction(EditAction editAction)
     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 EditActionTyping: return WEB_UI_STRING_KEY("Typing", "Typing (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:
+        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 EditActionInsertList: return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
+    case EditActionInsertUnorderedList:
+    case EditActionInsertOrderedList:
+        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");
index f35820b..97b0b10 100644 (file)
@@ -1,3 +1,19 @@
+2016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Support InputEvent.inputType for the new InputEvent spec
+        https://bugs.webkit.org/show_bug.cgi?id=163025
+        <rdar://problem/28658092>
+
+        Reviewed by Darin Adler.
+
+        Accounts for some changes to the EditAction enum in nameForEditAction. Some former edit
+        actions, such as EditActionTyping, have been split out into its more specific subtypes,
+        so we preserve shipping behavior by treating all of the new subtypes the same way as the
+        original type.
+
+        * UIProcess/WebEditCommandProxy.cpp:
+        (WebKit::WebEditCommandProxy::nameForEditAction):
+
 2016-10-08  Emanuele Aina  <emanuele.aina@collabora.com>
 
         [GTK] Drop redundant wl_display_flush_clients() call
index 91b699a..a3a29f1 100644 (file)
@@ -76,6 +76,8 @@ String WebEditCommandProxy::nameForEditAction(EditAction editAction)
         return String();
     case EditActionInsert:
         return String();
+    case EditActionInsertReplacement:
+        return String();
     case EditActionSetColor:
         return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
     case EditActionSetBackgroundColor:
@@ -142,13 +144,23 @@ String WebEditCommandProxy::nameForEditAction(EditAction editAction)
         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 EditActionTyping:
+    case EditActionTypingDeleteSelection:
+    case EditActionTypingDeleteBackward:
+    case EditActionTypingDeleteForward:
+    case EditActionTypingDeleteWordBackward:
+    case EditActionTypingDeleteWordForward:
+    case EditActionTypingDeleteLineBackward:
+    case EditActionTypingDeleteLineForward:
+    case EditActionTypingInsertText:
+    case EditActionTypingInsertLineBreak:
+    case EditActionTypingInsertParagraph:
         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 EditActionInsertList:
+    case EditActionInsertUnorderedList:
+    case EditActionInsertOrderedList:
         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");