Re: [CSSOM] offsetWidth, offsetLeft issues

On Fri, Oct 16, 2009 at 8:03 PM, Robert O'Callahan <robert@ocallahan.org> wrote:
> On Sat, Oct 17, 2009 at 1:10 PM, Ojan Vafai <ojan@chromium.org> wrote:
>>
>> On Wed, Oct 14, 2009 at 1:17 PM, Robert O'Callahan <robert@ocallahan.org>
>> wrote:
>>>
>>> On Thu, Oct 15, 2009 at 8:50 AM, Erik Arvidsson <arv@chromium.org> wrote:
>>>>
>>>> The width and height of getBoundingClientRect is always the same as
>>>>
>>>> offsetWidth and offsetHeight.
>>>
>>> I don't really care about this one. offsetWidth and offsetHeight are
>>> really bad legacy features.
>>
>> No argument there. But we should at least make them as sane as possible,
>> no? In the case of tables with captions, it makes more sense to include the
>> caption. Given that IE already does this, it seems likely to maximize
>> compatibility, or at least not make it worse.
>
> It seems to me that right now the CSSOM spec is a little vague on this
> matter. On the offset* properties it talks about "the border-edge of element
> A", when it really needs to specify a particular CSS box (or union of CSS
> boxes).
>
> I don't really mind if the spec changes so that offsetWidth and offsetHeight
> match the size of getBoundingClientRect. That would make them include the
> table caption. However, I can't promise that we'll change Gecko to match. It
> seems almost any change to our offset* implementation produces regressions
> in Web content, perhaps because there is browser-sniffing code that makes
> assumptions about what we currently do. I'd rather just give up on offset*
> and forget about them and concentrate on making
> getClientRects/getBoundingClientRect useful and interoperable across
> browsers.
>

In contrast to offsetLeft and offsetTop, ffsetWidth and offsetHeight
more consistently reliable. They are useful because they return
dimensions that include border. The properties are widely supported,
widely used and programs will continue to use them and continue to
expect that they behave as they do today.

As with any major change, I recommend a google code search for
research. This is a very easy step to take.

http://www.google.com/codesearch?q=offsetWidth+lang%3Ajavascript&hl=en&btnG=Search+Code

A browser changing these properties return *content* width would
probably break millions of web pages and applications.

In CSS2, A CAPTION has its own content, padding, margin, and border areas.

The CAPTION's margin collapses with its TABLE's margin, and its border
that is adjacent to its TABLE collapses with its table border.

IE treats css differently with CAPTION.

Garrett

Received on Saturday, 17 October 2009 05:42:33 UTC