[RFE] implement CSS 3 indirect adjacent combinator

VERIFIED FIXED

Status

()

Core
CSS Parsing and Computation
--
enhancement
VERIFIED FIXED
15 years ago
7 years ago

People

(Reporter: glazou, Assigned: glazou)

Tracking

({css3})

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(5 attachments)

(Assignee)

Description

15 years ago
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.
(Assignee)

Comment 1

15 years ago
Created attachment 77447 [details]
test case (not dynamic)
(Assignee)

Comment 2

15 years ago
Created attachment 77448 [details]
test case (dynamic)
(Assignee)

Comment 3

15 years ago
Created attachment 77449 [details] [diff] [review]
patch 1.0, partial fix, not handling dynamic case
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...

Updated

14 years ago
Blocks: 65133
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.)
Created attachment 139000 [details] [diff] [review]
patch that doesn't break 80th column

(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.
Created attachment 139001 [details] [diff] [review]
patch with comments
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
Last Resolved: 14 years ago
Resolution: --- → FIXED

Comment 13

14 years ago
-> 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.