⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185415 in webkit


Ignore:
Timestamp:
Jun 10, 2015, 6:32:22 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Get rid of GetEditorCommandsForKeyEvent sync message
​https://bugs.webkit.org/show_bug.cgi?id=145598

Reviewed by Žan Doberšek.

Source/WebCore:

  • 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:

Source/WebKit2:

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.

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185411 r185415  
     12015-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
    1232015-06-10  Per Arne Vollan  <peavo@outlook.com>
    224
  • trunk/Source/WebCore/platform/PlatformKeyboardEvent.h

    r172862 r185415  
    6262            , m_nativeVirtualKeyCode(0)
    6363            , m_macCharCode(0)
    64 #if USE(APPKIT)
     64#if USE(APPKIT) || PLATFORM(GTK)
    6565            , m_handledByInputMethod(false)
    6666#endif
    … …  
    8282            , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
    8383            , m_macCharCode(macCharCode)
    84 #if USE(APPKIT)
     84#if USE(APPKIT) || PLATFORM(GTK)
    8585            , m_handledByInputMethod(false)
    8686#endif
    … …  
    116116        int macCharCode() const { return m_macCharCode; }
    117117
     118#if USE(APPKIT) || PLATFORM(GTK)
     119        bool handledByInputMethod() const { return m_handledByInputMethod; }
     120#endif
    118121#if USE(APPKIT)
    119         bool handledByInputMethod() const { return m_handledByInputMethod; }
    120122        const Vector<KeypressCommand>& commands() const { return m_commands; }
     123#elif PLATFORM(GTK)
     124        const Vector<String>& commands() const { return m_commands; }
    121125#endif
    122126
    … …  
    163167        int m_nativeVirtualKeyCode;
    164168        int m_macCharCode;
     169#if USE(APPKIT) || PLATFORM(GTK)
     170        bool m_handledByInputMethod;
     171#endif
    165172#if USE(APPKIT)
    166         bool m_handledByInputMethod;
    167173        Vector<KeypressCommand> m_commands;
     174#elif PLATFORM(GTK)
     175        Vector<String> m_commands;
    168176#endif
    169177        bool m_autoRepeat;
  • trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.cpp

    r165607 r185415  
    185185};
    186186
    187 static const KeyCombinationEntry keyDownEntries[] = {
     187static const KeyCombinationEntry customKeyBindings[] = {
    188188    { GDK_b,         GDK_CONTROL_MASK,               "ToggleBold"    },
    189189    { GDK_i,         GDK_CONTROL_MASK,               "ToggleItalic"  },
    190190    { GDK_Escape,    0,                              "Cancel"        },
    191191    { GDK_greater,   GDK_CONTROL_MASK,               "Cancel"        },
    192 };
    193 
    194 // These commands are text insertion commands, so should take place
    195 // while handling the KeyPress event.
    196 static const KeyCombinationEntry keyPressEntries[] = {
    197192    { GDK_Tab,       0,                              "InsertTab"     },
    198193    { GDK_Tab,       GDK_SHIFT_MASK,                 "InsertBacktab" },
    199194};
    200195
    201 void KeyBindingTranslator::getEditorCommandsForKeyEvent(GdkEventKey* event, EventType type, Vector<WTF::String>& commandList)
    202 {
    203     m_pendingEditorCommands.clear();
    204 
     196Vector<String> KeyBindingTranslator::commandsForKeyEvent(GdkEventKey* event)
     197{
     198    ASSERT(m_pendingEditorCommands.isEmpty());
     199
     200    // FIXME: Move KeyBindingTranslator to WebKit layer and remove the GTK2 code.
    205201#ifdef GTK_API_VERSION_2
    206202    gtk_bindings_activate_event(GTK_OBJECT(m_nativeWidget.get()), event);
    … …  
    209205#endif
    210206
    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 };
    214222    }
    215223
    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 { };
    242225}
    243226
  • trunk/Source/WebCore/platform/gtk/KeyBindingTranslator.h

    r127757 r185415  
    3232    KeyBindingTranslator();
    3333
    34     enum EventType { KeyDown, KeyPress };
    35     void getEditorCommandsForKeyEvent(GdkEventKey*, EventType, Vector<WTF::String>&);
     34    Vector<String> commandsForKeyEvent(GdkEventKey*);
    3635    void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(command); }
    3736
    3837private:
    3938    GRefPtr<GtkWidget> m_nativeWidget;
    40     Vector<WTF::String> m_pendingEditorCommands;
     39    Vector<String> m_pendingEditorCommands;
    4140};
    4241
  • trunk/Source/WebKit2/ChangeLog

    r185413 r185415  
     12015-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
    1752015-06-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    276
  • trunk/Source/WebKit2/Shared/NativeWebKeyboardEvent.h

    r175046 r185415  
    6464#elif PLATFORM(GTK)
    6565    NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
    66     NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition);
     66    NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
    6767#elif PLATFORM(EFL)
    6868    NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool);
  • trunk/Source/WebKit2/Shared/WebEvent.h

    r184028 r185415  
    236236#if USE(APPKIT)
    237237    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);
    238240#else
    239241    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);
    … …  
    246248    int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
    247249    int32_t macCharCode() const { return m_macCharCode; }
     250#if USE(APPKIT) || PLATFORM(GTK)
     251    bool handledByInputMethod() const { return m_handledByInputMethod; }
     252#endif
    248253#if USE(APPKIT)
    249     bool handledByInputMethod() const { return m_handledByInputMethod; }
    250254    const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; }
     255#elif PLATFORM(GTK)
     256    const Vector<String>& commands() const { return m_commands; }
    251257#endif
    252258    bool isAutoRepeat() const { return m_isAutoRepeat; }
    … …  
    266272    int32_t m_nativeVirtualKeyCode;
    267273    int32_t m_macCharCode;
     274#if USE(APPKIT) || PLATFORM(GTK)
     275    bool m_handledByInputMethod;
     276#endif
    268277#if USE(APPKIT)
    269     bool m_handledByInputMethod;
    270278    Vector<WebCore::KeypressCommand> m_commands;
     279#elif PLATFORM(GTK)
     280    Vector<String> m_commands;
    271281#endif
    272282    bool m_isAutoRepeat;
  • trunk/Source/WebKit2/Shared/WebEventConversion.cpp

    r184028 r185415  
    205205        m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode();
    206206        m_macCharCode = webEvent.macCharCode();
    207 #if USE(APPKIT)
     207#if USE(APPKIT) || PLATFORM(GTK)
    208208        m_handledByInputMethod = webEvent.handledByInputMethod();
    209209        m_commands = webEvent.commands();
  • trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp

    r165356 r185415  
    5555}
    5656
     57#elif PLATFORM(GTK)
     58
     59WebKeyboardEvent::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
    5776#else
    5877
    … …  
    88107    encoder << m_nativeVirtualKeyCode;
    89108    encoder << m_macCharCode;
    90 #if USE(APPKIT)
     109#if USE(APPKIT) || PLATFORM(GTK)
    91110    encoder << m_handledByInputMethod;
    92111    encoder << m_commands;
    … …  
    114133    if (!decoder.decode(result.m_macCharCode))
    115134        return false;
    116 #if USE(APPKIT)
     135#if USE(APPKIT) || PLATFORM(GTK)
    117136    if (!decoder.decode(result.m_handledByInputMethod))
    118137        return false;
  • trunk/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp

    r175046 r185415  
    3636namespace WebKit {
    3737
    38 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked)
    39     : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults))
     38NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands)
     39    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTF::move(commands)))
    4040    , m_nativeEvent(gdk_event_copy(event))
    4141    , m_compositionResults(compositionResults)
    … …  
    4545
    4646NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
    47     : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults()))
     47    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands())))
    4848    , m_nativeEvent(gdk_event_copy(event.nativeEvent()))
    4949    , m_compositionResults(event.compositionResults())
  • trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp

    r182005 r185415  
    182182}
    183183
    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));
     184WebKeyboardEvent 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));
    205197}
    206198
  • trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h

    r182005 r185415  
    3939    static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
    4040    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);
    4242    static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
    4343};
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r183517 r185415  
    5757}
    5858
    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 
    6859// PageClient's pure virtual functions
    6960std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

    r183517 r185415  
    3030
    3131#include "DefaultUndoController.h"
    32 #include "KeyBindingTranslator.h"
    3332#include "PageClient.h"
    3433#include "WebFullScreenManagerProxy.h"
    3534#include "WebPageProxy.h"
    36 #include "WindowsKeyboardCodes.h"
    3735#include <WebCore/IntSize.h>
    3836#include <gtk/gtk.h>
    … …  
    9290    virtual void clearTextIndicator(WebCore::TextIndicatorDismissalAnimation = WebCore::TextIndicatorDismissalAnimation::FadeOut) override;
    9391    virtual void setTextIndicatorAnimationProgress(float) override;
    94     virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) override;
    9592    virtual void updateTextInputState() override;
    9693#if ENABLE(DRAG_SUPPORT)
    … …  
    139136    GtkWidget* m_viewWidget;
    140137    DefaultUndoController m_undoController;
    141     WebCore::KeyBindingTranslator m_keyBindingTranslator;
    142138};
    143139
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r183731 r185415  
    3232#include "DrawingAreaProxyImpl.h"
    3333#include "InputMethodFilter.h"
     34#include "NativeWebKeyboardEvent.h"
    3435#include "NativeWebMouseEvent.h"
    3536#include "NativeWebWheelEvent.h"
    … …  
    5354#include <WebCore/GtkUtilities.h>
    5455#include <WebCore/GtkVersioning.h>
     56#include <WebCore/KeyBindingTranslator.h>
    5557#include <WebCore/NotImplemented.h>
    5658#include <WebCore/PasteboardHelper.h>
    … …  
    164166    WebContextMenuProxyGtk* activeContextMenuProxy;
    165167    InputMethodFilter inputMethodFilter;
     168    KeyBindingTranslator keyBindingTranslator;
    166169    TouchEventsMap touchEvents;
    167170
    … …  
    750753        return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event);
    751754    }
    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
    753761    return TRUE;
    754762}
    … …  
    763771        return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_release_event(widget, event);
    764772    }
    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
    766778    return TRUE;
    767779}
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r184780 r185415  
    197197#endif
    198198
    199 #if PLATFORM(GTK)
    200     virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) = 0;
    201 #endif
    202199    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
    203200    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r185013 r185415  
    205205
    206206#if PLATFORM(GTK)
    207     # Support for GTK+ platform keybindings
    208     GetEditorCommandsForKeyEvent(AtomicString eventType) -> (Vector<String> commandsList)
    209 
    210207    # Support for connecting the Accessibility worlds of the UI and the Web processes
    211208    BindAccessibilityTree(String plugID)
  • trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.cpp

    r175047 r185415  
    2121#include "InputMethodFilter.h"
    2222
    23 #include "NativeWebKeyboardEvent.h"
    2423#include "WebPageProxy.h"
    2524#include <WebCore/Color.h>
    … …  
    123122    }
    124123#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;
    126128}
    127129
    … …  
    134136    }
    135137#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;
    137142
    138143    if (resultsToSend & Composition && !m_confirmedComposition.isNull())
    … …  
    145150}
    146151
    147 void InputMethodFilter::filterKeyEvent(GdkEventKey* event)
     152void InputMethodFilter::filterKeyEvent(GdkEventKey* event, FilterKeyEventCompletionHandler&& completionHandler)
    148153{
    149154#if ENABLE(API_TESTS)
    … …  
    152157    ASSERT(m_page);
    153158#endif
     159    m_filterKeyEventCompletionHandler = WTF::move(completionHandler);
    154160    if (!m_enabled) {
    155161        handleKeyboardEvent(event);
  • trunk/Source/WebKit2/UIProcess/gtk/InputMethodFilter.h

    r175046 r185415  
    3030
    3131namespace WebCore {
     32class CompositionResults;
    3233class IntRect;
    3334}
    … …  
    5556    void setCursorRect(const WebCore::IntRect&);
    5657
    57     void filterKeyEvent(GdkEventKey*);
     58    using FilterKeyEventCompletionHandler = std::function<void (const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition)>;
     59    void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&& = nullptr);
    5860    void notifyFocusedIn();
    5961    void notifyFocusedOut();
    … …  
    112114    String m_preedit;
    113115
     116    FilterKeyEventCompletionHandler m_filterKeyEventCompletionHandler;
     117
    114118#if ENABLE(API_TESTS)
    115119    bool m_testingMode;
  • trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp

    r180465 r185415  
    2828#include "WebPageProxy.h"
    2929
    30 #include "NativeWebKeyboardEvent.h"
    3130#include "NotImplemented.h"
    3231#include "PageClientImpl.h"
    … …  
    5251{
    5352    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);
    6253}
    6354
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp

    r179409 r185415  
    2222
    2323#include "PlatformKeyboardEvent.h"
    24 #include "WebPage.h"
    25 #include "WebPageProxyMessages.h"
    26 #include "WebProcess.h"
    2724#include <WebCore/DataObjectGtk.h>
    2825#include <WebCore/Document.h>
     26#include <WebCore/Editor.h>
    2927#include <WebCore/Frame.h>
    3028#include <WebCore/FrameDestructionObserver.h>
    3129#include <WebCore/KeyboardEvent.h>
    3230#include <WebCore/Pasteboard.h>
    33 #include <WebCore/WindowsKeyboardCodes.h>
    3431#include <WebCore/markup.h>
    3532#include <wtf/gobject/GRefPtr.h>
    … …  
    3835
    3936namespace 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 }
    5137
    5238bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)
    … …  
    7157void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
    7258{
     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
    7367    Node* node = event->target()->toNode();
    7468    ASSERT(node);
    … …  
    7670    ASSERT(frame);
    7771
    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();
    8873    if (!pendingEditorCommands.isEmpty()) {
    8974
    … …  
    130115{
    131116    const PlatformKeyboardEvent* platformEvent = event->keyEvent();
    132     if (platformEvent && platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
    133         event->preventDefault();
     117    if (platformEvent && platformEvent->handledByInputMethod())
     118        event->setDefaultHandled();
    134119}
    135120
Note: See TracChangeset for help on using the changeset viewer.