Changeset 216114 in webkit


Ignore:
Timestamp:
May 3, 2017 1:55:56 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Add GTK+ implementation of WebAutomationSession
https://bugs.webkit.org/show_bug.cgi?id=171431

Reviewed by Michael Catanzaro.

Add platform dependent methods for GTK+ to synthesize events.

  • PlatformGTK.cmake:
  • UIProcess/API/gtk/WebKitUIClient.cpp: Always resize the window for web views controlled by automation.
  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
(WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
(WebKit::WebAutomationSession::performMouseInteraction):
(WebKit::WebAutomationSession::performKeyboardInteractions):

  • UIProcess/Automation/WebAutomationSession.h:
  • UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp: Added.

(WebKit::modifiersToEventState):
(WebKit::mouseButtonToGdkButton):
(WebKit::doMouseEvent):
(WebKit::doMotionEvent):
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):
(WebKit::doKeyStrokeEvent):
(WebKit::keyCodeForVirtualKey):
(WebKit::WebAutomationSession::platformSimulateKeyStroke):
(WebKit::WebAutomationSession::platformSimulateKeySequence):
(WebKit::WebAutomationSession::platformGetBase64EncodedPNGData):

Location:
trunk/Source/WebKit2
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r216112 r216114  
     12017-05-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add GTK+ implementation of WebAutomationSession
     4        https://bugs.webkit.org/show_bug.cgi?id=171431
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add platform dependent methods for GTK+ to synthesize events.
     9
     10        * PlatformGTK.cmake:
     11        * UIProcess/API/gtk/WebKitUIClient.cpp: Always resize the window for web views controlled by automation.
     12        * UIProcess/Automation/WebAutomationSession.cpp:
     13        (WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
     14        (WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
     15        (WebKit::WebAutomationSession::performMouseInteraction):
     16        (WebKit::WebAutomationSession::performKeyboardInteractions):
     17        * UIProcess/Automation/WebAutomationSession.h:
     18        * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp: Added.
     19        (WebKit::modifiersToEventState):
     20        (WebKit::mouseButtonToGdkButton):
     21        (WebKit::doMouseEvent):
     22        (WebKit::doMotionEvent):
     23        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
     24        (WebKit::doKeyStrokeEvent):
     25        (WebKit::keyCodeForVirtualKey):
     26        (WebKit::WebAutomationSession::platformSimulateKeyStroke):
     27        (WebKit::WebAutomationSession::platformSimulateKeySequence):
     28        (WebKit::WebAutomationSession::platformGetBase64EncodedPNGData):
     29
    1302017-05-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    231
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r216006 r216114  
    305305    UIProcess/API/gtk/webkit2.h
    306306
     307    UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp
     308
    307309    UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
    308310
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp

    r215149 r216114  
    140140    {
    141141        GdkRectangle geometry = WebCore::IntRect(frame);
    142         webkitWindowPropertiesSetGeometry(webkit_web_view_get_window_properties(m_webView), &geometry);
     142        GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
     143        if (webkit_web_view_is_controlled_by_automation(m_webView) && WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) {
     144            if (geometry.x >= 0 && geometry.y >= 0)
     145                gtk_window_move(GTK_WINDOW(window), geometry.x, geometry.y);
     146            if (geometry.width > 0 && geometry.height > 0)
     147                gtk_window_resize(GTK_WINDOW(window), geometry.width, geometry.height);
     148        } else
     149            webkitWindowPropertiesSetGeometry(webkit_web_view_get_window_properties(m_webView), &geometry);
    143150    }
    144151
  • trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp

    r216070 r216114  
    321321    page->setWindowFrame(newFrame);
    322322
     323#if !PLATFORM(GTK)
    323324    // If nothing changed at all, it's probably fair to report that something went wrong.
    324325    // (We can't assume that the requested frame size will be honored exactly, however.)
     
    328329        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window size was expected to have changed, but did not.");
    329330#endif
     331#endif
    330332}
    331333
     
    362364    page->setWindowFrame(newFrame);
    363365
     366#if !PLATFORM(GTK)
    364367    // If nothing changed at all, it's probably fair to report that something went wrong.
    365368    // (We can't assume that the requested frame size will be honored exactly, however.)
     
    368371    if (originalFrame == updatedFrame)
    369372        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window position was expected to have changed, but did not.");
     373#endif
    370374#endif
    371375}
     
    834838}
    835839
    836 #if USE(APPKIT)
     840#if USE(APPKIT) || PLATFORM(GTK)
    837841static WebEvent::Modifiers protocolModifierToWebEventModifier(Inspector::Protocol::Automation::KeyModifier modifier)
    838842{
     
    854858void WebAutomationSession::performMouseInteraction(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const Inspector::InspectorArray& keyModifierStrings, RefPtr<Inspector::Protocol::Automation::Point>& updatedPositionObject)
    855859{
    856 #if !USE(APPKIT)
     860#if !USE(APPKIT) && !PLATFORM(GTK)
    857861    FAIL_WITH_PREDEFINED_ERROR(NotImplemented);
    858862#else
     
    909913void WebAutomationSession::performKeyboardInteractions(ErrorString& errorString, const String& handle, const Inspector::InspectorArray& interactions, Ref<PerformKeyboardInteractionsCallback>&& callback)
    910914{
    911 #if !PLATFORM(COCOA)
     915#if !PLATFORM(COCOA) && !PLATFORM(GTK)
    912916    FAIL_WITH_PREDEFINED_ERROR(NotImplemented);
    913917#else
     
    10161020// Platform-dependent Implementation Stubs.
    10171021
    1018 #if !PLATFORM(MAC)
     1022#if !PLATFORM(MAC) && !PLATFORM(GTK)
    10191023void WebAutomationSession::platformSimulateMouseInteraction(WebKit::WebPageProxy&, const WebCore::IntPoint&, Inspector::Protocol::Automation::MouseInteraction, Inspector::Protocol::Automation::MouseButton, WebEvent::Modifiers)
    10201024{
     
    10221026#endif // !PLATFORM(MAC)
    10231027
    1024 #if !PLATFORM(COCOA)
     1028#if !PLATFORM(COCOA) && !PLATFORM(GTK)
    10251029void WebAutomationSession::platformSimulateKeyStroke(WebPageProxy&, Inspector::Protocol::Automation::KeyboardInteractionType, Inspector::Protocol::Automation::VirtualKey)
    10261030{
  • trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h

    r216070 r216114  
    226226#endif
    227227
    228 #if PLATFORM(IOS)
     228#if PLATFORM(IOS) || PLATFORM(GTK)
    229229    // Keep track of currently active modifiers across multiple keystrokes.
    230230    // We don't synthesize platform keyboard events on iOS, so we need to track it ourselves.
     231    // GTK+ doesn't keep track of the active modifiers when using synthesized events.
    231232    unsigned m_currentModifiers { 0 };
    232233#endif
Note: See TracChangeset for help on using the changeset viewer.