Skip to content

Implement live CSSMediaRule.media MediaList mutation #362

Closed

Description

@wieslawsoltes

Parent: #239
CSS epic: #235

Proven gap

After #330 and #359, WebScene exposes live owner-backed CSSMediaRule objects with conditionText, nested rule mutation, and bounded publication, but the standard media attribute is absent. Authors cannot obtain the rule's SameObject MediaList, update mediaText, append a medium, delete a medium, or use Web IDL PutForwards assignment.

CSSOM defines CSSMediaRule.media as [SameObject, PutForwards=mediaText]. The WPT CSSOM interface surface and a direct Chromium 153 control require stable MediaList identity, indexed/item reflection, normalized list serialization, mutation through mediaText / appendMedium / deleteMedium, synchronized conditionText and cssText, and immediate style changes.

Focused scope

  • Expose a realm-correct MediaList for owner-backed top-level and nested CSSMediaRule objects.
  • Preserve SameObject identity and implement indexed/item access, mediaText, appendMedium, deleteMedium, and PutForwards assignment through the rule's existing condition state.
  • Re-serialize enclosing media groups and publish through the existing bounded stylesheet staging path only while attached.
  • Preserve rule/list identity, owner DOM text topology, nested mutation, detach behavior, main/iframe realm isolation, and the 32 MiB/1,024-owner staging bounds.
  • Keep constructed/adopted sheets, replace/replaceSync, imports/namespaces, other grouping-rule types, and media-query parser expansion outside this slice. Constructed adoption currently lacks a native owner primitive: native stylesheet wrappers and staged publication are keyed to connected style/link nodes.

Ownership and non-overlap

Planned paths:

  • experiments/WebScene.NativeEngine.Probe/native/webscene_stylesheet_cssom_compatibility.h;
  • experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_browser_dom_tests.inc;
  • new tests/WebPlatformSubset/contracts/cssom-media-list-mutation.html;
  • new dedicated WebPlatformSubset profile.

These paths have zero overlap with active #312 PR #354, #248 File System Access work, or draft docs PR #76.

Acceptance

  • Chromium/native contract matches interface branding, SameObject and PutForwards behavior, normalized indexed/item reflection, append/delete/error behavior, synchronized condition/cssText, and synchronous computed style.
  • Top-level and nested media rules preserve rule/list identity and mutate only their owning cascade while attached; detached mutation cannot recascade the former document.
  • Main and iframe realms remain isolated through owner removal/navigation.
  • A 64-rule, 20-cycle mutation workload stays within the focused timing budget with bounded invalidation/publication counters.
  • A 100-cycle create/mutate/detach/navigation gate retains <= 8 MiB V8 heap and <= 64 MiB RSS after warm-up and drains native CSS rules/pending replacements.

Activity

  1. added
    vscode-oss/planned
    on Sep 18, 2026
  2. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Merged through PR #365 as c4c4ac915918d44919d573539e89e7ace551aa5c from exact head 6caac6643b05026084618804593be5a83d2db52b, based on b6dfb66051e417fecb328da6639d7dfce7f251ee after #354 and #363.

    WebScene now exposes stable realm-local MediaList objects for owner-backed top-level and nested CSSMediaRule.media, including PutForwards assignment, normalized indexed/item/string reflection, append/deduplicate/delete behavior, synchronized conditionText/cssText, immediate recascade while attached, containing-group serialization, and detached mutation isolation.

    Final evidence:

    • Chromium 153 and exact-head native: 6/6 contract assertions in main and iframe realms. The pre-change native build failed at undefined CSSMediaRule.media.
    • Exact-head portable suite: 8/8; focused native stylesheet CSSOM filter: pass.
    • 64-rule, 20-cycle MediaList mutation: p95/max 0.209/0.342 ms.
    • 100 main/iframe lifecycle cycles: heap 34,342,396 -> 34,342,396 B; RSS 105,693,184 -> 121,929,728 B; native CSS rules returned to baseline; layout delta 82; scene delta 1; pending scenes <=2.
    • Exact-head GitHub runners: Linux, macOS, portable V8, and native document contracts all passed. Superseded/release tails are canceled or complete.

    Constructed/adopted sheets remain in #239 because correct multi-root adoption still requires an owner-independent native stylesheet primitive.

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/planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions