Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom-view] Add a "get the bounding box" algorithm for getBoundingClientRect() #5614 #7446

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions cssom-view-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,16 +1057,22 @@ The <dfn method for=Element>getClientRects()</dfn> method, when invoked, must re

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

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

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

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

Expand Down