Diff
Modified: trunk/Source/WebCore/ChangeLog (185414 => 185415)
--- trunk/Source/WebCore/ChangeLog 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/ChangeLog 2015-06-10 13:32:22 UTC (rev 185415)
@@ -1,3 +1,25 @@
+2015-06-10 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Get rid of GetEditorCommandsForKeyEvent sync message
+ https://bugs.webkit.org/show_bug.cgi?id=145598
+
+ Reviewed by Žan Doberšek.
+
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ (WebCore::PlatformKeyboardEvent::commands):
+ * platform/gtk/KeyBindingTranslator.cpp: Use a single list of
+ custom key bindings. We don't need to distinguish between key down and
+ key press commands, since the web editor client already does that
+ when executing the commands.
+ (WebCore::KeyBindingTranslator::commandsForKeyEvent): This is
+ getEditorCommandsForKeyEvent() renamed as commandsForKeyEvent(),
+ since it now returns the list of commands to simplify the
+ code. Also simplify the custom key bindings handling, by using the
+ global list instead of moving it to a HashMap.
+ (WebCore::KeyBindingTranslator::getEditorCommandsForKeyEvent): Deleted.
+ * platform/gtk/KeyBindingTranslator.h:
+
2015-06-10 Per Arne Vollan <[email protected]>
[WinCairo] Crash on exit when terminating egl
Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (185414 => 185415)
--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -61,7 +61,7 @@
, m_windowsVirtualKeyCode(0)
, m_nativeVirtualKeyCode(0)
, m_macCharCode(0)
-#if USE(APPKIT)
+#if USE(APPKIT) || PLATFORM(GTK)
, m_handledByInputMethod(false)
#endif
, m_autoRepeat(false)
@@ -81,7 +81,7 @@
, m_windowsVirtualKeyCode(windowsVirtualKeyCode)
, m_nativeVirtualKeyCode(nativeVirtualKeyCode)
, m_macCharCode(macCharCode)
-#if USE(APPKIT)
+#if USE(APPKIT) || PLATFORM(GTK)
, m_handledByInputMethod(false)
#endif
, m_autoRepeat(isAutoRepeat)
@@ -115,9 +115,13 @@
int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
int macCharCode() const { return m_macCharCode; }
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool handledByInputMethod() const { return m_handledByInputMethod; }
+#endif
#if USE(APPKIT)
- bool handledByInputMethod() const { return m_handledByInputMethod; }
const Vector<KeypressCommand>& commands() const { return m_commands; }
+#elif PLATFORM(GTK)
+ const Vector<String>& commands() const { return m_commands; }
#endif
bool isAutoRepeat() const { return m_autoRepeat; }
@@ -162,9 +166,13 @@
int m_windowsVirtualKeyCode;
int m_nativeVirtualKeyCode;
int m_macCharCode;
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool m_handledByInputMethod;
+#endif
#if USE(APPKIT)
- bool m_handledByInputMethod;
Vector<KeypressCommand> m_commands;
+#elif PLATFORM(GTK)
+ Vector<String> m_commands;
#endif
bool m_autoRepeat;
bool m_isKeypad;
Modified: trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp (185414 => 185415)
--- trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -184,61 +184,44 @@
const char* name;
};
-static const KeyCombinationEntry keyDownEntries[] = {
+static const KeyCombinationEntry customKeyBindings[] = {
{ GDK_b, GDK_CONTROL_MASK, "ToggleBold" },
{ GDK_i, GDK_CONTROL_MASK, "ToggleItalic" },
{ GDK_Escape, 0, "Cancel" },
{ GDK_greater, GDK_CONTROL_MASK, "Cancel" },
-};
-
-// These commands are text insertion commands, so should take place
-// while handling the KeyPress event.
-static const KeyCombinationEntry keyPressEntries[] = {
{ GDK_Tab, 0, "InsertTab" },
{ GDK_Tab, GDK_SHIFT_MASK, "InsertBacktab" },
};
-void KeyBindingTranslator::getEditorCommandsForKeyEvent(GdkEventKey* event, EventType type, Vector<WTF::String>& commandList)
+Vector<String> KeyBindingTranslator::commandsForKeyEvent(GdkEventKey* event)
{
- m_pendingEditorCommands.clear();
+ ASSERT(m_pendingEditorCommands.isEmpty());
+ // FIXME: Move KeyBindingTranslator to WebKit layer and remove the GTK2 code.
#ifdef GTK_API_VERSION_2
gtk_bindings_activate_event(GTK_OBJECT(m_nativeWidget.get()), event);
#else
gtk_bindings_activate_event(G_OBJECT(m_nativeWidget.get()), event);
#endif
- if (!m_pendingEditorCommands.isEmpty()) {
- commandList.appendVector(m_pendingEditorCommands);
- return;
- }
+ if (!m_pendingEditorCommands.isEmpty())
+ return WTF::move(m_pendingEditorCommands);
- DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyDownCommandsMap, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyPressCommandsMap, ());
-
- if (keyDownCommandsMap.isEmpty()) {
- for (unsigned i = 0; i < G_N_ELEMENTS(keyDownEntries); i++)
- keyDownCommandsMap.set(keyDownEntries[i].state << 16 | keyDownEntries[i].gdkKeyCode, keyDownEntries[i].name);
-
- for (unsigned i = 0; i < G_N_ELEMENTS(keyPressEntries); i++)
- keyPressCommandsMap.set(keyPressEntries[i].state << 16 | keyPressEntries[i].gdkKeyCode, keyPressEntries[i].name);
- }
-
// Special-case enter keys for we want them to work regardless of modifier.
- if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || event->keyval == GDK_ISO_Enter) && type == KeyPress) {
- commandList.append("InsertNewLine");
- return;
- }
+ if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || event->keyval == GDK_ISO_Enter))
+ return { "InsertNewLine" };
// For keypress events, we want charCode(), but keyCode() does that.
- int mapKey = event->state << 16 | event->keyval;
- if (mapKey) {
- HashMap<int, const char*>* commandMap = type == KeyDown ? &keyDownCommandsMap : &keyPressCommandsMap;
- if (const char* commandString = commandMap->get(mapKey)) {
- commandList.append(commandString);
- return;
- }
+ unsigned mapKey = event->state << 16 | event->keyval;
+ if (!mapKey)
+ return { };
+
+ for (unsigned i = 0; i < G_N_ELEMENTS(customKeyBindings); ++i) {
+ if (mapKey == (customKeyBindings[i].state << 16 | customKeyBindings[i].gdkKeyCode))
+ return { customKeyBindings[i].name };
}
+
+ return { };
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h (185414 => 185415)
--- trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -31,13 +31,12 @@
public:
KeyBindingTranslator();
- enum EventType { KeyDown, KeyPress };
- void getEditorCommandsForKeyEvent(GdkEventKey*, EventType, Vector<WTF::String>&);
+ Vector<String> commandsForKeyEvent(GdkEventKey*);
void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(command); }
private:
GRefPtr<GtkWidget> m_nativeWidget;
- Vector<WTF::String> m_pendingEditorCommands;
+ Vector<String> m_pendingEditorCommands;
};
} // namespace WebCore
Modified: trunk/Source/WebKit2/ChangeLog (185414 => 185415)
--- trunk/Source/WebKit2/ChangeLog 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/ChangeLog 2015-06-10 13:32:22 UTC (rev 185415)
@@ -1,5 +1,79 @@
2015-06-10 Carlos Garcia Campos <[email protected]>
+ [GTK] Get rid of GetEditorCommandsForKeyEvent sync message
+ https://bugs.webkit.org/show_bug.cgi?id=145598
+
+ Reviewed by Žan Doberšek.
+
+ We are sending GetEditorCommandsForKeyEvent sync message from web
+ process to the UI process for every key pressed. And if the
+ keydown event doesn't handle the key, the message is sent again
+ for the keypress event, so in many cases it happens twice per
+ keypress. We can get the list of commands when the key press event
+ happens in the web view, and send it to the web process as part of
+ the keyboard event like mac port does. In the web process,
+ commands not inserting text will be handled by keydown and the
+ rest in keypress without having to use any other IPC message for that.
+
+ * Shared/NativeWebKeyboardEvent.h: Add command list parameter to
+ the constructor.
+ * Shared/WebEvent.h: Add GTK specific constructor that receives a
+ list of commands and whether the event was handled by input methods.
+ (WebKit::WebKeyboardEvent::commands): Returns the list of commands.
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+ Also copy the commands and handledByInputMethod member.
+ * Shared/WebKeyboardEvent.cpp:
+ (WebKit::WebKeyboardEvent::WebKeyboardEvent): Implement GTK
+ specific constructor that receives a list of commands and whether
+ the event was handled by input methods.
+ (WebKit::WebKeyboardEvent::encode): Encode commands and handledByInputMethod.
+ (WebKit::WebKeyboardEvent::decode): Decode commands and handledByInputMethod.
+ * Shared/gtk/NativeWebKeyboardEventGtk.cpp:
+ (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): Add
+ command list parameter to the constructor.
+ * Shared/gtk/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebKeyboardEvent): Use the new
+ WebKeyboardEvent constructor and simplify the code. We don't need
+ to explicitly set VK_PROCESSKEY as windows virtual key code when
+ the event was handled by input methods. The WebCore event handler
+ already does that.
+ * Shared/gtk/WebEventFactory.h:
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::getEditorCommandsForKeyEvent): Deleted.
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp: Add a
+ KeyBindingTranslator member.
+ (webkitWebViewBaseKeyPressEvent): Use the new
+ InputMethodFilter::filterKeyEvent() API and get the list of
+ commands for the key when events was not handled by input methods.
+ (webkitWebViewBaseKeyReleaseEvent): Use the new
+ InputMethodFilter::filterKeyEvent() API.
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.messages.in: Remove GetEditorCommandsForKeyEvent message.
+ * UIProcess/gtk/InputMethodFilter.cpp:
+ (WebKit::InputMethodFilter::handleKeyboardEvent): Call the
+ completation handler.
+ (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults): Ditto.
+ (WebKit::InputMethodFilter::filterKeyEvent): Use a completion
+ handler for the task, so that the caller (the web view) can handle
+ the keyboard event.
+ * UIProcess/gtk/InputMethodFilter.h:
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ (WebKit::WebPageProxy::getEditorCommandsForKeyEvent): Deleted.
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::WebEditorClient::handleKeyboardEvent): Return earlier if
+ the event was handled by input methods. And get the list of
+ commands from the PlatformKeyboardEvent instead of sending a sync
+ message to the UI process.
+ (WebKit::WebEditorClient::handleInputMethodKeydown): If the event
+ was handled by inpout methods, set the event as default handled so
+ that the WebCore event handler sets VK_PROCESSKEY as windows
+ virtual key code.
+ (WebKit::WebEditorClient::getEditorCommandsForKeyEvent): Deleted.
+
+2015-06-10 Carlos Garcia Campos <[email protected]>
+
Unreviewed. Fix GTK build after r185412.
Add missing include.
Modified: trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h (185414 => 185415)
--- trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -63,7 +63,7 @@
NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&);
#elif PLATFORM(GTK)
NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
- NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition);
+ NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
#elif PLATFORM(EFL)
NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool);
NativeWebKeyboardEvent(const Evas_Event_Key_Up*);
Modified: trunk/Source/WebKit2/Shared/WebEvent.h (185414 => 185415)
--- trunk/Source/WebKit2/Shared/WebEvent.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebEvent.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -235,6 +235,8 @@
#if USE(APPKIT)
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);
+#elif PLATFORM(GTK)
+ WebKeyboardEvent(Type, const String& text, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
#else
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);
#endif
@@ -245,9 +247,13 @@
int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
int32_t macCharCode() const { return m_macCharCode; }
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool handledByInputMethod() const { return m_handledByInputMethod; }
+#endif
#if USE(APPKIT)
- bool handledByInputMethod() const { return m_handledByInputMethod; }
const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; }
+#elif PLATFORM(GTK)
+ const Vector<String>& commands() const { return m_commands; }
#endif
bool isAutoRepeat() const { return m_isAutoRepeat; }
bool isKeypad() const { return m_isKeypad; }
@@ -265,9 +271,13 @@
int32_t m_windowsVirtualKeyCode;
int32_t m_nativeVirtualKeyCode;
int32_t m_macCharCode;
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool m_handledByInputMethod;
+#endif
#if USE(APPKIT)
- bool m_handledByInputMethod;
Vector<WebCore::KeypressCommand> m_commands;
+#elif PLATFORM(GTK)
+ Vector<String> m_commands;
#endif
bool m_isAutoRepeat;
bool m_isKeypad;
Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (185414 => 185415)
--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -204,7 +204,7 @@
m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode();
m_macCharCode = webEvent.macCharCode();
-#if USE(APPKIT)
+#if USE(APPKIT) || PLATFORM(GTK)
m_handledByInputMethod = webEvent.handledByInputMethod();
m_commands = webEvent.commands();
#endif
Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (185414 => 185415)
--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -54,6 +54,25 @@
ASSERT(isKeyboardEventType(type));
}
+#elif PLATFORM(GTK)
+
+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)
+ : WebEvent(type, modifiers, timestamp)
+ , m_text(text)
+ , m_unmodifiedText(text)
+ , m_keyIdentifier(keyIdentifier)
+ , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+ , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+ , m_macCharCode(0)
+ , m_handledByInputMethod(handledByInputMethod)
+ , m_commands(WTF::move(commands))
+ , m_isAutoRepeat(false)
+ , m_isKeypad(isKeypad)
+ , m_isSystemKey(false)
+{
+ ASSERT(isKeyboardEventType(type));
+}
+
#else
WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
@@ -87,7 +106,7 @@
encoder << m_windowsVirtualKeyCode;
encoder << m_nativeVirtualKeyCode;
encoder << m_macCharCode;
-#if USE(APPKIT)
+#if USE(APPKIT) || PLATFORM(GTK)
encoder << m_handledByInputMethod;
encoder << m_commands;
#endif
@@ -113,7 +132,7 @@
return false;
if (!decoder.decode(result.m_macCharCode))
return false;
-#if USE(APPKIT)
+#if USE(APPKIT) || PLATFORM(GTK)
if (!decoder.decode(result.m_handledByInputMethod))
return false;
if (!decoder.decode(result.m_commands))
Modified: trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp (185414 => 185415)
--- trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -35,8 +35,8 @@
namespace WebKit {
-NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults))
+NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands)
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTF::move(commands)))
, m_nativeEvent(gdk_event_copy(event))
, m_compositionResults(compositionResults)
, m_fakeEventForComposition(faked == InputMethodFilter::EventFaked)
@@ -44,7 +44,7 @@
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults()))
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands())))
, m_nativeEvent(gdk_event_copy(event.nativeEvent()))
, m_compositionResults(event.compositionResults())
, m_fakeEventForComposition(event.isFakeEventForComposition())
Modified: trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp (185414 => 185415)
--- trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -181,27 +181,19 @@
gdk_event_get_time(event));
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
{
- unsigned int keyValue = event->key.keyval;
- String text = compositionResults.simpleString.length() ?
- compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyValue);
-
- int windowsVirtualKeyCode = compositionResults.compositionUpdated() ?
- VK_PROCESSKEY : PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval);
-
- return WebKeyboardEvent((event->type == GDK_KEY_RELEASE) ? WebEvent::KeyUp : WebEvent::KeyDown,
- text,
- text,
- PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyValue),
- windowsVirtualKeyCode,
- static_cast<int>(keyValue),
- 0 /* macCharCode */,
- false /* isAutoRepeat */,
- isGdkKeyCodeFromKeyPad(keyValue),
- false /* isSystemKey */,
- modifiersForEvent(event),
- gdk_event_get_time(event));
+ return WebKeyboardEvent(
+ event->type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
+ compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(event->key.keyval),
+ PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(event->key.keyval),
+ PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval),
+ static_cast<int>(event->key.keyval),
+ compositionResults.compositionUpdated(),
+ WTF::move(commands),
+ isGdkKeyCodeFromKeyPad(event->key.keyval),
+ modifiersForEvent(event),
+ gdk_event_get_time(event));
}
WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector<WebPlatformTouchPoint>&& touchPoints)
Modified: trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h (185414 => 185415)
--- trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -38,7 +38,7 @@
public:
static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
static WebWheelEvent createWebWheelEvent(const GdkEvent*);
- static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
+ static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&, Vector<String>&& commands);
static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
};
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -56,15 +56,6 @@
{
}
-void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, const AtomicString& eventType, Vector<WTF::String>& commandList)
-{
- ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent);
-
- KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ?
- KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress;
- m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast<GdkEventKey*>(&event.nativeEvent()->key), type, commandList);
-}
-
// PageClient's pure virtual functions
std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
{
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -29,11 +29,9 @@
#define PageClientImpl_h
#include "DefaultUndoController.h"
-#include "KeyBindingTranslator.h"
#include "PageClient.h"
#include "WebFullScreenManagerProxy.h"
#include "WebPageProxy.h"
-#include "WindowsKeyboardCodes.h"
#include <WebCore/IntSize.h>
#include <gtk/gtk.h>
#include <memory>
@@ -91,7 +89,6 @@
virtual void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorLifetime = WebCore::TextIndicatorLifetime::Permanent) override;
virtual void clearTextIndicator(WebCore::TextIndicatorDismissalAnimation = WebCore::TextIndicatorDismissalAnimation::FadeOut) override;
virtual void setTextIndicatorAnimationProgress(float) override;
- virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) override;
virtual void updateTextInputState() override;
#if ENABLE(DRAG_SUPPORT)
virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) override;
@@ -138,7 +135,6 @@
// Members of PageClientImpl class
GtkWidget* m_viewWidget;
DefaultUndoController m_undoController;
- WebCore::KeyBindingTranslator m_keyBindingTranslator;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -31,6 +31,7 @@
#include "DrawingAreaProxyImpl.h"
#include "InputMethodFilter.h"
+#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#include "NativeWebWheelEvent.h"
#include "PageClientImpl.h"
@@ -52,6 +53,7 @@
#include <WebCore/GUniquePtrGtk.h>
#include <WebCore/GtkUtilities.h>
#include <WebCore/GtkVersioning.h>
+#include <WebCore/KeyBindingTranslator.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/PasteboardHelper.h>
#include <WebCore/PlatformDisplay.h>
@@ -163,6 +165,7 @@
GUniquePtr<GdkEvent> contextMenuEvent;
WebContextMenuProxyGtk* activeContextMenuProxy;
InputMethodFilter inputMethodFilter;
+ KeyBindingTranslator keyBindingTranslator;
TouchEventsMap touchEvents;
GtkWindow* toplevelOnScreenWindow;
@@ -749,7 +752,12 @@
priv->shouldForwardNextKeyEvent = FALSE;
return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event);
}
- priv->inputMethodFilter.filterKeyEvent(event);
+
+ priv->inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), compositionResults, faked,
+ !compositionResults.compositionUpdated() ? priv->keyBindingTranslator.commandsForKeyEvent(event) : Vector<String>()));
+ });
+
return TRUE;
}
@@ -762,7 +770,11 @@
priv->shouldForwardNextKeyEvent = FALSE;
return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_release_event(widget, event);
}
- priv->inputMethodFilter.filterKeyEvent(event);
+
+ priv->inputMethodFilter.filterKeyEvent(event, [priv, event](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), compositionResults, faked, { }));
+ });
+
return TRUE;
}
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -196,9 +196,6 @@
#endif
#endif
-#if PLATFORM(GTK)
- virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) = 0;
-#endif
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) = 0;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-06-10 13:32:22 UTC (rev 185415)
@@ -204,9 +204,6 @@
PluginZoomFactorDidChange(double zoomFactor)
#if PLATFORM(GTK)
- # Support for GTK+ platform keybindings
- GetEditorCommandsForKeyEvent(AtomicString eventType) -> (Vector<String> commandsList)
-
# Support for connecting the Accessibility worlds of the UI and the Web processes
BindAccessibilityTree(String plugID)
Modified: trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -20,7 +20,6 @@
#include "config.h"
#include "InputMethodFilter.h"
-#include "NativeWebKeyboardEvent.h"
#include "WebPageProxy.h"
#include <WebCore/Color.h>
#include <WebCore/CompositionResults.h>
@@ -122,7 +121,10 @@
return;
}
#endif
- m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(simpleString), faked));
+
+ ASSERT(m_filterKeyEventCompletionHandler);
+ m_filterKeyEventCompletionHandler(CompositionResults(simpleString), faked);
+ m_filterKeyEventCompletionHandler = nullptr;
}
void InputMethodFilter::handleKeyboardEventWithCompositionResults(GdkEventKey* event, ResultsToSend resultsToSend, EventFakedForComposition faked)
@@ -133,8 +135,11 @@
return;
}
#endif
- m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked));
+ ASSERT(m_filterKeyEventCompletionHandler);
+ m_filterKeyEventCompletionHandler(CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked);
+ m_filterKeyEventCompletionHandler = nullptr;
+
if (resultsToSend & Composition && !m_confirmedComposition.isNull())
m_page->confirmComposition(m_confirmedComposition, -1, 0);
@@ -144,13 +149,14 @@
}
}
-void InputMethodFilter::filterKeyEvent(GdkEventKey* event)
+void InputMethodFilter::filterKeyEvent(GdkEventKey* event, FilterKeyEventCompletionHandler&& completionHandler)
{
#if ENABLE(API_TESTS)
ASSERT(m_page || m_testingMode);
#else
ASSERT(m_page);
#endif
+ m_filterKeyEventCompletionHandler = WTF::move(completionHandler);
if (!m_enabled) {
handleKeyboardEvent(event);
return;
Modified: trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h 2015-06-10 13:32:22 UTC (rev 185415)
@@ -29,6 +29,7 @@
typedef struct _GtkIMContext GtkIMContext;
namespace WebCore {
+class CompositionResults;
class IntRect;
}
@@ -54,7 +55,8 @@
void setEnabled(bool);
void setCursorRect(const WebCore::IntRect&);
- void filterKeyEvent(GdkEventKey*);
+ using FilterKeyEventCompletionHandler = std::function<void (const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition)>;
+ void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&& = nullptr);
void notifyFocusedIn();
void notifyFocusedOut();
void notifyMouseButtonPress();
@@ -111,6 +113,8 @@
String m_confirmedComposition;
String m_preedit;
+ FilterKeyEventCompletionHandler m_filterKeyEventCompletionHandler;
+
#if ENABLE(API_TESTS)
bool m_testingMode;
Vector<String> m_events;
Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (185414 => 185415)
--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -27,7 +27,6 @@
#include "config.h"
#include "WebPageProxy.h"
-#include "NativeWebKeyboardEvent.h"
#include "NotImplemented.h"
#include "PageClientImpl.h"
#include "WebKitWebViewBasePrivate.h"
@@ -53,14 +52,6 @@
return WebCore::standardUserAgent(applicationNameForUserAgent);
}
-void WebPageProxy::getEditorCommandsForKeyEvent(const AtomicString& eventType, Vector<WTF::String>& commandsList)
-{
- // When the keyboard event is started in the WebProcess side (e.g. from the Inspector)
- // it will arrive without a GdkEvent associated, so the keyEventQueue will be empty.
- if (!m_keyEventQueue.isEmpty())
- m_pageClient.getEditorCommandsForKeyEvent(m_keyEventQueue.first(), eventType, commandsList);
-}
-
void WebPageProxy::bindAccessibilityTree(const String& plugID)
{
m_accessibilityPlugID = plugID;
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (185414 => 185415)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2015-06-10 13:25:38 UTC (rev 185414)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2015-06-10 13:32:22 UTC (rev 185415)
@@ -21,16 +21,13 @@
#include "WebEditorClient.h"
#include "PlatformKeyboardEvent.h"
-#include "WebPage.h"
-#include "WebPageProxyMessages.h"
-#include "WebProcess.h"
#include <WebCore/DataObjectGtk.h>
#include <WebCore/Document.h>
+#include <WebCore/Editor.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameDestructionObserver.h>
#include <WebCore/KeyboardEvent.h>
#include <WebCore/Pasteboard.h>
-#include <WebCore/WindowsKeyboardCodes.h>
#include <WebCore/markup.h>
#include <wtf/gobject/GRefPtr.h>
@@ -38,17 +35,6 @@
namespace WebKit {
-void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, Vector<WTF::String>& pendingEditorCommands)
-{
- ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent);
-
- /* First try to interpret the command in the UI and get the commands.
- UI needs to receive event type because only knows current NativeWebKeyboardEvent.*/
- WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetEditorCommandsForKeyEvent(event->type()),
- Messages::WebPageProxy::GetEditorCommandsForKeyEvent::Reply(pendingEditorCommands),
- m_page->pageID(), std::chrono::milliseconds::max());
-}
-
bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)
{
Vector<Editor::Command> commands;
@@ -70,21 +56,20 @@
void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
{
- Node* node = event->target()->toNode();
- ASSERT(node);
- Frame* frame = node->document().frame();
- ASSERT(frame);
-
const PlatformKeyboardEvent* platformEvent = event->keyEvent();
if (!platformEvent)
return;
// If this was an IME event don't do anything.
- if (platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
+ if (platformEvent->handledByInputMethod())
return;
- Vector<WTF::String> pendingEditorCommands;
- getEditorCommandsForKeyEvent(event, pendingEditorCommands);
+ Node* node = event->target()->toNode();
+ ASSERT(node);
+ Frame* frame = node->document().frame();
+ ASSERT(frame);
+
+ const Vector<String> pendingEditorCommands = platformEvent->commands();
if (!pendingEditorCommands.isEmpty()) {
// During RawKeyDown events if an editor command will insert text, defer
@@ -129,8 +114,8 @@
void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
{
const PlatformKeyboardEvent* platformEvent = event->keyEvent();
- if (platformEvent && platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
- event->preventDefault();
+ if (platformEvent && platformEvent->handledByInputMethod())
+ event->setDefaultHandled();
}
#if PLATFORM(X11)