diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/screenshots/overlayHelpers.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/screenshots/overlayHelpers.mjs')
-rw-r--r-- | browser/components/screenshots/overlayHelpers.mjs | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/browser/components/screenshots/overlayHelpers.mjs b/browser/components/screenshots/overlayHelpers.mjs index 70a1bd86d0..e91200a8f5 100644 --- a/browser/components/screenshots/overlayHelpers.mjs +++ b/browser/components/screenshots/overlayHelpers.mjs @@ -402,6 +402,8 @@ export class WindowDimensions { #scrollY = null; #scrollMinX = null; #scrollMinY = null; + #scrollMaxX = null; + #scrollMaxY = null; #devicePixelRatio = null; set dimensions(dimensions) { @@ -429,6 +431,12 @@ export class WindowDimensions { if (dimensions.scrollMinY != null) { this.#scrollMinY = dimensions.scrollMinY; } + if (dimensions.scrollMaxX != null) { + this.#scrollMaxX = dimensions.scrollMaxX; + } + if (dimensions.scrollMaxY != null) { + this.#scrollMaxY = dimensions.scrollMaxY; + } if (dimensions.devicePixelRatio != null) { this.#devicePixelRatio = dimensions.devicePixelRatio; } @@ -436,15 +444,19 @@ export class WindowDimensions { get dimensions() { return { - clientHeight: this.#clientHeight, - clientWidth: this.#clientWidth, - scrollHeight: this.#scrollHeight, - scrollWidth: this.#scrollWidth, - scrollX: this.#scrollX, - scrollY: this.#scrollY, - scrollMinX: this.#scrollMinX, - scrollMinY: this.#scrollMinY, - devicePixelRatio: this.#devicePixelRatio, + clientHeight: this.clientHeight, + clientWidth: this.clientWidth, + scrollHeight: this.scrollHeight, + scrollWidth: this.scrollWidth, + scrollX: this.scrollX, + scrollY: this.scrollY, + pageScrollX: this.pageScrollX, + pageScrollY: this.pageScrollY, + scrollMinX: this.scrollMinX, + scrollMinY: this.scrollMinY, + scrollMaxX: this.scrollMaxX, + scrollMaxY: this.scrollMaxY, + devicePixelRatio: this.devicePixelRatio, }; } @@ -465,10 +477,18 @@ export class WindowDimensions { } get scrollX() { + return this.#scrollX - this.scrollMinX; + } + + get pageScrollX() { return this.#scrollX; } get scrollY() { + return this.#scrollY - this.scrollMinY; + } + + get pageScrollY() { return this.#scrollY; } @@ -480,10 +500,33 @@ export class WindowDimensions { return this.#scrollMinY; } + get scrollMaxX() { + return this.#scrollMaxX; + } + + get scrollMaxY() { + return this.#scrollMaxY; + } + get devicePixelRatio() { return this.#devicePixelRatio; } + isInViewport(rect) { + // eslint-disable-next-line no-shadow + let { left, top, right, bottom } = rect; + + if ( + left > this.scrollX + this.clientWidth || + right < this.scrollX || + top > this.scrollY + this.clientHeight || + bottom < this.scrollY + ) { + return false; + } + return true; + } + reset() { this.#clientHeight = 0; this.#clientWidth = 0; @@ -493,5 +536,7 @@ export class WindowDimensions { this.#scrollY = 0; this.#scrollMinX = 0; this.#scrollMinY = 0; + this.#scrollMaxX = 0; + this.#scrollMaxY = 0; } } |