[csswg-drafts] [css-font-loading] CSS-connectedness of @font-face rules in constructed stylesheets (#10378)

ADKaster has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-font-loading] CSS-connectedness of @font-face rules in constructed stylesheets ==
In https://drafts.csswg.org/css-font-loading/#font-face-css-connection , the section describing the relationship between `@font-face` rules and their associated FontFace IDL objects, it's unclear to me how this is supposed to interact with constructed stylesheets.

For example, the spec says that

> A CSS [@font-face](https://www.w3.org/TR/css-fonts-5/#at-font-face-rule) rule automatically defines a corresponding [FontFace](https://drafts.csswg.org/css-font-loading/#fontface) object, which is automatically placed in the document’s [font source](https://drafts.csswg.org/css-font-loading/#font-source) when the rule is parsed. This [FontFace](https://drafts.csswg.org/css-font-loading/#fontface) object is CSS-connected.

Does this mean that when javascript does something like this:

```js
let sheet = new CSSStyleSheet();
sheet.insertRule("@font-face {\
  font-family: InterVariable;\
  font-style: normal;\
  font-weight: 100 900;\
  font-display: swap;\
  src: url('https://rsms.me/inter/font-files/InterVariable.woff2?v=4.0') format('woff2');\
}", 0);
``` 

That the `FontFace` associated with the `CSSFontFaceRule` in the constructed style sheet should be added to `document.fonts` *at construction*?

This seems clearly wrong to me... I would expect the `FontFace` to only appear in `document.fonts` when `sheet` is added to `document.adoptedStyleSheets`. 

Additionally, it's unclear whether the FontFace is supposed to be created as `css-connected` when the `CSSFontFaceRule` is constructed, simply because the `CSSStyleSheet` has a constructor document, or whether it's only supposed to be created and visible when and if the sheet is added to someone's `FontFaceSet`. 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10378 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 29 May 2024 23:19:25 UTC