Lightpanda: the headless browser designed for AI and automation
extend root container check to Document.extent
Karl Seguina672e70b6376
diff --git a/src/browser/tests/window_scroll.html b/src/browser/tests/window_scroll.htmlindex 7bc1e7496..ccba4508b 100644--- a/src/browser/tests/window_scroll.html+++ b/src/browser/tests/window_scroll.html@@ -155,3 +155,13 @@testing.expectEqual(300, nested_root.scrollHeight);nested_root.remove();</script>++<script id=nested_root_tags_extend_the_document>+ // A nested <body> is an ordinary wrapper, so a spacer inside it extends+ // the document like one inside a <div>.+ const spacer_root = document.body.appendChild(document.createElement('body'));+ const root_spacer = spacer_root.appendChild(document.createElement('div'));+ root_spacer.style.height = '20000px';+ testing.expectTrue(document.documentElement.scrollHeight >= 20000);+ spacer_root.remove();+</script>diff --git a/src/browser/webapi/Document.zig b/src/browser/webapi/Document.zigindex bdc09cca3..43caaacc3 100644--- a/src/browser/webapi/Document.zig+++ b/src/browser/webapi/Document.zig@@ -532,7 +532,7 @@ pub fn extent(self: *Document) Extent {while (tw.next()) |node| : (index += 1) {const el = node.is(Element) orelse continue;const parent = el.parentElement() orelse continue;- if (parent.getTag() == .html or parent.getTag() == .body) {+ if (parent.isRootContainer()) {continue;}if (style_manager.inlineSize(el, .height)) |height| {diff --git a/src/browser/webapi/Element.zig b/src/browser/webapi/Element.zigindex ce57a3179..2329435fb 100644--- a/src/browser/webapi/Element.zig+++ b/src/browser/webapi/Element.zig@@ -1535,7 +1535,7 @@ pub fn getElementAxis(self: *Element, frame: *Frame, comptime axis: Axis) Axis.S// The document's <html>, or a <body> under it. These span the document and// scroll the viewport. A script can insert these tags anywhere, and a nested// one gets treated as a normal element.-fn isRootContainer(self: *const Element) bool {+pub fn isRootContainer(self: *const Element) bool {const parent = self.asConstNode().parentNode() orelse return false;return switch (self.getTag()) {.html => parent._type == .document,