mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 13:24:12 +00:00
Fix for 67739. r=pierre,attinasi, sr=ben
This commit is contained in:
parent
6d784c14e8
commit
e050817098
@ -206,6 +206,10 @@ protected:
|
||||
PRBool ParseSingleValueProperty(PRInt32& aErrorCode, nsCSSValue& aValue,
|
||||
nsCSSProperty aPropID);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool ParseOutlinerPseudoElement(PRInt32& aErrorCode, nsCSSSelector& aSelector);
|
||||
#endif
|
||||
|
||||
// Property specific parsing routines
|
||||
PRBool ParseAzimuth(PRInt32& aErrorCode, nsCSSValue& aValue);
|
||||
PRBool ParseBackground(PRInt32& aErrorCode, nsICSSDeclaration* aDeclaration, PRInt32& aChangeHint);
|
||||
@ -1356,6 +1360,20 @@ static PRBool IsSinglePseudoClass(const nsCSSSelector& aSelector)
|
||||
(aSelector.mPseudoClassList->mNext == nsnull));
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
static PRBool IsOutlinerPseudoElement(const nsString& aPseudo)
|
||||
{
|
||||
return !(aPseudo.CompareWithConversion("-moz-outliner-", PR_FALSE, 14));
|
||||
}
|
||||
|
||||
static PRBool IsOutlinerPseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return !(str.CompareWithConversion(":-moz-outliner-", PR_FALSE, 15));
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
SelectorList*& aList)
|
||||
{
|
||||
@ -1401,6 +1419,14 @@ PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
else { // append new pseudo element selector
|
||||
selector.Reset();
|
||||
selector.mTag = pseudoClassList->mAtom; // steal ref count
|
||||
if (IsOutlinerPseudoElement(selector.mTag)) {
|
||||
// Take the remaining "pseudoclasses" that we parsed
|
||||
// inside the outliner pseudoelement's ()-list, and
|
||||
// make our new selector have these pseudoclasses
|
||||
// in its pseudoclass list.
|
||||
selector.mPseudoClassList = pseudoClassList->mNext;
|
||||
pseudoClassList->mNext = nsnull;
|
||||
}
|
||||
list->AddSelector(selector);
|
||||
pseudoClassList->mAtom = nsnull;
|
||||
listSel->mOperator = PRUnichar('>');
|
||||
@ -1674,9 +1700,16 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident != mToken.mType) { // malformed selector
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function != mToken.mType ||
|
||||
!IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
#endif
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
buffer.Truncate();
|
||||
@ -1696,6 +1729,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later
|
||||
NS_RELEASE(pseudo);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
// We have encountered a pseudoelement of the form
|
||||
// -moz-outliner-xxxx(a,b,c). We parse (a,b,c) and add each
|
||||
// item in the list to the pseudoclass list. They will be pulled
|
||||
// from the list later along with the pseudoelement.
|
||||
if (!ParseOutlinerPseudoElement(aErrorCode, aSelector))
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ensure selector ends here, must be followed by EOF, space, '{' or ','
|
||||
if (GetToken(aErrorCode, PR_FALSE)) { // premature eof is ok (here!)
|
||||
if ((eCSSToken_WhiteSpace == mToken.mType) ||
|
||||
@ -2060,6 +2105,31 @@ PRBool CSSParserImpl::ParseColorComponent(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool CSSParserImpl::ParseOutlinerPseudoElement(PRInt32& aErrorCode,
|
||||
nsCSSSelector& aSelector)
|
||||
{
|
||||
if (ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
|
||||
while (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
|
||||
if (!GetToken(aErrorCode, PR_TRUE)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else if (eCSSToken_Ident == mToken.mType) {
|
||||
nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_NewAtom(mToken.mIdent));
|
||||
aSelector.AddPseudoClass(pseudo);
|
||||
}
|
||||
else if (eCSSToken_Symbol == mToken.mType) {
|
||||
if (!mToken.IsSymbol(','))
|
||||
return PR_FALSE;
|
||||
}
|
||||
else return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PRBool
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsICSSPseudoComparator.h"
|
||||
#include "nsICSSStyleRuleProcessor.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsICSSNameSpaceRule.h"
|
||||
@ -403,6 +404,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -3299,13 +3301,16 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
struct PseudoEnumData : public SelectorMatchesData {
|
||||
PseudoEnumData(nsIPresContext* aPresContext, nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag, nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
: SelectorMatchesData(aPresContext, aParentContent, aParentContext, aResults)
|
||||
{
|
||||
mPseudoTag = aPseudoTag;
|
||||
mComparator = aComparator;
|
||||
}
|
||||
|
||||
nsIAtom* mPseudoTag;
|
||||
nsIAtom* mPseudoTag;
|
||||
nsICSSPseudoComparator* mComparator;
|
||||
};
|
||||
|
||||
static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
@ -3313,7 +3318,12 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
PseudoEnumData* data = (PseudoEnumData*)aData;
|
||||
|
||||
nsCSSSelector* selector = aRule->FirstSelector();
|
||||
if (selector->mTag == data->mPseudoTag) {
|
||||
|
||||
PRBool matches = (selector->mTag == data->mPseudoTag);
|
||||
if (data->mComparator)
|
||||
data->mComparator->PseudoMatches(data->mPseudoTag, selector, &matches);
|
||||
|
||||
if (matches) {
|
||||
selector = selector->mNext;
|
||||
|
||||
if (selector) { // test next selector specially
|
||||
@ -3362,6 +3372,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPresContext, "null arg");
|
||||
@ -3371,7 +3382,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
RuleCascadeData* cascade = GetRuleCascade(aMedium);
|
||||
|
||||
if (cascade) {
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aResults);
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aComparator, aResults);
|
||||
cascade->mRuleHash.EnumerateTagRules(aPseudoTag, PseudoEnumFunc, &data);
|
||||
|
||||
#ifdef DEBUG_RULES
|
||||
|
@ -351,6 +351,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -535,6 +536,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
|
||||
|
@ -605,6 +605,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -958,6 +959,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
// no pseudo frame style
|
||||
|
@ -206,6 +206,10 @@ protected:
|
||||
PRBool ParseSingleValueProperty(PRInt32& aErrorCode, nsCSSValue& aValue,
|
||||
nsCSSProperty aPropID);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool ParseOutlinerPseudoElement(PRInt32& aErrorCode, nsCSSSelector& aSelector);
|
||||
#endif
|
||||
|
||||
// Property specific parsing routines
|
||||
PRBool ParseAzimuth(PRInt32& aErrorCode, nsCSSValue& aValue);
|
||||
PRBool ParseBackground(PRInt32& aErrorCode, nsICSSDeclaration* aDeclaration, PRInt32& aChangeHint);
|
||||
@ -1356,6 +1360,20 @@ static PRBool IsSinglePseudoClass(const nsCSSSelector& aSelector)
|
||||
(aSelector.mPseudoClassList->mNext == nsnull));
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
static PRBool IsOutlinerPseudoElement(const nsString& aPseudo)
|
||||
{
|
||||
return !(aPseudo.CompareWithConversion("-moz-outliner-", PR_FALSE, 14));
|
||||
}
|
||||
|
||||
static PRBool IsOutlinerPseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return !(str.CompareWithConversion(":-moz-outliner-", PR_FALSE, 15));
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
SelectorList*& aList)
|
||||
{
|
||||
@ -1401,6 +1419,14 @@ PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
else { // append new pseudo element selector
|
||||
selector.Reset();
|
||||
selector.mTag = pseudoClassList->mAtom; // steal ref count
|
||||
if (IsOutlinerPseudoElement(selector.mTag)) {
|
||||
// Take the remaining "pseudoclasses" that we parsed
|
||||
// inside the outliner pseudoelement's ()-list, and
|
||||
// make our new selector have these pseudoclasses
|
||||
// in its pseudoclass list.
|
||||
selector.mPseudoClassList = pseudoClassList->mNext;
|
||||
pseudoClassList->mNext = nsnull;
|
||||
}
|
||||
list->AddSelector(selector);
|
||||
pseudoClassList->mAtom = nsnull;
|
||||
listSel->mOperator = PRUnichar('>');
|
||||
@ -1674,9 +1700,16 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident != mToken.mType) { // malformed selector
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function != mToken.mType ||
|
||||
!IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
#endif
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
buffer.Truncate();
|
||||
@ -1696,6 +1729,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later
|
||||
NS_RELEASE(pseudo);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
// We have encountered a pseudoelement of the form
|
||||
// -moz-outliner-xxxx(a,b,c). We parse (a,b,c) and add each
|
||||
// item in the list to the pseudoclass list. They will be pulled
|
||||
// from the list later along with the pseudoelement.
|
||||
if (!ParseOutlinerPseudoElement(aErrorCode, aSelector))
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ensure selector ends here, must be followed by EOF, space, '{' or ','
|
||||
if (GetToken(aErrorCode, PR_FALSE)) { // premature eof is ok (here!)
|
||||
if ((eCSSToken_WhiteSpace == mToken.mType) ||
|
||||
@ -2060,6 +2105,31 @@ PRBool CSSParserImpl::ParseColorComponent(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool CSSParserImpl::ParseOutlinerPseudoElement(PRInt32& aErrorCode,
|
||||
nsCSSSelector& aSelector)
|
||||
{
|
||||
if (ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
|
||||
while (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
|
||||
if (!GetToken(aErrorCode, PR_TRUE)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else if (eCSSToken_Ident == mToken.mType) {
|
||||
nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_NewAtom(mToken.mIdent));
|
||||
aSelector.AddPseudoClass(pseudo);
|
||||
}
|
||||
else if (eCSSToken_Symbol == mToken.mType) {
|
||||
if (!mToken.IsSymbol(','))
|
||||
return PR_FALSE;
|
||||
}
|
||||
else return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PRBool
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsICSSPseudoComparator.h"
|
||||
#include "nsICSSStyleRuleProcessor.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsICSSNameSpaceRule.h"
|
||||
@ -403,6 +404,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -3299,13 +3301,16 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
struct PseudoEnumData : public SelectorMatchesData {
|
||||
PseudoEnumData(nsIPresContext* aPresContext, nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag, nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
: SelectorMatchesData(aPresContext, aParentContent, aParentContext, aResults)
|
||||
{
|
||||
mPseudoTag = aPseudoTag;
|
||||
mComparator = aComparator;
|
||||
}
|
||||
|
||||
nsIAtom* mPseudoTag;
|
||||
nsIAtom* mPseudoTag;
|
||||
nsICSSPseudoComparator* mComparator;
|
||||
};
|
||||
|
||||
static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
@ -3313,7 +3318,12 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
PseudoEnumData* data = (PseudoEnumData*)aData;
|
||||
|
||||
nsCSSSelector* selector = aRule->FirstSelector();
|
||||
if (selector->mTag == data->mPseudoTag) {
|
||||
|
||||
PRBool matches = (selector->mTag == data->mPseudoTag);
|
||||
if (data->mComparator)
|
||||
data->mComparator->PseudoMatches(data->mPseudoTag, selector, &matches);
|
||||
|
||||
if (matches) {
|
||||
selector = selector->mNext;
|
||||
|
||||
if (selector) { // test next selector specially
|
||||
@ -3362,6 +3372,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPresContext, "null arg");
|
||||
@ -3371,7 +3382,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
RuleCascadeData* cascade = GetRuleCascade(aMedium);
|
||||
|
||||
if (cascade) {
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aResults);
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aComparator, aResults);
|
||||
cascade->mRuleHash.EnumerateTagRules(aPseudoTag, PseudoEnumFunc, &data);
|
||||
|
||||
#ifdef DEBUG_RULES
|
||||
|
@ -351,6 +351,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -535,6 +536,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
|
||||
|
@ -605,6 +605,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -958,6 +959,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
// no pseudo frame style
|
||||
|
@ -206,6 +206,10 @@ protected:
|
||||
PRBool ParseSingleValueProperty(PRInt32& aErrorCode, nsCSSValue& aValue,
|
||||
nsCSSProperty aPropID);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool ParseOutlinerPseudoElement(PRInt32& aErrorCode, nsCSSSelector& aSelector);
|
||||
#endif
|
||||
|
||||
// Property specific parsing routines
|
||||
PRBool ParseAzimuth(PRInt32& aErrorCode, nsCSSValue& aValue);
|
||||
PRBool ParseBackground(PRInt32& aErrorCode, nsICSSDeclaration* aDeclaration, PRInt32& aChangeHint);
|
||||
@ -1356,6 +1360,20 @@ static PRBool IsSinglePseudoClass(const nsCSSSelector& aSelector)
|
||||
(aSelector.mPseudoClassList->mNext == nsnull));
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
static PRBool IsOutlinerPseudoElement(const nsString& aPseudo)
|
||||
{
|
||||
return !(aPseudo.CompareWithConversion("-moz-outliner-", PR_FALSE, 14));
|
||||
}
|
||||
|
||||
static PRBool IsOutlinerPseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return !(str.CompareWithConversion(":-moz-outliner-", PR_FALSE, 15));
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
SelectorList*& aList)
|
||||
{
|
||||
@ -1401,6 +1419,14 @@ PRBool CSSParserImpl::ParseSelectorGroup(PRInt32& aErrorCode,
|
||||
else { // append new pseudo element selector
|
||||
selector.Reset();
|
||||
selector.mTag = pseudoClassList->mAtom; // steal ref count
|
||||
if (IsOutlinerPseudoElement(selector.mTag)) {
|
||||
// Take the remaining "pseudoclasses" that we parsed
|
||||
// inside the outliner pseudoelement's ()-list, and
|
||||
// make our new selector have these pseudoclasses
|
||||
// in its pseudoclass list.
|
||||
selector.mPseudoClassList = pseudoClassList->mNext;
|
||||
pseudoClassList->mNext = nsnull;
|
||||
}
|
||||
list->AddSelector(selector);
|
||||
pseudoClassList->mAtom = nsnull;
|
||||
listSel->mOperator = PRUnichar('>');
|
||||
@ -1674,9 +1700,16 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident != mToken.mType) { // malformed selector
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function != mToken.mType ||
|
||||
!IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
#endif
|
||||
REPORT_UNEXPECTED_TOKEN();
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
#ifdef INCLUDE_XUL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
buffer.Truncate();
|
||||
@ -1696,6 +1729,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
||||
aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later
|
||||
NS_RELEASE(pseudo);
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
IsOutlinerPseudoElement(mToken.mIdent)) {
|
||||
// We have encountered a pseudoelement of the form
|
||||
// -moz-outliner-xxxx(a,b,c). We parse (a,b,c) and add each
|
||||
// item in the list to the pseudoclass list. They will be pulled
|
||||
// from the list later along with the pseudoelement.
|
||||
if (!ParseOutlinerPseudoElement(aErrorCode, aSelector))
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ensure selector ends here, must be followed by EOF, space, '{' or ','
|
||||
if (GetToken(aErrorCode, PR_FALSE)) { // premature eof is ok (here!)
|
||||
if ((eCSSToken_WhiteSpace == mToken.mType) ||
|
||||
@ -2060,6 +2105,31 @@ PRBool CSSParserImpl::ParseColorComponent(PRInt32& aErrorCode,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_XUL
|
||||
PRBool CSSParserImpl::ParseOutlinerPseudoElement(PRInt32& aErrorCode,
|
||||
nsCSSSelector& aSelector)
|
||||
{
|
||||
if (ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
|
||||
while (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
|
||||
if (!GetToken(aErrorCode, PR_TRUE)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else if (eCSSToken_Ident == mToken.mType) {
|
||||
nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_NewAtom(mToken.mIdent));
|
||||
aSelector.AddPseudoClass(pseudo);
|
||||
}
|
||||
else if (eCSSToken_Symbol == mToken.mType) {
|
||||
if (!mToken.IsSymbol(','))
|
||||
return PR_FALSE;
|
||||
}
|
||||
else return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PRBool
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsICSSPseudoComparator.h"
|
||||
#include "nsICSSStyleRuleProcessor.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsICSSNameSpaceRule.h"
|
||||
@ -403,6 +404,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -3299,13 +3301,16 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
struct PseudoEnumData : public SelectorMatchesData {
|
||||
PseudoEnumData(nsIPresContext* aPresContext, nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag, nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
: SelectorMatchesData(aPresContext, aParentContent, aParentContext, aResults)
|
||||
{
|
||||
mPseudoTag = aPseudoTag;
|
||||
mComparator = aComparator;
|
||||
}
|
||||
|
||||
nsIAtom* mPseudoTag;
|
||||
nsIAtom* mPseudoTag;
|
||||
nsICSSPseudoComparator* mComparator;
|
||||
};
|
||||
|
||||
static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
@ -3313,7 +3318,12 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, void* aData)
|
||||
PseudoEnumData* data = (PseudoEnumData*)aData;
|
||||
|
||||
nsCSSSelector* selector = aRule->FirstSelector();
|
||||
if (selector->mTag == data->mPseudoTag) {
|
||||
|
||||
PRBool matches = (selector->mTag == data->mPseudoTag);
|
||||
if (data->mComparator)
|
||||
data->mComparator->PseudoMatches(data->mPseudoTag, selector, &matches);
|
||||
|
||||
if (matches) {
|
||||
selector = selector->mNext;
|
||||
|
||||
if (selector) { // test next selector specially
|
||||
@ -3362,6 +3372,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPresContext, "null arg");
|
||||
@ -3371,7 +3382,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
|
||||
RuleCascadeData* cascade = GetRuleCascade(aMedium);
|
||||
|
||||
if (cascade) {
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aResults);
|
||||
PseudoEnumData data(aPresContext, aParentContent, aPseudoTag, aParentContext, aComparator, aResults);
|
||||
cascade->mRuleHash.EnumerateTagRules(aPseudoTag, PseudoEnumFunc, &data);
|
||||
|
||||
#ifdef DEBUG_RULES
|
||||
|
@ -351,6 +351,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -535,6 +536,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
|
||||
|
@ -605,6 +605,7 @@ public:
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults);
|
||||
|
||||
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
|
||||
@ -958,6 +959,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsIStyleContext* aParentContext,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsISupportsArray* aResults)
|
||||
{
|
||||
// no pseudo frame style
|
||||
|
Loading…
Reference in New Issue
Block a user