Skip to content

CSS Factories exposed to Worker context - #1177

Open
javifernandez wants to merge 1 commit into
w3c:mainfrom
javifernandez:css-factory-worker-exposed
Open

CSS Factories exposed to Worker context#1177
javifernandez wants to merge 1 commit into
w3c:mainfrom
javifernandez:css-factory-worker-exposed

Conversation

@javifernandez

@javifernandez javifernandez commented Jul 30, 2026

Copy link
Copy Markdown

The CSS namespace is only exposed to Window context. The CSS factories are very convenient to implement tests of CSS TypedOM features that are exposed to Workes.

This PR makes the CSS namespace extension proposed by CSS TypedOM to be exposed to Worker contexts.

It's been discussed in the csswg issue 14229 in the context of allowing partial extensions of the CSS namespace to be exported to contexts different than Window.

The WPT PR 61330 modifies some of the current CSS TypedOM tests so that they are run in Workers, requiring these CSS Factories to be exported to Worker contexts as well.

@javifernandez
javifernandez requested a review from tabatkins July 30, 2026 11:36
Comment thread css-typed-om/Overview.bs

<xmp class=idl>
[Exposed=(Window, Worker)]
partial namespace CSS {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be [Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)], but also I think a partial with a wider exposure than the namespace itself is not legal in WebIDL so we should fix CSSOM and co too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have realized that this would require a cross-spec PR to change the exposure of the different namespace CSS partial definitions, so that we declared them Window only explicitly. In addition, you have risen the concern of future partial definitions not being ware of the Worker exposure by default.

I'm already working on such PR, as it seems there was some agreement in issue 14229, but perhaps this needs more discussion ? When we merged the PR 61330) for the tests I thought this spec change was easier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have submitted the PR 14245 to fix the CSSOM and co, as requested.

That PR for cssom-1 would make the explicit exposure of the css-typed-on-1 partial definition redundant; even more, if eventually the CSS namespace exposure in cssom-1 is shortened, the css-typed-om-1 declaration won't be compliant with the WebIDL subset-rule about partials.

…ets #14229

The factory functions were [Exposed=(Window, Worker)] while the types they
return (CSSUnitValue and friends) are already
[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)], so worklet code could
receive a CSSUnitValue from StylePropertyMapReadOnly but could not call
CSS.px() to construct one.

Match the factories to their return types, and pin the document-side partials
to the exposure they have today:

  * css-paint-api: paintWorklet pinned to [Exposed=Window]
  * css-layout-api: layoutWorklet pinned to [Exposed=Window]
  * css-properties-values-api: registerProperty() pinned to [Exposed=Window]

Depends on the companion csswg-drafts change widening the base CSS namespace;
without it this partial violates WebIDL's partial-exposure subset rule.
@javifernandez
javifernandez force-pushed the css-factory-worker-exposed branch from 5ff80a2 to 686a180 Compare July 31, 2026 15:47
@javifernandez
javifernandez requested a review from emilio July 31, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants