Title: [241949] trunk
Revision
241949
Author
[email protected]
Date
2019-02-22 09:09:27 -0800 (Fri, 22 Feb 2019)

Log Message

Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
https://bugs.webkit.org/show_bug.cgi?id=194703
<rdar://problem/48111775>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Currently, when changing text direction, WebKit always sends input events of type formatSetInlineTextDirection,
even when changing paragraph text direction. Instead, we should be emitting formatSetBlockTextDirection in this
scenario. This is problematic when using the context menus on macOS to change writing direction, since changing
"Selection Direction" is currently indistinguishable from changing "Paragraph Direction".

To fix this, we split EditAction::SetWritingDirection into EditAction::SetInlineWritingDirection and
EditAction::SetBlockWritingDirection, which emit inline and block text direction input events, respectively.

Tests: fast/events/before-input-events-prevent-block-text-direction.html
       fast/events/before-input-events-prevent-inline-text-direction.html

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::apply):
* editing/EditAction.cpp:
(WebCore::undoRedoLabel):
* editing/EditAction.h:
* editing/EditCommand.cpp:
(WebCore::inputTypeNameForEditingAction):
* editing/Editor.cpp:
(WebCore::inputEventDataForEditingStyleAndAction):
(WebCore::Editor::setBaseWritingDirection):
* editing/EditorCommand.cpp:
(WebCore::executeMakeTextWritingDirectionLeftToRight):
(WebCore::executeMakeTextWritingDirectionNatural):
(WebCore::executeMakeTextWritingDirectionRightToLeft):

Source/WebKitLegacy/win:

* WebCoreSupport/WebEditorClient.cpp:
(undoNameForEditAction):

LayoutTests:

Rebaseline some existing tests to expect input events of type "formatSetBlockTextDirection" instead of
"formatSetInlineTextDirection" when changing paragraph text direction; additionally, add a new layout test that
changes the inline text direction in some Bidi text, and verify that "formatSetInlineTextDirection" is emitted
in this scenario, and that calling `preventDefault()` in the beforeinput event handler causes no change to be
made.

* editing/input/ios/rtl-keyboard-input-on-focus-expected.txt:
* fast/events/before-input-events-prevent-block-text-direction-expected.txt: Added.
* fast/events/before-input-events-prevent-block-text-direction.html: Renamed from LayoutTests/fast/events/before-input-events-prevent-text-direction.html.
* fast/events/before-input-events-prevent-inline-text-direction-expected.txt: Added.
* fast/events/before-input-events-prevent-inline-text-direction.html: Added.
* fast/events/before-input-events-prevent-text-direction-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241948 => 241949)


--- trunk/LayoutTests/ChangeLog	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/LayoutTests/ChangeLog	2019-02-22 17:09:27 UTC (rev 241949)
@@ -1,3 +1,24 @@
+2019-02-22  Wenson Hsieh  <[email protected]>
+
+        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
+        https://bugs.webkit.org/show_bug.cgi?id=194703
+        <rdar://problem/48111775>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline some existing tests to expect input events of type "formatSetBlockTextDirection" instead of
+        "formatSetInlineTextDirection" when changing paragraph text direction; additionally, add a new layout test that
+        changes the inline text direction in some Bidi text, and verify that "formatSetInlineTextDirection" is emitted
+        in this scenario, and that calling `preventDefault()` in the beforeinput event handler causes no change to be
+        made.
+
+        * editing/input/ios/rtl-keyboard-input-on-focus-expected.txt:
+        * fast/events/before-input-events-prevent-block-text-direction-expected.txt: Added.
+        * fast/events/before-input-events-prevent-block-text-direction.html: Renamed from LayoutTests/fast/events/before-input-events-prevent-text-direction.html.
+        * fast/events/before-input-events-prevent-inline-text-direction-expected.txt: Added.
+        * fast/events/before-input-events-prevent-inline-text-direction.html: Added.
+        * fast/events/before-input-events-prevent-text-direction-expected.txt: Removed.
+
 2019-02-22  Rob Buis  <[email protected]>
 
         Fix unitless usage of mathsize

Modified: trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-expected.txt (241948 => 241949)


--- trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-expected.txt	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-expected.txt	2019-02-22 17:09:27 UTC (rev 241949)
@@ -14,12 +14,12 @@
 
 Observed 'beforeinput' events: [
     {
-        "inputType": "formatSetInlineTextDirection",
+        "inputType": "formatSetBlockTextDirection",
         "data": "rtl",
         "order": 1
     },
     {
-        "inputType": "formatSetInlineTextDirection",
+        "inputType": "formatSetBlockTextDirection",
         "data": "ltr",
         "order": 3
     }
@@ -26,12 +26,12 @@
 ]
 Observed 'input' events: [
     {
-        "inputType": "formatSetInlineTextDirection",
+        "inputType": "formatSetBlockTextDirection",
         "data": "rtl",
         "order": 2
     },
     {
-        "inputType": "formatSetInlineTextDirection",
+        "inputType": "formatSetBlockTextDirection",
         "data": "ltr",
         "order": 4
     }

Added: trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction-expected.txt (0 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction-expected.txt	2019-02-22 17:09:27 UTC (rev 241949)
@@ -0,0 +1,17 @@
+Hello world
+
+*** TESTING RICH TEXT ***
+Initial text direction: "rtl"
+Fired onbeforeinput event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Text direction after setting to LTR while preventing default: "rtl"
+Fired onbeforeinput event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Fired input event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Text direction after setting to LTR without preventing default: "ltr"
+*** TESTING PLAIN TEXT ***
+Initial text direction: "rtl"
+Fired onbeforeinput event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Text direction after setting to LTR while preventing default: "rtl"
+Fired onbeforeinput event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Fired input event of inputType 'formatSetBlockTextDirection' with data: 'ltr'
+Text direction after setting to LTR without preventing default: "ltr"
+

Copied: trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction.html (from rev 241948, trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction.html) (0 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-block-text-direction.html	2019-02-22 17:09:27 UTC (rev 241949)
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        #editor {
+            direction: rtl;
+            border: 1px blue dashed;
+        }
+    </style>
+</head>
+
+<body>
+    <div id="editor" contenteditable _oninput_=handleInputEvent(event) _onbeforeinput_=handleBeforeInputEvent(event)>
+        <div id="content">Hello world</div>
+    </div>
+    <input type="text" id="textfield" value="hi" dir="rtl" _oninput_=handleInputEvent(event) _onbeforeinput_=handleBeforeInputEvent(event)></input>
+    <div id="output"></div>
+    <script>
+        let write = s => output.innerHTML += `${s}<br>`;
+        (function()
+        {
+            window.shouldPreventDefault = true;
+            if (!window.eventSender || !window.internals || !window.testRunner) {
+                write("To test manually, try to change the text direction to ltr. This should be prevented.");
+                return;
+            }
+
+            internals.settings.setInputEventsEnabled(true);
+            testRunner.dumpAsText();
+            editor.focus();
+            write("*** TESTING RICH TEXT ***");
+            write(`Initial text direction: "${getComputedStyle(content).direction}"`);
+
+            internals.setBaseWritingDirection("Ltr");
+            write(`Text direction after setting to LTR while preventing default: "${getComputedStyle(content).direction}"`);
+
+            window.shouldPreventDefault = false;
+
+            internals.setBaseWritingDirection("Ltr");
+            write(`Text direction after setting to LTR without preventing default: "${getComputedStyle(content).direction}"`);
+
+            window.shouldPreventDefault = true;
+            textfield.focus();
+            write("*** TESTING PLAIN TEXT ***");
+            write(`Initial text direction: "${textfield.getAttribute("dir")}"`);
+
+            internals.setBaseWritingDirection("Ltr");
+            write(`Text direction after setting to LTR while preventing default: "${textfield.getAttribute("dir")}"`);
+
+            window.shouldPreventDefault = false;
+
+            internals.setBaseWritingDirection("Ltr");
+            write(`Text direction after setting to LTR without preventing default: "${textfield.getAttribute("dir")}"`);
+        })();
+
+        function handleInputEvent(event)
+        {
+            write(`Fired input event of inputType '${event.inputType}' with data: '${event.data}'`);
+        }
+
+        function handleBeforeInputEvent(event)
+        {
+            write(`Fired onbeforeinput event of inputType '${event.inputType}' with data: '${event.data}'`);
+            if (window.shouldPreventDefault)
+                event.preventDefault();
+        }
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction-expected.txt (0 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction-expected.txt	2019-02-22 17:09:27 UTC (rev 241949)
@@ -0,0 +1,34 @@
+Verifies that changing the text writing direction fires input events which may be prevented. To manually test, select 'מקור' in the top contenteditable and change the selection direction to 'left to right'; then, select the same word in the prevented contenteditable and change selection direction to 'left to right'. Check that the bottom editable area's contents did not change.
+
+beforeinput, formatSetInlineTextDirection, ltr on #notPrevented:
+| "Hello <#selection-anchor>מקור<#selection-focus> השם עברית world"
+
+input, formatSetInlineTextDirection, ltr on #notPrevented:
+| "Hello "
+| <span>
+|   style="unicode-bidi: embed;"
+|   "<#selection-anchor>מקור<#selection-focus>"
+| " השם עברית world"
+
+beforeinput, formatSetInlineTextDirection, rtl on #notPrevented:
+| "Hello "
+| <span>
+|   style="unicode-bidi: embed;"
+|   "מקור"
+| " השם עברית <#selection-anchor>world<#selection-focus>"
+
+input, formatSetInlineTextDirection, rtl on #notPrevented:
+| "Hello "
+| <span>
+|   style="unicode-bidi: embed;"
+|   "מקור"
+| " השם עברית "
+| <span>
+|   style="unicode-bidi: embed; direction: rtl;"
+|   "<#selection-anchor>world<#selection-focus>"
+
+beforeinput, formatSetInlineTextDirection, ltr on #prevented:
+| "Hello <#selection-anchor>מקור<#selection-focus> השם עברית world"
+
+beforeinput, formatSetInlineTextDirection, rtl on #prevented:
+| "Hello מקור השם עברית <#selection-anchor>world<#selection-focus>"

Added: trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction.html (0 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-inline-text-direction.html	2019-02-22 17:09:27 UTC (rev 241949)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<meta charset="utf8">
+<html>
+<head>
+    <script src=""
+    <style>
+        #editor {
+            border: 1px blue dashed;
+        }
+    </style>
+    <script>
+        const dumpMarkupOnInput = e => Markup.dump(e.target, `${e.type}, ${e.inputType}, ${e.data} on #${e.target.id}`);
+
+        Markup.description("Verifies that changing the text writing direction fires input events which may be prevented. To manually test, select 'מקור' in the top contenteditable and change the selection direction to 'left to right'; then, select the same word in the prevented contenteditable and change selection direction to 'left to right'. Check that the bottom editable area's contents did not change.");
+        Markup.noAutoDump();
+
+        addEventListener("load", () => {
+            const notPrevented = document.querySelector("#notPrevented");
+            const prevented = document.querySelector("#prevented");
+
+            notPrevented.addEventListener("input", dumpMarkupOnInput);
+            notPrevented.addEventListener("beforeinput", dumpMarkupOnInput);
+            prevented.addEventListener("input", dumpMarkupOnInput);
+            prevented.addEventListener("beforeinput", event => {
+                dumpMarkupOnInput(event);
+                event.preventDefault();
+            });
+
+            getSelection().setBaseAndExtent(notPrevented.firstChild, 6, notPrevented.firstChild, 10);
+            if (!window.testRunner)
+                return;
+            testRunner.execCommand("MakeTextWritingDirectionLeftToRight");
+            getSelection().setBaseAndExtent(notPrevented.lastChild, 11, notPrevented.lastChild, 16);
+            testRunner.execCommand("MakeTextWritingDirectionRightToLeft");
+
+            getSelection().setBaseAndExtent(prevented.firstChild, 6, prevented.firstChild, 10);
+            testRunner.execCommand("MakeTextWritingDirectionLeftToRight");
+            getSelection().setBaseAndExtent(prevented.lastChild, 21, prevented.lastChild, 26);
+            testRunner.execCommand("MakeTextWritingDirectionRightToLeft");
+
+            Markup.notifyDone();
+        });
+    </script>
+</head>
+<body>
+    <div contenteditable id="notPrevented">Hello מקור השם עברית world</div>
+    <div contenteditable id="prevented">Hello מקור השם עברית world</div>
+</body>
+</html>

Deleted: trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction-expected.txt (241948 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction-expected.txt	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction-expected.txt	2019-02-22 17:09:27 UTC (rev 241949)
@@ -1,17 +0,0 @@
-Hello world
-
-*** TESTING RICH TEXT ***
-Initial text direction: "rtl"
-Fired onbeforeinput event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Text direction after setting to LTR while preventing default: "rtl"
-Fired onbeforeinput event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Fired input event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Text direction after setting to LTR without preventing default: "ltr"
-*** TESTING PLAIN TEXT ***
-Initial text direction: "rtl"
-Fired onbeforeinput event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Text direction after setting to LTR while preventing default: "rtl"
-Fired onbeforeinput event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Fired input event of inputType 'formatSetInlineTextDirection' with data: 'ltr'
-Text direction after setting to LTR without preventing default: "ltr"
-

Deleted: trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction.html (241948 => 241949)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction.html	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-text-direction.html	2019-02-22 17:09:27 UTC (rev 241949)
@@ -1,69 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <style>
-        #editor {
-            direction: rtl;
-            border: 1px blue dashed;
-        }
-    </style>
-</head>
-
-<body>
-    <div id="editor" contenteditable _oninput_=handleInputEvent(event) _onbeforeinput_=handleBeforeInputEvent(event)>
-        <div id="content">Hello world</div>
-    </div>
-    <input type="text" id="textfield" value="hi" dir="rtl" _oninput_=handleInputEvent(event) _onbeforeinput_=handleBeforeInputEvent(event)></input>
-    <div id="output"></div>
-    <script>
-        let write = s => output.innerHTML += `${s}<br>`;
-        (function()
-        {
-            window.shouldPreventDefault = true;
-            if (!window.eventSender || !window.internals || !window.testRunner) {
-                write("To test manually, try to change the text direction to ltr. This should be prevented.");
-                return;
-            }
-
-            internals.settings.setInputEventsEnabled(true);
-            testRunner.dumpAsText();
-            editor.focus();
-            write("*** TESTING RICH TEXT ***");
-            write(`Initial text direction: "${getComputedStyle(content).direction}"`);
-
-            internals.setBaseWritingDirection("Ltr");
-            write(`Text direction after setting to LTR while preventing default: "${getComputedStyle(content).direction}"`);
-
-            window.shouldPreventDefault = false;
-
-            internals.setBaseWritingDirection("Ltr");
-            write(`Text direction after setting to LTR without preventing default: "${getComputedStyle(content).direction}"`);
-
-            window.shouldPreventDefault = true;
-            textfield.focus();
-            write("*** TESTING PLAIN TEXT ***");
-            write(`Initial text direction: "${textfield.getAttribute("dir")}"`);
-
-            internals.setBaseWritingDirection("Ltr");
-            write(`Text direction after setting to LTR while preventing default: "${textfield.getAttribute("dir")}"`);
-
-            window.shouldPreventDefault = false;
-
-            internals.setBaseWritingDirection("Ltr");
-            write(`Text direction after setting to LTR without preventing default: "${textfield.getAttribute("dir")}"`);
-        })();
-
-        function handleInputEvent(event)
-        {
-            write(`Fired input event of inputType '${event.inputType}' with data: '${event.data}'`);
-        }
-
-        function handleBeforeInputEvent(event)
-        {
-            write(`Fired onbeforeinput event of inputType '${event.inputType}' with data: '${event.data}'`);
-            if (window.shouldPreventDefault)
-                event.preventDefault();
-        }
-    </script>
-</body>
-</html>

Modified: trunk/Source/WebCore/ChangeLog (241948 => 241949)


--- trunk/Source/WebCore/ChangeLog	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/ChangeLog	2019-02-22 17:09:27 UTC (rev 241949)
@@ -1,3 +1,37 @@
+2019-02-22  Wenson Hsieh  <[email protected]>
+
+        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
+        https://bugs.webkit.org/show_bug.cgi?id=194703
+        <rdar://problem/48111775>
+
+        Reviewed by Ryosuke Niwa.
+
+        Currently, when changing text direction, WebKit always sends input events of type formatSetInlineTextDirection,
+        even when changing paragraph text direction. Instead, we should be emitting formatSetBlockTextDirection in this
+        scenario. This is problematic when using the context menus on macOS to change writing direction, since changing
+        "Selection Direction" is currently indistinguishable from changing "Paragraph Direction".
+
+        To fix this, we split EditAction::SetWritingDirection into EditAction::SetInlineWritingDirection and
+        EditAction::SetBlockWritingDirection, which emit inline and block text direction input events, respectively.
+
+        Tests: fast/events/before-input-events-prevent-block-text-direction.html
+               fast/events/before-input-events-prevent-inline-text-direction.html
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::apply):
+        * editing/EditAction.cpp:
+        (WebCore::undoRedoLabel):
+        * editing/EditAction.h:
+        * editing/EditCommand.cpp:
+        (WebCore::inputTypeNameForEditingAction):
+        * editing/Editor.cpp:
+        (WebCore::inputEventDataForEditingStyleAndAction):
+        (WebCore::Editor::setBaseWritingDirection):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeMakeTextWritingDirectionLeftToRight):
+        (WebCore::executeMakeTextWritingDirectionNatural):
+        (WebCore::executeMakeTextWritingDirectionRightToLeft):
+
 2019-02-22  Rob Buis  <[email protected]>
 
         Remove stripLeadingAndTrailingWhitespace from MathMLElement.cpp

Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (241948 => 241949)


--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -342,7 +342,8 @@
         case EditAction::TypingInsertFinalComposition:
         case EditAction::Paste:
         case EditAction::DeleteByDrag:
-        case EditAction::SetWritingDirection:
+        case EditAction::SetInlineWritingDirection:
+        case EditAction::SetBlockWritingDirection:
         case EditAction::Cut:
         case EditAction::Unspecified:
         case EditAction::Insert:

Modified: trunk/Source/WebCore/editing/EditAction.cpp (241948 => 241949)


--- trunk/Source/WebCore/editing/EditAction.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/EditAction.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -74,7 +74,8 @@
         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:
+    case EditAction::SetInlineWritingDirection:
+    case EditAction::SetBlockWritingDirection:
         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");

Modified: trunk/Source/WebCore/editing/EditAction.h (241948 => 241949)


--- trunk/Source/WebCore/editing/EditAction.h	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/EditAction.h	2019-02-22 17:09:27 UTC (rev 241949)
@@ -54,7 +54,8 @@
     AlignRight,
     Center,
     Justify,
-    SetWritingDirection,
+    SetInlineWritingDirection,
+    SetBlockWritingDirection,
     Subscript,
     Superscript,
     Underline,

Modified: trunk/Source/WebCore/editing/EditCommand.cpp (241948 => 241949)


--- trunk/Source/WebCore/editing/EditCommand.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/EditCommand.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -110,8 +110,10 @@
         return "formatIndent"_s;
     case EditAction::Outdent:
         return "formatOutdent"_s;
-    case EditAction::SetWritingDirection:
+    case EditAction::SetInlineWritingDirection:
         return "formatSetInlineTextDirection"_s;
+    case EditAction::SetBlockWritingDirection:
+        return "formatSetBlockTextDirection"_s;
     default:
         return emptyString();
     }

