Changeset 185415 in webkit
- Timestamp:
- Jun 10, 2015, 6:32:22 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/PlatformKeyboardEvent.h (modified) (4 diffs)
-
WebCore/platform/gtk/KeyBindingTranslator.cpp (modified) (2 diffs)
-
WebCore/platform/gtk/KeyBindingTranslator.h (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/Shared/NativeWebKeyboardEvent.h (modified) (1 diff)
-
WebKit2/Shared/WebEvent.h (modified) (3 diffs)
-
WebKit2/Shared/WebEventConversion.cpp (modified) (1 diff)
-
WebKit2/Shared/WebKeyboardEvent.cpp (modified) (3 diffs)
-
WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp (modified) (2 diffs)
-
WebKit2/Shared/gtk/WebEventFactory.cpp (modified) (1 diff)
-
WebKit2/Shared/gtk/WebEventFactory.h (modified) (1 diff)
-
WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (modified) (1 diff)
-
WebKit2/UIProcess/API/gtk/PageClientImpl.h (modified) (3 diffs)
-
WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (5 diffs)
-
WebKit2/UIProcess/PageClient.h (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit2/UIProcess/gtk/InputMethodFilter.cpp (modified) (5 diffs)
-
WebKit2/UIProcess/gtk/InputMethodFilter.h (modified) (3 diffs)
-
WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (modified) (2 diffs)
-
WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r185411 r185415 1 2015-06-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Get rid of GetEditorCommandsForKeyEvent sync message 4 https://bugs.webkit.org/show_bug.cgi?id=145598 5 6 Reviewed by Žan Doberšek. 7 8 * platform/PlatformKeyboardEvent.h: 9 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 10 (WebCore::PlatformKeyboardEvent::commands): 11 * platform/gtk/KeyBindingTranslator.cpp: Use a single list of 12 custom key bindings. We don't need to distinguish between key down and 13 key press commands, since the web editor client already does that 14 when executing the commands. 15 (WebCore::KeyBindingTranslator::commandsForKeyEvent): This is 16 getEditorCommandsForKeyEvent() renamed as commandsForKeyEvent(), 17 since it now returns the list of commands to simplify the 18 code. Also simplify the custom key bindings handling, by using the 19 global list instead of moving it to a HashMap. 20 (WebCore::KeyBindingTranslator::getEditorCommandsForKeyEvent): Deleted. 21 * platform/gtk/KeyBindingTranslator.h: 22 1 23 2015-06-10 Per Arne Vollan <peavo@outlook.com> 2 24 -
trunk/Source/WebCore/platform/PlatformKeyboardEvent.h
r172862 r185415 62 62 , m_nativeVirtualKeyCode(0) 63 63 , m_macCharCode(0) 64 #if USE(APPKIT) 64 #if USE(APPKIT) || PLATFORM(GTK) 65 65 , m_handledByInputMethod(false) 66 66 #endif … … 82 82 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) 83 83 , m_macCharCode(macCharCode) 84 #if USE(APPKIT) 84 #if USE(APPKIT) || PLATFORM(GTK) 85 85 , m_handledByInputMethod(false) 86 86 #endif … … 116 116 int macCharCode() const { return m_macCharCode; } 117 117 118 #if USE(APPKIT) || PLATFORM(GTK) 119 bool handledByInputMethod() const { return m_handledByInputMethod; } 120 #endif 118 121 #if USE(APPKIT) 119 bool handledByInputMethod() const { return m_handledByInputMethod; }120 122 const Vector<KeypressCommand>& commands() const { return m_commands; } 123 #elif PLATFORM(GTK) 124 const Vector<String>& commands() const { return m_commands; } 121 125 #endif 122 126 … … 163 167 int m_nativeVirtualKeyCode; 164 168 int m_macCharCode; 169 #if USE(APPKIT) || PLATFORM(GTK) 170 bool m_handledByInputMethod; 171 #endif 165 172 #if USE(APPKIT) 166 bool m_handledByInputMethod;167 173 Vector<KeypressCommand> m_commands; 174 #elif PLATFORM(GTK) 175 Vector<String> m_commands; 168 176 #endif 169 177 bool m_autoRepeat; -
trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp
r165607 r185415 185 185 }; 186 186 187 static const KeyCombinationEntry keyDownEntries[] = {187 static const KeyCombinationEntry customKeyBindings[] = { 188 188 { GDK_b, GDK_CONTROL_MASK, "ToggleBold" }, 189 189 { GDK_i, GDK_CONTROL_MASK, "ToggleItalic" }, 190 190 { GDK_Escape, 0, "Cancel" }, 191 191 { GDK_greater, GDK_CONTROL_MASK, "Cancel" }, 192 };193 194 // These commands are text insertion commands, so should take place195 // while handling the KeyPress event.196 static const KeyCombinationEntry keyPressEntries[] = {197 192 { GDK_Tab, 0, "InsertTab" }, 198 193 { GDK_Tab, GDK_SHIFT_MASK, "InsertBacktab" }, 199 194 }; 200 195 201 void KeyBindingTranslator::getEditorCommandsForKeyEvent(GdkEventKey* event, EventType type, Vector<WTF::String>& commandList) 202 { 203 m_pendingEditorCommands.clear(); 204 196 Vector<String> KeyBindingTranslator::commandsForKeyEvent(GdkEventKey* event) 197 { 198 ASSERT(m_pendingEditorCommands.isEmpty()); 199 200 // FIXME: Move KeyBindingTranslator to WebKit layer and remove the GTK2 code. 205 201 #ifdef GTK_API_VERSION_2 206 202 gtk_bindings_activate_event(GTK_OBJECT(m_nativeWidget.get()), event); … … 209 205 #endif 210 206 211 if (!m_pendingEditorCommands.isEmpty()) { 212 commandList.appendVector(m_pendingEditorCommands); 213 return; 207 if (!m_pendingEditorCommands.isEmpty()) 208 return WTF::move(m_pendingEditorCommands); 209 210 // Special-case enter keys for we want them to work regardless of modifier. 211 if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || event->keyval == GDK_ISO_Enter)) 212 return { "InsertNewLine" }; 213 214 // For keypress events, we want charCode(), but keyCode() does that. 215 unsigned mapKey = event->state << 16 | event->keyval; 216 if (!mapKey) 217 return { }; 218 219 for (unsigned i = 0; i < G_N_ELEMENTS(customKeyBindings); ++i) { 220 if (mapKey == (customKeyBindings[i].state << 16 | customKeyBindings[i].gdkKeyCode)) 221 return { customKeyBindings[i].name }; 214 222 } 215 223 216 DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyDownCommandsMap, ()); 217 DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyPressCommandsMap, ()); 218 219 if (keyDownCommandsMap.isEmpty()) { 220 for (unsigned i = 0; i < G_N_ELEMENTS(keyDownEntries); i++) 221 keyDownCommandsMap.set(keyDownEntries[i].state << 16 | keyDownEntries[i].gdkKeyCode, keyDownEntries[i].name); 222 223 for (unsigned i = 0; i < G_N_ELEMENTS(keyPressEntries); i++) 224 keyPressCommandsMap.set(keyPressEntries[i].state << 16 | keyPressEntries[i].gdkKeyCode, keyPressEntries[i].name); 225 } 226 227 // Special-case enter keys for we want them to work regardless of modifier. 228 if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || event->keyval == GDK_ISO_Enter) && type == KeyPress) { 229 commandList.append("InsertNewLine"); 230 return; 231 } 232 233 // For keypress events, we want charCode(), but keyCode() does that. 234 int mapKey = event->state << 16 | event->keyval; 235 if (mapKey) { 236 HashMap<int, const char*>* commandMap = type == KeyDown ? &keyDownCommandsMap : &keyPressCommandsMap; 237 if (const char* commandString = commandMap->get(mapKey)) { 238 commandList.append(commandString); 239 return; 240 } 241 } 224 return { }; 242 225 } 243 226 -
trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h
r127757 r185415 32 32 KeyBindingTranslator(); 33 33 34 enum EventType { KeyDown, KeyPress }; 35 void getEditorCommandsForKeyEvent(GdkEventKey*, EventType, Vector<WTF::String>&); 34 Vector<String> commandsForKeyEvent(GdkEventKey*); 36 35 void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(command); } 37 36 38 37 private: 39 38 GRefPtr<GtkWidget> m_nativeWidget; 40 Vector< WTF::String> m_pendingEditorCommands;39 Vector<String> m_pendingEditorCommands; 41 40 }; 42 41 -
trunk/Source/WebKit2/ChangeLog
r185413 r185415 1 2015-06-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Get rid of GetEditorCommandsForKeyEvent sync message 4 https://bugs.webkit.org/show_bug.cgi?id=145598 5 6 Reviewed by Žan Doberšek. 7 8 We are sending GetEditorCommandsForKeyEvent sync message from web 9 process to the UI process for every key pressed. And if the 10 keydown event doesn't handle the key, the message is sent again 11 for the keypress event, so in many cases it happens twice per 12 keypress. We can get the list of commands when the key press event 13 happens in the web view, and send it to the web process as part of 14 the keyboard event like mac port does. In the web process, 15 commands not inserting text will be handled by keydown and the 16 rest in keypress without having to use any other IPC message for that. 17 18 * Shared/NativeWebKeyboardEvent.h: Add command list parameter to 19 the constructor. 20 * Shared/WebEvent.h: Add GTK specific constructor that receives a 21 list of commands and whether the event was handled by input methods. 22 (WebKit::WebKeyboardEvent::commands): Returns the list of commands. 23 * Shared/WebEventConversion.cpp: 24 (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent): 25 Also copy the commands and handledByInputMethod member. 26 * Shared/WebKeyboardEvent.cpp: 27 (WebKit::WebKeyboardEvent::WebKeyboardEvent): Implement GTK 28 specific constructor that receives a list of commands and whether 29 the event was handled by input methods. 30 (WebKit::WebKeyboardEvent::encode): Encode commands and handledByInputMethod. 31 (WebKit::WebKeyboardEvent::decode): Decode commands and handledByInputMethod. 32 * Shared/gtk/NativeWebKeyboardEventGtk.cpp: 33 (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add 34 command list parameter to the constructor. 35 * Shared/gtk/WebEventFactory.cpp: 36 (WebKit::WebEventFactory::createWebKeyboardEvent): Use the new 37 WebKeyboardEvent constructor and simplify the code. We don't need 38 to explicitly set VK_PROCESSKEY as windows virtual key code when 39 the event was handled by input methods. The WebCore event handler 40 already does that. 41 * Shared/gtk/WebEventFactory.h: 42 * UIProcess/API/gtk/PageClientImpl.cpp: 43 (WebKit::PageClientImpl::getEditorCommandsForKeyEvent): Deleted. 44 * UIProcess/API/gtk/PageClientImpl.h: 45 * UIProcess/API/gtk/WebKitWebViewBase.cpp: Add a 46 KeyBindingTranslator member. 47 (webkitWebViewBaseKeyPressEvent): Use the new 48 InputMethodFilter::filterKeyEvent() API and get the list of 49 commands for the key when events was not handled by input methods. 50 (webkitWebViewBaseKeyReleaseEvent): Use the new 51 InputMethodFilter::filterKeyEvent() API. 52 * UIProcess/PageClient.h: 53 * UIProcess/WebPageProxy.messages.in: Remove GetEditorCommandsForKeyEvent message. 54 * UIProcess/gtk/InputMethodFilter.cpp: 55 (WebKit::InputMethodFilter::handleKeyboardEvent): Call the 56 completation handler. 57 (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults): Ditto. 58 (WebKit::InputMethodFilter::filterKeyEvent): Use a completion 59 handler for the task, so that the caller (the web view) can handle 60 the keyboard event. 61 * UIProcess/gtk/InputMethodFilter.h: 62 * UIProcess/gtk/WebPageProxyGtk.cpp: 63 (WebKit::WebPageProxy::getEditorCommandsForKeyEvent): Deleted. 64 * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp: 65 (WebKit::WebEditorClient::handleKeyboardEvent): Return earlier if 66 the event was handled by input methods. And get the list of 67 commands from the PlatformKeyboardEvent instead of sending a sync 68 message to the UI process. 69 (WebKit::WebEditorClient::handleInputMethodKeydown): If the event 70 was handled by inpout methods, set the event as default handled so 71 that the WebCore event handler sets VK_PROCESSKEY as windows 72 virtual key code. 73 (WebKit::WebEditorClient::getEditorCommandsForKeyEvent): Deleted. 74 1 75 2015-06-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 76 -
trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h
r175046 r185415 64 64 #elif PLATFORM(GTK) 65 65 NativeWebKeyboardEvent(const NativeWebKeyboardEvent&); 66 NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition );66 NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands); 67 67 #elif PLATFORM(EFL) 68 68 NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool); -
trunk/Source/WebKit2/Shared/WebEvent.h
r184028 r185415 236 236 #if USE(APPKIT) 237 237 WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp); 238 #elif PLATFORM(GTK) 239 WebKeyboardEvent(Type, const String& text, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp); 238 240 #else 239 241 WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp); … … 246 248 int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } 247 249 int32_t macCharCode() const { return m_macCharCode; } 250 #if USE(APPKIT) || PLATFORM(GTK) 251 bool handledByInputMethod() const { return m_handledByInputMethod; } 252 #endif 248 253 #if USE(APPKIT) 249 bool handledByInputMethod() const { return m_handledByInputMethod; }250 254 const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; } 255 #elif PLATFORM(GTK) 256 const Vector<String>& commands() const { return m_commands; } 251 257 #endif 252 258 bool isAutoRepeat() const { return m_isAutoRepeat; } … … 266 272 int32_t m_nativeVirtualKeyCode; 267 273 int32_t m_macCharCode; 274 #if USE(APPKIT) || PLATFORM(GTK) 275 bool m_handledByInputMethod; 276 #endif 268 277 #if USE(APPKIT) 269 bool m_handledByInputMethod;270 278 Vector<WebCore::KeypressCommand> m_commands; 279 #elif PLATFORM(GTK) 280 Vector<String> m_commands; 271 281 #endif 272 282 bool m_isAutoRepeat; -
trunk/Source/WebKit2/Shared/WebEventConversion.cpp
r184028 r185415 205 205 m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode(); 206 206 m_macCharCode = webEvent.macCharCode(); 207 #if USE(APPKIT) 207 #if USE(APPKIT) || PLATFORM(GTK) 208 208 m_handledByInputMethod = webEvent.handledByInputMethod(); 209 209 m_commands = webEvent.commands(); -
trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp
r165356 r185415 55 55 } 56 56 57 #elif PLATFORM(GTK) 58 59 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers modifiers, double timestamp) 60 : WebEvent(type, modifiers, timestamp) 61 , m_text(text) 62 , m_unmodifiedText(text) 63 , m_keyIdentifier(keyIdentifier) 64 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) 65 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) 66 , m_macCharCode(0) 67 , m_handledByInputMethod(handledByInputMethod) 68 , m_commands(WTF::move(commands)) 69 , m_isAutoRepeat(false) 70 , m_isKeypad(isKeypad) 71 , m_isSystemKey(false) 72 { 73 ASSERT(isKeyboardEventType(type)); 74 } 75 57 76 #else 58 77 … … 88 107 encoder << m_nativeVirtualKeyCode; 89 108 encoder << m_macCharCode; 90 #if USE(APPKIT) 109 #if USE(APPKIT) || PLATFORM(GTK) 91 110 encoder << m_handledByInputMethod; 92 111 encoder << m_commands; … … 114 133 if (!decoder.decode(result.m_macCharCode)) 115 134 return false; 116 #if USE(APPKIT) 135 #if USE(APPKIT) || PLATFORM(GTK) 117 136 if (!decoder.decode(result.m_handledByInputMethod)) 118 137 return false; -
trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp
r175046 r185415 36 36 namespace WebKit { 37 37 38 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked )39 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults ))38 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands) 39 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTF::move(commands))) 40 40 , m_nativeEvent(gdk_event_copy(event)) 41 41 , m_compositionResults(compositionResults) … … 45 45 46 46 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event) 47 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults() ))47 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands()))) 48 48 , m_nativeEvent(gdk_event_copy(event.nativeEvent())) 49 49 , m_compositionResults(event.compositionResults()) -
trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
r182005 r185415 182 182 } 183 183 184 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults) 185 { 186 unsigned int keyValue = event->key.keyval; 187 String text = compositionResults.simpleString.length() ? 188 compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyValue); 189 190 int windowsVirtualKeyCode = compositionResults.compositionUpdated() ? 191 VK_PROCESSKEY : PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval); 192 193 return WebKeyboardEvent((event->type == GDK_KEY_RELEASE) ? WebEvent::KeyUp : WebEvent::KeyDown, 194 text, 195 text, 196 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyValue), 197 windowsVirtualKeyCode, 198 static_cast<int>(keyValue), 199 0 /* macCharCode */, 200 false /* isAutoRepeat */, 201 isGdkKeyCodeFromKeyPad(keyValue), 202 false /* isSystemKey */, 203 modifiersForEvent(event), 204 gdk_event_get_time(event)); 184 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands) 185 { 186 return WebKeyboardEvent( 187 event->type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown, 188 compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(event->key.keyval), 189 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(event->key.keyval), 190 PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval), 191 static_cast<int>(event->key.keyval), 192 compositionResults.compositionUpdated(), 193 WTF::move(commands), 194 isGdkKeyCodeFromKeyPad(event->key.keyval), 195 modifiersForEvent(event), 196 gdk_event_get_time(event)); 205 197 } 206 198 -
trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h
r182005 r185415 39 39 static WebMouseEvent createWebMouseEvent(const GdkEvent*, int); 40 40 static WebWheelEvent createWebWheelEvent(const GdkEvent*); 41 static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults& );41 static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&, Vector<String>&& commands); 42 42 static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&); 43 43 }; -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r183517 r185415 57 57 } 58 58 59 void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, const AtomicString& eventType, Vector<WTF::String>& commandList)60 {61 ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent);62 63 KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ?64 KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress;65 m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast<GdkEventKey*>(&event.nativeEvent()->key), type, commandList);66 }67 68 59 // PageClient's pure virtual functions 69 60 std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
r183517 r185415 30 30 31 31 #include "DefaultUndoController.h" 32 #include "KeyBindingTranslator.h"33 32 #include "PageClient.h" 34 33 #include "WebFullScreenManagerProxy.h" 35 34 #include "WebPageProxy.h" 36 #include "WindowsKeyboardCodes.h"37 35 #include <WebCore/IntSize.h> 38 36 #include <gtk/gtk.h> … … 92 90 virtual void clearTextIndicator(WebCore::TextIndicatorDismissalAnimation = WebCore::TextIndicatorDismissalAnimation::FadeOut) override; 93 91 virtual void setTextIndicatorAnimationProgress(float) override; 94 virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) override;95 92 virtual void updateTextInputState() override; 96 93 #if ENABLE(DRAG_SUPPORT) … … 139 136 GtkWidget* m_viewWidget; 140 137 DefaultUndoController m_undoController; 141 WebCore::KeyBindingTranslator m_keyBindingTranslator;142 138 }; 143 139 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r183731 r185415 32 32 #include "DrawingAreaProxyImpl.h" 33 33 #include "InputMethodFilter.h" 34 #include "NativeWebKeyboardEvent.h" 34 35 #include "NativeWebMouseEvent.h" 35 36 #include "NativeWebWheelEvent.h" … … 53 54 #include <WebCore/GtkUtilities.h> 54 55 #include <WebCore/GtkVersioning.h> 56 #include <WebCore/KeyBindingTranslator.h> 55 57 #include <WebCore/NotImplemented.h> 56 58 #include <WebCore/PasteboardHelper.h> … … 164 166 WebContextMenuProxyGtk* activeContextMenuProxy; 165 167 InputMethodFilter inputMethodFilter; 168 KeyBindingTranslator keyBindingTranslator; 166 169 TouchEventsMap touchEvents; 167 170 … … 750 753 return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event); 751 754 } 752 priv->inputMethodFilter.filterKeyEvent(event); 755 756 priv->inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) { 757 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), compositionResults, faked, 758 !compositionResults.compositionUpdated() ? priv->keyBindingTranslator.commandsForKeyEvent(event) : Vector<String>())); 759 }); 760 753 761 return TRUE; 754 762 } … … 763 771 return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_release_event(widget, event); 764 772 } 765 priv->inputMethodFilter.filterKeyEvent(event); 773 774 priv->inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) { 775 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), compositionResults, faked, { })); 776 }); 777 766 778 return TRUE; 767 779 } -
trunk/Source/WebKit2/UIProcess/PageClient.h
r184780 r185415 197 197 #endif 198 198 199 #if PLATFORM(GTK)200 virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) = 0;201 #endif202 199 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0; 203 200 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r185013 r185415 205 205 206 206 #if PLATFORM(GTK) 207 # Support for GTK+ platform keybindings208 GetEditorCommandsForKeyEvent(AtomicString eventType) -> (Vector<String> commandsList)209 210 207 # Support for connecting the Accessibility worlds of the UI and the Web processes 211 208 BindAccessibilityTree(String plugID) -
trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp
r175047 r185415 21 21 #include "InputMethodFilter.h" 22 22 23 #include "NativeWebKeyboardEvent.h"24 23 #include "WebPageProxy.h" 25 24 #include <WebCore/Color.h> … … 123 122 } 124 123 #endif 125 m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(simpleString), faked)); 124 125 ASSERT(m_filterKeyEventCompletionHandler); 126 m_filterKeyEventCompletionHandler(CompositionResults(simpleString), faked); 127 m_filterKeyEventCompletionHandler = nullptr; 126 128 } 127 129 … … 134 136 } 135 137 #endif 136 m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked)); 138 139 ASSERT(m_filterKeyEventCompletionHandler); 140 m_filterKeyEventCompletionHandler(CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked); 141 m_filterKeyEventCompletionHandler = nullptr; 137 142 138 143 if (resultsToSend & Composition && !m_confirmedComposition.isNull()) … … 145 150 } 146 151 147 void InputMethodFilter::filterKeyEvent(GdkEventKey* event )152 void InputMethodFilter::filterKeyEvent(GdkEventKey* event, FilterKeyEventCompletionHandler&& completionHandler) 148 153 { 149 154 #if ENABLE(API_TESTS) … … 152 157 ASSERT(m_page); 153 158 #endif 159 m_filterKeyEventCompletionHandler = WTF::move(completionHandler); 154 160 if (!m_enabled) { 155 161 handleKeyboardEvent(event); -
trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h
r175046 r185415 30 30 31 31 namespace WebCore { 32 class CompositionResults; 32 33 class IntRect; 33 34 } … … 55 56 void setCursorRect(const WebCore::IntRect&); 56 57 57 void filterKeyEvent(GdkEventKey*); 58 using FilterKeyEventCompletionHandler = std::function<void (const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition)>; 59 void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&& = nullptr); 58 60 void notifyFocusedIn(); 59 61 void notifyFocusedOut(); … … 112 114 String m_preedit; 113 115 116 FilterKeyEventCompletionHandler m_filterKeyEventCompletionHandler; 117 114 118 #if ENABLE(API_TESTS) 115 119 bool m_testingMode; -
trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
r180465 r185415 28 28 #include "WebPageProxy.h" 29 29 30 #include "NativeWebKeyboardEvent.h"31 30 #include "NotImplemented.h" 32 31 #include "PageClientImpl.h" … … 52 51 { 53 52 return WebCore::standardUserAgent(applicationNameForUserAgent); 54 }55 56 void WebPageProxy::getEditorCommandsForKeyEvent(const AtomicString& eventType, Vector<WTF::String>& commandsList)57 {58 // When the keyboard event is started in the WebProcess side (e.g. from the Inspector)59 // it will arrive without a GdkEvent associated, so the keyEventQueue will be empty.60 if (!m_keyEventQueue.isEmpty())61 m_pageClient.getEditorCommandsForKeyEvent(m_keyEventQueue.first(), eventType, commandsList);62 53 } 63 54 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
r179409 r185415 22 22 23 23 #include "PlatformKeyboardEvent.h" 24 #include "WebPage.h"25 #include "WebPageProxyMessages.h"26 #include "WebProcess.h"27 24 #include <WebCore/DataObjectGtk.h> 28 25 #include <WebCore/Document.h> 26 #include <WebCore/Editor.h> 29 27 #include <WebCore/Frame.h> 30 28 #include <WebCore/FrameDestructionObserver.h> 31 29 #include <WebCore/KeyboardEvent.h> 32 30 #include <WebCore/Pasteboard.h> 33 #include <WebCore/WindowsKeyboardCodes.h>34 31 #include <WebCore/markup.h> 35 32 #include <wtf/gobject/GRefPtr.h> … … 38 35 39 36 namespace WebKit { 40 41 void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, Vector<WTF::String>& pendingEditorCommands)42 {43 ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent);44 45 /* First try to interpret the command in the UI and get the commands.46 UI needs to receive event type because only knows current NativeWebKeyboardEvent.*/47 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetEditorCommandsForKeyEvent(event->type()),48 Messages::WebPageProxy::GetEditorCommandsForKeyEvent::Reply(pendingEditorCommands),49 m_page->pageID(), std::chrono::milliseconds::max());50 }51 37 52 38 bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion) … … 71 57 void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) 72 58 { 59 const PlatformKeyboardEvent* platformEvent = event->keyEvent(); 60 if (!platformEvent) 61 return; 62 63 // If this was an IME event don't do anything. 64 if (platformEvent->handledByInputMethod()) 65 return; 66 73 67 Node* node = event->target()->toNode(); 74 68 ASSERT(node); … … 76 70 ASSERT(frame); 77 71 78 const PlatformKeyboardEvent* platformEvent = event->keyEvent(); 79 if (!platformEvent) 80 return; 81 82 // If this was an IME event don't do anything. 83 if (platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY) 84 return; 85 86 Vector<WTF::String> pendingEditorCommands; 87 getEditorCommandsForKeyEvent(event, pendingEditorCommands); 72 const Vector<String> pendingEditorCommands = platformEvent->commands(); 88 73 if (!pendingEditorCommands.isEmpty()) { 89 74 … … 130 115 { 131 116 const PlatformKeyboardEvent* platformEvent = event->keyEvent(); 132 if (platformEvent && platformEvent-> windowsVirtualKeyCode() == VK_PROCESSKEY)133 event-> preventDefault();117 if (platformEvent && platformEvent->handledByInputMethod()) 118 event->setDefaultHandled(); 134 119 } 135 120
Note:
See TracChangeset
for help on using the changeset viewer.