Closed Bug 135141 Opened 23 years ago Closed 21 years ago

[RFE] implement CSS 3 indirect adjacent combinator

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: glazou, Assigned: glazou)

References

Details

(Keywords: css3)

Attachments

(5 files)

CSS 3 introduces a new combinator '~' for indirect adjacent sibling matching. For instance : foo ~ bar should match all bar elements following, not necessarily immediately, a foo element in the list of their parent's children. We should implement it.
Can you convince me that there aren't any cases where this causes greedy matching rather than nondeterministic matching? (I haven't thought it through yet. Perhaps it's not that hard to demonstrate.)
Keywords: css3
Heh. I just implemented this myself (before searching for the bug). My patch is the same as glazou's except for whitespace issues, and I moved the NS_IS_GREEDY_OPERATOR defintion into nsCSSStyleSheet.cpp, which is the only place which actually uses that macro. The dynamic case for '+' is bug 110972, and I imagine that the same fix would fix '~', too. dbaron: re comment #4, code later in the function (which you added for bug 24031) tests against NS_IS_GREEDY_OPERATOR, which is modified in this patch to match '~' as well. The comment currently refers to the descendent combinator, but it does use the macro to test (I've updated the comment in my tree). IOW, if we DTRT for descendent selectors, I think that the patch makes us DTRT for ~.
It's clear to me that the macro would no longer be appropriate if someone came up with a generic non-adjacent first cousin combinator. I think it will still work with the non-adjacent sibling combinator (indirect adjacent is a horrible name -- the point is that the need *not* be adjacent). I think it should still be correct in this case, but only because I can't think of a way to break it. Perhaps I'll try to write a more formal proof later and see if I can...
Blocks: selectors3
Comment on attachment 77449 [details] [diff] [review] patch 1.0, partial fix, not handling dynamic case r+sr=dbaron if you fix the 80th-column violations (i.e., remove the space inside the parentheses in the definition of NS_IS_GREEDY_OPERATOR and break lines in nsCSSStyleSheet.cpp.)
Attachment #77449 - Flags: superreview+
Attachment #77449 - Flags: review+
(Note that I just fixed the dynamic issues in my patch for bug 15608.)
(Since I wrote the patch myself, as bbaetz did, before finding this bug, I'll attach my version, which doesn't go past the 80th column.)
Although, actually, it's worth fixing the "there are three combinators" comment in nsICSSStyleRule.h.
Fix checked in to trunk, 2004-01-14 12:12 -0800. I also took bbaetz's suggestion in comment 5 of moving the macro to the .cpp file.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
-> VERIFIED Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7a) Gecko/20040116
Status: RESOLVED → VERIFIED
(In reply to comment #5) > IOW, if > we DTRT for descendent selectors, I think that the patch makes us DTRT for ~. (In reply to comment #6) > I think it should still > be correct in this case, but only because I can't think of a way to break it. We were wrong. See bug 420814.
Depends on: 420814
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: