[webkit-dev] GTK+ Javascript return value

Sean Hignett sean at intelligent-design.ca
Thu Apr 24 12:50:45 PDT 2008

Apologies if this is the wrong place for this sort of discussion.  I  
have been developing an application using WebKit/GTK+, and I noticed  
that the GTK+ wrapper does not contain a means to get the return value  
from a javascript call (from C).

void webkit_web_view_execute_script(WebKitWebView* webView, const  
gchar* script);

exists, but is really a fire and forget.  I could find nothing else,  
so I wrote a quick extension:

gchar* webkit_web_view_execute_script_with_retval(WebKitWebView*  
webView, const gchar* script)
     if(!WEBKIT_IS_WEB_VIEW(webView)) return NULL;
     if(!script) return NULL;

     if (FrameLoader* loader = core(webView)->mainFrame()->loader())
         JSValue* retval = loader- 
 >executeScript(String::fromUTF8(script), true);
	        UString retstring = retval->getString();
	        if(retstring == NULL) return NULL;
	        gchar* gretval = g_utf16_to_utf8((gunichar2*) retstring.data(),
	        return gretval;

     return NULL;

Not at all patch worthy, but it works, and now I can call into  
javascript and get return values - I am wondering if there are any  
plans to implement something like this (but well written) in the future?

Also, I have not been able to get text shadows working on my WebKit/GTK 
+, but a recent article on Ars suggests it is now working - I am using  
pango - something else I need to do?


More information about the webkit-dev mailing list