[webkit-gtk] Accessing WebKit's CSS parser and CSS selector classes

Emmanuel Rodriguez emmanuel.rodriguez at gmail.com
Sun Oct 9 14:02:38 PDT 2011


Hi,

I'm writing a command line program to report the number of elements
that match each CSS rule defined in the current document.

The only way that I found to achieve this is to find all <style> and
<link> elements that declare CSS selectors and to extract the CSS
selectors by hand from the corresponding resources. Then for element
in the document call webkit_dom_element_webkit_matches_selector() with
the selector's string representation for each of the selectors defined
in the document.

webkit_dom_element_webkit_matches_selector() works well but it uses a
string for input which means that it has to parse the selector each
time that I need to match it with an element. Doing this for all
elements in a DOM tree is not too efficient...

>From what I can see WebKit's CSS parser (CSSParser) and selector
classes (SelectoChecker ,CSSSelector and CSSSelectorList) are not
exposed to WebKitGtk. Is there a plan to make these classes
accessible?

I thought of adding a custom method in C++ that could access the CSS
classes that I'm missing but WebKitGtk doesn't seen to install the
headers files for using the C++ classes of WebKit. Is there a way for
accessing the C++ classes from a WebKitGtk program without having to
add the program's code in WebKit's "Tools" folder?

-- 
Emmanuel Rodriguez


More information about the webkit-gtk mailing list