<!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>[165356] trunk/Source</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/165356">165356</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2014-03-09 15:56:08 -0700 (Sun, 09 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] Don't perform a round-trip through WebProcess before interpreting key events
https://bugs.webkit.org/show_bug.cgi?id=129812

Reviewed by Darin Adler.

Source/WebCore: 

No significant behavior changes expected, except for Esc key processing, which now
dispatches a keypress before executing its default action.

* platform/KeypressCommand.h: Added.
(WebCore::KeypressCommand::KeypressCommand):
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Moved KeypressCommand from dom/KeyboardEvent.h to its own header, as it needed
in platform/ directory now.

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/KeyboardEvent.h:
(WebCore::KeyboardEvent::handledByInputMethod):
(WebCore::KeyboardEvent::keypressCommands):
* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
(WebCore::PlatformKeyboardEvent::handledByInputMethod):
(WebCore::PlatformKeyboardEvent::commands):
PlatformKeyboardEvent now carries results of interpreting the event by AppKit. This
is logically not much different from carrying charcode, and is similar to what Gtk
does for input methods.
KeyboardEvent already had keypress commands, which were added to it after construction.
It's still possible for WebKit1, while with WebKit2, they are provided at construction
time. The event now also has a boolean for whether IM handled it already.

Source/WebKit/mac: 

* WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleInputMethodKeydown):
Added a FIXME. WebKit1/mac is the only port that uses this roundabout way to
interpret events, so it would simplify code if we switched it to WebKit2/mac model.

Source/WebKit2: 

* Shared/NativeWebKeyboardEvent.h:
* Shared/WebEvent.h:
(WebKit::WebKeyboardEvent::handledByInputMethod):
(WebKit::WebKeyboardEvent::commands):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent):
(WebKit::WebKeyboardEvent::~WebKeyboardEvent):
(WebKit::WebKeyboardEvent::encode):
(WebKit::WebKeyboardEvent::decode):
* Shared/mac/NativeWebKeyboardEventMac.mm:
(WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
* Shared/mac/WebEventFactory.h:
* Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebKeyboardEvent):
Keyboard events now carry results of interpretation with them.
Ideally, mouse events should also have a handledByInputMethod member, because IMs
can handle events, but that can wait until we have actual bugs caused by not diabling
default processing for these.

* UIProcess/API/mac/WKView.mm:
(-[WKView becomeFirstResponder]): Updated for new NativeWebKeyboardEvent contructor
signature. We don't interpret the event in this code path.
(-[WKView doCommandBySelector:]): Added logging.
(-[WKView performKeyEquivalent:]): Reimplemented Esc and Cmd+period handling to avoid
infinite loops and re-entrancy. These two work in a unique way in AppKit.
Interpret key event before sending it down to WebProcess.
(-[WKView keyUp:]): Interpret key event before sending it down to WebProcess.
We need to tell IMs about the event, but key binding processing is moot, all commands
are executed on keydown.
(-[WKView keyDown:]): Interpret the event.
(-[WKView flagsChanged:]): Ditto.
(-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]): Added an assertion in
consumedByIM code path.
(-[WKView _executeSavedCommandBySelector:]): Added logging.

* UIProcess/PageClient.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
* UIProcess/mac/WebPageProxyMac.mm:
Removed interpretQueuedKeyEvent/interpretKeyEvent, WebProcess no longer asks UIProcess to do this.

* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::handleKeyboardEvent):
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
WebPage::handleEditingKeyboardEvent is now one function instead of two with a boolean
switch between two behaviors.

* WebProcess/WebPage/WebPage.cpp:(WebKit::WebPage::WebPage):
* WebProcess/WebPage/WebPage.h:
Removed m_keyboardEventBeingInterpreted, as we no longer send the event for interpretation.
This means that we sometimes have to pass a null event down to WebCore, but I wasn't
able to find any behavior differences from us doing so.

* WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::handleEditingKeyboardEvent):
Added a FIXME.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::executeKeypressCommandsInternal): When we don't have an event,
use current frame as a target, just like input method messages do.
(WebKit::WebPage::handleEditingKeyboardEvent): This function no longer saves commands,
it only interprets them.
Added a check for Esc, as we don't want to handle it in keydown event handler.
(WebKit::WebPage::insertText): Pass 0 instead of m_keyboardEventBeingInterpreted.
(WebKit::WebPage::insertDictatedText): Ditto.
(WebKit::WebPage::executeKeypressCommands): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomKeyboardEventcpp">trunk/Source/WebCore/dom/KeyboardEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoredomKeyboardEventh">trunk/Source/WebCore/dom/KeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebCoreplatformPlatformKeyboardEventh">trunk/Source/WebCore/platform/PlatformKeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedNativeWebKeyboardEventh">trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebEventh">trunk/Source/WebKit2/Shared/WebEvent.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebEventConversioncpp">trunk/Source/WebKit2/Shared/WebEventConversion.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebKeyboardEventcpp">trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedmacNativeWebKeyboardEventMacmm">trunk/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedmacWebEventFactoryh">trunk/Source/WebKit2/Shared/mac/WebEventFactory.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacWebEventFactorymm">trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWebPageProxyMacmm">trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportiosWebEditorClientIOSmm">trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportmacWebEditorClientMacmm">trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformKeypressCommandh">trunk/Source/WebCore/platform/KeypressCommand.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/ChangeLog        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-03-06  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        [Mac] Don't perform a round-trip through WebProcess before interpreting key events
+        https://bugs.webkit.org/show_bug.cgi?id=129812
+
+        Reviewed by Darin Adler.
+
+        No significant behavior changes expected, except for Esc key processing, which now
+        dispatches a keypress before executing its default action.
+
+        * platform/KeypressCommand.h: Added.
+        (WebCore::KeypressCommand::KeypressCommand):
+        * GNUmakefile.list.am:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        Moved KeypressCommand from dom/KeyboardEvent.h to its own header, as it needed
+        in platform/ directory now.
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * dom/KeyboardEvent.h:
+        (WebCore::KeyboardEvent::handledByInputMethod):
+        (WebCore::KeyboardEvent::keypressCommands):
+        * platform/PlatformKeyboardEvent.h:
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+        (WebCore::PlatformKeyboardEvent::handledByInputMethod):
+        (WebCore::PlatformKeyboardEvent::commands):
+        PlatformKeyboardEvent now carries results of interpreting the event by AppKit. This
+        is logically not much different from carrying charcode, and is similar to what Gtk
+        does for input methods.
+        KeyboardEvent already had keypress commands, which were added to it after construction.
+        It's still possible for WebKit1, while with WebKit2, they are provided at construction
+        time. The event now also has a boolean for whether IM handled it already.
+
</ins><span class="cx"> 2014-03-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Subpixel rendering: Pass FloatSize boxsize to transform animations to support device pixel sizing.
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -6007,6 +6007,7 @@
</span><span class="cx">         Source/WebCore/platform/URL.h \
</span><span class="cx">         Source/WebCore/platform/URLHash.h \
</span><span class="cx">         Source/WebCore/platform/KeyedCoding.h \
</span><ins>+        Source/WebCore/platform/KeypressCommand.h \
</ins><span class="cx">         Source/WebCore/platform/KillRing.h \
</span><span class="cx">         Source/WebCore/platform/KillRingNone.cpp \
</span><span class="cx">         Source/WebCore/platform/Language.cpp \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -18947,6 +18947,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\win\SharedGDIObject.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\HistogramSupport.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\HostWindow.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\KeypressCommand.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\KillRing.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\URL.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\URLHash.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -7964,6 +7964,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\URLHash.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\KeypressCommand.h&quot;&gt;
+      &lt;Filter&gt;platform&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\Language.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -5786,6 +5786,7 @@
</span><span class="cx">                 E157A8F118185425009F821D /* JSCryptoAlgorithmBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = E157A8EF18185425009F821D /* JSCryptoAlgorithmBuilder.h */; };
</span><span class="cx">                 E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; };
</span><span class="cx">                 E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15A36D81104572700B7B639 /* XMLNSNames.cpp */; };
</span><ins>+                E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = E15FF7D418C9553800FE4C87 /* KeypressCommand.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E164FAA318315BF400DB4E61 /* CryptoKeyRSA.h in Headers */ = {isa = PBXBuildFile; fileRef = E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */; };
</span><span class="cx">                 E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */; };
</span><span class="cx">                 E169803D1133542D00894115 /* CRuntimeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E169803C1133542D00894115 /* CRuntimeObject.h */; };
</span><span class="lines">@@ -13101,6 +13102,7 @@
</span><span class="cx">                 E157A8EF18185425009F821D /* JSCryptoAlgorithmBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmBuilder.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E15A36D81104572700B7B639 /* XMLNSNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLNSNames.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E15FF7D418C9553800FE4C87 /* KeypressCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeypressCommand.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoKeyRSA.h; path = keys/CryptoKeyRSA.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyRSAMac.cpp; path = mac/CryptoKeyRSAMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E169803C1133542D00894115 /* CRuntimeObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CRuntimeObject.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20798,6 +20800,7 @@
</span><span class="cx">                                 D630E2AB149BF344005B2F93 /* HistogramSupport.h */,
</span><span class="cx">                                 BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
</span><span class="cx">                                 862F129F18C1DCE4005C54AF /* HysteresisActivity.h */,
</span><ins>+                                E15FF7D418C9553800FE4C87 /* KeypressCommand.h */,
</ins><span class="cx">                                 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */,
</span><span class="cx">                                 521D46F711AEC9B100514613 /* KillRing.h */,
</span><span class="cx">                                 4306E4E514955543007F17AC /* KillRingNone.cpp */,
</span><span class="lines">@@ -23228,6 +23231,7 @@
</span><span class="cx">                                 85E711930AC5D5350053270F /* DOMCSSStyleDeclarationInternal.h in Headers */,
</span><span class="cx">                                 85032DE70AA8C9BE007D3B7D /* DOMCSSStyleRule.h in Headers */,
</span><span class="cx">                                 85909CE20ACC7A7E00DF01F1 /* DOMCSSStyleRuleInternal.h in Headers */,
</span><ins>+                                E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */,
</ins><span class="cx">                                 858C39280AA8FF9D00B187A4 /* DOMCSSStyleSheet.h in Headers */,
</span><span class="cx">                                 85909CE30ACC7A7E00DF01F1 /* DOMCSSStyleSheetInternal.h in Headers */,
</span><span class="cx">                                 FCD8832A16A49F8200962227 /* DOMCSSSupportsRule.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomKeyboardEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/KeyboardEvent.cpp        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -102,6 +102,9 @@
</span><span class="cx"> KeyboardEvent::KeyboardEvent()
</span><span class="cx">     : m_location(DOM_KEY_LOCATION_STANDARD)
</span><span class="cx">     , m_altGraphKey(false)
</span><ins>+#if PLATFORM(COCOA)
+    , m_handledByInputMethod(false)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -112,6 +115,10 @@
</span><span class="cx">     , m_keyIdentifier(key.keyIdentifier())
</span><span class="cx">     , m_location(keyLocationCode(key))
</span><span class="cx">     , m_altGraphKey(false)
</span><ins>+#if PLATFORM(COCOA)
+    , m_handledByInputMethod(key.handledByInputMethod())
+    , m_keypressCommands(key.commands())
+#endif
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -120,6 +127,9 @@
</span><span class="cx">     , m_keyIdentifier(initializer.keyIdentifier)
</span><span class="cx">     , m_location(initializer.location)
</span><span class="cx">     , m_altGraphKey(false)
</span><ins>+#if PLATFORM(COCOA)
+    , m_handledByInputMethod(false)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/KeyboardEvent.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #ifndef KeyboardEvent_h
</span><span class="cx"> #define KeyboardEvent_h
</span><span class="cx"> 
</span><ins>+#include &quot;KeypressCommand.h&quot;
</ins><span class="cx"> #include &quot;UIEventWithKeyState.h&quot;
</span><span class="cx"> #include &lt;memory&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -33,17 +34,6 @@
</span><span class="cx"> class Node;
</span><span class="cx"> class PlatformKeyboardEvent;
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
-struct KeypressCommand {
-    KeypressCommand() { }
-    explicit KeypressCommand(const String&amp; commandName) : commandName(commandName) { ASSERT(isASCIILower(commandName[0U])); }
-    KeypressCommand(const String&amp; commandName, const String&amp; text) : commandName(commandName), text(text) { ASSERT(commandName == &quot;insertText:&quot;); }
-
-    String commandName; // Actually, a selector name - it may have a trailing colon, and a name that can be different from an editor command name.
-    String text;
-};
-#endif
-
</del><span class="cx"> struct KeyboardEventInit : public UIEventInit {
</span><span class="cx">     KeyboardEventInit();
</span><span class="cx"> 
</span><span class="lines">@@ -105,7 +95,10 @@
</span><span class="cx">     virtual int which() const override;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    // We only have this need to store keypress command info on the Mac.
</del><ins>+    bool handledByInputMethod() const { return m_handledByInputMethod; }
+    const Vector&lt;KeypressCommand&gt;&amp; keypressCommands() const { return m_keypressCommands; }
+
+    // The non-const version is still needed for WebKit1, which doesn't construct a complete KeyboardEvent with interpreted commands yet.
</ins><span class="cx">     Vector&lt;KeypressCommand&gt;&amp; keypressCommands() { return m_keypressCommands; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -121,6 +114,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     // Commands that were sent by AppKit when interpreting the event. Doesn't include input method commands.
</span><ins>+    bool m_handledByInputMethod;
</ins><span class="cx">     Vector&lt;KeypressCommand&gt; m_keypressCommands;
</span><span class="cx"> #endif
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformKeypressCommandh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/KeypressCommand.h (0 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/KeypressCommand.h                                (rev 0)
+++ trunk/Source/WebCore/platform/KeypressCommand.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef KeypressCommand_h
+#define KeypressCommand_h
+
+#include &lt;wtf/Assertions.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+#if PLATFORM(COCOA)
+
+namespace WebCore {
+
+struct KeypressCommand {
+    KeypressCommand() { }
+    explicit KeypressCommand(const String&amp; commandName) : commandName(commandName) { ASSERT(isASCIILower(commandName[0U])); }
+    KeypressCommand(const String&amp; commandName, const String&amp; text) : commandName(commandName), text(text) { ASSERT(commandName == &quot;insertText:&quot;); }
+
+    String commandName; // Actually, a selector name - it may have a trailing colon, and a name that can be different from an editor command name.
+    String text;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // KeypressCommand_h
</ins><span class="cx">Property changes on: trunk/Source/WebCore/platform/KeypressCommand.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCoreplatformPlatformKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #ifndef PlatformKeyboardEvent_h
</span><span class="cx"> #define PlatformKeyboardEvent_h
</span><span class="cx"> 
</span><ins>+#include &quot;KeypressCommand.h&quot;
</ins><span class="cx"> #include &quot;PlatformEvent.h&quot;
</span><span class="cx"> #include &lt;wtf/WindowsExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -60,6 +61,9 @@
</span><span class="cx">             , m_windowsVirtualKeyCode(0)
</span><span class="cx">             , m_nativeVirtualKeyCode(0)
</span><span class="cx">             , m_macCharCode(0)
</span><ins>+#if USE(APPKIT)
+            , m_handledByInputMethod(false)
+#endif
</ins><span class="cx">             , m_autoRepeat(false)
</span><span class="cx">             , m_isKeypad(false)
</span><span class="cx">             , m_isSystemKey(false)
</span><span class="lines">@@ -77,6 +81,9 @@
</span><span class="cx">             , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
</span><span class="cx">             , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
</span><span class="cx">             , m_macCharCode(macCharCode)
</span><ins>+#if USE(APPKIT)
+            , m_handledByInputMethod(false)
+#endif
</ins><span class="cx">             , m_autoRepeat(isAutoRepeat)
</span><span class="cx">             , m_isKeypad(isKeypad)
</span><span class="cx">             , m_isSystemKey(isSystemKey)
</span><span class="lines">@@ -108,6 +115,11 @@
</span><span class="cx">         int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
</span><span class="cx">         int macCharCode() const { return m_macCharCode; }
</span><span class="cx"> 
</span><ins>+#if USE(APPKIT)
+        bool handledByInputMethod() const { return m_handledByInputMethod; }
+        const Vector&lt;KeypressCommand&gt;&amp; commands() const { return m_commands; }
+#endif
+
</ins><span class="cx">         bool isAutoRepeat() const { return m_autoRepeat; }
</span><span class="cx">         bool isKeypad() const { return m_isKeypad; }
</span><span class="cx">         bool isSystemKey() const { return m_isSystemKey; }
</span><span class="lines">@@ -150,6 +162,10 @@
</span><span class="cx">         int m_windowsVirtualKeyCode;
</span><span class="cx">         int m_nativeVirtualKeyCode;
</span><span class="cx">         int m_macCharCode;
</span><ins>+#if USE(APPKIT)
+        bool m_handledByInputMethod;
+        Vector&lt;KeypressCommand&gt; m_commands;
+#endif
</ins><span class="cx">         bool m_autoRepeat;
</span><span class="cx">         bool m_isKeypad;
</span><span class="cx">         bool m_isSystemKey;
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-03-06  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        [Mac] Don't perform a round-trip through WebProcess before interpreting key events
+        https://bugs.webkit.org/show_bug.cgi?id=129812
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleInputMethodKeydown):
+        Added a FIXME. WebKit1/mac is the only port that uses this roundabout way to
+        interpret events, so it would simplify code if we switched it to WebKit2/mac model.
+
</ins><span class="cx"> 2014-03-08  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS Wk2] Can't scroll after going back to page in page cache
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -693,6 +693,7 @@
</span><span class="cx"> void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
</span><span class="cx"> {
</span><span class="cx"> #if !PLATFORM(IOS)
</span><ins>+    // FIXME: Switch to WebKit2 model, interpreting the event before it's sent down to WebCore.
</ins><span class="cx">     Frame* frame = event-&gt;target()-&gt;toNode()-&gt;document().frame();
</span><span class="cx">     WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
</span><span class="cx">     if ([webHTMLView _interpretKeyEvent:event savingCommands:YES])
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -1,3 +1,85 @@
</span><ins>+2014-03-06  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        [Mac] Don't perform a round-trip through WebProcess before interpreting key events
+        https://bugs.webkit.org/show_bug.cgi?id=129812
+
+        Reviewed by Darin Adler.
+
+        * Shared/NativeWebKeyboardEvent.h:
+        * Shared/WebEvent.h:
+        (WebKit::WebKeyboardEvent::handledByInputMethod):
+        (WebKit::WebKeyboardEvent::commands):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+        (WebKit::WebKeyboardEvent::~WebKeyboardEvent):
+        (WebKit::WebKeyboardEvent::encode):
+        (WebKit::WebKeyboardEvent::decode):
+        * Shared/mac/NativeWebKeyboardEventMac.mm:
+        (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
+        * Shared/mac/WebEventFactory.h:
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::WebEventFactory::createWebKeyboardEvent):
+        Keyboard events now carry results of interpretation with them.
+        Ideally, mouse events should also have a handledByInputMethod member, because IMs
+        can handle events, but that can wait until we have actual bugs caused by not diabling
+        default processing for these.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView becomeFirstResponder]): Updated for new NativeWebKeyboardEvent contructor
+        signature. We don't interpret the event in this code path.
+        (-[WKView doCommandBySelector:]): Added logging.
+        (-[WKView performKeyEquivalent:]): Reimplemented Esc and Cmd+period handling to avoid
+        infinite loops and re-entrancy. These two work in a unique way in AppKit.
+        Interpret key event before sending it down to WebProcess.
+        (-[WKView keyUp:]): Interpret key event before sending it down to WebProcess.
+        We need to tell IMs about the event, but key binding processing is moot, all commands
+        are executed on keydown.
+        (-[WKView keyDown:]): Interpret the event.
+        (-[WKView flagsChanged:]): Ditto.
+        (-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]): Added an assertion in
+        consumedByIM code path.
+        (-[WKView _executeSavedCommandBySelector:]): Added logging.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        Removed interpretQueuedKeyEvent/interpretKeyEvent, WebProcess no longer asks UIProcess to do this.
+
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        WebPage::handleEditingKeyboardEvent is now one function instead of two with a boolean
+        switch between two behaviors.
+
+        * WebProcess/WebPage/WebPage.cpp:(WebKit::WebPage::WebPage):
+        * WebProcess/WebPage/WebPage.h:
+        Removed m_keyboardEventBeingInterpreted, as we no longer send the event for interpretation.
+        This means that we sometimes have to pass a null event down to WebCore, but I wasn't
+        able to find any behavior differences from us doing so.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::handleEditingKeyboardEvent):
+        Added a FIXME.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::executeKeypressCommandsInternal): When we don't have an event,
+        use current frame as a target, just like input method messages do.
+        (WebKit::WebPage::handleEditingKeyboardEvent): This function no longer saves commands,
+        it only interprets them.
+        Added a check for Esc, as we don't want to handle it in keydown event handler.
+        (WebKit::WebPage::insertText): Pass 0 instead of m_keyboardEventBeingInterpreted.
+        (WebKit::WebPage::insertDictatedText): Ditto.
+        (WebKit::WebPage::executeKeypressCommands): Ditto.
+
</ins><span class="cx"> 2014-03-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Subpixel rendering: Pass FloatSize boxsize to transform animations to support device pixel sizing.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNativeWebKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -33,6 +33,10 @@
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> OBJC_CLASS NSView;
</span><ins>+
+namespace WebCore {
+struct KeypressCommand;
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="lines">@@ -56,7 +60,7 @@
</span><span class="cx"> class NativeWebKeyboardEvent : public WebKeyboardEvent {
</span><span class="cx"> public:
</span><span class="cx"> #if USE(APPKIT)
</span><del>-    NativeWebKeyboardEvent(NSEvent *, NSView *);
</del><ins>+    NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp;);
</ins><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx">     NativeWebKeyboardEvent(const NativeWebKeyboardEvent&amp;);
</span><span class="cx">     NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&amp;, WebCore::GtkInputMethodFilter::EventFakedForComposition);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEvent.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebEvent.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/WebEvent.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -41,6 +41,12 @@
</span><span class="cx">     class ArgumentEncoder;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(APPKIT)
+namespace WebCore {
+struct KeypressCommand;
+}
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebEvent {
</span><span class="lines">@@ -207,9 +213,14 @@
</span><span class="cx"> // FIXME: Move this class to its own header file.
</span><span class="cx"> class WebKeyboardEvent : public WebEvent {
</span><span class="cx"> public:
</span><del>-    WebKeyboardEvent() { }
</del><ins>+    WebKeyboardEvent();
+    ~WebKeyboardEvent();
</ins><span class="cx"> 
</span><ins>+#if USE(APPKIT)
+    WebKeyboardEvent(Type, const String&amp; text, const String&amp; unmodifiedText, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp;, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+#else
</ins><span class="cx">     WebKeyboardEvent(Type, const String&amp; text, const String&amp; unmodifiedText, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     const String&amp; text() const { return m_text; }
</span><span class="cx">     const String&amp; unmodifiedText() const { return m_unmodifiedText; }
</span><span class="lines">@@ -217,6 +228,10 @@
</span><span class="cx">     int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
</span><span class="cx">     int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
</span><span class="cx">     int32_t macCharCode() const { return m_macCharCode; }
</span><ins>+#if USE(APPKIT)
+    bool handledByInputMethod() const { return m_handledByInputMethod; }
+    const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands() const { return m_commands; }
+#endif
</ins><span class="cx">     bool isAutoRepeat() const { return m_isAutoRepeat; }
</span><span class="cx">     bool isKeypad() const { return m_isKeypad; }
</span><span class="cx">     bool isSystemKey() const { return m_isSystemKey; }
</span><span class="lines">@@ -233,6 +248,10 @@
</span><span class="cx">     int32_t m_windowsVirtualKeyCode;
</span><span class="cx">     int32_t m_nativeVirtualKeyCode;
</span><span class="cx">     int32_t m_macCharCode;
</span><ins>+#if USE(APPKIT)
+    bool m_handledByInputMethod;
+    Vector&lt;WebCore::KeypressCommand&gt; m_commands;
+#endif
</ins><span class="cx">     bool m_isAutoRepeat;
</span><span class="cx">     bool m_isKeypad;
</span><span class="cx">     bool m_isSystemKey;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -185,6 +185,10 @@
</span><span class="cx">         m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
</span><span class="cx">         m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode();
</span><span class="cx">         m_macCharCode = webEvent.macCharCode();
</span><ins>+#if USE(APPKIT)
+        m_handledByInputMethod = webEvent.handledByInputMethod();
+        m_commands = webEvent.commands();
+#endif
</ins><span class="cx">         m_autoRepeat = webEvent.isAutoRepeat();
</span><span class="cx">         m_isKeypad = webEvent.isKeypad();
</span><span class="cx">         m_isSystemKey = webEvent.isSystemKey();
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebKeyboardEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -27,9 +27,35 @@
</span><span class="cx"> #include &quot;WebEvent.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WebCoreArgumentCoders.h&quot;
</span><ins>+#include &lt;WebCore/KeypressCommand.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+WebKeyboardEvent::WebKeyboardEvent()
+{
+}
+
+#if USE(APPKIT)
+
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String&amp; text, const String&amp; unmodifiedText, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+    : WebEvent(type, modifiers, timestamp)
+    , m_text(text)
+    , m_unmodifiedText(unmodifiedText)
+    , m_keyIdentifier(keyIdentifier)
+    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+    , m_macCharCode(macCharCode)
+    , m_handledByInputMethod(handledByInputMethod)
+    , m_commands(commands)
+    , m_isAutoRepeat(isAutoRepeat)
+    , m_isKeypad(isKeypad)
+    , m_isSystemKey(isSystemKey)
+{
+    ASSERT(isKeyboardEventType(type));
+}
+
+#else
+
</ins><span class="cx"> WebKeyboardEvent::WebKeyboardEvent(Type type, const String&amp; text, const String&amp; unmodifiedText, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
</span><span class="cx">     : WebEvent(type, modifiers, timestamp)
</span><span class="cx">     , m_text(text)
</span><span class="lines">@@ -45,6 +71,12 @@
</span><span class="cx">     ASSERT(isKeyboardEventType(type));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#endif
+
+WebKeyboardEvent::~WebKeyboardEvent()
+{
+}
+
</ins><span class="cx"> void WebKeyboardEvent::encode(IPC::ArgumentEncoder&amp; encoder) const
</span><span class="cx"> {
</span><span class="cx">     WebEvent::encode(encoder);
</span><span class="lines">@@ -55,6 +87,10 @@
</span><span class="cx">     encoder &lt;&lt; m_windowsVirtualKeyCode;
</span><span class="cx">     encoder &lt;&lt; m_nativeVirtualKeyCode;
</span><span class="cx">     encoder &lt;&lt; m_macCharCode;
</span><ins>+#if USE(APPKIT)
+    encoder &lt;&lt; m_handledByInputMethod;
+    encoder &lt;&lt; m_commands;
+#endif
</ins><span class="cx">     encoder &lt;&lt; m_isAutoRepeat;
</span><span class="cx">     encoder &lt;&lt; m_isKeypad;
</span><span class="cx">     encoder &lt;&lt; m_isSystemKey;
</span><span class="lines">@@ -77,6 +113,12 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.m_macCharCode))
</span><span class="cx">         return false;
</span><ins>+#if USE(APPKIT)
+    if (!decoder.decode(result.m_handledByInputMethod))
+        return false;
+    if (!decoder.decode(result.m_commands))
+        return false;
+#endif
</ins><span class="cx">     if (!decoder.decode(result.m_isAutoRepeat))
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.m_isKeypad))
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacNativeWebKeyboardEventMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -29,11 +29,14 @@
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WebEventFactory.h&quot;
</span><ins>+#import &lt;WebCore/KeyboardEvent.h&gt;
</ins><span class="cx"> 
</span><ins>+using namespace WebCore;
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-NativeWebKeyboardEvent::NativeWebKeyboardEvent(NSEvent *event, NSView *view)
-    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, view))
</del><ins>+NativeWebKeyboardEvent::NativeWebKeyboardEvent(NSEvent *event, bool handledByInputMethod, const Vector&lt;KeypressCommand&gt;&amp; commands)
+    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, handledByInputMethod, commands))
</ins><span class="cx">     , m_nativeEvent(event)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacWebEventFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/WebEventFactory.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx"> class WebEventFactory {
</span><span class="cx"> public:
</span><span class="cx"> #if USE(APPKIT)
</span><del>-    static WebMouseEvent createWebMouseEvent(NSEvent *event, NSView *windowView);
-    static WebWheelEvent createWebWheelEvent(NSEvent *event, NSView *windowView);
-    static WebKeyboardEvent createWebKeyboardEvent(NSEvent *event, NSView *windowView);
</del><ins>+    static WebMouseEvent createWebMouseEvent(NSEvent *, NSView *windowView);
+    static WebWheelEvent createWebWheelEvent(NSEvent *, NSView *windowView);
+    static WebKeyboardEvent createWebKeyboardEvent(NSEvent *, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp;);
</ins><span class="cx"> #endif // USE(APPKIT)
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacWebEventFactorymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WebKitSystemInterface.h&quot;
</span><ins>+#import &lt;WebCore/KeyboardEvent.h&gt;
</ins><span class="cx"> #import &lt;WebCore/PlatformEventFactoryMac.h&gt;
</span><span class="cx"> #import &lt;WebCore/Scrollbar.h&gt;
</span><span class="cx"> #import &lt;WebCore/WindowsKeyboardCodes.h&gt;
</span><span class="lines">@@ -405,7 +406,7 @@
</span><span class="cx">     return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas, scrollCount, unacceleratedScrollingDelta, modifiers, timestamp);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView *)
</del><ins>+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands)
</ins><span class="cx"> {
</span><span class="cx">     WebEvent::Type type             = isKeyUpEvent(event) ? WebEvent::KeyUp : WebEvent::KeyDown;
</span><span class="cx">     String text                     = textFromEvent(event);
</span><span class="lines">@@ -438,7 +439,7 @@
</span><span class="cx">         unmodifiedText = &quot;\x9&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
</del><ins>+    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -345,7 +345,7 @@
</span><span class="cx">         NSEvent *keyboardEvent = nil;
</span><span class="cx">         if ([event type] == NSKeyDown || [event type] == NSKeyUp)
</span><span class="cx">             keyboardEvent = event;
</span><del>-        _data-&gt;_page-&gt;setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, self));
</del><ins>+        _data-&gt;_page-&gt;setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, false, Vector&lt;KeypressCommand&gt;()));
</ins><span class="cx">     }
</span><span class="cx">     return YES;
</span><span class="cx"> }
</span><span class="lines">@@ -1225,6 +1225,7 @@
</span><span class="cx">     if (parameters &amp;&amp; !isFromInputMethod) {
</span><span class="cx">         KeypressCommand command(NSStringFromSelector(selector));
</span><span class="cx">         parameters-&gt;commands-&gt;append(command);
</span><ins>+        LOG(TextInput, &quot;...stored&quot;);
</ins><span class="cx">         _data-&gt;_page-&gt;registerKeypressCommandName(command.commandName);
</span><span class="cx">     } else {
</span><span class="cx">         // FIXME: Send the command to Editor synchronously and only send it along the
</span><span class="lines">@@ -1301,18 +1302,29 @@
</span><span class="cx">     // fetching a new event might release the old one. Retaining and then autoreleasing
</span><span class="cx">     // the current event prevents that from causing a problem inside WebKit or AppKit code.
</span><span class="cx">     [[event retain] autorelease];
</span><del>-    
</del><ins>+
+    // We get Esc key here after processing either Esc or Cmd+period. The former starts as a keyDown, and the latter starts as a key equivalent,
+    // but both get transformed to a cancelOperation: command, executing which passes an Esc key event to -performKeyEquivalent:.
+    // Don't interpret this event again, avoiding re-entrancy and infinite loops.
+    if ([[event charactersIgnoringModifiers] isEqualToString:@&quot;\e&quot;] &amp;&amp; !([event modifierFlags] &amp; NSDeviceIndependentModifierFlagsMask))
+        return [super performKeyEquivalent:event];
+
+    // If we are already re-sending the event, then WebCore has already seen it, no need for custom processing.
</ins><span class="cx">     BOOL eventWasSentToWebCore = (_data-&gt;_keyDownEventBeingResent == event);
</span><ins>+    if (eventWasSentToWebCore)
+        return [super performKeyEquivalent:event];
</ins><span class="cx"> 
</span><del>-    if (!eventWasSentToWebCore)
-        [self _disableComplexTextInputIfNecessary];
</del><ins>+    ASSERT(event == [NSApp currentEvent]);
</ins><span class="cx"> 
</span><ins>+    [self _disableComplexTextInputIfNecessary];
+
</ins><span class="cx">     // Pass key combos through WebCore if there is a key binding available for
</span><span class="cx">     // this event. This lets web pages have a crack at intercepting key-modified keypresses.
</span><del>-    // But don't do it if we have already handled the event.
-    // Pressing Esc results in a fake event being sent - don't pass it to WebCore.
-    if (!eventWasSentToWebCore &amp;&amp; event == [NSApp currentEvent] &amp;&amp; self == [[self window] firstResponder]) {
-        _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(event, self));
</del><ins>+    // FIXME: Why is the firstResponder check needed?
+    if (self == [[self window] firstResponder]) {
+        Vector&lt;KeypressCommand&gt; commands;
+        BOOL handledByInputMethod = [self _interpretKeyEvent:event savingCommandsTo:commands];
+        _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(event, handledByInputMethod, commands));
</ins><span class="cx">         return YES;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -1322,7 +1334,11 @@
</span><span class="cx"> - (void)keyUp:(NSEvent *)theEvent
</span><span class="cx"> {
</span><span class="cx">     LOG(TextInput, &quot;keyUp:%p %@&quot;, theEvent, theEvent);
</span><del>-    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
</del><ins>+
+    Vector&lt;KeypressCommand&gt; commands;
+    BOOL handledByInputMethod = [self _interpretKeyEvent:theEvent savingCommandsTo:commands];
+
+    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, handledByInputMethod, commands));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_disableComplexTextInputIfNecessary
</span><span class="lines">@@ -1396,7 +1412,17 @@
</span><span class="cx">         [super keyDown:theEvent];
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
</del><ins>+
+    Vector&lt;KeypressCommand&gt; commands;
+    BOOL handledByInputMethod = [self _interpretKeyEvent:theEvent savingCommandsTo:commands];
+    if (!commands.isEmpty()) {
+        // An input method may make several actions per keypress. For example, pressing Return with Korean IM both confirms it and sends a newline.
+        // IM-like actions are handled immediately (so the return value from UI process is true), but there are saved commands that
+        // should be handled like normal text input after DOM event dispatch.
+        handledByInputMethod = NO;
+    }
+
+    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, handledByInputMethod, commands));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)flagsChanged:(NSEvent *)theEvent
</span><span class="lines">@@ -1414,7 +1440,10 @@
</span><span class="cx">     if (!keyCode || keyCode == 10 || keyCode == 63)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
</del><ins>+    Vector&lt;KeypressCommand&gt; commands;
+    BOOL handledByInputMethod = [self _interpretKeyEvent:theEvent savingCommandsTo:commands];
+
+    _data-&gt;_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, handledByInputMethod, commands));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_executeSavedKeypressCommands
</span><span class="lines">@@ -2310,11 +2339,12 @@
</span><span class="cx">     LOG(TextInput, &quot;-&gt; interpretKeyEvents:%p %@&quot;, event, event);
</span><span class="cx">     [self interpretKeyEvents:[NSArray arrayWithObject:event]];
</span><span class="cx"> 
</span><del>-    _data-&gt;_interpretKeyEventsParameters = 0;
</del><ins>+    _data-&gt;_interpretKeyEventsParameters = nullptr;
</ins><span class="cx"> 
</span><span class="cx">     // An input method may consume an event and not tell us (e.g. when displaying a candidate window),
</span><span class="cx">     // in which case we should not bubble the event up the DOM.
</span><span class="cx">     if (parameters.consumedByIM) {
</span><ins>+        ASSERT(commands.isEmpty());
</ins><span class="cx">         LOG(TextInput, &quot;...event %p was consumed by an input method&quot;, event);
</span><span class="cx">         return YES;
</span><span class="cx">     }
</span><span class="lines">@@ -2823,6 +2853,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (bool)_executeSavedCommandBySelector:(SEL)selector
</span><span class="cx"> {
</span><ins>+    LOG(TextInput, &quot;Executing previously saved command %s&quot;, sel_getName(selector));
</ins><span class="cx">     // The sink does two things: 1) Tells us if the responder went unhandled, and
</span><span class="cx">     // 2) prevents any NSBeep; we don't ever want to beep here.
</span><span class="cx">     RetainPtr&lt;WKResponderChainSink&gt; sink = adoptNS([[WKResponderChainSink alloc] initWithResponderChain:self]);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -168,7 +168,6 @@
</span><span class="cx">     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) = 0;
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&amp;) = 0;
</span><del>-    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&amp;, Vector&lt;WebCore::KeypressCommand&gt;&amp;) = 0;
</del><span class="cx">     virtual bool executeSavedCommandBySelector(const String&amp; selector) = 0;
</span><span class="cx">     virtual void setDragImage(const WebCore::IntPoint&amp; clientPosition, PassRefPtr&lt;ShareableBitmap&gt; dragImage, bool isLinkDrag) = 0;
</span><span class="cx">     virtual void updateSecureInputState() = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -1070,7 +1070,6 @@
</span><span class="cx"> 
</span><span class="cx">     // Keyboard handling
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    void interpretQueuedKeyEvent(const EditorState&amp;, bool&amp; handled, Vector&lt;WebCore::KeypressCommand&gt;&amp;);
</del><span class="cx">     void executeSavedCommandBySelector(const String&amp; selector, bool&amp; handled);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -261,7 +261,6 @@
</span><span class="cx">     DidPerformDictionaryLookup(WebKit::AttributedString text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)
</span><span class="cx"> 
</span><span class="cx">     # Keyboard input support messages
</span><del>-    InterpretQueuedKeyEvent(WebKit::EditorState state) -&gt; (bool handled, Vector&lt;WebCore::KeypressCommand&gt; savedCommands)
</del><span class="cx">     ExecuteSavedCommandBySelector(String selector) -&gt; (bool handled)
</span><span class="cx"> 
</span><span class="cx">     # Remote accessibility messages
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -73,7 +73,6 @@
</span><span class="cx">     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
</span><span class="cx">     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
</span><span class="cx">     virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&amp;) override;
</span><del>-    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&amp;, Vector&lt;WebCore::KeypressCommand&gt;&amp;) override;
</del><span class="cx">     virtual bool executeSavedCommandBySelector(const String&amp; selector) override;
</span><span class="cx">     virtual void setDragImage(const WebCore::IntPoint&amp; clientPosition, PassRefPtr&lt;ShareableBitmap&gt; dragImage, bool isLinkDrag) override;
</span><span class="cx">     virtual void updateSecureInputState() override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -196,12 +196,6 @@
</span><span class="cx">     [m_contentView _setAccessibilityWebProcessToken:remoteToken];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent&amp;, Vector&lt;KeypressCommand&gt;&amp;)
-{
-    notImplemented();
-    return false;
-}
-
</del><span class="cx"> bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent&amp; event, bool isCharEvent)
</span><span class="cx"> {
</span><span class="cx">     return [m_contentView _interpretKeyEvent:event.nativeEvent() isCharEvent:isCharEvent];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -410,11 +410,6 @@
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::ExtendSelection(static_cast&lt;uint32_t&gt;(granularity)), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::interpretQueuedKeyEvent(const EditorState&amp;, bool&amp;, Vector&lt;WebCore::KeypressCommand&gt;&amp;)
-{
-    notImplemented();
-}
-
</del><span class="cx"> void WebPageProxy::interpretKeyEvent(const EditorState&amp; state, bool isCharEvent, bool&amp; handled)
</span><span class="cx"> {
</span><span class="cx">     m_editorState = state;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -89,7 +89,6 @@
</span><span class="cx">     virtual void clearAllEditCommands();
</span><span class="cx">     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
</span><span class="cx">     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
</span><del>-    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&amp;, Vector&lt;WebCore::KeypressCommand&gt;&amp;);
</del><span class="cx">     virtual bool executeSavedCommandBySelector(const String&amp; selector);
</span><span class="cx">     virtual void setDragImage(const WebCore::IntPoint&amp; clientPosition, PassRefPtr&lt;ShareableBitmap&gt; dragImage, bool isLinkDrag);
</span><span class="cx">     virtual void setPromisedData(const String&amp; pasteboardName, PassRefPtr&lt;WebCore::SharedBuffer&gt; imageBuffer, const String&amp; filename, const String&amp; extension, const String&amp; title,
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -336,11 +336,6 @@
</span><span class="cx">     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent&amp; event, Vector&lt;WebCore::KeypressCommand&gt;&amp; commands)
-{
-    return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands];
-}
-
</del><span class="cx"> void PageClientImpl::setDragImage(const IntPoint&amp; clientPosition, PassRefPtr&lt;ShareableBitmap&gt; dragImage, bool isLinkDrag)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; dragCGImage = dragImage-&gt;makeCGImage();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWebPageProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -348,12 +348,6 @@
</span><span class="cx">     process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::interpretQueuedKeyEvent(const EditorState&amp; state, bool&amp; handled, Vector&lt;WebCore::KeypressCommand&gt;&amp; commands)
-{
-    m_editorState = state;
-    handled = m_pageClient.interpretKeyEvent(m_keyEventQueue.first(), commands);
-}
-
</del><span class="cx"> // Complex text input support for plug-ins.
</span><span class="cx"> void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String&amp; textInput)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportiosWebEditorClientIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     
</span><span class="cx"> void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
</span><span class="cx"> {
</span><del>-    if (m_page-&gt;handleEditingKeyboardEvent(event, false))
</del><ins>+    if (m_page-&gt;handleEditingKeyboardEvent(event))
</ins><span class="cx">         event-&gt;setDefaultHandled();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportmacWebEditorClientMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -62,13 +62,13 @@
</span><span class="cx">     
</span><span class="cx"> void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
</span><span class="cx"> {
</span><del>-    if (m_page-&gt;handleEditingKeyboardEvent(event, false))
</del><ins>+    if (m_page-&gt;handleEditingKeyboardEvent(event))
</ins><span class="cx">         event-&gt;setDefaultHandled();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
</span><span class="cx"> {
</span><del>-    if (m_page-&gt;handleEditingKeyboardEvent(event, true))
</del><ins>+    if (event-&gt;handledByInputMethod())
</ins><span class="cx">         event-&gt;setDefaultHandled();
</span><span class="cx"> }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -253,7 +253,6 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     , m_pdfPluginEnabled(false)
</span><span class="cx">     , m_hasCachedWindowFrame(false)
</span><del>-    , m_keyboardEventBeingInterpreted(0)
</del><span class="cx">     , m_viewGestureGeometryCollector(*this)
</span><span class="cx"> #elif PLATFORM(GTK) &amp;&amp; HAVE(ACCESSIBILITY)
</span><span class="cx">     , m_accessibilityObject(0)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -237,11 +237,7 @@
</span><span class="cx">     void layoutIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     // -- Called from WebCore clients.
</span><del>-#if PLATFORM(COCOA)
-    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*, bool saveCommands);
-#elif !PLATFORM(GTK)
</del><span class="cx">     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     void didStartPageTransition();
</span><span class="cx">     void didCompletePageTransition();
</span><span class="lines">@@ -1000,8 +996,6 @@
</span><span class="cx">     
</span><span class="cx">     RetainPtr&lt;WKAccessibilityWebPageObject&gt; m_mockAccessibilityElement;
</span><span class="cx"> 
</span><del>-    WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
-
</del><span class="cx">     ViewGestureGeometryCollector m_viewGestureGeometryCollector;
</span><span class="cx"> 
</span><span class="cx"> #elif HAVE(ACCESSIBILITY) &amp;&amp; (PLATFORM(GTK) || PLATFORM(EFL))
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -142,8 +142,9 @@
</span><span class="cx">     return m_viewportConfiguration.allowsUserScaling();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event, bool)
</del><ins>+bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event)
</ins><span class="cx"> {
</span><ins>+    // FIXME: Interpret the event immediately upon receiving it in UI process, without sending to WebProcess first.
</ins><span class="cx">     bool eventWasHandled = false;
</span><span class="cx">     bool sendResult = WebProcess::shared().parentProcessConnection()-&gt;sendSync(Messages::WebPageProxy::InterpretKeyEvent(editorState(), event-&gt;keyEvent()-&gt;type() == PlatformKeyboardEvent::Char),
</span><span class="cx">                                                                                Messages::WebPageProxy::InterpretKeyEvent::Reply(eventWasHandled), m_pageID);
</span><span class="lines">@@ -206,7 +207,7 @@
</span><span class="cx">     if (!frame.editor().hasComposition()) {
</span><span class="cx">         // An insertText: might be handled by other responders in the chain if we don't handle it.
</span><span class="cx">         // One example is space bar that results in scrolling down the page.
</span><del>-        frame.editor().insertText(text, 0);
</del><ins>+        frame.editor().insertText(text, nullptr);
</ins><span class="cx">     } else
</span><span class="cx">         frame.editor().confirmComposition(text);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (165355 => 165356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-03-09 21:07:32 UTC (rev 165355)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-03-09 22:56:08 UTC (rev 165356)
</span><span class="lines">@@ -166,22 +166,25 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebPage::executeKeypressCommandsInternal(const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands, KeyboardEvent* event)
</span><span class="cx"> {
</span><del>-    Frame* frame = frameForEvent(event);
-    ASSERT(frame-&gt;page() == corePage());
</del><ins>+    Frame&amp; frame = event ? *frameForEvent(event) : m_page-&gt;focusController().focusedOrMainFrame();
+    ASSERT(frame.page() == corePage());
</ins><span class="cx"> 
</span><span class="cx">     bool eventWasHandled = false;
</span><span class="cx">     for (size_t i = 0; i &lt; commands.size(); ++i) {
</span><span class="cx">         if (commands[i].commandName == &quot;insertText:&quot;) {
</span><del>-            ASSERT(!frame-&gt;editor().hasComposition());
</del><ins>+            if (frame.editor().hasComposition()) {
+                eventWasHandled = true;
+                frame.editor().confirmComposition(commands[i].text);
+            } else {
+                if (!frame.editor().canEdit())
+                    continue;
</ins><span class="cx"> 
</span><del>-            if (!frame-&gt;editor().canEdit())
-                continue;
-
-            // An insertText: might be handled by other responders in the chain if we don't handle it.
-            // One example is space bar that results in scrolling down the page.
-            eventWasHandled |= frame-&gt;editor().insertText(commands[i].text, event);
</del><ins>+                // An insertText: might be handled by other responders in the chain if we don't handle it.
+                // One example is space bar that results in scrolling down the page.
+                eventWasHandled |= frame.editor().insertText(commands[i].text, event);
+            }
</ins><span class="cx">         } else {
</span><del>-            Editor::Command command = frame-&gt;editor().command(commandNameForSelectorName(commands[i].commandName));
</del><ins>+            Editor::Command command = frame.editor().command(commandNameForSelectorName(commands[i].commandName));
</ins><span class="cx">             if (command.isSupported()) {
</span><span class="cx">                 bool commandExecutedByEditor = command.execute(event);
</span><span class="cx">                 eventWasHandled |= commandExecutedByEditor;
</span><span class="lines">@@ -200,53 +203,39 @@
</span><span class="cx">     return eventWasHandled;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event, bool saveCommands)
</del><ins>+bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event)
</ins><span class="cx"> {
</span><del>-    ASSERT(!saveCommands || event-&gt;keypressCommands().isEmpty()); // Save commands once for each event.
-
</del><span class="cx">     Frame* frame = frameForEvent(event);
</span><span class="cx">     
</span><span class="cx">     const PlatformKeyboardEvent* platformEvent = event-&gt;keyEvent();
</span><span class="cx">     if (!platformEvent)
</span><span class="cx">         return false;
</span><del>-    Vector&lt;KeypressCommand&gt;&amp; commands = event-&gt;keypressCommands();
</del><ins>+    const Vector&lt;KeypressCommand&gt;&amp; commands = event-&gt;keypressCommands();
</ins><span class="cx"> 
</span><del>-    if ([platformEvent-&gt;macEvent() type] == NSFlagsChanged)
</del><ins>+    ASSERT(!platformEvent-&gt;macEvent()); // Cannot have a native event in WebProcess.
+
+    // Don't handle Esc while handling keydown event, we need to dispatch a keypress first.
+    if (platformEvent-&gt;type() != PlatformEvent::Char &amp;&amp; platformEvent-&gt;windowsVirtualKeyCode() == VK_ESCAPE &amp;&amp; commands.size() == 1 &amp;&amp; commandNameForSelectorName(commands[0].commandName) == &quot;cancelOperation&quot;)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     bool eventWasHandled = false;
</span><del>-    
-    if (saveCommands) {
-        KeyboardEvent* oldEvent = m_keyboardEventBeingInterpreted;
-        m_keyboardEventBeingInterpreted = event;
-        bool sendResult = WebProcess::shared().parentProcessConnection()-&gt;sendSync(Messages::WebPageProxy::InterpretQueuedKeyEvent(editorState()), 
-            Messages::WebPageProxy::InterpretQueuedKeyEvent::Reply(eventWasHandled, commands), m_pageID);
-        m_keyboardEventBeingInterpreted = oldEvent;
-        if (!sendResult)
-            return false;
</del><span class="cx"> 
</span><del>-        // An input method may make several actions per keypress. For example, pressing Return with Korean IM both confirms it and sends a newline.
-        // IM-like actions are handled immediately (so the return value from UI process is true), but there are saved commands that
-        // should be handled like normal text input after DOM event dispatch.
-        if (!event-&gt;keypressCommands().isEmpty())
-            return false;
-    } else {
-        // Are there commands that could just cause text insertion if executed via Editor?
-        // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore
-        // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
-        // (e.g. Tab that inserts a Tab character, or Enter).
-        bool haveTextInsertionCommands = false;
-        for (size_t i = 0; i &lt; commands.size(); ++i) {
-            if (frame-&gt;editor().command(commandNameForSelectorName(commands[i].commandName)).isTextInsertion())
-                haveTextInsertionCommands = true;
-        }
-        // If there are no text insertion commands, default keydown handler is the right time to execute the commands.
-        // Keypress (Char event) handler is the latest opportunity to execute.
-        if (!haveTextInsertionCommands || platformEvent-&gt;type() == PlatformEvent::Char) {
-            eventWasHandled = executeKeypressCommandsInternal(event-&gt;keypressCommands(), event);
-            event-&gt;keypressCommands().clear();
-        }
</del><ins>+    // Are there commands that could just cause text insertion if executed via Editor?
+    // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore
+    // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
+    // (e.g. Tab that inserts a Tab character, or Enter).
+    bool haveTextInsertionCommands = false;
+    for (auto&amp; command : commands) {
+        if (frame-&gt;editor().command(commandNameForSelectorName(command.commandName)).isTextInsertion())
+            haveTextInsertionCommands = true;
</ins><span class="cx">     }
</span><ins>+    // If there are no text insertion commands, default keydown handler is the right time to execute the commands.
+    // Keypress (Char event) handler is the latest opportunity to execute.
+    if (!haveTextInsertionCommands || platformEvent-&gt;type() == PlatformEvent::Char) {
+        eventWasHandled = executeKeypressCommandsInternal(event-&gt;keypressCommands(), event);
+        event-&gt;keypressCommands().clear();
+    }
+
</ins><span class="cx">     return eventWasHandled;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -302,7 +291,7 @@
</span><span class="cx">     if (!frame.editor().hasComposition()) {
</span><span class="cx">         // An insertText: might be handled by other responders in the chain if we don't handle it.
</span><span class="cx">         // One example is space bar that results in scrolling down the page.
</span><del>-        handled = frame.editor().insertText(text, m_keyboardEventBeingInterpreted);
</del><ins>+        handled = frame.editor().insertText(text, nullptr);
</ins><span class="cx">     } else {
</span><span class="cx">         handled = true;
</span><span class="cx">         frame.editor().confirmComposition(text);
</span><span class="lines">@@ -322,7 +311,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!frame.editor().hasComposition());
</span><del>-    handled = frame.editor().insertDictatedText(text, dictationAlternativeLocations, m_keyboardEventBeingInterpreted);
</del><ins>+    handled = frame.editor().insertDictatedText(text, dictationAlternativeLocations, nullptr);
</ins><span class="cx">     newState = editorState();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -436,7 +425,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::executeKeypressCommands(const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands, bool&amp; handled, EditorState&amp; newState)
</span><span class="cx"> {
</span><del>-    handled = executeKeypressCommandsInternal(commands, m_keyboardEventBeingInterpreted);
</del><ins>+    handled = executeKeypressCommandsInternal(commands, nullptr);
</ins><span class="cx">     newState = editorState();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>