[webkit-gtk] Webkit GTK 3.0: Using the DOM Tree Walker

charles at hailoo.com charles at hailoo.com
Thu Aug 2 06:09:29 PDT 2012


I'm experimenting with Webkit GTK DOM TreeWalker API.  Creating a 
TreeWalker with WebKit GTK seems pretty straightforward - except for one 
big problem: the fourth argument in the 
webkit_dom_document_create_tree_walker expects a filter object - that 
is, it wants an instance of WebKitDOMNodeFilter. Well, the 
document.createTreeWalker Javascript function also takes a filter, but 
you can pass null if you don't want to use a filter. With the Webkit 
API, passing NULL doesn't work. If you call:

WebKitDOMTreeWalker* walker = 
webkit_dom_document_create_tree_walker(doc, root, SHOW_ALL, NULL, false, 
err)

You get an assertion failure:

** (webkit:3367): CRITICAL : WebKitDOMTreeWalker* 
webkit_dom_document_create_tree_walker(WebKitDOMDocument*, 
WebKitDOMNode*, gulong, WebKitDOMNodeFilter*, gboolean, GError): 
assertion `filter' failed

So, the WebKit GTK API won't accept a NULL pointer for the filter 
argument. You need to pass an instance of a WebKitDOMNodeFilter. Okay, 
again - this wouldn't be a problem either, except I've searched far and 
wide through the WebKit GTK API, and I can't find anyway to create a 
WebKitDOMNodeFilter object. The header file for WebKitDOMNodeFilter.h 
doesn't expose any constructor for WebKitDOMNodeFilter. It seems like 
the API doesn't ever expose anyway to actually construct a 
WebKitDOMNodeFilter object at all.

Yet... the API exposes many functions (like 
webkit_dom_document_create_tree_walker, and 
webkit_dom_document_create_node_iterator) which require a 
WebKitDOMNodeFilter. So... is the API just incomplete right now? Or, is 
there some way to create a Filter object which I'm just not seeing?



More information about the webkit-gtk mailing list