From 4fdc506df549b6dd24ad672e4adeb45fa53f637a Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 29 Apr 2025 11:39:51 +0200 Subject: [PATCH 01/12] wip --- resources/developer-mode.mjs | 30 ++++++++++++++++++++++++++++-- resources/shared/params.mjs | 24 +++++++++++++++--------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index 18a23043b..90e1f86bb 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -1,5 +1,5 @@ import { Suites, Tags } from "./tests.mjs"; -import { params, defaultParams } from "./shared/params.mjs"; +import { params, defaultParams, LAYOUT_MODE,} from "./shared/params.mjs"; export function createDeveloperModeContainer() { const container = document.createElement("div"); @@ -22,6 +22,7 @@ export function createDeveloperModeContainer() { settings.append(createUIForWarmupBeforeSync()); settings.append(createUIForSyncStepDelay()); settings.append(createUIForAsyncSteps()); + settings.append(createUIForLayoutMode()); content.append(document.createElement("hr")); content.append(settings); @@ -107,6 +108,31 @@ function createTimeRangeUI(labelText, paramKey, unit = "ms", min = 0, max = 1000 return label; } +function createUIForLayoutMode() { + return createSelectUI("Force layout mode", params.layoutMode, LAYOUT_MODE, (value) => { + params.layoutMode = value; + }); +} + +function createSelectUI(labelValue, initialValue, choices, paramsUpdateCallback) { + const select = document.createElement("select"); + select.onchange = () => { + paramsUpdateCallback(select.value); + updateURL(); + }; + + choices.forEach(choice => { + const option = new Option(choice, choice); + select.add(option); + }); + select.value = initialValue; + + const label = document.createElement("label"); + label.append(span(labelValue), select); + + return label; +} + function createUIForSuites() { const control = document.createElement("nav"); control.className = "suites"; @@ -273,7 +299,7 @@ function updateURL() { else if (params.suites.length) url.searchParams.set("suites", params.suites.join(",")); - const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps"]; + const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps", "layoutMode"]; for (const paramKey of defaultParamKeys) { if (params[paramKey] !== defaultParams[paramKey]) url.searchParams.set(paramKey, params[paramKey]); diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 701222d97..4369f9cb2 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -1,3 +1,6 @@ + +export const LAYOUT_MODE = Object.freeze(["getBoundingClientRect", "elementFromPoint"]); + export class Params { viewport = { width: 800, @@ -27,6 +30,8 @@ export class Params { // "generate": generate a random seed // : use the provided integer as a seed shuffleSeed = "off"; + // Choices: "" + layoutMode = "getBoundingClientRect"; constructor(searchParams = undefined) { if (searchParams) @@ -55,8 +60,9 @@ export class Params { this.useAsyncSteps = this._parseBooleanParam(searchParams, "useAsyncSteps"); this.waitBeforeSync = this._parseIntParam(searchParams, "waitBeforeSync", 0); this.warmupBeforeSync = this._parseIntParam(searchParams, "warmupBeforeSync", 0); - this.measurementMethod = this._parseMeasurementMethod(searchParams); + this.measurementMethod = this._parseChoiceParam(searchParams, "measurementMethod", ["raf"]); this.shuffleSeed = this._parseShuffleSeed(searchParams); + this.layoutMode = this._parseChoiceParam(searchParams, "layoutMode", LAYOUT_MODE); const unused = Array.from(searchParams.keys()); if (unused.length > 0) @@ -121,14 +127,14 @@ export class Params { return tags; } - _parseMeasurementMethod(searchParams) { - if (!searchParams.has("measurementMethod")) - return defaultParams.measurementMethod; - const measurementMethod = searchParams.get("measurementMethod"); - if (measurementMethod !== "raf") - throw new Error(`Invalid measurement method: '${measurementMethod}', must be 'raf'.`); - searchParams.delete("measurementMethod"); - return measurementMethod; + _parseChoiceParam(searchParams, paramKey, choices) { + if (!searchParams.has(paramKey)) + return defaultParams[paramKey]; + const value = searchParams.get(paramKey); + if (!choices.includes(value)) + throw new Error(`Got invalid ${paramKey}: '${value}', choices are ${choices}`); + searchParams.delete(paramKey); + return value; } _parseShuffleSeed(searchParams) { From f098f261e4dd3f7b26aaae7a9fc56a908f9cc5a1 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 30 Apr 2025 09:03:22 +0200 Subject: [PATCH 02/12] cleanup --- resources/benchmark-runner.mjs | 10 ++++++++-- resources/shared/helpers.mjs | 1 + resources/shared/test-runner.mjs | 7 +++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/resources/benchmark-runner.mjs b/resources/benchmark-runner.mjs index 3fd6ec0a9..c8add0dfc 100644 --- a/resources/benchmark-runner.mjs +++ b/resources/benchmark-runner.mjs @@ -23,6 +23,7 @@ function getParent(lookupStartNode, path) { class Page { constructor(frame) { this._frame = frame; + this._leakedLayout = {}; } getLocalStorage() { @@ -30,8 +31,13 @@ class Page { } layout() { - const body = this._frame.contentDocument.body.getBoundingClientRect(); - this.layout.e = document.elementFromPoint((body.width / 2) | 0, (body.height / 2) | 0); + const body = this._frame ? this._frame.contentDocument.body : document.body; + const bodyRect = body.getBoundingClientRect(); + if (params.layoutMode === "getBoundingClientRect") + this._leakedLayout.sum = bodyRect.width; + if (params.layoutMode === "elementFromPoint") + this._leakedLayout.element = document.elementFromPoint((bodyRect.width / 2) | 0, (bodyRect.height / 2) | 0); + return bodyRect; } async waitForElement(selector) { diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index 729d5f3a4..5dd19f6db 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -24,6 +24,7 @@ export function getAllElements(selector, path = [], lookupStartNode = document) } export function forceLayout() { + // FIXME: sync implementation with Page.prototype.layout(). const rect = document.body.getBoundingClientRect(); const e = document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); return e; diff --git a/resources/shared/test-runner.mjs b/resources/shared/test-runner.mjs index 52defcb36..d0cbff6ab 100644 --- a/resources/shared/test-runner.mjs +++ b/resources/shared/test-runner.mjs @@ -67,12 +67,11 @@ export class TestRunner { asyncStartTime = syncEndTime; }; const measureAsync = () => { - const bodyReference = this.#frame ? this.#frame.contentDocument.body : document.body; - const windowReference = this.#frame ? this.#frame.contentWindow : window; // Some browsers don't immediately update the layout for paint. // Force the layout here to ensure we're measuring the layout time. - const height = bodyReference.getBoundingClientRect().height; - windowReference._unusedHeightValue = height; // Prevent dead code elimination. + const windowReference = this.#frame ? this.#frame.contentWindow : window; + const bodyRect = this.page.layout(); + windowReference._unusedHeightValue = bodyRect.height; // Prevent dead code elimination. const asyncEndTime = performance.now(); performance.mark(asyncEndLabel); From 9c4376237b609b93a76ce970bb4a09db8212afef Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 30 Apr 2025 09:23:10 +0200 Subject: [PATCH 03/12] formatting --- resources/developer-mode.mjs | 4 ++-- resources/shared/params.mjs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index 90e1f86bb..4f8d89708 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -1,5 +1,5 @@ import { Suites, Tags } from "./tests.mjs"; -import { params, defaultParams, LAYOUT_MODE,} from "./shared/params.mjs"; +import { params, defaultParams, LAYOUT_MODE } from "./shared/params.mjs"; export function createDeveloperModeContainer() { const container = document.createElement("div"); @@ -121,7 +121,7 @@ function createSelectUI(labelValue, initialValue, choices, paramsUpdateCallback) updateURL(); }; - choices.forEach(choice => { + choices.forEach((choice) => { const option = new Option(choice, choice); select.add(option); }); diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 4369f9cb2..15eb1b678 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -1,4 +1,3 @@ - export const LAYOUT_MODE = Object.freeze(["getBoundingClientRect", "elementFromPoint"]); export class Params { From 77d1b93e210000ef46f10682fab7bc9b6352d6a6 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 7 May 2025 12:11:47 +0200 Subject: [PATCH 04/12] merging Page and shared/helpers.mjs layout code --- resources/benchmark-runner.mjs | 10 +++------- resources/developer-mode.mjs | 4 ++-- resources/shared/helpers.mjs | 12 +++++++----- resources/shared/params.mjs | 14 +++++++------- resources/shared/test-runner.mjs | 4 +--- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/resources/benchmark-runner.mjs b/resources/benchmark-runner.mjs index c8add0dfc..ce08b4942 100644 --- a/resources/benchmark-runner.mjs +++ b/resources/benchmark-runner.mjs @@ -1,5 +1,6 @@ import { Metric } from "./metric.mjs"; import { params } from "./shared/params.mjs"; +import { forceLayout } from "./shared/helpers.mjs"; import { SUITE_RUNNER_LOOKUP } from "./suite-runner.mjs"; const performance = globalThis.performance; @@ -23,7 +24,6 @@ function getParent(lookupStartNode, path) { class Page { constructor(frame) { this._frame = frame; - this._leakedLayout = {}; } getLocalStorage() { @@ -32,12 +32,8 @@ class Page { layout() { const body = this._frame ? this._frame.contentDocument.body : document.body; - const bodyRect = body.getBoundingClientRect(); - if (params.layoutMode === "getBoundingClientRect") - this._leakedLayout.sum = bodyRect.width; - if (params.layoutMode === "elementFromPoint") - this._leakedLayout.element = document.elementFromPoint((bodyRect.width / 2) | 0, (bodyRect.height / 2) | 0); - return bodyRect; + const value = forceLayout(body, params.layoutMode); + body._leakedLayoutValue = value; // Prevent dead code elimination. } async waitForElement(selector) { diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index 4f8d89708..9129c803e 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -1,5 +1,5 @@ import { Suites, Tags } from "./tests.mjs"; -import { params, defaultParams, LAYOUT_MODE } from "./shared/params.mjs"; +import { params, defaultParams, LAYOUT_MODES } from "./shared/params.mjs"; export function createDeveloperModeContainer() { const container = document.createElement("div"); @@ -109,7 +109,7 @@ function createTimeRangeUI(labelText, paramKey, unit = "ms", min = 0, max = 1000 } function createUIForLayoutMode() { - return createSelectUI("Force layout mode", params.layoutMode, LAYOUT_MODE, (value) => { + return createSelectUI("Force layout mode", params.layoutMode, LAYOUT_MODES, (value) => { params.layoutMode = value; }); } diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index 5dd19f6db..7649f07eb 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -23,9 +23,11 @@ export function getAllElements(selector, path = [], lookupStartNode = document) return elements; } -export function forceLayout() { - // FIXME: sync implementation with Page.prototype.layout(). - const rect = document.body.getBoundingClientRect(); - const e = document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); - return e; +export function forceLayout(body, layoutMode = "elementFromPoint") { + if (body !== undefined) + body = document.body; + const rect = body.getBoundingClientRect(); + if (layoutMode === "elementFromPoint") + return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); + return rect.height; } diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 15eb1b678..a58e365e3 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -1,4 +1,4 @@ -export const LAYOUT_MODE = Object.freeze(["getBoundingClientRect", "elementFromPoint"]); +export const LAYOUT_MODES = Object.freeze(["getBoundingClientRect", "elementFromPoint"]); export class Params { viewport = { @@ -29,7 +29,7 @@ export class Params { // "generate": generate a random seed // : use the provided integer as a seed shuffleSeed = "off"; - // Choices: "" + // Choices: getBoundingClientRect or elementFromPoint layoutMode = "getBoundingClientRect"; constructor(searchParams = undefined) { @@ -59,9 +59,9 @@ export class Params { this.useAsyncSteps = this._parseBooleanParam(searchParams, "useAsyncSteps"); this.waitBeforeSync = this._parseIntParam(searchParams, "waitBeforeSync", 0); this.warmupBeforeSync = this._parseIntParam(searchParams, "warmupBeforeSync", 0); - this.measurementMethod = this._parseChoiceParam(searchParams, "measurementMethod", ["raf"]); + this.measurementMethod = this._parseEnumParam(searchParams, "measurementMethod", ["raf"]); this.shuffleSeed = this._parseShuffleSeed(searchParams); - this.layoutMode = this._parseChoiceParam(searchParams, "layoutMode", LAYOUT_MODE); + this.layoutMode = this._parseEnumParam(searchParams, "layoutMode", LAYOUT_MODES); const unused = Array.from(searchParams.keys()); if (unused.length > 0) @@ -126,12 +126,12 @@ export class Params { return tags; } - _parseChoiceParam(searchParams, paramKey, choices) { + _parseEnumParam(searchParams, paramKey, enumArray) { if (!searchParams.has(paramKey)) return defaultParams[paramKey]; const value = searchParams.get(paramKey); - if (!choices.includes(value)) - throw new Error(`Got invalid ${paramKey}: '${value}', choices are ${choices}`); + if (!enumArray.includes(value)) + throw new Error(`Got invalid ${paramKey}: '${value}', choices are ${enumArray}`); searchParams.delete(paramKey); return value; } diff --git a/resources/shared/test-runner.mjs b/resources/shared/test-runner.mjs index d0cbff6ab..6c606d5f2 100644 --- a/resources/shared/test-runner.mjs +++ b/resources/shared/test-runner.mjs @@ -69,9 +69,7 @@ export class TestRunner { const measureAsync = () => { // Some browsers don't immediately update the layout for paint. // Force the layout here to ensure we're measuring the layout time. - const windowReference = this.#frame ? this.#frame.contentWindow : window; - const bodyRect = this.page.layout(); - windowReference._unusedHeightValue = bodyRect.height; // Prevent dead code elimination. + this.page.layout(); const asyncEndTime = performance.now(); performance.mark(asyncEndLabel); From c15b2d875677de01e38d36cb9f21591e569c11bf Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 7 May 2025 12:14:20 +0200 Subject: [PATCH 05/12] merge main --- resources/developer-mode.mjs | 40 ------------------------------------ 1 file changed, 40 deletions(-) diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index d970a75ea..c6315ca7d 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -289,47 +289,7 @@ function updateURL() { updateParamsSuitesAndTags(); const url = new URL(window.location.href); -<<<<<<< HEAD - - url.searchParams.delete("tags"); - url.searchParams.delete("suites"); - url.searchParams.delete("suite"); - - if (params.tags.length) - url.searchParams.set("tags", params.tags.join(",")); - else if (params.suites.length) - url.searchParams.set("suites", params.suites.join(",")); - - const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps", "layoutMode"]; - for (const paramKey of defaultParamKeys) { - if (params[paramKey] !== defaultParams[paramKey]) - url.searchParams.set(paramKey, params[paramKey]); - else - url.searchParams.delete(paramKey); - } - -||||||| dd661c03 - - url.searchParams.delete("tags"); - url.searchParams.delete("suites"); - url.searchParams.delete("suite"); - - if (params.tags.length) - url.searchParams.set("tags", params.tags.join(",")); - else if (params.suites.length) - url.searchParams.set("suites", params.suites.join(",")); - - const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps"]; - for (const paramKey of defaultParamKeys) { - if (params[paramKey] !== defaultParams[paramKey]) - url.searchParams.set(paramKey, params[paramKey]); - else - url.searchParams.delete(paramKey); - } - -======= url.search = params.toSearchParams(); ->>>>>>> main // Only push state if changed if (url.href !== window.location.href) window.history.pushState({}, "", url); From 9d14b2ee41b1ccc383a04e128f10ddf5c046620f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 7 May 2025 12:15:06 +0200 Subject: [PATCH 06/12] cleanup --- resources/developer-mode.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index c6315ca7d..5e3b1c883 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -1,5 +1,5 @@ import { Suites, Tags } from "./tests.mjs"; -import { params, defaultParams, LAYOUT_MODES } from "./shared/params.mjs"; +import { params, LAYOUT_MODES } from "./shared/params.mjs"; export function createDeveloperModeContainer() { const container = document.createElement("div"); From 8baee34c5ef0ed7f3eb3077fe854c3fce2857f7d Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Wed, 21 May 2025 14:05:11 +0200 Subject: [PATCH 07/12] fix --- resources/shared/helpers.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index 7649f07eb..a1bf5bcf1 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -24,8 +24,7 @@ export function getAllElements(selector, path = [], lookupStartNode = document) } export function forceLayout(body, layoutMode = "elementFromPoint") { - if (body !== undefined) - body = document.body; + body ??= document.body; const rect = body.getBoundingClientRect(); if (layoutMode === "elementFromPoint") return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); From 8f89e37003e785cdab46a68db58b688e00c67160 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 27 May 2025 17:53:34 +0200 Subject: [PATCH 08/12] address comments --- resources/shared/params.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 4af4f796a..32fc70d85 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -1,4 +1,4 @@ -export const LAYOUT_MODES = Object.freeze(["getBoundingClientRect", "elementFromPoint"]); +export const LAYOUT_MODES = Object.freeze(["getBoundingClientRect", "getBoundingRectAndElementFromPoint"]); export class Params { viewport = { @@ -29,8 +29,8 @@ export class Params { // "generate": generate a random seed // : use the provided integer as a seed shuffleSeed = "off"; - // Choices: getBoundingClientRect or elementFromPoint - layoutMode = "getBoundingClientRect"; + // Choices: "getBoundingClientRect" or "getBoundingRectAndElementFromPoint" + layoutMode = LAYOUT_MODES[0]; // Measure more workload prepare time. measurePrepare = false; From f0d12c7a0b991e1509ea18edca1d9d71852cd2e4 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 27 May 2025 17:54:22 +0200 Subject: [PATCH 09/12] update consts --- resources/shared/helpers.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index a1bf5bcf1..e6d56c29c 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -23,10 +23,10 @@ export function getAllElements(selector, path = [], lookupStartNode = document) return elements; } -export function forceLayout(body, layoutMode = "elementFromPoint") { +export function forceLayout(body, layoutMode = "getBoundingRectAndElementFromPoint") { body ??= document.body; const rect = body.getBoundingClientRect(); - if (layoutMode === "elementFromPoint") + if (layoutMode === "getBoundingRectAndElementFromPoint") return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); return rect.height; } From 5f6394b461f15dfa1b169aa1e48fc371a55beaa6 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 16 Jun 2025 16:59:23 +0200 Subject: [PATCH 10/12] add check --- resources/shared/helpers.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index e6d56c29c..3075866ba 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -28,5 +28,7 @@ export function forceLayout(body, layoutMode = "getBoundingRectAndElementFromPoi const rect = body.getBoundingClientRect(); if (layoutMode === "getBoundingRectAndElementFromPoint") return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); + else if (layoutMode !== "getBoundingClientRect") + throw Error(`Invalid layoutMode: ${layoutMode}`); return rect.height; } From a94f92b28318dadc5a681f7aa43967c211da397b Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 19 Jun 2025 13:35:43 +0200 Subject: [PATCH 11/12] use switch --- resources/shared/helpers.mjs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index 3075866ba..7b6a2e61b 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -1,3 +1,5 @@ +import { isClassElement } from "typescript"; + /** * Helper Methods * @@ -26,9 +28,12 @@ export function getAllElements(selector, path = [], lookupStartNode = document) export function forceLayout(body, layoutMode = "getBoundingRectAndElementFromPoint") { body ??= document.body; const rect = body.getBoundingClientRect(); - if (layoutMode === "getBoundingRectAndElementFromPoint") - return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); - else if (layoutMode !== "getBoundingClientRect") - throw Error(`Invalid layoutMode: ${layoutMode}`); - return rect.height; + switch (layoutMode) { + case "getBoundingRectAndElementFromPoint": + return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); + case "getBoundingClientRect": + return rect.height; + default: + throw Error(`Invalid layoutMode: ${layoutMode}`); + } } From 44bacd3c8895c4d18ce6d28132559ca49abe03e0 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 19 Jun 2025 13:37:19 +0200 Subject: [PATCH 12/12] address comments --- resources/shared/helpers.mjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/shared/helpers.mjs b/resources/shared/helpers.mjs index 7b6a2e61b..735430f34 100644 --- a/resources/shared/helpers.mjs +++ b/resources/shared/helpers.mjs @@ -1,5 +1,3 @@ -import { isClassElement } from "typescript"; - /** * Helper Methods * @@ -31,7 +29,7 @@ export function forceLayout(body, layoutMode = "getBoundingRectAndElementFromPoi switch (layoutMode) { case "getBoundingRectAndElementFromPoint": return document.elementFromPoint((rect.width / 2) | 0, (rect.height / 2) | 0); - case "getBoundingClientRect": + case "getBoundingClientRect": return rect.height; default: throw Error(`Invalid layoutMode: ${layoutMode}`);