pidgin/gtkwebview.c

changeset 33535
e03ae42cf793
parent 33500
d6de39919ac3
child 33857
af0723304ab3
equal deleted inserted replaced
33533:f55a5555ee46 33535:e03ae42cf793
36 #include "gtk3compat.h" 36 #include "gtk3compat.h"
37 37
38 #define MAX_FONT_SIZE 7 38 #define MAX_FONT_SIZE 7
39 #define MAX_SCROLL_TIME 0.4 /* seconds */ 39 #define MAX_SCROLL_TIME 0.4 /* seconds */
40 #define SCROLL_DELAY 33 /* milliseconds */ 40 #define SCROLL_DELAY 33 /* milliseconds */
41 #define GTK_WEBVIEW_MAX_PROCESS_TIME 100000 /* microseconds */
41 42
42 #define GTK_WEBVIEW_GET_PRIVATE(obj) \ 43 #define GTK_WEBVIEW_GET_PRIVATE(obj) \
43 (G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEW, GtkWebViewPriv)) 44 (G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEW, GtkWebViewPriv))
44 45
45 enum { 46 enum {
703 g_free(tmp); 704 g_free(tmp);
704 } 705 }
705 } 706 }
706 } 707 }
707 708
708 static gboolean 709 static void
709 process_load_queue(GtkWebView *webview) 710 process_load_queue_element(GtkWebView *webview)
710 { 711 {
711 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); 712 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
712 int type; 713 int type;
713 char *str; 714 char *str;
714 WebKitDOMDocument *doc; 715 WebKitDOMDocument *doc;
715 WebKitDOMHTMLElement *body; 716 WebKitDOMHTMLElement *body;
716 WebKitDOMNode *start, *end; 717 WebKitDOMNode *start, *end;
717 WebKitDOMRange *range; 718 WebKitDOMRange *range;
718 gboolean require_scroll = FALSE; 719 gboolean require_scroll = FALSE;
719
720 if (priv->is_loading) {
721 priv->loader = 0;
722 return FALSE;
723 }
724 if (!priv->load_queue || g_queue_is_empty(priv->load_queue)) {
725 priv->loader = 0;
726 return FALSE;
727 }
728 720
729 type = GPOINTER_TO_INT(g_queue_pop_head(priv->load_queue)); 721 type = GPOINTER_TO_INT(g_queue_pop_head(priv->load_queue));
730 str = g_queue_pop_head(priv->load_queue); 722 str = g_queue_pop_head(priv->load_queue);
731 723
732 switch (type) { 724 switch (type) {
781 "Got unknown loading queue type: %d\n", type); 773 "Got unknown loading queue type: %d\n", type);
782 break; 774 break;
783 } 775 }
784 776
785 g_free(str); 777 g_free(str);
786 778 }
779
780 static gboolean
781 process_load_queue(GtkWebView *webview)
782 {
783 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
784 gint64 start_time;
785
786 if (priv->is_loading) {
787 priv->loader = 0;
788 return FALSE;
789 }
790 if (!priv->load_queue || g_queue_is_empty(priv->load_queue)) {
791 priv->loader = 0;
792 return FALSE;
793 }
794
795 start_time = g_get_monotonic_time();
796 while (!g_queue_is_empty(priv->load_queue)) {
797 process_load_queue_element(webview);
798 if (g_get_monotonic_time() - start_time >
799 GTK_WEBVIEW_MAX_PROCESS_TIME)
800 break;
801 }
802
803 if (g_queue_is_empty(priv->load_queue)) {
804 priv->loader = 0;
805 return FALSE;
806 }
787 return TRUE; 807 return TRUE;
788 } 808 }
789 809
790 static void 810 static void
791 webview_load_started(WebKitWebView *webview, WebKitWebFrame *frame, 811 webview_load_started(WebKitWebView *webview, WebKitWebFrame *frame,

mercurial