<!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>[185415] 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/185415">185415</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-10 06:32:22 -0700 (Wed, 10 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Get rid of GetEditorCommandsForKeyEvent sync message
https://bugs.webkit.org/show_bug.cgi?id=145598

Reviewed by Žan Doberšek.

Source/WebCore:

* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
(WebCore::PlatformKeyboardEvent::commands):
* platform/gtk/KeyBindingTranslator.cpp: Use a single list of
custom key bindings. We don't need to distinguish between key down and
key press commands, since the web editor client already does that
when executing the commands.
(WebCore::KeyBindingTranslator::commandsForKeyEvent): This is
getEditorCommandsForKeyEvent() renamed as commandsForKeyEvent(),
since it now returns the list of commands to simplify the
code. Also simplify the custom key bindings handling, by using the
global list instead of moving it to a HashMap.
(WebCore::KeyBindingTranslator::getEditorCommandsForKeyEvent): Deleted.
* platform/gtk/KeyBindingTranslator.h:

Source/WebKit2:

We are sending GetEditorCommandsForKeyEvent sync message from web
process to the UI process for every key pressed. And if the
keydown event doesn't handle the key, the message is sent again
for the keypress event, so in many cases it happens twice per
keypress. We can get the list of commands when the key press event
happens in the web view, and send it to the web process as part of
the keyboard event like mac port does. In the web process,
commands not inserting text will be handled by keydown and the
rest in keypress without having to use any other IPC message for that.

* Shared/NativeWebKeyboardEvent.h: Add command list parameter to
the constructor.
* Shared/WebEvent.h: Add GTK specific constructor that receives a
list of commands and whether the event was handled by input methods.
(WebKit::WebKeyboardEvent::commands): Returns the list of commands.
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
Also copy the commands and handledByInputMethod member.
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent): Implement GTK
specific constructor that receives a list of commands and whether
the event was handled by input methods.
(WebKit::WebKeyboardEvent::encode): Encode commands and handledByInputMethod.
(WebKit::WebKeyboardEvent::decode): Decode commands and handledByInputMethod.
* Shared/gtk/NativeWebKeyboardEventGtk.cpp:
(WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add
command list parameter to the constructor.
* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent): Use the new
WebKeyboardEvent constructor and simplify the code. We don't need
to explicitly set VK_PROCESSKEY as windows virtual key code when
the event was handled by input methods. The WebCore event handler
already does that.
* Shared/gtk/WebEventFactory.h:
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::getEditorCommandsForKeyEvent): Deleted.
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp: Add a
KeyBindingTranslator member.
(webkitWebViewBaseKeyPressEvent): Use the new
InputMethodFilter::filterKeyEvent() API and get the list of
commands for the key when events was not handled by input methods.
(webkitWebViewBaseKeyReleaseEvent): Use the new
InputMethodFilter::filterKeyEvent() API.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.messages.in: Remove GetEditorCommandsForKeyEvent message.
* UIProcess/gtk/InputMethodFilter.cpp:
(WebKit::InputMethodFilter::handleKeyboardEvent): Call the
completation handler.
(WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults): Ditto.
(WebKit::InputMethodFilter::filterKeyEvent): Use a completion
handler for the task, so that the caller (the web view) can handle
the keyboard event.
* UIProcess/gtk/InputMethodFilter.h:
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::getEditorCommandsForKeyEvent): Deleted.
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::handleKeyboardEvent): Return earlier if
the event was handled by input methods. And get the list of
commands from the PlatformKeyboardEvent instead of sending a sync
message to the UI process.
(WebKit::WebEditorClient::handleInputMethodKeydown): If the event
was handled by inpout methods, set the event as default handled so
that the WebCore event handler sets VK_PROCESSKEY as windows
virtual key code.
(WebKit::WebEditorClient::getEditorCommandsForKeyEvent): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformPlatformKeyboardEventh">trunk/Source/WebCore/platform/PlatformKeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkKeyBindingTranslatorcpp">trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkKeyBindingTranslatorh">trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h</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="#trunkSourceWebKit2SharedgtkNativeWebKeyboardEventGtkcpp">trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkWebEventFactorycpp">trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkWebEventFactoryh">trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplh">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkInputMethodFiltercpp">trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkInputMethodFilterh">trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/ChangeLog        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-06-10  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Get rid of GetEditorCommandsForKeyEvent sync message
+        https://bugs.webkit.org/show_bug.cgi?id=145598
+
+        Reviewed by Žan Doberšek.
+
+        * platform/PlatformKeyboardEvent.h:
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+        (WebCore::PlatformKeyboardEvent::commands):
+        * platform/gtk/KeyBindingTranslator.cpp: Use a single list of
+        custom key bindings. We don't need to distinguish between key down and
+        key press commands, since the web editor client already does that
+        when executing the commands.
+        (WebCore::KeyBindingTranslator::commandsForKeyEvent): This is
+        getEditorCommandsForKeyEvent() renamed as commandsForKeyEvent(),
+        since it now returns the list of commands to simplify the
+        code. Also simplify the custom key bindings handling, by using the
+        global list instead of moving it to a HashMap.
+        (WebCore::KeyBindingTranslator::getEditorCommandsForKeyEvent): Deleted.
+        * platform/gtk/KeyBindingTranslator.h:
+
</ins><span class="cx"> 2015-06-10  Per Arne Vollan  &lt;peavo@outlook.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WinCairo] Crash on exit when terminating egl
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPlatformKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">             , m_windowsVirtualKeyCode(0)
</span><span class="cx">             , m_nativeVirtualKeyCode(0)
</span><span class="cx">             , m_macCharCode(0)
</span><del>-#if USE(APPKIT)
</del><ins>+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">             , m_handledByInputMethod(false)
</span><span class="cx"> #endif
</span><span class="cx">             , m_autoRepeat(false)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">             , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
</span><span class="cx">             , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
</span><span class="cx">             , m_macCharCode(macCharCode)
</span><del>-#if USE(APPKIT)
</del><ins>+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">             , m_handledByInputMethod(false)
</span><span class="cx"> #endif
</span><span class="cx">             , m_autoRepeat(isAutoRepeat)
</span><span class="lines">@@ -115,9 +115,13 @@
</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) || PLATFORM(GTK)
+        bool handledByInputMethod() const { return m_handledByInputMethod; }
+#endif
</ins><span class="cx"> #if USE(APPKIT)
</span><del>-        bool handledByInputMethod() const { return m_handledByInputMethod; }
</del><span class="cx">         const Vector&lt;KeypressCommand&gt;&amp; commands() const { return m_commands; }
</span><ins>+#elif PLATFORM(GTK)
+        const Vector&lt;String&gt;&amp; commands() const { return m_commands; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         bool isAutoRepeat() const { return m_autoRepeat; }
</span><span class="lines">@@ -162,9 +166,13 @@
</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) || PLATFORM(GTK)
+        bool m_handledByInputMethod;
+#endif
</ins><span class="cx"> #if USE(APPKIT)
</span><del>-        bool m_handledByInputMethod;
</del><span class="cx">         Vector&lt;KeypressCommand&gt; m_commands;
</span><ins>+#elif PLATFORM(GTK)
+        Vector&lt;String&gt; m_commands;
</ins><span class="cx"> #endif
</span><span class="cx">         bool m_autoRepeat;
</span><span class="cx">         bool m_isKeypad;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkKeyBindingTranslatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -184,61 +184,44 @@
</span><span class="cx">     const char* name;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-static const KeyCombinationEntry keyDownEntries[] = {
</del><ins>+static const KeyCombinationEntry customKeyBindings[] = {
</ins><span class="cx">     { GDK_b,         GDK_CONTROL_MASK,               &quot;ToggleBold&quot;    },
</span><span class="cx">     { GDK_i,         GDK_CONTROL_MASK,               &quot;ToggleItalic&quot;  },
</span><span class="cx">     { GDK_Escape,    0,                              &quot;Cancel&quot;        },
</span><span class="cx">     { GDK_greater,   GDK_CONTROL_MASK,               &quot;Cancel&quot;        },
</span><del>-};
-
-// These commands are text insertion commands, so should take place
-// while handling the KeyPress event.
-static const KeyCombinationEntry keyPressEntries[] = {
</del><span class="cx">     { GDK_Tab,       0,                              &quot;InsertTab&quot;     },
</span><span class="cx">     { GDK_Tab,       GDK_SHIFT_MASK,                 &quot;InsertBacktab&quot; },
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-void KeyBindingTranslator::getEditorCommandsForKeyEvent(GdkEventKey* event, EventType type, Vector&lt;WTF::String&gt;&amp; commandList)
</del><ins>+Vector&lt;String&gt; KeyBindingTranslator::commandsForKeyEvent(GdkEventKey* event)
</ins><span class="cx"> {
</span><del>-    m_pendingEditorCommands.clear();
</del><ins>+    ASSERT(m_pendingEditorCommands.isEmpty());
</ins><span class="cx"> 
</span><ins>+    // FIXME: Move KeyBindingTranslator to WebKit layer and remove the GTK2 code.
</ins><span class="cx"> #ifdef GTK_API_VERSION_2
</span><span class="cx">     gtk_bindings_activate_event(GTK_OBJECT(m_nativeWidget.get()), event);
</span><span class="cx"> #else
</span><span class="cx">     gtk_bindings_activate_event(G_OBJECT(m_nativeWidget.get()), event);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (!m_pendingEditorCommands.isEmpty()) {
-        commandList.appendVector(m_pendingEditorCommands);
-        return;
-    }
</del><ins>+    if (!m_pendingEditorCommands.isEmpty())
+        return WTF::move(m_pendingEditorCommands);
</ins><span class="cx"> 
</span><del>-    DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyDownCommandsMap, ());
-    DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyPressCommandsMap, ());
-
-    if (keyDownCommandsMap.isEmpty()) {
-        for (unsigned i = 0; i &lt; G_N_ELEMENTS(keyDownEntries); i++)
-            keyDownCommandsMap.set(keyDownEntries[i].state &lt;&lt; 16 | keyDownEntries[i].gdkKeyCode, keyDownEntries[i].name);
-
-        for (unsigned i = 0; i &lt; G_N_ELEMENTS(keyPressEntries); i++)
-            keyPressCommandsMap.set(keyPressEntries[i].state &lt;&lt; 16 | keyPressEntries[i].gdkKeyCode, keyPressEntries[i].name);
-    }
-
</del><span class="cx">     // Special-case enter keys for we want them to work regardless of modifier.
</span><del>-    if ((event-&gt;keyval == GDK_Return || event-&gt;keyval == GDK_KP_Enter || event-&gt;keyval == GDK_ISO_Enter) &amp;&amp; type == KeyPress) {
-        commandList.append(&quot;InsertNewLine&quot;);
-        return;
-    }
</del><ins>+    if ((event-&gt;keyval == GDK_Return || event-&gt;keyval == GDK_KP_Enter || event-&gt;keyval == GDK_ISO_Enter))
+        return { &quot;InsertNewLine&quot; };
</ins><span class="cx"> 
</span><span class="cx">     // For keypress events, we want charCode(), but keyCode() does that.
</span><del>-    int mapKey = event-&gt;state &lt;&lt; 16 | event-&gt;keyval;
-    if (mapKey) {
-        HashMap&lt;int, const char*&gt;* commandMap = type == KeyDown ?  &amp;keyDownCommandsMap : &amp;keyPressCommandsMap;
-        if (const char* commandString = commandMap-&gt;get(mapKey)) {
-            commandList.append(commandString);
-            return;
-        }
</del><ins>+    unsigned mapKey = event-&gt;state &lt;&lt; 16 | event-&gt;keyval;
+    if (!mapKey)
+        return { };
+
+    for (unsigned i = 0; i &lt; G_N_ELEMENTS(customKeyBindings); ++i) {
+        if (mapKey == (customKeyBindings[i].state &lt;&lt; 16 | customKeyBindings[i].gdkKeyCode))
+            return { customKeyBindings[i].name };
</ins><span class="cx">     }
</span><ins>+
+    return { };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkKeyBindingTranslatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -31,13 +31,12 @@
</span><span class="cx"> public:
</span><span class="cx">     KeyBindingTranslator();
</span><span class="cx"> 
</span><del>-    enum EventType { KeyDown, KeyPress };
-    void getEditorCommandsForKeyEvent(GdkEventKey*, EventType, Vector&lt;WTF::String&gt;&amp;);
</del><ins>+    Vector&lt;String&gt; commandsForKeyEvent(GdkEventKey*);
</ins><span class="cx">     void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(command); }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     GRefPtr&lt;GtkWidget&gt; m_nativeWidget;
</span><del>-    Vector&lt;WTF::String&gt; m_pendingEditorCommands;
</del><ins>+    Vector&lt;String&gt; m_pendingEditorCommands;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/ChangeLog        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -1,5 +1,79 @@
</span><span class="cx"> 2015-06-10  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [GTK] Get rid of GetEditorCommandsForKeyEvent sync message
+        https://bugs.webkit.org/show_bug.cgi?id=145598
+
+        Reviewed by Žan Doberšek.
+
+        We are sending GetEditorCommandsForKeyEvent sync message from web
+        process to the UI process for every key pressed. And if the
+        keydown event doesn't handle the key, the message is sent again
+        for the keypress event, so in many cases it happens twice per
+        keypress. We can get the list of commands when the key press event
+        happens in the web view, and send it to the web process as part of
+        the keyboard event like mac port does. In the web process,
+        commands not inserting text will be handled by keydown and the
+        rest in keypress without having to use any other IPC message for that.
+
+        * Shared/NativeWebKeyboardEvent.h: Add command list parameter to
+        the constructor.
+        * Shared/WebEvent.h: Add GTK specific constructor that receives a
+        list of commands and whether the event was handled by input methods.
+        (WebKit::WebKeyboardEvent::commands): Returns the list of commands.
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+        Also copy the commands and handledByInputMethod member.
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent): Implement GTK
+        specific constructor that receives a list of commands and whether
+        the event was handled by input methods.
+        (WebKit::WebKeyboardEvent::encode): Encode commands and handledByInputMethod.
+        (WebKit::WebKeyboardEvent::decode): Decode commands and handledByInputMethod.
+        * Shared/gtk/NativeWebKeyboardEventGtk.cpp:
+        (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add
+        command list parameter to the constructor.
+        * Shared/gtk/WebEventFactory.cpp:
+        (WebKit::WebEventFactory::createWebKeyboardEvent): Use the new
+        WebKeyboardEvent constructor and simplify the code. We don't need
+        to explicitly set VK_PROCESSKEY as windows virtual key code when
+        the event was handled by input methods. The WebCore event handler
+        already does that.
+        * Shared/gtk/WebEventFactory.h:
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::getEditorCommandsForKeyEvent): Deleted.
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp: Add a
+        KeyBindingTranslator member.
+        (webkitWebViewBaseKeyPressEvent): Use the new
+        InputMethodFilter::filterKeyEvent() API and get the list of
+        commands for the key when events was not handled by input methods.
+        (webkitWebViewBaseKeyReleaseEvent): Use the new
+        InputMethodFilter::filterKeyEvent() API.
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.messages.in: Remove GetEditorCommandsForKeyEvent message.
+        * UIProcess/gtk/InputMethodFilter.cpp:
+        (WebKit::InputMethodFilter::handleKeyboardEvent): Call the
+        completation handler.
+        (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults): Ditto.
+        (WebKit::InputMethodFilter::filterKeyEvent): Use a completion
+        handler for the task, so that the caller (the web view) can handle
+        the keyboard event.
+        * UIProcess/gtk/InputMethodFilter.h:
+        * UIProcess/gtk/WebPageProxyGtk.cpp:
+        (WebKit::WebPageProxy::getEditorCommandsForKeyEvent): Deleted.
+        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+        (WebKit::WebEditorClient::handleKeyboardEvent): Return earlier if
+        the event was handled by input methods. And get the list of
+        commands from the PlatformKeyboardEvent instead of sending a sync
+        message to the UI process.
+        (WebKit::WebEditorClient::handleInputMethodKeydown): If the event
+        was handled by inpout methods, set the event as default handled so
+        that the WebCore event handler sets VK_PROCESSKEY as windows
+        virtual key code.
+        (WebKit::WebEditorClient::getEditorCommandsForKeyEvent): Deleted.
+
+2015-06-10  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
</ins><span class="cx">         Unreviewed. Fix GTK build after r185412.
</span><span class="cx"> 
</span><span class="cx">         Add missing include.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNativeWebKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, const Vector&lt;WebCore::KeypressCommand&gt;&amp;);
</span><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx">     NativeWebKeyboardEvent(const NativeWebKeyboardEvent&amp;);
</span><del>-    NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&amp;, InputMethodFilter::EventFakedForComposition);
</del><ins>+    NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&amp;, InputMethodFilter::EventFakedForComposition, Vector&lt;String&gt;&amp;&amp; commands);
</ins><span class="cx"> #elif PLATFORM(EFL)
</span><span class="cx">     NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool);
</span><span class="cx">     NativeWebKeyboardEvent(const Evas_Event_Key_Up*);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEvent.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebEvent.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebEvent.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -235,6 +235,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx">     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);
</span><ins>+#elif PLATFORM(GTK)
+    WebKeyboardEvent(Type, const String&amp; text, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector&lt;String&gt;&amp;&amp; commands, bool isKeypad, Modifiers, double timestamp);
</ins><span class="cx"> #else
</span><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><span class="cx"> #endif
</span><span class="lines">@@ -245,9 +247,13 @@
</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) || PLATFORM(GTK)
+    bool handledByInputMethod() const { return m_handledByInputMethod; }
+#endif
</ins><span class="cx"> #if USE(APPKIT)
</span><del>-    bool handledByInputMethod() const { return m_handledByInputMethod; }
</del><span class="cx">     const Vector&lt;WebCore::KeypressCommand&gt;&amp; commands() const { return m_commands; }
</span><ins>+#elif PLATFORM(GTK)
+    const Vector&lt;String&gt;&amp; commands() const { return m_commands; }
</ins><span class="cx"> #endif
</span><span class="cx">     bool isAutoRepeat() const { return m_isAutoRepeat; }
</span><span class="cx">     bool isKeypad() const { return m_isKeypad; }
</span><span class="lines">@@ -265,9 +271,13 @@
</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) || PLATFORM(GTK)
+    bool m_handledByInputMethod;
+#endif
</ins><span class="cx"> #if USE(APPKIT)
</span><del>-    bool m_handledByInputMethod;
</del><span class="cx">     Vector&lt;WebCore::KeypressCommand&gt; m_commands;
</span><ins>+#elif PLATFORM(GTK)
+    Vector&lt;String&gt; m_commands;
</ins><span class="cx"> #endif
</span><span class="cx">     bool m_isAutoRepeat;
</span><span class="cx">     bool m_isKeypad;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -204,7 +204,7 @@
</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><del>-#if USE(APPKIT)
</del><ins>+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">         m_handledByInputMethod = webEvent.handledByInputMethod();
</span><span class="cx">         m_commands = webEvent.commands();
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebKeyboardEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -54,6 +54,25 @@
</span><span class="cx">     ASSERT(isKeyboardEventType(type));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#elif PLATFORM(GTK)
+
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String&amp; text, const String&amp; keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector&lt;String&gt;&amp;&amp; commands, bool isKeypad, Modifiers modifiers, double timestamp)
+    : WebEvent(type, modifiers, timestamp)
+    , m_text(text)
+    , m_unmodifiedText(text)
+    , m_keyIdentifier(keyIdentifier)
+    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+    , m_macCharCode(0)
+    , m_handledByInputMethod(handledByInputMethod)
+    , m_commands(WTF::move(commands))
+    , m_isAutoRepeat(false)
+    , m_isKeypad(isKeypad)
+    , m_isSystemKey(false)
+{
+    ASSERT(isKeyboardEventType(type));
+}
+
</ins><span class="cx"> #else
</span><span class="cx"> 
</span><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="lines">@@ -87,7 +106,7 @@
</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><del>-#if USE(APPKIT)
</del><ins>+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">     encoder &lt;&lt; m_handledByInputMethod;
</span><span class="cx">     encoder &lt;&lt; m_commands;
</span><span class="cx"> #endif
</span><span class="lines">@@ -113,7 +132,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.m_macCharCode))
</span><span class="cx">         return false;
</span><del>-#if USE(APPKIT)
</del><ins>+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">     if (!decoder.decode(result.m_handledByInputMethod))
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.m_commands))
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkNativeWebKeyboardEventGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -35,8 +35,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults&amp; compositionResults, InputMethodFilter::EventFakedForComposition faked)
-    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults))
</del><ins>+NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults&amp; compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector&lt;String&gt;&amp;&amp; commands)
+    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTF::move(commands)))
</ins><span class="cx">     , m_nativeEvent(gdk_event_copy(event))
</span><span class="cx">     , m_compositionResults(compositionResults)
</span><span class="cx">     , m_fakeEventForComposition(faked == InputMethodFilter::EventFaked)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent&amp; event)
</span><del>-    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults()))
</del><ins>+    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector&lt;String&gt;(event.commands())))
</ins><span class="cx">     , m_nativeEvent(gdk_event_copy(event.nativeEvent()))
</span><span class="cx">     , m_compositionResults(event.compositionResults())
</span><span class="cx">     , m_fakeEventForComposition(event.isFakeEventForComposition())
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkWebEventFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -181,27 +181,19 @@
</span><span class="cx">                          gdk_event_get_time(event));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults&amp; compositionResults)
</del><ins>+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults&amp; compositionResults, Vector&lt;String&gt;&amp;&amp; commands)
</ins><span class="cx"> {
</span><del>-    unsigned int keyValue = event-&gt;key.keyval;
-    String text = compositionResults.simpleString.length() ?
-         compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyValue);
-
-    int windowsVirtualKeyCode = compositionResults.compositionUpdated() ?
-         VK_PROCESSKEY : PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event-&gt;key.keyval);
-
-    return WebKeyboardEvent((event-&gt;type == GDK_KEY_RELEASE) ? WebEvent::KeyUp : WebEvent::KeyDown,
-                            text,
-                            text,
-                            PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyValue),
-                            windowsVirtualKeyCode,
-                            static_cast&lt;int&gt;(keyValue),
-                            0 /* macCharCode */,
-                            false /* isAutoRepeat */,
-                            isGdkKeyCodeFromKeyPad(keyValue),
-                            false /* isSystemKey */,
-                            modifiersForEvent(event),
-                            gdk_event_get_time(event));
</del><ins>+    return WebKeyboardEvent(
+        event-&gt;type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
+        compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(event-&gt;key.keyval),
+        PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(event-&gt;key.keyval),
+        PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event-&gt;key.keyval),
+        static_cast&lt;int&gt;(event-&gt;key.keyval),
+        compositionResults.compositionUpdated(),
+        WTF::move(commands),
+        isGdkKeyCodeFromKeyPad(event-&gt;key.keyval),
+        modifiersForEvent(event),
+        gdk_event_get_time(event));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector&lt;WebPlatformTouchPoint&gt;&amp;&amp; touchPoints)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkWebEventFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> public:
</span><span class="cx">     static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
</span><span class="cx">     static WebWheelEvent createWebWheelEvent(const GdkEvent*);
</span><del>-    static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&amp;);
</del><ins>+    static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&amp;, Vector&lt;String&gt;&amp;&amp; commands);
</ins><span class="cx">     static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector&lt;WebPlatformTouchPoint&gt;&amp;&amp;);
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -56,15 +56,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&amp; event, const AtomicString&amp; eventType, Vector&lt;WTF::String&gt;&amp; commandList)
-{
-    ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent);
-
-    KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ?
-        KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress;
-    m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast&lt;GdkEventKey*&gt;(&amp;event.nativeEvent()-&gt;key), type, commandList);
-}
-
</del><span class="cx"> // PageClient's pure virtual functions
</span><span class="cx"> std::unique_ptr&lt;DrawingAreaProxy&gt; PageClientImpl::createDrawingAreaProxy()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -29,11 +29,9 @@
</span><span class="cx"> #define PageClientImpl_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;DefaultUndoController.h&quot;
</span><del>-#include &quot;KeyBindingTranslator.h&quot;
</del><span class="cx"> #include &quot;PageClient.h&quot;
</span><span class="cx"> #include &quot;WebFullScreenManagerProxy.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><del>-#include &quot;WindowsKeyboardCodes.h&quot;
</del><span class="cx"> #include &lt;WebCore/IntSize.h&gt;
</span><span class="cx"> #include &lt;gtk/gtk.h&gt;
</span><span class="cx"> #include &lt;memory&gt;
</span><span class="lines">@@ -91,7 +89,6 @@
</span><span class="cx">     virtual void setTextIndicator(Ref&lt;WebCore::TextIndicator&gt;, WebCore::TextIndicatorLifetime = WebCore::TextIndicatorLifetime::Permanent) override;
</span><span class="cx">     virtual void clearTextIndicator(WebCore::TextIndicatorDismissalAnimation = WebCore::TextIndicatorDismissalAnimation::FadeOut) override;
</span><span class="cx">     virtual void setTextIndicatorAnimationProgress(float) override;
</span><del>-    virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&amp;, const AtomicString&amp;, Vector&lt;WTF::String&gt;&amp;) override;
</del><span class="cx">     virtual void updateTextInputState() override;
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx">     virtual void startDrag(const WebCore::DragData&amp;, PassRefPtr&lt;ShareableBitmap&gt; dragImage) override;
</span><span class="lines">@@ -138,7 +135,6 @@
</span><span class="cx">     // Members of PageClientImpl class
</span><span class="cx">     GtkWidget* m_viewWidget;
</span><span class="cx">     DefaultUndoController m_undoController;
</span><del>-    WebCore::KeyBindingTranslator m_keyBindingTranslator;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;DrawingAreaProxyImpl.h&quot;
</span><span class="cx"> #include &quot;InputMethodFilter.h&quot;
</span><ins>+#include &quot;NativeWebKeyboardEvent.h&quot;
</ins><span class="cx"> #include &quot;NativeWebMouseEvent.h&quot;
</span><span class="cx"> #include &quot;NativeWebWheelEvent.h&quot;
</span><span class="cx"> #include &quot;PageClientImpl.h&quot;
</span><span class="lines">@@ -52,6 +53,7 @@
</span><span class="cx"> #include &lt;WebCore/GUniquePtrGtk.h&gt;
</span><span class="cx"> #include &lt;WebCore/GtkUtilities.h&gt;
</span><span class="cx"> #include &lt;WebCore/GtkVersioning.h&gt;
</span><ins>+#include &lt;WebCore/KeyBindingTranslator.h&gt;
</ins><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;WebCore/PasteboardHelper.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformDisplay.h&gt;
</span><span class="lines">@@ -163,6 +165,7 @@
</span><span class="cx">     GUniquePtr&lt;GdkEvent&gt; contextMenuEvent;
</span><span class="cx">     WebContextMenuProxyGtk* activeContextMenuProxy;
</span><span class="cx">     InputMethodFilter inputMethodFilter;
</span><ins>+    KeyBindingTranslator keyBindingTranslator;
</ins><span class="cx">     TouchEventsMap touchEvents;
</span><span class="cx"> 
</span><span class="cx">     GtkWindow* toplevelOnScreenWindow;
</span><span class="lines">@@ -749,7 +752,12 @@
</span><span class="cx">         priv-&gt;shouldForwardNextKeyEvent = FALSE;
</span><span class="cx">         return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)-&gt;key_press_event(widget, event);
</span><span class="cx">     }
</span><del>-    priv-&gt;inputMethodFilter.filterKeyEvent(event);
</del><ins>+
+    priv-&gt;inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults&amp; compositionResults, InputMethodFilter::EventFakedForComposition faked) {
+        priv-&gt;pageProxy-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast&lt;GdkEvent*&gt;(event), compositionResults, faked,
+            !compositionResults.compositionUpdated() ? priv-&gt;keyBindingTranslator.commandsForKeyEvent(event) : Vector&lt;String&gt;()));
+    });
+
</ins><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -762,7 +770,11 @@
</span><span class="cx">         priv-&gt;shouldForwardNextKeyEvent = FALSE;
</span><span class="cx">         return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)-&gt;key_release_event(widget, event);
</span><span class="cx">     }
</span><del>-    priv-&gt;inputMethodFilter.filterKeyEvent(event);
</del><ins>+
+    priv-&gt;inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults&amp; compositionResults, InputMethodFilter::EventFakedForComposition faked) {
+        priv-&gt;pageProxy-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast&lt;GdkEvent*&gt;(event), compositionResults, faked, { }));
+    });
+
</ins><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -196,9 +196,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK)
-    virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&amp;, const AtomicString&amp;, Vector&lt;WTF::String&gt;&amp;) = 0;
-#endif
</del><span class="cx">     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&amp;) = 0;
</span><span class="cx">     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&amp;) = 0;
</span><span class="cx">     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&amp;) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -204,9 +204,6 @@
</span><span class="cx">     PluginZoomFactorDidChange(double zoomFactor)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><del>-    # Support for GTK+ platform keybindings
-    GetEditorCommandsForKeyEvent(AtomicString eventType) -&gt; (Vector&lt;String&gt; commandsList)
-
</del><span class="cx">     # Support for connecting the Accessibility worlds of the UI and the Web processes
</span><span class="cx">     BindAccessibilityTree(String plugID)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkInputMethodFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -20,7 +20,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InputMethodFilter.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;NativeWebKeyboardEvent.h&quot;
</del><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> #include &lt;WebCore/Color.h&gt;
</span><span class="cx"> #include &lt;WebCore/CompositionResults.h&gt;
</span><span class="lines">@@ -122,7 +121,10 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    m_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast&lt;GdkEvent*&gt;(event), CompositionResults(simpleString), faked));
</del><ins>+
+    ASSERT(m_filterKeyEventCompletionHandler);
+    m_filterKeyEventCompletionHandler(CompositionResults(simpleString), faked);
+    m_filterKeyEventCompletionHandler = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InputMethodFilter::handleKeyboardEventWithCompositionResults(GdkEventKey* event, ResultsToSend resultsToSend, EventFakedForComposition faked)
</span><span class="lines">@@ -133,8 +135,11 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    m_page-&gt;handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast&lt;GdkEvent*&gt;(event), CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked));
</del><span class="cx"> 
</span><ins>+    ASSERT(m_filterKeyEventCompletionHandler);
+    m_filterKeyEventCompletionHandler(CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked);
+    m_filterKeyEventCompletionHandler = nullptr;
+
</ins><span class="cx">     if (resultsToSend &amp; Composition &amp;&amp; !m_confirmedComposition.isNull())
</span><span class="cx">         m_page-&gt;confirmComposition(m_confirmedComposition, -1, 0);
</span><span class="cx"> 
</span><span class="lines">@@ -144,13 +149,14 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InputMethodFilter::filterKeyEvent(GdkEventKey* event)
</del><ins>+void InputMethodFilter::filterKeyEvent(GdkEventKey* event, FilterKeyEventCompletionHandler&amp;&amp; completionHandler)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(API_TESTS)
</span><span class="cx">     ASSERT(m_page || m_testingMode);
</span><span class="cx"> #else
</span><span class="cx">     ASSERT(m_page);
</span><span class="cx"> #endif
</span><ins>+    m_filterKeyEventCompletionHandler = WTF::move(completionHandler);
</ins><span class="cx">     if (!m_enabled) {
</span><span class="cx">         handleKeyboardEvent(event);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkInputMethodFilterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> typedef struct _GtkIMContext GtkIMContext;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+class CompositionResults;
</ins><span class="cx"> class IntRect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -54,7 +55,8 @@
</span><span class="cx">     void setEnabled(bool);
</span><span class="cx">     void setCursorRect(const WebCore::IntRect&amp;);
</span><span class="cx"> 
</span><del>-    void filterKeyEvent(GdkEventKey*);
</del><ins>+    using FilterKeyEventCompletionHandler = std::function&lt;void (const WebCore::CompositionResults&amp;, InputMethodFilter::EventFakedForComposition)&gt;;
+    void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&amp;&amp; = nullptr);
</ins><span class="cx">     void notifyFocusedIn();
</span><span class="cx">     void notifyFocusedOut();
</span><span class="cx">     void notifyMouseButtonPress();
</span><span class="lines">@@ -111,6 +113,8 @@
</span><span class="cx">     String m_confirmedComposition;
</span><span class="cx">     String m_preedit;
</span><span class="cx"> 
</span><ins>+    FilterKeyEventCompletionHandler m_filterKeyEventCompletionHandler;
+
</ins><span class="cx"> #if ENABLE(API_TESTS)
</span><span class="cx">     bool m_testingMode;
</span><span class="cx">     Vector&lt;String&gt; m_events;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;NativeWebKeyboardEvent.h&quot;
</del><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &quot;PageClientImpl.h&quot;
</span><span class="cx"> #include &quot;WebKitWebViewBasePrivate.h&quot;
</span><span class="lines">@@ -53,14 +52,6 @@
</span><span class="cx">     return WebCore::standardUserAgent(applicationNameForUserAgent);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::getEditorCommandsForKeyEvent(const AtomicString&amp; eventType, Vector&lt;WTF::String&gt;&amp; commandsList)
-{
-    // When the keyboard event is started in the WebProcess side (e.g. from the Inspector)
-    // it will arrive without a GdkEvent associated, so the keyEventQueue will be empty.
-    if (!m_keyEventQueue.isEmpty())
-        m_pageClient.getEditorCommandsForKeyEvent(m_keyEventQueue.first(), eventType, commandsList);
-}
-
</del><span class="cx"> void WebPageProxy::bindAccessibilityTree(const String&amp; plugID)
</span><span class="cx"> {
</span><span class="cx">     m_accessibilityPlugID = plugID;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (185414 => 185415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2015-06-10 13:32:22 UTC (rev 185415)
</span><span class="lines">@@ -21,16 +21,13 @@
</span><span class="cx"> #include &quot;WebEditorClient.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformKeyboardEvent.h&quot;
</span><del>-#include &quot;WebPage.h&quot;
-#include &quot;WebPageProxyMessages.h&quot;
-#include &quot;WebProcess.h&quot;
</del><span class="cx"> #include &lt;WebCore/DataObjectGtk.h&gt;
</span><span class="cx"> #include &lt;WebCore/Document.h&gt;
</span><ins>+#include &lt;WebCore/Editor.h&gt;
</ins><span class="cx"> #include &lt;WebCore/Frame.h&gt;
</span><span class="cx"> #include &lt;WebCore/FrameDestructionObserver.h&gt;
</span><span class="cx"> #include &lt;WebCore/KeyboardEvent.h&gt;
</span><span class="cx"> #include &lt;WebCore/Pasteboard.h&gt;
</span><del>-#include &lt;WebCore/WindowsKeyboardCodes.h&gt;
</del><span class="cx"> #include &lt;WebCore/markup.h&gt;
</span><span class="cx"> #include &lt;wtf/gobject/GRefPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -38,17 +35,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, Vector&lt;WTF::String&gt;&amp; pendingEditorCommands)
-{
-    ASSERT(event-&gt;type() == eventNames().keydownEvent || event-&gt;type() == eventNames().keypressEvent);
-
-    /* First try to interpret the command in the UI and get the commands.
-       UI needs to receive event type because only knows current NativeWebKeyboardEvent.*/
-    WebProcess::singleton().parentProcessConnection()-&gt;sendSync(Messages::WebPageProxy::GetEditorCommandsForKeyEvent(event-&gt;type()),
-                                                Messages::WebPageProxy::GetEditorCommandsForKeyEvent::Reply(pendingEditorCommands),
-                                                m_page-&gt;pageID(), std::chrono::milliseconds::max());
-}
-
</del><span class="cx"> bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector&lt;WTF::String&gt;&amp; pendingEditorCommands, bool allowTextInsertion)
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;Editor::Command&gt; commands;
</span><span class="lines">@@ -70,21 +56,20 @@
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
</span><span class="cx"> {
</span><del>-    Node* node = event-&gt;target()-&gt;toNode();
-    ASSERT(node);
-    Frame* frame = node-&gt;document().frame();
-    ASSERT(frame);
-
</del><span class="cx">     const PlatformKeyboardEvent* platformEvent = event-&gt;keyEvent();
</span><span class="cx">     if (!platformEvent)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // If this was an IME event don't do anything.
</span><del>-    if (platformEvent-&gt;windowsVirtualKeyCode() == VK_PROCESSKEY)
</del><ins>+    if (platformEvent-&gt;handledByInputMethod())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    Vector&lt;WTF::String&gt; pendingEditorCommands;
-    getEditorCommandsForKeyEvent(event, pendingEditorCommands);
</del><ins>+    Node* node = event-&gt;target()-&gt;toNode();
+    ASSERT(node);
+    Frame* frame = node-&gt;document().frame();
+    ASSERT(frame);
+
+    const Vector&lt;String&gt; pendingEditorCommands = platformEvent-&gt;commands();
</ins><span class="cx">     if (!pendingEditorCommands.isEmpty()) {
</span><span class="cx"> 
</span><span class="cx">         // During RawKeyDown events if an editor command will insert text, defer
</span><span class="lines">@@ -129,8 +114,8 @@
</span><span class="cx"> void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
</span><span class="cx"> {
</span><span class="cx">     const PlatformKeyboardEvent* platformEvent = event-&gt;keyEvent();
</span><del>-    if (platformEvent &amp;&amp; platformEvent-&gt;windowsVirtualKeyCode() == VK_PROCESSKEY)
-        event-&gt;preventDefault();
</del><ins>+    if (platformEvent &amp;&amp; platformEvent-&gt;handledByInputMethod())
+        event-&gt;setDefaultHandled();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(X11)
</span></span></pre>
</div>
</div>

</body>
</html>