[webkit-dev] GDOM-Binding: using gdom_css_style_sheet_add_rule()

Luke Kenneth Casson Leighton lkcl at lkcl.net
Thu Jun 11 04:01:09 PDT 2009


On 6/10/09, Leon Winter <lwi at ring0.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
>  Hash: SHA1
>
>  Hi,
>
>  the GDOM-Binding provides functions for setting up global CSS rules
>  and manipulating them. I'm interested in this functions, especially in:
>
>  WEBKIT_API glong
>  gdom_css_style_sheet_add_rule (GdomCSSStyleSheet *thiz, gchar *
>  selector, gchar * style, gulong index);
>
>  Okay, we need a GdomCSSStyleSheet, lets have a look:
>
>  WEBKIT_API GdomCSSStyleSheet *
>  gdom_dom_implementation_create_css_style_sheet (GdomDOMImplementation
>  *thiz, gchar * title, gchar * media);
>
>  So far so good, seems we need a GdomDOMImplementation object but there
>  is no function that returns this object.

 function, no, property, yes.

$ grep DOMImplementation */*/*.idl */*/*/*.idl
WebCore/dom/Document.idl:        readonly attribute [V8Custom]
DOMImplementation implementation;
WebCore/dom/DOMImplementation.idl:    ] DOMImplementation {
WebCore/dom/DOMImplementation.idl:        // DOMImplementationCSS
interface from DOM Level 2 CSS
WebCore/dom/DOMImplementation.idl:        // HTMLDOMImplementation
interface from DOM Level 2 HTML
WebCore/page/DOMWindow.idl://        attribute
DOMImplementationListConstructor DOMImplementationList;
WebCore/page/DOMWindow.idl://        attribute
DOMImplementationSourceConstructor DOMImplementationSource;
WebCore/page/DOMWindow.idl:        attribute
DOMImplementationConstructor DOMImplementation;
WebKit/win/Interfaces/DOMCore.idl:    @interface DOMImplementation : DOMObject
WebKit/win/Interfaces/DOMCore.idl:interface IDOMImplementation : IDOMObject
WebKit/win/Interfaces/DOMCore.idl:        - (DOMImplementation *)implementation;
WebKit/win/Interfaces/DOMCore.idl:    HRESULT implementation([out,
retval] IDOMImplementation** result);
WebKit/win/Interfaces/WebKit.idl:#include "IGEN_DOMDOMImplementation.idl"

the top one is the clue.  ignore the [V8Custom] modifier flag, that
just says that when doing google v8 engine, there's a custom
implementation of the function that fetches that property.

so:

    GdomDocument *doc = get_dom_document();
    GdomDOMImplementation *di;
    GdomCSSStyleSheet *css;

    g_object_get(doc, "implementation", &di, NULL);

    css = gdom_dom_implementation_create_css_style_sheet (di, title, media);

    ....
    ....

    g_object_unref(di);
    g_object_unref(css);
    g_object_unref(doc);

try that.

i'd be interested to see a successful creation of an example like
this: these things are a bit new, and collecting some working examples
would help people a lot.

l.


More information about the webkit-dev mailing list