Skip to content

Implement live CSSGroupingRule mutation for nested media rules #330

Description

@wieslawsoltes

Parent: #239
CSS epic: #235

Proven gap

WebScene's current owner-backed stylesheet adapter supports a stable top-level cssRules list, insertRule, deleteRule, declaration mutation, media enablement, detach/reattach, and bounded staged publication. A top-level @media rule is parsed and applied, but it is exposed as a generic rule object without the CSSGroupingRule surface: cssRules, insertRule, and deleteRule are absent, nested child identity/parent links cannot be inspected, and nested mutation is impossible.

A Chromium control for @media (min-width: 1px) { .x { display:block } } proves:

  • the grouping rule is a CSSMediaRule with type 4 and normalized conditionText;
  • mediaRule.cssRules has stable CSSRuleList identity;
  • children expose parentRule === mediaRule and parentStyleSheet === sheet;
  • mediaRule.insertRule('.x { display:grid }', length) updates computed style synchronously;
  • deleting the inserted child restores style and clears that removed child's parent links;
  • out-of-range nested insert throws IndexSizeError, and missing delete index throws TypeError.

Focused scope

  • Represent nested @media children as live rule objects with stable list/rule identity and browser-shaped parent links.
  • Implement nested insertRule/deleteRule validation and synchronous observable recascade through the existing bounded owner publication path.
  • Preserve top-level behavior, owner DOM text topology, media activation, detach/reattach, navigation teardown, and the 32 MiB/256-owner staging bounds.
  • Keep @import, @namespace, constructed/adopted sheets, replace/replaceSync, other grouping-rule types, cascade/global-keyword work, and selector metadata outside this slice.

Ownership and non-overlap

Planned implementation and gates are limited to:

  • experiments/WebScene.NativeEngine.Probe/native/webscene_stylesheet_cssom_compatibility.h;
  • experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_browser_dom_tests.inc;
  • a new tests/WebPlatformSubset/contracts/cssom-grouping-rule-mutation.html;
  • a new dedicated CSSOM grouping profile/evidence file.

Do not touch #292/#245 structural DOM/listener paths, #322 generated line-height paths, #329 stream/service-worker paths, open PR #326 selector metadata, or draft #76.

Acceptance

  • Chromium/native contract matches constructor/type/condition serialization, stable rule-list identity, parent links, exceptions, synchronous computed style, and removed-child detachment.
  • Main and iframe documents preserve rule identity/order across nested insert/delete, stylesheet disable/media changes, owner detach/reattach, and navigation/teardown.
  • Nested mutation targets only the owning cascade root; unrelated nodes/rules do not receive stale or cross-document style.
  • A product-shaped nested lookup/update workload reports 20-cycle p95/max within the focused budget and bounded publication/queue counts.
  • A 100-cycle create/mutate/detach/navigation lifecycle retains <= 8 MiB V8 heap and <= 64 MiB RSS after warm-up, with no retained owners/rules/pending replacements.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions