[webkit-gtk] Proposal for Gobject Javascript Bridge for WebKitGtk

siraj razick siraj.razick at collabora.co.uk
Tue Aug 16 12:18:21 PDT 2011


Hi :)

This is a quick proposal for adding an API similar to Qt's 
QWebFrame::addToJavaScriptWindowObject  to GtkWebKit API.

API
=====
The higher level user API would be :

void webkit_web_frame_add_gobject_to_js_window_object (WebkitWebFrame 
*frame, const char *name, GObject *object); // add a already 
instantiated gobject into the webframe's js context
void 
webkit_web_frame_import_namespace_to_js_window_object(WebkitWebFrame 
*frame, const char *name, const gchar *namespace); // introduces a gir 
namespace into the frame js context


frame : The WebFrame
name : Variable name to identify the /"object" /within the frame's 
javascript context.
object : GObject we want to insert into the javascript context.
namespace : The GIR name space such as "GLib..etc"

How to do it : webkit_web_frame_add_gobject_to_js_window_object
========
* Use libsee ( http://live.gnome.org/Seed),

today libseed dev's downgraded their license from LGPL3+ to LGPL2+, 
which legally allows
us to use it inside webkit. How ever this will create a circular 
dependency since libseed depends on Webkit to build, To remerdy this
we will try to reuse only the utility methods in libseed, either by 
directly copying over the utility mehods or by spiting libseed into two
as libseed and libseed-util (Something I'll have to talk with seed dev's 
about). The reason for this is as follows

1.) libseed alraedy provides ways to handle GObject and its class 
hierarchy as javascript prototypes and object.

2.) proxy javascript method to native object methods

3.) Memory management of these objects


once we are cherry pick the libseed utility methods we need we can use 
this and build a bridge similar to Qt or Object-c
with Gtk Port.


Howto Do it : webkit_web_frame_import_namespace_to_js_window_object(..)

*. we use libseed and create a seed engine with frames js context, and 
import the
namespace specified as input so that users can create new object 
instances like
we do with seed or gjs scripts.

So what do you think ?. comments, reviews, idea's, and corrections a are 
really appreciated :)


note : I would like to thank Alexandre Mazari  and Kov for helping me 
draft this, /I've been discussing
these things with them on irc, mail..etc. and they helped me compile 
this proposal :)/

-- 
BR,
Siraj Razick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20110817/3e74fcfa/attachment.html>


More information about the webkit-gtk mailing list