Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 17:09:27 +0000 (17:09 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 17:09:27 +0000 (17:09 +0000)
commited3267158026a1b0f5b8f5a3d9155ec204c7de50
tree71cab8a7115c59c980c76651f80359c799814356
parentd2c7944d694d1f9a82e412b2610faf12caf17f27
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-expected.txt
LayoutTests/fast/events/before-input-events-prevent-block-text-direction-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-events-prevent-block-text-direction.html [moved from LayoutTests/fast/events/before-input-events-prevent-text-direction.html with 100% similarity]
LayoutTests/fast/events/before-input-events-prevent-inline-text-direction-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/before-input-events-prevent-inline-text-direction.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-events-prevent-text-direction-expected.txt [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/EditAction.cpp
Source/WebCore/editing/EditAction.h
Source/WebCore/editing/EditCommand.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp