Title: [102604] trunk/Source
Revision
102604
Author
commit-qu...@webkit.org
Date
2011-12-12 10:44:10 -0800 (Mon, 12 Dec 2011)

Log Message

[GTK] gtk_widget_size_allocate for plugin widgets should happen in the WebView size-allocate method
https://bugs.webkit.org/show_bug.cgi?id=72805

Patch by Martin Robinson <mrobin...@igalia.com> on 2011-12-12
Reviewed by Gustavo Noronha Silva.

Source/WebCore:

No new tests. This is only a performance tweak.

Instead of immediately calling gtk_widget_size during painting, defer
this until the size-allocate method of the WebView.

* plugins/gtk/PluginViewGtk.cpp:
(WebCore::PluginView::updateWidgetAllocationAndClip): Instead of immediately changing
the widget allocation, just record it in a GObject data attachment.

Source/WebKit/gtk:

Instead of immediately calling gtk_widget_size during painting, defer
this until the size-allocate method of the WebView.

* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::paint): If any child widgets have a pending allocation
call gtk_widget_size_allocate.
* webkit/webkitwebview.cpp:
(updateChildAllocationFromPendingAllocation): Added this helper.
(webkit_web_view_size_allocate): Call the helper on all child widgets.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102603 => 102604)


--- trunk/Source/WebCore/ChangeLog	2011-12-12 18:40:03 UTC (rev 102603)
+++ trunk/Source/WebCore/ChangeLog	2011-12-12 18:44:10 UTC (rev 102604)
@@ -1,3 +1,19 @@
+2011-12-12  Martin Robinson  <mrobin...@igalia.com>
+
+        [GTK] gtk_widget_size_allocate for plugin widgets should happen in the WebView size-allocate method
+        https://bugs.webkit.org/show_bug.cgi?id=72805
+
+        Reviewed by Gustavo Noronha Silva.
+
+        No new tests. This is only a performance tweak.
+
+        Instead of immediately calling gtk_widget_size during painting, defer
+        this until the size-allocate method of the WebView.
+
+        * plugins/gtk/PluginViewGtk.cpp:
+        (WebCore::PluginView::updateWidgetAllocationAndClip): Instead of immediately changing
+        the widget allocation, just record it in a GObject data attachment.
+
 2011-12-12  Nate Chapin  <jap...@chromium.org>
 
         A SubresourceLoader in the middle of revalidating

Modified: trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp (102603 => 102604)


--- trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp	2011-12-12 18:40:03 UTC (rev 102603)
+++ trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp	2011-12-12 18:44:10 UTC (rev 102604)
@@ -576,17 +576,14 @@
 #endif
     }
 
-    GtkAllocation allocation(m_delayedAllocation);
-    m_delayedAllocation = IntRect();
+    // The goal is to try to avoid calling gtk_widget_size_allocate in the WebView's
+    // size-allocate method. It blocks the main loop and if the widget is offscreen
+    // or hasn't moved it isn't required.
 
-    // The goal is to avoid calling gtk_widget_size_allocate when necessary.
-    // It blocks the main loop and if the widget is offscreen or hasn't moved
-    // it isn't required.
-
     // Don't do anything if the allocation has not changed.
     GtkAllocation currentAllocation;
     gtk_widget_get_allocation(widget, &currentAllocation);
-    if (currentAllocation == allocation)
+    if (currentAllocation == m_delayedAllocation)
         return;
 
     // Don't do anything if both the old and the new allocations are outside the frame.
@@ -595,7 +592,7 @@
     if (currentAllocationRect.isEmpty() && m_clipRect.isEmpty())
         return;
 
-    gtk_widget_size_allocate(widget, &allocation);
+    g_object_set_data(G_OBJECT(widget), "delayed-allocation", &m_delayedAllocation);
 }
 
 void PluginView::setParentVisible(bool visible)

Modified: trunk/Source/WebKit/gtk/ChangeLog (102603 => 102604)


--- trunk/Source/WebKit/gtk/ChangeLog	2011-12-12 18:40:03 UTC (rev 102603)
+++ trunk/Source/WebKit/gtk/ChangeLog	2011-12-12 18:44:10 UTC (rev 102604)
@@ -1,3 +1,20 @@
+2011-12-12  Martin Robinson  <mrobin...@igalia.com>
+
+        [GTK] gtk_widget_size_allocate for plugin widgets should happen in the WebView size-allocate method
+        https://bugs.webkit.org/show_bug.cgi?id=72805
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Instead of immediately calling gtk_widget_size during painting, defer
+        this until the size-allocate method of the WebView.
+
+        * WebCoreSupport/ChromeClientGtk.cpp:
+        (WebKit::ChromeClient::paint): If any child widgets have a pending allocation
+        call gtk_widget_size_allocate.
+        * webkit/webkitwebview.cpp:
+        (updateChildAllocationFromPendingAllocation): Added this helper.
+        (webkit_web_view_size_allocate): Call the helper on all child widgets.
+
 2011-12-09  Joone Hur  <joone....@collabora.co.uk>
 
         [GTK] Initial implementation of Accelerated Compositing using Clutter

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp (102603 => 102604)


--- trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp	2011-12-12 18:40:03 UTC (rev 102603)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp	2011-12-12 18:44:10 UTC (rev 102604)
@@ -565,6 +565,15 @@
     const IntRect& rect = m_dirtyRegion.bounds();
     gtk_widget_queue_draw_area(GTK_WIDGET(m_webView), rect.x(), rect.y(), rect.width(), rect.height());
 
+    HashSet<GtkWidget*> children = m_webView->priv->children;
+    HashSet<GtkWidget*>::const_iterator end = children.end();
+    for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) {
+        if (static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(*current), "delayed-allocation"))) {
+            gtk_widget_queue_resize_no_redraw(GTK_WIDGET(m_webView));
+            break;
+        }
+    }
+
     m_dirtyRegion = Region();
     m_lastDisplayTime = currentTime();
     m_repaintSoonSourceId = 0;

Modified: trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp (102603 => 102604)


--- trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2011-12-12 18:40:03 UTC (rev 102603)
+++ trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2011-12-12 18:44:10 UTC (rev 102604)
@@ -841,18 +841,33 @@
 }
 #endif
 
+static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
+{
+    if (!gtk_widget_get_visible(child))
+        return;
+
+    GtkAllocation* allocation = static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(child), "delayed-allocation"));
+    if (!allocation)
+        return;
+
+    g_object_set_data(G_OBJECT(child), "delayed-allocation", 0);
+    gtk_widget_size_allocate(child, allocation);
+    *allocation = IntRect();
+}
+
 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
 {
     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
 
-    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
-    Page* page = core(webView);
+    Page* page = core(WEBKIT_WEB_VIEW(widget));
     IntSize oldSize;
     if (FrameView* frameView = page->mainFrame()->view()) {
         oldSize = frameView->size();
         frameView->resize(allocation->width, allocation->height);
     }
 
+    gtk_container_forall(GTK_CONTAINER(widget), updateChildAllocationFromPendingAllocation, 0);
+
     WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
     chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
     chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to