[mingw-webkitgtk: 26/36] Backport patch to fix WebKitWebView not drawing initially on win32

Kalev Lember kalev at fedoraproject.org
Tue Mar 6 21:11:38 UTC 2012


commit a82503bd865c7b0d63ecbdc5c2a4e34ba4f28e8f
Author: Kalev Lember <kalevlember at gmail.com>
Date:   Tue Feb 7 12:58:32 2012 +0200

    Backport patch to fix WebKitWebView not drawing initially on win32

 ...ebView-does-a-lot-of-work-during-size_all.patch |  193 ++++++++++++++++++++
 mingw32-webkitgtk.spec                             |    5 +
 2 files changed, 198 insertions(+), 0 deletions(-)
---
diff --git a/0001-GTK-WebKitWebView-does-a-lot-of-work-during-size_all.patch b/0001-GTK-WebKitWebView-does-a-lot-of-work-during-size_all.patch
new file mode 100644
index 0000000..58bc115
--- /dev/null
+++ b/0001-GTK-WebKitWebView-does-a-lot-of-work-during-size_all.patch
@@ -0,0 +1,193 @@
+From dcf2cdef61e54a2fe29d509953fbba83fc51ec2c Mon Sep 17 00:00:00 2001
+From: "commit-queue at webkit.org"
+ <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
+Date: Mon, 6 Feb 2012 17:59:27 +0000
+Subject: [PATCH] [GTK] WebKitWebView does a lot of work during size_allocate
+ when not mapped
+ https://bugs.webkit.org/show_bug.cgi?id=77743
+
+Patch by Martin Robinson <mrobinson at igalia.com> on 2012-02-06
+Reviewed by Gustavo Noronha Silva.
+
+Instead of resizing the guts of a WebView when it's not mapped, wait
+until it's mapped and do one resize. This prevents unmapped WebViews
+from adding to a container's resize cost.
+
+Source/WebKit/gtk:
+
+* webkit/webkitwebview.cpp:
+(resizeWebViewFromAllocation): Abstracted out this helper.
+(webkit_web_view_size_allocate): Wait until map to resize umapped widgets.
+(webkitWebViewMap): Added this vmethod implementation.
+(webkit_web_view_class_init): Added vmethod.
+* webkit/webkitwebviewprivate.h: Added new needsResizeOnMap member.
+
+Source/WebKit2:
+
+* UIProcess/API/gtk/WebKitWebViewBase.cpp:
+(_WebKitWebViewBasePrivate): Added a new member needsResizeOnMap.
+(resizeWebKitWebViewBaseFromAllocation): Abstracted out this helper.
+(webkitWebViewBaseSizeAllocate): Wait until map to resize unmapped WebViews.
+(webkitWebViewBaseMap): Added this vmethod implementation.
+(webkit_web_view_base_class_init): Added vmethod.
+
+git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+---
+ Source/WebKit/gtk/webkit/webkitwebview.cpp         |   35 +++++++++++++++---
+ Source/WebKit/gtk/webkit/webkitwebviewprivate.h    |    1 +
+ .../UIProcess/API/gtk/WebKitWebViewBase.cpp        |   39 ++++++++++++++++----
+ 5 files changed, 99 insertions(+), 12 deletions(-)
+
+diff --git a/Source/WebKit/gtk/webkit/webkitwebview.cpp b/Source/WebKit/gtk/webkit/webkitwebview.cpp
+index ac6158b..a512d55 100644
+--- a/Source/WebKit/gtk/webkit/webkitwebview.cpp
++++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp
+@@ -859,18 +859,16 @@ static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
+     *allocation = IntRect();
+ }
+ 
+-static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
++static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation)
+ {
+-    GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
+-
+-    Page* page = core(WEBKIT_WEB_VIEW(widget));
++    Page* page = core(webView);
+     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);
++    gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0);
+ 
+     WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
+     chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
+@@ -881,6 +879,32 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo
+ #endif
+ }
+ 
++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);
++    if (!gtk_widget_get_mapped(widget)) {
++        webView->priv->needsResizeOnMap = true;
++        return;
++    }
++    resizeWebViewFromAllocation(webView, allocation);
++}
++
++static void webkitWebViewMap(GtkWidget* widget)
++{
++    GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget);
++
++    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
++    if (!webView->priv->needsResizeOnMap)
++        return;
++
++    GtkAllocation allocation;
++    gtk_widget_get_allocation(widget, &allocation);
++    resizeWebViewFromAllocation(webView, &allocation);
++    webView->priv->needsResizeOnMap = false;
++}
++
+ static void webkit_web_view_grab_focus(GtkWidget* widget)
+ {
+ 
+@@ -2767,6 +2791,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
+     widgetClass->query_tooltip = webkit_web_view_query_tooltip;
+     widgetClass->show_help = webkit_web_view_show_help;
+ #endif
++    widgetClass->map = webkitWebViewMap;
+ 
+     GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
+     containerClass->add = webkit_web_view_container_add;
+diff --git a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h
+index 8d2b7b0..b9d0b29 100644
+--- a/Source/WebKit/gtk/webkit/webkitwebviewprivate.h
++++ b/Source/WebKit/gtk/webkit/webkitwebviewprivate.h
+@@ -61,6 +61,7 @@ struct _WebKitWebViewPrivate {
+     GRefPtr<GtkIMContext> imContext;
+ 
+     gboolean transparent;
++    bool needsResizeOnMap;
+ 
+ #ifndef GTK_API_VERSION_2
+     // GtkScrollablePolicy needs to be checked when
+diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+index d9ccaa3..adcc34a 100644
+--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
++++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+@@ -71,6 +71,7 @@ struct _WebKitWebViewBasePrivate {
+     DragIcon dragIcon;
+     IntSize resizerSize;
+     GRefPtr<AtkObject> accessible;
++    bool needsResizeOnMap;
+ };
+ 
+ G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
+@@ -202,20 +203,43 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
+     return FALSE;
+ }
+ 
++static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation)
++{
++    WebKitWebViewBasePrivate* priv = webViewBase->priv;
++
++    if (priv->pageProxy->drawingArea())
++        priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize());
++
++    GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webViewBase));
++    if (widgetIsOnscreenToplevelWindow(toplevel))
++        webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel));
++}
++
+ 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);
+-    WebKitWebViewBasePrivate* priv = webViewBase->priv;
++    if (!gtk_widget_get_mapped(GTK_WIDGET(webViewBase)) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) {
++        webViewBase->priv->needsResizeOnMap = true;
++        return;
++    }
++    resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation);
++}
++
++static void webkitWebViewBaseMap(GtkWidget* widget)
++{
++    GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget);
+ 
+-    if (!priv->pageProxy->drawingArea())
++    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
++    if (!webViewBase->priv->needsResizeOnMap)
+         return;
+ 
+-    GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
+-    priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize());
++    GtkAllocation allocation;
++    gtk_widget_get_allocation(widget, &allocation);
++    resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation);
++    webViewBase->priv->needsResizeOnMap = false;
+ 
+-    GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
+-    if (widgetIsOnscreenToplevelWindow(toplevel))
+-        webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel));
+ }
+ 
+ static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event)
+@@ -454,6 +478,7 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
+     widgetClass->realize = webkitWebViewBaseRealize;
+     widgetClass->draw = webkitWebViewBaseDraw;
+     widgetClass->size_allocate = webkitWebViewBaseSizeAllocate;
++    widgetClass->map = webkitWebViewBaseMap;
+     widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent;
+     widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent;
+     widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent;
+-- 
+1.7.9
+
diff --git a/mingw32-webkitgtk.spec b/mingw32-webkitgtk.spec
index bcaafae..002afa1 100644
--- a/mingw32-webkitgtk.spec
+++ b/mingw32-webkitgtk.spec
@@ -68,6 +68,9 @@ Patch2:		webkit-dont-build-dump-render-tree.patch
 # Upstream patch, link with gmodule-2.0
 Patch3:		webkitgtk-1.7.5-gmodule.patch
 
+# Upstream patch, fixes WebKitWebView not drawing initially on win32
+Patch4:		0001-GTK-WebKitWebView-does-a-lot-of-work-during-size_all.patch
+
 BuildArch:	noarch
 
 BuildRequires:	bison
@@ -123,6 +126,7 @@ Static version of the MinGW Windows WebKitGTK+ library.
 %patch1 -p1 -b .mingw
 %patch2 -p0 -b .dumprendertree
 %patch3 -p1 -b .gmodule
+%patch4 -p1 -b .webview_map
 
 
 %build
@@ -208,6 +212,7 @@ fi
 - Drop upstreamed patches
 - Add a patch to link with gmodule
 - Switch to .xz tarballs
+- Backport patch to fix WebKitWebView not drawing initially on win32
 
 * Tue Jan 31 2012 Erik van Pienbroek <epienbro at fedoraproject.org> - 1.6.1-3
 - Fix compilation against glib 2.31.2 or higher


More information about the scm-commits mailing list