[css-values] Add sibling-count() and sibling-index()
Categories
(Core :: CSS Parsing and Computation, enhancement)
Tracking
()
| Size Estimate | M |
People
(Reporter: mozilla-apprentice, Unassigned)
References
(Depends on 1 open bug, Blocks 14 open bugs, )
Details
(4 keywords, Whiteboard: [webcompat:risk-moderate])
User Story
web-feature: sibling-count
A resolution was made for csswg-drafts/#4559.
[css-values] Proposal: add sibling-count() and sibling-index()
- RESOLVED: Add sibling-count() and sibling-index() to css-values-5 ED
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Updated•10 months ago
|
Comment 1•7 months ago
|
||
(Moving WPT failures to "blocks" rather than "depends on")
Comment 2•4 months ago
|
||
Hey, I had some very early local changes for sibling-index() / sibling-count() a couple months back that I've finally had some time to close out (almost), so I'm expecting to post patches for review in the next few days. Most of the tree-counting WPTs and all of the demos that I've found online are working and I think I've got generally the right solution. But here's a quick summary before I'm ready to publish in case it's useful context (or to let me know I'm way off-base):
-
Storing the calculation tree. I've converted the specified versions of multiple numeric types into enums with
NoCalcandCalcvariants, similar to what's already in place for Length. TheCalcvariants have the full calculation tree so thatsibling-index()andsibling-count()can be applied at computed-value time.- I did think about whether it might have required fewer changes to implement them like
var()/env()/ substitutions, but I think the semantics wouldn't have been right. You wouldn't have been able to reject invalid declarations at parse time, likecalc(1em + sibling-index()), for example. - One nice thing is that this prerequisite actually ends up fixing a lot of WPT failures where Firefox's handling of
calcwas too narrow, in particular tests that usesignand font/viewport/container units. - Downside is that all of these variants are no longer
Copyand have to be cloned in some places. And since the types are slightly larger, there are a few property types that need to be boxed. Hopefully not catastrophic.
- I did think about whether it might have required fewer changes to implement them like
-
Parsing/computing a new
TreeCountingFunctiontype. This is separate from the types that supportcalcsince these functions are distinct from math functions in the spec. The practical difference is thatsibling-index()/sibling-count()can be used directly for<integer>and<number>properties without being part of acalcnode, and they don't serialize tocalc(...)like the other math functions. -
Computing and counting the element's siblings. This is where I'm less sure about whether I've gotten the specifics right. I've added an
ElementSiblingData(just index and count integers) to the computed Context, but I'm computing and building this in theContext::newevery time, which is definitely wrong and way too often. I could compute it the first time it's accessed (and recompute when siblings change), but I'm not sure where to store it, maybe on the element itself? I think I might also be able to do the rule cache keying and style sharing better/more granularly than I've got, too.
I'm working on getting the commits to a presentable state and going through WPT results, but hopefully should have some patches very soon!
Updated•4 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•2 months ago
|
Updated•19 days ago
|
Description
•