W3C home > Mailing lists > Public > www-style@w3.org > May 2016

[cssom-view] getBoundingClientRect() when the first rectangle is empty

From: Koji Ishii <kojiishi@gmail.com>
Date: Thu, 5 May 2016 22:06:35 +0900
Message-ID: <CAN9ydbUOzz4BJieAa-4ofcxFv25xtZ+qbairxwVh7wVsF=VS1w@mail.gmail.com>
To: "www-style@w3.org" <www-style@w3.org>
I'd like to propose a change to getBoundingClientRect algorithm[1] from:

3. Otherwise, return a static DOMRect object describing the smallest
rectangle that includes the first rectangle in list and all of the
remaining rectangles of which the height or width is not zero.

to:

3. If all rectangles in the list have zero in its width or height, return
the first rectangle in the list.
4. Otherwise, return a static DOMRect object describing the smallest
rectangle that includes all of the rectangles of which the height or width
is not zero.

Background
----------

Blink recently changed getBoundingClientRect() implementation to follow the
spec. We received feedback saying that it produces undesirable result when
the first rectangle is empty and the second is not.

I talked to roc and he confirmed that Gecko actually does what proposed
above.

As far as I tested, Trident unions all rectangles including width or height
is zero. WebKit excludes empty rects, but returns (0,0,0,0) when all
rectangles are empty.

Changing the spec this way produces reasonable results when only the first
rectangle is empty, and makes Gecko and Blink (with a coming fix) conform
to the spec.

[1] https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect

/koji
Received on Thursday, 5 May 2016 13:07:22 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 5 May 2016 13:07:23 UTC