Changeset 251650 in webkit


Ignore:
Timestamp:
Oct 28, 2019 2:24:57 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Simplify the Input Method implementation
https://bugs.webkit.org/show_bug.cgi?id=203149

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Remove CompositionResults and remove dead code in PlatformKeyboardEventGtk.

  • PlatformGTK.cmake:
  • platform/PlatformKeyboardEvent.h:

(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):

  • platform/gtk/CompositionResults.h: Removed.
  • platform/gtk/PlatformKeyboardEventGtk.cpp:

(WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent):

Source/WebKit:

  • Shared/NativeWebKeyboardEvent.h: Stop using WebCore::CompositionResults.

(WebKit::NativeWebKeyboardEvent::text const):
(WebKit::NativeWebKeyboardEvent::handledByInputMethod const):
(WebKit::NativeWebKeyboardEvent::fakedForComposition const):

  • Shared/gtk/NativeWebKeyboardEventGtk.cpp: Ditto.

(WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):

  • Shared/gtk/WebEventFactory.cpp:

(WebKit::WebEventFactory::createWebKeyboardEvent): Ditto.

  • Shared/gtk/WebEventFactory.h:
  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::doneWithKeyEvent): Updated to use the new name.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp: Stop using WebCore::CompositionResults.

(webkitWebViewBaseKeyPressEvent):
(webkitWebViewBaseKeyReleaseEvent):

  • UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Remove unused function.
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setComposition): Use EditingRange instead of two integers and remove replacement range
that is unused.
(WebKit::WebPageProxy::confirmComposition): Remove unused selection range parameters.

  • UIProcess/WebPageProxy.h:
  • UIProcess/gtk/InputMethodFilter.cpp:

(WebKit::InputMethodFilter::handleKeyboardEvent):
(WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults):
(WebKit::InputMethodFilter::confirmComposition):
(WebKit::InputMethodFilter::updatePreedit):
(WebKit::InputMethodFilter::confirmCurrentComposition):
(WebKit::InputMethodFilter::sendCompositionAndPreeditWithFakeKeyEvents):
(WebKit::InputMethodFilter::logHandleKeyboardEventForTesting):
(WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting):

  • UIProcess/gtk/InputMethodFilter.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::targetFrameForEditing): Receive a reference instead of a pointer.
