- Revision
- 207244
- Author
- wenson_hs...@apple.com
- Date
- 2016-10-12 14:49:10 -0700 (Wed, 12 Oct 2016)
Log 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:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (207243 => 207244)
--- trunk/LayoutTests/ChangeLog 2016-10-12 21:09:46 UTC (rev 207243)
+++ trunk/LayoutTests/ChangeLog 2016-10-12 21:49:10 UTC (rev 207244)
@@ -1,3 +1,18 @@
+2016-10-12 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Add experimental support for the "formatForeColor" inputType
+ https://bugs.webkit.org/show_bug.cgi?id=163348
+ <rdar://problem/28739334>
+
+ Reviewed by Ryosuke Niwa.
+
+ 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:
+
2016-10-12 Yusuke Suzuki <utatane....@gmail.com>
[DOMJIT][JSC] Explore the way to embed nodeType into JSC::JSType in WebCore
Added: trunk/LayoutTests/fast/events/input-events-forecolor-data-expected.txt (0 => 207244)
--- trunk/LayoutTests/fast/events/input-events-forecolor-data-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/input-events-forecolor-data-expected.txt 2016-10-12 21:49:10 UTC (rev 207244)
@@ -0,0 +1,33 @@
+To manually test this, change the foreground color and check the resulting debug messages.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+event.type = beforeinput
+event.inputType = formatForeColor
+event.data = "" 255, 255)
+event.type = input
+event.inputType = formatForeColor
+event.data = "" 255, 255)
+event.type = beforeinput
+event.inputType = formatForeColor
+event.data = "" 255, 0)
+event.type = input
+event.inputType = formatForeColor
+event.data = "" 255, 0)
+event.type = beforeinput
+event.inputType = formatForeColor
+event.data = "" 0, 0)
+event.type = input
+event.inputType = formatForeColor
+event.data = "" 0, 0)
+event.type = beforeinput
+event.inputType = formatForeColor
+event.data = "" 0, 0)
+event.type = input
+event.inputType = formatForeColor
+event.data = "" 0, 0)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/input-events-forecolor-data.html (0 => 207244)
--- trunk/LayoutTests/fast/events/input-events-forecolor-data.html (rev 0)
+++ trunk/LayoutTests/fast/events/input-events-forecolor-data.html 2016-10-12 21:49:10 UTC (rev 207244)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <div id="editable" contenteditable _onbeforeinput_=handleInput(event) _oninput_=handleInput(event)></div>
+ <script type="text/_javascript_">
+ description("To manually test this, change the foreground color and check the resulting debug messages.");
+ if (window.internals)
+ internals.settings.setInputEventsEnabled(true);
+
+ document.getElementById("editable").focus();
+
+ if (window.testRunner) {
+ // FIXME: The value argument is passed twice here for compatibility with DumpRenderTree. We should address
+ // this if we require more editing tests that need to pass arguments to the editing command.
+ testRunner.execCommand("ForeColor", "rgb(255, 255, 255)", "rgb(255, 255, 255)");
+ testRunner.execCommand("ForeColor", "rgb(100, 255, 0)", "rgb(100, 255, 0)");
+ testRunner.execCommand("ForeColor", "rgb(0, 0, 0)", "rgb(0, 0, 0)");
+ testRunner.execCommand("ForeColor", "rgb(255, 0, 0)", "rgb(255, 0, 0)");
+ }
+
+ function handleInput(event)
+ {
+ debug(`event.type = ${event.type}`);
+ debug(`event.inputType = ${event.inputType}`);
+ debug(`event.data = ""
+ }
+ </script>
+ <script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (207243 => 207244)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-10-12 21:09:46 UTC (rev 207243)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-10-12 21:49:10 UTC (rev 207244)
@@ -1208,6 +1208,7 @@
fast/events/input-events-fired-when-typing.html [ Failure ]
fast/events/input-events-paste-data.html [ Failure ]
fast/events/input-events-typing-data.html [ Failure ]
+fast/events/input-events-forecolor-data.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 ]
Modified: trunk/Source/WebCore/ChangeLog (207243 => 207244)
--- trunk/Source/WebCore/ChangeLog 2016-10-12 21:09:46 UTC (rev 207243)
+++ trunk/Source/WebCore/ChangeLog 2016-10-12 21:49:10 UTC (rev 207244)
@@ -1,3 +1,25 @@
+2016-10-12 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Add experimental support for the "formatForeColor" inputType
+ https://bugs.webkit.org/show_bug.cgi?id=163348
+ <rdar://problem/28739334>
+
+ Reviewed by Ryosuke Niwa.
+
+ 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):
+
2016-10-12 Chris Dumez <cdu...@apple.com>
[Web IDL] Generated bindings include the wrong header when ImplementedAs is used on a dictionary
Modified: trunk/Source/WebCore/editing/EditCommand.cpp (207243 => 207244)
--- trunk/Source/WebCore/editing/EditCommand.cpp 2016-10-12 21:09:46 UTC (rev 207243)
+++ trunk/Source/WebCore/editing/EditCommand.cpp 2016-10-12 21:49:10 UTC (rev 207244)
@@ -56,6 +56,8 @@
return ASCIILiteral("formatSuperscript");
case EditActionUnderline:
return ASCIILiteral("formatUnderline");
+ case EditActionSetColor:
+ return ASCIILiteral("formatForeColor");
case EditActionDrag:
return ASCIILiteral("deleteByDrag");
case EditActionCut:
Modified: trunk/Source/WebCore/editing/Editor.cpp (207243 => 207244)
--- trunk/Source/WebCore/editing/Editor.cpp 2016-10-12 21:09:46 UTC (rev 207243)
+++ trunk/Source/WebCore/editing/Editor.cpp 2016-10-12 21:49:10 UTC (rev 207244)
@@ -132,6 +132,20 @@
element.dispatchInputEvent();
}
+static String inputEventDataForEditingStyleAndAction(EditingStyle& style, EditAction action)
+{
+ auto* properties = style.style();
+ if (!properties)
+ return { };
+
+ switch (action) {
+ case EditActionSetColor:
+ return properties->getPropertyValue(CSSPropertyColor);
+ default:
+ return { };
+ }
+}
+
class ClearTextCommand : public DeleteSelectionCommand {
public:
ClearTextCommand(Document& document);
@@ -3107,8 +3121,9 @@
}
String inputTypeName = inputTypeNameForEditingAction(editingAction);
+ String inputEventData = inputEventDataForEditingStyleAndAction(style, editingAction);
auto* element = m_frame.selection().selection().rootEditableElement();
- if (element && !dispatchBeforeInputEvent(*element, inputTypeName))
+ if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData))
return;
// Calculate the current typing style.
@@ -3125,7 +3140,7 @@
applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction));
if (element)
- dispatchInputEvent(*element, inputTypeName);
+ dispatchInputEvent(*element, inputTypeName, inputEventData);
// Set the remaining style as the typing style.
m_frame.selection().setTypingStyle(typingStyle);