Repository navigation
Description
Focus, attribute, and tree changes can change the styles of elements beyond the mutated element and its ancestors. Those dependent elements need their cached styles invalidated and their rendered output rebuilt.
This follows the review of #128 and affects stylesheet support in #138 and subtree replay from #143.
Problem
RenderApi.request() currently marks notified nodes and their ancestors as changed. Layout can reuse cached styles and replay the output of other subtrees. Notifying the previous and next focused elements addresses their own focus styles and styles applied directly to their :focus-within ancestors, but leaves other selector dependencies unmarked. For example:
button:focus + .hint { color: green; }
.panel:focus-within .status { color: green; }
section:has(:focus) > .label { color: green; }
[data-state="open"] .content { color: green; }
.selected ~ .item { color: green; }Focus changes in the first three examples can change a different sibling or descendant's style. Attribute/class changes and insertion, removal, or movement can similarly change which elements match. A new frame alone is insufficient if those elements still reuse cached styles or replay stale output.
Expected behavior
- Invalidate every element whose resolved style depends on changed focus state, attributes/classes, or tree relationships, including affected siblings and descendants.
- Recompute affected styles before deciding whether their rendered subtrees can be replayed. Clear the old styles when focus or attributes are removed as well as applying new styles.
- Preserve frame coalescing and reuse unaffected output. The invalidation strategy can be conservative initially; it must not leave stale styles or terminal output.
Upstream coverage to enable as support becomes available
These sources exist at the pinned WPT revision b719612f963a05ece9c89a7dd7598c1c59618874:
focus-within-009.html: computed ancestor/target styles across focus changes, removal, and reinsertion.focus-visible-023.html: computed outline styles during focus and blur.display-contents-state-change-001.html: a visual reftest for:focus-withinstyling another descendant.user-action-pseudo-classes-in-has.html: computed styles for ancestors and other descendants affected by:has(:focus),:focus-visible, and:focus-within. Its pointer/keyboard sequence is one test and cannot be split into selected assertions.sibling.htmlandattribute.html: sibling/descendant invalidation after class and attribute mutations.focus-pseudo-class-002.xht: manual visual coverage ofinput:focus + span.
The runner needs stylesheet/computed-style support and, depending on the file, CSSOM, input automation, or rendered-reference comparison. Keep upstream tests unchanged. Also verify the actual terminal rendering path: on-demand getComputedStyle() recalculation alone could pass while frame scheduling or subtree replay remains stale.
Activity