/pidgin/main: e03ae42cf793: Faster webkit webview - process elem...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Mon Nov 19 09:54:07 EST 2012


Changeset: e03ae42cf7933fa4978db0fa77cd70d36850d221
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-11-19 15:53 +0100
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/e03ae42cf793

Description:

Faster webkit webview - process elements from queue until timeout is hit

diffstat:

 pidgin/gtkwebview.c |  42 +++++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 11 deletions(-)

diffs (74 lines):

diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -38,6 +38,7 @@
 #define MAX_FONT_SIZE 7
 #define MAX_SCROLL_TIME 0.4 /* seconds */
 #define SCROLL_DELAY 33 /* milliseconds */
+#define GTK_WEBVIEW_MAX_PROCESS_TIME 100000 /* microseconds */
 
 #define GTK_WEBVIEW_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEW, GtkWebViewPriv))
@@ -705,8 +706,8 @@ webview_resource_loading(WebKitWebView *
 	}
 }
 
-static gboolean
-process_load_queue(GtkWebView *webview)
+static void
+process_load_queue_element(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
 	int type;
@@ -717,15 +718,6 @@ process_load_queue(GtkWebView *webview)
 	WebKitDOMRange *range;
 	gboolean require_scroll = FALSE;
 
-	if (priv->is_loading) {
-		priv->loader = 0;
-		return FALSE;
-	}
-	if (!priv->load_queue || g_queue_is_empty(priv->load_queue)) {
-		priv->loader = 0;
-		return FALSE;
-	}
-
 	type = GPOINTER_TO_INT(g_queue_pop_head(priv->load_queue));
 	str = g_queue_pop_head(priv->load_queue);
 
@@ -783,7 +775,35 @@ process_load_queue(GtkWebView *webview)
 	}
 
 	g_free(str);
+}
 
+static gboolean
+process_load_queue(GtkWebView *webview)
+{
+	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	gint64 start_time;
+
+	if (priv->is_loading) {
+		priv->loader = 0;
+		return FALSE;
+	}
+	if (!priv->load_queue || g_queue_is_empty(priv->load_queue)) {
+		priv->loader = 0;
+		return FALSE;
+	}
+
+	start_time = g_get_monotonic_time();
+	while (!g_queue_is_empty(priv->load_queue)) {
+		process_load_queue_element(webview);
+		if (g_get_monotonic_time() - start_time >
+			GTK_WEBVIEW_MAX_PROCESS_TIME)
+			break;
+	}
+
+	if (g_queue_is_empty(priv->load_queue)) {
+		priv->loader = 0;
+		return FALSE;
+	}
 	return TRUE;
 }
 



More information about the Commits mailing list