Changeset 241949 in webkit


Ignore:
Timestamp:
Feb 22, 2019 9:09:27 AM (5 years ago)
Author:
Wenson Hsieh
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.
Location:
trunk
Files:
3 added
1 deleted
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r241942 r241949  
     12019-02-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
     4        https://bugs.webkit.org/show_bug.cgi?id=194703
     5        <rdar://problem/48111775>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Rebaseline some existing tests to expect input events of type "formatSetBlockTextDirection" instead of
     10        "formatSetInlineTextDirection" when changing paragraph text direction; additionally, add a new layout test that
     11        changes the inline text direction in some Bidi text, and verify that "formatSetInlineTextDirection" is emitted
     12        in this scenario, and that calling `preventDefault()` in the beforeinput event handler causes no change to be
     13        made.
     14
     15        * editing/input/ios/rtl-keyboard-input-on-focus-expected.txt:
     16        * fast/events/before-input-events-prevent-block-text-direction-expected.txt: Added.
     17        * fast/events/before-input-events-prevent-block-text-direction.html: Renamed from LayoutTests/fast/events/before-input-events-prevent-text-direction.html.
     18        * fast/events/before-input-events-prevent-inline-text-direction-expected.txt: Added.
     19        * fast/events/before-input-events-prevent-inline-text-direction.html: Added.
     20        * fast/events/before-input-events-prevent-text-direction-expected.txt: Removed.
     21
    1222019-02-22  Rob Buis  <rbuis@igalia.com>
    223
  • trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-expected.txt

    r238939 r241949  
    1515Observed 'beforeinput' events: [
    1616    {
    17         "inputType": "formatSetInlineTextDirection",
     17        "inputType": "formatSetBlockTextDirection",
    1818        "data": "rtl",
    1919        "order": 1
    2020    },
    2121    {
    22         "inputType": "formatSetInlineTextDirection",
     22        "inputType": "formatSetBlockTextDirection",
    2323        "data": "ltr",
    2424        "order": 3
     
    2727Observed 'input' events: [
    2828    {
    29         "inputType": "formatSetInlineTextDirection",
     29        "inputType": "formatSetBlockTextDirection",
    3030        "data": "rtl",
    3131        "order": 2
    3232    },
    3333    {
    34         "inputType": "formatSetInlineTextDirection",
     34        "inputType": "formatSetBlockTextDirection",
    3535        "data": "ltr",
    3636        "order": 4
  • trunk/Source/WebCore/ChangeLog

    r241947 r241949  
     12019-02-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
     4        https://bugs.webkit.org/show_bug.cgi?id=194703
     5        <rdar://problem/48111775>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Currently, when changing text direction, WebKit always sends input events of type formatSetInlineTextDirection,
     10        even when changing paragraph text direction. Instead, we should be emitting formatSetBlockTextDirection in this
     11        scenario. This is problematic when using the context menus on macOS to change writing direction, since changing
     12        "Selection Direction" is currently indistinguishable from changing "Paragraph Direction".
     13
     14        To fix this, we split EditAction::SetWritingDirection into EditAction::SetInlineWritingDirection and
     15        EditAction::SetBlockWritingDirection, which emit inline and block text direction input events, respectively.
     16
     17        Tests: fast/events/before-input-events-prevent-block-text-direction.html
     18               fast/events/before-input-events-prevent-inline-text-direction.html
     19
     20        * editing/CompositeEditCommand.cpp:
     21        (WebCore::CompositeEditCommand::apply):
     22        * editing/EditAction.cpp:
     23        (WebCore::undoRedoLabel):
     24        * editing/EditAction.h:
     25        * editing/EditCommand.cpp:
     26        (WebCore::inputTypeNameForEditingAction):
     27        * editing/Editor.cpp:
     28        (WebCore::inputEventDataForEditingStyleAndAction):
     29        (WebCore::Editor::setBaseWritingDirection):
     30        * editing/EditorCommand.cpp:
     31        (WebCore::executeMakeTextWritingDirectionLeftToRight):
     32        (WebCore::executeMakeTextWritingDirectionNatural):
     33        (WebCore::executeMakeTextWritingDirectionRightToLeft):
     34
    1352019-02-22  Rob Buis  <rbuis@igalia.com>
    236
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r240342 r241949  
    343343        case EditAction::Paste:
    344344        case EditAction::DeleteByDrag:
    345         case EditAction::SetWritingDirection:
     345        case EditAction::SetInlineWritingDirection:
     346        case EditAction::SetBlockWritingDirection:
    346347        case EditAction::Cut:
    347348        case EditAction::Unspecified:
  • trunk/Source/WebCore/editing/EditAction.cpp

    r240342 r241949  
    7575    case EditAction::Justify:
    7676        return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
    77     case EditAction::SetWritingDirection:
     77    case EditAction::SetInlineWritingDirection:
     78    case EditAction::SetBlockWritingDirection:
    7879        return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
    7980    case EditAction::Subscript:
  • trunk/Source/WebCore/editing/EditAction.h

    r240342 r241949  
    5555    Center,
    5656    Justify,
    57     SetWritingDirection,
     57    SetInlineWritingDirection,
     58    SetBlockWritingDirection,
    5859    Subscript,
    5960    Superscript,
  • trunk/Source/WebCore/editing/EditCommand.cpp

    r235775 r241949  
    111111    case EditAction::Outdent:
    112112        return "formatOutdent"_s;
    113     case EditAction::SetWritingDirection:
     113    case EditAction::SetInlineWritingDirection:
    114114        return "formatSetInlineTextDirection"_s;
     115    case EditAction::SetBlockWritingDirection:
     116        return "formatSetBlockTextDirection"_s;
    115117    default:
    116118        return emptyString();
  • trunk/Source/WebCore/editing/Editor.cpp

    r241749 r241949  
    154154    case EditAction::SetColor:
    155155        return style->getPropertyValue(CSSPropertyColor);
    156     case EditAction::SetWritingDirection:
     156    case EditAction::SetInlineWritingDirection:
     157    case EditAction::SetBlockWritingDirection:
    157158        return style->getPropertyValue(CSSPropertyDirection);
    158159    default:
     
    18041805        auto& focusedFormElement = downcast<HTMLTextFormControlElement>(*focusedElement);
    18051806        auto directionValue = direction == WritingDirection::LeftToRight ? "ltr" : "rtl";
    1806         auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditAction::SetWritingDirection);
     1807        auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditAction::SetBlockWritingDirection);
    18071808        if (!dispatchBeforeInputEvent(focusedFormElement, writingDirectionInputTypeName, directionValue))
    18081809            return;
     
    18161817    auto style = MutableStyleProperties::create();
    18171818    style->setProperty(CSSPropertyDirection, direction == WritingDirection::LeftToRight ? "ltr" : direction == WritingDirection::RightToLeft ? "rtl" : "inherit", false);
    1818     applyParagraphStyleToSelection(style.ptr(), EditAction::SetWritingDirection);
     1819    applyParagraphStyleToSelection(style.ptr(), EditAction::SetBlockWritingDirection);
    18191820}
    18201821
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r241719 r241949  
    586586    style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
    587587    style->setProperty(CSSPropertyDirection, CSSValueLtr);
    588     frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
     588    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
    589589    return true;
    590590}
     
    594594    auto style = MutableStyleProperties::create();
    595595    style->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
    596     frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
     596    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
    597597    return true;
    598598}
     
    603603    style->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
    604604    style->setProperty(CSSPropertyDirection, CSSValueRtl);
    605     frame.editor().applyStyle(style.ptr(), EditAction::SetWritingDirection);
     605    frame.editor().applyStyle(style.ptr(), EditAction::SetInlineWritingDirection);
    606606    return true;
    607607}
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r241749 r241949  
     12019-02-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction
     4        https://bugs.webkit.org/show_bug.cgi?id=194703
     5        <rdar://problem/48111775>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * WebCoreSupport/WebEditorClient.cpp:
     10        (undoNameForEditAction):
     11
    1122019-02-18  Wenson Hsieh  <wenson_hsieh@apple.com>
    213
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp

    r241749 r241949  
    589589    case EditAction::Center: return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
    590590    case EditAction::Justify: return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
    591     case EditAction::SetWritingDirection: return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
     591    case EditAction::SetInlineWritingDirection:
     592    case EditAction::SetBlockWritingDirection:
     593        return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
    592594    case EditAction::Subscript: return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
    593595    case EditAction::Superscript: return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
Note: See TracChangeset for help on using the changeset viewer.