<!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>[186888] trunk</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>[GTK] Input method filter is always enabled when the view is focused
https://bugs.webkit.org/show_bug.cgi?id=146965

Reviewed by Martin Robinson.

Source/WebKit2:

It should only be enabled when the view is focused and there's an
editable element focused. In <a href="http://trac.webkit.org/projects/webkit/changeset/138544">r138544</a>, when input methods were
implemented, the message SetInputMethodState was added, but it was
never used. Instead, the notifyFocusIn method of the IM filter
enables the input method unconditionally. We should actually use
the SetInputMethodState message to enable/disable input methods
when editable elements are focused/unfocused.

* UIProcess/gtk/InputMethodFilter.cpp:
(WebKit::InputMethodFilter::setEnabled): Call notifyFocusedIn/Out
when inputs methods are enabled/disabled instead of notifying the
IM context directly.
(WebKit::InputMethodFilter::setCursorRect): Do not update the
cursor position if input methods are didabled.
(WebKit::InputMethodFilter::notifyFocusedIn): Do nothing when
input methods are disabled. Do not enable input methods
uncontionally here.
(WebKit::InputMethodFilter::notifyFocusedOut): Do not disable
input methods uncontionally here.
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::setInputMethodState): Call
WebPage::setInputMethodState() for GTK platform.
* WebProcess/WebPage/WebPage.h: Add setInputMethodState() for GTK platform.
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::setInputMethodState): Update input method state
and send SetInputMethodState message to the UI process if state changed.

Tools:

Use setEnabled() instead of notifyFocusedIn() to enable input methods.

* TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp:
(TestWebKitAPI::TestInputMethodFilter::TestInputMethodFilter):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkInputMethodFiltercpp">trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2gtkInputMethodFiltercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Source/WebKit2/ChangeLog        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2015-07-15  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Input method filter is always enabled when the view is focused
+        https://bugs.webkit.org/show_bug.cgi?id=146965
+
+        Reviewed by Martin Robinson.
+
+        It should only be enabled when the view is focused and there's an
+        editable element focused. In r138544, when input methods were
+        implemented, the message SetInputMethodState was added, but it was
+        never used. Instead, the notifyFocusIn method of the IM filter
+        enables the input method unconditionally. We should actually use
+        the SetInputMethodState message to enable/disable input methods
+        when editable elements are focused/unfocused.
+
+        * UIProcess/gtk/InputMethodFilter.cpp:
+        (WebKit::InputMethodFilter::setEnabled): Call notifyFocusedIn/Out
+        when inputs methods are enabled/disabled instead of notifying the
+        IM context directly.
+        (WebKit::InputMethodFilter::setCursorRect): Do not update the
+        cursor position if input methods are didabled.
+        (WebKit::InputMethodFilter::notifyFocusedIn): Do nothing when
+        input methods are disabled. Do not enable input methods
+        uncontionally here.
+        (WebKit::InputMethodFilter::notifyFocusedOut): Do not disable
+        input methods uncontionally here.
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::setInputMethodState): Call
+        WebPage::setInputMethodState() for GTK platform.
+        * WebProcess/WebPage/WebPage.h: Add setInputMethodState() for GTK platform.
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::setInputMethodState): Update input method state
+        and send SetInputMethodState message to the UI process if state changed.
+
</ins><span class="cx"> 2015-07-15  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r186088): Crash under WebKit::WebPageProxy::didFailLoadForFrame
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkInputMethodFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -85,16 +85,21 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_page);
</span><span class="cx"> 
</span><ins>+    // Notify focus out before changing the m_enabled.
+    if (!enabled)
+        notifyFocusedOut();
</ins><span class="cx">     m_enabled = enabled;
</span><span class="cx">     if (enabled)
</span><del>-        gtk_im_context_focus_in(m_context.get());
-    else
-        gtk_im_context_focus_out(m_context.get());
</del><ins>+        notifyFocusedIn();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InputMethodFilter::setCursorRect(const IntRect&amp; cursorRect)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_page);
</span><ins>+
+    if (!m_enabled)
+        return;
+
</ins><span class="cx">     // Don't move the window unless the cursor actually moves more than 10
</span><span class="cx">     // pixels. This prevents us from making the window flash during minor
</span><span class="cx">     // cursor adjustments.
</span><span class="lines">@@ -263,7 +268,9 @@
</span><span class="cx"> #else
</span><span class="cx">     ASSERT(m_page);
</span><span class="cx"> #endif
</span><del>-    m_enabled = true;
</del><ins>+    if (!m_enabled)
+        return;
+
</ins><span class="cx">     gtk_im_context_focus_in(m_context.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -280,7 +287,6 @@
</span><span class="cx">     confirmCurrentComposition();
</span><span class="cx">     cancelContextComposition();
</span><span class="cx">     gtk_im_context_focus_out(m_context.get());
</span><del>-    m_enabled = false;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InputMethodFilter::notifyMouseButtonPress()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -522,9 +522,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::setInputMethodState(bool)
</del><ins>+void WebEditorClient::setInputMethodState(bool enabled)
</ins><span class="cx"> {
</span><ins>+#if PLATFORM(GTK)
+    m_page-&gt;setInputMethodState(enabled);
+#else
</ins><span class="cx">     notImplemented();
</span><ins>+    UNUSED_PARAM(enabled);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebEditorClient::supportsGlobalSelection()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -897,6 +897,10 @@
</span><span class="cx">     void postMessage(const String&amp; messageName, API::Object* messageBody);
</span><span class="cx">     void postSynchronousMessage(const String&amp; messageName, API::Object* messageBody, RefPtr&lt;API::Object&gt;&amp; returnData);
</span><span class="cx"> 
</span><ins>+#if PLATFORM(GTK)
+    void setInputMethodState(bool);
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     WebPage(uint64_t pageID, const WebPageCreationParameters&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -1388,6 +1392,10 @@
</span><span class="cx">     bool m_mainFrameProgressCompleted;
</span><span class="cx">     bool m_shouldDispatchFakeMouseMoveEvents;
</span><span class="cx">     bool m_isEditorStateMissingPostLayoutData { false };
</span><ins>+
+#if PLATFORM(GTK)
+    bool m_inputMethodEnabled { false };
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -176,4 +176,13 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void WebPage::setInputMethodState(bool enabled)
+{
+    if (m_inputMethodEnabled == enabled)
+        return;
+
+    m_inputMethodEnabled = enabled;
+    send(Messages::WebPageProxy::SetInputMethodState(enabled));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Tools/ChangeLog        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-07-15  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Input method filter is always enabled when the view is focused
+        https://bugs.webkit.org/show_bug.cgi?id=146965
+
+        Reviewed by Martin Robinson.
+
+        Use setEnabled() instead of notifyFocusedIn() to enable input methods.
+
+        * TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp:
+        (TestWebKitAPI::TestInputMethodFilter::TestInputMethodFilter):
+
</ins><span class="cx"> 2015-07-15  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Bump libseccomp version to 2.2.3
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2gtkInputMethodFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp (186887 => 186888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp        2015-07-16 04:03:11 UTC (rev 186887)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/gtk/InputMethodFilter.cpp        2015-07-16 05:31:55 UTC (rev 186888)
</span><span class="lines">@@ -47,8 +47,7 @@
</span><span class="cx">         gtk_widget_show(m_testWindow);
</span><span class="cx">         gtk_im_context_set_client_window(context(), gtk_widget_get_window(m_testWindow));
</span><span class="cx"> 
</span><del>-        // Focus in is necessary to activate the default input method in the multicontext.
-        notifyFocusedIn();
</del><ins>+        setEnabled(true);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ~TestInputMethodFilter()
</span></span></pre>
</div>
</div>

</body>
</html>