Bug 1031149 - Consistently pass correct aRelevantLinkVisited to nsStyleContext::FindChildWithRules. r=heycam

I believe this will fix some cache misses in the FindChildWithRules
lookup when restyling.  I don't think it will fix any correctness bugs
because the RelevantLinkVisited() bit will always end up set to true
anyway as the non-link descendant of a visited link style context, and
link descendants shouldn't be able to share styles with non-link
descendants due to matching rules in the UA style sheet.
This commit is contained in:
L. David Baron 2014-08-02 19:37:42 -07:00
parent 8212edadc8
commit f402ea6beb

View File

@ -788,11 +788,15 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
parentIfVisited = aParentContext;
}
bool relevantLinkVisited = (aFlags & eIsLink) ?
(aFlags & eIsVisitedLink) :
(aParentContext && aParentContext->RelevantLinkVisited());
nsRefPtr<nsStyleContext> result;
if (aParentContext)
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode,
aVisitedRuleNode,
aFlags & eIsVisitedLink);
relevantLinkVisited);
#ifdef NOISY_DEBUG
if (result)
@ -816,10 +820,6 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
resultIfVisited->SetIsStyleIfVisited();
result->SetStyleIfVisited(resultIfVisited.forget());
bool relevantLinkVisited = (aFlags & eIsLink) ?
(aFlags & eIsVisitedLink) :
(aParentContext && aParentContext->RelevantLinkVisited());
if (relevantLinkVisited) {
result->AddStyleBit(NS_STYLE_RELEVANT_LINK_VISITED);
}
@ -1306,9 +1306,13 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
uint32_t flags = eNoFlags;
if (aBaseContext->IsLinkContext()) {
flags |= eIsLink;
}
if (aBaseContext->RelevantLinkVisited()) {
flags |= eIsVisitedLink;
// GetContext handles propagating RelevantLinkVisited state from the
// parent in non-link cases; all we need to pass in is if this link
// is visited.
if (aBaseContext->RelevantLinkVisited()) {
flags |= eIsVisitedLink;
}
}
return GetContext(aBaseContext->GetParent(), ruleNode, visitedRuleNode,
aBaseContext->GetPseudo(),
@ -1869,17 +1873,13 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
uint32_t flags = eNoFlags;
if (aStyleContext->IsLinkContext()) {
flags |= eIsLink;
}
// If we're a style context for a link, then we already know whether
// our relevant link is visited, since that does not depend on our
// parent. Otherwise, we need to match aNewParentContext.
bool relevantLinkVisited = aStyleContext->IsLinkContext() ?
aStyleContext->RelevantLinkVisited() :
aNewParentContext->RelevantLinkVisited();
if (relevantLinkVisited) {
flags |= eIsVisitedLink;
// GetContext handles propagating RelevantLinkVisited state from the
// parent in non-link cases; all we need to pass in is if this link
// is visited.
if (aStyleContext->RelevantLinkVisited()) {
flags |= eIsVisitedLink;
}
}
if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||