Diff
Modified: trunk/Source/WebCore/ChangeLog (253880 => 253881)
--- trunk/Source/WebCore/ChangeLog 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/ChangeLog 2019-12-23 09:19:50 UTC (rev 253881)
@@ -1,3 +1,33 @@
+2019-12-23 Carlos Garcia Campos <[email protected]>
+
+ [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load
+ https://bugs.webkit.org/show_bug.cgi?id=185248
+
+ Reviewed by Žan Doberšek.
+
+ Notify the editor when a key event handled by input method has been dispatched. This way we can handle the
+ composition results right after the event is dispatched.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::didDispatchInputMethodKeydown): Notify the client.
+ * editing/Editor.h:
+ * page/EditorClient.h:
+ (WebCore::EditorClient::didDispatchInputMethodKeydown): Added.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::internalKeyEvent): Call Editor::didDispatchInputMethodKeydown() for events handled by
+ input method right after the event is dispatched.
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::preeditUnderlines const):
+ (WebCore::PlatformKeyboardEvent::preeditSelectionRangeStart const):
+ (WebCore::PlatformKeyboardEvent::preeditSelectionRangeLength const):
+ * platform/gtk/PlatformKeyboardEventGtk.cpp:
+ (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): Return early if the event was handled by input
+ method and remove the special case for Char events handled by input method because this is never called with
+ Char type for events handled by input method.
+ * platform/libwpe/PlatformKeyboardEventLibWPE.cpp:
+ (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): Return early if the event was handled by input
+ method.
+
2019-12-22 Simon Fraser <[email protected]>
Very basic <dialog> show/close support
Modified: trunk/Source/WebCore/editing/Editor.cpp (253880 => 253881)
--- trunk/Source/WebCore/editing/Editor.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/editing/Editor.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -302,6 +302,12 @@
client->handleInputMethodKeydown(event);
}
+void Editor::didDispatchInputMethodKeydown(KeyboardEvent& event)
+{
+ if (auto* client = this->client())
+ client->didDispatchInputMethodKeydown(event);
+}
+
bool Editor::handleTextEvent(TextEvent& event)
{
LOG(Editing, "Editor %p handleTextEvent (data %s)", this, event.data().utf8().data());
Modified: trunk/Source/WebCore/editing/Editor.h (253880 => 253881)
--- trunk/Source/WebCore/editing/Editor.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/editing/Editor.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -151,6 +151,7 @@
void handleKeyboardEvent(KeyboardEvent&);
void handleInputMethodKeydown(KeyboardEvent&);
+ void didDispatchInputMethodKeydown(KeyboardEvent&);
bool handleTextEvent(TextEvent&);
WEBCORE_EXPORT bool canEdit() const;
Modified: trunk/Source/WebCore/page/EditorClient.h (253880 => 253881)
--- trunk/Source/WebCore/page/EditorClient.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/page/EditorClient.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -121,6 +121,7 @@
virtual void handleKeyboardEvent(KeyboardEvent&) = 0;
virtual void handleInputMethodKeydown(KeyboardEvent&) = 0;
+ virtual void didDispatchInputMethodKeydown(KeyboardEvent&) { }
virtual void textFieldDidBeginEditing(Element*) = 0;
virtual void textFieldDidEndEditing(Element*) = 0;
Modified: trunk/Source/WebCore/page/EventHandler.cpp (253880 => 253881)
--- trunk/Source/WebCore/page/EventHandler.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -3357,8 +3357,10 @@
#endif
element->dispatchEvent(keydown);
- if (handledByInputMethod)
+ if (handledByInputMethod) {
+ m_frame.editor().didDispatchInputMethodKeydown(keydown.get());
return true;
+ }
// If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame.
bool changedFocusedFrame = m_frame.page() && &m_frame != &m_frame.page()->focusController().focusedOrMainFrame();
Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (253880 => 253881)
--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -26,6 +26,7 @@
#pragma once
+#include "CompositionUnderline.h"
#include "KeypressCommand.h"
#include "PlatformEvent.h"
#include <wtf/WindowsExtras.h>
@@ -96,6 +97,11 @@
#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
bool handledByInputMethod() const { return m_handledByInputMethod; }
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ const Optional<Vector<WebCore::CompositionUnderline>>& preeditUnderlines() const { return m_preeditUnderlines; }
+ const Optional<uint64_t>& preeditSelectionRangeStart() const { return m_preeditSelectionRangeStart; }
+ const Optional<uint64_t>& preeditSelectionRangeLength() const { return m_preeditSelectionRangeLength; }
+#endif
#if USE(APPKIT)
const Vector<KeypressCommand>& commands() const { return m_commands; }
#elif PLATFORM(GTK)
@@ -154,6 +160,11 @@
#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
bool m_handledByInputMethod { false };
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ Optional<Vector<WebCore::CompositionUnderline>> m_preeditUnderlines;
+ Optional<uint64_t> m_preeditSelectionRangeStart;
+ Optional<uint64_t> m_preeditSelectionRangeLength;
+#endif
#if USE(APPKIT)
Vector<KeypressCommand> m_commands;
#elif PLATFORM(GTK)
Modified: trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp (253880 => 253881)
--- trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -1327,18 +1327,12 @@
ASSERT(m_type == KeyDown);
m_type = type;
- if (backwardCompatibilityMode)
+ if (backwardCompatibilityMode || m_handledByInputMethod)
return;
if (type == PlatformEvent::RawKeyDown) {
m_text = String();
m_unmodifiedText = String();
- } 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.
- m_text = String();
- m_unmodifiedText = String();
} else {
m_keyIdentifier = String();
m_windowsVirtualKeyCode = 0;
Modified: trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp (253880 => 253881)
--- trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -1320,7 +1320,7 @@
{
ASSERT(m_type == KeyDown);
m_type = type;
- if (backwardsCompatibility)
+ if (backwardsCompatibility || m_handledByInputMethod)
return;
if (type == PlatformEvent::RawKeyDown) {
Modified: trunk/Source/WebKit/ChangeLog (253880 => 253881)
--- trunk/Source/WebKit/ChangeLog 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/ChangeLog 2019-12-23 09:19:50 UTC (rev 253881)
@@ -1,3 +1,73 @@
+2019-12-23 Carlos Garcia Campos <[email protected]>
+
+ [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load
+ https://bugs.webkit.org/show_bug.cgi?id=185248
+
+ Reviewed by Žan Doberšek.
+
+ Key events are queued by the WebPageProxy so that the next event is not sent to the web process until the
+ previous one has been handled by the web process already. However, the composition results generated by key
+ events are sent to the web process using IPC messages when they happen. In case of high CPU load it can happen
+ that the composition results are sent to the web process even before the associated keys, that are still in the
+ queue waiting to be sent. We need to ensure that composition results are always processed right after its
+ associated key press event. So, instead of sending the results independently, we now include them as part of the
+ key event.
+
+ * Shared/NativeWebKeyboardEvent.h: Add optional preeditUnderlines and preeditSelectionRange parameters to constructor.
+ * Shared/WebEvent.h:
+ (WebKit::WebKeyboardEvent::preeditUnderlines const): Return the optional preeditUnderlines.
+ (WebKit::WebKeyboardEvent::preeditSelectionRange const): Return the optional preeditSelectionRange.
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent): Copy preeditUnderlines and
+ preeditSelectionRange too.
+ * Shared/WebKeyboardEvent.cpp:
+ (WebKit::WebKeyboardEvent::WebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRange
+ parameters and initialize them.
+ (WebKit::WebKeyboardEvent::encode const): Encode preeditUnderlines and preeditSelectionRange.
+ (WebKit::WebKeyboardEvent::decode): Decode preeditUnderlines and preeditSelectionRange.
+ * Shared/gtk/NativeWebKeyboardEventGtk.cpp:
+ (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add optional preeditUnderlines and
+ preeditSelectionRange parameters and initialize them.
+ * Shared/gtk/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRange
+ parameters and pass them to WebKeyboardEvent constructor.
+ * Shared/gtk/WebEventFactory.h:
+ * Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp:
+ (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add optional preeditUnderlines and
+ preeditSelectionRange parameters and initialize them.
+ * Shared/libwpe/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRang
+ parameters and pass them to WebKeyboardEvent constructor.
+ * Shared/libwpe/WebEventFactory.h: Add optional preeditUnderlines and preeditSelectionRange parameters to constructor.
+ * UIProcess/API/glib/WebKitWebView.cpp:
+ (webkitWebViewSynthesizeCompositionKeyPress): Pass the preeditUnderlines and preeditSelectionRange to platform
+ implementation.
+ (webkitWebViewSetComposition): Remove the call to WebPageProxy::setComposition().
+ (webkitWebViewConfirmComposition): Remove the call to WebPageProxy::confirmComposition().
+ (webkitWebViewCancelComposition): Call WebPageProxy::cancelComposition();
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseKeyPressEvent): Pass the preeditUnderlines and preeditSelectionRange to NativeWebKeyboardEvent constructor.
+ (webkitWebViewBaseKeyReleaseEvent): Ditto.
+ (webkitWebViewBaseSynthesizeCompositionKeyPress): Ditto.
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+ * UIProcess/API/wpe/WPEView.cpp:
+ (WKWPE::View::handleKeyboardEvent): Ditto.
+ (WKWPE::View::synthesizeCompositionKeyPress): Ditto.
+ * UIProcess/API/wpe/WPEView.h:
+ * UIProcess/WebPageProxy.cpp:
+ * UIProcess/WebPageProxy.h:
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::WebEditorClient::didDispatchInputMethodKeydown): Handle the composition results here, right after the
+ associated key events has been dispatched.
+ * WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
+ (WebKit::WebEditorClient::didDispatchInputMethodKeydown): Ditto.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::cancelComposition): Confirm the given string to cancel the composition.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in: Remove SetComposition message and rename ConfirmComposition as
+ CancelComposition since it's now only used for canceling.
+
2019-12-22 Simon Fraser <[email protected]>
Make support for <dialog> an internal feature, off by default
Modified: trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h (253880 => 253881)
--- trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -36,6 +36,7 @@
OBJC_CLASS NSView;
namespace WebCore {
+struct CompositionUnderline;
struct KeypressCommand;
}
#endif
@@ -59,6 +60,7 @@
#endif
namespace WebKit {
+struct EditingRange;
class NativeWebKeyboardEvent : public WebKeyboardEvent {
public:
@@ -68,13 +70,13 @@
#elif PLATFORM(GTK)
NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
enum class HandledByInputMethod : bool { No, Yes };
- NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, Vector<String>&& commands);
+ NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands);
#elif PLATFORM(IOS_FAMILY)
enum class HandledByInputMethod : bool { No, Yes };
NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod);
#elif USE(LIBWPE)
enum class HandledByInputMethod : bool { No, Yes };
- NativeWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, HandledByInputMethod);
+ NativeWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&);
#elif PLATFORM(WIN)
NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM, Vector<MSG>&& pendingCharEvents);
#endif
Modified: trunk/Source/WebKit/Shared/WebEvent.h (253880 => 253881)
--- trunk/Source/WebKit/Shared/WebEvent.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/WebEvent.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -29,6 +29,8 @@
// FIXME: We should probably move to makeing the WebCore/PlatformFooEvents trivial classes so that
// we can use them as the event type.
+#include "EditingRange.h"
+#include <WebCore/CompositionUnderline.h>
#include <WebCore/FloatPoint.h>
#include <WebCore/FloatSize.h>
#include <WebCore/IntPoint.h>
@@ -257,11 +259,11 @@
#if USE(APPKIT)
WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
#elif PLATFORM(GTK)
- WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
+ WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
#elif PLATFORM(IOS_FAMILY)
WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
#elif USE(LIBWPE)
- WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
+ WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
#else
WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
#endif
@@ -277,6 +279,10 @@
#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
bool handledByInputMethod() const { return m_handledByInputMethod; }
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ const Optional<Vector<WebCore::CompositionUnderline>>& preeditUnderlines() const { return m_preeditUnderlines; }
+ const Optional<EditingRange>& preeditSelectionRange() const { return m_preeditSelectionRange; }
+#endif
#if USE(APPKIT)
const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; }
#elif PLATFORM(GTK)
@@ -303,6 +309,10 @@
#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
bool m_handledByInputMethod;
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ Optional<Vector<WebCore::CompositionUnderline>> m_preeditUnderlines;
+ Optional<EditingRange> m_preeditSelectionRange;
+#endif
#if USE(APPKIT)
Vector<WebCore::KeypressCommand> m_commands;
#elif PLATFORM(GTK)
Modified: trunk/Source/WebKit/Shared/WebEventConversion.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/WebEventConversion.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/WebEventConversion.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -217,9 +217,16 @@
m_code = webEvent.code();
m_keyIdentifier = webEvent.keyIdentifier();
m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
-#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
m_handledByInputMethod = webEvent.handledByInputMethod();
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ m_preeditUnderlines = webEvent.preeditUnderlines();
+ if (auto preeditSelectionRange = webEvent.preeditSelectionRange()) {
+ m_preeditSelectionRangeStart = preeditSelectionRange->location;
+ m_preeditSelectionRangeLength = preeditSelectionRange->length;
+ }
+#endif
#if USE(APPKIT) || PLATFORM(GTK)
m_commands = webEvent.commands();
#endif
Modified: trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -58,7 +58,7 @@
#elif PLATFORM(GTK)
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier> modifiers, WallTime timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier> modifiers, WallTime timestamp)
: WebEvent(type, modifiers, timestamp)
, m_text(text)
, m_unmodifiedText(text)
@@ -69,6 +69,8 @@
, m_nativeVirtualKeyCode(nativeVirtualKeyCode)
, m_macCharCode(0)
, m_handledByInputMethod(handledByInputMethod)
+ , m_preeditUnderlines(WTFMove(preeditUnderlines))
+ , m_preeditSelectionRange(WTFMove(preeditSelectionRange))
, m_commands(WTFMove(commands))
, m_isAutoRepeat(false)
, m_isKeypad(isKeypad)
@@ -101,7 +103,7 @@
#elif USE(LIBWPE)
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, bool isKeypad, OptionSet<Modifier> modifiers, WallTime timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, bool isKeypad, OptionSet<Modifier> modifiers, WallTime timestamp)
: WebEvent(type, modifiers, timestamp)
, m_text(text)
, m_unmodifiedText(text)
@@ -112,6 +114,8 @@
, m_nativeVirtualKeyCode(nativeVirtualKeyCode)
, m_macCharCode(0)
, m_handledByInputMethod(handledByInputMethod)
+ , m_preeditUnderlines(WTFMove(preeditUnderlines))
+ , m_preeditSelectionRange(WTFMove(preeditSelectionRange))
, m_isAutoRepeat(false)
, m_isKeypad(isKeypad)
, m_isSystemKey(false)
@@ -159,6 +163,10 @@
#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
encoder << m_handledByInputMethod;
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ encoder << m_preeditUnderlines;
+ encoder << m_preeditSelectionRange;
+#endif
#if USE(APPKIT) || PLATFORM(GTK)
encoder << m_commands;
#endif
@@ -192,6 +200,12 @@
if (!decoder.decode(result.m_handledByInputMethod))
return false;
#endif
+#if PLATFORM(GTK) || USE(LIBWPE)
+ if (!decoder.decode(result.m_preeditUnderlines))
+ return false;
+ if (!decoder.decode(result.m_preeditSelectionRange))
+ return false;
+#endif
#if USE(APPKIT) || PLATFORM(GTK)
if (!decoder.decode(result.m_commands))
return false;
Modified: trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -33,14 +33,14 @@
namespace WebKit {
-NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, Vector<String>&& commands)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(commands)))
+NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands)
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(preeditUnderlines), WTFMove(preeditSelectionRange), WTFMove(commands)))
, m_nativeEvent(gdk_event_copy(event))
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Vector<String>(event.commands())))
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Optional<Vector<WebCore::CompositionUnderline>>(event.preeditUnderlines()), Optional<EditingRange>(event.preeditSelectionRange()), Vector<String>(event.commands())))
, m_nativeEvent(gdk_event_copy(event.nativeEvent()))
{
}
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -252,7 +252,7 @@
wallTimeForEvent(event));
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Vector<String>&& commands)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Optional<Vector<CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands)
{
guint keyval;
gdk_event_get_keyval(event, &keyval);
@@ -269,6 +269,8 @@
PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
static_cast<int>(keyval),
handledByInputMethod,
+ WTFMove(preeditUnderlines),
+ WTFMove(preeditSelectionRange),
WTFMove(commands),
isGdkKeyCodeFromKeyPad(keyval),
modifiersForEvent(event),
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.h (253880 => 253881)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -37,7 +37,7 @@
static WebMouseEvent createWebMouseEvent(const GdkEvent*, int, Optional<WebCore::IntPoint>);
static WebWheelEvent createWebWheelEvent(const GdkEvent*);
static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
- static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Vector<String>&& commands);
+ static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands);
#if ENABLE(TOUCH_EVENTS)
static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
#endif
Modified: trunk/Source/WebKit/Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -30,8 +30,8 @@
namespace WebKit {
-NativeWebKeyboardEvent::NativeWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, HandledByInputMethod handledByInputMethod)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes))
+NativeWebKeyboardEvent::NativeWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, HandledByInputMethod handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange)
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(preeditUnderlines), WTFMove(preeditSelectionRange)))
{
}
Modified: trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp (253880 => 253881)
--- trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -62,7 +62,7 @@
return timestamp ? MonotonicTime::fromRawSeconds(timestamp / 1000.).approximateWallTime() : WallTime::now();
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, bool handledByInputMethod)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange)
{
return WebKeyboardEvent(event->pressed ? WebEvent::KeyDown : WebEvent::KeyUp,
text.isNull() ? WebCore::PlatformKeyboardEvent::singleCharacterString(event->key_code) : text,
@@ -72,6 +72,8 @@
WebCore::PlatformKeyboardEvent::windowsKeyCodeForWPEKeyCode(event->key_code),
event->key_code,
handledByInputMethod,
+ WTFMove(preeditUnderlines),
+ WTFMove(preeditSelectionRange),
isWPEKeyCodeFromKeyPad(event->key_code),
modifiersForEventModifiers(event->modifiers),
wallTimeForEventTime(event->time));
Modified: trunk/Source/WebKit/Shared/libwpe/WebEventFactory.h (253880 => 253881)
--- trunk/Source/WebKit/Shared/libwpe/WebEventFactory.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/Shared/libwpe/WebEventFactory.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -38,7 +38,7 @@
class WebEventFactory {
public:
- static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod);
+ static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&);
static WebMouseEvent createWebMouseEvent(struct wpe_input_pointer_event*, float deviceScaleFactor);
static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor);
#if ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -2691,30 +2691,28 @@
}
#endif
-static void webkitWebViewSynthesizeCompositionKeyPress(WebKitWebView* webView)
+static void webkitWebViewSynthesizeCompositionKeyPress(WebKitWebView* webView, const String& text, Optional<Vector<CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange)
{
#if PLATFORM(GTK)
- webkitWebViewBaseSynthesizeCompositionKeyPress(WEBKIT_WEB_VIEW_BASE(webView));
+ webkitWebViewBaseSynthesizeCompositionKeyPress(WEBKIT_WEB_VIEW_BASE(webView), text, WTFMove(underlines), WTFMove(selectionRange));
#elif PLATFORM(WPE)
- webView->priv->view->synthesizeCompositionKeyPress();
+ webView->priv->view->synthesizeCompositionKeyPress(text, WTFMove(underlines), WTFMove(selectionRange));
#endif
}
-void webkitWebViewSetComposition(WebKitWebView* webView, const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
+void webkitWebViewSetComposition(WebKitWebView* webView, const String& text, const Vector<CompositionUnderline>& underlines, EditingRange&& selectionRange)
{
- webkitWebViewSynthesizeCompositionKeyPress(webView);
- getPage(webView).setComposition(text, underlines, selectionRange);
+ webkitWebViewSynthesizeCompositionKeyPress(webView, text, underlines, WTFMove(selectionRange));
}
void webkitWebViewConfirmComposition(WebKitWebView* webView, const String& text)
{
- webkitWebViewSynthesizeCompositionKeyPress(webView);
- getPage(webView).confirmComposition(text);
+ webkitWebViewSynthesizeCompositionKeyPress(webView, text, WTF::nullopt, WTF::nullopt);
}
void webkitWebViewCancelComposition(WebKitWebView* webView, const String& text)
{
- getPage(webView).confirmComposition(text);
+ getPage(webView).cancelComposition(text);
}
#if PLATFORM(WPE)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -112,6 +112,6 @@
void webkitWebViewDidLosePointerLock(WebKitWebView*);
#endif
-void webkitWebViewSetComposition(WebKitWebView*, const String&, const Vector<WebCore::CompositionUnderline>&, const WebKit::EditingRange&);
+void webkitWebViewSetComposition(WebKitWebView*, const String&, const Vector<WebCore::CompositionUnderline>&, WebKit::EditingRange&&);
void webkitWebViewConfirmComposition(WebKitWebView*, const String&);
void webkitWebViewCancelComposition(WebKitWebView*, const String&);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -799,7 +799,7 @@
auto filterResult = priv->inputMethodFilter.filterKeyEvent(keyEvent);
if (!filterResult.handled) {
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(keyEvent), filterResult.keyText,
- NativeWebKeyboardEvent::HandledByInputMethod::No, priv->keyBindingTranslator.commandsForKeyEvent(keyEvent)));
+ NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt, priv->keyBindingTranslator.commandsForKeyEvent(keyEvent)));
}
return GDK_EVENT_STOP;
@@ -817,7 +817,7 @@
if (!priv->inputMethodFilter.filterKeyEvent(keyEvent).handled) {
priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(keyEvent), { },
- NativeWebKeyboardEvent::HandledByInputMethod::No, { }));
+ NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt, { }));
}
return GDK_EVENT_STOP;
@@ -1909,7 +1909,7 @@
return webViewBase->priv->inputMethodFilter.context();
}
-void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase* webViewBase)
+void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase* webViewBase, const String& text, Optional<Vector<CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange)
{
static GdkEvent* event = nullptr;
if (!event) {
@@ -1924,5 +1924,5 @@
}
WebKitWebViewBasePrivate* priv = webViewBase->priv;
- priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event, { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes, { }));
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event, text, NativeWebKeyboardEvent::HandledByInputMethod::Yes, WTFMove(underlines), WTFMove(selectionRange), { }));
}
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -38,6 +38,7 @@
#include "WebKitInputMethodContext.h"
#include "WebKitWebViewBase.h"
#include "WebPageProxy.h"
+#include <wtf/Optional.h>
WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&);
WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
@@ -108,4 +109,4 @@
void webkitWebViewBaseSetInputMethodContext(WebKitWebViewBase*, WebKitInputMethodContext*);
WebKitInputMethodContext* webkitWebViewBaseGetInputMethodContext(WebKitWebViewBase*);
-void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase*);
+void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase*, const String& text, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<WebKit::EditingRange>&&);
Modified: trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -29,6 +29,7 @@
#include "APIPageConfiguration.h"
#include "APIViewClient.h"
#include "DrawingAreaProxy.h"
+#include "EditingRange.h"
#include "EditorState.h"
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
@@ -36,6 +37,7 @@
#include "NativeWebWheelEvent.h"
#include "WebPageGroup.h"
#include "WebProcessPool.h"
+#include <WebCore/CompositionUnderline.h>
#include <wpe/wpe.h>
using namespace WebKit;
@@ -270,10 +272,10 @@
if (filterResult.handled)
return;
- page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(event, event->pressed ? filterResult.keyText : String(), NativeWebKeyboardEvent::HandledByInputMethod::No));
+ page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(event, event->pressed ? filterResult.keyText : String(), NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt));
}
-void View::synthesizeCompositionKeyPress()
+void View::synthesizeCompositionKeyPress(const String& text, Optional<Vector<WebCore::CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange)
{
// The Windows composition key event code is 299 or VK_PROCESSKEY. We need to
// emit this code for web compatibility reasons when key events trigger
@@ -280,7 +282,7 @@
// composition results. WPE doesn't have an equivalent, so we send VoidSymbol
// here to WebCore. PlatformKeyEvent converts this code into VK_PROCESSKEY.
static struct wpe_input_keyboard_event event = { 0, WPE_KEY_VoidSymbol, 0, true, 0 };
- page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(&event, { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes));
+ page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(&event, text, NativeWebKeyboardEvent::HandledByInputMethod::Yes, WTFMove(underlines), WTFMove(selectionRange)));
}
void View::close()
Modified: trunk/Source/WebKit/UIProcess/API/wpe/WPEView.h (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/API/wpe/WPEView.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WPEView.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -48,10 +48,15 @@
class ViewClient;
}
+namespace WebCore {
+struct CompositionUnderline;
+}
+
namespace WebKit {
class DownloadProxy;
class WebPageGroup;
class WebProcessPool;
+struct EditingRange;
struct UserMessage;
}
@@ -77,7 +82,7 @@
void setInputMethodContext(WebKitInputMethodContext*);
WebKitInputMethodContext* inputMethodContext() const;
void setInputMethodState(bool);
- void synthesizeCompositionKeyPress();
+ void synthesizeCompositionKeyPress(const String&, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<WebKit::EditingRange>&&);
void selectionDidChange();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -8194,22 +8194,21 @@
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
-void WebPageProxy::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
+void WebPageProxy::cancelComposition(const String& compositionString)
{
- // FIXME: We need to find out how to proper handle the crashes case.
if (!hasRunningProcess())
return;
- send(Messages::WebPage::SetComposition(text, underlines, selectionRange));
+ // Remove any pending composition key event.
+ if (m_keyEventQueue.size() > 1) {
+ auto event = m_keyEventQueue.takeFirst();
+ m_keyEventQueue.removeAllMatching([](const auto& event) {
+ return event.handledByInputMethod();
+ });
+ m_keyEventQueue.prepend(WTFMove(event));
+ }
+ send(Messages::WebPage::CancelComposition(compositionString));
}
-
-void WebPageProxy::confirmComposition(const String& compositionString)
-{
- if (!hasRunningProcess())
- return;
-
- send(Messages::WebPage::ConfirmComposition(compositionString));
-}
#endif // PLATFORM(GTK)
void WebPageProxy::setScrollPinningBehavior(ScrollPinningBehavior pinning)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (253880 => 253881)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -788,8 +788,7 @@
bool updateLayoutViewportParameters(const WebKit::RemoteLayerTreeTransaction&);
#if PLATFORM(GTK) || PLATFORM(WPE)
- void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
- void confirmComposition(const String& compositionString);
+ void cancelComposition(const String& compositionString);
void setInputMethodState(bool enabled);
#endif
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -174,6 +174,10 @@
bool shouldShowUnicodeMenu() final;
#endif
+#if PLATFORM(GTK) || PLATFORM(WPE)
+ void didDispatchInputMethodKeydown(WebCore::KeyboardEvent&) final;
+#endif
+
#if PLATFORM(IOS_FAMILY)
void startDelayingAndCoalescingContentChangeNotifications() final;
void stopDelayingAndCoalescingContentChangeNotifications() final;
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -139,6 +139,21 @@
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 (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -241,4 +241,19 @@
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/WebPage.cpp (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -5352,21 +5352,11 @@
return &targetFrame;
}
-void WebPage::confirmComposition(const String& compositionString)
+void WebPage::cancelComposition(const String& compositionString)
{
if (auto* targetFrame = targetFrameForEditing(*this))
targetFrame->editor().confirmComposition(compositionString);
}
-
-void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
-{
- Frame* targetFrame = targetFrameForEditing(*this);
- if (!targetFrame || !targetFrame->selection().selection().isContentEditable())
- return;
-
- Ref<Frame> protector(*targetFrame);
- targetFrame->editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length);
-}
#endif
void WebPage::didApplyStyle()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-12-23 09:19:50 UTC (rev 253881)
@@ -778,8 +778,7 @@
SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
#if PLATFORM(GTK) || PLATFORM(WPE)
- void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
- void confirmComposition(const String& text);
+ void cancelComposition(const String& text);
#endif
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (253880 => 253881)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-12-23 09:19:50 UTC (rev 253881)
@@ -414,8 +414,7 @@
SetCanRunModal(bool canRunModal)
#if PLATFORM(GTK) || PLATFORM(WPE)
- SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, struct WebKit::EditingRange selectionRange)
- ConfirmComposition(String text)
+ CancelComposition(String text)
#endif
#if PLATFORM(GTK)
Modified: trunk/Tools/ChangeLog (253880 => 253881)
--- trunk/Tools/ChangeLog 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Tools/ChangeLog 2019-12-23 09:19:50 UTC (rev 253881)
@@ -1,3 +1,18 @@
+2019-12-23 Carlos Garcia Campos <[email protected]>
+
+ [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load
+ https://bugs.webkit.org/show_bug.cgi?id=185248
+
+ Reviewed by Žan Doberšek.
+
+ Remove the waits() that were added to work around this bug.
+
+ * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
+ (testWebKitInputMethodContextSequence):
+ (testWebKitInputMethodContextInvalidSequence):
+ (testWebKitInputMethodContextCancelSequence):
+ (testWebKitInputMethodContextReset):
+
2019-12-21 Yusuke Suzuki <[email protected]>
[JSC] Improve our bound function implementation
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp (253880 => 253881)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp 2019-12-23 03:51:49 UTC (rev 253880)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp 2019-12-23 09:19:50 UTC (rev 253881)
@@ -436,7 +436,6 @@
g_assert_cmpuint(test->m_events[3].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[3].key.data(), ==, "w");
g_assert_true(test->m_events[3].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(g), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -449,7 +448,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 71);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "g");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(t), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -462,7 +460,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 84);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "t");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(k), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -475,7 +472,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 75);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "k");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(ISO_Enter), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -508,7 +504,6 @@
g_assert_cmpuint(test->m_events[3].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[3].key.data(), ==, "w");
g_assert_true(test->m_events[3].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(w), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -521,7 +516,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "w");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(p), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -534,7 +528,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 80);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "p");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(e), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -547,7 +540,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 69);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "e");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(space), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -591,7 +583,6 @@
g_assert_cmpuint(test->m_events[3].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[3].key.data(), ==, "w");
g_assert_true(test->m_events[3].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(w), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -604,7 +595,6 @@
g_assert_cmpuint(test->m_events[2].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[2].key.data(), ==, "w");
g_assert_true(test->m_events[2].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(space), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -648,7 +638,6 @@
g_assert_cmpuint(test->m_events[3].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[3].key.data(), ==, "w");
g_assert_true(test->m_events[3].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->keyStrokeAndWaitForEvents(KEY(Escape), 3);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::KeyDown);
@@ -692,7 +681,6 @@
g_assert_cmpuint(test->m_events[3].keyCode, ==, 87);
g_assert_cmpstr(test->m_events[3].key.data(), ==, "w");
g_assert_true(test->m_events[3].isComposing);
- test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.
test->m_events.clear();
test->clickAndWaitForEvents(1);
g_assert_true(test->m_events[0].type == InputMethodTest::Event::Type::CompositionEnd);