Changeset 278301 in webkit
- Timestamp:
- Jun 1, 2021, 4:59:21 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/gtk/PageClientImpl.cpp (modified) (1 diff)
-
UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (3 diffs)
-
UIProcess/API/gtk/WebKitWebViewBasePrivate.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r278258 r278301 1 2021-06-01 Alexander Mikhaylenko <alexm@gnome.org> 2 3 [GTK] Try harder to find initial WebKitWebView size 4 https://bugs.webkit.org/show_bug.cgi?id=226320 5 6 Reviewed by Michael Catanzaro. 7 8 Currently we base the viewport size on the drawing area size. The 9 drawing area is created with an initial size based on the viewport 10 size, which will be (0, 0) because the drawing area is still null 11 by that point. 12 13 Then, later, during the widget allocation, the drawing area receives 14 its proper size. 15 16 There are 2 issues here. First, this approach guarantees that the 17 initial viewport size will always be (0, 0), and then there's no 18 guarantee the widget will be allocated any time soon - for example, 19 while GtkNotebook in GTK3 does allocate children that aren't currently 20 visible, GtkStack doesn't (and that means that GtkNotebook in GTK4 and 21 HdyTabView don't either). This leads to a situation where a page opened 22 in background will load with 0, 0 size and if a page depends on that, 23 it won't load correctly. 24 25 The first issue can be fixed by basing the viewport size on the view 26 allocation as well, and then if the widget isn't allocated, we instead 27 try to use the size of a parent as an estimation, so that the initial 28 size is at least not 0 even if not fully accurate. 29 30 See https://gitlab.gnome.org/GNOME/epiphany/-/issues/1532 31 32 * UIProcess/API/gtk/PageClientImpl.cpp: 33 (WebKit::PageClientImpl::viewSize): 34 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 35 (webkitWebViewBaseGetViewSize): 36 * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: 37 1 38 2021-05-30 Dean Jackson <dino@apple.com> 2 39 -
trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
r278253 r278301 104 104 WebCore::IntSize PageClientImpl::viewSize() 105 105 { 106 auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->drawingArea()); 107 return drawingArea ? drawingArea->size() : IntSize(); 106 return webkitWebViewBaseGetViewSize(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); 108 107 } 109 108 -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r278253 r278301 264 264 std::unique_ptr<PageClientImpl> pageClient; 265 265 RefPtr<WebPageProxy> pageProxy; 266 IntSize viewSize { }; 266 267 bool shouldForwardNextKeyEvent { false }; 267 268 bool shouldForwardNextWheelEvent { false }; … … 892 893 #endif 893 894 895 priv->viewSize = viewRect.size(); 896 894 897 if (auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(priv->pageProxy->drawingArea())) 895 drawingArea->setSize( viewRect.size());898 drawingArea->setSize(priv->viewSize); 896 899 } 897 900 … … 2361 2364 2362 2365 webkitWebViewBaseScheduleUpdateActivityState(webViewBase, flagsToUpdate); 2366 } 2367 2368 IntSize webkitWebViewBaseGetViewSize(WebKitWebViewBase* webViewBase) 2369 { 2370 WebKitWebViewBasePrivate* priv = webViewBase->priv; 2371 int width = priv->viewSize.width(); 2372 int height = priv->viewSize.height(); 2373 2374 // First try the widget's own size. If it's already allocated, 2375 // everything is fine and we'll just use that. 2376 if (width > 0 || height > 0) 2377 return IntSize(width, height); 2378 2379 GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(webViewBase)); 2380 2381 // If it's not allocated, then its size will be 0. This can be a problem 2382 // if the web view is loaded in background and the container doesn't 2383 // allocate non-visible children: e.g. GtkNotebook in GTK3 does allocate 2384 // them, but GtkStack, and so GtkNotebook in GTK4 and HdyTabView don't. 2385 // See https://gitlab.gnome.org/GNOME/epiphany/-/issues/1532 2386 // In that case we go up through the hierarchy and try to find a parent 2387 // with non-0 size. 2388 while (parent) { 2389 #if USE(GTK4) 2390 width = gtk_widget_get_width(parent); 2391 height = gtk_widget_get_height(parent); 2392 2393 if (width > 0 || height > 0) 2394 #else 2395 width = gtk_widget_get_allocated_width(parent); 2396 height = gtk_widget_get_allocated_height(parent); 2397 2398 // The default widget size in GTK3 is 1x1, not 0x0. 2399 if (width > 1 || height > 1) 2400 #endif 2401 return IntSize(width, height); 2402 2403 parent = gtk_widget_get_parent(parent); 2404 } 2405 2406 // If there was no such a parent, it's likely the widget widget isn't 2407 // in a window, or the whole window isn't mapped. No point in trying 2408 // in this case. 2409 2410 return IntSize(); 2363 2411 } 2364 2412 -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
r278253 r278301 65 65 66 66 void webkitWebViewBaseSetFocus(WebKitWebViewBase*, bool focused); 67 WebCore::IntSize webkitWebViewBaseGetViewSize(WebKitWebViewBase*); 67 68 bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase*); 68 69 bool webkitWebViewBaseIsFocused(WebKitWebViewBase*);
Note:
See TracChangeset
for help on using the changeset viewer.