Diff
Modified: trunk/Source/WebCore/ChangeLog (251649 => 251650)
--- trunk/Source/WebCore/ChangeLog 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebCore/ChangeLog 2019-10-28 09:24:57 UTC (rev 251650)
@@ -1,3 +1,19 @@
+2019-10-28 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Simplify the Input Method implementation
+ https://bugs.webkit.org/show_bug.cgi?id=203149
+
+ Reviewed by Adrian Perez de Castro.
+
+ Remove CompositionResults and remove dead code in PlatformKeyboardEventGtk.
+
+ * PlatformGTK.cmake:
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ * platform/gtk/CompositionResults.h: Removed.
+ * platform/gtk/PlatformKeyboardEventGtk.cpp:
+ (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent):
+
2019-10-27 Antoine Quint <grao...@apple.com>
[Web Animations] getKeyframes() doesn't return the right timing function for declarative animations
Modified: trunk/Source/WebCore/PlatformGTK.cmake (251649 => 251650)
--- trunk/Source/WebCore/PlatformGTK.cmake 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2019-10-28 09:24:57 UTC (rev 251650)
@@ -48,7 +48,6 @@
platform/graphics/x11/XUniquePtr.h
platform/graphics/x11/XUniqueResource.h
- platform/gtk/CompositionResults.h
platform/gtk/GRefPtrGtk.h
platform/gtk/GUniquePtrGtk.h
platform/gtk/GtkUtilities.h
Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (251649 => 251650)
--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -40,11 +40,6 @@
OBJC_CLASS WebEvent;
#endif
-#if PLATFORM(GTK)
-typedef struct _GdkEventKey GdkEventKey;
-#include "CompositionResults.h"
-#endif
-
namespace WebCore {
class PlatformKeyboardEvent : public PlatformEvent {
@@ -56,9 +51,6 @@
, m_autoRepeat(false)
, m_isKeypad(false)
, m_isSystemKey(false)
-#if PLATFORM(GTK)
- , m_gdkEventKey(0)
-#endif
{
}
@@ -150,10 +142,6 @@
#endif
#if PLATFORM(GTK)
- PlatformKeyboardEvent(GdkEventKey*, const CompositionResults&);
- GdkEventKey* gdkEventKey() const { return m_gdkEventKey; }
- const CompositionResults& compositionResults() const { return m_compositionResults; }
-
// Used by WebKit2
static String keyValueForGdkKeyCode(unsigned);
static String keyCodeForHardwareKeyCode(unsigned);
@@ -203,11 +191,6 @@
RetainPtr<::WebEvent> m_Event;
#endif
#endif
-#if PLATFORM(GTK)
- GdkEventKey* m_gdkEventKey;
- CompositionResults m_compositionResults;
-#endif
-
// The modifier state is optional, since it is not needed in the UI process or in legacy WebKit.
static Optional<OptionSet<Modifier>> s_currentModifiers;
};
Deleted: trunk/Source/WebCore/platform/gtk/CompositionResults.h (251649 => 251650)
--- trunk/Source/WebCore/platform/gtk/CompositionResults.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebCore/platform/gtk/CompositionResults.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CompositionResults_h
-#define CompositionResults_h
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-struct CompositionResults {
- CompositionResults()
- : associatedWithPendingCompositionUpdate(false)
- {
- }
-
- CompositionResults(String simpleString)
- : simpleString(simpleString)
- , associatedWithPendingCompositionUpdate(false)
- {
- }
-
- enum ResultsIndicator { WillSendCompositionResultsSoon };
- CompositionResults(ResultsIndicator)
- : associatedWithPendingCompositionUpdate(true)
- {
- }
-
- bool compositionUpdated() const
- {
- return associatedWithPendingCompositionUpdate;
- }
-
- // Some simple input methods return a string for all keyboard events. This
- // value should be treated as the string representation of the keycode.
- String simpleString;
-
- bool associatedWithPendingCompositionUpdate;
-};
-
-}
-
-#endif // CompositionResults_h
Modified: trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp (251649 => 251650)
--- trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -1321,59 +1321,6 @@
}
}
-static PlatformEvent::Type eventTypeForGdkKeyEvent(GdkEventKey* event)
-{
- return gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? PlatformEvent::KeyUp : PlatformEvent::KeyDown;
-}
-
-static OptionSet<PlatformEvent::Modifier> modifiersForGdkKeyEvent(GdkEventKey* event)
-{
- GdkModifierType state;
- gdk_event_get_state(reinterpret_cast<GdkEvent*>(event), &state);
- guint keyval;
- gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
-
- OptionSet<PlatformEvent::Modifier> modifiers;
- if (state & GDK_SHIFT_MASK || keyval == GDK_KEY_3270_BackTab)
- modifiers.add(PlatformEvent::Modifier::ShiftKey);
- if (state & GDK_CONTROL_MASK)
- modifiers.add(PlatformEvent::Modifier::ControlKey);
- if (state & GDK_MOD1_MASK)
- modifiers.add(PlatformEvent::Modifier::AltKey);
- if (state & GDK_META_MASK)
- modifiers.add(PlatformEvent::Modifier::MetaKey);
- if (state & GDK_LOCK_MASK)
- modifiers.add(PlatformEvent::Modifier::CapsLockKey);
- return modifiers;
-}
-
-// Keep this in sync with the other platform event constructors
-PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event, const CompositionResults& compositionResults)
- : PlatformEvent(eventTypeForGdkKeyEvent(event), modifiersForGdkKeyEvent(event), wallTimeForEvent(event))
- , m_handledByInputMethod(false)
- , m_autoRepeat(false)
- , m_isSystemKey(false)
- , m_gdkEventKey(event)
- , m_compositionResults(compositionResults)
-{
- guint keyval;
- gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
- guint16 keycode;
- gdk_event_get_keycode(reinterpret_cast<GdkEvent*>(event), &keycode);
-
- m_text = compositionResults.simpleString.length() ? compositionResults.simpleString : singleCharacterString(keyval);
- m_unmodifiedText = m_text;
- m_key = keyValueForGdkKeyCode(keyval);
- m_code = keyCodeForHardwareKeyCode(keycode);
- m_keyIdentifier = keyIdentifierForGdkKeyCode(keyval);
- m_windowsVirtualKeyCode = windowsKeyCodeForGdkKeyCode(keyval);
- m_isKeypad = keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9;
-
- // To match the behavior of IE, we return VK_PROCESSKEY for keys that triggered composition results.
- if (compositionResults.compositionUpdated())
- m_windowsVirtualKeyCode = VK_PROCESSKEY;
-}
-
void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
{
// Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
@@ -1386,7 +1333,7 @@
if (type == PlatformEvent::RawKeyDown) {
m_text = String();
m_unmodifiedText = String();
- } else if (type == PlatformEvent::Char && m_compositionResults.compositionUpdated()) {
+ } else if (type == PlatformEvent::Char && m_handledByInputMethod) {
// Having empty text, prevents this Char (which is a DOM keypress) event
// from going to the DOM. Keys that trigger composition events should not
// fire keypress.
Modified: trunk/Source/WebKit/ChangeLog (251649 => 251650)
--- trunk/Source/WebKit/ChangeLog 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/ChangeLog 2019-10-28 09:24:57 UTC (rev 251650)
@@ -1,3 +1,47 @@
+2019-10-28 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Simplify the Input Method implementation
+ https://bugs.webkit.org/show_bug.cgi?id=203149
+
+ Reviewed by Adrian Perez de Castro.
+
+ * Shared/NativeWebKeyboardEvent.h: Stop using WebCore::CompositionResults.
+ (WebKit::NativeWebKeyboardEvent::text const):
+ (WebKit::NativeWebKeyboardEvent::handledByInputMethod const):
+ (WebKit::NativeWebKeyboardEvent::fakedForComposition const):
+ * Shared/gtk/NativeWebKeyboardEventGtk.cpp: Ditto.
+ (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
+ * Shared/gtk/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebKeyboardEvent): Ditto.
+ * Shared/gtk/WebEventFactory.h:
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::doneWithKeyEvent): Updated to use the new name.
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp: Stop using WebCore::CompositionResults.
+ (webkitWebViewBaseKeyPressEvent):
+ (webkitWebViewBaseKeyReleaseEvent):
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Remove unused function.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setComposition): Use EditingRange instead of two integers and remove replacement range
+ that is unused.
+ (WebKit::WebPageProxy::confirmComposition): Remove unused selection range parameters.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/gtk/InputMethodFilter.cpp:
+ (WebKit::InputMethodFilter::handleKeyboardEvent):
+ (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults):
+ (WebKit::InputMethodFilter::confirmComposition):
+ (WebKit::InputMethodFilter::updatePreedit):
+ (WebKit::InputMethodFilter::confirmCurrentComposition):
+ (WebKit::InputMethodFilter::sendCompositionAndPreeditWithFakeKeyEvents):
+ (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting):
+ (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting):
+ * UIProcess/gtk/InputMethodFilter.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::targetFrameForEditing): Receive a reference instead of a pointer.
+ (WebKit::WebPage::confirmComposition): Remove the unused code to handle the selection range.
+ (WebKit::WebPage::setComposition): Remove the unused code to handle the replacement range.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2019-10-27 Fujii Hironori <hironori.fu...@sony.com>
Unreviewed build fix for !ENABLE(MEDIA_STREAM) builds
Modified: trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h (251649 => 251650)
--- trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -41,8 +41,6 @@
#endif
#if PLATFORM(GTK)
-#include "InputMethodFilter.h"
-#include <WebCore/CompositionResults.h>
#include <WebCore/GUniquePtrGtk.h>
typedef union _GdkEvent GdkEvent;
#endif
@@ -69,7 +67,9 @@
NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&);
#elif PLATFORM(GTK)
NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
- NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
+ enum class HandledByInputMethod : bool { No, Yes };
+ enum class FakedForComposition : bool { No, Yes };
+ NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, FakedForComposition, Vector<String>&& commands);
#elif PLATFORM(IOS_FAMILY)
enum class HandledByInputMethod : bool { No, Yes };
NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod);
@@ -83,8 +83,9 @@
NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(GTK)
GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
- const WebCore::CompositionResults& compositionResults() const { return m_compositionResults; }
- bool isFakeEventForComposition() const { return m_fakeEventForComposition; }
+ const String& text() const { return m_text; }
+ bool handledByInputMethod() const { return m_handledByInputMethod == HandledByInputMethod::Yes; }
+ bool fakedForComposition() const { return m_fakedForComposition == FakedForComposition::Yes; }
#elif PLATFORM(IOS_FAMILY)
::WebEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(WIN)
@@ -98,8 +99,9 @@
RetainPtr<NSEvent> m_nativeEvent;
#elif PLATFORM(GTK)
GUniquePtr<GdkEvent> m_nativeEvent;
- WebCore::CompositionResults m_compositionResults;
- bool m_fakeEventForComposition;
+ String m_text;
+ HandledByInputMethod m_handledByInputMethod;
+ FakedForComposition m_fakedForComposition;
#elif PLATFORM(IOS_FAMILY)
RetainPtr<::WebEvent> m_nativeEvent;
#elif PLATFORM(WIN)
Modified: trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp (251649 => 251650)
--- trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -32,21 +32,22 @@
#include <gdk/gdk.h>
namespace WebKit {
-using namespace WebCore;
-NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTFMove(commands)))
+NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, FakedForComposition fakedForComposition, Vector<String>&& commands)
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(commands)))
, m_nativeEvent(gdk_event_copy(event))
- , m_compositionResults(compositionResults)
- , m_fakeEventForComposition(faked == InputMethodFilter::EventFaked)
+ , m_text(text)
+ , m_handledByInputMethod(handledByInputMethod)
+ , m_fakedForComposition(fakedForComposition)
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands())))
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Vector<String>(event.commands())))
, m_nativeEvent(gdk_event_copy(event.nativeEvent()))
- , m_compositionResults(event.compositionResults())
- , m_fakeEventForComposition(event.isFakeEventForComposition())
+ , m_text(event.text())
+ , m_handledByInputMethod(event.handledByInputMethod() ? HandledByInputMethod::Yes : HandledByInputMethod::No)
+ , m_fakedForComposition(event.fakedForComposition() ? FakedForComposition::Yes : FakedForComposition::No)
{
}
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (251649 => 251650)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -249,7 +249,7 @@
wallTimeForEvent(event));
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Vector<String>&& commands)
{
guint keyval;
gdk_event_get_keyval(event, &keyval);
@@ -259,13 +259,13 @@
return WebKeyboardEvent(
type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
- compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyval),
+ text.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : text,
PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
static_cast<int>(keyval),
- compositionResults.compositionUpdated(),
+ handledByInputMethod,
WTFMove(commands),
isGdkKeyCodeFromKeyPad(keyval),
modifiersForEvent(event),
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.h (251649 => 251650)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -24,11 +24,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebEventFactory_h
-#define WebEventFactory_h
+#pragma once
#include "WebEvent.h"
-#include <WebCore/CompositionResults.h>
typedef union _GdkEvent GdkEvent;
@@ -39,7 +37,7 @@
static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
static WebWheelEvent createWebWheelEvent(const GdkEvent*);
static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
- static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&, Vector<String>&& commands);
+ static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Vector<String>&& commands);
#if ENABLE(TOUCH_EVENTS)
static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
#endif
@@ -46,5 +44,3 @@
};
} // namespace WebKit
-
-#endif // WebEventFactory_h
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -224,7 +224,7 @@
{
if (wasEventHandled)
return;
- if (event.isFakeEventForComposition())
+ if (event.fakedForComposition())
return;
WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -784,9 +784,11 @@
// We need to copy the event as otherwise it could be destroyed before we reach the lambda body.
GUniquePtr<GdkEvent> event(gdk_event_copy(reinterpret_cast<GdkEvent*>(keyEvent)));
- priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
- priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), compositionResults, faked,
- !compositionResults.compositionUpdated() ? priv->keyBindingTranslator.commandsForKeyEvent(&event->key) : Vector<String>()));
+ priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const String& text, InputMethodFilter::EventHandledByInputMethod handled, InputMethodFilter::EventFakedForComposition faked) {
+ auto handledByInputMethod = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? NativeWebKeyboardEvent::HandledByInputMethod::Yes : NativeWebKeyboardEvent::HandledByInputMethod::No;
+ auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
+ auto commands = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? Vector<String>() : priv->keyBindingTranslator.commandsForKeyEvent(&event->key);
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), text, handledByInputMethod, fakedForComposition, WTFMove(commands)));
});
return GDK_EVENT_STOP;
@@ -804,8 +806,10 @@
// We need to copy the event as otherwise it could be destroyed before we reach the lambda body.
GUniquePtr<GdkEvent> event(gdk_event_copy(reinterpret_cast<GdkEvent*>(keyEvent)));
- priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
- priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), compositionResults, faked, { }));
+ priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const String& text, InputMethodFilter::EventHandledByInputMethod handled, InputMethodFilter::EventFakedForComposition faked) {
+ auto handledByInputMethod = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? NativeWebKeyboardEvent::HandledByInputMethod::Yes : NativeWebKeyboardEvent::HandledByInputMethod::No;
+ auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), text, handledByInputMethod, fakedForComposition, { }));
});
return GDK_EVENT_STOP;
@@ -1455,11 +1459,6 @@
return webkitWebViewBase;
}
-GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase* webkitWebViewBase)
-{
- return webkitWebViewBase->priv->inputMethodFilter.context();
-}
-
WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase* webkitWebViewBase)
{
return webkitWebViewBase->priv->pageProxy.get();
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -39,7 +39,6 @@
#include "WebPageProxy.h"
WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&);
-GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*);
WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, Ref<API::PageConfiguration>&&);
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -8020,30 +8020,22 @@
#endif
#if PLATFORM(GTK)
-void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
+void WebPageProxy::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
{
// FIXME: We need to find out how to proper handle the crashes case.
if (!hasRunningProcess())
return;
- process().send(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), m_webPageID);
+ process().send(Messages::WebPage::SetComposition(text, underlines, selectionRange), m_webPageID);
}
-void WebPageProxy::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
+void WebPageProxy::confirmComposition(const String& compositionString)
{
if (!hasRunningProcess())
return;
- process().send(Messages::WebPage::ConfirmComposition(compositionString, selectionStart, selectionLength), m_webPageID);
+ process().send(Messages::WebPage::ConfirmComposition(compositionString), m_webPageID);
}
-
-void WebPageProxy::cancelComposition()
-{
- if (!hasRunningProcess())
- return;
-
- process().send(Messages::WebPage::CancelComposition(), m_webPageID);
-}
#endif // PLATFORM(GTK)
void WebPageProxy::setScrollPinningBehavior(ScrollPinningBehavior pinning)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -787,9 +787,8 @@
bool updateLayoutViewportParameters(const WebKit::RemoteLayerTreeTransaction&);
#if PLATFORM(GTK)
- void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
- void confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength);
- void cancelComposition();
+ void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
+ void confirmComposition(const String& compositionString);
void setInputMethodState(bool enabled);
Modified: trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -23,7 +23,6 @@
#include "NativeWebKeyboardEvent.h"
#include "WebPageProxy.h"
#include <WebCore/Color.h>
-#include <WebCore/CompositionResults.h>
#include <WebCore/Editor.h>
#include <WebCore/GUniquePtrGtk.h>
#include <WebCore/IntRect.h>
@@ -145,10 +144,12 @@
#endif
if (m_filterKeyEventCompletionHandler) {
- m_filterKeyEventCompletionHandler(CompositionResults(simpleString), faked);
+ m_filterKeyEventCompletionHandler(simpleString, EventHandledByInputMethod::No, faked);
m_filterKeyEventCompletionHandler = nullptr;
- } else
- m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(simpleString), faked, Vector<String>()));
+ } else {
+ auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
+ m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), simpleString, NativeWebKeyboardEvent::HandledByInputMethod::No, fakedForComposition, Vector<String>()));
+ }
}
void InputMethodFilter::handleKeyboardEventWithCompositionResults(GdkEventKey* event, ResultsToSend resultsToSend, EventFakedForComposition faked)
@@ -161,16 +162,19 @@
#endif
if (m_filterKeyEventCompletionHandler) {
- m_filterKeyEventCompletionHandler(CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked);
+ m_filterKeyEventCompletionHandler({ }, EventHandledByInputMethod::Yes, faked);
m_filterKeyEventCompletionHandler = nullptr;
- } else
- m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked, Vector<String>()));
+ } else {
+ auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
+ m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes, fakedForComposition, Vector<String>()));
+ }
+
if (resultsToSend & Composition && !m_confirmedComposition.isNull())
- m_page->confirmComposition(m_confirmedComposition, -1, 0);
+ m_page->confirmComposition(m_confirmedComposition);
if (resultsToSend & Preedit && !m_preedit.isNull()) {
m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
- m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
+ EditingRange(m_cursorOffset, 1));
}
}
@@ -267,7 +271,7 @@
return;
}
#endif
- m_page->confirmComposition(m_confirmedComposition, -1, 0);
+ m_page->confirmComposition(m_confirmedComposition);
m_confirmedComposition = String();
}
@@ -281,7 +285,7 @@
#endif
// FIXME: We should parse the PangoAttrList that we get from the IM context here.
m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
- m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
+ EditingRange(m_cursorOffset, 1));
m_preeditChanged = false;
}
@@ -340,7 +344,7 @@
}
#endif
- m_page->confirmComposition(String(), -1, 0);
+ m_page->confirmComposition({ });
m_composingTextCurrently = false;
}
@@ -368,7 +372,7 @@
GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
event->key.time = GDK_CURRENT_TIME;
event->key.keyval = compositionEventKeyCode;
- handleKeyboardEventWithCompositionResults(&event->key, resultsToSend, EventFaked);
+ handleKeyboardEventWithCompositionResults(&event->key, resultsToSend, EventFakedForComposition::Yes);
m_confirmedComposition = String();
if (resultsToSend & Composition)
@@ -375,7 +379,7 @@
m_composingTextCurrently = false;
event->type = GDK_KEY_RELEASE;
- handleKeyboardEvent(&event->key, String(), EventFaked);
+ handleKeyboardEvent(&event->key, String(), EventFakedForComposition::Yes);
m_justSentFakeKeyUp = true;
}
@@ -450,7 +454,7 @@
guint keyval;
gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
const char* eventType = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? "release" : "press";
- const char* fakedString = faked == EventFaked ? " (faked)" : "";
+ const char* fakedString = faked == EventFakedForComposition::Yes ? " (faked)" : "";
if (!eventString.isNull())
m_events.append(makeString("sendSimpleKeyEvent type=", eventType, " keycode=", hex(keyval), " text='", eventString, '\'', fakedString));
else
@@ -462,7 +466,7 @@
guint keyval;
gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
const char* eventType = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? "release" : "press";
- const char* fakedString = faked == EventFaked ? " (faked)" : "";
+ const char* fakedString = faked == EventFakedForComposition::Yes ? " (faked)" : "";
m_events.append(makeString("sendKeyEventWithCompositionResults type=", eventType, " keycode=", hex(keyval), fakedString));
if (resultsToSend & Composition && !m_confirmedComposition.isNull())
Modified: trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.h (251649 => 251650)
--- trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -17,8 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef InputMethodFilter_h
-#define InputMethodFilter_h
+#pragma once
#include <WebCore/IntPoint.h>
#include <wtf/Function.h>
@@ -30,7 +29,6 @@
typedef struct _GtkIMContext GtkIMContext;
namespace WebCore {
-struct CompositionResults;
class IntRect;
}
@@ -41,10 +39,14 @@
class InputMethodFilter {
WTF_MAKE_NONCOPYABLE(InputMethodFilter);
public:
- enum EventFakedForComposition {
- EventFaked,
- EventNotFaked
+ enum class EventFakedForComposition {
+ No,
+ Yes
};
+ enum class EventHandledByInputMethod {
+ No,
+ Yes
+ };
InputMethodFilter();
~InputMethodFilter();
@@ -56,7 +58,7 @@
void setEnabled(bool);
void setCursorRect(const WebCore::IntRect&);
- using FilterKeyEventCompletionHandler = Function<void(const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition)>;
+ using FilterKeyEventCompletionHandler = Function<void(const String&, EventHandledByInputMethod, EventFakedForComposition)>;
void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&& = nullptr);
void notifyFocusedIn();
void notifyFocusedOut();
@@ -84,8 +86,8 @@
void handlePreeditStart();
void handlePreeditEnd();
- void handleKeyboardEvent(GdkEventKey*, const String& eventString = String(), EventFakedForComposition = EventNotFaked);
- void handleKeyboardEventWithCompositionResults(GdkEventKey*, ResultsToSend = PreeditAndComposition, EventFakedForComposition = EventNotFaked);
+ void handleKeyboardEvent(GdkEventKey*, const String& eventString = String(), EventFakedForComposition = EventFakedForComposition::No);
+ void handleKeyboardEventWithCompositionResults(GdkEventKey*, ResultsToSend = PreeditAndComposition, EventFakedForComposition = EventFakedForComposition::No);
void sendCompositionAndPreeditWithFakeKeyEvents(ResultsToSend);
void confirmComposition();
@@ -126,4 +128,3 @@
} // namespace WebKit
-#endif // InputMethodFilter_h
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (251649 => 251650)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-10-28 09:24:57 UTC (rev 251650)
@@ -5291,9 +5291,9 @@
#endif // PLATFORM(COCOA)
#if PLATFORM(GTK)
-static Frame* targetFrameForEditing(WebPage* page)
+static Frame* targetFrameForEditing(WebPage& page)
{
- Frame& targetFrame = page->corePage()->focusController().focusedOrMainFrame();
+ Frame& targetFrame = page.corePage()->focusController().focusedOrMainFrame();
Editor& editor = targetFrame.editor();
if (!editor.canEdit())
@@ -5312,63 +5312,21 @@
return &targetFrame;
}
-void WebPage::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
+void WebPage::confirmComposition(const String& compositionString)
{
- Frame* targetFrame = targetFrameForEditing(this);
- if (!targetFrame) {
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
- return;
- }
-
- targetFrame->editor().confirmComposition(compositionString);
-
- if (selectionStart == -1) {
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
- return;
- }
-
- Element* scope = targetFrame->selection().selection().rootEditableElement();
- RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(scope, selectionStart, selectionLength);
- ASSERT_WITH_MESSAGE(selectionRange, "Invalid selection: [%lld:%lld] in text of length %d", static_cast<long long>(selectionStart), static_cast<long long>(selectionLength), scope->innerText().length());
-
- if (selectionRange) {
- VisibleSelection selection(*selectionRange, SEL_DEFAULT_AFFINITY);
- targetFrame->selection().setSelection(selection);
- }
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
+ if (auto* targetFrame = targetFrameForEditing(*this))
+ targetFrame->editor().confirmComposition(compositionString);
}
-void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementStart, uint64_t replacementLength)
+void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
{
- Frame* targetFrame = targetFrameForEditing(this);
- if (!targetFrame || !targetFrame->selection().selection().isContentEditable()) {
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
+ Frame* targetFrame = targetFrameForEditing(*this);
+ if (!targetFrame || !targetFrame->selection().selection().isContentEditable())
return;
- }
Ref<Frame> protector(*targetFrame);
-
- if (replacementLength > 0) {
- // The layout needs to be uptodate before setting a selection
- targetFrame->document()->updateLayout();
-
- Element* scope = targetFrame->selection().selection().rootEditableElement();
- RefPtr<Range> replacementRange = TextIterator::rangeFromLocationAndLength(scope, replacementStart, replacementLength);
- targetFrame->editor().setIgnoreSelectionChanges(true);
- targetFrame->selection().setSelection(VisibleSelection(*replacementRange, SEL_DEFAULT_AFFINITY));
- targetFrame->editor().setIgnoreSelectionChanges(false);
- }
-
- targetFrame->editor().setComposition(text, underlines, selectionStart, selectionStart + selectionLength);
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
+ targetFrame->editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length);
}
-
-void WebPage::cancelComposition()
-{
- if (Frame* targetFrame = targetFrameForEditing(this))
- targetFrame->editor().cancelComposition();
- send(Messages::WebPageProxy::EditorStateChanged(editorState()));
-}
#endif
void WebPage::didApplyStyle()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (251649 => 251650)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-10-28 09:24:57 UTC (rev 251650)
@@ -773,9 +773,8 @@
SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
#if PLATFORM(GTK)
- void setComposition(const String& text, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength);
- void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
- void cancelComposition();
+ void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
+ void confirmComposition(const String& text);
void collapseSelectionInFrame(WebCore::FrameIdentifier);
void showEmojiPicker(WebCore::Frame&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (251649 => 251650)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-10-28 08:08:59 UTC (rev 251649)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-10-28 09:24:57 UTC (rev 251650)
@@ -411,9 +411,8 @@
SetCanRunModal(bool canRunModal)
#if PLATFORM(GTK)
- SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
- ConfirmComposition(String text, int64_t selectionStart, int64_t selectionLength)
- CancelComposition()
+ SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, struct WebKit::EditingRange selectionRange)
+ ConfirmComposition(String text)
CollapseSelectionInFrame(WebCore::FrameIdentifier frameID)