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

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