Bug 562688 part 14. Eliminate eELEMENT usage in the rule processor; switch to Element as we can. r=dbaron

This commit is contained in:
Boris Zbarsky 2010-04-30 09:12:06 -04:00
Родитель 0466fc87f5
Коммит 3f7bc45256
6 изменённых файлов: 143 добавлений и 162 удалений

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

@ -91,6 +91,9 @@
#include "nsIPrivateBrowsingService.h"
#include "nsNetCID.h"
#include "mozilla/Services.h"
#include "Element.h"
using namespace mozilla::dom;
#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
@ -979,11 +982,11 @@ nsCSSRuleProcessor::HasSystemMetric(nsIAtom* aMetric)
}
RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
Element* aElement,
nsRuleWalker* aRuleWalker,
nsCompatibility* aCompat /*= nsnull*/)
: mPresContext(aPresContext),
mContent(aContent),
mElement(aElement),
mRuleWalker(aRuleWalker),
mScopedRoot(nsnull),
mPreviousSiblingData(nsnull),
@ -993,8 +996,7 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
{
MOZ_COUNT_CTOR(RuleProcessorData);
NS_ASSERTION(aContent && aContent->IsNodeOfType(nsINode::eELEMENT),
"non-element leaked into SelectorMatches");
NS_ASSERTION(aElement, "null element leaked into SelectorMatches");
mNthIndices[0][0] = -2;
mNthIndices[0][1] = -2;
@ -1008,34 +1010,33 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
} else if (NS_LIKELY(mPresContext)) {
mCompatMode = mPresContext->CompatibilityMode();
} else {
NS_ASSERTION(aContent, "Must have content");
NS_ASSERTION(aContent->GetOwnerDoc(), "Must have document");
mCompatMode = aContent->GetOwnerDoc()->GetCompatibilityMode();
NS_ASSERTION(aElement->GetOwnerDoc(), "Must have document");
mCompatMode = aElement->GetOwnerDoc()->GetCompatibilityMode();
}
NS_ASSERTION(aContent->GetOwnerDoc(), "Document-less node here?");
NS_ASSERTION(aElement->GetOwnerDoc(), "Document-less node here?");
// get the tag and parent
mContentTag = aContent->Tag();
mParentContent = aContent->GetParent();
mContentTag = aElement->Tag();
mParentContent = aElement->GetParent();
// see if there are attributes for the content
mHasAttributes = aContent->GetAttrCount() > 0;
mHasAttributes = aElement->GetAttrCount() > 0;
if (mHasAttributes) {
// get the ID and classes for the content
mContentID = aContent->GetID();
mClasses = aContent->GetClasses();
mContentID = aElement->GetID();
mClasses = aElement->GetClasses();
} else {
mContentID = nsnull;
mClasses = nsnull;
}
// get the namespace
mNameSpaceID = aContent->GetNameSpaceID();
mNameSpaceID = aElement->GetNameSpaceID();
// check for HTMLContent status
mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
mIsHTML = mIsHTMLContent && aContent->IsInHTMLDocument();
mIsHTML = mIsHTMLContent && aElement->IsInHTMLDocument();
// No need to initialize mContentState; the ContentState() accessor will handle
// that.
@ -1079,7 +1080,7 @@ const nsString* RuleProcessorData::GetLang()
mLanguage = new nsString();
if (!mLanguage)
return nsnull;
for (nsIContent* content = mContent; content;
for (nsIContent* content = mElement; content;
content = content->GetParent()) {
if (content->GetAttrCount() > 0) {
// xml:lang has precedence over lang on HTML elements (see
@ -1108,10 +1109,10 @@ RuleProcessorData::ContentState()
mGotContentState = PR_TRUE;
mContentState = 0;
if (mPresContext) {
mPresContext->EventStateManager()->GetContentState(mContent,
mPresContext->EventStateManager()->GetContentState(mElement,
mContentState);
} else {
mContentState = mContent->IntrinsicState();
mContentState = mElement->IntrinsicState();
}
// If we are not supposed to mark visited links as such, be sure to
@ -1131,7 +1132,7 @@ RuleProcessorData::ContentState()
PRUint32
RuleProcessorData::DocumentState()
{
return mContent->GetOwnerDoc()->GetDocumentState();
return mElement->GetOwnerDoc()->GetDocumentState();
}
PRBool
@ -1175,9 +1176,6 @@ RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
PRBool aCheckEdgeOnly)
{
NS_ASSERTION(mParentContent, "caller should check mParentContent");
NS_ASSERTION(!mPreviousSiblingData ||
mPreviousSiblingData->mContent->IsNodeOfType(nsINode::eELEMENT),
"Unexpected previous sibling data");
PRInt32 &slot = mNthIndices[aIsOfType][aIsFromEnd];
if (slot != -2 && (slot != -1 || aCheckEdgeOnly))
@ -1223,9 +1221,9 @@ RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
break;
}
nsIContent* child = *curChildPtr;
if (child == mContent)
if (child == mElement)
break;
if (child->IsNodeOfType(nsINode::eELEMENT) &&
if (child->IsElement() &&
(!aIsOfType ||
(child->Tag() == mContentTag &&
child->GetNameSpaceID() == mNameSpaceID))) {
@ -1496,7 +1494,7 @@ checkGenericEmptyMatches(RuleProcessorData& data,
PRBool isWhitespaceSignificant)
{
nsIContent *child = nsnull;
nsIContent *element = data.mContent;
Element *element = data.mElement;
PRInt32 index = -1;
if (aTreeMatchContext.mForStyling)
@ -1650,7 +1648,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
{
NS_ASSERTION(pseudoClass->u.mString, "Must have string!");
nsIContent *child = nsnull;
nsIContent *element = data.mContent;
Element *element = data.mElement;
PRInt32 index = -1;
if (aTreeMatchContext.mForStyling)
@ -1689,7 +1687,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
break;
}
nsIDocument* doc = data.mContent->GetDocument();
nsIDocument* doc = data.mElement->GetDocument();
if (doc) {
// Try to get the language from the HTTP header or if this
// is missing as well from the preferences.
@ -1726,14 +1724,14 @@ static PRBool SelectorMatches(RuleProcessorData &data,
break;
case nsCSSPseudoClasses::ePseudoClass_mozBoundElement:
if (data.mScopedRoot != data.mContent) {
if (data.mScopedRoot != data.mElement) {
return PR_FALSE;
}
break;
case nsCSSPseudoClasses::ePseudoClass_root:
if (data.mParentContent != nsnull ||
data.mContent != data.mContent->GetOwnerDoc()->GetRootElement()) {
data.mElement != data.mElement->GetOwnerDoc()->GetRootElement()) {
return PR_FALSE;
}
break;
@ -1776,7 +1774,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
} while (firstNode &&
!IsSignificantChild(firstNode, PR_TRUE, PR_FALSE));
}
if (data.mContent != firstNode) {
if (data.mElement != firstNode) {
return PR_FALSE;
}
}
@ -1803,7 +1801,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
} while (lastNode &&
!IsSignificantChild(lastNode, PR_TRUE, PR_FALSE));
}
if (data.mContent != lastNode) {
if (data.mElement != lastNode) {
return PR_FALSE;
}
}
@ -1864,7 +1862,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
case nsCSSPseudoClasses::ePseudoClass_mozHasHandlerRef:
{
nsIContent *child = nsnull;
nsIContent *element = data.mContent;
Element *element = data.mElement;
PRInt32 index = -1;
do {
@ -1916,7 +1914,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
case nsCSSPseudoClasses::ePseudoClass_mozLWTheme:
{
nsIDocument* doc = data.mContent->GetOwnerDoc();
nsIDocument* doc = data.mElement->GetOwnerDoc();
if (!doc ||
doc->GetDocumentLWTheme() <= nsIDocument::Doc_Theme_None) {
return PR_FALSE;
@ -1926,7 +1924,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
case nsCSSPseudoClasses::ePseudoClass_mozLWThemeBrightText:
{
nsIDocument* doc = data.mContent->GetOwnerDoc();
nsIDocument* doc = data.mElement->GetOwnerDoc();
if (!doc ||
doc->GetDocumentLWTheme() != nsIDocument::Doc_Theme_Bright) {
return PR_FALSE;
@ -1936,7 +1934,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
case nsCSSPseudoClasses::ePseudoClass_mozLWThemeDarkText:
{
nsIDocument* doc = data.mContent->GetOwnerDoc();
nsIDocument* doc = data.mElement->GetOwnerDoc();
if (!doc ||
doc->GetDocumentLWTheme() != nsIDocument::Doc_Theme_Dark) {
return PR_FALSE;
@ -2008,11 +2006,11 @@ static PRBool SelectorMatches(RuleProcessorData &data,
// matches, evaluate for each namespace (the only namespaces that
// have a chance at matching, of course, are ones that the element
// actually has attributes in), short-circuiting if we ever match.
PRUint32 attrCount = data.mContent->GetAttrCount();
PRUint32 attrCount = data.mElement->GetAttrCount();
result = PR_FALSE;
for (PRUint32 i = 0; i < attrCount; ++i) {
const nsAttrName* attrName =
data.mContent->GetAttrNameAt(i);
data.mElement->GetAttrNameAt(i);
NS_ASSERTION(attrName, "GetAttrCount lied or GetAttrNameAt failed");
if (attrName->LocalName() != matchAttribute) {
continue;
@ -2024,7 +2022,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
#ifdef DEBUG
PRBool hasAttr =
#endif
data.mContent->GetAttr(attrName->NamespaceID(),
data.mElement->GetAttr(attrName->NamespaceID(),
attrName->LocalName(), value);
NS_ASSERTION(hasAttr, "GetAttrNameAt lied");
result = AttrMatchesValue(attr, value, data.mIsHTML);
@ -2042,12 +2040,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
}
else if (attr->mFunction == NS_ATTR_FUNC_EQUALS) {
result =
data.mContent->
data.mElement->
AttrValueIs(attr->mNameSpace, matchAttribute, attr->mValue,
(!data.mIsHTML || attr->mCaseSensitive) ? eCaseMatters
: eIgnoreCase);
}
else if (!data.mContent->HasAttr(attr->mNameSpace, matchAttribute)) {
else if (!data.mElement->HasAttr(attr->mNameSpace, matchAttribute)) {
result = PR_FALSE;
}
else if (attr->mFunction != NS_ATTR_FUNC_SET) {
@ -2055,7 +2053,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
#ifdef DEBUG
PRBool hasAttr =
#endif
data.mContent->GetAttr(attr->mNameSpace, matchAttribute, value);
data.mElement->GetAttr(attr->mNameSpace, matchAttribute, value);
NS_ASSERTION(hasAttr, "HasAttr lied");
result = AttrMatchesValue(attr, value, data.mIsHTML);
}
@ -2116,17 +2114,17 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
aLookForRelevantLink = PR_FALSE;
data = prevdata->mPreviousSiblingData;
if (!data) {
nsIContent* content = prevdata->mContent;
nsIContent* parent = prevdata->mParentContent;
if (parent) {
if (aTreeMatchContext.mForStyling)
parent->SetFlags(NODE_HAS_SLOW_SELECTOR_NOAPPEND);
PRInt32 index = parent->IndexOf(content);
PRInt32 index = parent->IndexOf(prevdata->mElement);
while (0 <= --index) {
content = parent->GetChildAt(index);
if (content->IsNodeOfType(nsINode::eELEMENT)) {
data = RuleProcessorData::Create(prevdata->mPresContext, content,
nsIContent* content = parent->GetChildAt(index);
if (content->IsElement()) {
data = RuleProcessorData::Create(prevdata->mPresContext,
content->AsElement(),
prevdata->mRuleWalker,
prevdata->mCompatMode);
prevdata->mPreviousSiblingData = data;
@ -2144,8 +2142,9 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
nsIContent *content = prevdata->mParentContent;
// GetParent could return a document fragment; we only want
// element parents.
if (content && content->IsNodeOfType(nsINode::eELEMENT)) {
data = RuleProcessorData::Create(prevdata->mPresContext, content,
if (content && content->IsElement()) {
data = RuleProcessorData::Create(prevdata->mPresContext,
content->AsElement(),
prevdata->mRuleWalker,
prevdata->mCompatMode);
prevdata->mParentData = data;
@ -2242,9 +2241,6 @@ static void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector,
NS_IMETHODIMP
nsCSSRuleProcessor::RulesMatching(ElementRuleProcessorData *aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
if (cascade) {
@ -2261,9 +2257,6 @@ nsCSSRuleProcessor::RulesMatching(ElementRuleProcessorData *aData)
NS_IMETHODIMP
nsCSSRuleProcessor::RulesMatching(PseudoElementRuleProcessorData* aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
if (cascade) {
@ -2311,9 +2304,6 @@ nsCSSRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
NS_IMETHODIMP
nsCSSRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
if (cascade && cascade->mXULTreeRules.entryCount) {
@ -2345,9 +2335,6 @@ IsSiblingOperator(PRUnichar oper)
nsRestyleHint
nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
// Look up the content node in the state rule list, which points to
@ -2426,9 +2413,6 @@ AttributeEnumFunc(nsCSSSelector* aSelector, AttributeEnumData* aData)
nsRestyleHint
nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
// We could try making use of aData->mModType, but :not rules make it a bit
// of a pain to do so... So just ignore it for now.
@ -2441,7 +2425,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
if ((aData->mAttribute == nsGkAtoms::lwtheme ||
aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
aData->mNameSpaceID == kNameSpaceID_XUL &&
aData->mContent == aData->mContent->GetOwnerDoc()->GetRootElement())
aData->mElement == aData->mElement->GetOwnerDoc()->GetRootElement())
{
data.change = nsRestyleHint(data.change | eRestyle_Self);
}
@ -2456,7 +2440,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
// rules we might stop matching; if the after change notification, the
// ones we might have started matching.
if (cascade) {
if (aData->mAttribute == aData->mContent->GetIDAttributeName()) {
if (aData->mAttribute == aData->mElement->GetIDAttributeName()) {
nsCSSSelector **iter = cascade->mIDSelectors.Elements(),
**end = iter + cascade->mIDSelectors.Length();
for(; iter != end; ++iter) {
@ -2464,7 +2448,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
}
}
if (aData->mAttribute == aData->mContent->GetClassAttributeName()) {
if (aData->mAttribute == aData->mElement->GetClassAttributeName()) {
nsCSSSelector **iter = cascade->mClassSelectors.Elements(),
**end = iter + cascade->mClassSelectors.Length();
for(; iter != end; ++iter) {

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

@ -55,6 +55,9 @@
#include "nsRuleWalker.h"
#include "nsRuleData.h"
#include "nsRuleProcessorData.h"
#include "Element.h"
using namespace mozilla::dom;
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
: mRefCnt(0),
@ -75,24 +78,24 @@ NS_IMPL_ISUPPORTS2(nsHTMLCSSStyleSheet,
NS_IMETHODIMP
nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
{
nsIContent* content = aData->mContent;
Element* element = aData->mElement;
// just get the one and only style rule from the content's STYLE attribute
nsICSSStyleRule* rule = content->GetInlineStyleRule();
nsICSSStyleRule* rule = element->GetInlineStyleRule();
if (rule) {
rule->RuleMatched();
aData->mRuleWalker->Forward(rule);
}
#ifdef MOZ_SMIL
rule = content->GetSMILOverrideStyleRule();
rule = element->GetSMILOverrideStyleRule();
if (rule) {
if (aData->mPresContext->IsProcessingRestyles() &&
!aData->mPresContext->IsProcessingAnimationStyleChange()) {
// Non-animation restyle -- don't process SMIL override style, because we
// don't want SMIL animation to trigger new CSS transitions. Instead,
// request an Animation restyle, so we still get noticed.
aData->mPresContext->PresShell()->RestyleForAnimation(aData->mContent);
aData->mPresContext->PresShell()->RestyleForAnimation(element);
} else {
// Animation restyle (or non-restyle traversal of rules)
// Now we can walk SMIL overrride style, without triggering transitions.

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

@ -70,6 +70,9 @@
#include "nsRuleData.h"
#include "nsContentErrors.h"
#include "nsRuleProcessorData.h"
#include "Element.h"
using namespace mozilla::dom;
NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::HTMLColorRule, nsIStyleRule)
@ -228,65 +231,61 @@ static nsresult GetBodyColor(nsPresContext* aPresContext, nscolor* aColor)
NS_IMETHODIMP
nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
{
nsIContent *content = aData->mContent;
nsRuleWalker *ruleWalker = aData->mRuleWalker;
if (aData->mIsHTMLContent) {
nsIAtom* tag = aData->mContentTag;
if (content) {
nsRuleWalker *ruleWalker = aData->mRuleWalker;
if (aData->mIsHTMLContent) {
nsIAtom* tag = aData->mContentTag;
// if we have anchor colors, check if this is an anchor with an href
if (tag == nsGkAtoms::a) {
if (mLinkRule || mVisitedRule || mActiveRule) {
PRUint32 state = aData->GetContentStateForVisitedHandling(
ruleWalker->VisitedHandling(),
// If the node being matched is a link,
// it's the relevant link.
aData->IsLink());
if (mLinkRule && (state & NS_EVENT_STATE_UNVISITED)) {
ruleWalker->Forward(mLinkRule);
ruleWalker->SetHaveRelevantLink();
}
else if (mVisitedRule && (state & NS_EVENT_STATE_VISITED)) {
ruleWalker->Forward(mVisitedRule);
ruleWalker->SetHaveRelevantLink();
}
// No need to add to the active rule if it's not a link
if (mActiveRule && aData->IsLink() &&
(state & NS_EVENT_STATE_ACTIVE)) {
ruleWalker->Forward(mActiveRule);
}
} // end link/visited/active rules
} // end A tag
// add the rule to handle text-align for a <th>
else if (tag == nsGkAtoms::th) {
ruleWalker->Forward(mTableTHRule);
}
else if (tag == nsGkAtoms::table) {
if (aData->mCompatMode == eCompatibility_NavQuirks) {
nscolor bodyColor;
nsresult rv =
GetBodyColor(ruleWalker->CurrentNode()->GetPresContext(),
&bodyColor);
if (NS_SUCCEEDED(rv) &&
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
NS_IF_RELEASE(mDocumentColorRule);
mDocumentColorRule = new HTMLColorRule();
if (mDocumentColorRule) {
NS_ADDREF(mDocumentColorRule);
mDocumentColorRule->mColor = bodyColor;
}
}
if (mDocumentColorRule)
ruleWalker->Forward(mDocumentColorRule);
// if we have anchor colors, check if this is an anchor with an href
if (tag == nsGkAtoms::a) {
if (mLinkRule || mVisitedRule || mActiveRule) {
PRUint32 state = aData->GetContentStateForVisitedHandling(
ruleWalker->VisitedHandling(),
// If the node being matched is a link,
// it's the relevant link.
aData->IsLink());
if (mLinkRule && (state & NS_EVENT_STATE_UNVISITED)) {
ruleWalker->Forward(mLinkRule);
ruleWalker->SetHaveRelevantLink();
}
else if (mVisitedRule && (state & NS_EVENT_STATE_VISITED)) {
ruleWalker->Forward(mVisitedRule);
ruleWalker->SetHaveRelevantLink();
}
// No need to add to the active rule if it's not a link
if (mActiveRule && aData->IsLink() &&
(state & NS_EVENT_STATE_ACTIVE)) {
ruleWalker->Forward(mActiveRule);
}
} // end link/visited/active rules
} // end A tag
// add the rule to handle text-align for a <th>
else if (tag == nsGkAtoms::th) {
ruleWalker->Forward(mTableTHRule);
}
else if (tag == nsGkAtoms::table) {
if (aData->mCompatMode == eCompatibility_NavQuirks) {
nscolor bodyColor;
nsresult rv =
GetBodyColor(ruleWalker->CurrentNode()->GetPresContext(),
&bodyColor);
if (NS_SUCCEEDED(rv) &&
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
NS_IF_RELEASE(mDocumentColorRule);
mDocumentColorRule = new HTMLColorRule();
if (mDocumentColorRule) {
NS_ADDREF(mDocumentColorRule);
mDocumentColorRule->mColor = bodyColor;
}
}
if (mDocumentColorRule)
ruleWalker->Forward(mDocumentColorRule);
}
} // end html element
}
} // end html element
// just get the style rules from the content
content->WalkContentStyleRules(ruleWalker);
}
aData->mElement->WalkContentStyleRules(ruleWalker);
return NS_OK;
}
@ -326,11 +325,10 @@ nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
// needed.
// Result is true for |href| changes on HTML links if we have link rules.
nsIContent *content = aData->mContent;
Element *element = aData->mElement;
if (aData->mAttribute == nsGkAtoms::href &&
(mLinkRule || mVisitedRule || mActiveRule) &&
content &&
content->IsHTML() &&
element->IsHTML() &&
aData->mContentTag == nsGkAtoms::a) {
return eRestyle_Self;
}
@ -339,7 +337,7 @@ nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
// to descendants of body, when we're already reresolving.
// Handle the content style rules.
if (content && content->IsAttributeMapped(aData->mAttribute)) {
if (element->IsAttributeMapped(aData->mAttribute)) {
return eRestyle_Self;
}

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

@ -61,7 +61,7 @@ class nsAttrValue;
struct RuleProcessorData {
RuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
mozilla::dom::Element* aElement,
nsRuleWalker* aRuleWalker,
nsCompatibility* aCompat = nsnull);
@ -70,16 +70,16 @@ struct RuleProcessorData {
// This should be used for all heap-allocation of RuleProcessorData
static RuleProcessorData* Create(nsPresContext* aPresContext,
nsIContent* aContent,
mozilla::dom::Element* aElement,
nsRuleWalker* aRuleWalker,
nsCompatibility aCompat)
{
if (NS_LIKELY(aPresContext)) {
return new (aPresContext) RuleProcessorData(aPresContext, aContent,
return new (aPresContext) RuleProcessorData(aPresContext, aElement,
aRuleWalker, &aCompat);
}
return new RuleProcessorData(aPresContext, aContent, aRuleWalker,
return new RuleProcessorData(aPresContext, aElement, aRuleWalker,
&aCompat);
}
@ -124,19 +124,19 @@ public:
PRBool aCheckEdgeOnly);
nsPresContext* mPresContext;
nsIContent* mContent; // weak ref, must not be null
nsIContent* mParentContent; // mContent->GetParent(); weak ref
mozilla::dom::Element* mElement; // weak ref, must not be null
nsIContent* mParentContent; // mElement->GetParent(); weak ref
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
nsIContent* mScopedRoot; // Root of scoped stylesheet (set and unset by the supplier of the scoped stylesheet
nsIAtom* mContentTag; // mContent->GetTag()
nsIAtom* mContentID; // mContent->GetID()
PRPackedBool mIsHTMLContent; // whether mContent it's IsHTML()
nsIAtom* mContentTag; // mElement->GetTag()
nsIAtom* mContentID; // mElement->GetID()
PRPackedBool mIsHTMLContent; // whether mElement is IsHTML()
PRPackedBool mIsHTML; // mIsHTMLContent && IsInHTMLDocument()
PRPackedBool mHasAttributes; // mContent->GetAttrCount() > 0
PRPackedBool mHasAttributes; // mElement->GetAttrCount() > 0
nsCompatibility mCompatMode; // Possibly remove use of this in SelectorMatches?
PRInt32 mNameSpaceID; // mContent->GetNameSapce()
const nsAttrValue* mClasses; // mContent->GetClasses()
PRInt32 mNameSpaceID; // mElement->GetNameSapce()
const nsAttrValue* mClasses; // mElement->GetClasses()
// mPreviousSiblingData and mParentData are always RuleProcessorData
// and never a derived class. They are allocated lazily, when
// selectors require matching of prior siblings or ancestors.
@ -156,7 +156,7 @@ private:
// mContentState is initialized lazily.
PRInt32 mContentState; // eventStateMgr->GetContentState() or
// mContent->IntrinsicState() if we have no ESM
// mElement->IntrinsicState() if we have no ESM
// adjusted for not supporting :visited (but with
// visitedness information when we support it)
PRPackedBool mGotContentState;
@ -164,9 +164,9 @@ private:
struct ElementRuleProcessorData : public RuleProcessorData {
ElementRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
mozilla::dom::Element* aElement,
nsRuleWalker* aRuleWalker)
: RuleProcessorData(aPresContext,aContent,aRuleWalker)
: RuleProcessorData(aPresContext, aElement, aRuleWalker)
{
NS_PRECONDITION(aPresContext, "null pointer");
NS_PRECONDITION(aRuleWalker, "null pointer");
@ -175,10 +175,10 @@ struct ElementRuleProcessorData : public RuleProcessorData {
struct PseudoElementRuleProcessorData : public RuleProcessorData {
PseudoElementRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aParentContent,
mozilla::dom::Element* aParentElement,
nsRuleWalker* aRuleWalker,
nsCSSPseudoElements::Type aPseudoType)
: RuleProcessorData(aPresContext, aParentContent, aRuleWalker),
: RuleProcessorData(aPresContext, aParentElement, aRuleWalker),
mPseudoType(aPseudoType)
{
NS_PRECONDITION(aPresContext, "null pointer");
@ -212,11 +212,11 @@ struct AnonBoxRuleProcessorData {
#ifdef MOZ_XUL
struct XULTreeRuleProcessorData : public RuleProcessorData {
XULTreeRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aParentContent,
mozilla::dom::Element* aParentElement,
nsRuleWalker* aRuleWalker,
nsIAtom* aPseudoTag,
nsICSSPseudoComparator* aComparator)
: RuleProcessorData(aPresContext, aParentContent, aRuleWalker),
: RuleProcessorData(aPresContext, aParentElement, aRuleWalker),
mPseudoTag(aPseudoTag),
mComparator(aComparator)
{
@ -233,9 +233,9 @@ struct XULTreeRuleProcessorData : public RuleProcessorData {
struct StateRuleProcessorData : public RuleProcessorData {
StateRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
mozilla::dom::Element* aElement,
PRInt32 aStateMask)
: RuleProcessorData(aPresContext, aContent, nsnull),
: RuleProcessorData(aPresContext, aElement, nsnull),
mStateMask(aStateMask)
{
NS_PRECONDITION(aPresContext, "null pointer");
@ -246,11 +246,11 @@ struct StateRuleProcessorData : public RuleProcessorData {
struct AttributeRuleProcessorData : public RuleProcessorData {
AttributeRuleProcessorData(nsPresContext* aPresContext,
nsIContent* aContent,
mozilla::dom::Element* aElement,
nsIAtom* aAttribute,
PRInt32 aModType,
PRBool aAttrHasChanged)
: RuleProcessorData(aPresContext, aContent, nsnull),
: RuleProcessorData(aPresContext, aElement, nsnull),
mAttribute(aAttribute),
mModType(aModType),
mAttrHasChanged(aAttrHasChanged)

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

@ -736,7 +736,7 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
if (mRuleProcessors[ePresHintSheet])
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
PRBool skipUserStyles = aData->mContent->IsInNativeAnonymousSubtree();
PRBool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
(*aFunc)(mRuleProcessors[eUserSheet], aData);
@ -1181,8 +1181,8 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
struct StatefulData : public StateRuleProcessorData {
StatefulData(nsPresContext* aPresContext,
nsIContent* aContent, PRInt32 aStateMask)
: StateRuleProcessorData(aPresContext, aContent, aStateMask),
Element* aElement, PRInt32 aStateMask)
: StateRuleProcessorData(aPresContext, aElement, aStateMask),
mHint(nsRestyleHint(0))
{}
nsRestyleHint mHint;
@ -1241,9 +1241,9 @@ nsStyleSet::HasStateDependentStyle(nsPresContext* aPresContext,
struct AttributeData : public AttributeRuleProcessorData {
AttributeData(nsPresContext* aPresContext,
nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType,
Element* aElement, nsIAtom* aAttribute, PRInt32 aModType,
PRBool aAttrHasChanged)
: AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType,
: AttributeRuleProcessorData(aPresContext, aElement, aAttribute, aModType,
aAttrHasChanged),
mHint(nsRestyleHint(0))
{}

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

@ -816,12 +816,8 @@ nsresult
nsTransitionManager::WalkTransitionRule(RuleProcessorData* aData,
nsCSSPseudoElements::Type aPseudoType)
{
if (!aData->mContent) {
return NS_OK;
}
ElementTransitions *et =
GetElementTransitions(aData->mContent, aPseudoType, PR_FALSE);
GetElementTransitions(aData->mElement, aPseudoType, PR_FALSE);
if (!et) {
return NS_OK;
}
@ -835,7 +831,7 @@ nsTransitionManager::WalkTransitionRule(RuleProcessorData* aData,
// We need to immediately restyle with animation
// after doing this.
if (et) {
mPresContext->PresShell()->RestyleForAnimation(aData->mContent);
mPresContext->PresShell()->RestyleForAnimation(aData->mElement);
}
return NS_OK;
}