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
Родитель 12aeda8a30
Коммит eb2548e97d
3 изменённых файлов: 31 добавлений и 6 удалений

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

@ -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--;

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

@ -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?

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

@ -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)