diff --git a/docs/validation/css-anchor-cssom-903-20260922.md b/docs/validation/css-anchor-cssom-903-20260922.md new file mode 100644 index 00000000..d9ec5e29 --- /dev/null +++ b/docs/validation/css-anchor-cssom-903-20260922.md @@ -0,0 +1,45 @@ +# CSSOM-created anchor overlay regression — 22 September 2026 + +## Product reproduction + +The exact installed-SDK/CLI Code OSS Release using WebScene `406bc88a` and +AppScene `36d7a82e` still opens a blank Markdown Preview. The unchanged +workbench creates its overlay at runtime. Its two named targets have nonzero +rectangles: editor part `[348, 61, 792, 857]` and preview editor +`[744, 96, 396, 822]`; the clipping root, overlay content, and iframe remain +0×0. A diagnostic fixed-position probe whose `top`, `left`, `width`, and +`height` are assigned through JavaScript named style setters also measures +0×0 for either target. A direct pixel-sized probe measures +`[17, 19, 53, 37]`, while a stylesheet-defined named-anchor control measures +`[27, 29, 43, 47]`. Thus the problem is the CSSOM-created anchor-function +path, not target geometry, generic positioned layout, or absence of the +anchor implementation in the package. The native screenshot confirms the +blank preview pane. + +## Cause and fix + +The V8 `CSSStyleDeclaration` named-property setter updates numeric inset and +size fields but did not retain `anchor()` / `anchor-size()` tokens. When a +detached element is appended, CSS recascade also cleared cold effect tokens; +ordinary inline dimensions are intentionally not replayed, so their anchor +functions disappeared even if the setter had retained them. Retain tokens in +the six named setters, then restore only authored inline anchor functions +after recascade clears cold values. The restoration path is guarded by an +existing anchor token, avoiding six authored-style lookups for ordinary nodes. +No VS Code source change or browser shell is involved. + +## Focused gates + +| Gate | Result | +| --- | --- | +| Chrome headless dynamic CSSOM contract | 9/9 assertions pass | +| Native V8 Release before this fix | 2/9 assertions pass; dynamic overlay 0×0 | +| Native V8 Release with this fix | 9/9 assertions pass | +| Existing named-anchor geometry contract | 9/9 assertions pass | +| Dynamic panel-move budget | 64 moves remain below 500 ms in the native and Chrome contracts | + +The contract is +`tests/WebPlatformSubset/contracts/css-anchor-overlay-cssom.html` and is +included in `webscene-css-anchor-overlay-profile.json`. Product acceptance +still requires an exact rebuilt SDK/CLI package with painted Markdown, +visual comparison, iframe lifecycle, and idle-CPU gates before #903 closes. diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_cascade_reset.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_cascade_reset.h index e2b347ad..3c935bf5 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_cascade_reset.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_cascade_reset.h @@ -1,4 +1,5 @@ #pragma once +#include "webscene_css_anchor_values.h" #include "webscene_css_property_mask.h" #include "webscene_css_variables.h" #include "webscene_css_visibility_values.h" @@ -201,6 +202,7 @@ inline void reset_cascaded_style(dom_node& node, if ((node.style.inline_property_mask & inline_opacity) == 0U) node.style.opacity = 1; if ((node.style.inline_property_mask & inline_color) == 0U) node.style.foreground_rgba = 0; if ((node.style.inline_property_mask & inline_font_size) == 0U) node.style.font_size = -1; + bool restore_inline_anchor_functions = false; if (auto* textual = node.style.mutable_textual_if_present(); textual != nullptr) { if ((node.style.inline_property_mask & inline_font_family) == 0U) { @@ -217,6 +219,14 @@ inline void reset_cascaded_style(dom_node& node, textual->svg_stroke_width.clear(); textual->list_style_position.clear(); textual->list_style_type.clear(); + for (const auto& [property, value] : textual->effect_values) { + if ((value.starts_with("anchor(") || value.starts_with("anchor-size(")) + && (property == "left" || property == "top" || property == "right" + || property == "bottom" || property == "width" || property == "height")) { + restore_inline_anchor_functions = true; + break; + } + } textual->effect_values.clear(); if ((node.style.inline_property_mask & inline_text_align) == 0U) { textual->text_align.clear(); @@ -235,6 +245,19 @@ inline void reset_cascaded_style(dom_node& node, textual->overscroll_y = overscroll_behavior::automatic; textual->touch_action_value = touch_action::automatic; } + // The hot numeric inset/size fields survive a recascade when they came + // from inline CSSOM. Their sparse anchor() tokens must survive with + // them: ordinary inline dimensions are deliberately not replayed by + // apply_matched_declarations(). This is the path used by a detached + // overlay styled before it is appended to the document. + if (restore_inline_anchor_functions) { + for (const auto* property : {"left", "top", "right", "bottom", "width", "height"}) { + const auto authored = node.authored_style().declarations.find(property); + if (authored != node.authored_style().declarations.end()) { + retain_anchor_function(node.style, property, authored->second); + } + } + } if ((node.style.inline_property_mask & inline_font_weight) == 0U) node.style.font_weight = 0; node.style.isolation_stacking_context = false; node.style.will_change_stacking_context = false; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc index 38e0aea8..08d5310d 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc @@ -2633,9 +2633,11 @@ } else if (apply_border_declaration(node->style, name, value)) { node->style.inline_property_mask |= inline_border; } else if (name == "width") { + css::retain_anchor_function(node->style, "width", value); node->style.width = native_document::parse_length(value); node->style.inline_property_mask |= inline_width; } else if (name == "height") { + css::retain_anchor_function(node->style, "height", value); node->style.height = native_document::parse_length(value); node->style.inline_property_mask |= inline_height; } else if (name == "minWidth") { @@ -2651,15 +2653,19 @@ node->style.max_height = value == "none" ? css_length{} : native_document::parse_length(value); node->style.inline_property_mask |= inline_max_height; } else if (name == "left") { + css::retain_anchor_function(node->style, "left", value); node->style.left = parse_inset_length(value); node->style.inline_property_mask |= inline_left; } else if (name == "top") { + css::retain_anchor_function(node->style, "top", value); node->style.top = parse_inset_length(value); node->style.inline_property_mask |= inline_top; } else if (name == "right") { + css::retain_anchor_function(node->style, "right", value); node->style.right = parse_inset_length(value); node->style.inline_property_mask |= inline_right; } else if (name == "bottom") { + css::retain_anchor_function(node->style, "bottom", value); node->style.bottom = parse_inset_length(value); node->style.inline_property_mask |= inline_bottom; } diff --git a/tests/WebPlatformSubset/contracts/css-anchor-overlay-cssom.html b/tests/WebPlatformSubset/contracts/css-anchor-overlay-cssom.html new file mode 100644 index 00000000..315585d2 --- /dev/null +++ b/tests/WebPlatformSubset/contracts/css-anchor-overlay-cssom.html @@ -0,0 +1,91 @@ + + +CSSOM-created named anchor overlay geometry + +
+PENDING + diff --git a/tests/WebPlatformSubset/webscene-css-anchor-overlay-profile.json b/tests/WebPlatformSubset/webscene-css-anchor-overlay-profile.json index b096c948..4784138d 100644 --- a/tests/WebPlatformSubset/webscene-css-anchor-overlay-profile.json +++ b/tests/WebPlatformSubset/webscene-css-anchor-overlay-profile.json @@ -11,6 +11,13 @@ "evidence": ["code-oss-markdown-preview-overlay-20260921", "chrome-browser-reference"], "reason": "Named-anchor and fixed-overlay geometry used by unchanged Code OSS webviews." }, + { + "path": "contracts/css-anchor-overlay-cssom.html", + "type": "contract", + "capabilities": ["css-anchor-positioning", "dynamic-anchor-layout", "cssom-style-named-setters"], + "evidence": ["code-oss-markdown-preview-overlay-20260922", "chrome-browser-reference"], + "reason": "A runtime-created overlay must retain anchor functions assigned through CSSStyleDeclaration named setters." + }, { "path": "contracts/css-anchor-overlay-paint.html", "type": "reftest",