Title: [253914] trunk/Source/WebKit
Revision
253914
Author
[email protected]
Date
2019-12-26 02:12:24 -0800 (Thu, 26 Dec 2019)

Log Message

[GTK][WPE] Remove duplicated code
https://bugs.webkit.org/show_bug.cgi?id=205560

Reviewed by Sergio Villar Senin.

Remove duplicated code related to IME between GTK and WPE that can be shared.

* SourcesGTK.txt:
* SourcesWPE.txt:
* WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp: Added.
(WebKit::WebEditorClient::handleInputMethodKeydown):
(WebKit::WebEditorClient::didDispatchInputMethodKeydown):
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
* WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
* WebProcess/WebPage/glib/WebPageGLib.cpp:
(WebKit::WebPage::setInputMethodState):
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
* WebProcess/WebPage/wpe/WebPageWPE.cpp:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (253913 => 253914)


--- trunk/Source/WebKit/ChangeLog	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/ChangeLog	2019-12-26 10:12:24 UTC (rev 253914)
@@ -1,3 +1,24 @@
+2019-12-26  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Remove duplicated code
+        https://bugs.webkit.org/show_bug.cgi?id=205560
+
+        Reviewed by Sergio Villar Senin.
+
+        Remove duplicated code related to IME between GTK and WPE that can be shared.
+
+        * SourcesGTK.txt:
+        * SourcesWPE.txt:
+        * WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp: Added.
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        (WebKit::WebEditorClient::didDispatchInputMethodKeydown):
+        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+        * WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
+        * WebProcess/WebPage/glib/WebPageGLib.cpp:
+        (WebKit::WebPage::setInputMethodState):
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        * WebProcess/WebPage/wpe/WebPageWPE.cpp:
+
 2019-12-24  Eric Carlson  <[email protected]>
 
         [Media in GPU process] Enable media player proxy logging

Modified: trunk/Source/WebKit/SourcesGTK.txt (253913 => 253914)


--- trunk/Source/WebKit/SourcesGTK.txt	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/SourcesGTK.txt	2019-12-26 10:12:24 UTC (rev 253914)
@@ -398,6 +398,8 @@
 
 WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp @no-unify
 
+WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp
+
 WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp
 WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
 WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp

Modified: trunk/Source/WebKit/SourcesWPE.txt (253913 => 253914)


--- trunk/Source/WebKit/SourcesWPE.txt	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/SourcesWPE.txt	2019-12-26 10:12:24 UTC (rev 253914)
@@ -238,6 +238,8 @@
 
 WebProcess/Plugins/Netscape/NetscapePluginNone.cpp @no-unify
 
+WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp
+
 WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
 
 WebProcess/WebCoreSupport/wpe/WebContextMenuClientWPE.cpp

Added: trunk/Source/WebKit/WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp (0 => 253914)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 2019 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2 of
+ *  the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "WebEditorClient.h"
+
+#include <WebCore/Document.h>
+#include <WebCore/Editor.h>
+#include <WebCore/Frame.h>
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/PlatformKeyboardEvent.h>
+#include <WebPage.h>
+
+namespace WebKit {
+using namespace WebCore;
+
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
+{
+    auto* platformEvent = event.underlyingPlatformEvent();
+    if (platformEvent && platformEvent->handledByInputMethod())
+        event.setDefaultHandled();
+}
+
+void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event)
+{
+    auto* platformEvent = event.underlyingPlatformEvent();
+    ASSERT(event.target());
+    auto* frame = downcast<Node>(event.target())->document().frame();
+    ASSERT(frame);
+
+    if (const auto& underlines = platformEvent->preeditUnderlines()) {
+        auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0);
+        auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0);
+        frame->editor().setComposition(platformEvent->text(), underlines.value(), rangeStart, rangeStart + rangeLength);
+    } else
+        frame->editor().confirmComposition(platformEvent->text());
+}
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (253913 => 253914)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -132,28 +132,6 @@
         event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
-{
-    auto* platformEvent = event.underlyingPlatformEvent();
-    if (platformEvent && platformEvent->handledByInputMethod())
-        event.setDefaultHandled();
-}
-
-void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event)
-{
-    auto* platformEvent = event.underlyingPlatformEvent();
-    ASSERT(event.target());
-    auto* frame = downcast<Node>(event.target())->document().frame();
-    ASSERT(frame);
-
-    if (const auto& underlines = platformEvent->preeditUnderlines()) {
-        auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0);
-        auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0);
-        frame->editor().setComposition(platformEvent->text(), underlines.value(), rangeStart, rangeStart + rangeLength);
-    } else
-        frame->editor().confirmComposition(platformEvent->text());
-}
-
 void WebEditorClient::updateGlobalSelection(Frame* frame)
 {
     if (!frame->selection().isRange())

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp (253913 => 253914)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -234,26 +234,4 @@
         return handleKeyDown(*frame, event, *platformEvent);
 }
 
-void WebEditorClient::handleInputMethodKeydown(WebCore::KeyboardEvent& event)
-{
-    auto* platformEvent = event.underlyingPlatformEvent();
-    if (platformEvent && platformEvent->handledByInputMethod())
-        event.setDefaultHandled();
-}
-
-void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event)
-{
-    auto* platformEvent = event.underlyingPlatformEvent();
-    ASSERT(event.target());
-    auto* frame = downcast<Node>(event.target())->document().frame();
-    ASSERT(frame);
-
-    if (const auto& underlines = platformEvent->preeditUnderlines()) {
-        auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0);
-        auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0);
-        frame->editor().setComposition(platformEvent->text(), underlines.value(), rangeStart, rangeStart + rangeLength);
-    } else
-        frame->editor().confirmComposition(platformEvent->text());
-}
-
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp (253913 => 253914)


--- trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -31,6 +31,7 @@
 #include "WebKitUserMessage.h"
 #include "WebKitWebExtension.h"
 #include "WebKitWebPagePrivate.h"
+#include "WebPageProxyMessages.h"
 
 namespace WebKit {
 
@@ -56,4 +57,13 @@
     sendMessageToWebExtensionWithReply(WTFMove(message), [](UserMessage&&) { });
 }
 
+void WebPage::setInputMethodState(bool enabled)
+{
+    if (m_inputMethodEnabled == enabled)
+        return;
+
+    m_inputMethodEnabled = enabled;
+    send(Messages::WebPageProxy::SetInputMethodState(enabled));
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (253913 => 253914)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -174,15 +174,6 @@
     completionHandler(WTFMove(result));
 }
 
-void WebPage::setInputMethodState(bool enabled)
-{
-    if (m_inputMethodEnabled == enabled)
-        return;
-
-    m_inputMethodEnabled = enabled;
-    send(Messages::WebPageProxy::SetInputMethodState(enabled));
-}
-
 void WebPage::collapseSelectionInFrame(FrameIdentifier frameID)
 {
     WebFrame* frame = WebProcess::singleton().webFrame(frameID);

Modified: trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp (253913 => 253914)


--- trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2019-12-26 10:11:15 UTC (rev 253913)
+++ trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2019-12-26 10:12:24 UTC (rev 253914)
@@ -92,13 +92,4 @@
     return String();
 }
 
-void WebPage::setInputMethodState(bool enabled)
-{
-    if (m_inputMethodEnabled == enabled)
-        return;
-
-    m_inputMethodEnabled = enabled;
-    send(Messages::WebPageProxy::SetInputMethodState(enabled));
-}
-
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to