Make style contexts know if they are the if-visited style. (Bug 557287) r=bzbarsky

This commit is contained in:
L. David Baron 2010-04-06 12:42:41 -07:00
parent d93e0789b9
commit 1e8873bdf4
4 changed files with 19 additions and 0 deletions

View File

@ -185,6 +185,7 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
do {
if (child->mRuleNode == aRuleNode &&
child->mPseudoTag == aPseudoTag &&
!child->IsStyleIfVisited() &&
child->RelevantLinkVisited() == aRelevantLinkVisited) {
PRBool match = PR_FALSE;
if (aRulesIfVisited) {

View File

@ -145,6 +145,16 @@ public:
PRBool RelevantLinkVisited() const
{ return !!(mBits & NS_STYLE_RELEVANT_LINK_VISITED); }
// Is this style context the GetStyleIfVisited() for some other style
// context?
PRBool IsStyleIfVisited() const
{ return !!(mBits & NS_STYLE_IS_STYLE_IF_VISITED); }
// Tells this style context that it should return true from
// IsStyleIfVisited.
void SetIsStyleIfVisited()
{ mBits |= NS_STYLE_IS_STYLE_IF_VISITED; }
// Return the style context whose style data should be used for the R,
// G, and B components of color, background-color, and border-*-color
// if RelevantLinkIsVisited().
@ -165,6 +175,11 @@ public:
// To be called only from nsStyleSet.
void SetStyleIfVisited(already_AddRefed<nsStyleContext> aStyleIfVisited)
{
NS_ABORT_IF_FALSE(!IsStyleIfVisited(), "this context is not visited data");
NS_ABORT_IF_FALSE(aStyleIfVisited.get()->IsStyleIfVisited(),
"other context is visited data");
NS_ABORT_IF_FALSE(!aStyleIfVisited.get()->GetStyleIfVisited(),
"other context does not have visited data");
NS_ASSERTION(!mStyleIfVisited, "should only be set once");
mStyleIfVisited = aStyleIfVisited;

View File

@ -500,6 +500,7 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
if (!resultIfVisited) {
return nsnull;
}
resultIfVisited->SetIsStyleIfVisited();
result->SetStyleIfVisited(resultIfVisited.forget());
PRBool relevantLinkVisited =

View File

@ -86,6 +86,8 @@ class imgIContainer;
#define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x02000000
// See nsStyleContext::RelevantLinkIsVisited
#define NS_STYLE_RELEVANT_LINK_VISITED 0x04000000
// See nsStyleContext::IsStyleIfVisited
#define NS_STYLE_IS_STYLE_IF_VISITED 0x08000000
// See nsStyleContext::GetPseudoEnum
#define NS_STYLE_CONTEXT_TYPE_MASK 0xf0000000
#define NS_STYLE_CONTEXT_TYPE_SHIFT 28