<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207670] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207670">207670</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2016-10-21 08:51:28 -0700 (Fri, 21 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement InputEvent.getTargetRanges() for the input events spec
https://bugs.webkit.org/show_bug.cgi?id=162947
&lt;rdar://problem/28853079&gt;

Reviewed by Darin Adler.

Source/JavaScriptCore:

Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry
for more details.

* runtime/CommonIdentifiers.h:

Source/WebCore:

Implements InputEvent.getTargetRanges(). See individual method changes below for more details. Adds a new hook
for subclasses of CompositeEditCommand to vend a list of target StaticRanges when retrieving target ranges for
an editing command on a contenteditable area.

Tests: fast/events/before-input-delete-empty-list-target-ranges.html
       fast/events/before-input-delete-text-target-ranges.html
       fast/events/before-input-replace-text-target-ranges.html

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:

Add StaticRange.idl, StaticRange.cpp and StaticRange.h.

* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setInputEventsEnabled):
(WebCore::RuntimeEnabledFeatures::inputEventsEnabled):

Add a new runtime bindings flag for InputEvents and guard both InputEvent and StaticRange behind it.

* dom/DOMAllInOne.cpp:
* dom/InputEvent.cpp:
(WebCore::InputEvent::InputEvent):
* dom/InputEvent.h:
* dom/InputEvent.idl:
* dom/StaticRange.cpp: Copied from Source/WebCore/dom/InputEvent.cpp.
(WebCore::StaticRange::StaticRange):
(WebCore::StaticRange::create):
(WebCore::StaticRange::createFromRange):

Convenience method for creating a StaticRange from a Range's start/end container and offset.

(WebCore::StaticRange::startContainer):
(WebCore::StaticRange::endContainer):
(WebCore::StaticRange::collapsed):
* dom/StaticRange.h: Copied from Source/WebCore/dom/InputEvent.cpp.
(WebCore::StaticRange::startOffset):
(WebCore::StaticRange::endOffset):
* dom/StaticRange.idl: Copied from Source/WebCore/editing/ReplaceRangeWithTextCommand.h.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::willApplyCommand):
(WebCore::CompositeEditCommand::targetRanges):

Virtual method that returns a list of target ranges which are associated with this command.

(WebCore::CompositeEditCommand::targetRangesForBindings):

Non-virtual method that calls the above targetRanges(). Takes whether or not the CompositeEditCommand is editing
a textarea or plain text input into account.

(WebCore::CompositeEditCommand::moveParagraphs):
* editing/CompositeEditCommand.h:
* editing/EditCommand.cpp:
(WebCore::EditCommand::frame):
* editing/EditCommand.h:
(WebCore::EditCommand::document):
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent):
(WebCore::dispatchInputEvent):
(WebCore::dispatchBeforeInputEvents):

Changed the `beforeinput` event dispatch to use the regular Node::dispatchEvent instead of dispatchScopedEvent.
This is because if the page prevents the `beforeinput` event, we need to know immediately in order to bail from
the default action.

(WebCore::dispatchInputEvents):
(WebCore::Editor::willApplyEditing):

Added a list of static ranges as a parameter when calling on the Editor to dispatch `beforeinput` events.
By default, this uses the composite edit command's targetRangesForBindings(), though it may be special cased
by subclasses of CompositeEditCommand (see ReplaceRangeWithTextCommand, SpellingCorrectionCommand, and
TypingCommand).

* editing/Editor.h:
* editing/ReplaceRangeWithTextCommand.cpp:
(WebCore::ReplaceRangeWithTextCommand::targetRanges):
* editing/ReplaceRangeWithTextCommand.h:
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::targetRanges):
* editing/SpellingCorrectionCommand.h:
* editing/TypingCommand.cpp:
(WebCore::editActionIsDeleteByTyping):
(WebCore::TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand):
(WebCore::TypingCommand::willApplyCommand):
(WebCore::TypingCommand::willAddTypingToOpenCommand):
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):

Moves the firing of the `beforeinput` until after the selection range to delete has been computed.

* editing/TypingCommand.h:

Source/WebKit2:

Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry
for more details.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

LayoutTests:

Adds 3 new layout tests and tweaks some existing unit tests. See WebCore ChangeLog entry for more details.
Tests verify the result of getTargetRanges() when breaking out of a list, deleting backwards and forwards at
all text granularities, deleting selected text, and spell checking (candidate text replacement).

