Changeset 207244 in webkit


Ignore:
Timestamp:
Oct 12, 2016 2:49:10 PM (8 years ago)
Author:
Wenson Hsieh
Message:

Add experimental support for the "formatForeColor" inputType
https://bugs.webkit.org/show_bug.cgi?id=163348
<rdar://problem/28739334>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Adds support for the "formatForeColor" attribute. This patch introduces a simple hook in Editor.cpp to extract
data for an input event from an EditingStyle when performing an editing action.

Test: fast/events/input-events-forecolor-data.html

  • editing/EditCommand.cpp:

(WebCore::inputTypeNameForEditingAction):

  • editing/Editor.cpp:

(WebCore::inputEventDataForEditingStyleAndAction):

Added a new static helper to compute the data attribute of an InputEvent when handling a style change.

(WebCore::Editor::computeAndSetTypingStyle):

LayoutTests:

Adds a new test verifying that input events with inputType "formatForeColor" are dispatched when changing
foreground color, and that their data attributes are as expected.

  • fast/events/input-events-forecolor-data-expected.txt: Added.
  • fast/events/input-events-forecolor-data.html: Added.
  • platform/ios-simulator/TestExpectations:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207239 r207244  
     12016-10-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add experimental support for the "formatForeColor" inputType
     4        https://bugs.webkit.org/show_bug.cgi?id=163348
     5        <rdar://problem/28739334>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Adds a new test verifying that input events with inputType "formatForeColor" are dispatched when changing
     10        foreground color, and that their data attributes are as expected.
     11
     12        * fast/events/input-events-forecolor-data-expected.txt: Added.
     13        * fast/events/input-events-forecolor-data.html: Added.
     14        * platform/ios-simulator/TestExpectations:
     15
    1162016-10-12  Yusuke Suzuki  <utatane.tea@gmail.com>
    217
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r207180 r207244  
    12091209fast/events/input-events-paste-data.html [ Failure ]
    12101210fast/events/input-events-typing-data.html [ Failure ]
     1211fast/events/input-events-forecolor-data.html [ Failure ]
    12111212fast/events/before-input-events-prevent-default.html [ Failure ]
    12121213fast/events/before-input-events-prevent-default-in-textfield.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r207243 r207244  
     12016-10-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add experimental support for the "formatForeColor" inputType
     4        https://bugs.webkit.org/show_bug.cgi?id=163348
     5        <rdar://problem/28739334>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Adds support for the "formatForeColor" attribute. This patch introduces a simple hook in Editor.cpp to extract
     10        data for an input event from an EditingStyle when performing an editing action.
     11
     12        Test: fast/events/input-events-forecolor-data.html
     13
     14        * editing/EditCommand.cpp:
     15        (WebCore::inputTypeNameForEditingAction):
     16        * editing/Editor.cpp:
     17        (WebCore::inputEventDataForEditingStyleAndAction):
     18
     19        Added a new static helper to compute the data attribute of an InputEvent when handling a style change.
     20
     21        (WebCore::Editor::computeAndSetTypingStyle):
     22
    1232016-10-12  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebCore/editing/EditCommand.cpp

    r207010 r207244  
    5757    case EditActionUnderline:
    5858        return ASCIILiteral("formatUnderline");
     59    case EditActionSetColor:
     60        return ASCIILiteral("formatForeColor");
    5961    case EditActionDrag:
    6062        return ASCIILiteral("deleteByDrag");
  • trunk/Source/WebCore/editing/Editor.cpp

    r207010 r207244  
    133133}
    134134
     135static String inputEventDataForEditingStyleAndAction(EditingStyle& style, EditAction action)
     136{
     137    auto* properties = style.style();
     138    if (!properties)
     139        return { };
     140
     141    switch (action) {
     142    case EditActionSetColor:
     143        return properties->getPropertyValue(CSSPropertyColor);
     144    default:
     145        return { };
     146    }
     147}
     148
    135149class ClearTextCommand : public DeleteSelectionCommand {
    136150public:
     
    31083122
    31093123    String inputTypeName = inputTypeNameForEditingAction(editingAction);
     3124    String inputEventData = inputEventDataForEditingStyleAndAction(style, editingAction);
    31103125    auto* element = m_frame.selection().selection().rootEditableElement();
    3111     if (element && !dispatchBeforeInputEvent(*element, inputTypeName))
     3126    if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData))
    31123127        return;
    31133128
     
    31263141
    31273142    if (element)
    3128         dispatchInputEvent(*element, inputTypeName);
     3143        dispatchInputEvent(*element, inputTypeName, inputEventData);
    31293144
    31303145    // Set the remaining style as the typing style.
Note: See TracChangeset for help on using the changeset viewer.