From 8570ead256e0e0d825e3c78c5db52d2b00c212e6 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Fri, 10 Jan 2014 00:03:16 +0100 Subject: [PATCH] Fixed none removed hints on pages with AJAX (#61). The load of page parts with AJAX triggered the injection of the VbHint object into the page. This overlayed the current used VbHint object so that the clear() call (started out of hints.c) was run on the new and empty VbHint object, that does not know anything of already active hints. This patch moves the initializing of hints to "window-object-cleared" signal. This is only emmited, if a new window object is created, so thatwe do not overlay an already defined object. According to the surf browser also the user script loading was moved to the "window-object-clear" signal handler, else this would be called multiple times on each page load or if only parts of the page are updated via AJAX. --- src/main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index e2899e7..805f9a4 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,8 @@ static void title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, cons static gboolean mimetype_decision_cb(WebKitWebView *webview, WebKitWebFrame *frame, WebKitNetworkRequest *request, char* mime_type, WebKitWebPolicyDecision *decision); +static void window_object_cleared_cb(GtkWidget *widget, WebKitWebFrame *frame, + JSContextRef js, JSObjectRef win, gpointer data); static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec); /* functions */ @@ -416,12 +418,6 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) } else { set_status(VB_STATUS_NORMAL); } - - /* inject the hinting javascript */ - hints_init(frame); - - /* run user script file */ - run_user_script(frame); } /* if we load a page from a submitted form, leafe the insert mode */ @@ -708,6 +704,7 @@ static void setup_signals() "signal::hovering-over-link", G_CALLBACK(hover_link_cb), NULL, "signal::title-changed", G_CALLBACK(title_changed_cb), NULL, "signal::mime-type-policy-decision-requested", G_CALLBACK(mimetype_decision_cb), NULL, + "signal::window-object-cleared", G_CALLBACK(window_object_cleared_cb), NULL, "signal::download-requested", G_CALLBACK(vb_download), NULL, "signal::should-show-delete-interface-for-element", G_CALLBACK(gtk_false), NULL, NULL @@ -905,6 +902,16 @@ static gboolean mimetype_decision_cb(WebKitWebView *webview, return false; } +static void window_object_cleared_cb(GtkWidget *widget, WebKitWebFrame *frame, + JSContextRef js, JSObjectRef win, gpointer data) +{ + /* inject the hinting javascript */ + hints_init(frame); + + /* run user script file */ + run_user_script(frame); +} + gboolean vb_download(WebKitWebView *view, WebKitDownload *download, const char *path) { WebKitDownloadStatus status; -- 2.20.1