Skip to content

Commit 75fb940

Browse files
miketaylremilio
authored andcommitted
[cssom-view] Add a "get the bounding box" algorithm for getBoundingClientRect()
This way other specs like IntersectionObserver can call it.
1 parent abf2870 commit 75fb940

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cssom-view-1/Overview.bs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,16 +1057,22 @@ The <dfn method for=Element>getClientRects()</dfn> method, when invoked, must re
10571057

10581058
Note: The {{DOMRect}} objects returned by {{Element/getClientRects()}} are not <a spec=html>live</a>.
10591059

1060-
The <dfn method for=Element caniuse=getboundingclientrect>getBoundingClientRect()</dfn> method, when invoked, must return the result of the following
1061-
algorithm:
1060+
The <dfn method for=Element caniuse=getboundingclientrect>getBoundingClientRect()</dfn> method, when
1061+
invoked on an element <var>element</var>, must return the result of
1062+
<a>getting the bounding box</a> for <var>element</var>.
10621063

1063-
1. Let <var>list</var> be the result of invoking {{Element/getClientRects()}} on the same element this method was invoked on.
1064-
1. If the <var>list</var> is empty return a {{DOMRect}} object
1065-
whose {{DOMRect/x}}, {{DOMRect/y}}, {{DOMRect/width}} and {{DOMRect/height}} members are zero.
1066-
1. If all rectangles in <var>list</var> have zero width or height, return the first rectangle in
1067-
<var>list</var>.
1068-
1. Otherwise, return a {{DOMRect}} object describing the smallest rectangle that includes all
1069-
of the rectangles in <var>list</var> of which the height or width is not zero.
1064+
<div algorithm>
1065+
To <dfn export for=Element>get the bounding box</dfn> for <var>element</var>,
1066+
run the following steps:
1067+
1. Let <var>list</var> be the result of invoking {{Element/getClientRects()}} on
1068+
<var>element</var>.
1069+
1. If the <var>list</var> is empty return a {{DOMRect}} object whose {{DOMRect/x}},
1070+
{{DOMRect/y}}, {{DOMRect/width}} and {{DOMRect/height}} members are zero.
1071+
1. If all rectangles in <var>list</var> have zero width or height, return the first rectangle in
1072+
<var>list</var>.
1073+
1. Otherwise, return a {{DOMRect}} object describing the smallest rectangle that includes all
1074+
of the rectangles in <var>list</var> of which the height or width is not zero.
1075+
</div>
10701076

10711077
Note: The {{DOMRect}} object returned by {{Element/getBoundingClientRect()}} is not <a spec=html>live</a>.
10721078

0 commit comments

Comments
 (0)