Changeset 250707 in webkit
- Timestamp:
- Oct 3, 2019 11:15:39 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r250706 r250707 1 2019-10-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] WebAutomation: make setWindowRect synchronous 4 https://bugs.webkit.org/show_bug.cgi?id=202530 5 6 Reviewed by Carlos Alberto Lopez Perez. 7 8 Move/resize window is asynchronous in GTK, but automation expects it to be synchronous so that get window rect 9 after setting it always returns the value set. Use a nested run loop to wait for the configure events after the 10 move/resize. 11 12 * UIProcess/API/glib/WebKitUIClient.cpp: 13 (UIClient::windowConfigureEventCallback): 14 (UIClient::setWindowFrameTimerFired): 15 1 16 2019-10-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 17 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
r248846 r250707 36 36 #include "WebsiteDataStore.h" 37 37 #include <wtf/glib/GRefPtr.h> 38 #include <wtf/glib/RunLoopSourcePriority.h> 38 39 39 40 #if PLATFORM(GTK) … … 129 130 } 130 131 132 #if PLATFORM(GTK) 133 static void windowConfigureEventCallback(GtkWindow* window, GdkEventConfigure*, GdkRectangle* targetGeometry) 134 { 135 GdkRectangle geometry = { 0, 0, 0, 0 }; 136 gtk_window_get_position(window, &geometry.x, &geometry.y); 137 gtk_window_get_size(window, &geometry.width, &geometry.height); 138 if (geometry.x == targetGeometry->x && geometry.y == targetGeometry->y && geometry.width == targetGeometry->width && geometry.height == targetGeometry->height) 139 RunLoop::current().stop(); 140 } 141 142 void setWindowFrameTimerFired() 143 { 144 RunLoop::current().stop(); 145 } 146 #endif 147 131 148 void setWindowFrame(WebPageProxy&, const WebCore::FloatRect& frame) final 132 149 { … … 135 152 GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); 136 153 if (webkit_web_view_is_controlled_by_automation(m_webView) && WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) { 154 if ((geometry.x < 0 || geometry.y < 0) && (geometry.width <= 0 || geometry.height <= 0)) 155 return; 156 157 auto signalID = g_signal_connect(window, "configure-event", G_CALLBACK(windowConfigureEventCallback), &geometry); 137 158 if (geometry.x >= 0 && geometry.y >= 0) 138 159 gtk_window_move(GTK_WINDOW(window), geometry.x, geometry.y); 139 160 if (geometry.width > 0 && geometry.height > 0) 140 161 gtk_window_resize(GTK_WINDOW(window), geometry.width, geometry.height); 162 163 // We need the move/resize to happen synchronously in automation mode, so we use a nested RunLoop 164 // to wait, up top 1 second, for the configure events. 165 auto timer = makeUnique<RunLoop::Timer<UIClient>>(RunLoop::main(), this, &UIClient::setWindowFrameTimerFired); 166 timer->setPriority(RunLoopSourcePriority::RunLoopTimer); 167 timer->startOneShot(1_s); 168 RunLoop::run(); 169 timer = nullptr; 170 g_signal_handler_disconnect(window, signalID); 141 171 } else 142 172 webkitWindowPropertiesSetGeometry(webkit_web_view_get_window_properties(m_webView), &geometry);
Note: See TracChangeset
for help on using the changeset viewer.