diff --git a/README.md b/README.md
index 77e045f701d..7074692f500 100644
--- a/README.md
+++ b/README.md
@@ -312,6 +312,13 @@ Source lookup and hit-test candidates are derived from the frozen tree when
queried. The system has no incrementally maintained layout tree, damage graph,
retained display list, GPU compositor, or persistent window.
+Inline SVG object geometry is collected before clipping and paint-tree
+simplification, then frozen with its CSS viewport in that same layout pass.
+Computed paint styles are supplied separately from the original SVG XML, so
+they cannot change author selector matching or inflate the encoded-input
+budget. Geometry queries read the published numeric results without reparsing
+the SVG or mixing live child geometry with an older outer layout.
+
## Benchmark
The following measurements show Moli's current capability envelope. They cover
diff --git a/moli-cdp-smoke/moli_cdp_smoke/groups/svg_rect.py b/moli-cdp-smoke/moli_cdp_smoke/groups/svg_rect.py
index 4e25275179c..7d56585706f 100644
--- a/moli-cdp-smoke/moli_cdp_smoke/groups/svg_rect.py
+++ b/moli-cdp-smoke/moli_cdp_smoke/groups/svg_rect.py
@@ -1,9 +1,80 @@
from __future__ import annotations
+import base64
from typing import Any
-from ..assertions import assert_equal, record_contract
-from ..config import REPO_ROOT
+from ..assertions import SmokeError, assert_equal, record_contract
+from ..config import REPO_ROOT, is_moli_browser
+from ..diagnostics import new_cdp_session
+from ..png_image import decode_png
+
+
+async def _check_inline_svg(page: Any, results: list[dict[str, Any]]) -> None:
+ session = await new_cdp_session(page.context, page)
+
+ async def capture() -> Any:
+ response = await session.send("Page.captureScreenshot", {"format": "png"})
+ return decode_png(base64.b64decode(response["data"]))
+
+ cases = [
+ ("original_style_selector", '', [0, 0, 20, 20]),
+ ("original_id_selector", '', [0, 0, 20, 20]),
+ ("empty_clip_geometry", '', [10, 20, 30, 40]),
+ ("nested_visible_geometry", '', [12, 23, 30, 40]),
+ ]
+ try:
+ for name, content, expected in cases:
+ await page.evaluate("""content => {
+ document.head.innerHTML='';
+ document.body.innerHTML='';
+ }""", content)
+ image = await capture()
+ observed = await page.evaluate("""() => {
+ const e=document.querySelector('body>svg>svg,rect'), r=e.getBoundingClientRect();
+ return {rect:[r.x,r.y,r.width,r.height], count:e.getClientRects().length};
+ }""")
+ assert_equal(observed, {"rect": expected, "count": 1}, name)
+ if name.startswith("original_"):
+ assert_equal(image.pixel(10, 10), (255, 0, 0, 255), name + " paint")
+ assert_equal(image.pixel(50, 10), (255, 255, 255, 255), name + " unmatched transform")
+ record_contract(results, "svg/" + name, observed=observed,
+ contract="Final computed styles and source geometry preserve original SVG XML identity.",
+ source="Chromium 145.0.7632.116 executable comparison (2026-11-13)", commands=["Runtime.evaluate", "Page.captureScreenshot"])
+
+ await page.evaluate("""() => {
+ document.body.innerHTML='';
+ }""")
+ image = await capture()
+ if any(channel > 2 for channel in image.pixel(0, 0)[:3]):
+ raise SmokeError("690 KB SVG disappeared after applying computed styles")
+ record_contract(results, "svg/original_source_budget", observed={"circles": 30000},
+ contract="Derived styles do not inflate the bounded encoded SVG input.",
+ source="Chromium 145.0.7632.116 executable comparison (2026-11-13)", commands=["Page.captureScreenshot"])
+
+ await page.evaluate("""() => {
+ document.body.innerHTML='';
+ }""")
+ await capture()
+ count = await page.evaluate("""() => {
+ const r=document.createRange();r.selectNodeContents(document.querySelector('svg'));
+ return r.getClientRects().length;
+ }""")
+ assert_equal(count, 1000, "SVG Range geometry batch")
+ observed = await page.evaluate("""() => {
+ document.querySelector('svg').style.left='300px';
+ document.querySelector('rect').setAttribute('x','30');
+ return [document.querySelector('svg'),document.querySelector('rect')].map(e=>e.getBoundingClientRect().x);
+ }""")
+ assert_equal(observed, [100, 110] if is_moli_browser() else [300, 330], "coherent SVG geometry publication")
+ await capture()
+ updated = await page.evaluate("document.querySelector('rect').getBoundingClientRect().x")
+ assert_equal(updated, 330, "SVG geometry after publication")
+ record_contract(results, "svg/coherent_batch_publication", observed={"count": count, "immediate": observed, "published": updated},
+ contract="SVG object and viewport coordinates come from one publication; Moli freezes ordinary queries, Chromium flushes live layout.",
+ source="Chromium executable comparison and Moli frozen-layout contract", commands=["Runtime.evaluate", "Page.captureScreenshot"])
+ finally:
+ await session.detach()
async def run_svg_rect_group(
@@ -24,5 +95,6 @@ async def run_svg_rect_group(
commands=["Runtime.evaluate"],
observed=observed,
)
+ await _check_inline_svg(page, results)
finally:
await context.close()
diff --git a/moli-dom/src/native/html_serialization/engine.rs b/moli-dom/src/native/html_serialization/engine.rs
index 93dadc7e3bd..d4a93d0d878 100644
--- a/moli-dom/src/native/html_serialization/engine.rs
+++ b/moli-dom/src/native/html_serialization/engine.rs
@@ -54,7 +54,6 @@ struct HtmlSerializationOptions<'a> {
// whose owner Document has different scripting state from the outer tree.
scripting_enabled_for_node: &'a dyn Fn(NativeNodeId) -> bool,
shadow_root_provider: Option<&'a dyn HtmlShadowRootProvider>,
- attribute_overrides: Option<&'a dyn Fn(NativeNodeId) -> Vec<(String, String)>>,
}
impl<'a> HtmlSerializationOptions<'a> {
@@ -66,7 +65,6 @@ impl<'a> HtmlSerializationOptions<'a> {
target,
scripting_enabled_for_node,
shadow_root_provider: None,
- attribute_overrides: None,
}
}
@@ -267,9 +265,6 @@ fn serialize_html_node_frame<'a, S>(
out.push('>');
}
NodeData::Element(element) => {
- let overrides = options
- .attribute_overrides
- .map(|attributes| attributes(node_id));
out.push('<');
out.push_str(element.local_name());
if let Some(is_name) = element.custom_element_is_name()
@@ -283,31 +278,12 @@ fn serialize_html_node_frame<'a, S>(
if out.limit_exceeded() {
return;
}
- if overrides.as_ref().is_some_and(|attributes| {
- attributes
- .iter()
- .any(|(name, _)| attribute.name_matches(name))
- }) {
- continue;
- }
out.push(' ');
attribute.push_html_serialized_name(|part| out.push_str(part));
out.push_str("=\"");
escape_html_attribute(attribute.value(), out);
out.push('"');
}
- if let Some(overrides) = overrides {
- for (name, value) in overrides {
- if out.limit_exceeded() {
- return;
- }
- out.push(' ');
- out.push_str(&name);
- out.push_str("=\"");
- escape_html_attribute(&value, out);
- out.push('"');
- }
- }
out.push('>');
if !is_void_html_element(element.namespace(), element.local_name()) {
@@ -506,24 +482,18 @@ pub(super) fn serialize_html_with_limit(
dom: &NativeDom,
node_id: NativeNodeId,
max_bytes: usize,
-) -> Result