Carlos Garcia Campos
cgarcia at igalia.com
Thu Oct 30 00:05:35 PDT 2014
El mié, 29-10-2014 a las 23:33 +0200, Anatoly Zaretsky escribió:
> I am migrating a WebKit1-based application to the WebKit2 API. The
> used the WebKitWebView's "window-object-cleared" signal and the
> C API to extend the window object with the function
> void renderHTML(String content, String baseURI, Callback
> When called the function would:
> - create a new WebKitWebView;
> - place it inside a newly created GtkOffscreenWindow;
> - load the supplied content with webkit_web_view_load_string;
> - subscribe to the view's "notify::load-status" signal;
> - get the pixbuf from the GtkOffscreenWindow on WEBKIT_LOAD_FINISHED;
> - finally, invoke the contentRendered callback passing it the contents
> of the extracted pixbuf (particular pixbuf representation used is not
> of interest here).
> Is it possible to do the same with WebKit2? In particular can a web
> process extension use webkit_web_view_new/webkit_web_view_load_html?
No, WebView is the UI process API.
> The reference manual does not explicitly forbid doing so, though
> both <webkit2/webkit2.h> and <webkit2/webkit-web-extension.h> in the
> same source forces compilation error.
> Also, are there other ways to programmatically convert some arbitrary
> html text into an image?
If I understood correctly what you want, I think it would be something
In the web extension you connect to the window-object-cleared signal,
and with the exactly same code you currently has extends the window
object to add renderHTML. In the callback you would need to send a
message to the UI process, using DBus or any other IPC mechanism you
In the UI process, when the message is received you create a WebView,
connects to load-changed, and loads the HTML using
webkit_web_view_load_html. In the load-changed signal when the load
event is finished, you can call webkit_web_view_get_snpashot to
asynchronously get a cairo image surface with the web view contents
rendered. Now you need to send another message to the web extension with
We are about to land a patch that would simplify this, you wouldn't need
to extend the window object nor send an IPC message to the UI process.
window.webkit.messageHandlers.renderer.postMessage() and the message
would be received in the UI process as a signal with a
> webkit-gtk mailing list
> webkit-gtk at lists.webkit.org
Carlos Garcia Campos
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 181 bytes
Desc: This is a digitally signed message part
More information about the webkit-gtk