(WebKit::WebPage::confirmComposition): Remove the unused code to handle the selection range.
(WebKit::WebPage::setComposition): Remove the unused code to handle the replacement range.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
Location:
trunk/Source
Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251649 r251650  
     12019-10-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Simplify the Input Method implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=203149
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Remove CompositionResults and remove dead code in PlatformKeyboardEventGtk.
     9
     10        * PlatformGTK.cmake:
     11        * platform/PlatformKeyboardEvent.h:
     12        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
     13        * platform/gtk/CompositionResults.h: Removed.
     14        * platform/gtk/PlatformKeyboardEventGtk.cpp:
     15        (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent):
     16
    1172019-10-27  Antoine Quint  <graouts@apple.com>
    218
  • trunk/Source/WebCore/PlatformGTK.cmake

    r246632 r251650  
    4949    platform/graphics/x11/XUniqueResource.h
    5050
    51     platform/gtk/CompositionResults.h
    5251    platform/gtk/GRefPtrGtk.h
    5352    platform/gtk/GUniquePtrGtk.h
  • trunk/Source/WebCore/platform/PlatformKeyboardEvent.h

    r245079 r251650  
    4141#endif
    4242
    43 #if PLATFORM(GTK)
    44 typedef struct _GdkEventKey GdkEventKey;
    45 #include "CompositionResults.h"
    46 #endif
    47 
    4843namespace WebCore {
    4944
     
    5752            , m_isKeypad(false)
    5853            , m_isSystemKey(false)
    59 #if PLATFORM(GTK)
    60             , m_gdkEventKey(0)
    61 #endif
    6254        {
    6355        }
     
    151143
    152144#if PLATFORM(GTK)
    153         PlatformKeyboardEvent(GdkEventKey*, const CompositionResults&);
    154         GdkEventKey* gdkEventKey() const { return m_gdkEventKey; }
    155         const CompositionResults& compositionResults() const { return m_compositionResults; }
    156 
    157145        // Used by WebKit2
    158146        static String keyValueForGdkKeyCode(unsigned);
     
    204192#endif
    205193#endif
    206 #if PLATFORM(GTK)
    207         GdkEventKey* m_gdkEventKey;
    208         CompositionResults m_compositionResults;
    209 #endif
    210        
    211194        // The modifier state is optional, since it is not needed in the UI process or in legacy WebKit.
    212195        static Optional<OptionSet<Modifier>> s_currentModifiers;
  • trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp

    r246677 r251650  
    13221322}
    13231323
    1324 static PlatformEvent::Type eventTypeForGdkKeyEvent(GdkEventKey* event)
    1325 {
    1326     return gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? PlatformEvent::KeyUp : PlatformEvent::KeyDown;
    1327 }
    1328 
    1329 static OptionSet<PlatformEvent::Modifier> modifiersForGdkKeyEvent(GdkEventKey* event)
    1330 {
    1331     GdkModifierType state;
    1332     gdk_event_get_state(reinterpret_cast<GdkEvent*>(event), &state);
    1333     guint keyval;
    1334     gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
    1335 
    1336     OptionSet<PlatformEvent::Modifier> modifiers;
    1337     if (state & GDK_SHIFT_MASK || keyval == GDK_KEY_3270_BackTab)
    1338         modifiers.add(PlatformEvent::Modifier::ShiftKey);
    1339     if (state & GDK_CONTROL_MASK)
    1340         modifiers.add(PlatformEvent::Modifier::ControlKey);
    1341     if (state & GDK_MOD1_MASK)
    1342         modifiers.add(PlatformEvent::Modifier::AltKey);
    1343     if (state & GDK_META_MASK)
    1344         modifiers.add(PlatformEvent::Modifier::MetaKey);
    1345     if (state & GDK_LOCK_MASK)
    1346         modifiers.add(PlatformEvent::Modifier::CapsLockKey);
    1347     return modifiers;
    1348 }
    1349 
    1350 // Keep this in sync with the other platform event constructors
    1351 PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event, const CompositionResults& compositionResults)
    1352     : PlatformEvent(eventTypeForGdkKeyEvent(event), modifiersForGdkKeyEvent(event), wallTimeForEvent(event))
    1353     , m_handledByInputMethod(false)
    1354     , m_autoRepeat(false)
    1355     , m_isSystemKey(false)
    1356     , m_gdkEventKey(event)
    1357     , m_compositionResults(compositionResults)
    1358 {
    1359     guint keyval;
    1360     gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
    1361     guint16 keycode;
    1362     gdk_event_get_keycode(reinterpret_cast<GdkEvent*>(event), &keycode);
    1363 
    1364     m_text = compositionResults.simpleString.length() ? compositionResults.simpleString : singleCharacterString(keyval);
    1365     m_unmodifiedText = m_text;
    1366     m_key = keyValueForGdkKeyCode(keyval);
    1367     m_code = keyCodeForHardwareKeyCode(keycode);
    1368     m_keyIdentifier = keyIdentifierForGdkKeyCode(keyval);
    1369     m_windowsVirtualKeyCode = windowsKeyCodeForGdkKeyCode(keyval);
    1370     m_isKeypad = keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9;
    1371 
    1372     // To match the behavior of IE, we return VK_PROCESSKEY for keys that triggered composition results.
    1373     if (compositionResults.compositionUpdated())
    1374         m_windowsVirtualKeyCode = VK_PROCESSKEY;
    1375 }
    1376 
    13771324void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
    13781325{
     
    13871334        m_text = String();
    13881335        m_unmodifiedText = String();
    1389     } else if (type == PlatformEvent::Char && m_compositionResults.compositionUpdated()) {
     1336    } else if (type == PlatformEvent::Char && m_handledByInputMethod) {
    13901337        // Having empty text, prevents this Char (which is a DOM keypress) event
    13911338        // from going to the DOM. Keys that trigger composition events should not
  • trunk/Source/WebKit/ChangeLog

    r251646 r251650  
     12019-10-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Simplify the Input Method implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=203149
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        * Shared/NativeWebKeyboardEvent.h: Stop using WebCore::CompositionResults.
     9        (WebKit::NativeWebKeyboardEvent::text const):
     10        (WebKit::NativeWebKeyboardEvent::handledByInputMethod const):
     11        (WebKit::NativeWebKeyboardEvent::fakedForComposition const):
     12        * Shared/gtk/NativeWebKeyboardEventGtk.cpp: Ditto.
     13        (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
     14        * Shared/gtk/WebEventFactory.cpp:
     15        (WebKit::WebEventFactory::createWebKeyboardEvent): Ditto.
     16        * Shared/gtk/WebEventFactory.h:
     17        * UIProcess/API/gtk/PageClientImpl.cpp:
     18        (WebKit::PageClientImpl::doneWithKeyEvent): Updated to use the new name.
     19        * UIProcess/API/gtk/WebKitWebViewBase.cpp: Stop using WebCore::CompositionResults.
     20        (webkitWebViewBaseKeyPressEvent):
     21        (webkitWebViewBaseKeyReleaseEvent):
     22        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Remove unused function.
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::WebPageProxy::setComposition): Use EditingRange instead of two integers and remove replacement range
     25        that is unused.
     26        (WebKit::WebPageProxy::confirmComposition): Remove unused selection range parameters.
     27        * UIProcess/WebPageProxy.h:
     28        * UIProcess/gtk/InputMethodFilter.cpp:
     29        (WebKit::InputMethodFilter::handleKeyboardEvent):
     30        (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults):
     31        (WebKit::InputMethodFilter::confirmComposition):
     32        (WebKit::InputMethodFilter::updatePreedit):
     33        (WebKit::InputMethodFilter::confirmCurrentComposition):
     34        (WebKit::InputMethodFilter::sendCompositionAndPreeditWithFakeKeyEvents):
     35        (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting):
     36        (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting):
     37        * UIProcess/gtk/InputMethodFilter.h:
     38        * WebProcess/WebPage/WebPage.cpp:
     39        (WebKit::targetFrameForEditing): Receive a reference instead of a pointer.
     40        (WebKit::WebPage::confirmComposition): Remove the unused code to handle the selection range.
     41        (WebKit::WebPage::setComposition): Remove the unused code to handle the replacement range.
     42        * WebProcess/WebPage/WebPage.h:
     43        * WebProcess/WebPage/WebPage.messages.in:
     44
    1452019-10-27  Fujii Hironori  <Hironori.Fujii@sony.com>
    246
  • trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h

    r244975 r251650  
    4242
    4343#if PLATFORM(GTK)
    44 #include "InputMethodFilter.h"
    45 #include <WebCore/CompositionResults.h>
    4644#include <WebCore/GUniquePtrGtk.h>
    4745typedef union _GdkEvent GdkEvent;
     
    7068#elif PLATFORM(GTK)
    7169    NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
    72     NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
     70    enum class HandledByInputMethod : bool { No, Yes };
     71    enum class FakedForComposition : bool { No, Yes };
     72    NativeWebKeyboardEvent(GdkEvent*, const String&, HandledByInputMethod, FakedForComposition, Vector<String>&& commands);
    7373#elif PLATFORM(IOS_FAMILY)
    7474    enum class HandledByInputMethod : bool { No, Yes };
     
    8484#elif PLATFORM(GTK)
    8585    GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
    86     const WebCore::CompositionResults& compositionResults() const  { return m_compositionResults; }
    87     bool isFakeEventForComposition() const { return m_fakeEventForComposition; }
     86    const String& text() const { return m_text; }
     87    bool handledByInputMethod() const { return m_handledByInputMethod == HandledByInputMethod::Yes; }
     88    bool fakedForComposition() const { return m_fakedForComposition == FakedForComposition::Yes; }
    8889#elif PLATFORM(IOS_FAMILY)
    8990    ::WebEvent* nativeEvent() const { return m_nativeEvent.get(); }
     
    99100#elif PLATFORM(GTK)
    100101    GUniquePtr<GdkEvent> m_nativeEvent;
    101     WebCore::CompositionResults m_compositionResults;
    102     bool m_fakeEventForComposition;
     102    String m_text;
     103    HandledByInputMethod m_handledByInputMethod;
     104    FakedForComposition m_fakedForComposition;
    103105#elif PLATFORM(IOS_FAMILY)
    104106    RetainPtr<::WebEvent> m_nativeEvent;
  • trunk/Source/WebKit/Shared/gtk/NativeWebKeyboardEventGtk.cpp

    r228373 r251650  
    3333
    3434namespace WebKit {
    35 using namespace WebCore;
    3635
    37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands)
    38     : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTFMove(commands)))
     36NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const String& text, HandledByInputMethod handledByInputMethod, FakedForComposition fakedForComposition, Vector<String>&& commands)
     37    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, text, handledByInputMethod == HandledByInputMethod::Yes, WTFMove(commands)))
    3938    , m_nativeEvent(gdk_event_copy(event))
    40     , m_compositionResults(compositionResults)
    41     , m_fakeEventForComposition(faked == InputMethodFilter::EventFaked)
     39    , m_text(text)
     40    , m_handledByInputMethod(handledByInputMethod)
     41    , m_fakedForComposition(fakedForComposition)
    4242{
    4343}
    4444
    4545NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
    46     : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands())))
     46    : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.text(), event.handledByInputMethod(), Vector<String>(event.commands())))
    4747    , m_nativeEvent(gdk_event_copy(event.nativeEvent()))
    48     , m_compositionResults(event.compositionResults())
    49     , m_fakeEventForComposition(event.isFakeEventForComposition())
     48    , m_text(event.text())
     49    , m_handledByInputMethod(event.handledByInputMethod() ? HandledByInputMethod::Yes : HandledByInputMethod::No)
     50    , m_fakedForComposition(event.fakedForComposition() ? FakedForComposition::Yes : FakedForComposition::No)
    5051{
    5152}
  • trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp

    r247862 r251650  
    250250}
    251251
    252 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
     252WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const String& text, bool handledByInputMethod, Vector<String>&& commands)
    253253{
    254254    guint keyval;
     
    260260    return WebKeyboardEvent(
    261261        type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
    262         compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyval),
     262        text.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : text,
    263263        PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
    264264        PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
     
    266266        PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
    267267        static_cast<int>(keyval),
    268         compositionResults.compositionUpdated(),
     268        handledByInputMethod,
    269269        WTFMove(commands),
    270270        isGdkKeyCodeFromKeyPad(keyval),
  • trunk/Source/WebKit/Shared/gtk/WebEventFactory.h

    r217971 r251650  
    2525 */
    2626
    27 #ifndef WebEventFactory_h
    28 #define WebEventFactory_h
     27#pragma once
    2928
    3029#include "WebEvent.h"
    31 #include <WebCore/CompositionResults.h>
    3230
    3331typedef union _GdkEvent GdkEvent;
     
    4038    static WebWheelEvent createWebWheelEvent(const GdkEvent*);
    4139    static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
    42     static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&, Vector<String>&& commands);
     40    static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Vector<String>&& commands);
    4341#if ENABLE(TOUCH_EVENTS)
    4442    static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
     
    4745
    4846} // namespace WebKit
    49 
    50 #endif // WebEventFactory_h
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp

    r250645 r251650  
    225225    if (wasEventHandled)
    226226        return;
    227     if (event.isFakeEventForComposition())
     227    if (event.fakedForComposition())
    228228        return;
    229229
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r250648 r251650  
    785785    // We need to copy the event as otherwise it could be destroyed before we reach the lambda body.
    786786    GUniquePtr<GdkEvent> event(gdk_event_copy(reinterpret_cast<GdkEvent*>(keyEvent)));
    787     priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
    788         priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), compositionResults, faked,
    789             !compositionResults.compositionUpdated() ? priv->keyBindingTranslator.commandsForKeyEvent(&event->key) : Vector<String>()));
     787    priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const String& text, InputMethodFilter::EventHandledByInputMethod handled, InputMethodFilter::EventFakedForComposition faked) {
     788        auto handledByInputMethod = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? NativeWebKeyboardEvent::HandledByInputMethod::Yes : NativeWebKeyboardEvent::HandledByInputMethod::No;
     789        auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
     790        auto commands = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? Vector<String>() : priv->keyBindingTranslator.commandsForKeyEvent(&event->key);
     791        priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), text, handledByInputMethod, fakedForComposition, WTFMove(commands)));
    790792    });
    791793
     
    805807    // We need to copy the event as otherwise it could be destroyed before we reach the lambda body.
    806808    GUniquePtr<GdkEvent> event(gdk_event_copy(reinterpret_cast<GdkEvent*>(keyEvent)));
    807     priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked) {
    808         priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), compositionResults, faked, { }));
     809    priv->inputMethodFilter.filterKeyEvent(keyEvent, [priv, event = WTFMove(event)](const String& text, InputMethodFilter::EventHandledByInputMethod handled, InputMethodFilter::EventFakedForComposition faked) {
     810        auto handledByInputMethod = handled == InputMethodFilter::EventHandledByInputMethod::Yes ? NativeWebKeyboardEvent::HandledByInputMethod::Yes : NativeWebKeyboardEvent::HandledByInputMethod::No;
     811        auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
     812        priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(event.get(), text, handledByInputMethod, fakedForComposition, { }));
    809813    });
    810814
     
    14561460}
    14571461
    1458 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase* webkitWebViewBase)
    1459 {
    1460     return webkitWebViewBase->priv->inputMethodFilter.context();
    1461 }
    1462 
    14631462WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase* webkitWebViewBase)
    14641463{
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

    r246677 r251650  
    4040
    4141WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&);
    42 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*);
    4342WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
    4443void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, Ref<API::PageConfiguration>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r251600 r251650  
    80218021
    80228022#if PLATFORM(GTK)
    8023 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
     8023void WebPageProxy::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
    80248024{
    80258025    // FIXME: We need to find out how to proper handle the crashes case.
     
    80278027        return;
    80288028
    8029     process().send(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), m_webPageID);
    8030 }
    8031 
    8032 void WebPageProxy::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
    8033 {
    8034     if (!hasRunningProcess())
    8035         return;
    8036 
    8037     process().send(Messages::WebPage::ConfirmComposition(compositionString, selectionStart, selectionLength), m_webPageID);
    8038 }
    8039 
    8040 void WebPageProxy::cancelComposition()
    8041 {
    8042     if (!hasRunningProcess())
    8043         return;
    8044 
    8045     process().send(Messages::WebPage::CancelComposition(), m_webPageID);
     8029    process().send(Messages::WebPage::SetComposition(text, underlines, selectionRange), m_webPageID);
     8030}
     8031
     8032void WebPageProxy::confirmComposition(const String& compositionString)
     8033{
     8034    if (!hasRunningProcess())
     8035        return;
     8036
     8037    process().send(Messages::WebPage::ConfirmComposition(compositionString), m_webPageID);
    80468038}
    80478039#endif // PLATFORM(GTK)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r251600 r251650  
    788788
    789789#if PLATFORM(GTK)
    790     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
    791     void confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength);
    792     void cancelComposition();
     790    void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
     791    void confirmComposition(const String& compositionString);
    793792
    794793    void setInputMethodState(bool enabled);
  • trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp

    r246677 r251650  
    2424#include "WebPageProxy.h"
    2525#include <WebCore/Color.h>
    26 #include <WebCore/CompositionResults.h>
    2726#include <WebCore/Editor.h>
    2827#include <WebCore/GUniquePtrGtk.h>
     
    146145
    147146    if (m_filterKeyEventCompletionHandler) {
    148         m_filterKeyEventCompletionHandler(CompositionResults(simpleString), faked);
     147        m_filterKeyEventCompletionHandler(simpleString, EventHandledByInputMethod::No, faked);
    149148        m_filterKeyEventCompletionHandler = nullptr;
    150     } else
    151         m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(simpleString), faked, Vector<String>()));
     149    } else {
     150        auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
     151        m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), simpleString, NativeWebKeyboardEvent::HandledByInputMethod::No, fakedForComposition, Vector<String>()));
     152    }
    152153}
    153154
     
    162163
    163164    if (m_filterKeyEventCompletionHandler) {
    164         m_filterKeyEventCompletionHandler(CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked);
     165        m_filterKeyEventCompletionHandler({ }, EventHandledByInputMethod::Yes, faked);
    165166        m_filterKeyEventCompletionHandler = nullptr;
    166     } else
    167         m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), CompositionResults(CompositionResults::WillSendCompositionResultsSoon), faked, Vector<String>()));
     167    } else {
     168        auto fakedForComposition = faked == InputMethodFilter::EventFakedForComposition::Yes ? NativeWebKeyboardEvent::FakedForComposition::Yes : NativeWebKeyboardEvent::FakedForComposition::No;
     169        m_page->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), { }, NativeWebKeyboardEvent::HandledByInputMethod::Yes, fakedForComposition, Vector<String>()));
     170    }
     171
    168172    if (resultsToSend & Composition && !m_confirmedComposition.isNull())
    169         m_page->confirmComposition(m_confirmedComposition, -1, 0);
     173        m_page->confirmComposition(m_confirmedComposition);
    170174
    171175    if (resultsToSend & Preedit && !m_preedit.isNull()) {
    172176        m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
    173             m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
     177            EditingRange(m_cursorOffset, 1));
    174178    }
    175179}
     
    268272    }
    269273#endif
    270     m_page->confirmComposition(m_confirmedComposition, -1, 0);
     274    m_page->confirmComposition(m_confirmedComposition);
    271275    m_confirmedComposition = String();
    272276}
     
    282286    // FIXME: We should parse the PangoAttrList that we get from the IM context here.
    283287    m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
    284         m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
     288        EditingRange(m_cursorOffset, 1));
    285289    m_preeditChanged = false;
    286290}
     
    341345#endif
    342346
    343     m_page->confirmComposition(String(), -1, 0);
     347    m_page->confirmComposition({ });
    344348    m_composingTextCurrently = false;
    345349}
     
    369373    event->key.time = GDK_CURRENT_TIME;
    370374    event->key.keyval = compositionEventKeyCode;
    371     handleKeyboardEventWithCompositionResults(&event->key, resultsToSend, EventFaked);
     375    handleKeyboardEventWithCompositionResults(&event->key, resultsToSend, EventFakedForComposition::Yes);
    372376
    373377    m_confirmedComposition = String();
     
    376380
    377381    event->type = GDK_KEY_RELEASE;
    378     handleKeyboardEvent(&event->key, String(), EventFaked);
     382    handleKeyboardEvent(&event->key, String(), EventFakedForComposition::Yes);
    379383    m_justSentFakeKeyUp = true;
    380384}
     
    451455    gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
    452456    const char* eventType = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? "release" : "press";
    453     const char* fakedString = faked == EventFaked ? " (faked)" : "";
     457    const char* fakedString = faked == EventFakedForComposition::Yes ? " (faked)" : "";
    454458    if (!eventString.isNull())
    455459        m_events.append(makeString("sendSimpleKeyEvent type=", eventType, " keycode=", hex(keyval), " text='", eventString, '\'', fakedString));
     
    463467    gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(event), &keyval);
    464468    const char* eventType = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(event)) == GDK_KEY_RELEASE ? "release" : "press";
    465     const char* fakedString = faked == EventFaked ? " (faked)" : "";
     469    const char* fakedString = faked == EventFakedForComposition::Yes ? " (faked)" : "";
    466470    m_events.append(makeString("sendKeyEventWithCompositionResults type=", eventType, " keycode=", hex(keyval), fakedString));
    467471
  • trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.h

    r232151 r251650  
    1818 */
    1919
    20 #ifndef InputMethodFilter_h
    21 #define InputMethodFilter_h
     20#pragma once
    2221
    2322#include <WebCore/IntPoint.h>
     
    3130
    3231namespace WebCore {
    33 struct CompositionResults;
    3432class IntRect;
    3533}
     
    4240    WTF_MAKE_NONCOPYABLE(InputMethodFilter);
    4341public:
    44     enum EventFakedForComposition {
    45         EventFaked,
    46         EventNotFaked
     42    enum class EventFakedForComposition {
     43        No,
     44        Yes
     45    };
     46    enum class EventHandledByInputMethod {
     47        No,
     48        Yes
    4749    };
    4850
     
    5759    void setCursorRect(const WebCore::IntRect&);
    5860
    59     using FilterKeyEventCompletionHandler = Function<void(const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition)>;
     61    using FilterKeyEventCompletionHandler = Function<void(const String&, EventHandledByInputMethod, EventFakedForComposition)>;
    6062    void filterKeyEvent(GdkEventKey*, FilterKeyEventCompletionHandler&& = nullptr);
    6163    void notifyFocusedIn();
     
    8587    void handlePreeditEnd();
    8688
    87     void handleKeyboardEvent(GdkEventKey*, const String& eventString = String(), EventFakedForComposition = EventNotFaked);
    88     void handleKeyboardEventWithCompositionResults(GdkEventKey*, ResultsToSend = PreeditAndComposition, EventFakedForComposition = EventNotFaked);
     89    void handleKeyboardEvent(GdkEventKey*, const String& eventString = String(), EventFakedForComposition = EventFakedForComposition::No);
     90    void handleKeyboardEventWithCompositionResults(GdkEventKey*, ResultsToSend = PreeditAndComposition, EventFakedForComposition = EventFakedForComposition::No);
    8991
    9092    void sendCompositionAndPreeditWithFakeKeyEvents(ResultsToSend);
     
    127129} // namespace WebKit
    128130
    129 #endif // InputMethodFilter_h
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r251600 r251650  
    52925292
    52935293#if PLATFORM(GTK)
    5294 static Frame* targetFrameForEditing(WebPage* page)
    5295 {
    5296     Frame& targetFrame = page->corePage()->focusController().focusedOrMainFrame();
     5294static Frame* targetFrameForEditing(WebPage& page)
     5295{
     5296    Frame& targetFrame = page.corePage()->focusController().focusedOrMainFrame();
    52975297
    52985298    Editor& editor = targetFrame.editor();
     
    53135313}
    53145314
    5315 void WebPage::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
    5316 {
    5317     Frame* targetFrame = targetFrameForEditing(this);
    5318     if (!targetFrame) {
    5319         send(Messages::WebPageProxy::EditorStateChanged(editorState()));
    5320         return;
    5321     }
    5322 
    5323     targetFrame->editor().confirmComposition(compositionString);
    5324 
    5325     if (selectionStart == -1) {
    5326         send(Messages::WebPageProxy::EditorStateChanged(editorState()));
    5327         return;
    5328     }
    5329 
    5330     Element* scope = targetFrame->selection().selection().rootEditableElement();
    5331     RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(scope, selectionStart, selectionLength);
    5332     ASSERT_WITH_MESSAGE(selectionRange, "Invalid selection: [%lld:%lld] in text of length %d", static_cast<long long>(selectionStart), static_cast<long long>(selectionLength), scope->innerText().length());
    5333 
    5334     if (selectionRange) {
    5335         VisibleSelection selection(*selectionRange, SEL_DEFAULT_AFFINITY);
    5336         targetFrame->selection().setSelection(selection);
    5337     }
    5338     send(Messages::WebPageProxy::EditorStateChanged(editorState()));
    5339 }
    5340 
    5341 void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementStart, uint64_t replacementLength)
    5342 {
    5343     Frame* targetFrame = targetFrameForEditing(this);
    5344     if (!targetFrame || !targetFrame->selection().selection().isContentEditable()) {
    5345         send(Messages::WebPageProxy::EditorStateChanged(editorState()));
    5346         return;
    5347     }
     5315void WebPage::confirmComposition(const String& compositionString)
     5316{
     5317    if (auto* targetFrame = targetFrameForEditing(*this))
     5318        targetFrame->editor().confirmComposition(compositionString);
     5319}
     5320
     5321void WebPage::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange)
     5322{
     5323    Frame* targetFrame = targetFrameForEditing(*this);
     5324    if (!targetFrame || !targetFrame->selection().selection().isContentEditable())
     5325        return;
    53485326
    53495327    Ref<Frame> protector(*targetFrame);
    5350 
    5351     if (replacementLength > 0) {
    5352         // The layout needs to be uptodate before setting a selection
    5353         targetFrame->document()->updateLayout();
    5354 
    5355         Element* scope = targetFrame->selection().selection().rootEditableElement();
    5356         RefPtr<Range> replacementRange = TextIterator::rangeFromLocationAndLength(scope, replacementStart, replacementLength);
    5357         targetFrame->editor().setIgnoreSelectionChanges(true);
    5358         targetFrame->selection().setSelection(VisibleSelection(*replacementRange, SEL_DEFAULT_AFFINITY));
    5359         targetFrame->editor().setIgnoreSelectionChanges(false);
    5360     }
    5361 
    5362     targetFrame->editor().setComposition(text, underlines, selectionStart, selectionStart + selectionLength);
    5363     send(Messages::WebPageProxy::EditorStateChanged(editorState()));
    5364 }
    5365 
    5366 void WebPage::cancelComposition()
    5367 {
    5368     if (Frame* targetFrame = targetFrameForEditing(this))
    5369         targetFrame->editor().cancelComposition();
    5370     send(Messages::WebPageProxy::EditorStateChanged(editorState()));
     5328    targetFrame->editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length);
    53715329}
    53725330#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r251600 r251650  
    774774
    775775#if PLATFORM(GTK)
    776     void setComposition(const String& text, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength);
    777     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
    778     void cancelComposition();
     776    void setComposition(const String&, const Vector<WebCore::CompositionUnderline>&, const EditingRange& selectionRange);
     777    void confirmComposition(const String& text);
    779778
    780779    void collapseSelectionInFrame(WebCore::FrameIdentifier);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r251600 r251650  
    412412
    413413#if PLATFORM(GTK)
    414     SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
    415     ConfirmComposition(String text, int64_t selectionStart, int64_t selectionLength)
    416     CancelComposition()
     414    SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, struct WebKit::EditingRange selectionRange)
     415    ConfirmComposition(String text)
    417416
    418417    CollapseSelectionInFrame(WebCore::FrameIdentifier frameID)
Note: See TracChangeset for help on using the changeset viewer.