зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
ce13bac37f
Коммит
5adbb6a8c9
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче