Bug 598832 part 16. Use a single TreeMatchContext for all the style resolution that the frame constructor does as part of a single frame construction batch. r=dbaron
This commit is contained in:
@@ -150,6 +150,7 @@
|
||||
#include "nsSVGOuterSVGFrame.h"
|
||||
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "nsRuleProcessorData.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -744,6 +745,8 @@ public:
|
||||
|
||||
nsCOMArray<nsIContent> mGeneratedTextNodesWithInitializer;
|
||||
|
||||
TreeMatchContext mTreeMatchContext;
|
||||
|
||||
// Constructor
|
||||
// Use the passed-in history state.
|
||||
nsFrameConstructorState(nsIPresShell* aPresShell,
|
||||
@@ -906,6 +909,8 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresShell* aPresShe
|
||||
HasTransform()),
|
||||
mHavePendingPopupgroup(PR_FALSE),
|
||||
mCreatingExtraFrames(PR_FALSE),
|
||||
mTreeMatchContext(PR_TRUE, nsRuleWalker::eRelevantLinkUnvisited,
|
||||
aPresShell->GetDocument()),
|
||||
mCurrentPendingBindingInsertionPoint(&mPendingBindings)
|
||||
{
|
||||
#ifdef MOZ_XUL
|
||||
@@ -938,6 +943,8 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresShell* aPresShell,
|
||||
HasTransform()),
|
||||
mHavePendingPopupgroup(PR_FALSE),
|
||||
mCreatingExtraFrames(PR_FALSE),
|
||||
mTreeMatchContext(PR_TRUE, nsRuleWalker::eRelevantLinkUnvisited,
|
||||
aPresShell->GetDocument()),
|
||||
mCurrentPendingBindingInsertionPoint(&mPendingBindings)
|
||||
{
|
||||
#ifdef MOZ_XUL
|
||||
@@ -1688,7 +1695,8 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
|
||||
pseudoStyleContext =
|
||||
styleSet->ProbePseudoElementStyle(aParentContent->AsElement(),
|
||||
aPseudoElement,
|
||||
aStyleContext);
|
||||
aStyleContext,
|
||||
aState.mTreeMatchContext);
|
||||
if (!pseudoStyleContext)
|
||||
return;
|
||||
// |ProbePseudoStyleFor| checked the 'display' property and the
|
||||
@@ -4546,7 +4554,8 @@ nsCSSFrameConstructor::InitAndRestoreFrame(const nsFrameConstructorState& aState
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
|
||||
nsIContent* aContent)
|
||||
nsIContent* aContent,
|
||||
nsFrameConstructorState* aState)
|
||||
{
|
||||
nsStyleContext* parentStyleContext = nsnull;
|
||||
NS_ASSERTION(aContent->GetParent(), "Must have parent here");
|
||||
@@ -4565,17 +4574,24 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
|
||||
// previous page's fixed-pos frame?
|
||||
}
|
||||
|
||||
return ResolveStyleContext(parentStyleContext, aContent);
|
||||
return ResolveStyleContext(parentStyleContext, aContent, aState);
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
|
||||
nsIContent* aContent)
|
||||
nsIContent* aContent,
|
||||
nsFrameConstructorState* aState)
|
||||
{
|
||||
nsStyleSet *styleSet = mPresShell->StyleSet();
|
||||
|
||||
if (aContent->IsElement()) {
|
||||
if (aState) {
|
||||
return styleSet->ResolveStyleFor(aContent->AsElement(),
|
||||
aParentStyleContext,
|
||||
aState->mTreeMatchContext);
|
||||
}
|
||||
return styleSet->ResolveStyleFor(aContent->AsElement(), aParentStyleContext);
|
||||
|
||||
}
|
||||
|
||||
NS_ASSERTION(aContent->IsNodeOfType(nsINode::eTEXT),
|
||||
@@ -5031,7 +5047,7 @@ nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState
|
||||
return;
|
||||
|
||||
nsRefPtr<nsStyleContext> styleContext;
|
||||
styleContext = ResolveStyleContext(aParentFrame, aContent);
|
||||
styleContext = ResolveStyleContext(aParentFrame, aContent, &aState);
|
||||
|
||||
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame,
|
||||
aContent->Tag(), aContent->GetNameSpaceID(),
|
||||
@@ -5113,7 +5129,8 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
|
||||
}
|
||||
|
||||
if (resolveStyle) {
|
||||
styleContext = ResolveStyleContext(styleContext->GetParent(), aContent);
|
||||
styleContext =
|
||||
ResolveStyleContext(styleContext->GetParent(), aContent, &aState);
|
||||
display = styleContext->GetStyleDisplay();
|
||||
aStyleContext = styleContext;
|
||||
}
|
||||
@@ -5829,7 +5846,9 @@ nsCSSFrameConstructor::IsValidSibling(nsIFrame* aSibling,
|
||||
NS_NOTREACHED("Shouldn't happen");
|
||||
return PR_FALSE;
|
||||
}
|
||||
styleContext = ResolveStyleContext(styleParent, aContent);
|
||||
// XXXbz when this code is killed, the state argument to
|
||||
// ResolveStyleContext can be made non-optional.
|
||||
styleContext = ResolveStyleContext(styleParent, aContent, nsnull);
|
||||
if (!styleContext) return PR_FALSE;
|
||||
const nsStyleDisplay* display = styleContext->GetStyleDisplay();
|
||||
aDisplay = display->mDisplay;
|
||||
@@ -10558,7 +10577,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext,
|
||||
mTempFrameTreeState);
|
||||
|
||||
nsRefPtr<nsStyleContext> styleContext;
|
||||
styleContext = ResolveStyleContext(aParentFrame, aChild);
|
||||
styleContext = ResolveStyleContext(aParentFrame, aChild, &state);
|
||||
|
||||
// Pre-check for display "none" - only if we find that, do we create
|
||||
// any frame at all
|
||||
@@ -10941,7 +10960,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState,
|
||||
}
|
||||
|
||||
nsRefPtr<nsStyleContext> childContext =
|
||||
ResolveStyleContext(parentStyleContext, content);
|
||||
ResolveStyleContext(parentStyleContext, content, &aState);
|
||||
|
||||
AddFrameConstructionItemsInternal(aState, content, nsnull, content->Tag(),
|
||||
content->GetNameSpaceID(),
|
||||
|
||||
Reference in New Issue
Block a user