Implement CSS3 indirect adjacent sibling combinator (~). Roughly identical patches independently written by Daniel Glazman <daniel@glazman.org>, Bradley Baetz <bbaetz@acm.org>, and me. r+sr=dbaron b=135141

This commit is contained in:
dbaron%dbaron.org 2004-01-14 20:12:03 +00:00
parent 05f83fbe5d
commit 7c0fd2338b
6 changed files with 22 additions and 14 deletions

View File

@ -1619,7 +1619,9 @@ PRBool CSSParserImpl::ParseSelectorGroup(nsresult& aErrorCode,
}
if (eCSSToken_Symbol == mToken.mType &&
('+' == mToken.mSymbol || '>' == mToken.mSymbol)) {
('+' == mToken.mSymbol ||
'>' == mToken.mSymbol ||
'~' == mToken.mSymbol)) {
done = PR_FALSE;
combinator = mToken.mSymbol;
list->mSelectors->SetOperator(combinator);

View File

@ -3786,6 +3786,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
return result;
}
// Right now, there are four operators:
// PRUnichar(0), the descendent combinator, is greedy
// '~', the indirect adjacent sibling combinator, is greedy
// '+' and '>', the direct adjacent sibling and child combinators, are not
#define NS_IS_GREEDY_OPERATOR(ch) (ch == PRUnichar(0) || ch == PRUnichar('~'))
static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
nsCSSSelector* aSelector)
{
@ -3799,7 +3805,8 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
// for adjacent sibling combinators, the content to test against the
// selector is the previous sibling *element*
RuleProcessorData* data;
if (PRUnichar('+') == selector->mOperator) {
if (PRUnichar('+') == selector->mOperator ||
PRUnichar('~') == selector->mOperator) {
data = prevdata->mPreviousSiblingData;
if (!data) {
nsIContent* content = prevdata->mContent;

View File

@ -101,11 +101,6 @@ public:
nsAttrSelector* mNext;
};
// Right now, there are three operators:
// PRUnichar(0), the descendent combinator, is greedy
// '+' and '>', the adjacent sibling and child combinators, are not
#define NS_IS_GREEDY_OPERATOR(ch) ( ch == PRUnichar(0) )
struct nsCSSSelector {
public:
nsCSSSelector(void);

View File

@ -1619,7 +1619,9 @@ PRBool CSSParserImpl::ParseSelectorGroup(nsresult& aErrorCode,
}
if (eCSSToken_Symbol == mToken.mType &&
('+' == mToken.mSymbol || '>' == mToken.mSymbol)) {
('+' == mToken.mSymbol ||
'>' == mToken.mSymbol ||
'~' == mToken.mSymbol)) {
done = PR_FALSE;
combinator = mToken.mSymbol;
list->mSelectors->SetOperator(combinator);

View File

@ -3786,6 +3786,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
return result;
}
// Right now, there are four operators:
// PRUnichar(0), the descendent combinator, is greedy
// '~', the indirect adjacent sibling combinator, is greedy
// '+' and '>', the direct adjacent sibling and child combinators, are not
#define NS_IS_GREEDY_OPERATOR(ch) (ch == PRUnichar(0) || ch == PRUnichar('~'))
static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
nsCSSSelector* aSelector)
{
@ -3799,7 +3805,8 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
// for adjacent sibling combinators, the content to test against the
// selector is the previous sibling *element*
RuleProcessorData* data;
if (PRUnichar('+') == selector->mOperator) {
if (PRUnichar('+') == selector->mOperator ||
PRUnichar('~') == selector->mOperator) {
data = prevdata->mPreviousSiblingData;
if (!data) {
nsIContent* content = prevdata->mContent;

View File

@ -101,11 +101,6 @@ public:
nsAttrSelector* mNext;
};
// Right now, there are three operators:
// PRUnichar(0), the descendent combinator, is greedy
// '+' and '>', the adjacent sibling and child combinators, are not
#define NS_IS_GREEDY_OPERATOR(ch) ( ch == PRUnichar(0) )
struct nsCSSSelector {
public:
nsCSSSelector(void);