Make nsStyleContext::FindChildWithRules deal with the visited style context. (Bug 147777) r=bzbarsky

This commit is contained in:
L. David Baron 2010-04-02 18:58:26 -07:00
parent e280ee7267
commit 7716822c2c
3 changed files with 31 additions and 6 deletions

View File

@ -168,8 +168,12 @@ void nsStyleContext::RemoveChild(nsStyleContext* aChild)
already_AddRefed<nsStyleContext>
nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
nsRuleNode* aRuleNode)
nsRuleNode* aRuleNode,
nsRuleNode* aRulesIfVisited,
PRBool aRelevantLinkVisited)
{
NS_ABORT_IF_FALSE(aRulesIfVisited || !aRelevantLinkVisited,
"aRelevantLinkVisited should only be set when we have a separate style");
PRUint32 threshold = 10; // The # of siblings we're willing to examine
// before just giving this whole thing up.
@ -179,9 +183,20 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
if (list) {
nsStyleContext *child = list;
do {
if (child->mRuleNode == aRuleNode && child->mPseudoTag == aPseudoTag) {
result = child;
break;
if (child->mRuleNode == aRuleNode &&
child->mPseudoTag == aPseudoTag &&
child->RelevantLinkVisited() == aRelevantLinkVisited) {
PRBool match = PR_FALSE;
if (aRulesIfVisited) {
match = child->GetStyleIfVisited() &&
child->GetStyleIfVisited()->mRuleNode == aRulesIfVisited;
} else {
match = !child->GetStyleIfVisited();
}
if (match) {
result = child;
break;
}
}
child = child->mNextSibling;
threshold--;

View File

@ -115,8 +115,17 @@ public:
NS_STYLE_CONTEXT_TYPE_SHIFT);
}
// Find, if it already exists *and is easily findable* (i.e., near the
// start of the child list), a style context whose:
// * GetPseudo() matches aPseudoTag
// * GetRuleNode() matches aRules
// * !GetStyleIfVisited() == !aRulesIfVisited, and, if they're
// non-null, GetStyleIfVisited()->GetRuleNode() == aRulesIfVisited
// * RelevantLinkVisited() == aRelevantLinkVisited
NS_HIDDEN_(already_AddRefed<nsStyleContext>)
FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules);
FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules,
nsRuleNode* aRulesIfVisited,
PRBool aRelevantLinkVisited);
// Does this style context or any of its ancestors have text
// decorations?

View File

@ -443,7 +443,8 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
nsStyleContext* result = nsnull;
if (aParentContext)
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode).get();
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode,
nsnull, PR_FALSE).get();
#ifdef NOISY_DEBUG
if (result)