- From: Matthieu Dubet via GitHub <sysbot+gh@w3.org>
- Date: Thu, 29 Feb 2024 18:19:44 +0000
- To: public-css-archive@w3.org
For implementation, both because as you said some things still only need declarations and because the whole codebase is kinda built/optimized around the concept of "1 rule = 1 selector + 1 array of declaration", we would need - in WebKit at least - to separate the rule into pieces at parse time (each block of declarations and each rule being a piece) and keep the original order of appearance in memory (because it's not exactly the implicit order of rules anymore).
It should just have a performance impact at parsing time to split the rule, during style resolving for order of appearance (minimal?), and during OM (not hot) ?
Depending on how important is backward compatibility (I would say paramount for `CSSStyleRule`?), the idea was to not touch `CSSStyleDeclaration` at all (keep it a map like iterable) because it's backward compatible and needed for other stuff such as style attributes anyway.
But adding a `CSSBlockContent` parent class for all nested group rules (the most important one being `CSSStyleRule`) (note that modifying the `CSSGroupingRule` interface might also works and be less invasive)
```cpp
enum BlockElement {
CSSStyleDeclaration, // slight preference to return block of declaration, but it could also be each property individually ?
CSSRule
}
class CSSBlockContent {
array<BlockElement> elements;
}
class CSSStyleRule : CSSBlockContent {
CSSStyleAttribute style() // return the current style attribute including all the properties inside the rule but ignoring the interleaving rules
}
```
For the padding example
```
foo {
padding-top: 0;
padding-left: 0;
& { padding-top: 10px; }
padding-bottom: 0;
padding-right: 0;
}
```
Calling `style()` would return `padding: 0px` (which is really what this rule is about), but calling `elements()` would return
```
[
CSSStyleDeclaration(padding-top: 0, padding-left: 0);
CSSStyleRule(...);
CSSStyleDeclaration(padding-bottom: 0px; padding-right: 0)
]
```
--
GitHub Notification of comment by mdubet
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8738#issuecomment-1971701952 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 29 February 2024 18:19:45 UTC