Skip to content

[multiple] Serialization of rules #4828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tabatkins opened this issue Mar 4, 2020 · 8 comments
Open

[multiple] Serialization of rules #4828

tabatkins opened this issue Mar 4, 2020 · 8 comments
Labels

Comments

@tabatkins
Copy link
Member

I just merged a PR (w3c/css-houdini-drafts#980) specifying how to serialize an @property rule. I wasn't sure whether it should all be serialized on one line (as the PR specified, and now in the draft), or if they should be indented on a newline, so I went looking for precedents, and it doesn't appear we have any.

Afaict, no spec defines how to serialize rules at all: not CSSOM, nor any spec that defines its own at-rules, like Conditional or Animations.

I presume we want to specify this so we can be consistent, and can test rule serialization? How should it work? Where should such a definition live - individual specs, or in CSSOM, or general rules in CSSOM with explicit hooks that individual specs have to define for serialization of preludes and which descriptors to include?

@tabatkins
Copy link
Member Author

Agenda+ to bring the issue into general awareness; I don't expect us to decide these questions in the call.

@svgeesus
Copy link
Contributor

svgeesus commented Mar 4, 2020

Yeah it would be good to get some discussion on this, so for example fonts 4 can say how to serialize the at-rules it has (or I can give input on what goes in CSSOM. However, we recently decided to move color serialization from CSSOM to color 4, so...)

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [multiple] Serialization of rules, and agreed to the following:

  • RESOLVED: We define this is CSSOM to match browser compat as much as it exists.
The full IRC log of that discussion <dael> Topic: [multiple] Serialization of rules
<dael> github: https://github.com//issues/4828
<dael> TabAtkins: Merged a PR to spec how to serialize @Property. Decided to serialize in one line.
<dael> TabAtkins: Fine but wanted consistent. I looked arounda nd couldn't find one spec on how to serialize rules. But I think we tend to serialize multi line.
<dael> TabAtkins: I would like to define this, prob in CSSOM, with descriptors. Then we need to decide if it's on a single line or multi-line with indents
<dael> florian: I have vague memory of doing something like this in preso and trying to align to where a line is broken. I vaguely remember compat problems
<dael> emilio: style rules seem to be one line
<dael> Rossen_: Is prop to allow multi-line but not define how and where you should break?
<dael> TabAtkins: No, no. I would like precise spec. We have it for whitespace and we need that level
<dael> florian: I support doing this, write something sensible, and then if compat says we can't at least we know where
<dael> emilio: I think impl are somewhat consistent so I don't think would be hard. Happy to help
<dael> Rossen_: Don't see pushback on multi line
<dael> emilio: Biggest is that's not what browsers do
<dael> Rossen_: Compat risk?
<dael> TabAtkins: If there's compat we should follow that. emilio is right style is one line so we should consistently do that
<dael> florian: Seems sad too but okay
<dael> Rossen_: Prop: Specify serialization is one line?
<dael> TabAtkins: Prop: We define this is CSSOM to match browser compat as much as it exists.
<dael> TabAtkins: emilio or I can write it out
<dael> Rossen_: Objections?
<dael> RESOLVED: We define this is CSSOM to match browser compat as much as it exists.

@tabatkins
Copy link
Member Author

So it turns out browser's aren't consistent:

testcase:

<!DOCTYPE html>
<style>
@font-face {
 font-family: foo; src: url(foo);
 font-weight: bold;
}
</style>
<script>
w(document.styleSheets[0].cssRules[0].cssText);
</script>

Chrome puts all of it on one line. Firefox puts each descriptor on its own line.

@emilio You expressed during the call a preference for single-line, I think? Are you okay with specifying that and getting Firefox to fix?

@Loirooriol
Copy link
Contributor

But with @keyframes both browsers use multiple lines (Chromium with indentation, Firefox without)
testcase

@emilio
Copy link
Collaborator

emilio commented Mar 11, 2020

ew, what a mess. I think changing style rules is a no-go, so I'd be happy to do everything in one line if other browsers are happy with that too.

@tabatkins
Copy link
Member Author

Ah, yeah, both Chrome and Firefox do style rules on a single line, and I agree that's the most common case and most likely to be depended on, so we should go with that.

@emilio
Copy link
Collaborator

emilio commented Sep 3, 2020

https://drafts.csswg.org/cssom/#serialize-a-css-rule does have some text that matches Firefox and Chrome. Spec for some rules is missing and we should add it though.

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 5, 2020
…s and style rules.

Style rules serialize on one line and so should @font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1663231
gecko-commit: b021c9737f2bd71713c487ccb0410bd335edd5ba
gecko-reviewers: xidorn
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Sep 5, 2020
… other browsers and style rules. r=xidorn

Style rules serialize on one line and so should @font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 6, 2020
…s and style rules.

Style rules serialize on one line and so should @font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1663231
gecko-commit: b021c9737f2bd71713c487ccb0410bd335edd5ba
gecko-reviewers: xidorn
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Sep 16, 2020
…ther browsers and style rules. r=xidorn

Style rules serialize on one line and so should font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302

UltraBlame original commit: b021c9737f2bd71713c487ccb0410bd335edd5ba
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Sep 16, 2020
…ther browsers and style rules. r=xidorn

Style rules serialize on one line and so should font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302

UltraBlame original commit: b021c9737f2bd71713c487ccb0410bd335edd5ba
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Sep 16, 2020
…ther browsers and style rules. r=xidorn

Style rules serialize on one line and so should font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302

UltraBlame original commit: b021c9737f2bd71713c487ccb0410bd335edd5ba
ambroff pushed a commit to ambroff/gecko that referenced this issue Nov 4, 2020
… other browsers and style rules. r=xidorn

Style rules serialize on one line and so should @font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302
emilio added a commit to servo/servo that referenced this issue Feb 26, 2021
…browsers and style rules.

Style rules serialize on one line and so should @font-face blocks.

Part of w3c/csswg-drafts#4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants