Changeset 253881 in webkit
- Timestamp:
- Dec 23, 2019 1:19:50 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r253880 r253881 1 2019-12-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load 4 https://bugs.webkit.org/show_bug.cgi?id=185248 5 6 Reviewed by Žan Doberšek. 7 8 Notify the editor when a key event handled by input method has been dispatched. This way we can handle the 9 composition results right after the event is dispatched. 10 11 * editing/Editor.cpp: 12 (WebCore::Editor::didDispatchInputMethodKeydown): Notify the client. 13 * editing/Editor.h: 14 * page/EditorClient.h: 15 (WebCore::EditorClient::didDispatchInputMethodKeydown): Added. 16 * page/EventHandler.cpp: 17 (WebCore::EventHandler::internalKeyEvent): Call Editor::didDispatchInputMethodKeydown() for events handled by 18 input method right after the event is dispatched. 19 * platform/PlatformKeyboardEvent.h: 20 (WebCore::PlatformKeyboardEvent::preeditUnderlines const): 21 (WebCore::PlatformKeyboardEvent::preeditSelectionRangeStart const): 22 (WebCore::PlatformKeyboardEvent::preeditSelectionRangeLength const): 23 * platform/gtk/PlatformKeyboardEventGtk.cpp: 24 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): Return early if the event was handled by input 25 method and remove the special case for Char events handled by input method because this is never called with 26 Char type for events handled by input method. 27 * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: 28 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): Return early if the event was handled by input 29 method. 30 1 31 2019-12-22 Simon Fraser <simon.fraser@apple.com> 2 32 -
trunk/Source/WebCore/editing/Editor.cpp
r249605 r253881 303 303 } 304 304 305 void Editor::didDispatchInputMethodKeydown(KeyboardEvent& event) 306 { 307 if (auto* client = this->client()) 308 client->didDispatchInputMethodKeydown(event); 309 } 310 305 311 bool Editor::handleTextEvent(TextEvent& event) 306 312 { -
trunk/Source/WebCore/editing/Editor.h
r249605 r253881 152 152 void handleKeyboardEvent(KeyboardEvent&); 153 153 void handleInputMethodKeydown(KeyboardEvent&); 154 void didDispatchInputMethodKeydown(KeyboardEvent&); 154 155 bool handleTextEvent(TextEvent&); 155 156 -
trunk/Source/WebCore/page/EditorClient.h
r250365 r253881 122 122 virtual void handleKeyboardEvent(KeyboardEvent&) = 0; 123 123 virtual void handleInputMethodKeydown(KeyboardEvent&) = 0; 124 virtual void didDispatchInputMethodKeydown(KeyboardEvent&) { } 124 125 125 126 virtual void textFieldDidBeginEditing(Element*) = 0; -
trunk/Source/WebCore/page/EventHandler.cpp
r253636 r253881 3358 3358 3359 3359 element->dispatchEvent(keydown); 3360 if (handledByInputMethod) 3360 if (handledByInputMethod) { 3361 m_frame.editor().didDispatchInputMethodKeydown(keydown.get()); 3361 3362 return true; 3363 } 3362 3364 3363 3365 // If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame. -
trunk/Source/WebCore/platform/PlatformKeyboardEvent.h
r253749 r253881 27 27 #pragma once 28 28 29 #include "CompositionUnderline.h" 29 30 #include "KeypressCommand.h" 30 31 #include "PlatformEvent.h" … … 97 98 bool handledByInputMethod() const { return m_handledByInputMethod; } 98 99 #endif 100 #if PLATFORM(GTK) || USE(LIBWPE) 101 const Optional<Vector<WebCore::CompositionUnderline>>& preeditUnderlines() const { return m_preeditUnderlines; } 102 const Optional<uint64_t>& preeditSelectionRangeStart() const { return m_preeditSelectionRangeStart; } 103 const Optional<uint64_t>& preeditSelectionRangeLength() const { return m_preeditSelectionRangeLength; } 104 #endif 99 105 #if USE(APPKIT) 100 106 const Vector<KeypressCommand>& commands() const { return m_commands; } … … 155 161 bool m_handledByInputMethod { false }; 156 162 #endif 163 #if PLATFORM(GTK) || USE(LIBWPE) 164 Optional<Vector<WebCore::CompositionUnderline>> m_preeditUnderlines; 165 Optional<uint64_t> m_preeditSelectionRangeStart; 166 Optional<uint64_t> m_preeditSelectionRangeLength; 167 #endif 157 168 #if USE(APPKIT) 158 169 Vector<KeypressCommand> m_commands; -
trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
r251650 r253881 1328 1328 m_type = type; 1329 1329 1330 if (backwardCompatibilityMode )1330 if (backwardCompatibilityMode || m_handledByInputMethod) 1331 1331 return; 1332 1332 1333 1333 if (type == PlatformEvent::RawKeyDown) { 1334 m_text = String();1335 m_unmodifiedText = String();1336 } else if (type == PlatformEvent::Char && m_handledByInputMethod) {1337 // Having empty text, prevents this Char (which is a DOM keypress) event1338 // from going to the DOM. Keys that trigger composition events should not1339 // fire keypress.1340 1334 m_text = String(); 1341 1335 m_unmodifiedText = String(); -
trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp
r248660 r253881 1321 1321 ASSERT(m_type == KeyDown); 1322 1322 m_type = type; 1323 if (backwardsCompatibility )1323 if (backwardsCompatibility || m_handledByInputMethod) 1324 1324 return; 1325 1325 -
trunk/Source/WebKit/ChangeLog
r253880 r253881 1 2019-12-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load 4 https://bugs.webkit.org/show_bug.cgi?id=185248 5 6 Reviewed by Žan Doberšek. 7 8 Key events are queued by the WebPageProxy so that the next event is not sent to the web process until the 9 previous one has been handled by the web process already. However, the composition results generated by key 10 events are sent to the web process using IPC messages when they happen. In case of high CPU load it can happen 11 that the composition results are sent to the web process even before the associated keys, that are still in the 12 queue waiting to be sent. We need to ensure that composition results are always processed right after its 13 associated key press event. So, instead of sending the results independently, we now include them as part of the 14 key event. 15 16 * Shared/NativeWebKeyboardEvent.h: Add optional preeditUnderlines and preeditSelectionRange parameters to constructor. 17 * Shared/WebEvent.h: 18 (WebKit::WebKeyboardEvent::preeditUnderlines const): Return the optional preeditUnderlines. 19 (WebKit::WebKeyboardEvent::preeditSelectionRange const): Return the optional preeditSelectionRange. 20 * Shared/WebEventConversion.cpp: 21 (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent): Copy preeditUnderlines and 22 preeditSelectionRange too. 23 * Shared/WebKeyboardEvent.cpp: 24 (WebKit::WebKeyboardEvent::WebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRange 25 parameters and initialize them. 26 (WebKit::WebKeyboardEvent::encode const): Encode preeditUnderlines and preeditSelectionRange. 27 (WebKit::WebKeyboardEvent::decode): Decode preeditUnderlines and preeditSelectionRange. 28 * Shared/gtk/NativeWebKeyboardEventGtk.cpp: 29 (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add optional preeditUnderlines and 30 preeditSelectionRange parameters and initialize them. 31 * Shared/gtk/WebEventFactory.cpp: 32 (WebKit::WebEventFactory::createWebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRange 33 parameters and pass them to WebKeyboardEvent constructor. 34 * Shared/gtk/WebEventFactory.h: 35 * Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp: 36 (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add optional preeditUnderlines and 37 preeditSelectionRange parameters and initialize them. 38 * Shared/libwpe/WebEventFactory.cpp: 39 (WebKit::WebEventFactory::createWebKeyboardEvent): Add optional preeditUnderlines and preeditSelectionRang 40 parameters and pass them to WebKeyboardEvent constructor. 41 * Shared/libwpe/WebEventFactory.h: Add optional preeditUnderlines and preeditSelectionRange parameters to constructor. 42 * UIProcess/API/glib/WebKitWebView.cpp: 43 (webkitWebViewSynthesizeCompositionKeyPress): Pass the preeditUnderlines and preeditSelectionRange to platform 44 implementation. 45 (webkitWebViewSetComposition): Remove the call to WebPageProxy::setComposition(). 46 (webkitWebViewConfirmComposition): Remove the call to WebPageProxy::confirmComposition(). 47 (webkitWebViewCancelComposition): Call WebPageProxy::cancelComposition(); 48 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 49 (webkitWebViewBaseKeyPressEvent): Pass the preeditUnderlines and preeditSelectionRange to NativeWebKeyboardEvent constructor. 50 (webkitWebViewBaseKeyReleaseEvent): Ditto. 51 (webkitWebViewBaseSynthesizeCompositionKeyPress): Ditto. 52 * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: 53 * UIProcess/API/wpe/WPEView.cpp: 54 (WKWPE::View::handleKeyboardEvent): Ditto. 55 (WKWPE::View::synthesizeCompositionKeyPress): Ditto. 56 * UIProcess/API/wpe/WPEView.h: 57 * UIProcess/WebPageProxy.cpp: 58 * UIProcess/WebPageProxy.h: 59 * WebProcess/WebCoreSupport/WebEditorClient.h: 60 * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp: 61 (WebKit::WebEditorClient::didDispatchInputMethodKeydown): Handle the composition results here, right after the 62 associated key events has been dispatched. 63 * WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp: 64 (WebKit::WebEditorClient::didDispatchInputMethodKeydown): Ditto. 65 * WebProcess/WebPage/WebPage.cpp: 66 (WebKit::WebPage::cancelComposition): Confirm the given string to cancel the composition. 67 * WebProcess/WebPage/WebPage.h: 68 * WebProcess/WebPage/WebPage.messages.in: Remove SetComposition message and rename ConfirmComposition as 69 CancelComposition since it's now only used for canceling. 70 1 71 2019-12-22 Simon Fraser <simon.fraser@apple.com> 2 72 -
trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h
r253749 r253881 37 37 38 38 namespace WebCore { 39 struct CompositionUnderline; 39 40 struct KeypressCommand; 40 41 } … … 60 61 61 62 namespace WebKit { 63 struct EditingRange; 62 64 63 65 class NativeWebKeyboardEvent : public WebKeyboardEvent { … … 69 71 NativeWebKeyboardEvent(const NativeWebKeyboardEvent&); 70 72 enum class HandledByInputMethod : bool { No, Yes }; 71 NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, Vector<String>&& commands);73 NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands); 72 74 #elif PLATFORM(IOS_FAMILY) 73 75 enum class HandledByInputMethod : bool { No, Yes }; … … 75 77 #elif USE(LIBWPE) 76 78 enum class HandledByInputMethod : bool { No, Yes }; 77 NativeWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, HandledByInputMethod );79 NativeWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, HandledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&); 78 80 #elif PLATFORM(WIN) 79 81 NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM, Vector<MSG>&& pendingCharEvents); -
trunk/Source/WebKit/Shared/WebEvent.h
r253749 r253881 30 30 // we can use them as the event type. 31 31 32 #include "EditingRange.h" 33 #include <WebCore/CompositionUnderline.h> 32 34 #include <WebCore/FloatPoint.h> 33 35 #include <WebCore/FloatSize.h> … … 258 260 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); 259 261 #elif PLATFORM(GTK) 260 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);262 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); 261 263 #elif PLATFORM(IOS_FAMILY) 262 264 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); 263 265 #elif USE(LIBWPE) 264 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);266 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); 265 267 #else 266 268 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); … … 278 280 bool handledByInputMethod() const { return m_handledByInputMethod; } 279 281 #endif 282 #if PLATFORM(GTK) || USE(LIBWPE) 283 const Optional<Vector<WebCore::CompositionUnderline>>& preeditUnderlines() const { return m_preeditUnderlines; } 284 const Optional<EditingRange>& preeditSelectionRange() const { return m_preeditSelectionRange; } 285 #endif 280 286 #if USE(APPKIT) 281 287 const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; } … … 303 309 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE) 304 310 bool m_handledByInputMethod; 311 #endif 312 #if PLATFORM(GTK) || USE(LIBWPE) 313 Optional<Vector<WebCore::CompositionUnderline>> m_preeditUnderlines; 314 Optional<EditingRange> m_preeditSelectionRange; 305 315 #endif 306 316 #if USE(APPKIT) -
trunk/Source/WebKit/Shared/WebEventConversion.cpp
r252936 r253881 218 218 m_keyIdentifier = webEvent.keyIdentifier(); 219 219 m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); 220 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 220 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE) 221 221 m_handledByInputMethod = webEvent.handledByInputMethod(); 222 #endif 223 #if PLATFORM(GTK) || USE(LIBWPE) 224 m_preeditUnderlines = webEvent.preeditUnderlines(); 225 if (auto preeditSelectionRange = webEvent.preeditSelectionRange()) { 226 m_preeditSelectionRangeStart = preeditSelectionRange->location; 227 m_preeditSelectionRangeLength = preeditSelectionRange->length; 228 } 222 229 #endif 223 230 #if USE(APPKIT) || PLATFORM(GTK) -
trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp
r253749 r253881 59 59 #elif PLATFORM(GTK) 60 60 61 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)61 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) 62 62 : WebEvent(type, modifiers, timestamp) 63 63 , m_text(text) … … 70 70 , m_macCharCode(0) 71 71 , m_handledByInputMethod(handledByInputMethod) 72 , m_preeditUnderlines(WTFMove(preeditUnderlines)) 73 , m_preeditSelectionRange(WTFMove(preeditSelectionRange)) 72 74 , m_commands(WTFMove(commands)) 73 75 , m_isAutoRepeat(false) … … 102 104 #elif USE(LIBWPE) 103 105 104 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)106 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) 105 107 : WebEvent(type, modifiers, timestamp) 106 108 , m_text(text) … … 113 115 , m_macCharCode(0) 114 116 , m_handledByInputMethod(handledByInputMethod) 117 , m_preeditUnderlines(WTFMove(preeditUnderlines)) 118 , m_preeditSelectionRange(WTFMove(preeditSelectionRange)) 115 119 , m_isAutoRepeat(false) 116 120 , m_isKeypad(isKeypad) … … 160 164 encoder << m_handledByInputMethod; 161 165 #endif 166 #if PLATFORM(GTK) || USE(LIBWPE) 167 encoder << m_preeditUnderlines; 168 encoder << m_preeditSelectionRange; 169 #endif 162 170 #if USE(APPKIT) || PLATFORM(GTK) 163 171 encoder << m_commands; … … 193 201 return false; 194 202 #endif 203 #if PLATFORM(GTK) || USE(LIBWPE) 204 if (!decoder.decode(result.m_preeditUnderlines)) 205 return false; 206 if (!decoder.decode(result.m_preeditSelectionRange)) 207 return false; 208 #endif 195 209 #if USE(APPKIT) || PLATFORM(GTK) 196 210 if (!decoder.decode(result.m_commands)) -
trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp
r253749 r253881 34 34 namespace WebKit { 35 35 36 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, Vector<String>&& commands)37 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove( commands)))36 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands) 37 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(preeditUnderlines), WTFMove(preeditSelectionRange), WTFMove(commands))) 38 38 , m_nativeEvent(gdk_event_copy(event)) 39 39 { … … 41 41 42 42 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event) 43 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Vector<String>(event.commands())))43 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Optional<Vector<WebCore::CompositionUnderline>>(event.preeditUnderlines()), Optional<EditingRange>(event.preeditSelectionRange()), Vector<String>(event.commands()))) 44 44 , m_nativeEvent(gdk_event_copy(event.nativeEvent())) 45 45 { -
trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp
r252126 r253881 253 253 } 254 254 255 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Vector<String>&& commands)255 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Optional<Vector<CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange, Vector<String>&& commands) 256 256 { 257 257 guint keyval; … … 270 270 static_cast<int>(keyval), 271 271 handledByInputMethod, 272 WTFMove(preeditUnderlines), 273 WTFMove(preeditSelectionRange), 272 274 WTFMove(commands), 273 275 isGdkKeyCodeFromKeyPad(keyval), -
trunk/Source/WebKit/Shared/gtk/WebEventFactory.h
r252126 r253881 38 38 static WebWheelEvent createWebWheelEvent(const GdkEvent*); 39 39 static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase); 40 static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Vector<String>&& commands);40 static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands); 41 41 #if ENABLE(TOUCH_EVENTS) 42 42 static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&); -
trunk/Source/WebKit/Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp
r253749 r253881 31 31 namespace WebKit { 32 32 33 NativeWebKeyboardEvent::NativeWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, HandledByInputMethod handledByInputMethod )34 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes ))33 NativeWebKeyboardEvent::NativeWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, HandledByInputMethod handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange) 34 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(preeditUnderlines), WTFMove(preeditSelectionRange))) 35 35 { 36 36 } -
trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp
r253749 r253881 63 63 } 64 64 65 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, bool handledByInputMethod )65 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboard_event* event, const String& text, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&& preeditUnderlines, Optional<EditingRange>&& preeditSelectionRange) 66 66 { 67 67 return WebKeyboardEvent(event->pressed ? WebEvent::KeyDown : WebEvent::KeyUp, … … 73 73 event->key_code, 74 74 handledByInputMethod, 75 WTFMove(preeditUnderlines), 76 WTFMove(preeditSelectionRange), 75 77 isWPEKeyCodeFromKeyPad(event->key_code), 76 78 modifiersForEventModifiers(event->modifiers), -
trunk/Source/WebKit/Shared/libwpe/WebEventFactory.h
r253749 r253881 39 39 class WebEventFactory { 40 40 public: 41 static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod );41 static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&); 42 42 static WebMouseEvent createWebMouseEvent(struct wpe_input_pointer_event*, float deviceScaleFactor); 43 43 static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor); -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
r253749 r253881 2692 2692 #endif 2693 2693 2694 static void webkitWebViewSynthesizeCompositionKeyPress(WebKitWebView* webView )2694 static void webkitWebViewSynthesizeCompositionKeyPress(WebKitWebView* webView, const String& text, Optional<Vector<CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange) 2695 2695 { 2696 2696 #if PLATFORM(GTK) 2697 webkitWebViewBaseSynthesizeCompositionKeyPress(WEBKIT_WEB_VIEW_BASE(webView) );2697 webkitWebViewBaseSynthesizeCompositionKeyPress(WEBKIT_WEB_VIEW_BASE(webView), text, WTFMove(underlines), WTFMove(selectionRange)); 2698 2698 #elif PLATFORM(WPE) 2699 webView->priv->view->synthesizeCompositionKeyPress(); 2700 #endif 2701 } 2702 2703 void webkitWebViewSetComposition(WebKitWebView* webView, const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange) 2704 { 2705 webkitWebViewSynthesizeCompositionKeyPress(webView); 2706 getPage(webView).setComposition(text, underlines, selectionRange); 2699 webView->priv->view->synthesizeCompositionKeyPress(text, WTFMove(underlines), WTFMove(selectionRange)); 2700 #endif 2701 } 2702 2703 void webkitWebViewSetComposition(WebKitWebView* webView, const String& text, const Vector<CompositionUnderline>& underlines, EditingRange&& selectionRange) 2704 { 2705 webkitWebViewSynthesizeCompositionKeyPress(webView, text, underlines, WTFMove(selectionRange)); 2707 2706 } 2708 2707 2709 2708 void webkitWebViewConfirmComposition(WebKitWebView* webView, const String& text) 2710 2709 { 2711 webkitWebViewSynthesizeCompositionKeyPress(webView); 2712 getPage(webView).confirmComposition(text); 2710 webkitWebViewSynthesizeCompositionKeyPress(webView, text, WTF::nullopt, WTF::nullopt); 2713 2711 } 2714 2712 2715 2713 void webkitWebViewCancelComposition(WebKitWebView* webView, const String& text) 2716 2714 { 2717 getPage(webView).c onfirmComposition(text);2715 getPage(webView).cancelComposition(text); 2718 2716 } 2719 2717 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
r253749 r253881 113 113 #endif 114 114 115 void webkitWebViewSetComposition(WebKitWebView*, const String&, const Vector<WebCore::CompositionUnderline>&, const WebKit::EditingRange&);115 void webkitWebViewSetComposition(WebKitWebView*, const String&, const Vector<WebCore::CompositionUnderline>&, WebKit::EditingRange&&); 116 116 void webkitWebViewConfirmComposition(WebKitWebView*, const String&); 117 117 void webkitWebViewCancelComposition(WebKitWebView*, const String&); -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r253749 r253881 800 800 if (!filterResult.handled) { 801 801 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(keyEvent), filterResult.keyText, 802 NativeWebKeyboardEvent::HandledByInputMethod::No, priv->keyBindingTranslator.commandsForKeyEvent(keyEvent)));802 NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt, priv->keyBindingTranslator.commandsForKeyEvent(keyEvent))); 803 803 } 804 804 … … 818 818 if (!priv->inputMethodFilter.filterKeyEvent(keyEvent).handled) { 819 819 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(keyEvent), { }, 820 NativeWebKeyboardEvent::HandledByInputMethod::No, { }));820 NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt, { })); 821 821 } 822 822 … … 1910 1910 } 1911 1911 1912 void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase* webViewBase )1912 void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase* webViewBase, const String& text, Optional<Vector<CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange) 1913 1913 { 1914 1914 static GdkEvent* event = nullptr; … … 1925 1925 1926 1926 WebKitWebViewBasePrivate* priv = webViewBase->priv; 1927 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event, { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes, { }));1928 } 1927 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event, text, NativeWebKeyboardEvent::HandledByInputMethod::Yes, WTFMove(underlines), WTFMove(selectionRange), { })); 1928 } -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
r253749 r253881 39 39 #include "WebKitWebViewBase.h" 40 40 #include "WebPageProxy.h" 41 #include <wtf/Optional.h> 41 42 42 43 WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&); … … 109 110 void webkitWebViewBaseSetInputMethodContext(WebKitWebViewBase*, WebKitInputMethodContext*); 110 111 WebKitInputMethodContext* webkitWebViewBaseGetInputMethodContext(WebKitWebViewBase*); 111 void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase* );112 void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase*, const String& text, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<WebKit::EditingRange>&&); -
trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp
r253749 r253881 30 30 #include "APIViewClient.h" 31 31 #include "DrawingAreaProxy.h" 32 #include "EditingRange.h" 32 33 #include "EditorState.h" 33 34 #include "NativeWebKeyboardEvent.h" … … 37 38 #include "WebPageGroup.h" 38 39 #include "WebProcessPool.h" 40 #include <WebCore/CompositionUnderline.h> 39 41 #include <wpe/wpe.h> 40 42 … … 271 273 return; 272 274 273 page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(event, event->pressed ? filterResult.keyText : String(), NativeWebKeyboardEvent::HandledByInputMethod::No ));274 } 275 276 void View::synthesizeCompositionKeyPress( )275 page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(event, event->pressed ? filterResult.keyText : String(), NativeWebKeyboardEvent::HandledByInputMethod::No, WTF::nullopt, WTF::nullopt)); 276 } 277 278 void View::synthesizeCompositionKeyPress(const String& text, Optional<Vector<WebCore::CompositionUnderline>>&& underlines, Optional<EditingRange>&& selectionRange) 277 279 { 278 280 // The Windows composition key event code is 299 or VK_PROCESSKEY. We need to … … 281 283 // here to WebCore. PlatformKeyEvent converts this code into VK_PROCESSKEY. 282 284 static struct wpe_input_keyboard_event event = { 0, WPE_KEY_VoidSymbol, 0, true, 0 }; 283 page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(&event, { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes));285 page().handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(&event, text, NativeWebKeyboardEvent::HandledByInputMethod::Yes, WTFMove(underlines), WTFMove(selectionRange))); 284 286 } 285 287 -
trunk/Source/WebKit/UIProcess/API/wpe/WPEView.h
r253749 r253881 49 49 } 50 50 51 namespace WebCore { 52 struct CompositionUnderline; 53 } 54 51 55 namespace WebKit { 52 56 class DownloadProxy; 53 57 class WebPageGroup; 54 58 class WebProcessPool; 59 struct EditingRange; 55 60 struct UserMessage; 56 61 } … … 78 83 WebKitInputMethodContext* inputMethodContext() const; 79 84 void setInputMethodState(bool); 80 void synthesizeCompositionKeyPress( );85 void synthesizeCompositionKeyPress(const String&, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<WebKit::EditingRange>&&); 81 86 82 87 void selectionDidChange(); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r253749 r253881 8195 8195 8196 8196 #if PLATFORM(GTK) || PLATFORM(WPE) 8197 void WebPageProxy::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange) 8198 { 8199 // FIXME: We need to find out how to proper handle the crashes case. 8200 if (!hasRunningProcess()) 8201 return; 8202 8203 send(Messages::WebPage::SetComposition(text, underlines, selectionRange)); 8204 } 8205 8206 void WebPageProxy::confirmComposition(const String& compositionString) 8207 { 8208 if (!hasRunningProcess()) 8209 return; 8210 8211 send(Messages::WebPage::ConfirmComposition(compositionString)); 8197 void WebPageProxy::cancelComposition(const String& compositionString) 8198 { 8199 if (!hasRunningProcess()) 8200 return; 8201 8202 // Remove any pending composition key event. 8203 if (m_keyEventQueue.size() > 1) { 8204 auto event = m_keyEventQueue.takeFirst(); 8205 m_keyEventQueue.removeAllMatching([](const auto& event) { 8206 return event.handledByInputMethod(); 8207 }); 8208 m_keyEventQueue.prepend(WTFMove(event)); 8209 } 8210 send(Messages::WebPage::CancelComposition(compositionString)); 8212 8211 } 8213 8212 #endif // PLATFORM(GTK) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r253749 r253881 789 789 790 790 #if PLATFORM(GTK) || PLATFORM(WPE) 791 void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange); 792 void confirmComposition(const String& compositionString); 791 void cancelComposition(const String& compositionString); 793 792 794 793 void setInputMethodState(bool enabled); -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
r250365 r253881 175 175 #endif 176 176 177 #if PLATFORM(GTK) || PLATFORM(WPE) 178 void didDispatchInputMethodKeydown(WebCore::KeyboardEvent&) final; 179 #endif 180 177 181 #if PLATFORM(IOS_FAMILY) 178 182 void startDelayingAndCoalescingContentChangeNotifications() final; -
trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
r246596 r253881 140 140 } 141 141 142 void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event) 143 { 144 auto* platformEvent = event.underlyingPlatformEvent(); 145 ASSERT(event.target()); 146 auto* frame = downcast<Node>(event.target())->document().frame(); 147 ASSERT(frame); 148 149 if (const auto& underlines = platformEvent->preeditUnderlines()) { 150 auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0); 151 auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0); 152 frame->editor().setComposition(platformEvent->text(), underlines.value(), rangeStart, rangeStart + rangeLength); 153 } else 154 frame->editor().confirmComposition(platformEvent->text()); 155 } 156 142 157 void WebEditorClient::updateGlobalSelection(Frame* frame) 143 158 { -
trunk/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp
r253749 r253881 242 242 } 243 243 244 void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event) 245 { 246 auto* platformEvent = event.underlyingPlatformEvent(); 247 ASSERT(event.target()); 248 auto* frame = downcast<Node>(event.target())->document().frame(); 249 ASSERT(frame); 250 251 if (const auto& underlines = platformEvent->preeditUnderlines()) { 252 auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0); 253 auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0); 254 frame->editor().setComposition(platformEvent->text(), underlines.value(), rangeStart, rangeStart + rangeLength); 255 } else 256 frame->editor().confirmComposition(platformEvent->text()); 257 } 258 244 259 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r253749 r253881 5353 5353 } 5354 5354 5355 void WebPage::c onfirmComposition(const String& compositionString)5355 void WebPage::cancelComposition(const String& compositionString) 5356 5356 { 5357 5357 if (auto* targetFrame = targetFrameForEditing(*this)) 5358 5358 targetFrame->editor().confirmComposition(compositionString); 5359 }5360 5361 void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)5362 {5363 Frame* targetFrame = targetFrameForEditing(*this);5364 if (!targetFrame || !targetFrame->selection().selection().isContentEditable())5365 return;5366 5367 Ref<Frame> protector(*targetFrame);5368 targetFrame->editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length);5369 5359 } 5370 5360 #endif -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r253749 r253881 779 779 780 780 #if PLATFORM(GTK) || PLATFORM(WPE) 781 void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange); 782 void confirmComposition(const String& text); 781 void cancelComposition(const String& text); 783 782 #endif 784 783 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r253749 r253881 415 415 416 416 #if PLATFORM(GTK) || PLATFORM(WPE) 417 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, struct WebKit::EditingRange selectionRange) 418 ConfirmComposition(String text) 417 CancelComposition(String text) 419 418 #endif 420 419 -
trunk/Tools/ChangeLog
r253867 r253881 1 2019-12-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Special combination characters doesn't respect the keystroke order when high CPU load 4 https://bugs.webkit.org/show_bug.cgi?id=185248 5 6 Reviewed by Žan Doberšek. 7 8 Remove the waits() that were added to work around this bug. 9 10 * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp: 11 (testWebKitInputMethodContextSequence): 12 (testWebKitInputMethodContextInvalidSequence): 13 (testWebKitInputMethodContextCancelSequence): 14 (testWebKitInputMethodContextReset): 15 1 16 2019-12-21 Yusuke Suzuki <ysuzuki@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp
r253749 r253881 437 437 g_assert_cmpstr(test->m_events[3].key.data(), ==, "w"); 438 438 g_assert_true(test->m_events[3].isComposing); 439 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.440 439 test->m_events.clear(); 441 440 test->keyStrokeAndWaitForEvents(KEY(g), 3); … … 450 449 g_assert_cmpstr(test->m_events[2].key.data(), ==, "g"); 451 450 g_assert_true(test->m_events[2].isComposing); 452 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.453 451 test->m_events.clear(); 454 452 test->keyStrokeAndWaitForEvents(KEY(t), 3); … … 463 461 g_assert_cmpstr(test->m_events[2].key.data(), ==, "t"); 464 462 g_assert_true(test->m_events[2].isComposing); 465 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.466 463 test->m_events.clear(); 467 464 test->keyStrokeAndWaitForEvents(KEY(k), 3); … … 476 473 g_assert_cmpstr(test->m_events[2].key.data(), ==, "k"); 477 474 g_assert_true(test->m_events[2].isComposing); 478 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.479 475 test->m_events.clear(); 480 476 test->keyStrokeAndWaitForEvents(KEY(ISO_Enter), 3); … … 509 505 g_assert_cmpstr(test->m_events[3].key.data(), ==, "w"); 510 506 g_assert_true(test->m_events[3].isComposing); 511 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.512 507 test->m_events.clear(); 513 508 test->keyStrokeAndWaitForEvents(KEY(w), 3); … … 522 517 g_assert_cmpstr(test->m_events[2].key.data(), ==, "w"); 523 518 g_assert_true(test->m_events[2].isComposing); 524 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.525 519 test->m_events.clear(); 526 520 test->keyStrokeAndWaitForEvents(KEY(p), 3); … … 535 529 g_assert_cmpstr(test->m_events[2].key.data(), ==, "p"); 536 530 g_assert_true(test->m_events[2].isComposing); 537 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.538 531 test->m_events.clear(); 539 532 test->keyStrokeAndWaitForEvents(KEY(e), 3); … … 548 541 g_assert_cmpstr(test->m_events[2].key.data(), ==, "e"); 549 542 g_assert_true(test->m_events[2].isComposing); 550 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.551 543 test->m_events.clear(); 552 544 test->keyStrokeAndWaitForEvents(KEY(space), 3); … … 592 584 g_assert_cmpstr(test->m_events[3].key.data(), ==, "w"); 593 585 g_assert_true(test->m_events[3].isComposing); 594 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.595 586 test->m_events.clear(); 596 587 test->keyStrokeAndWaitForEvents(KEY(w), 3); … … 605 596 g_assert_cmpstr(test->m_events[2].key.data(), ==, "w"); 606 597 g_assert_true(test->m_events[2].isComposing); 607 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.608 598 test->m_events.clear(); 609 599 test->keyStrokeAndWaitForEvents(KEY(space), 3); … … 649 639 g_assert_cmpstr(test->m_events[3].key.data(), ==, "w"); 650 640 g_assert_true(test->m_events[3].isComposing); 651 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.652 641 test->m_events.clear(); 653 642 test->keyStrokeAndWaitForEvents(KEY(Escape), 3); … … 693 682 g_assert_cmpstr(test->m_events[3].key.data(), ==, "w"); 694 683 g_assert_true(test->m_events[3].isComposing); 695 test->wait(0.1); // FIXME: this is a workaround for existing bug when key events are queued.696 684 test->m_events.clear(); 697 685 test->clickAndWaitForEvents(1);
Note: See TracChangeset
for help on using the changeset viewer.