Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/validation/css-anchor-cssom-903-20260922.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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;
}
Expand Down
91 changes: 91 additions & 0 deletions tests/WebPlatformSubset/contracts/css-anchor-overlay-cssom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!doctype html>
<meta charset="utf-8">
<title>CSSOM-created named anchor overlay geometry</title>
<style>
html, body { margin: 0; padding: 0; }
#workbench { position: relative; width: 800px; height: 600px; }
</style>
<div id="workbench"></div>
<output id="result">PENDING</output>
<script>
const state = globalThis.__webSceneWptState = {
complete: false, harness: null, results: [], errors: [], diagnostics: []
};
const workbench = document.getElementById('workbench');
const box = node => {
const rect = node.getBoundingClientRect();
return [rect.x, rect.y, rect.width, rect.height].map(Math.round);
};
const record = (name, actual, expected) => {
const pass = actual.join(',') === expected.join(',');
state.results.push({ name, status: pass ? 'PASS' : 'FAIL',
message: pass ? null : `${name}: expected ${expected}, got ${actual}`, stack: null });
state.diagnostics.push(JSON.stringify({ name, actual, expected }));
};

// VS Code creates the anchor and overlay after the workbench is running.
// The dimensions and insets below use CSSStyleDeclaration named setters;
// setProperty() only assigns the anchor identifiers.
const anchor = document.createElement('div');
anchor.style.cssText = 'position:absolute;left:140px;top:90px;width:220px;height:160px';
anchor.style.setProperty('anchor-name', '--cssom-editor');
workbench.appendChild(anchor);
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.setProperty('position-anchor', '--cssom-editor');
overlay.style.top = 'anchor(top)';
overlay.style.left = 'anchor(left)';
overlay.style.width = 'anchor-size(width)';
overlay.style.height = 'anchor-size(height)';
workbench.appendChild(overlay);
record('named CSSOM setters position a newly attached overlay',
box(overlay), [140, 90, 220, 160]);
record('named CSSOM setters retain authored functions', [
overlay.style.top, overlay.style.left, overlay.style.width, overlay.style.height
], ['anchor(top)', 'anchor(left)', 'anchor-size(width)', 'anchor-size(height)']);

anchor.style.left = '180px';
anchor.style.width = '260px';
record('named CSSOM overlay follows anchor move and resize',
box(overlay), [180, 90, 260, 160]);
overlay.style.top = '12px';
record('replacing an anchor inset clears its used function',
box(overlay), [180, 12, 260, 160]);
overlay.style.top = 'anchor(top)';
overlay.style.width = '80px';
record('replacing anchor-size clears its used function',
box(overlay), [180, 90, 80, 160]);
overlay.style.width = 'anchor-size(width)';
record('restoring named CSSOM functions restores anchor geometry',
box(overlay), [180, 90, 260, 160]);

const opposite = document.createElement('div');
opposite.style.position = 'fixed';
opposite.style.setProperty('position-anchor', '--cssom-editor');
opposite.style.right = 'anchor(right)';
opposite.style.bottom = 'anchor(bottom)';
opposite.style.width = 'anchor-size(width)';
opposite.style.height = 'anchor-size(height)';
workbench.appendChild(opposite);
record('named right and bottom setters resolve the same box',
box(opposite), [180, 90, 260, 160]);

const started = performance.now();
let last = [];
for (let index = 0; index < 64; ++index) {
anchor.style.left = `${180 + index}px`;
last = box(overlay);
if (last[0] !== 180 + index) break;
}
const milliseconds = performance.now() - started;
record('named CSSOM overlay follows 64 panel moves', last, [243, 90, 260, 160]);
state.diagnostics.push(JSON.stringify({ name: '64 CSSOM move cycles', milliseconds }));
record('64 named CSSOM moves stay within 500 ms', [milliseconds <= 500], [true]);
state.harness = {
status: state.results.every(result => result.status === 'PASS') ? 0 : 1,
message: state.results.find(result => result.status === 'FAIL')?.message || null,
stack: null
};
state.complete = true;
document.getElementById('result').textContent = JSON.stringify(state.diagnostics);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading