[webkit-dev] webkit #16401
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Tue Jun 9 02:16:24 PDT 2009
[moving this discussion to webkit-dev]
On 6/7/09, Leon Winter <lwi at ring0.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> I tried to port my javascript further in order to find new issues and
> I found some as expected:
>
> Luke, in your example main.c you use the custom function
> get_absolute_top() in order to compute the absolute distance to the
> top. It seems thats currently the only way but it shouldnt since we
> have the excellent getBoundingClientRect() function on every DOM
> element in JavaScript and it would make a lot of sense do provide this
> function aswell in the binding. Using this function we can access the
> distance the top directly because the engine computed it anyway before
> in order to display.
> I searched for this function in the binding but did not find it,
> however there is "GdomRect" which one should gain via
> "GdomCSSPrimitiveValue". However there are no functions to access
> "GdomRect" and there is no constructor for "GdomCSSPrimitiveValue".
ok. the getBoundingClientRect function is declared as a
"javascriptism", and is therefore declared as "Not Part Of The Vision
For Webkit Language Bindings As Dictated By Apple The Great Fascist
Leaders All Hail Apple And Bow Before Them For They Expect Us To Obey
Them Without Question"
let's have a look at this, in other implementations:
https://developer.mozilla.org/En/DOM:element.getBoundingClientRect
yes, mozilla has getBoundingRectClient.
let's double-check whether that's actually available, by trying an
actual real-world test in e.g. mozilla-xpdom / python-hulahop. modify
the source in http://lkcl.net/pyjamas/pyjamas-xpdom.tgz as follows:
n = doc.createTextNode("hello")
print n
body = doc.getElementsByTagName("body").item(0)
body.appendChild(n)
vvvvvvvvvvvvvvvvvvvvvvvvvvvv
print body.getBoundingClientRect()
^^^^^^^^^^^^^^^^^^^^^^
run it, and yes, we get this:
<XPCOM component '<unknown>' (implementing nsIDOMClientRect)>
so yes, in the firefox Gecko / XUL engine, competitor to webkit, it
can be deduced to support this function across all language bindings.
from the same web page, it is quoted:
"getBoundingClientRect() was first introduced in the MS IE DHTML object model."
ok - that's a DCOM interface. and through DCOM, you can bind any
language to DCOM that has a DCOM support library (python-win32com,
visual basic, visual c++, visual .NET etc.)
what about KDE? i'd be surprised if KHTML had it, but hey, i like surprises.
http://developer.kde.org/documentation/library/3.4-api/khtml/html/classDOM_1_1Element.html
ehhh, no. they've implemented "most" of DOM level 1 and 2, bless
them. DOM level 3 isn't on the roadmap, and CSSOM most certainly
isn't.
what about opera?
hhmmm, they implement DOM level 3 and various recommendations, and also, ah ha!
http://my.opera.com/edvakf/blog/2008/10/16/opera-9-60
a poorly-implemented version of getBoundingClientRect.
there _seems_ to be some hints that their API has other language
bindings - an article said "javascript, java, or perl" god help us.
what about webkit?
vi WebCore/dom/Element.idl
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
// CSSOM View Module API
ClientRectList getClientRects();
ClientRect getBoundingClientRect();
#endif
no.
so, your answer, leon: if you want getBoundingClientRect in the gdom
glib/gobject bindings, you're going to have to fight for it.
good justifications for adding it include:
* it's in every other web engine technology that implements this level
of W3C standards (CSSOM?)
* every other web engine technology makes the functions that are
available to javascript _also_ available to all other language
bindings.
comments from apple as to why this function is restricted to just
javascript are requested.
l.
More information about the webkit-dev
mailing list