Modified: trunk/Source/WebCore/editing/Editor.cpp (241948 => 241949)


--- trunk/Source/WebCore/editing/Editor.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/Editor.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -153,7 +153,8 @@
     switch (action) {
     case EditAction::SetColor:
         return style->getPropertyValue(CSSPropertyColor);
-    case EditAction::SetWritingDirection:
+    case EditAction::SetInlineWritingDirection:
+    case EditAction::SetBlockWritingDirection:
         return style->getPropertyValue(CSSPropertyDirection);
     default:
         return { };
@@ -1803,7 +1804,7 @@
 
         auto& focusedFormElement = downcast<HTMLTextFormControlElement>(*focusedElement);
         auto directionValue = direction == WritingDirection::LeftToRight ? "ltr" : "rtl";
-        auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditAction::SetWritingDirection);
+        auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditAction::SetBlockWritingDirection);
         if (!dispatchBeforeInputEvent(focusedFormElement, writingDirectionInputTypeName, directionValue))
             return;
 
@@ -1815,7 +1816,7 @@
 
     auto style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyDirection, direction == WritingDirection::LeftToRight ? "ltr" : direction == WritingDirection::RightToLeft ? "rtl" : "inherit", false);
-    applyParagraphStyleToSelection(style.ptr(), EditAction::SetWritingDirection);
+    applyParagraphStyleToSelection(style.ptr(), EditAction::SetBlockWritingDirection);
 }
 
 WritingDirection Editor::baseWritingDirectionForSelectionStart() const

Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (241948 => 241949)


