struct _MidoriWebView
{
WebKitWebView parent_instance;
+ gboolean window_object_cleared;
GdkPixbuf* icon;
gchar* uri;
webkit_web_view_load_started (MidoriWebView* web_view,
WebKitWebFrame* web_frame)
{
+ web_view->window_object_cleared = FALSE;
+
web_view->load_status = MIDORI_LOAD_PROVISIONAL;
g_object_notify (G_OBJECT (web_view), "mload-status");
if (web_view->tab_icon)
g_object_notify (G_OBJECT (web_view), "progress");
}
+static void
+webkit_web_view_window_object_cleared_cb (MidoriWebView* web_view,
+ WebKitWebFrame* web_frame,
+ JSGlobalContextRef js_context,
+ JSObjectRef js_window)
+{
+ web_view->window_object_cleared = TRUE;
+}
+
#if GLIB_CHECK_VERSION (2, 16, 0)
void
loadable_icon_finish_cb (GdkPixbuf* icon,
gboolean success,
MidoriWebView* web_view)
{
+ JSContextRef js_context;
+ JSValueRef js_window;
GjsValue* value;
GjsValue* document;
GjsValue* links;
+ /* If WebKit didn't emit the signal due to a bug, we will */
+ if (!web_view->window_object_cleared)
+ {
+ js_context = webkit_web_frame_get_global_context (web_frame);
+ js_window = JSContextGetGlobalObject (js_context);
+ g_signal_emit_by_name (web_view, "window-object-cleared",
+ web_frame, js_context, js_window);
+ }
+
value = gjs_value_new (webkit_web_frame_get_global_context (web_frame), NULL);
document = gjs_value_get_by_name (value, "document");
links = gjs_value_get_elements_by_tag_name (document, "link");
g_object_connect (web_view,
"signal::load-started",
webkit_web_view_load_started, NULL,
+ "signal::window-object-cleared",
+ webkit_web_view_window_object_cleared_cb, NULL,
"signal::load-committed",
webkit_web_view_load_committed, NULL,
"signal::icon-ready",