[webkit-dev] webkit glib DOM bindings demo code

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Dec 10 12:56:54 PST 2008


the modifications to main.c are getting a little bit more
sophisticated, so i thought it best to post it as a separate link,
with explanations here.

get_absolute_top() is a [bad] port of the pyjamas-desktop javascript
function of the same absolute camelised name, DOM.getAbsoluteTop() -
source code here:
you can at least see what was being attempted :)

scroll_into_view() is quite obvious: given any particular node in the
DOM tree, scroll_into_view() ensures that that node will be visible.
having used get_absolute_top() to locate its absolute position,
gdom_dom_window_scroll_to() is called to actually move the window
scroll position.  it's left as an exercise to the reader (at the
moment) to do scrolling on X position and to write a
get_absolute_left() to match, and to get the width/height of the
window and of the node and put the node at the _bottom_ of the
scrolling window (or in the middle) with a little maths.

print_attribute() is necessary in instances where XML is being
created, or in cases where an HTML element has non-W3C-compliant
attributes.  in such cases, you cannot get the "property" - i.e. you
cannot use g_object_get() - because the attribute's not named in the
IDL file.  such attributes end up in the NamedNodeMap, you thus have
to use gdom_named_node_map_get_named_item() to get at them.  this
being c, it's all rather damn long-winded and awkward.

set_example_css_property() shows how to set a border CSS property
(yippee!) - it's the only one of the functions that actually makes any
modifications to the page.

i've corrected the examples, adding in g_free() which i had left out
up until now (whoops!)


More information about the webkit-dev mailing list