[hackers] [surf] added js-fix by Troels Henriksen. Thanks :) || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Sun, 9 May 2010 20:40:21 +0000 (UTC)

changeset: 197:21259f9b0be2
user: Enno Boland (tox) <tox_AT_s01.de>
date: Sun May 09 19:37:46 2010 +0200
files: surf.c
description:
added js-fix by Troels Henriksen. Thanks :)

diff -r a1d762bef415 -r 21259f9b0be2 surf.c
--- a/surf.c Thu May 06 13:58:49 2010 +0200
+++ b/surf.c Sun May 09 19:37:46 2010 +0200
@@ -151,6 +151,19 @@
 }
 
 void
+runscript(WebKitWebFrame *frame, JSContextRef js) {
+ JSStringRef jsscript;
+ char *script;
+ JSValueRef exception = NULL;
+ GError *error;
+
+ if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
+ jsscript = JSStringCreateWithUTF8CString(script);
+ JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js), NULL, 0, &exception);
+ }
+}
+
+void
 clipboard(Client *c, const Arg *arg) {
         gboolean paste = *(gboolean *)arg;
 
@@ -470,6 +483,7 @@
         int i;
         Client *c;
         WebKitWebSettings *settings;
+ WebKitWebFrame *frame;
         GdkGeometry hints = { 1, 1 };
         char *uri, *ua;
 
@@ -556,6 +570,8 @@
         gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
         gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
         webkit_web_view_set_full_content_zoom(c->view, TRUE);
+ frame = webkit_web_view_get_main_frame(c->view);
+ runscript(frame, webkit_web_frame_get_global_context(frame));
         settings = webkit_web_view_get_settings(c->view);
         if(!(ua = getenv("SURF_USERAGENT")))
                 ua = useragent;
@@ -860,15 +876,7 @@
 
 void
 windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js, JSObjectRef win, Client *c) {
- JSStringRef jsscript;
- char *script;
- JSValueRef exception = NULL;
- GError *error;
-
- if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
- jsscript = JSStringCreateWithUTF8CString(script);
- JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js), NULL, 0, &exception);
- }
+ runscript(frame, js);
 }
 
 void
Received on Sun May 09 2010 - 20:40:21 UTC

This archive was generated by hypermail 2.2.0 : Sun May 09 2010 - 20:48:05 UTC