--- trunk/Source/WebCore/editing/EditorCommand.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -585,7 +585,7 @@
     auto style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
     style->setProperty(CSSPropertyDirection, CSSValueLtr);
-    frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
+    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
     return true;
 }
 
@@ -593,7 +593,7 @@
 {
     auto style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
-    frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
+    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
     return true;
 }
 
@@ -602,7 +602,7 @@
     auto style = MutableStyleProperties::create();
     style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
     style->setProperty(CSSPropertyDirection, CSSValueRtl);
-    frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
+    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
     return true;
 }
 

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (241948 => 241949)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2019-02-22 17:09:27 UTC (rev 241949)
@@ -1,3 +1,14 @@
+2019-02-22  Wenson Hsieh  <[email protected]>
+
+        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
+        https://bugs.webkit.org/show_bug.cgi?id=194703
+        <rdar://problem/48111775>
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (undoNameForEditAction):
+
 2019-02-18  Wenson Hsieh  <[email protected]>
 
         [iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp (241948 => 241949)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp	2019-02-22 16:48:38 UTC (rev 241948)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp	2019-02-22 17:09:27 UTC (rev 241949)
@@ -588,7 +588,9 @@
     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::SetInlineWritingDirection:
+    case EditAction::SetBlockWritingDirection:
+        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");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to