* fast/events/before-input-delete-empty-list-target-ranges-expected.txt: Added.
* fast/events/before-input-delete-empty-list-target-ranges.html: Added.
* fast/events/before-input-delete-text-target-ranges-expected.txt: Added.
* fast/events/before-input-delete-text-target-ranges.html: Added.
* fast/events/before-input-events-prevent-default-in-textfield.html:
* fast/events/before-input-replace-text-target-ranges-expected.txt: Added.
* fast/events/before-input-replace-text-target-ranges.html: Added.
* fast/events/input-events-fired-when-typing-expected.txt:
* fast/events/input-events-fired-when-typing.html:
* 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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputeventspreventdefaultintextfieldhtml">trunk/LayoutTests/fast/events/before-input-events-prevent-default-in-textfield.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsinputeventsfiredwhentypingexpectedtxt">trunk/LayoutTests/fast/events/input-events-fired-when-typing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsinputeventsfiredwhentypinghtml">trunk/LayoutTests/fast/events/input-events-fired-when-typing.html</a></li>
<li><a href="#trunkLayoutTestsjsdomglobalconstructorsattributesexpectedtxt">trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacjsdomglobalconstructorsattributesexpectedtxt">trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1jsdomglobalconstructorsattributesexpectedtxt">trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacyosemitejsdomglobalconstructorsattributesexpectedtxt">trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsgenericRuntimeEnabledFeaturesh">trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h</a></li>
<li><a href="#trunkSourceWebCoredomDOMAllInOnecpp">trunk/Source/WebCore/dom/DOMAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoredomInputEventcpp">trunk/Source/WebCore/dom/InputEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoredomInputEventh">trunk/Source/WebCore/dom/InputEvent.h</a></li>
<li><a href="#trunkSourceWebCoredomInputEventidl">trunk/Source/WebCore/dom/InputEvent.idl</a></li>
<li><a href="#trunkSourceWebCoreeditingCompositeEditCommandcpp">trunk/Source/WebCore/editing/CompositeEditCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingCompositeEditCommandh">trunk/Source/WebCore/editing/CompositeEditCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingEditCommandcpp">trunk/Source/WebCore/editing/EditCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditCommandh">trunk/Source/WebCore/editing/EditCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorh">trunk/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkSourceWebCoreeditingReplaceRangeWithTextCommandcpp">trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingReplaceRangeWithTextCommandh">trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingSpellingCorrectionCommandcpp">trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingSpellingCorrectionCommandh">trunk/Source/WebCore/editing/SpellingCorrectionCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingTypingCommandcpp">trunk/Source/WebCore/editing/TypingCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTypingCommandh">trunk/Source/WebCore/editing/TypingCommand.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputdeleteemptylisttargetrangesexpectedtxt">trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputdeleteemptylisttargetrangeshtml">trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputdeletetexttargetrangesexpectedtxt">trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputdeletetexttargetrangeshtml">trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputreplacetexttargetrangesexpectedtxt">trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeinputreplacetexttargetrangeshtml">trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges.html</a></li>
<li><a href="#trunkSourceWebCoredomStaticRangecpp">trunk/Source/WebCore/dom/StaticRange.cpp</a></li>
<li><a href="#trunkSourceWebCoredomStaticRangeh">trunk/Source/WebCore/dom/StaticRange.h</a></li>
<li><a href="#trunkSourceWebCoredomStaticRangeidl">trunk/Source/WebCore/dom/StaticRange.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/ChangeLog        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-10-21  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Implement InputEvent.getTargetRanges() for the input events spec
+        https://bugs.webkit.org/show_bug.cgi?id=162947
+        &lt;rdar://problem/28853079&gt;
+
+        Reviewed by Darin Adler.
+
+        Adds 3 new layout tests and tweaks some existing unit tests. See WebCore ChangeLog entry for more details.
+        Tests verify the result of getTargetRanges() when breaking out of a list, deleting backwards and forwards at
+        all text granularities, deleting selected text, and spell checking (candidate text replacement).
+
+        * fast/events/before-input-delete-empty-list-target-ranges-expected.txt: Added.
+        * fast/events/before-input-delete-empty-list-target-ranges.html: Added.
+        * fast/events/before-input-delete-text-target-ranges-expected.txt: Added.
+        * fast/events/before-input-delete-text-target-ranges.html: Added.
+        * fast/events/before-input-events-prevent-default-in-textfield.html:
+        * fast/events/before-input-replace-text-target-ranges-expected.txt: Added.
+        * fast/events/before-input-replace-text-target-ranges.html: Added.
+        * fast/events/input-events-fired-when-typing-expected.txt:
+        * fast/events/input-events-fired-when-typing.html:
+        * 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:
+
</ins><span class="cx"> 2016-10-21  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [css-grid] Content Alignment broken with indefinite sized grid container
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputdeleteemptylisttargetrangesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges-expected.txt (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+To manually test this, delete the empty list element and observe the output.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS event.getTargetRanges().length is 1
+PASS range.startContainer.nodeName is '#text'
+PASS range.startContainer.textContent is 'foo'
+PASS range.endContainer is item
+PASS range.startOffset is 3
+PASS range.endOffset is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+foo
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputdeleteemptylisttargetrangeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges.html (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-delete-empty-list-target-ranges.html        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;editable&quot; contenteditable onbeforeinput=beforeinput(event)&gt;foo&lt;div&gt;&lt;ul&gt;&lt;li id=&quot;item&quot;&gt;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        description(&quot;To manually test this, delete the empty list element and observe the output.&quot;);
+
+        editable.focus();
+        getSelection().setPosition(item);
+
+        if (window.internals)
+            internals.settings.setInputEventsEnabled(true);
+
+        if (window.testRunner)
+            testRunner.execCommand(&quot;deleteBackward&quot;);
+
+        function beforeinput(event)
+        {
+            shouldBe(&quot;event.getTargetRanges().length&quot;, &quot;1&quot;);
+            for (let range of event.getTargetRanges()) {
+                window.range = range;
+                shouldBe(&quot;range.startContainer.nodeName&quot;, &quot;'#text'&quot;);
+                shouldBe(&quot;range.startContainer.textContent&quot;, &quot;'foo'&quot;);
+                shouldBe(&quot;range.endContainer&quot;, &quot;item&quot;);
+                shouldBe(&quot;range.startOffset&quot;, &quot;3&quot;);
+                shouldBe(&quot;range.endOffset&quot;, &quot;0&quot;);
+            }
+            event.preventDefault();
+        }
+    &lt;/script&gt;
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputdeletetexttargetrangesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges-expected.txt (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+To manually test this, try deleting backwards/forwards at various text granularities and observe the output.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [0, 1]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [3, 4]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [2, 3]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [16, 17]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [0, 17]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [4, 7]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [7, 10]
+PASS event.inputType.startsWith('delete') is true
+PASS deletionRange.startContainer is deletionRange.endContainer
+Deleting text in range: [0, 10]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+foo barbaz garply
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputdeletetexttargetrangeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges.html (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-delete-text-target-ranges.html        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;editable&quot; contenteditable onbeforeinput=beforeinput(event)&gt;foo barbaz garply&lt;/div&gt;
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        description(&quot;To manually test this, try deleting backwards/forwards at various text granularities and observe the output.&quot;);
+
+        editable.focus();
+
+        if (window.internals)
+            internals.settings.setInputEventsEnabled(true);
+
+        if (window.testRunner) {
+            select(0, 0);
+            testRunner.execCommand(&quot;deleteForward&quot;);
+
+            select(3, 3);
+            testRunner.execCommand(&quot;deleteForward&quot;);
+            testRunner.execCommand(&quot;deleteBackward&quot;);
+
+            select(17, 17);
+            testRunner.execCommand(&quot;deleteBackward&quot;);
+            testRunner.execCommand(&quot;deleteToBeginningOfLine&quot;);
+
+            select(7, 7);
+            testRunner.execCommand(&quot;deleteWordBackward&quot;);
+            testRunner.execCommand(&quot;deleteWordForward&quot;);
+
+            select(0, 10);
+            testRunner.execCommand(&quot;deleteBackward&quot;);
+        }
+
+        function beforeinput(event)
+        {
+            shouldBeTrue(&quot;event.inputType.startsWith('delete')&quot;);
+
+            window.deletionRange = event.getTargetRanges()[0];
+            shouldBe(&quot;deletionRange.startContainer&quot;, &quot;deletionRange.endContainer&quot;);
+            debug(`Deleting text in range: [${deletionRange.startOffset}, ${deletionRange.endOffset}]`)
+            event.preventDefault();
+        }
+
+        function select(startOffset, endOffset)
+        {
+            let range = document.createRange();
+            let textNode = editable.childNodes[0];
+
+            getSelection().removeAllRanges();
+            range.setStart(textNode, startOffset);
+            range.setEnd(textNode, endOffset);
+            getSelection().addRange(range);
+        }
+    &lt;/script&gt;
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputeventspreventdefaultintextfieldhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/before-input-events-prevent-default-in-textfield.html (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-events-prevent-default-in-textfield.html        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-default-in-textfield.html        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> 
</span><span class="cx">             preventDefaultInputEvents = true;
</span><span class="cx"> 
</span><del>-            eventSender.keyDown(&quot;delete&quot;);
</del><ins>+            testRunner.execCommand(&quot;DeleteBackward&quot;);
</ins><span class="cx">             debug(`The final value is: ${input.value}`);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputreplacetexttargetrangesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges-expected.txt (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+To manually test this, type &quot;hllo&quot; and trigger spell checking. Select a spell checking candidate.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS replacementRange.startOffset is 0
+PASS replacementRange.endOffset is 4
+PASS replacementRange.startContainer is editable.childNodes[0]
+PASS replacementRange.endContainer is editable.childNodes[0]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+hllo
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeinputreplacetexttargetrangeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges.html (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/before-input-replace-text-target-ranges.html        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;editable&quot; contenteditable onbeforeinput=beforeinput(event)&gt;&lt;/div&gt;
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        description(&quot;To manually test this, type \&quot;hllo\&quot; and trigger spell checking. Select a spell checking candidate.&quot;);
+
+        editable.focus();
+
+        if (window.eventSender &amp;&amp; window.internals) {
+            internals.settings.setInputEventsEnabled(true);
+            eventSender.keyDown(&quot;h&quot;);
+            eventSender.keyDown(&quot;l&quot;);
+            eventSender.keyDown(&quot;l&quot;);
+            eventSender.keyDown(&quot;o&quot;);
+            internals.handleAcceptedCandidate(&quot;hello&quot;, 0, 4);
+        }
+
+        function beforeinput(event)
+        {
+            if (event.inputType !== &quot;insertReplacementText&quot;)
+                return;
+
+            window.replacementRange = event.getTargetRanges()[0];
+            shouldBe(&quot;replacementRange.startOffset&quot;, &quot;0&quot;);
+            shouldBe(&quot;replacementRange.endOffset&quot;, &quot;4&quot;);
+            shouldBe(&quot;replacementRange.startContainer&quot;, &quot;editable.childNodes[0]&quot;);
+            shouldBe(&quot;replacementRange.endContainer&quot;, &quot;editable.childNodes[0]&quot;);
+            event.preventDefault();
+        }
+    &lt;/script&gt;
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsinputeventsfiredwhentypingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/input-events-fired-when-typing-expected.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/input-events-fired-when-typing-expected.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/fast/events/input-events-fired-when-typing-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> Fired `onbeforeinput`!
</span><span class="cx"> PASS event.__lookupGetter__('inputType') is defined.
</span><span class="cx"> PASS event.__lookupGetter__('data') is defined.
</span><del>-PASS Object.getPrototypeOf(event) is InputEvent.prototype
</del><ins>+PASS event.getTargetRanges is defined.
</ins><span class="cx"> PASS event.target.id is expectedTargetID
</span><span class="cx"> PASS event.bubbles is true
</span><span class="cx"> PASS event.cancelable is true
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> Fired `oninput`!
</span><span class="cx"> PASS event.__lookupGetter__('inputType') is defined.
</span><span class="cx"> PASS event.__lookupGetter__('data') is defined.
</span><del>-PASS Object.getPrototypeOf(event) is InputEvent.prototype
</del><ins>+PASS event.getTargetRanges is defined.
</ins><span class="cx"> PASS event.target.id is expectedTargetID
</span><span class="cx"> PASS event.bubbles is true
</span><span class="cx"> PASS event.cancelable is false
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> Fired `onbeforeinput`!
</span><span class="cx"> PASS event.__lookupGetter__('inputType') is defined.
</span><span class="cx"> PASS event.__lookupGetter__('data') is defined.
</span><del>-PASS Object.getPrototypeOf(event) is InputEvent.prototype
</del><ins>+PASS event.getTargetRanges is defined.
</ins><span class="cx"> PASS event.target.id is expectedTargetID
</span><span class="cx"> PASS event.bubbles is true
</span><span class="cx"> PASS event.cancelable is true
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> Fired `oninput`!
</span><span class="cx"> PASS event.__lookupGetter__('inputType') is defined.
</span><span class="cx"> PASS event.__lookupGetter__('data') is defined.
</span><del>-PASS Object.getPrototypeOf(event) is InputEvent.prototype
</del><ins>+PASS event.getTargetRanges is defined.
</ins><span class="cx"> PASS event.target.id is expectedTargetID
</span><span class="cx"> PASS event.bubbles is true
</span><span class="cx"> PASS event.cancelable is false
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsinputeventsfiredwhentypinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/input-events-fired-when-typing.html (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/input-events-fired-when-typing.html        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/fast/events/input-events-fired-when-typing.html        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx">             debug(&quot;Fired `oninput`!&quot;);
</span><span class="cx">             shouldBeDefined(&quot;event.__lookupGetter__('inputType')&quot;);
</span><span class="cx">             shouldBeDefined(&quot;event.__lookupGetter__('data')&quot;);
</span><del>-            shouldBe(&quot;Object.getPrototypeOf(event)&quot;, &quot;InputEvent.prototype&quot;);
</del><ins>+            shouldBeDefined(&quot;event.getTargetRanges&quot;);
</ins><span class="cx">             shouldBe(&quot;event.target.id&quot;, &quot;expectedTargetID&quot;);
</span><span class="cx">             shouldBe(&quot;event.bubbles&quot;, &quot;true&quot;);
</span><span class="cx">             shouldBe(&quot;event.cancelable&quot;, &quot;false&quot;);
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">             debug(&quot;Fired `onbeforeinput`!&quot;);
</span><span class="cx">             shouldBeDefined(&quot;event.__lookupGetter__('inputType')&quot;);
</span><span class="cx">             shouldBeDefined(&quot;event.__lookupGetter__('data')&quot;);
</span><del>-            shouldBe(&quot;Object.getPrototypeOf(event)&quot;, &quot;InputEvent.prototype&quot;);
</del><ins>+            shouldBeDefined(&quot;event.getTargetRanges&quot;);
</ins><span class="cx">             shouldBe(&quot;event.target.id&quot;, &quot;expectedTargetID&quot;);
</span><span class="cx">             shouldBe(&quot;event.bubbles&quot;, &quot;true&quot;);
</span><span class="cx">             shouldBe(&quot;event.cancelable&quot;, &quot;true&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomglobalconstructorsattributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1798,6 +1798,11 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').hasOwnProperty('set') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').enumerable is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').configurable is true
</span><ins>+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').value is StaticRange
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').configurable is true
</ins><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').value is Storage
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1217,6 +1217,9 @@
</span><span class="cx"> fast/events/before-input-prevent-paste.html [ Failure ]
</span><span class="cx"> fast/events/before-input-prevent-undo.html [ Failure ]
</span><span class="cx"> fast/events/before-input-prevent-typing.html [ Failure ]
</span><ins>+fast/events/before-input-delete-text-target-ranges.html [ Failure ]
+fast/events/before-input-replace-text-target-ranges.html [ Failure ]
+fast/events/before-input-delete-empty-list-target-ranges.html [ Failure ]
</ins><span class="cx"> fast/events/key-events-in-input-button.html [ Failure ]
</span><span class="cx"> fast/events/keydown-1.html [ Failure ]
</span><span class="cx"> fast/events/keydown-leftright-keys.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacjsdomglobalconstructorsattributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -2038,6 +2038,11 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').hasOwnProperty('set') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').enumerable is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').configurable is true
</span><ins>+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').value is StaticRange
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').configurable is true
</ins><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').value is Storage
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1jsdomglobalconstructorsattributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -923,11 +923,6 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'ImageData').enumerable is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'ImageData').configurable is true
</span><del>-PASS Object.getOwnPropertyDescriptor(global, 'InputEvent').value is InputEvent
-PASS Object.getOwnPropertyDescriptor(global, 'InputEvent').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'InputEvent').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'InputEvent').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'InputEvent').configurable is true
</del><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Int16Array').value is Int16Array
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Int16Array').hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Int16Array').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacyosemitejsdomglobalconstructorsattributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -2038,6 +2038,11 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').hasOwnProperty('set') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').enumerable is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'SpeechSynthesisUtterance').configurable is true
</span><ins>+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').value is StaticRange
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'StaticRange').configurable is true
</ins><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').value is Storage
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 'Storage').hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-10-21  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Implement InputEvent.getTargetRanges() for the input events spec
+        https://bugs.webkit.org/show_bug.cgi?id=162947
+        &lt;rdar://problem/28853079&gt;
+
+        Reviewed by Darin Adler.
+
+        Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry
+        for more details.
+
+        * runtime/CommonIdentifiers.h:
+
</ins><span class="cx"> 2016-10-20  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix JSC cast-align compiler warnings on ARMv7
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     macro(IDBTransaction) \
</span><span class="cx">     macro(IDBVersionChangeEvent) \
</span><span class="cx">     macro(Infinity) \
</span><ins>+    macro(InputEvent) \
</ins><span class="cx">     macro(Intl) \
</span><span class="cx">     macro(JSON) \
</span><span class="cx">     macro(Loader) \
</span><span class="lines">@@ -88,6 +89,7 @@
</span><span class="cx">     macro(Set)\
</span><span class="cx">     macro(SetIterator)\
</span><span class="cx">     macro(ShadowRoot) \
</span><ins>+    macro(StaticRange) \
</ins><span class="cx">     macro(String) \
</span><span class="cx">     macro(Symbol) \
</span><span class="cx">     macro(SyntaxError) \
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -440,6 +440,7 @@
</span><span class="cx">     dom/SecurityPolicyViolationEvent.idl
</span><span class="cx">     dom/ShadowRoot.idl
</span><span class="cx">     dom/Slotable.idl
</span><ins>+    dom/StaticRange.idl
</ins><span class="cx">     dom/StringCallback.idl
</span><span class="cx">     dom/Text.idl
</span><span class="cx">     dom/TextEvent.idl
</span><span class="lines">@@ -1507,6 +1508,7 @@
</span><span class="cx">     dom/SlotAssignment.cpp
</span><span class="cx">     dom/SpaceSplitString.cpp
</span><span class="cx">     dom/StaticNodeList.cpp
</span><ins>+    dom/StaticRange.cpp
</ins><span class="cx">     dom/StringCallback.cpp
</span><span class="cx">     dom/StyledElement.cpp
</span><span class="cx">     dom/TagCollection.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/ChangeLog        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1,3 +1,103 @@
</span><ins>+2016-10-21  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Implement InputEvent.getTargetRanges() for the input events spec
+        https://bugs.webkit.org/show_bug.cgi?id=162947
+        &lt;rdar://problem/28853079&gt;
+
+        Reviewed by Darin Adler.
+
+        Implements InputEvent.getTargetRanges(). See individual method changes below for more details. Adds a new hook
+        for subclasses of CompositeEditCommand to vend a list of target StaticRanges when retrieving target ranges for
+        an editing command on a contenteditable area.
+
+        Tests: fast/events/before-input-delete-empty-list-target-ranges.html
+               fast/events/before-input-delete-text-target-ranges.html
+               fast/events/before-input-replace-text-target-ranges.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Add StaticRange.idl, StaticRange.cpp and StaticRange.h.
+
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setInputEventsEnabled):
+        (WebCore::RuntimeEnabledFeatures::inputEventsEnabled):
+
+        Add a new runtime bindings flag for InputEvents and guard both InputEvent and StaticRange behind it.
+
+        * dom/DOMAllInOne.cpp:
+        * dom/InputEvent.cpp:
+        (WebCore::InputEvent::InputEvent):
+        * dom/InputEvent.h:
+        * dom/InputEvent.idl:
+        * dom/StaticRange.cpp: Copied from Source/WebCore/dom/InputEvent.cpp.
+        (WebCore::StaticRange::StaticRange):
+        (WebCore::StaticRange::create):
+        (WebCore::StaticRange::createFromRange):
+
+        Convenience method for creating a StaticRange from a Range's start/end container and offset.
+
+        (WebCore::StaticRange::startContainer):
+        (WebCore::StaticRange::endContainer):
+        (WebCore::StaticRange::collapsed):
+        * dom/StaticRange.h: Copied from Source/WebCore/dom/InputEvent.cpp.
+        (WebCore::StaticRange::startOffset):
+        (WebCore::StaticRange::endOffset):
+        * dom/StaticRange.idl: Copied from Source/WebCore/editing/ReplaceRangeWithTextCommand.h.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::willApplyCommand):
+        (WebCore::CompositeEditCommand::targetRanges):
+
+        Virtual method that returns a list of target ranges which are associated with this command.
+
+        (WebCore::CompositeEditCommand::targetRangesForBindings):
+
+        Non-virtual method that calls the above targetRanges(). Takes whether or not the CompositeEditCommand is editing
+        a textarea or plain text input into account.
+
+        (WebCore::CompositeEditCommand::moveParagraphs):
+        * editing/CompositeEditCommand.h:
+        * editing/EditCommand.cpp:
+        (WebCore::EditCommand::frame):
+        * editing/EditCommand.h:
+        (WebCore::EditCommand::document):
+        * editing/Editor.cpp:
+        (WebCore::dispatchBeforeInputEvent):
+        (WebCore::dispatchInputEvent):
+        (WebCore::dispatchBeforeInputEvents):
+
+        Changed the `beforeinput` event dispatch to use the regular Node::dispatchEvent instead of dispatchScopedEvent.
+        This is because if the page prevents the `beforeinput` event, we need to know immediately in order to bail from
+        the default action.
+
+        (WebCore::dispatchInputEvents):
+        (WebCore::Editor::willApplyEditing):
+
+        Added a list of static ranges as a parameter when calling on the Editor to dispatch `beforeinput` events.
+        By default, this uses the composite edit command's targetRangesForBindings(), though it may be special cased
+        by subclasses of CompositeEditCommand (see ReplaceRangeWithTextCommand, SpellingCorrectionCommand, and
+        TypingCommand).
+
+        * editing/Editor.h:
+        * editing/ReplaceRangeWithTextCommand.cpp:
+        (WebCore::ReplaceRangeWithTextCommand::targetRanges):
+        * editing/ReplaceRangeWithTextCommand.h:
+        * editing/SpellingCorrectionCommand.cpp:
+        (WebCore::SpellingCorrectionCommand::targetRanges):
+        * editing/SpellingCorrectionCommand.h:
+        * editing/TypingCommand.cpp:
+        (WebCore::editActionIsDeleteByTyping):
+        (WebCore::TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand):
+        (WebCore::TypingCommand::willApplyCommand):
+        (WebCore::TypingCommand::willAddTypingToOpenCommand):
+        (WebCore::TypingCommand::deleteKeyPressed):
+        (WebCore::TypingCommand::forwardDeleteKeyPressed):
+
+        Moves the firing of the `beforeinput` until after the selection range to delete has been computed.
+
+        * editing/TypingCommand.h:
+
</ins><span class="cx"> 2016-10-21  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Style resolver should be updated lazily
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/DerivedSources.make        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -350,6 +350,7 @@
</span><span class="cx">     $(WebCore)/dom/SecurityPolicyViolationEvent.idl \
</span><span class="cx">     $(WebCore)/dom/ShadowRoot.idl \
</span><span class="cx">     $(WebCore)/dom/Slotable.idl \
</span><ins>+    $(WebCore)/dom/StaticRange.idl \
</ins><span class="cx">     $(WebCore)/dom/StringCallback.idl \
</span><span class="cx">     $(WebCore)/dom/Text.idl \
</span><span class="cx">     $(WebCore)/dom/TextEvent.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -4114,8 +4114,10 @@
</span><span class="cx">                 A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A86629CC09DA2B47009633A5 /* JSMouseEvent.cpp */; };
</span><span class="cx">                 A86629D309DA2B48009633A5 /* JSKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */; };
</span><span class="cx">                 A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A86629CD09DA2B47009633A6 /* JSInputEvent.h */; };
</span><ins>+                A86629D309DA2B48009633A7 /* JSStaticRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A86629CD09DA2B47009633A7 /* JSStaticRange.h */; };
</ins><span class="cx">                 A86629D409DA2B48009633A5 /* JSKeyboardEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */; };
</span><span class="cx">                 A86629D409DA2B48009633A6 /* JSInputEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A86629CE09DA2B47009633A6 /* JSInputEvent.cpp */; };
</span><ins>+                A86629D409DA2B48009633A7 /* JSStaticRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A86629CE09DA2B47009633A7 /* JSStaticRange.cpp */; };
</ins><span class="cx">                 A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A871D44C0A127CBC00B12A68 /* HTMLPlugInElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A871D4570A127CBC00B12A68 /* HTMLPlugInElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A871D44D0A127CBC00B12A68 /* HTMLPlugInElement.cpp */; };
</span><span class="cx">                 A871D4580A127CBC00B12A68 /* HTMLParamElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A871D44E0A127CBC00B12A68 /* HTMLParamElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -6354,6 +6356,8 @@
</span><span class="cx">                 F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */; };
</span><span class="cx">                 F40EA8AB1B867E4400CE5581 /* NSScrollingInputFilterSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 F42FFB461984B71600F6837F /* LengthRepeat.h in Headers */ = {isa = PBXBuildFile; fileRef = F42FFB451984B71600F6837F /* LengthRepeat.h */; };
</span><ins>+                F44EBBD91DB5D21400277334 /* StaticRange.h in Headers */ = {isa = PBXBuildFile; fileRef = F44EBBD81DB5D21400277334 /* StaticRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                F44EBBDB1DB5DD9D00277334 /* StaticRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F44EBBDA1DB5DD9D00277334 /* StaticRange.cpp */; };
</ins><span class="cx">                 F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */; };
</span><span class="cx">                 F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */ = {isa = PBXBuildFile; fileRef = F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */ = {isa = PBXBuildFile; fileRef = F478755219983AFF0024A287 /* ScrollSnapAnimatorState.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -11585,8 +11589,10 @@
</span><span class="cx">                 A86629CC09DA2B47009633A5 /* JSMouseEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMouseEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSKeyboardEvent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A86629CD09DA2B47009633A6 /* JSInputEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSInputEvent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A86629CD09DA2B47009633A7 /* JSStaticRange.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStaticRange.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSKeyboardEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A86629CE09DA2B47009633A6 /* JSInputEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSInputEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A86629CE09DA2B47009633A7 /* JSStaticRange.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStaticRange.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A871D44C0A127CBC00B12A68 /* HTMLPlugInElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLPlugInElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A871D44D0A127CBC00B12A68 /* HTMLPlugInElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLPlugInElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A871D44E0A127CBC00B12A68 /* HTMLParamElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParamElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -14145,6 +14151,9 @@
</span><span class="cx">                 F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorConsoleInstrumentation.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSScrollingInputFilterSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F42FFB451984B71600F6837F /* LengthRepeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthRepeat.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F44EBBD61DB5D1B600277334 /* StaticRange.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StaticRange.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
+                F44EBBD81DB5D21400277334 /* StaticRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticRange.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                F44EBBDA1DB5DD9D00277334 /* StaticRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticRange.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapOffsets.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F478755219983AFF0024A287 /* ScrollSnapAnimatorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollSnapAnimatorState.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20089,6 +20098,8 @@
</span><span class="cx">                                 8482B7501198CB6B00BFB005 /* JSHashChangeEvent.h */,
</span><span class="cx">                                 A86629CE09DA2B47009633A6 /* JSInputEvent.cpp */,
</span><span class="cx">                                 A86629CD09DA2B47009633A6 /* JSInputEvent.h */,
</span><ins>+                                A86629CE09DA2B47009633A7 /* JSStaticRange.cpp */,
+                                A86629CD09DA2B47009633A7 /* JSStaticRange.h */,
</ins><span class="cx">                                 A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */,
</span><span class="cx">                                 A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */,
</span><span class="cx">                                 E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */,
</span><span class="lines">@@ -23715,6 +23726,9 @@
</span><span class="cx">                                 D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */,
</span><span class="cx">                                 BC7FA62C0D1F0EFF00DB22A9 /* StaticNodeList.cpp */,
</span><span class="cx">                                 BC7FA62B0D1F0EFF00DB22A9 /* StaticNodeList.h */,
</span><ins>+                                F44EBBDA1DB5DD9D00277334 /* StaticRange.cpp */,
+                                F44EBBD81DB5D21400277334 /* StaticRange.h */,
+                                F44EBBD61DB5D1B600277334 /* StaticRange.idl */,
</ins><span class="cx">                                 8102C5871325BB1100DDE67A /* StringCallback.cpp */,
</span><span class="cx">                                 81AC6C35131C57D30009A7E0 /* StringCallback.h */,
</span><span class="cx">                                 81AC6C34131C57C20009A7E0 /* StringCallback.idl */,
</span><span class="lines">@@ -25661,6 +25675,7 @@
</span><span class="cx">                                 A77979290D6B9E64003851B9 /* JSImageData.h in Headers */,
</span><span class="cx">                                 A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
</span><span class="cx">                                 7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */,
</span><ins>+                                A86629D309DA2B48009633A7 /* JSStaticRange.h in Headers */,
</ins><span class="cx">                                 A86629D309DA2B48009633A5 /* JSKeyboardEvent.h in Headers */,
</span><span class="cx">                                 12A253E11C8FFF6600C22295 /* JSKeyframeEffect.h in Headers */,
</span><span class="cx">                                 935F45430F7C3B5F00D7C1FB /* JSLazyEventListener.h in Headers */,
</span><span class="lines">@@ -26561,6 +26576,7 @@
</span><span class="cx">                                 BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */,
</span><span class="cx">                                 9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */,
</span><span class="cx">                                 BCEA486E097D93020094C9E4 /* RenderDeprecatedFlexibleBox.h in Headers */,
</span><ins>+                                F44EBBD91DB5D21400277334 /* StaticRange.h in Headers */,
</ins><span class="cx">                                 836DAA061CEAB80D00A2B707 /* RenderDescendantIterator.h in Headers */,
</span><span class="cx">                                 D302754A12A5FE84004BD828 /* RenderDetailsMarker.h in Headers */,
</span><span class="cx">                                 A76E5F7F135E0DCF00A69837 /* RenderedDocumentMarker.h in Headers */,
</span><span class="lines">@@ -29163,6 +29179,7 @@
</span><span class="cx">                                 BCA83E520D7CE205003421A8 /* JSDataTransferCustom.cpp in Sources */,
</span><span class="cx">                                 4162A4571011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp in Sources */,
</span><span class="cx">                                 4162A454101145E300DFF3ED /* JSDedicatedWorkerGlobalScopeCustom.cpp in Sources */,
</span><ins>+                                F44EBBDB1DB5DD9D00277334 /* StaticRange.cpp in Sources */,
</ins><span class="cx">                                 FDA15ED112B03F94003A583A /* JSDelayNode.cpp in Sources */,
</span><span class="cx">                                 31FB1A65120A5D3F00DC02A0 /* JSDeviceMotionEvent.cpp in Sources */,
</span><span class="cx">                                 31FB1A6C120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp in Sources */,
</span><span class="lines">@@ -29382,6 +29399,7 @@
</span><span class="cx">                                 A86629D409DA2B48009633A6 /* JSInputEvent.cpp in Sources */,
</span><span class="cx">                                 7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */,
</span><span class="cx">                                 7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */,
</span><ins>+                                A86629D409DA2B48009633A7 /* JSStaticRange.cpp in Sources */,
</ins><span class="cx">                                 A86629D409DA2B48009633A5 /* JSKeyboardEvent.cpp in Sources */,
</span><span class="cx">                                 12A253E01C8FFF6600C22295 /* JSKeyframeEffect.cpp in Sources */,
</span><span class="cx">                                 935F45420F7C3B5F00D7C1FB /* JSLazyEventListener.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsgenericRuntimeEnabledFeaturesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -198,6 +198,9 @@
</span><span class="cx">     void setShadowDOMEnabled(bool isEnabled) { m_isShadowDOMEnabled = isEnabled; }
</span><span class="cx">     bool shadowDOMEnabled() const { return m_isShadowDOMEnabled; }
</span><span class="cx"> 
</span><ins>+    void setInputEventsEnabled(bool isEnabled) { m_inputEventsEnabled = isEnabled; }
+    bool inputEventsEnabled() const { return m_inputEventsEnabled; }
+
</ins><span class="cx">     void setInteractiveFormValidationEnabled(bool isEnabled) { m_isInteractiveFormValidationEnabled = isEnabled; }
</span><span class="cx">     bool interactiveFormValidationEnabled() const { return m_isInteractiveFormValidationEnabled; }
</span><span class="cx"> 
</span><span class="lines">@@ -321,6 +324,8 @@
</span><span class="cx">     
</span><span class="cx">     bool m_isShadowDOMEnabled;
</span><span class="cx"> 
</span><ins>+    bool m_inputEventsEnabled;
+
</ins><span class="cx">     bool m_isInteractiveFormValidationEnabled { false };
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span></span></pre></div>
<a id="trunkSourceWebCoredomDOMAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMAllInOne.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -141,6 +141,7 @@
</span><span class="cx"> #include &quot;SlotAssignment.cpp&quot;
</span><span class="cx"> #include &quot;SpaceSplitString.cpp&quot;
</span><span class="cx"> #include &quot;StaticNodeList.cpp&quot;
</span><ins>+#include &quot;StaticRange.cpp&quot;
</ins><span class="cx"> #include &quot;StringCallback.cpp&quot;
</span><span class="cx"> #include &quot;StyledElement.cpp&quot;
</span><span class="cx"> #include &quot;TagCollection.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoredomInputEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InputEvent.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InputEvent.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/dom/InputEvent.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;DOMWindow.h&quot;
</span><span class="cx"> #include &quot;EventNames.h&quot;
</span><ins>+#include &quot;Node.h&quot;
</ins><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -34,10 +35,11 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-InputEvent::InputEvent(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow* view, const String&amp; data, int detail)
</del><ins>+InputEvent::InputEvent(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow* view, const String&amp; data, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges, int detail)
</ins><span class="cx">     : UIEvent(eventType, canBubble, cancelable, view, detail)
</span><span class="cx">     , m_inputType(inputType)
</span><span class="cx">     , m_data(data)
</span><ins>+    , m_targetRanges(targetRanges)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomInputEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InputEvent.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InputEvent.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/dom/InputEvent.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include &quot;StaticRange.h&quot;
</ins><span class="cx"> #include &quot;UIEvent.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -34,9 +35,9 @@
</span><span class="cx"> 
</span><span class="cx"> class InputEvent final : public UIEvent {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;InputEvent&gt; create(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow* view, const String&amp; data, int detail)
</del><ins>+    static Ref&lt;InputEvent&gt; create(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow* view, const String&amp; data, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges, int detail)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new InputEvent(eventType, inputType, canBubble, cancelable, view, data, detail));
</del><ins>+        return adoptRef(*new InputEvent(eventType, inputType, canBubble, cancelable, view, data, targetRanges, detail));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     struct Init : UIEventInit {
</span><span class="lines">@@ -48,7 +49,7 @@
</span><span class="cx">         return adoptRef(*new InputEvent(type, initializer, isTrusted));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    InputEvent(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow*, const String&amp; data, int detail);
</del><ins>+    InputEvent(const AtomicString&amp; eventType, const String&amp; inputType, bool canBubble, bool cancelable, DOMWindow*, const String&amp; data, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges, int detail);
</ins><span class="cx">     InputEvent(const AtomicString&amp; eventType, const Init&amp;, IsTrusted);
</span><span class="cx"> 
</span><span class="cx">     virtual ~InputEvent() { }
</span><span class="lines">@@ -57,10 +58,12 @@
</span><span class="cx">     EventInterface eventInterface() const final { return InputEventInterfaceType; }
</span><span class="cx">     const String&amp; inputType() const { return m_inputType; }
</span><span class="cx">     const String&amp; data() const { return m_data; }
</span><ins>+    const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; getTargetRanges() { return m_targetRanges; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     String m_inputType;
</span><span class="cx">     String m_data;
</span><ins>+    Vector&lt;RefPtr&lt;StaticRange&gt;&gt; m_targetRanges;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomInputEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InputEvent.idl (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InputEvent.idl        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/dom/InputEvent.idl        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -25,9 +25,12 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     Constructor(DOMString type, optional InputEventInit eventInitDict),
</span><ins>+    EnabledAtRuntime=InputEvents,
</ins><span class="cx"> ] interface InputEvent : UIEvent {
</span><span class="cx">     readonly attribute DOMString inputType;
</span><span class="cx">     readonly attribute DOMString? data;
</span><ins>+
+    sequence&lt;StaticRange&gt; getTargetRanges();
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> dictionary InputEventInit : UIEventInit {
</span></span></pre></div>
<a id="trunkSourceWebCoredomStaticRangecppfromrev207669trunkSourceWebCoredomInputEventcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/StaticRange.cpp (from rev 207669, trunk/Source/WebCore/dom/InputEvent.cpp) (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StaticRange.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/StaticRange.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;StaticRange.h&quot;
+
+#include &quot;Node.h&quot;
+#include &quot;Range.h&quot;
+
+namespace WebCore {
+
+StaticRange::StaticRange(Ref&lt;Node&gt;&amp;&amp; startContainer, unsigned startOffset, Ref&lt;Node&gt;&amp;&amp; endContainer, unsigned endOffset)
+    : m_startContainer(WTFMove(startContainer))
+    , m_startOffset(startOffset)
+    , m_endContainer(WTFMove(endContainer))
+    , m_endOffset(endOffset)
+{
+}
+
+Ref&lt;StaticRange&gt; StaticRange::create(Ref&lt;WebCore::Node&gt; &amp;&amp;startContainer, unsigned startOffset, Ref&lt;WebCore::Node&gt; &amp;&amp;endContainer, unsigned endOffset)
+{
+    return adoptRef(*new StaticRange(WTFMove(startContainer), startOffset, WTFMove(endContainer), endOffset));
+}
+
+Ref&lt;StaticRange&gt; StaticRange::createFromRange(const Range&amp; range)
+{
+    return StaticRange::create(range.startContainer(), range.startOffset(), range.endContainer(), range.endOffset());
+}
+
+Node* StaticRange::startContainer() const
+{
+    return (Node*)m_startContainer.ptr();
+}
+
+Node* StaticRange::endContainer() const
+{
+    return (Node*)m_endContainer.ptr();
+}
+
+bool StaticRange::collapsed() const
+{
+    return m_startOffset == m_endOffset &amp;&amp; m_startContainer.ptr() == m_endContainer.ptr();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomStaticRangehfromrev207669trunkSourceWebCoredomInputEventcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/StaticRange.h (from rev 207669, trunk/Source/WebCore/dom/InputEvent.cpp) (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StaticRange.h                                (rev 0)
+++ trunk/Source/WebCore/dom/StaticRange.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace WebCore {
+
+class Node;
+class Range;
+
+class StaticRange : public RefCounted&lt;StaticRange&gt; {
+public:
+    static Ref&lt;StaticRange&gt; createFromRange(const Range&amp;);
+    static Ref&lt;StaticRange&gt; create(Ref&lt;Node&gt;&amp;&amp; startContainer, unsigned startOffset, Ref&lt;Node&gt;&amp;&amp; endContainer, unsigned endOffset);
+
+    unsigned startOffset() const { return m_startOffset; }
+    unsigned endOffset() const { return m_endOffset; }
+    Node* startContainer() const;
+    Node* endContainer() const;
+    bool collapsed() const;
+
+private:
+    StaticRange(Ref&lt;Node&gt;&amp;&amp; startContainer, unsigned startOffset, Ref&lt;Node&gt;&amp;&amp; endContainer, unsigned endOffset);
+
+    Ref&lt;Node&gt; m_startContainer;
+    unsigned m_startOffset;
+    Ref&lt;Node&gt; m_endContainer;
+    unsigned m_endOffset;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomStaticRangeidlfromrev207669trunkSourceWebCoreeditingReplaceRangeWithTextCommandh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/StaticRange.idl (from rev 207669, trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.h) (0 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StaticRange.idl                                (rev 0)
+++ trunk/Source/WebCore/dom/StaticRange.idl        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=InputEvents,
+    ImplementationLacksVTable,
+] interface StaticRange {
+    readonly attribute unsigned long startOffset;
+    readonly attribute unsigned long endOffset;
+    readonly attribute Node startContainer;
+    readonly attribute Node endContainer;
+    readonly attribute boolean collapsed;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreeditingCompositeEditCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> #include &quot;SplitElementCommand.h&quot;
</span><span class="cx"> #include &quot;SplitTextNodeCommand.h&quot;
</span><span class="cx"> #include &quot;SplitTextNodeContainingElementCommand.h&quot;
</span><ins>+#include &quot;StaticRange.h&quot;
</ins><span class="cx"> #include &quot;Text.h&quot;
</span><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;VisibleUnits.h&quot;
</span><span class="lines">@@ -319,7 +320,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool CompositeEditCommand::willApplyCommand()
</span><span class="cx"> {
</span><del>-    return frame().editor().willApplyEditing(*this);
</del><ins>+    return frame().editor().willApplyEditing(*this, targetRangesForBindings());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CompositeEditCommand::apply()
</span><span class="lines">@@ -375,6 +376,25 @@
</span><span class="cx">     frame().editor().appliedEditing(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;RefPtr&lt;StaticRange&gt;&gt; CompositeEditCommand::targetRanges() const
+{
+    ASSERT(!isEditingTextAreaOrTextInput());
+    auto firstRange = frame().selection().selection().firstRange();
+    if (!firstRange)
+        return { };
+
+    RefPtr&lt;StaticRange&gt; range = StaticRange::createFromRange(*firstRange);
+    return { 1, range };
+}
+
+Vector&lt;RefPtr&lt;StaticRange&gt;&gt; CompositeEditCommand::targetRangesForBindings() const
+{
+    if (isEditingTextAreaOrTextInput())
+        return { };
+
+    return targetRanges();
+}
+
</ins><span class="cx"> EditCommandComposition* CompositeEditCommand::ensureComposition()
</span><span class="cx"> {
</span><span class="cx">     CompositeEditCommand* command = this;
</span><span class="lines">@@ -1496,24 +1516,34 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: Send an appropriate shouldDeleteRange call.
-bool CompositeEditCommand::breakOutOfEmptyListItem()
</del><ins>+Optional&lt;VisibleSelection&gt; CompositeEditCommand::shouldBreakOutOfEmptyListItem() const
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;Node&gt; emptyListItem = enclosingEmptyListItem(endingSelection().visibleStart());
</del><ins>+    auto emptyListItem = enclosingEmptyListItem(endingSelection().visibleStart());
</ins><span class="cx">     if (!emptyListItem)
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx"> 
</span><del>-    RefPtr&lt;EditingStyle&gt; style = EditingStyle::create(endingSelection().start());
-    style-&gt;mergeTypingStyle(document());
-
-    RefPtr&lt;ContainerNode&gt; listNode = emptyListItem-&gt;parentNode();
</del><ins>+    auto listNode = emptyListItem-&gt;parentNode();
</ins><span class="cx">     // FIXME: Can't we do something better when the immediate parent wasn't a list node?
</span><span class="cx">     if (!listNode
</span><span class="cx">         || (!listNode-&gt;hasTagName(ulTag) &amp;&amp; !listNode-&gt;hasTagName(olTag))
</span><span class="cx">         || !listNode-&gt;hasEditableStyle()
</span><span class="cx">         || listNode == emptyListItem-&gt;rootEditableElement())
</span><ins>+        return Nullopt;
+
+    return VisibleSelection(endingSelection().start().previous(BackwardDeletion), endingSelection().end());
+}
+
+// FIXME: Send an appropriate shouldDeleteRange call.
+bool CompositeEditCommand::breakOutOfEmptyListItem()
+{
+    if (!shouldBreakOutOfEmptyListItem())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    auto emptyListItem = enclosingEmptyListItem(endingSelection().visibleStart());
+    auto listNode = emptyListItem-&gt;parentNode();
+    auto style = EditingStyle::create(endingSelection().start());
+    style-&gt;mergeTypingStyle(document());
+
</ins><span class="cx">     RefPtr&lt;Element&gt; newBlock;
</span><span class="cx">     if (ContainerNode* blockEnclosingList = listNode-&gt;parentNode()) {
</span><span class="cx">         if (is&lt;HTMLLIElement&gt;(*blockEnclosingList)) { // listNode is inside another list item
</span><span class="lines">@@ -1538,7 +1568,7 @@
</span><span class="cx">     if (isListItem(nextListNode.get()) || isListHTMLElement(nextListNode.get())) {
</span><span class="cx">         // If emptyListItem follows another list item or nested list, split the list node.
</span><span class="cx">         if (isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()))
</span><del>-            splitElement(downcast&lt;Element&gt;(listNode.get()), emptyListItem);
</del><ins>+            splitElement(downcast&lt;Element&gt;(listNode), emptyListItem);
</ins><span class="cx"> 
</span><span class="cx">         // If emptyListItem is followed by other list item or nested list, then insert newBlock before the list node.
</span><span class="cx">         // Because we have splitted the element, emptyListItem is the first element in the list node.
</span><span class="lines">@@ -1549,7 +1579,7 @@
</span><span class="cx">         // When emptyListItem does not follow any list item or nested list, insert newBlock after the enclosing list node.
</span><span class="cx">         // Remove the enclosing node if emptyListItem is the only child; otherwise just remove emptyListItem.
</span><span class="cx">         insertNodeAfter(newBlock, listNode);
</span><del>-        removeNode(isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()) ? emptyListItem.get() : listNode.get());
</del><ins>+        removeNode(isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()) ? emptyListItem : listNode);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     appendBlockPlaceholder(newBlock);
</span><span class="lines">@@ -1557,7 +1587,7 @@
</span><span class="cx"> 
</span><span class="cx">     style-&gt;prepareToApplyAt(endingSelection().start());
</span><span class="cx">     if (!style-&gt;isEmpty())
</span><del>-        applyStyle(style.get());
</del><ins>+        applyStyle(style.ptr());
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingCompositeEditCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/CompositeEditCommand.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/CompositeEditCommand.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> 
</span><span class="cx"> class EditingStyle;
</span><span class="cx"> class HTMLElement;
</span><ins>+class StaticRange;
</ins><span class="cx"> class StyledElement;
</span><span class="cx"> class Text;
</span><span class="cx"> 
</span><span class="lines">@@ -115,6 +116,7 @@
</span><span class="cx">     virtual bool shouldStopCaretBlinking() const { return false; }
</span><span class="cx">     virtual String inputEventTypeName() const;
</span><span class="cx">     virtual String inputEventData() const { return { }; }
</span><ins>+    Vector&lt;RefPtr&lt;StaticRange&gt;&gt; targetRangesForBindings() const;
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     explicit CompositeEditCommand(Document&amp;, EditAction = EditActionUnspecified);
</span><span class="lines">@@ -123,6 +125,8 @@
</span><span class="cx">     virtual bool willApplyCommand();
</span><span class="cx">     virtual void didApplyCommand();
</span><span class="cx"> 
</span><ins>+    virtual Vector&lt;RefPtr&lt;StaticRange&gt;&gt; targetRanges() const;
+
</ins><span class="cx">     //
</span><span class="cx">     // sugary-sweet convenience functions to help create and apply edit commands in composite commands
</span><span class="cx">     //
</span><span class="lines">@@ -193,6 +197,7 @@
</span><span class="cx">     void cloneParagraphUnderNewElement(const Position&amp; start, const Position&amp; end, Node* outerNode, Element* blockElement);
</span><span class="cx">     void cleanupAfterDeletion(VisiblePosition destination = VisiblePosition());
</span><span class="cx">     
</span><ins>+    Optional&lt;VisibleSelection&gt; shouldBreakOutOfEmptyListItem() const;
</ins><span class="cx">     bool breakOutOfEmptyListItem();
</span><span class="cx">     bool breakOutOfEmptyMailBlockquotedParagraph();
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditCommand.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditCommand.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/EditCommand.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -132,6 +132,12 @@
</span><span class="cx">     return *document().frame();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const Frame&amp; EditCommand::frame() const
+{
+    ASSERT(document().frame());
+    return *document().frame();
+}
+
</ins><span class="cx"> EditAction EditCommand::editingAction() const
</span><span class="cx"> {
</span><span class="cx">     return m_editingAction;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditCommand.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditCommand.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/EditCommand.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -66,7 +66,9 @@
</span><span class="cx">     explicit EditCommand(Document&amp;, EditAction = EditActionUnspecified);
</span><span class="cx">     EditCommand(Document&amp;, const VisibleSelection&amp;, const VisibleSelection&amp;);
</span><span class="cx"> 
</span><ins>+    const Frame&amp; frame() const;
</ins><span class="cx">     Frame&amp; frame();
</span><ins>+    const Document&amp; document() const { return m_document; }
</ins><span class="cx">     Document&amp; document() { return m_document; }
</span><span class="cx">     CompositeEditCommand* parent() const { return m_parent; }
</span><span class="cx">     void setStartingSelection(const VisibleSelection&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -111,23 +111,20 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static bool dispatchBeforeInputEvent(Element&amp; element, const AtomicString&amp; inputType, const String&amp; data = { })
</del><ins>+static bool dispatchBeforeInputEvent(Element&amp; element, const AtomicString&amp; inputType, const String&amp; data = { }, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges = { })
</ins><span class="cx"> {
</span><span class="cx">     auto* settings = element.document().settings();
</span><span class="cx">     if (!settings || !settings-&gt;inputEventsEnabled())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    auto event = InputEvent::create(eventNames().beforeinputEvent, inputType, true, true, element.document().defaultView(), data, 0);
-    element.dispatchScopedEvent(event);
-
-    return !event-&gt;defaultPrevented();
</del><ins>+    return element.dispatchEvent(InputEvent::create(eventNames().beforeinputEvent, inputType, true, true, element.document().defaultView(), data, targetRanges, 0));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void dispatchInputEvent(Element&amp; element, const AtomicString&amp; inputType, const String&amp; data = { })
</del><ins>+static void dispatchInputEvent(Element&amp; element, const AtomicString&amp; inputType, const String&amp; data = { }, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges = { })
</ins><span class="cx"> {
</span><span class="cx">     auto* settings = element.document().settings();
</span><span class="cx">     if (settings &amp;&amp; settings-&gt;inputEventsEnabled())
</span><del>-        element.dispatchScopedEvent(InputEvent::create(eventNames().inputEvent, inputType, true, false, element.document().defaultView(), data, 0));
</del><ins>+        element.dispatchScopedEvent(InputEvent::create(eventNames().inputEvent, inputType, true, false, element.document().defaultView(), data, targetRanges, 0));
</ins><span class="cx">     else
</span><span class="cx">         element.dispatchInputEvent();
</span><span class="cx"> }
</span><span class="lines">@@ -1066,31 +1063,31 @@
</span><span class="cx">         endingTextControl-&gt;didEditInnerTextValue();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool dispatchBeforeInputEvents(RefPtr&lt;Element&gt; startRoot, RefPtr&lt;Element&gt; endRoot, const AtomicString&amp; inputTypeName, const String&amp; data = { })
</del><ins>+static bool dispatchBeforeInputEvents(RefPtr&lt;Element&gt; startRoot, RefPtr&lt;Element&gt; endRoot, const AtomicString&amp; inputTypeName, const String&amp; data = { }, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges = { })
</ins><span class="cx"> {
</span><span class="cx">     bool continueWithDefaultBehavior = true;
</span><span class="cx">     if (startRoot)
</span><del>-        continueWithDefaultBehavior &amp;= dispatchBeforeInputEvent(*startRoot, inputTypeName, data);
</del><ins>+        continueWithDefaultBehavior &amp;= dispatchBeforeInputEvent(*startRoot, inputTypeName, data, targetRanges);
</ins><span class="cx">     if (endRoot &amp;&amp; endRoot != startRoot)
</span><del>-        continueWithDefaultBehavior &amp;= dispatchBeforeInputEvent(*endRoot, inputTypeName, data);
</del><ins>+        continueWithDefaultBehavior &amp;= dispatchBeforeInputEvent(*endRoot, inputTypeName, data, targetRanges);
</ins><span class="cx">     return continueWithDefaultBehavior;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void dispatchInputEvents(RefPtr&lt;Element&gt; startRoot, RefPtr&lt;Element&gt; endRoot, const AtomicString&amp; inputTypeName, const String&amp; data = { })
</del><ins>+static void dispatchInputEvents(RefPtr&lt;Element&gt; startRoot, RefPtr&lt;Element&gt; endRoot, const AtomicString&amp; inputTypeName, const String&amp; data = { }, const Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp; targetRanges = { })
</ins><span class="cx"> {
</span><span class="cx">     if (startRoot)
</span><del>-        dispatchInputEvent(*startRoot, inputTypeName, data);
</del><ins>+        dispatchInputEvent(*startRoot, inputTypeName, data, targetRanges);
</ins><span class="cx">     if (endRoot &amp;&amp; endRoot != startRoot)
</span><del>-        dispatchInputEvent(*endRoot, inputTypeName, data);
</del><ins>+        dispatchInputEvent(*endRoot, inputTypeName, data, targetRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Editor::willApplyEditing(CompositeEditCommand&amp; command) const
</del><ins>+bool Editor::willApplyEditing(CompositeEditCommand&amp; command, Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp;&amp; targetRanges) const
</ins><span class="cx"> {
</span><span class="cx">     auto* composition = command.composition();
</span><span class="cx">     if (!composition)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    return dispatchBeforeInputEvents(composition-&gt;startingRootEditableElement(), composition-&gt;endingRootEditableElement(), command.inputEventTypeName(), command.inputEventData());
</del><ins>+    return dispatchBeforeInputEvents(composition-&gt;startingRootEditableElement(), composition-&gt;endingRootEditableElement(), command.inputEventTypeName(), command.inputEventData(), targetRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Editor::appliedEditing(PassRefPtr&lt;CompositeEditCommand&gt; cmd)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/Editor.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> class Font;
</span><span class="cx"> class SpellCheckRequest;
</span><span class="cx"> class SpellChecker;
</span><ins>+class StaticRange;
</ins><span class="cx"> class StyleProperties;
</span><span class="cx"> class Text;
</span><span class="cx"> class TextCheckerClient;
</span><span class="lines">@@ -199,7 +200,7 @@
</span><span class="cx">     void applyParagraphStyleToSelection(StyleProperties*, EditAction);
</span><span class="cx"> 
</span><span class="cx">     // Returns whether or not we should proceed with editing.
</span><del>-    bool willApplyEditing(CompositeEditCommand&amp;) const;
</del><ins>+    bool willApplyEditing(CompositeEditCommand&amp;, Vector&lt;RefPtr&lt;StaticRange&gt;&gt;&amp;&amp;) const;
</ins><span class="cx">     bool willUnapplyEditing(const EditCommandComposition&amp;) const;
</span><span class="cx">     bool willReapplyEditing(const EditCommandComposition&amp;) const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingReplaceRangeWithTextCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;ReplaceSelectionCommand.h&quot;
</span><span class="cx"> #include &quot;SetSelectionCommand.h&quot;
</span><ins>+#include &quot;StaticRange.h&quot;
</ins><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;markup.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -73,4 +74,10 @@
</span><span class="cx">     return CompositeEditCommand::inputEventData();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;RefPtr&lt;StaticRange&gt;&gt; ReplaceRangeWithTextCommand::targetRanges() const
+{
+    RefPtr&lt;StaticRange&gt; range = StaticRange::createFromRange(*m_rangeToBeReplaced);
+    return { 1, range };
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingReplaceRangeWithTextCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx">     ReplaceRangeWithTextCommand(RefPtr&lt;Range&gt; rangeToBeReplaced, const String&amp; text);
</span><span class="cx">     void doApply() override;
</span><span class="cx">     String inputEventData() const final;
</span><ins>+    Vector&lt;RefPtr&lt;StaticRange&gt;&gt; targetRanges() const final;
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Range&gt; m_rangeToBeReplaced;
</span><span class="cx">     String m_text;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSpellingCorrectionCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;ReplaceSelectionCommand.h&quot;
</span><span class="cx"> #include &quot;SetSelectionCommand.h&quot;
</span><ins>+#include &quot;StaticRange.h&quot;
</ins><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;markup.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -119,6 +120,12 @@
</span><span class="cx">     return CompositeEditCommand::inputEventData();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;RefPtr&lt;StaticRange&gt;&gt; SpellingCorrectionCommand::targetRanges() const
+{
+    RefPtr&lt;StaticRange&gt; range = StaticRange::createFromRange(*m_rangeToBeCorrected);
+    return { 1, range };
+}
+
</ins><span class="cx"> bool SpellingCorrectionCommand::shouldRetainAutocorrectionIndicator() const
</span><span class="cx"> {
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSpellingCorrectionCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx">     bool shouldRetainAutocorrectionIndicator() const override;
</span><span class="cx"> 
</span><span class="cx">     String inputEventData() const final;
</span><ins>+    Vector&lt;RefPtr&lt;StaticRange&gt;&gt; targetRanges() const final;
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Range&gt; m_rangeToBeCorrected;
</span><span class="cx">     VisibleSelection m_selectionToBeCorrected;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTypingCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TypingCommand.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MathMLElement.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><ins>+#include &quot;StaticRange.h&quot;
</ins><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;VisibleUnits.h&quot;
</span><span class="cx"> #include &quot;htmlediting.h&quot;
</span><span class="lines">@@ -106,6 +107,22 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline bool editActionIsDeleteByTyping(EditAction action)
+{
+    switch (action) {
+    case EditActionTypingDeleteSelection:
+    case EditActionTypingDeleteBackward:
+    case EditActionTypingDeleteWordBackward:
+    case EditActionTypingDeleteLineBackward:
+    case EditActionTypingDeleteForward:
+    case EditActionTypingDeleteWordForward:
+    case EditActionTypingDeleteLineForward:
+        return true;
+    default:
+        return false;
+    }
+}
+
</ins><span class="cx"> TypingCommand::TypingCommand(Document&amp; document, ETypingCommand commandType, const String &amp;textToInsert, Options options, TextGranularity granularity, TextCompositionType compositionType)
</span><span class="cx">     : TextInsertionBaseCommand(document, editActionForTypingCommand(commandType, granularity))
</span><span class="cx">     , m_commandType(commandType)
</span><span class="lines">@@ -267,6 +284,11 @@
</span><span class="cx">     return static_cast&lt;TypingCommand*&gt;(lastEditCommand.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TypingCommand::shouldDeferWillApplyCommandUntilAddingTypingCommand() const
+{
+    return !m_isHandlingInitialTypingCommand || editActionIsDeleteByTyping(editingAction());
+}
+
</ins><span class="cx"> void TypingCommand::closeTyping(Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     if (RefPtr&lt;TypingCommand&gt; lastTypingCommand = lastTypingCommandIfStillOpenForTyping(*frame))
</span><span class="lines">@@ -296,7 +318,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool TypingCommand::willApplyCommand()
</span><span class="cx"> {
</span><del>-    if (!m_isHandlingInitialTypingCommand) {
</del><ins>+    if (shouldDeferWillApplyCommandUntilAddingTypingCommand()) {
</ins><span class="cx">         // The TypingCommand will handle the willApplyCommand logic separately in TypingCommand::willAddTypingToOpenCommand.
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -413,14 +435,19 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity, const String&amp; text)
</del><ins>+bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity, const String&amp; text, RefPtr&lt;Range&gt;&amp;&amp; range)
</ins><span class="cx"> {
</span><del>-    if (m_isHandlingInitialTypingCommand)
</del><ins>+    m_currentTextToInsert = text;
+    m_currentTypingEditAction = editActionForTypingCommand(commandType, granularity);
+
+    if (!shouldDeferWillApplyCommandUntilAddingTypingCommand())
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    m_currentTextToInsert = text;
-    m_currentTypingEditAction = editActionForTypingCommand(commandType, granularity);
-    return frame().editor().willApplyEditing(*this);
</del><ins>+    if (!range || isEditingTextAreaOrTextInput())
+        return frame().editor().willApplyEditing(*this, CompositeEditCommand::targetRangesForBindings());
+
+    RefPtr&lt;StaticRange&gt; staticRange = StaticRange::createFromRange(*range);
+    return frame().editor().willApplyEditing(*this, { 1, staticRange });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping)
</span><span class="lines">@@ -562,9 +589,6 @@
</span><span class="cx"> 
</span><span class="cx"> void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing)
</span><span class="cx"> {
</span><del>-    if (!willAddTypingToOpenCommand(DeleteKey, granularity))
-        return;
-
</del><span class="cx">     Frame&amp; frame = this-&gt;frame();
</span><span class="cx"> 
</span><span class="cx">     frame.editor().updateMarkersForWordsAffectedByEditing(false);
</span><span class="lines">@@ -593,11 +617,15 @@
</span><span class="cx"> 
</span><span class="cx">         if (endingSelection().visibleStart().previous(CannotCrossEditingBoundary).isNull()) {
</span><span class="cx">             // When the caret is at the start of the editable area in an empty list item, break out of the list item.
</span><del>-            if (breakOutOfEmptyListItem()) {
-                typingAddedToOpenCommand(DeleteKey);
</del><ins>+            if (auto deleteListSelection = shouldBreakOutOfEmptyListItem()) {
+                if (willAddTypingToOpenCommand(DeleteKey, granularity, { }, Range::create(document(), deleteListSelection.value().start(), deleteListSelection.value().end()))) {
+                    breakOutOfEmptyListItem();
+                    typingAddedToOpenCommand(DeleteKey);
+                }
</ins><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">             // When there are no visible positions in the editing root, delete its entire contents.
</span><ins>+            // FIXME: Dispatch a `beforeinput` event here and bail if preventDefault() was invoked.
</ins><span class="cx">             if (endingSelection().visibleStart().next(CannotCrossEditingBoundary).isNull() &amp;&amp; makeEditableRootEmpty()) {
</span><span class="cx">                 typingAddedToOpenCommand(DeleteKey);
</span><span class="cx">                 return;
</span><span class="lines">@@ -660,6 +688,9 @@
</span><span class="cx">     if (selectionToDelete.isCaret() || !frame.selection().shouldDeleteSelection(selectionToDelete))
</span><span class="cx">         return;
</span><span class="cx">     
</span><ins>+    if (!willAddTypingToOpenCommand(DeleteKey, granularity, { }, selectionToDelete.firstRange()))
+        return;
+
</ins><span class="cx">     if (shouldAddToKillRing)
</span><span class="cx">         frame.editor().addRangeToKillRing(*selectionToDelete.toNormalizedRange().get(), Editor::KillRingInsertionMode::PrependText);
</span><span class="cx"> 
</span><span class="lines">@@ -678,9 +709,6 @@
</span><span class="cx"> 
</span><span class="cx"> void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing)
</span><span class="cx"> {
</span><del>-    if (!willAddTypingToOpenCommand(ForwardDeleteKey, granularity))
-        return;
-
</del><span class="cx">     Frame&amp; frame = this-&gt;frame();
</span><span class="cx"> 
</span><span class="cx">     frame.editor().updateMarkersForWordsAffectedByEditing(false);
</span><span class="lines">@@ -764,7 +792,10 @@
</span><span class="cx">     
</span><span class="cx">     if (selectionToDelete.isCaret() || !frame.selection().shouldDeleteSelection(selectionToDelete))
</span><span class="cx">         return;
</span><del>-        
</del><ins>+
+    if (!willAddTypingToOpenCommand(ForwardDeleteKey, granularity, { }, selectionToDelete.firstRange()))
+        return;
+
</ins><span class="cx">     // Post the accessibility notification before actually deleting the content while selectionToDelete is still valid
</span><span class="cx">     postTextStateChangeNotificationForDeletion(selectionToDelete);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTypingCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TypingCommand.h (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TypingCommand.h        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebCore/editing/TypingCommand.h        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">     static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*);
</span><span class="cx"> 
</span><span class="cx">     void updatePreservesTypingStyle(ETypingCommand);
</span><del>-    bool willAddTypingToOpenCommand(ETypingCommand, TextGranularity, const String&amp; = emptyString());
</del><ins>+    bool willAddTypingToOpenCommand(ETypingCommand, TextGranularity, const String&amp; = emptyString(), RefPtr&lt;Range&gt;&amp;&amp; = nullptr);
</ins><span class="cx">     void markMisspellingsAfterTyping(ETypingCommand);
</span><span class="cx">     void typingAddedToOpenCommand(ETypingCommand);
</span><span class="cx">     bool makeEditableRootEmpty();
</span><span class="lines">@@ -136,6 +136,8 @@
</span><span class="cx">     bool willApplyCommand() final;
</span><span class="cx">     void didApplyCommand() final;
</span><span class="cx"> 
</span><ins>+    bool shouldDeferWillApplyCommandUntilAddingTypingCommand() const;
+
</ins><span class="cx">     ETypingCommand m_commandType;
</span><span class="cx">     EditAction m_currentTypingEditAction;
</span><span class="cx">     String m_textToInsert;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-21  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Implement InputEvent.getTargetRanges() for the input events spec
+        https://bugs.webkit.org/show_bug.cgi?id=162947
+        &lt;rdar://problem/28853079&gt;
+
+        Reviewed by Darin Adler.
+
+        Boilerplate change to add a runtime guard for InputEvents-related IDL interfaces. See WebCore ChangeLog entry
+        for more details.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
</ins><span class="cx"> 2016-10-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Configures but fails to link with ENABLE_OPENGL=OFF
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (207669 => 207670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-21 13:36:45 UTC (rev 207669)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-21 15:51:28 UTC (rev 207670)
</span><span class="lines">@@ -3224,6 +3224,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     settings.setInputEventsEnabled(store.getBoolValueForKey(WebPreferencesKey::inputEventsEnabledKey()));
</span><ins>+    RuntimeEnabledFeatures::sharedFeatures().setInputEventsEnabled(store.getBoolValueForKey(WebPreferencesKey::inputEventsEnabledKey()));
</ins><span class="cx"> 
</span><span class="cx">     RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled(store.getBoolValueForKey(WebPreferencesKey::modernMediaControlsEnabledKey()));
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>