Title: [186761] trunk/Source/WebKit2
Revision
186761
Author
carlo...@webkit.org
Date
2015-07-13 00:44:18 -0700 (Mon, 13 Jul 2015)

Log Message

[GTK] Contents not correctly laid out when the web view is not realized
https://bugs.webkit.org/show_bug.cgi?id=142532

Reviewed by Darin Adler.

The problem is that we are not reporting any size until the web
view is realized, so any web view loaded in a separate tab in the
browser, will report 0x0 as the window.innerWidth,
window.innerHeight until the view is realized. Websites that use
the window.innerWidth/innerHeight during the page load to decide
how to lay out the contents will be rendered wrongly.
I haven't been able to reproduce this with unit tests, as this
requires the particular case of same window but different web
views using tabs for example.

* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::viewSize): Always report the drawing area
size to make usre it's in sync with the WebProcess page size.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseSizeAllocate): Remove the optimization of only
report the size when it has changed, since both the redirected
window and the drawing area already do that check. Also remove the
optimization of waiting until the view is mapped to report its
size, since that's often too late for websites using the window
size during load.
(webkitWebViewBaseMap): Never report size on map, it should have
already been reported by size-allocate.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (186760 => 186761)


--- trunk/Source/WebKit2/ChangeLog	2015-07-13 07:13:31 UTC (rev 186760)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-13 07:44:18 UTC (rev 186761)
@@ -1,3 +1,33 @@
+2015-07-13  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Contents not correctly laid out when the web view is not realized
+        https://bugs.webkit.org/show_bug.cgi?id=142532
+
+        Reviewed by Darin Adler.
+
+        The problem is that we are not reporting any size until the web
+        view is realized, so any web view loaded in a separate tab in the
+        browser, will report 0x0 as the window.innerWidth,
+        window.innerHeight until the view is realized. Websites that use
+        the window.innerWidth/innerHeight during the page load to decide
+        how to lay out the contents will be rendered wrongly.
+        I haven't been able to reproduce this with unit tests, as this
+        requires the particular case of same window but different web
+        views using tabs for example.
+
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::viewSize): Always report the drawing area
+        size to make usre it's in sync with the WebProcess page size.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseSizeAllocate): Remove the optimization of only
+        report the size when it has changed, since both the redirected
+        window and the drawing area already do that check. Also remove the
+        optimization of waiting until the view is mapped to report its
+        size, since that's often too late for websites using the window
+        size during load.
+        (webkitWebViewBaseMap): Never report size on map, it should have
+        already been reported by size-allocate.
+
 2015-07-11  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Inspector should be able to be docked to the bottom of a narrow window

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (186760 => 186761)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2015-07-13 07:13:31 UTC (rev 186760)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2015-07-13 07:44:18 UTC (rev 186761)
@@ -84,11 +84,8 @@
 
 WebCore::IntSize PageClientImpl::viewSize()
 {
-    if (!gtk_widget_get_realized(m_viewWidget))
-        return IntSize();
-    GtkAllocation allocation;
-    gtk_widget_get_allocation(m_viewWidget, &allocation);
-    return IntSize(allocation.width, allocation.height);
+    auto* drawingArea = static_cast<DrawingAreaProxyImpl*>(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->drawingArea());
+    return drawingArea ? drawingArea->size() : IntSize();
 }
 
 bool PageClientImpl::isViewWindowActive()

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (186760 => 186761)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-07-13 07:13:31 UTC (rev 186760)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-07-13 07:44:18 UTC (rev 186761)
@@ -155,7 +155,6 @@
     CString tooltipText;
     IntRect tooltipArea;
     GRefPtr<AtkObject> accessible;
-    bool needsResizeOnMap;
     GtkWidget* authenticationDialog;
     GtkWidget* inspectorView;
     AttachmentSide inspectorAttachmentSide;
@@ -551,8 +550,11 @@
     priv->children.set(child, IntRect());
 }
 
-static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation, bool sizeChanged)
+static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
 {
+    GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
+
+    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
     gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase);
 
     IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height);
@@ -594,34 +596,18 @@
     }
 
     DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
+    if (!drawingArea)
+        return;
 
+
 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (sizeChanged && priv->redirectedWindow && drawingArea && drawingArea->isInAcceleratedCompositingMode())
+    if (priv->redirectedWindow && drawingArea->isInAcceleratedCompositingMode())
         priv->redirectedWindow->resize(viewRect.size());
-#else
-    UNUSED_PARAM(sizeChanged);
 #endif
 
-    if (drawingArea)
-        drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
+    drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
 }
 
-static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
-{
-    bool sizeChanged = gtk_widget_get_allocated_width(widget) != allocation->width
-                       || gtk_widget_get_allocated_height(widget) != allocation->height;
-
-    GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
-
-    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
-    if (sizeChanged && !gtk_widget_get_mapped(widget)) {
-        webViewBase->priv->needsResizeOnMap = true;
-        return;
-    }
-
-    resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation, sizeChanged);
-}
-
 static void webkitWebViewBaseMap(GtkWidget* widget)
 {
     GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget);
@@ -632,14 +618,6 @@
         priv->isVisible = true;
         priv->pageProxy->viewStateDidChange(ViewState::IsVisible);
     }
-
-    if (!priv->needsResizeOnMap)
-        return;
-
-    GtkAllocation allocation;
-    gtk_widget_get_allocation(widget, &allocation);
-    resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation, true /* sizeChanged */);
-    priv->needsResizeOnMap = false;
 }
 
 static void webkitWebViewBaseUnmap(GtkWidget* widget)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to