From d75bed55e0288ab7be22e826f2de73e4896401fb Mon Sep 17 00:00:00 2001 From: Will Bamberg Date: Mon, 23 Jan 2023 18:26:54 -0800 Subject: [PATCH] Remove fx_minversion_note from Element.getClientRects --- .../web/api/element/getclientrects/index.md | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/files/en-us/web/api/element/getclientrects/index.md b/files/en-us/web/api/element/getclientrects/index.md index 550ba0695fbed11..9b58d61018e4b6b 100644 --- a/files/en-us/web/api/element/getclientrects/index.md +++ b/files/en-us/web/api/element/getclientrects/index.md @@ -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-``, the "viewport" that the resulting @@ -49,15 +47,6 @@ outer-`` establishes (and to be clear, the rectangles are also transformed by the outer-``'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 width and height - properties to the TextRectangle 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. @@ -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. @@ -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); }