Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Introduce InputEvent bindings in preparation for the input events spec
https://bugs.webkit.org/show_bug.cgi?id=162954 Reviewed by Ryosuke Niwa. Source/WebCore: Creates new bindings for InputEvent. Also introduces a runtime switch that allows Node to dispatch InputEvents rather than generic events of type 'input'. Adds a new test verifying that when the switch is enabled, inputs and contenteditable divs fire these new InputEvents on input. So far, only inputType is a part of the object prototype, since we will be implementing this first. getTargetRanges() will follow once the finer details of StaticRange are hashed out. See https://bugs.webkit.org/show_bug.cgi?id=162947 for more details. Tests: fast/events/input-events-fired-when-typing.html fast/events/ios/input-events-fired-when-typing-in-contenteditable.html * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * dom/DOMAllInOne.cpp: * dom/Event.cpp: (WebCore::Event::composed): (WebCore::Event::isInputEvent): * dom/Event.h: * dom/EventNames.in: * dom/InputEvent.cpp: Added. (WebCore::InputEvent::InputEvent): * dom/InputEvent.h: Added. * dom/InputEvent.idl: Added. * dom/Node.cpp: (WebCore::Node::dispatchInputEvent): (WebCore::Node::defaultEventHandler): * dom/Node.h: * editing/Editor.cpp: (WebCore::Editor::setBaseWritingDirection): * html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::dispatchFormControlInputEvent): * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setEditingValue): (WebCore::HTMLInputElement::setValueFromRenderer): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::listBoxOnChange): (WebCore::HTMLSelectElement::dispatchChangeEventForMenuList): * html/shadow/MediaControlElements.cpp: (WebCore::MediaControlTimelineElement::defaultEventHandler): * page/Settings.in: * testing/InternalSettings.cpp: (WebCore::InternalSettings::Backup::Backup): (WebCore::InternalSettings::Backup::restoreTo): * testing/InternalSettings.h: * testing/InternalSettings.idl: Source/WebKit2: Adds a new runtime switch for enabling InputEvents. * Shared/WebPreferencesDefinitions.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): LayoutTests: Adds a new test verifying that InputEvents are fired when the runtime switch for input events is enabled. * fast/events/input-events-fired-when-typing-expected.txt: Added. * fast/events/input-events-fired-when-typing.html: Added. * fast/events/ios/input-events-fired-when-typing-in-contenteditable-expected.txt: Added. * fast/events/ios/input-events-fired-when-typing-in-contenteditable.html: Added. * js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/ios-simulator/TestExpectations: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/180896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
470 additions
and 12 deletions.
- +20 −0 LayoutTests/ChangeLog
- +17 −0 LayoutTests/fast/events/input-events-fired-when-typing-expected.txt
- +52 −0 LayoutTests/fast/events/input-events-fired-when-typing.html
- +10 −0 LayoutTests/fast/events/ios/input-events-fired-when-typing-in-contenteditable-expected.txt
- +77 −0 LayoutTests/fast/events/ios/input-events-fired-when-typing-in-contenteditable.html
- +5 −0 LayoutTests/js/dom/global-constructors-attributes-expected.txt
- +5 −0 LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
- +1 −0 LayoutTests/platform/ios-simulator/TestExpectations
- +5 −0 LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt
- +5 −0 LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
- +5 −0 LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
- +2 −0 Source/WebCore/CMakeLists.txt
- +53 −0 Source/WebCore/ChangeLog
- +1 −0 Source/WebCore/DerivedSources.cpp
- +1 −0 Source/WebCore/DerivedSources.make
- +18 −0 Source/WebCore/WebCore.xcodeproj/project.pbxproj
- +1 −0 Source/WebCore/dom/DOMAllInOne.cpp
- +7 −1 Source/WebCore/dom/Event.cpp
- +1 −0 Source/WebCore/dom/Event.h
- +2 −0 Source/WebCore/dom/EventNames.in
- +49 −0 Source/WebCore/dom/InputEvent.cpp
- +64 −0 Source/WebCore/dom/InputEvent.h
- +30 −0 Source/WebCore/dom/InputEvent.idl
- +8 −3 Source/WebCore/dom/Node.cpp
- +1 −1 Source/WebCore/dom/Node.h
- +1 −1 Source/WebCore/editing/Editor.cpp
- +1 −1 Source/WebCore/html/HTMLFormControlElement.cpp
- +2 −2 Source/WebCore/html/HTMLInputElement.cpp
- +2 −2 Source/WebCore/html/HTMLSelectElement.cpp
- +1 −1 Source/WebCore/html/shadow/MediaControlElements.cpp
- +2 −0 Source/WebCore/page/Settings.in
- +2 −0 Source/WebCore/testing/InternalSettings.cpp
- +1 −0 Source/WebCore/testing/InternalSettings.h
- +2 −0 Source/WebCore/testing/InternalSettings.idl
- +13 −0 Source/WebKit2/ChangeLog
- +1 −0 Source/WebKit2/Shared/WebPreferencesDefinitions.h
- +2 −0 Source/WebKit2/WebProcess/WebPage/WebPage.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
PASS event.__lookupGetter__('inputType') is defined. | ||
PASS Object.getPrototypeOf(event) is InputEvent.prototype | ||
PASS event.target.id is expectedTargetID | ||
PASS event.bubbles is true | ||
PASS event.cancelable is false | ||
PASS event.composed is true | ||
PASS event.__lookupGetter__('inputType') is defined. | ||
PASS Object.getPrototypeOf(event) is InputEvent.prototype | ||
PASS event.target.id is expectedTargetID | ||
PASS event.bubbles is true | ||
PASS event.cancelable is false | ||
PASS event.composed is true | ||
a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
|
||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script> | ||
var expectedTargetID = "foo"; | ||
|
||
function contentEditable() | ||
{ | ||
return document.querySelector("#foo"); | ||
} | ||
|
||
function plainText() | ||
{ | ||
return document.querySelector("#bar"); | ||
} | ||
|
||
function beginTest() | ||
{ | ||
if (!window.eventSender || !window.internals || !window.testRunner) | ||
return; | ||
|
||
internals.settings.setInputEventsEnabled(true); | ||
testRunner.dumpAsText(); | ||
contentEditable().focus(); | ||
eventSender.keyDown("a", []); | ||
|
||
expectedTargetID = "bar"; | ||
plainText().focus(); | ||
eventSender.keyDown("b", []); | ||
} | ||
|
||
function checkInputEvent(event) | ||
{ | ||
shouldBeDefined("event.__lookupGetter__('inputType')"); | ||
shouldBe("Object.getPrototypeOf(event)", "InputEvent.prototype"); | ||
shouldBe("event.target.id", "expectedTargetID"); | ||
shouldBe("event.bubbles", "true"); | ||
shouldBe("event.cancelable", "false"); | ||
shouldBe("event.composed", "true"); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body onload=beginTest()> | ||
<div id="foo" contenteditable oninput=checkInputEvent(event)></div> | ||
<input id="bar" oninput=checkInputEvent(event)></input> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,10 @@ | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Does the event have an inputType method? YES | ||
Does the event have InputEvent's prototype? YES | ||
What is the event's id? editable | ||
Does the event bubble? YES | ||
Is the event cancelable? NO | ||
Is the event composed? YES | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
|
||
<html> | ||
|
||
<head> | ||
<script src="../../../resources/js-test-pre.js"></script> | ||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | ||
<script id="ui-script" type="text/plain"> | ||
(function() { | ||
uiController.didShowKeyboardCallback = function() { | ||
uiController.typeCharacterUsingHardwareKeyboard(" ", function() { | ||
uiController.uiScriptComplete(); | ||
}); | ||
} | ||
uiController.singleTapAtPoint(100, 100, function() {}); | ||
})(); | ||
</script> | ||
|
||
<script> | ||
var progress = 0; | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
internals.settings.setInputEventsEnabled(true); | ||
} | ||
|
||
function incrementProgress() | ||
{ | ||
progress++; | ||
if (progress == 2) | ||
testRunner.notifyDone(); | ||
} | ||
|
||
function getUIScript() | ||
{ | ||
return document.getElementById("ui-script").text; | ||
} | ||
|
||
function runTest() | ||
{ | ||
if (!window.testRunner || !testRunner.runUIScript) | ||
return; | ||
|
||
testRunner.runUIScript(getUIScript(), function(result) { | ||
incrementProgress(); | ||
}); | ||
} | ||
|
||
function yesno(b) { return b ? "YES" : "NO"; } | ||
|
||
function handleInput(event) | ||
{ | ||
debug("Does the event have an inputType method? " + yesno(event.__lookupGetter__("inputType"))); | ||
debug("Does the event have InputEvent's prototype? " + yesno(Object.getPrototypeOf(event) === InputEvent.prototype)); | ||
debug("What is the event's id? " + event.target.id); | ||
debug("Does the event bubble? " + yesno(event.bubbles)); | ||
debug("Is the event cancelable? " + yesno(event.cancelable)); | ||
debug("Is the event composed? " + yesno(event.composed)); | ||
incrementProgress(); | ||
} | ||
</script> | ||
<style> | ||
#editable { | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body style="margin: 0;" onload=runTest()> | ||
<div contenteditable id="editable" oninput=handleInput(event)> | ||
<div id="console"></div> | ||
<script src="../../../resources/js-test-post.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.