Open emilio opened 3 years ago
It looks like replacing "CSS-connected" with "CSS-created".
I'm not sure about the compatibility risk. Maybe we should add a use counter first?
Other than that, I like the proposal, and I'm fine with either Gecko or Blink's behavior regarding .add()
.
What happens with non-CSS-connected FontFace objects which are added to multiple FontFaceSets? A FontFace has a [[Url]] slot, but if it's added to document.fonts of two different documents with different base urls?
add() says it shouldn't be added twice to the same set, but I couldn't see anything in the spec blocking it from being added to multiple sets.
I see now that there is an issue (Issue 3) in the spec about specifying how base urls work, but it doesn't mention multiple sets/documents. This probably warrants a separate issue.
Yes, that looks like a separate issue. It also crossed my mind because this has been the reason for a lot of discussion for other similar things like Constructable Stylesheets and such.
The CSS Working Group just discussed [css-font-loading] Browsers disagree on what it means for a FontFace object to be "CSS-connected", and what effect does it have.
, and agreed to the following:
RESOLVED: Change css-connected by css created bool where it cannot be unset until removed from a document
RESOLVED: Have it throw an error
RESOLVED: have document.fonts.add when called with css create fontface object throw an error
I filed https://bugs.chromium.org/p/chromium/issues/detail?id=1159471 to track the issue mentioned in the minutes where Chrome silently ignores attempts to add a CSS-connected FontFace to other documents' FontFaceSets.
Consider a test-case like this:
Behavior across browsers differs:
add
is called with a CSS-connected rule, even if it's connected to a different document.frameDoc
isAhem
,Ahem2
.frameDoc
, and ends up withAhem2
,Ahem
.So this is clearly broken. Stuff gets more weird if you do something like
document.querySelector("style").remove()
and such.I'd like to do a proposal, and then, separately, discuss what should happen with
.add()
etc.The proposal I'd like to add is not to make CSS-connectedness dependent on the current state of the stylesheets of any given document. Basically, making it a per-instance "this came from a CSS rule" flag. This proposal would basically change whether
css
in the example above would be CSS-connected after doingdocument.querySelector("style").remove()
. This proposal would match WebKit from my understanding of the code.The reasoning for that is that it's clearly error-prone, and causes synchronous stylesheet updates. Blink gets it wrong because it doesn't look at the right document. Gecko gets the above test-case right per spec, but has other bugs in the area, like incorrectly throwing in this test-case (for the same reason fundamentally, it updates the stylesheets of the wrong document):
Then there's the discussion of what should happen when you call
.add()
with a CSS-connected rule. I think we have multiple options:Thoughts on both proposals, noting that the first is independent of the second?
cc @litherum @tabatkins @lilles @xiaochengh