From 9e05cf37d11c750e294f5d527ff50f946202e01b Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Tue, 4 Aug 2026 18:50:22 +0800 Subject: [PATCH] render: Fallback to contentWidth when clientWidth isn't explicit amivoice.com appends to a child until that child reports a specific clientWidth. To be correct, we'd need to know the render mode of the node (e.g. flexbox modes overflows, etc...). Without that, we have limited options. If the width is explicitly set, we use that (as before), but if it isn't, rather than defaulting we use the much more expensive contentWidth. Also applies to height. --- src/browser/tests/element/position.html | 40 +++++++++++++- src/browser/webapi/Element.zig | 69 +++++++++++++++++++------ 2 files changed, 92 insertions(+), 17 deletions(-) diff --git a/src/browser/tests/element/position.html b/src/browser/tests/element/position.html index 3022384c9..2657f326b 100644 --- a/src/browser/tests/element/position.html +++ b/src/browser/tests/element/position.html @@ -53,7 +53,8 @@ box.appendChild(document.createElement('span')); testing.expectTrue(box.scrollWidth > oneChild); - testing.expectTrue(box.scrollWidth > box.clientWidth); + // An unsized box shrink-wraps: clientWidth tracks the same content sum. + testing.expectEqual(box.scrollWidth, box.clientWidth); // Text contributes nothing, however long. Estimating a run from its length // would need a per-character advance that tracks font-size, and would report @@ -133,6 +134,40 @@ } + +