Backout 15cf68a3c027, 2f403e4c42c8, 61534874aed7, 1cb3705557d9 & 03970d1fc919 (bug 661746) for Win PGO build failures; a=bz

This commit is contained in:
Ed Morley 2011-11-14 18:10:22 +00:00
Родитель 5632a10a76
Коммит 5db488079f
17 изменённых файлов: 131 добавлений и 169 удалений

Просмотреть файл

@ -195,9 +195,4 @@ inline mozilla::dom::Element* nsINode::AsElement() {
return static_cast<mozilla::dom::Element*>(this);
}
inline const mozilla::dom::Element* nsINode::AsElement() const {
NS_ASSERTION(IsElement(), "Not an element?");
return static_cast<const mozilla::dom::Element*>(this);
}
#endif // mozilla_dom_Element_h__

Просмотреть файл

@ -518,7 +518,7 @@ public:
* Get the length of the text content.
* NOTE: This should not be called on elements.
*/
virtual PRUint32 TextLength() const = 0;
virtual PRUint32 TextLength() = 0;
/**
* Set the text to the given value. If aNotify is true then
@ -550,7 +550,7 @@ public:
* Query method to see if the frame is nothing but whitespace
* NOTE: Always returns false for elements
*/
virtual bool TextIsOnlyWhitespace() const = 0;
virtual bool TextIsOnlyWhitespace() = 0;
/**
* Append the text content to aResult.

Просмотреть файл

@ -379,7 +379,6 @@ public:
* for which IsElement() is true.
*/
mozilla::dom::Element* AsElement();
const mozilla::dom::Element* AsElement() const;
/**
* Get the number of children

Просмотреть файл

@ -849,7 +849,7 @@ nsGenericDOMDataNode::GetText()
}
PRUint32
nsGenericDOMDataNode::TextLength() const
nsGenericDOMDataNode::TextLength()
{
return mText.GetLength();
}
@ -871,7 +871,7 @@ nsGenericDOMDataNode::AppendText(const PRUnichar* aBuffer,
}
bool
nsGenericDOMDataNode::TextIsOnlyWhitespace() const
nsGenericDOMDataNode::TextIsOnlyWhitespace()
{
if (mText.Is2b()) {
// The fragment contains non-8bit characters and such characters

Просмотреть файл

@ -211,7 +211,7 @@ public:
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
virtual PRUint32 GetAttrCount() const;
virtual const nsTextFragment *GetText();
virtual PRUint32 TextLength() const;
virtual PRUint32 TextLength();
virtual nsresult SetText(const PRUnichar* aBuffer, PRUint32 aLength,
bool aNotify);
// Need to implement this here too to avoid hiding.
@ -221,7 +221,7 @@ public:
}
virtual nsresult AppendText(const PRUnichar* aBuffer, PRUint32 aLength,
bool aNotify);
virtual bool TextIsOnlyWhitespace() const;
virtual bool TextIsOnlyWhitespace();
virtual void AppendTextTo(nsAString& aResult);
virtual void DestroyContent();
virtual void SaveSubtreeState();

Просмотреть файл

@ -4889,7 +4889,7 @@ nsGenericElement::GetText()
}
PRUint32
nsGenericElement::TextLength() const
nsGenericElement::TextLength()
{
// We can remove this assertion if it turns out to be useful to be able
// to depend on this returning 0
@ -4917,7 +4917,7 @@ nsGenericElement::AppendText(const PRUnichar* aBuffer, PRUint32 aLength,
}
bool
nsGenericElement::TextIsOnlyWhitespace() const
nsGenericElement::TextIsOnlyWhitespace()
{
return false;
}

Просмотреть файл

@ -325,7 +325,7 @@ public:
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
virtual PRUint32 GetAttrCount() const;
virtual const nsTextFragment *GetText();
virtual PRUint32 TextLength() const;
virtual PRUint32 TextLength();
virtual nsresult SetText(const PRUnichar* aBuffer, PRUint32 aLength,
bool aNotify);
// Need to implement this here too to avoid hiding.
@ -335,7 +335,7 @@ public:
}
virtual nsresult AppendText(const PRUnichar* aBuffer, PRUint32 aLength,
bool aNotify);
virtual bool TextIsOnlyWhitespace() const;
virtual bool TextIsOnlyWhitespace();
virtual void AppendTextTo(nsAString& aResult);
virtual nsIContent *GetBindingParent() const;
virtual bool IsNodeOfType(PRUint32 aFlags) const;

Просмотреть файл

@ -143,16 +143,15 @@ nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType)
}
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
nsIAtom* aAtom)
const PRUnichar* aString)
: mType(aType),
mNext(nsnull)
{
NS_ASSERTION(nsCSSPseudoClasses::HasStringArg(aType),
"unexpected pseudo-class");
NS_ASSERTION(aAtom, "atom expected");
NS_ASSERTION(aString, "string expected");
MOZ_COUNT_CTOR(nsPseudoClassList);
NS_ADDREF(aAtom);
u.mAtom = aAtom;
u.mString = NS_strdup(aString);
}
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
@ -188,7 +187,7 @@ nsPseudoClassList::Clone(bool aDeep) const
if (!u.mMemory) {
result = new nsPseudoClassList(mType);
} else if (nsCSSPseudoClasses::HasStringArg(mType)) {
result = new nsPseudoClassList(mType, u.mAtom);
result = new nsPseudoClassList(mType, u.mString);
} else if (nsCSSPseudoClasses::HasNthPairArg(mType)) {
result = new nsPseudoClassList(mType, u.mNumbers);
} else {
@ -211,11 +210,7 @@ nsPseudoClassList::~nsPseudoClassList(void)
if (nsCSSPseudoClasses::HasSelectorListArg(mType)) {
delete u.mSelectors;
} else if (u.mMemory) {
if (nsCSSPseudoClasses::HasStringArg(mType)) {
NS_RELEASE(u.mAtom);
} else {
NS_Free(u.mMemory);
}
NS_Free(u.mMemory);
}
NS_CSS_DELETE_LIST_MEMBER(nsPseudoClassList, this, mNext);
}
@ -419,9 +414,9 @@ void nsCSSSelector::AddPseudoClass(nsCSSPseudoClasses::Type aType)
}
void nsCSSSelector::AddPseudoClass(nsCSSPseudoClasses::Type aType,
nsIAtom* aAtom)
const PRUnichar* aString)
{
AddPseudoClassInternal(new nsPseudoClassList(aType, aAtom));
AddPseudoClassInternal(new nsPseudoClassList(aType, aString));
}
void nsCSSSelector::AddPseudoClass(nsCSSPseudoClasses::Type aType,
@ -777,7 +772,7 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
aString.Append(PRUnichar('('));
if (nsCSSPseudoClasses::HasStringArg(list->mType)) {
nsStyleUtil::AppendEscapedCSSIdent(
nsDependentAtomString(list->u.mAtom), aString);
nsDependentString(list->u.mString), aString);
} else if (nsCSSPseudoClasses::HasNthPairArg(list->mType)) {
PRInt32 a = list->u.mNumbers[0],
b = list->u.mNumbers[1];

Просмотреть файл

@ -80,7 +80,7 @@ private:
struct nsPseudoClassList {
public:
nsPseudoClassList(nsCSSPseudoClasses::Type aType);
nsPseudoClassList(nsCSSPseudoClasses::Type aType, nsIAtom *aAtom);
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const PRUnichar *aString);
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const PRInt32 *aIntPair);
nsPseudoClassList(nsCSSPseudoClasses::Type aType,
nsCSSSelectorList *aSelectorList /* takes ownership */);
@ -99,8 +99,8 @@ public:
// (if nsCSSPseudoClasses::HasNthPairArg(mType))
// d. a selector list, which means mSelectors is non-null
// (if nsCSSPseudoClasses::HasSelectorListArg(mType))
void* mMemory; // mNumbers uses NS_Alloc/NS_Free
nsIAtom* mAtom; // STRONG REF
void* mMemory; // mString and mNumbers use NS_Alloc/NS_Free
PRUnichar* mString;
PRInt32* mNumbers;
nsCSSSelectorList* mSelectors;
} u;
@ -165,7 +165,7 @@ public:
void AddID(const nsString& aID);
void AddClass(const nsString& aClass);
void AddPseudoClass(nsCSSPseudoClasses::Type aType);
void AddPseudoClass(nsCSSPseudoClasses::Type aType, nsIAtom* aAtom);
void AddPseudoClass(nsCSSPseudoClasses::Type aType, const PRUnichar* aString);
void AddPseudoClass(nsCSSPseudoClasses::Type aType, const PRInt32* aIntPair);
// takes ownership of aSelectorList
void AddPseudoClass(nsCSSPseudoClasses::Type aType,

Просмотреть файл

@ -3371,16 +3371,16 @@ CSSParserImpl::ParsePseudoClassWithIdentArg(nsCSSSelector& aSelector,
return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')')
}
nsCOMPtr<nsIAtom> atom = do_GetAtom(mToken.mIdent);
// -moz-locale-dir can only have values of 'ltr' or 'rtl'.
if (aType == nsCSSPseudoClasses::ePseudoClass_mozLocaleDir) {
if (atom != nsGkAtoms::ltr && atom != nsGkAtoms::rtl) {
if (!mToken.mIdent.EqualsLiteral("ltr") &&
!mToken.mIdent.EqualsLiteral("rtl")) {
return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')')
}
}
// Add the pseudo with the language parameter
aSelector.AddPseudoClass(aType, atom);
aSelector.AddPseudoClass(aType, mToken.mIdent.get());
// close the parenthesis
if (!ExpectSymbol(')', true)) {

Просмотреть файл

@ -419,7 +419,7 @@ public:
RuleHash(bool aQuirksMode);
~RuleHash();
void AppendRule(const RuleSelectorPair &aRuleInfo);
void EnumerateAllRules(const Element* aElement, RuleProcessorData* aData,
void EnumerateAllRules(Element* aElement, RuleProcessorData* aData,
NodeMatchContext& aNodeMatchContext);
PLArenaPool& Arena() { return mArena; }
@ -628,10 +628,10 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
#endif
static inline
void ContentEnumFunc(css::StyleRule* aRule, const nsCSSSelector* aSelector,
void ContentEnumFunc(css::StyleRule* aRule, nsCSSSelector* aSelector,
RuleProcessorData* data, NodeMatchContext& nodeContext);
void RuleHash::EnumerateAllRules(const Element* aElement, RuleProcessorData* aData,
void RuleHash::EnumerateAllRules(Element* aElement, RuleProcessorData* aData,
NodeMatchContext& aNodeContext)
{
PRInt32 nameSpace = aElement->GetNameSpaceID();
@ -1247,7 +1247,7 @@ nsCSSRuleProcessor::GetWindowsThemeIdentifier()
/* static */
nsEventStates
nsCSSRuleProcessor::GetContentState(const Element* aElement)
nsCSSRuleProcessor::GetContentState(Element* aElement)
{
nsEventStates state = aElement->State();
@ -1267,7 +1267,7 @@ nsCSSRuleProcessor::GetContentState(const Element* aElement)
/* static */
bool
nsCSSRuleProcessor::IsLink(const Element* aElement)
nsCSSRuleProcessor::IsLink(Element* aElement)
{
nsEventStates state = aElement->State();
return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED);
@ -1276,7 +1276,7 @@ nsCSSRuleProcessor::IsLink(const Element* aElement)
/* static */
nsEventStates
nsCSSRuleProcessor::GetContentStateForVisitedHandling(
const Element* aElement,
Element* aElement,
nsRuleWalker::VisitedHandlingType aVisitedHandling,
bool aIsRelevantLink)
{
@ -1390,7 +1390,7 @@ inline bool IsQuirkEventSensitive(nsIAtom *aContentTag)
static inline bool
IsSignificantChild(const nsIContent* aChild, bool aTextIsSignificant,
IsSignificantChild(nsIContent* aChild, bool aTextIsSignificant,
bool aWhitespaceIsSignificant)
{
return nsStyleUtil::IsSignificantChild(aChild, aTextIsSignificant,
@ -1442,16 +1442,16 @@ static bool AttrMatchesValue(const nsAttrSelector* aAttrSelector,
}
static inline bool
edgeChildMatches(const Element* aElement, TreeMatchContext& aTreeMatchContext,
edgeChildMatches(Element* aElement, TreeMatchContext& aTreeMatchContext,
bool checkFirst, bool checkLast)
{
const nsIContent *parent = aElement->GetParent();
nsIContent *parent = aElement->GetParent();
if (!parent) {
return false;
}
if (aTreeMatchContext.mForStyling)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_EDGE_CHILD_SELECTOR);
parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
return (!checkFirst ||
aTreeMatchContext.mNthIndexCache.
@ -1462,21 +1462,21 @@ edgeChildMatches(const Element* aElement, TreeMatchContext& aTreeMatchContext,
}
static inline bool
nthChildGenericMatches(const Element* aElement,
nthChildGenericMatches(Element* aElement,
TreeMatchContext& aTreeMatchContext,
const nsPseudoClassList* pseudoClass,
nsPseudoClassList* pseudoClass,
bool isOfType, bool isFromEnd)
{
const nsIContent *parent = aElement->GetParent();
nsIContent *parent = aElement->GetParent();
if (!parent) {
return false;
}
if (aTreeMatchContext.mForStyling) {
if (isFromEnd)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_SLOW_SELECTOR);
parent->SetFlags(NODE_HAS_SLOW_SELECTOR);
else
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
parent->SetFlags(NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
}
const PRInt32 index = aTreeMatchContext.mNthIndexCache.
@ -1502,19 +1502,19 @@ nthChildGenericMatches(const Element* aElement,
}
static inline bool
edgeOfTypeMatches(const Element* aElement, TreeMatchContext& aTreeMatchContext,
edgeOfTypeMatches(Element* aElement, TreeMatchContext& aTreeMatchContext,
bool checkFirst, bool checkLast)
{
const nsIContent *parent = aElement->GetParent();
nsIContent *parent = aElement->GetParent();
if (!parent) {
return false;
}
if (aTreeMatchContext.mForStyling) {
if (checkLast)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_SLOW_SELECTOR);
parent->SetFlags(NODE_HAS_SLOW_SELECTOR);
else
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
parent->SetFlags(NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
}
return (!checkFirst ||
@ -1526,15 +1526,15 @@ edgeOfTypeMatches(const Element* aElement, TreeMatchContext& aTreeMatchContext,
}
static inline bool
checkGenericEmptyMatches(const Element* aElement,
checkGenericEmptyMatches(Element* aElement,
TreeMatchContext& aTreeMatchContext,
bool isWhitespaceSignificant)
{
const nsIContent *child = nsnull;
nsIContent *child = nsnull;
PRInt32 index = -1;
if (aTreeMatchContext.mForStyling)
aTreeMatchContext.RecordFlagsToAdd(aElement, NODE_HAS_EMPTY_SELECTOR);
aElement->SetFlags(NODE_HAS_EMPTY_SELECTOR);
do {
child = aElement->GetChildAt(++index);
@ -1566,8 +1566,8 @@ PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
// which is done only when SelectorMatches calls itself recursively
// * what it points to should be set to true whenever a test is skipped
// because of aStateMask
static bool SelectorMatches(const Element* aElement,
const nsCSSSelector* aSelector,
static bool SelectorMatches(Element* aElement,
nsCSSSelector* aSelector,
NodeMatchContext& aNodeMatchContext,
TreeMatchContext& aTreeMatchContext,
bool* const aDependence = nsnull)
@ -1596,7 +1596,7 @@ static bool SelectorMatches(const Element* aElement,
}
}
const nsAtomList* IDList = aSelector->mIDList;
nsAtomList* IDList = aSelector->mIDList;
if (IDList) {
nsIAtom* id = aElement->GetID();
if (id) {
@ -1630,7 +1630,7 @@ static bool SelectorMatches(const Element* aElement,
}
}
const nsAtomList* classList = aSelector->mClassList;
nsAtomList* classList = aSelector->mClassList;
if (classList) {
// test for class match
const nsAttrValue *elementClasses = aElement->GetClasses();
@ -1665,7 +1665,7 @@ static bool SelectorMatches(const Element* aElement,
"state-dependence");
// test for pseudo class match
for (const nsPseudoClassList* pseudoClass = aSelector->mPseudoClassList;
for (nsPseudoClassList* pseudoClass = aSelector->mPseudoClassList;
pseudoClass; pseudoClass = pseudoClass->mNext) {
nsEventStates statesToCheck = sPseudoClassStates[pseudoClass->mType];
if (statesToCheck.IsEmpty()) {
@ -1686,8 +1686,8 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozEmptyExceptChildrenWithLocalname:
{
NS_ASSERTION(pseudoClass->u.mAtom, "Must have atom!");
const nsIContent *child = nsnull;
NS_ASSERTION(pseudoClass->u.mString, "Must have string!");
nsIContent *child = nsnull;
PRInt32 index = -1;
if (aTreeMatchContext.mForStyling)
@ -1696,13 +1696,13 @@ static bool SelectorMatches(const Element* aElement,
// :-moz-empty-except-children-with-localname() ~ E
// because we don't know to restyle the grandparent of the
// inserted/removed element (as in bug 534804 for :empty).
aTreeMatchContext.RecordFlagsToAdd(aElement, NODE_HAS_SLOW_SELECTOR);
aElement->SetFlags(NODE_HAS_SLOW_SELECTOR);
do {
child = aElement->GetChildAt(++index);
} while (child &&
(!IsSignificantChild(child, true, false) ||
(child->GetNameSpaceID() == aElement->GetNameSpaceID() &&
child->Tag() == pseudoClass->u.mAtom)));
child->Tag()->Equals(nsDependentString(pseudoClass->u.mString)))));
if (child != nsnull) {
return false;
}
@ -1711,7 +1711,10 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_lang:
{
NS_ASSERTION(pseudoClass->u.mAtom, "Must have atom!");
NS_ASSERTION(nsnull != pseudoClass->u.mString, "null lang parameter");
if (!pseudoClass->u.mString || !*pseudoClass->u.mString) {
return false;
}
// We have to determine the language of the current element. Since
// this is currently no property and since the language is inherited
@ -1719,10 +1722,9 @@ static bool SelectorMatches(const Element* aElement,
// nodes. The language itself is encoded in the LANG attribute.
nsAutoString language;
aElement->GetLang(language);
nsDependentAtomString langString(pseudoClass->u.mAtom);
if (!language.IsEmpty()) {
if (!nsStyleUtil::DashMatchCompare(language,
langString,
nsDependentString(pseudoClass->u.mString),
nsASCIICaseInsensitiveStringComparator())) {
return false;
}
@ -1730,7 +1732,7 @@ static bool SelectorMatches(const Element* aElement,
break;
}
const nsIDocument* doc = aTreeMatchContext.mDocument;
nsIDocument* doc = aTreeMatchContext.mDocument;
if (doc) {
// Try to get the language from the HTTP header or if this
// is missing as well from the preferences.
@ -1738,6 +1740,7 @@ static bool SelectorMatches(const Element* aElement,
// language codes.
doc->GetContentLanguage(language);
nsDependentString langString(pseudoClass->u.mString);
language.StripWhitespace();
PRInt32 begin = 0;
PRInt32 len = language.Length();
@ -1779,9 +1782,9 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_any:
{
const nsCSSSelectorList *l;
nsCSSSelectorList *l;
for (l = pseudoClass->u.mSelectors; l; l = l->mNext) {
const nsCSSSelector *s = l->mSelectors;
nsCSSSelector *s = l->mSelectors;
NS_ABORT_IF_FALSE(!s->mNext && !s->IsPseudoElement(),
"parser failed");
if (SelectorMatches(aElement, s, aNodeMatchContext,
@ -1803,11 +1806,11 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_firstNode:
{
const nsIContent *firstNode = nsnull;
const nsIContent *parent = aElement->GetParent();
nsIContent *firstNode = nsnull;
nsIContent *parent = aElement->GetParent();
if (parent) {
if (aTreeMatchContext.mForStyling)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_EDGE_CHILD_SELECTOR);
parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
PRInt32 index = -1;
do {
@ -1830,11 +1833,11 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_lastNode:
{
const nsIContent *lastNode = nsnull;
const nsIContent *parent = aElement->GetParent();
nsIContent *lastNode = nsnull;
nsIContent *parent = aElement->GetParent();
if (parent) {
if (aTreeMatchContext.mForStyling)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_EDGE_CHILD_SELECTOR);
parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
PRUint32 index = parent->GetChildCount();
do {
@ -1903,7 +1906,7 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozHasHandlerRef:
{
const nsIContent *child = nsnull;
nsIContent *child = nsnull;
PRInt32 index = -1;
do {
@ -1930,7 +1933,8 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozSystemMetric:
{
if (!nsCSSRuleProcessor::HasSystemMetric(pseudoClass->u.mAtom)) {
nsCOMPtr<nsIAtom> metric = do_GetAtom(pseudoClass->u.mString);
if (!nsCSSRuleProcessor::HasSystemMetric(metric)) {
return false;
}
}
@ -1939,13 +1943,15 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozLocaleDir:
{
bool docIsRTL =
aTreeMatchContext.mDocStates.HasState(NS_DOCUMENT_STATE_RTL_LOCALE);
aTreeMatchContext.mDocument->GetDocumentState().
HasState(NS_DOCUMENT_STATE_RTL_LOCALE);
NS_ASSERTION(pseudoClass->u.mAtom == nsGkAtoms::ltr ||
pseudoClass->u.mAtom == nsGkAtoms::rtl,
nsDependentString dirString(pseudoClass->u.mString);
NS_ASSERTION(dirString.EqualsLiteral("ltr") ||
dirString.EqualsLiteral("rtl"),
"invalid value for -moz-locale-dir");
if ((pseudoClass->u.mAtom == nsGkAtoms::rtl) != docIsRTL) {
if (dirString.EqualsLiteral("rtl") != docIsRTL) {
return false;
}
}
@ -1953,7 +1959,8 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozLWTheme:
{
if (aTreeMatchContext.mDocTheme <= nsIDocument::Doc_Theme_None) {
if (aTreeMatchContext.mDocument->GetDocumentLWTheme() <=
nsIDocument::Doc_Theme_None) {
return false;
}
}
@ -1961,7 +1968,8 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozLWThemeBrightText:
{
if (aTreeMatchContext.mDocTheme != nsIDocument::Doc_Theme_Bright) {
if (aTreeMatchContext.mDocument->GetDocumentLWTheme() !=
nsIDocument::Doc_Theme_Bright) {
return false;
}
}
@ -1969,14 +1977,16 @@ static bool SelectorMatches(const Element* aElement,
case nsCSSPseudoClasses::ePseudoClass_mozLWThemeDarkText:
{
if (aTreeMatchContext.mDocTheme != nsIDocument::Doc_Theme_Dark) {
if (aTreeMatchContext.mDocument->GetDocumentLWTheme() !=
nsIDocument::Doc_Theme_Dark) {
return false;
}
}
break;
case nsCSSPseudoClasses::ePseudoClass_mozWindowInactive:
if (!aTreeMatchContext.mDocStates.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
if (!aTreeMatchContext.mDocument->GetDocumentState().
HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
return false;
}
break;
@ -1986,7 +1996,7 @@ static bool SelectorMatches(const Element* aElement,
if (!aElement->IsHTML(nsGkAtoms::table)) {
return false;
}
const nsGenericElement *ge = static_cast<const nsGenericElement*>(aElement);
nsGenericElement *ge = static_cast<nsGenericElement*>(aElement);
const nsAttrValue *val = ge->GetParsedAttr(nsGkAtoms::border);
if (!val ||
(val->Type() == nsAttrValue::eInteger &&
@ -2044,7 +2054,7 @@ static bool SelectorMatches(const Element* aElement,
return false;
} else {
result = true;
const nsAttrSelector* attr = aSelector->mAttrList;
nsAttrSelector* attr = aSelector->mAttrList;
nsIAtom* matchAttribute;
do {
@ -2116,7 +2126,7 @@ static bool SelectorMatches(const Element* aElement,
// apply SelectorMatches to the negated selectors in the chain
if (!isNegated) {
for (const nsCSSSelector *negation = aSelector->mNegations;
for (nsCSSSelector *negation = aSelector->mNegations;
result && negation; negation = negation->mNegations) {
bool dependence = false;
result = !SelectorMatches(aElement, negation, aNodeMatchContext,
@ -2140,13 +2150,13 @@ static bool SelectorMatches(const Element* aElement,
#define NS_IS_GREEDY_OPERATOR(ch) \
((ch) == PRUnichar(' ') || (ch) == PRUnichar('~'))
static bool SelectorMatchesTree(const Element* aPrevElement,
const nsCSSSelector* aSelector,
static bool SelectorMatchesTree(Element* aPrevElement,
nsCSSSelector* aSelector,
TreeMatchContext& aTreeMatchContext,
bool aLookForRelevantLink)
{
const nsCSSSelector* selector = aSelector;
const Element* prevElement = aPrevElement;
nsCSSSelector* selector = aSelector;
Element* prevElement = aPrevElement;
while (selector) { // check compound selectors
NS_ASSERTION(!selector->mNext ||
selector->mNext->mOperator != PRUnichar(0),
@ -2154,21 +2164,21 @@ static bool SelectorMatchesTree(const Element* aPrevElement,
// for adjacent sibling combinators, the content to test against the
// selector is the previous sibling *element*
const Element* element = nsnull;
Element* element = nsnull;
if (PRUnichar('+') == selector->mOperator ||
PRUnichar('~') == selector->mOperator) {
// The relevant link must be an ancestor of the node being matched.
aLookForRelevantLink = false;
const nsIContent* parent = prevElement->GetParent();
nsIContent* parent = prevElement->GetParent();
if (parent) {
if (aTreeMatchContext.mForStyling)
aTreeMatchContext.RecordFlagsToAdd(parent, NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
parent->SetFlags(NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
for (const nsIContent* curr = prevElement->GetPreviousSibling();
curr;
curr = curr->GetPreviousSibling()) {
if (curr->IsElement()) {
element = curr->AsElement();
PRInt32 index = parent->IndexOf(prevElement);
while (0 <= --index) {
nsIContent* content = parent->GetChildAt(index);
if (content->IsElement()) {
element = content->AsElement();
break;
}
}
@ -2177,7 +2187,7 @@ static bool SelectorMatchesTree(const Element* aPrevElement,
// for descendant combinators and child combinators, the element
// to test against is the parent
else {
const nsIContent *content = prevElement->GetParent();
nsIContent *content = prevElement->GetParent();
// GetParent could return a document fragment; we only want
// element parents.
if (content && content->IsElement()) {
@ -2241,7 +2251,7 @@ static bool SelectorMatchesTree(const Element* aPrevElement,
}
static inline
void ContentEnumFunc(css::StyleRule* aRule, const nsCSSSelector* aSelector,
void ContentEnumFunc(css::StyleRule* aRule, nsCSSSelector* aSelector,
RuleProcessorData* data, NodeMatchContext& nodeContext)
{
if (nodeContext.mIsRelevantLink) {
@ -2249,7 +2259,7 @@ void ContentEnumFunc(css::StyleRule* aRule, const nsCSSSelector* aSelector,
}
if (SelectorMatches(data->mElement, aSelector, nodeContext,
data->mTreeMatchContext)) {
const nsCSSSelector *next = aSelector->mNext;
nsCSSSelector *next = aSelector->mNext;
if (!next || SelectorMatchesTree(data->mElement, next,
data->mTreeMatchContext,
!nodeContext.mIsRelevantLink)) {
@ -3098,17 +3108,17 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
}
/* static */ bool
nsCSSRuleProcessor::SelectorListMatches(const Element* aElement,
nsCSSRuleProcessor::SelectorListMatches(Element* aElement,
TreeMatchContext& aTreeMatchContext,
const nsCSSSelectorList* aSelectorList)
nsCSSSelectorList* aSelectorList)
{
while (aSelectorList) {
const nsCSSSelector* sel = aSelectorList->mSelectors;
nsCSSSelector* sel = aSelectorList->mSelectors;
NS_ASSERTION(sel, "Should have *some* selectors");
NS_ASSERTION(!sel->IsPseudoElement(), "Shouldn't have been called");
NodeMatchContext nodeContext(nsEventStates(), false);
if (SelectorMatches(aElement, sel, nodeContext, aTreeMatchContext)) {
const nsCSSSelector* next = sel->mNext;
nsCSSSelector* next = sel->mNext;
if (!next ||
SelectorMatchesTree(aElement, next, aTreeMatchContext, false)) {
return true;

Просмотреть файл

@ -93,28 +93,28 @@ public:
* include any pseudo-element selectors. aSelectorList is allowed
* to be null; in this case false will be returned.
*/
static bool SelectorListMatches(const mozilla::dom::Element* aElement,
static bool SelectorListMatches(mozilla::dom::Element* aElement,
TreeMatchContext& aTreeMatchContext,
const nsCSSSelectorList* aSelectorList);
nsCSSSelectorList* aSelectorList);
/*
* Helper to get the content state for a content node. This may be
* slightly adjusted from IntrinsicState().
*/
static nsEventStates GetContentState(const mozilla::dom::Element* aElement);
static nsEventStates GetContentState(mozilla::dom::Element* aElement);
/*
* Helper to get the content state for :visited handling for an element
*/
static nsEventStates GetContentStateForVisitedHandling(
const mozilla::dom::Element* aElement,
mozilla::dom::Element* aElement,
nsRuleWalker::VisitedHandlingType aVisitedHandling,
bool aIsRelevantLink);
/*
* Helper to test whether a node is a link
*/
static bool IsLink(const mozilla::dom::Element* aElement);
static bool IsLink(mozilla::dom::Element* aElement);
// nsIStyleRuleProcessor
virtual void RulesMatching(ElementRuleProcessorData* aData);

Просмотреть файл

@ -63,7 +63,7 @@ nsNthIndexCache::Reset()
}
inline bool
nsNthIndexCache::SiblingMatchesElement(const nsIContent* aSibling, const Element* aElement,
nsNthIndexCache::SiblingMatchesElement(nsIContent* aSibling, Element* aElement,
bool aIsOfType)
{
return aSibling->IsElement() &&
@ -72,8 +72,8 @@ nsNthIndexCache::SiblingMatchesElement(const nsIContent* aSibling, const Element
}
inline bool
nsNthIndexCache::IndexDeterminedFromPreviousSibling(const nsIContent* aSibling,
const Element* aChild,
nsNthIndexCache::IndexDeterminedFromPreviousSibling(nsIContent* aSibling,
Element* aChild,
bool aIsOfType,
bool aIsFromEnd,
const Cache& aCache,
@ -105,7 +105,7 @@ nsNthIndexCache::IndexDeterminedFromPreviousSibling(const nsIContent* aSibling,
}
PRInt32
nsNthIndexCache::GetNthIndex(const Element* aChild, bool aIsOfType,
nsNthIndexCache::GetNthIndex(Element* aChild, bool aIsOfType,
bool aIsFromEnd, bool aCheckEdgeOnly)
{
NS_ASSERTION(aChild->GetParent(), "caller should check GetParent()");
@ -139,7 +139,7 @@ nsNthIndexCache::GetNthIndex(const Element* aChild, bool aIsOfType,
// The caller only cares whether or not the result is 1, so we can
// stop as soon as we see any other elements that match us.
if (aIsFromEnd) {
for (const nsIContent *cur = aChild->GetNextSibling();
for (nsIContent *cur = aChild->GetNextSibling();
cur;
cur = cur->GetNextSibling()) {
if (SiblingMatchesElement(cur, aChild, aIsOfType)) {
@ -148,7 +148,7 @@ nsNthIndexCache::GetNthIndex(const Element* aChild, bool aIsOfType,
}
}
} else {
for (const nsIContent *cur = aChild->GetPreviousSibling();
for (nsIContent *cur = aChild->GetPreviousSibling();
cur;
cur = cur->GetPreviousSibling()) {
if (SiblingMatchesElement(cur, aChild, aIsOfType)) {
@ -160,7 +160,7 @@ nsNthIndexCache::GetNthIndex(const Element* aChild, bool aIsOfType,
} else {
// In the common case, we already have a cached index for one of
// our previous siblings, so check that first.
for (const nsIContent *cur = aChild->GetPreviousSibling();
for (nsIContent *cur = aChild->GetPreviousSibling();
cur;
cur = cur->GetPreviousSibling()) {
if (IndexDeterminedFromPreviousSibling(cur, aChild, aIsOfType,
@ -177,7 +177,7 @@ nsNthIndexCache::GetNthIndex(const Element* aChild, bool aIsOfType,
// is not primed for them.
if (aIsFromEnd) {
result = 1;
for (const nsIContent *cur = aChild->GetNextSibling();
for (nsIContent *cur = aChild->GetNextSibling();
cur;
cur = cur->GetNextSibling()) {
if (SiblingMatchesElement(cur, aChild, aIsOfType)) {

Просмотреть файл

@ -67,7 +67,7 @@ public:
// is 1, and something other than 1 (maybe or maybe not a valid
// result) otherwise.
// This must only be called on nodes which have a non-null parent.
PRInt32 GetNthIndex(const Element* aChild, bool aIsOfType, bool aIsFromEnd,
PRInt32 GetNthIndex(Element* aChild, bool aIsOfType, bool aIsFromEnd,
bool aCheckEdgeOnly);
void Reset();
@ -77,8 +77,7 @@ private:
* Returns true if aSibling and aElement should be considered in the same
* list for nth-index purposes, taking aIsOfType into account.
*/
inline bool SiblingMatchesElement(const nsIContent* aSibling,
const Element* aElement,
inline bool SiblingMatchesElement(nsIContent* aSibling, Element* aElement,
bool aIsOfType);
// This node's index for this cache.
@ -95,8 +94,7 @@ private:
void reportAllocOverflow() const {}
};
typedef js::HashMap<const nsIContent*, CacheEntry,
js::DefaultHasher<const nsIContent*>,
typedef js::HashMap<nsIContent*, CacheEntry, js::DefaultHasher<nsIContent*>,
SystemAllocPolicy> Cache;
/**
@ -110,8 +108,8 @@ private:
* elements in the closed range [aSibling, aChild] that match aChild
* otherwise.
*/
inline bool IndexDeterminedFromPreviousSibling(const nsIContent* aSibling,
const Element* aChild,
inline bool IndexDeterminedFromPreviousSibling(nsIContent* aSibling,
Element* aChild,
bool aIsOfType,
bool aIsFromEnd,
const Cache& aCache,

Просмотреть файл

@ -51,23 +51,12 @@
#include "nsCSSPseudoElements.h"
#include "nsRuleWalker.h"
#include "nsNthIndexCache.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
class nsIStyleSheet;
class nsIAtom;
class nsICSSPseudoComparator;
class nsAttrValue;
struct NodeFlagEntry : public nsPtrHashKey<const nsINode>
{
NodeFlagEntry(const nsINode* aNode) : nsPtrHashKey<const nsINode>(aNode), mFlags(0) {}
PRUint32 mFlags;
};
typedef nsTHashtable<NodeFlagEntry> NodeFlagsTable;
/**
* A |TreeMatchContext| has data about a matching operation. The
* data are not node-specific but are invariants of the DOM tree the
@ -119,24 +108,9 @@ struct NS_STACK_CLASS TreeMatchContext {
// nsRuleWalker::VisitedHandlingType.
nsRuleWalker::VisitedHandlingType mVisitedHandling;
NodeFlagsTable mFlagsToAdd;
static PLDHashOperator
AddFlagsToNode(NodeFlagEntry* aEntry, void* aData) {
const_cast<nsINode*>(aEntry->GetKey())->SetFlags(aEntry->mFlags);
return PL_DHASH_NEXT;
}
public:
void RecordFlagsToAdd(const nsINode* aNode, PRUint32 aFlags) {
NodeFlagEntry* entry = mFlagsToAdd.PutEntry(aNode);
entry->mFlags |= aFlags;
}
// The document we're working with.
const nsIDocument* const mDocument;
const nsEventStates mDocStates;
const int mDocTheme;
nsIDocument* const mDocument;
// Root of scoped stylesheet (set and unset by the supplier of the
// scoped stylesheet).
@ -162,19 +136,10 @@ struct NS_STACK_CLASS TreeMatchContext {
, mHaveRelevantLink(false)
, mVisitedHandling(aVisitedHandling)
, mDocument(aDocument)
, mDocStates(aDocument->GetDocumentState())
, mDocTheme(aDocument->GetDocumentLWTheme())
, mScopedRoot(nsnull)
, mIsHTMLDocument(aDocument->IsHTML())
, mCompatMode(aDocument->GetCompatibilityMode())
{
NS_ASSERTION(NS_IsMainThread(), "TreeMatchContext should be created on main thread");
mFlagsToAdd.Init();
}
~TreeMatchContext() {
NS_ASSERTION(NS_IsMainThread(), "TreeMatchContext should be destroyed on main thread");
mFlagsToAdd.EnumerateEntries(AddFlagsToNode, nsnull);
}
};

Просмотреть файл

@ -505,7 +505,7 @@ nsStyleUtil::ColorComponentToFloat(PRUint8 aAlpha)
}
/* static */ bool
nsStyleUtil::IsSignificantChild(const nsIContent* aChild, bool aTextIsSignificant,
nsStyleUtil::IsSignificantChild(nsIContent* aChild, bool aTextIsSignificant,
bool aWhitespaceIsSignificant)
{
NS_ASSERTION(!aWhitespaceIsSignificant || aTextIsSignificant,

Просмотреть файл

@ -112,7 +112,7 @@ public:
/*
* Does this child count as significant for selector matching?
*/
static bool IsSignificantChild(const nsIContent* aChild,
static bool IsSignificantChild(nsIContent* aChild,
bool aTextIsSignificant,
bool aWhitespaceIsSignificant);
};