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

Remove fx_minversion_note from Element.getClientRects #23855

Merged
merged 1 commit into from
Jan 24, 2023
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
29 changes: 10 additions & 19 deletions files/en-us/web/api/element/getclientrects/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ None.
### Return value

The returned value is a collection of {{DOMxRef("DOMRect")}} objects, one for each CSS
border box associated with the element. Each {{DOMxRef("DOMRect")}} object contains
read-only `left`, `top`, `right` and
`bottom` properties describing the border box, in pixels, with the top-left
border box associated with the element. Each {{DOMxRef("DOMRect")}} object describes the border box, in pixels, with the top-left
relative to the top-left of the viewport. For tables with captions, the caption is
included even though it's outside the border box of the table. When called on SVG
elements other than an outer-`<svg>`, the "viewport" that the resulting
Expand All @@ -49,15 +47,6 @@ outer-`<svg>` establishes (and to be clear, the rectangles are also
transformed by the outer-`<svg>`'s `viewBox` transform, if
any).

Originally, Microsoft intended this method to return a `TextRectangle`
object for each _line_ of text. However, the CSSOM working draft specifies that
it returns a {{DOMxRef("DOMRect")}} for each _border box_. For an inline element,
the two definitions are the same. But for a block element, Mozilla will return only a
single rectangle.

{{Fx_MinVersion_Note(3.5, "Firefox 3.5 adds <code>width</code> and <code>height</code>
properties to the <code>TextRectangle</code> object.")}}

The amount of scrolling that has been done of the viewport area (or any other
scrollable element) is taken into account when computing the rectangles.

Expand Down Expand Up @@ -245,12 +234,14 @@ function addClientRectsOverlay(elt) {
Note: the overlays will be out of place if the user resizes or zooms. */
const rects = elt.getClientRects();
for (const rect of rects) {
const tableRectDiv = document.createElement('div');
tableRectDiv.style.position = 'absolute';
tableRectDiv.style.border = '1px solid red';
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
tableRectDiv.style.margin = tableRectDiv.style.padding = '0';
const tableRectDiv = document.createElement("div");
tableRectDiv.style.position = "absolute";
tableRectDiv.style.border = "1px solid red";
const scrollTop =
document.documentElement.scrollTop || document.body.scrollTop;
const scrollLeft =
document.documentElement.scrollLeft || document.body.scrollLeft;
tableRectDiv.style.margin = tableRectDiv.style.padding = "0";
tableRectDiv.style.top = `${rect.top + scrollTop}px`;
tableRectDiv.style.left = `${rect.left + scrollLeft}px`;
// We want rect.width to be the border width, so content width is 2px less.
Expand All @@ -263,7 +254,7 @@ function addClientRectsOverlay(elt) {
(() => {
/* Call function addClientRectsOverlay(elt) for all elements with
assigned class "withClientRectsOverlay" */
const elts = document.getElementsByClassName('withClientRectsOverlay');
const elts = document.getElementsByClassName("withClientRectsOverlay");
for (const elt of elts) {
addClientRectsOverlay(elt);
}
Expand Down