[webkit-help] HTML and JavaScript reflection layer

Julien Chaffraix julien.chaffraix at gmail.com
Tue Oct 18 08:48:12 PDT 2011

> I'v noticed that in the interface descriptions of html objects, not
> every field is marked with a Reflect. For example,
> WebCore/html/HTMLImageElement.idl does not mark the width and height
> attributes as Reflect. However, name, hspace and vspace are marked
> Reflect.
> I'm just wondering, why the inconsistency? why not just Reflect on
> every attribute?

It's not necessarily an inconsistency. The definition of reflection is
given in HTML5 [1]. We try to follow the standards on what should and
should not be reflected but it is in flux so there may be differences.
Now from WebKit perspective, using [reflect] for an IDL property means
that the binding script will auto-generate the logic to return the
associated attribute value. When this is undesirable (for example you
have some processing to do), [reflect] may not be the best solution.

In the example you give, width and height values depends on different
factors (see the implementation of width [2]). Also we need to resolve
any pending stylesheet to make sure the values are up-to-date when
queried. In those conditions, the simple reflected logic just does not

Hope it helps,

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes
[2] http://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLImageElement.cpp#L249

More information about the webkit-help mailing list