From fd6fed0d82438375a151eb240ed5269ef3da3c28 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 28 Jan 2004 00:18:22 +0000 Subject: [PATCH] More nsIPresContext deCOMtamination (bug 229371). Removed GetBaseURL, rename GetMedium to Medium and inline it, remove virtual style resolution methods that forward to style set (callers will call style set methods directly). Removed PresContext parameter to StyleSet style resolution functions. r+sr=dbaron. --- content/base/src/nsStyleSet.cpp | 81 +++--- content/base/src/nsStyleSet.h | 25 +- content/html/document/src/nsImageDocument.cpp | 3 +- content/html/style/src/nsComputedDOMStyle.cpp | 7 +- .../html/style/src/nsInspectorCSSUtils.cpp | 9 +- layout/base/nsCSSFrameConstructor.cpp | 238 +++++++++--------- layout/base/nsFrameManager.cpp | 35 +-- layout/base/nsLayoutUtils.h | 6 +- layout/base/nsPresContext.cpp | 76 +----- layout/base/nsPresContext.h | 76 +----- layout/base/public/nsIPresContext.h | 76 +----- layout/base/public/nsLayoutUtils.h | 6 +- layout/base/public/nsPresContext.h | 76 +----- layout/base/src/nsGalleyContext.cpp | 14 +- layout/base/src/nsPresContext.cpp | 76 +----- layout/base/src/nsPresContext.h | 30 +-- layout/base/src/nsPrintContext.cpp | 11 +- layout/base/src/nsPrintPreviewContext.cpp | 11 +- layout/forms/nsButtonFrameRenderer.cpp | 14 +- layout/forms/nsComboboxControlFrame.cpp | 20 +- layout/forms/nsGfxButtonControlFrame.cpp | 4 +- layout/forms/nsHTMLButtonControlFrame.cpp | 10 +- layout/generic/nsBlockFrame.cpp | 8 +- layout/generic/nsBlockFrame.h | 7 +- layout/generic/nsFirstLetterFrame.cpp | 6 +- layout/generic/nsFrameSetFrame.cpp | 22 +- layout/generic/nsInlineFrame.cpp | 7 +- layout/generic/nsTextFrame.cpp | 7 +- layout/html/base/src/nsBlockFrame.cpp | 8 +- layout/html/base/src/nsBlockFrame.h | 7 +- layout/html/base/src/nsFirstLetterFrame.cpp | 6 +- layout/html/base/src/nsFrameManager.cpp | 35 +-- layout/html/base/src/nsInlineFrame.cpp | 7 +- layout/html/base/src/nsTextFrame.cpp | 7 +- layout/html/document/src/nsFrameSetFrame.cpp | 22 +- .../html/forms/src/nsButtonFrameRenderer.cpp | 14 +- .../html/forms/src/nsComboboxControlFrame.cpp | 20 +- .../forms/src/nsGfxButtonControlFrame.cpp | 4 +- .../forms/src/nsHTMLButtonControlFrame.cpp | 10 +- .../html/style/src/nsCSSFrameConstructor.cpp | 238 +++++++++--------- layout/html/table/src/Makefile.in | 1 + layout/html/table/src/nsTableFrame.cpp | 20 +- layout/html/tests/TestInlineFrame.cpp | 19 +- .../base/src/nsMathMLContainerFrame.cpp | 8 +- layout/mathml/base/src/nsMathMLFrame.cpp | 8 +- .../mathml/base/src/nsMathMLmactionFrame.cpp | 6 +- layout/style/nsComputedDOMStyle.cpp | 7 +- layout/style/nsInspectorCSSUtils.cpp | 9 +- layout/style/nsStyleSet.cpp | 81 +++--- layout/style/nsStyleSet.h | 25 +- layout/tables/nsTableFrame.cpp | 20 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 6 +- layout/xul/base/src/nsSplitterFrame.cpp | 4 +- layout/xul/base/src/tree/src/Makefile.in | 1 + .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 8 +- 55 files changed, 648 insertions(+), 914 deletions(-) diff --git a/content/base/src/nsStyleSet.cpp b/content/base/src/nsStyleSet.cpp index 5d58ca76d8a..d0605336886 100644 --- a/content/base/src/nsStyleSet.cpp +++ b/content/base/src/nsStyleSet.cpp @@ -317,11 +317,10 @@ nsStyleSet::EnableQuirkStyleSheet(PRBool aEnable) struct RulesMatchingData : public ElementRuleProcessorData { RulesMatchingData(nsIPresContext* aPresContext, - nsIAtom* aMedium, nsIContent* aContent, nsRuleWalker* aRuleWalker) : ElementRuleProcessorData(aPresContext, aContent, aRuleWalker), - mMedium(aMedium) + mMedium(aPresContext->Medium()) { } nsIAtom* mMedium; @@ -504,27 +503,24 @@ PRBool nsStyleSet::BuildDefaultStyleData(nsIPresContext* aPresContext) } already_AddRefed -nsStyleSet::ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, +nsStyleSet::ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext* presContext = PresContext(); NS_ASSERTION(aContent, "must have content"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(aContent->IsContentOfType(nsIContent::eELEMENT), "content must be element"); - if (aContent && aPresContext) { + if (aContent && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - RulesMatchingData data(aPresContext, medium, aContent, mRuleWalker); + RulesMatchingData data(presContext, aContent, mRuleWalker); FileRules(EnumRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, nsnull).get(); + result = GetContext(presContext, aParentContext, nsnull).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -535,19 +531,17 @@ nsStyleSet::ResolveStyleFor(nsIPresContext* aPresContext, } already_AddRefed -nsStyleSet::ResolveStyleForNonElement(nsIPresContext* aPresContext, - nsStyleContext* aParentContext) +nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); - NS_ASSERTION(aPresContext, "must have pres context"); - - if (aPresContext) { + if (presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - result = GetContext(aPresContext, aParentContext, + result = GetContext(presContext, aParentContext, nsCSSAnonBoxes::mozNonElement).get(); NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root"); } @@ -559,14 +553,13 @@ nsStyleSet::ResolveStyleForNonElement(nsIPresContext* aPresContext, struct PseudoRulesMatchingData : public PseudoRuleProcessorData { PseudoRulesMatchingData(nsIPresContext* aPresContext, - nsIAtom* aMedium, nsIContent* aParentContent, nsIAtom* aPseudoTag, nsICSSPseudoComparator* aComparator, nsRuleWalker* aRuleWalker) : PseudoRuleProcessorData(aPresContext, aParentContent, aPseudoTag, aComparator, aRuleWalker), - mMedium(aMedium) + mMedium(aPresContext->Medium()) { } nsIAtom* mMedium; @@ -582,32 +575,29 @@ EnumPseudoRulesMatching(nsIStyleRuleProcessor* aProcessor, void* aData) } already_AddRefed -nsStyleSet::ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, +nsStyleSet::ResolvePseudoStyleFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, nsStyleContext* aParentContext, nsICSSPseudoComparator* aComparator) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); NS_ASSERTION(aPseudoTag, "must have pseudo tag"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(!aParentContent || aParentContent->IsContentOfType(nsIContent::eELEMENT), "content (if non-null) must be element"); - if (aPseudoTag && aPresContext) { + if (aPseudoTag && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - PseudoRulesMatchingData data(aPresContext, medium, aParentContent, - aPseudoTag, aComparator, mRuleWalker); + PseudoRulesMatchingData data(presContext, aParentContent, aPseudoTag, + aComparator, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); + result = GetContext(presContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -618,32 +608,29 @@ nsStyleSet::ResolvePseudoStyleFor(nsIPresContext* aPresContext, } already_AddRefed -nsStyleSet::ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) +nsStyleSet::ProbePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); NS_ASSERTION(aPseudoTag, "must have pseudo tag"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(!aParentContent || aParentContent->IsContentOfType(nsIContent::eELEMENT), "content (if non-null) must be element"); - if (aPseudoTag && aPresContext) { + if (aPseudoTag && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - PseudoRulesMatchingData data(aPresContext, medium, aParentContent, - aPseudoTag, nsnull, mRuleWalker); + PseudoRulesMatchingData data(presContext, aParentContent, aPseudoTag, + nsnull, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); if (!mRuleWalker->AtRoot()) - result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); + result = GetContext(presContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -762,10 +749,10 @@ nsStyleSet::ReParentStyleContext(nsIPresContext* aPresContext, } struct StatefulData : public StateRuleProcessorData { - StatefulData(nsIPresContext* aPresContext, nsIAtom* aMedium, + StatefulData(nsIPresContext* aPresContext, nsIContent* aContent, PRInt32 aStateMask) : StateRuleProcessorData(aPresContext, aContent, aStateMask), - mMedium(aMedium), + mMedium(aPresContext->Medium()), mHint(nsReStyleHint(0)) {} nsIAtom* mMedium; @@ -795,9 +782,7 @@ nsStyleSet::HasStateDependentStyle(nsIPresContext* aPresContext, mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count())) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - StatefulData data(aPresContext, medium, aContent, aStateMask); + StatefulData data(aPresContext, aContent, aStateMask); WalkRuleProcessors(SheetHasStatefulStyle, &data); result = data.mHint; } @@ -806,10 +791,10 @@ nsStyleSet::HasStateDependentStyle(nsIPresContext* aPresContext, } struct AttributeData : public AttributeRuleProcessorData { - AttributeData(nsIPresContext* aPresContext, nsIAtom* aMedium, - nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) + AttributeData(nsIPresContext* aPresContext, + nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType), - mMedium(aMedium), + mMedium(aPresContext->Medium()), mHint(nsReStyleHint(0)) {} nsIAtom* mMedium; @@ -840,9 +825,7 @@ nsStyleSet::HasAttributeDependentStyle(nsIPresContext* aPresContext, mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count())) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - AttributeData data(aPresContext, medium, aContent, aAttribute, aModType); + AttributeData data(aPresContext, aContent, aAttribute, aModType); WalkRuleProcessors(SheetHasAttributeStyle, &data); result = data.mHint; } diff --git a/content/base/src/nsStyleSet.h b/content/base/src/nsStyleSet.h index fe00880c66f..11b51b3f257 100644 --- a/content/base/src/nsStyleSet.h +++ b/content/base/src/nsStyleSet.h @@ -75,9 +75,7 @@ class nsStyleSet // get a style context for a non-pseudo frame. already_AddRefed - ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsStyleContext* aParentContext); + ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext); // Get a style context for a non-element (which no rules will match). // Eventually, this should go away and we shouldn't even create style @@ -90,26 +88,23 @@ class nsStyleSet // represents everything except the first letter.) // already_AddRefed - ResolveStyleForNonElement(nsIPresContext* aPresContext, - nsStyleContext* aParentContext); + ResolveStyleForNonElement(nsStyleContext* aParentContext); // get a style context for a pseudo-element (i.e., // |aPseudoTag == nsCOMPtr(do_GetAtom(":first-line"))|; already_AddRefed - ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator = nsnull); + ResolvePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator = nsnull); // This funtions just like ResolvePseudoStyleFor except that it will // return nsnull if there are no explicit style rules for that // pseudo element. already_AddRefed - ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext); + ProbePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext); // Begin ignoring style context destruction, to avoid lots of unnecessary // work on document teardown. @@ -213,6 +208,8 @@ class nsStyleSet nsStyleContext* aParentContext, nsIAtom* aPseudoTag); + nsIPresContext* PresContext() { return mRuleTree->GetPresContext(); } + static nsIURI *gQuirkURI; nsCOMArray mSheets[eSheetTypeCount]; diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index be5d8d23f81..575f43f8de4 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -58,6 +58,7 @@ #include "nsIPrefService.h" #include "nsAutoPtr.h" #include "nsMediaDocument.h" +#include "nsStyleSet.h" #define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing" @@ -533,7 +534,7 @@ nsImageDocument::CheckOverflowing() nsCOMPtr content = do_QueryInterface(mBodyContent); nsRefPtr styleContext = - context->ResolveStyleContextFor(content, nsnull); + context->StyleSet()->ResolveStyleFor(content, nsnull); const nsStyleMargin* marginData = styleContext->GetStyleMargin(); nsMargin margin; diff --git a/content/html/style/src/nsComputedDOMStyle.cpp b/content/html/style/src/nsComputedDOMStyle.cpp index ce7ad161c8d..5f95a27fc0e 100644 --- a/content/html/style/src/nsComputedDOMStyle.cpp +++ b/content/html/style/src/nsComputedDOMStyle.cpp @@ -59,6 +59,7 @@ #include "nsIDocument.h" #include "nsCSSPseudoElements.h" +#include "nsStyleSet.h" #if defined(DEBUG_bzbarsky) || defined(DEBUG_caillon) #define DEBUG_ComputedDOMStyle @@ -2912,10 +2913,12 @@ nsComputedDOMStyle::GetStyleData(nsStyleStructID aID, presShell->GetPresContext(getter_AddRefs(pctx)); if (pctx) { nsStyleContext* sctx; + nsStyleSet *styleSet = presShell->StyleSet(); if (!mPseudo) { - sctx = pctx->ResolveStyleContextFor(mContent, nsnull).get(); + sctx = styleSet->ResolveStyleFor(mContent, nsnull).get(); } else { - sctx = pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull).get(); + sctx = styleSet->ResolvePseudoStyleFor(mContent, mPseudo, + nsnull).get(); } if (sctx) { aStyleStruct = sctx->GetStyleData(aID); diff --git a/content/html/style/src/nsInspectorCSSUtils.cpp b/content/html/style/src/nsInspectorCSSUtils.cpp index 5b1f4e79ce8..20771ec20a6 100644 --- a/content/html/style/src/nsInspectorCSSUtils.cpp +++ b/content/html/style/src/nsInspectorCSSUtils.cpp @@ -45,6 +45,7 @@ #include "nsIPresShell.h" #include "nsAutoPtr.h" #include "nsIFrame.h" +#include "nsStyleSet.h" nsInspectorCSSUtils::nsInspectorCSSUtils() { @@ -159,10 +160,12 @@ nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, if (!presContext) return nsnull; - if (aContent->IsContentOfType(nsIContent::eELEMENT)) - return presContext->ResolveStyleContextFor(aContent, parentContext); + nsStyleSet *styleSet = aPresShell->StyleSet(); - return presContext->ResolveStyleContextForNonElement(parentContext); + if (aContent->IsContentOfType(nsIContent::eELEMENT)) + return styleSet->ResolveStyleFor(aContent, parentContext); + + return styleSet->ResolveStyleForNonElement(parentContext); } NS_IMETHODIMP diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index d70e5bd69c4..3c45d7288dd 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1519,11 +1519,13 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe if (!aContent->IsContentOfType(nsIContent::eELEMENT)) return PR_FALSE; + nsStyleSet *styleSet = aPresShell->StyleSet(); + // Probe for the existence of the pseudo-element nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext); + pseudoStyleContext = styleSet->ProbePseudoStyleFor(aContent, + aPseudoElement, + aStyleContext); if (pseudoStyleContext) { // |ProbePseudoStyleContext| checks the 'display' property and the @@ -1540,9 +1542,8 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe } nsStyleContext* parentSC = aStyleContext->GetParent(); nsRefPtr wrapperSC; - wrapperSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, - wrapperPseudo, - parentSC); + wrapperSC = styleSet->ResolvePseudoStyleFor(nsnull, + wrapperPseudo, parentSC); // |aFrame| is already the correct parent. InitAndRestoreFrame(aPresContext, aState, aContent, aFrame, wrapperSC, nsnull, *aWrapperFrame); @@ -1572,7 +1573,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe // Create another pseudo style context to use for all the generated child // frames nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(pseudoStyleContext); // Now create content objects (and child frames) for each value of the // 'content' property @@ -1917,9 +1918,9 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel nsIContent* parentContent = parentFrame->GetContent(); // create the SC for the inner table which will be the parent of the outer table's SC - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::table, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::table, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mTableOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mTableInner; @@ -1965,9 +1966,9 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRowGroup, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableRowGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRowGroup; @@ -2009,9 +2010,9 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableColGroup, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableColGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mColGroup; @@ -2051,9 +2052,9 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRow, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableRow, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRow; @@ -2094,9 +2095,9 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableCell, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableCell, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mCellOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mCellInner; @@ -2462,9 +2463,8 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, // create the pseudo SC for the outer table as a child of the inner SC nsRefPtr outerStyleContext; - outerStyleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::tableOuter, - aStyleContext); + outerStyleContext = aPresShell->StyleSet()-> + ResolvePseudoStyleFor(aContent, nsCSSAnonBoxes::tableOuter, aStyleContext); // Init the table outer frame and see if we need to create a view, e.g. // the frame is absolutely positioned @@ -2854,9 +2854,10 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe // Resolve pseudo style and initialize the body cell frame nsRefPtr innerPseudoStyle; - innerPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::cellContent, - aStyleContext); + innerPseudoStyle = aPresShell->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::cellContent, aStyleContext); + InitAndRestoreFrame(aPresContext, aState, aContent, aNewCellOuterFrame, innerPseudoStyle, nsnull, aNewCellInnerFrame); @@ -3283,8 +3284,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, // --------- CREATE AREA OR BOX FRAME ------- nsRefPtr styleContext; - styleContext = aPresContext->ResolveStyleContextFor(aDocElement, - aParentStyleContext); + styleContext = aPresShell->StyleSet()->ResolveStyleFor(aDocElement, + aParentStyleContext); const nsStyleDisplay* display = styleContext->GetStyleDisplay(); @@ -3519,10 +3520,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // --------- BUILD VIEWPORT ----------- nsIFrame* viewportFrame = nsnull; nsRefPtr viewportPseudoStyle; + nsStyleSet *styleSet = aPresShell->StyleSet(); - viewportPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewport, - nsnull); + viewportPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::viewport, + nsnull); NS_NewViewportFrame(aPresShell, &viewportFrame); @@ -3652,7 +3654,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // see if the style is overflow: hidden, first on the document element nsRefPtr styleContext; - styleContext = aPresContext->ResolveStyleContextFor(aDocElement, nsnull); + styleContext = styleSet->ResolveStyleFor(aDocElement, nsnull); if (styleContext) { const nsStyleDisplay* display = styleContext->GetStyleDisplay(); if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN || @@ -3681,8 +3683,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, if (bodyElement) { nsRefPtr bodyContext; - bodyContext = aPresContext->ResolveStyleContextFor(bodyElement, - styleContext); + bodyContext = styleSet->ResolveStyleFor(bodyElement, styleContext); if (bodyContext) { const nsStyleDisplay* display = bodyContext->GetStyleDisplay(); if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN || @@ -3707,9 +3708,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // If paginated, make sure we don't put scrollbars in if (isPaginated && !printPreviewContext) - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - viewportPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + viewportPseudoStyle); else if (isScrollable) { // Build the frame. We give it the content we are wrapping which is the document, @@ -3718,9 +3719,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // resolve a context for the scrollframe nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewportScroll, - viewportPseudoStyle); + styleContext = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::viewportScroll, + viewportPseudoStyle); nsIFrame* newScrollableFrame = nsnull; @@ -3754,18 +3755,18 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } else { // If no scrollbars and xul, don't build a scrollframe at all. if (isXUL) { - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - viewportPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + viewportPseudoStyle); } else { // if HTML the always create a scrollframe so anchors work. That way you can scroll to // anchors even if we don't have scrollbars. // create a style context for the scrollport of the viewport nsRefPtr scrollPseudoStyle; - scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::scrolledContent, - viewportPseudoStyle); + scrollPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::scrolledContent, + viewportPseudoStyle); // create scrollframe nsIFrame* scrollFrame = nsnull; @@ -3775,9 +3776,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull); // resolve a new style for the root frame - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - scrollPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + scrollPseudoStyle); // Inform the view manager about the root scrollable view nsIView* view = scrollFrame->GetView(); @@ -3851,11 +3852,13 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, return rv; nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresShell->StyleSet(); nsRefPtr pagePseudoStyle; - pagePseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::page, - parentStyleContext); + pagePseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::page, + parentStyleContext); + // Initialize the page frame and force it to have a view. This makes printing of // the pages easier and faster. aPageFrame->Init(aPresContext, nsnull, aParentFrame, pagePseudoStyle, aPrevPageFrame); @@ -3867,9 +3870,10 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, NS_NewPageContentFrame(aPresShell, &aPageContentFrame); nsRefPtr pageContentPseudoStyle; - pageContentPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageContent, - pagePseudoStyle); + pageContentPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::pageContent, + pagePseudoStyle); + // Initialize the page content frame and force it to have a view. Also make it the // containing block for fixed elements which are repeated on every page. aPageContentFrame->Init(aPresContext, nsnull, aPageFrame, pageContentPseudoStyle, nsnull); @@ -3903,7 +3907,8 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, // The placeholder frame gets a pseudo style context nsRefPtr placeholderStyle; nsStyleContext* parentContext = aStyleContext->GetParent(); - placeholderStyle = aPresContext->ResolveStyleContextForNonElement(parentContext); + placeholderStyle = aPresShell->StyleSet()-> + ResolveStyleForNonElement(parentContext); placeholderFrame->Init(aPresContext, aContent, aParentFrame, placeholderStyle, nsnull); @@ -3935,9 +3940,9 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel } nsRefPtr radioStyle; - radioStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::radio, - aStyleContext); + radioStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::radio, + aStyleContext); nsIRadioControlFrame* radio = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&radio))) { radio->SetRadioButtonFaceStyleContext(radioStyle); @@ -3960,9 +3965,9 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell } nsRefPtr checkboxStyle; - checkboxStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::check, - aStyleContext); + checkboxStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::check, + aStyleContext); nsICheckboxControlFrame* checkbox = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsICheckboxControlFrame), (void**)&checkbox))) { @@ -4049,9 +4054,9 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, // Resolve psuedo element style for the dropdown list nsRefPtr listStyle; - listStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::dropDownList, - aStyleContext); + listStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::dropDownList, + aStyleContext); // Initialize the scroll frame positioned. Note that it is NOT // initialized as absolutely positioned. @@ -4303,9 +4308,9 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel // Resolve style and initialize the frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::fieldsetContent, - aStyleContext); + styleContext = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::fieldsetContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, styleContext, nsnull, areaFrame); @@ -5788,17 +5793,19 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh // we used the style that was passed in. So resolve another one. nsRefPtr scrollPseudoStyle; - scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - contentStyle); + nsStyleSet *styleSet = aPresShell->StyleSet(); + + scrollPseudoStyle = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::scrolledContent, + contentStyle); contentStyle = scrollPseudoStyle; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, contentStyle, nsnull, scrollFrame); - nsStyleContext* aScrolledChildStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - aScrolledPseudo, - contentStyle).get(); + nsStyleContext* aScrolledChildStyle = styleSet->ResolvePseudoStyleFor(aContent, + aScrolledPseudo, + contentStyle).get(); aScrollableFrame = scrollFrame; @@ -6509,15 +6516,17 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, parentStyleContext = parentStyleContext->GetParent(); } + nsStyleSet *styleSet = aPresContext->StyleSet(); + if (aContent->IsContentOfType(nsIContent::eELEMENT)) { - return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext); + return styleSet->ResolveStyleFor(aContent, parentStyleContext); } else { NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName, "shouldn't waste time creating style contexts for " "comments and processing instructions"); - return aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + return styleSet->ResolveStyleForNonElement(parentStyleContext); } } @@ -6618,14 +6627,15 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, // block so that it can mix better with other surrounding MathML markups nsStyleContext* parentContext = aParentFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresShell->StyleSet(); // first, create a MathML mrow frame that will wrap the block frame rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); if (NS_FAILED(rv)) return rv; nsRefPtr mrowContext; - mrowContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozMathInline, - parentContext); + mrowContext = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::mozMathInline, + parentContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, mrowContext, nsnull, newFrame); @@ -6634,16 +6644,16 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, rv = NS_NewBlockFrame(aPresShell, &blockFrame); if (NS_FAILED(rv)) return rv; nsRefPtr blockContext; - blockContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mrowContext); + blockContext = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mrowContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, blockContext, nsnull, blockFrame); // then, create the table frame itself nsRefPtr tableContext; - tableContext = aPresContext->ResolveStyleContextFor(aContent, - blockContext); + tableContext = styleSet->ResolveStyleFor(aContent, blockContext); + nsFrameItems tempItems; nsIFrame* outerTable; nsIFrame* innerTable; @@ -6923,9 +6933,9 @@ nsCSSFrameConstructor::ConstructPageBreakFrame(nsIPresShell* aPresShe nsFrameItems& aFrameItems) { nsRefPtr pseudoStyle; - pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageBreak, - aStyleContext); + pseudoStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::pageBreak, + aStyleContext); nsIFrame* pageBreakFrame; nsresult rv = NS_NewPageBreakFrame(aPresShell, &pageBreakFrame); if (NS_SUCCEEDED(rv)) { @@ -10197,7 +10207,8 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, NS_NewTextFrame(aPresShell, &textFrame); nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(aStyleContext); + textStyleContext = aPresShell->StyleSet()-> + ResolveStyleForNonElement(aStyleContext); textFrame->Init(aPresContext, altTextContent, containerFrame, textStyleContext, nsnull); @@ -11214,15 +11225,15 @@ nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIPresContext* aPresContex nsIContent* aContent) { nsresult result = NS_OK; - nsCOMPtr frameManager; - aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); + nsIPresShell *shell = aPresContext->PresShell(); + nsIFrameManager *frameManager = shell->GetFrameManager(); nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent); if (oldContext) { // The parent has a frame, so try resolving a new context. - nsRefPtr newContext = - aPresContext->ResolveStyleContextFor(aContent, - oldContext->GetParent()); + nsRefPtr newContext = shell->StyleSet()-> + ResolveStyleFor(aContent, oldContext->GetParent()); + frameManager->ChangeUndisplayedContent(aContent, newContext); if (newContext->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_NONE) { result = RecreateFramesForContent(aPresContext, aContent); @@ -11330,9 +11341,9 @@ nsCSSFrameConstructor::GetFirstLetterStyle(nsIPresContext* aPresContext, nsStyleContext* aStyleContext) { if (aContent) { - return aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLetter, - aStyleContext); + return aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSPseudoElements::firstLetter, aStyleContext); } return nsnull; } @@ -11343,9 +11354,9 @@ nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, nsStyleContext* aStyleContext) { if (aContent) { - return aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLine, - aStyleContext); + return aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSPseudoElements::firstLine, aStyleContext); } return nsnull; } @@ -11883,6 +11894,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( { // Create the first-letter-frame nsIFrame* letterFrame; + nsStyleSet *styleSet = aPresShell->StyleSet(); NS_NewFirstLetterFrame(aPresShell, &letterFrame); InitAndRestoreFrame(aPresContext, aState, aTextContent, @@ -11893,7 +11905,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // letter frame and will have the float property set on it; the text // frame shouldn't have that set). nsRefPtr textSC; - textSC = aPresContext->ResolveStyleContextForNonElement(aStyleContext); + textSC = styleSet->ResolveStyleForNonElement(aStyleContext); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, aTextFrame); @@ -11920,7 +11932,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( nsStyleContext* parentStyleContext = aStyleContext->GetParent(); if (parentStyleContext) { nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + newSC = styleSet->ResolveStyleForNonElement(parentStyleContext); if (newSC) { nextTextFrame->SetStyleContext(aPresContext, newSC); } @@ -11983,9 +11995,11 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex letterFrame->Init(aPresContext, aTextContent, aParentFrame, sc, nsnull); nsRefPtr textSC; - textSC = aPresContext->ResolveStyleContextForNonElement(sc); + textSC = aPresContext->StyleSet()->ResolveStyleForNonElement(sc); + InitAndRestoreFrame(aPresContext, aState, aTextContent, - letterFrame, textSC, nsnull, textFrame); + letterFrame, textSC, nsnull, textFrame); + letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame); aResult.childList = aResult.lastChild = letterFrame; } @@ -12183,7 +12197,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( return NS_OK; } nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); + newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); if (!newSC) { return NS_OK; } @@ -12271,7 +12285,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, break; } nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); + newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); if (!newSC) { break; } @@ -12638,8 +12652,8 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, } nsRefPtr blockSC; - blockSC = aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, - aStyleContext); + blockSC = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, blockStyle, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, blockSC, nsnull, blockFrame); @@ -13102,9 +13116,9 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, nsStyleContext* styleContext = aFrame->GetStyleContext(); nsRefPtr blockSC; - blockSC = aPresContext->ResolvePseudoStyleContextFor(content, - nsCSSAnonBoxes::mozAnonymousBlock, - styleContext); + blockSC = shell->StyleSet()->ResolvePseudoStyleFor(content, + nsCSSAnonBoxes::mozAnonymousBlock, + styleContext); InitAndRestoreFrame(aPresContext, aState, content, nsnull, blockSC, nsnull, blockFrame); diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index dd123aed5f8..1b113a14ca0 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -1556,6 +1556,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // that the frame has the last reference to it, so AddRef it here. nsStyleContext* oldContext = aFrame->GetStyleContext(); + nsStyleSet* styleSet = aPresContext->StyleSet(); if (oldContext) { oldContext->AddRef(); @@ -1594,7 +1595,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - newContext = aPresContext->ResolveStyleContextForNonElement(parentContext).get(); + newContext = styleSet->ResolveStyleForNonElement(parentContext).get(); } else if (pseudoTag) { nsIContent* pseudoContent = @@ -1602,9 +1603,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after) { // XXX what other pseudos do we need to treat like this? - newContext = aPresContext->ProbePseudoStyleContextFor(pseudoContent, - pseudoTag, - parentContext).get(); + newContext = styleSet->ProbePseudoStyleFor(pseudoContent, + pseudoTag, + parentContext).get(); if (!newContext) { // This pseudo should no longer exist; gotta reframe NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1615,15 +1616,15 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, newContext->AddRef(); } } else { - newContext = aPresContext->ResolvePseudoStyleContextFor(pseudoContent, - pseudoTag, - parentContext).get(); + newContext = styleSet->ResolvePseudoStyleFor(pseudoContent, + pseudoTag, + parentContext).get(); } } else { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - newContext = aPresContext->ResolveStyleContextFor(content, parentContext).get(); + newContext = styleSet->ResolveStyleFor(content, parentContext).get(); } NS_ASSERTION(newContext, "failed to get new style context"); if (newContext) { @@ -1680,9 +1681,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, NS_ASSERTION(pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement, "extra style context is not pseudo element"); - newExtraContext = aPresContext->ResolvePseudoStyleContextFor(content, - pseudoTag, - newContext).get(); + newExtraContext = styleSet->ResolvePseudoStyleFor(content, + pseudoTag, + newContext).get(); if (newExtraContext) { if (oldExtraContext != newExtraContext) { aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, @@ -1707,18 +1708,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsRefPtr undisplayedContext; pseudoTag = undisplayed->mStyle->GetPseudoType(); if (pseudoTag == nsnull) { // child content - undisplayedContext = aPresContext->ResolveStyleContextFor(undisplayed->mContent, - newContext); + undisplayedContext = styleSet->ResolveStyleFor(undisplayed->mContent, + newContext); } else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { - undisplayedContext = aPresContext->ResolveStyleContextForNonElement(newContext); + undisplayedContext = styleSet->ResolveStyleForNonElement(newContext); } else { // pseudo element NS_NOTREACHED("no pseudo elements in undisplayed map"); NS_ASSERTION(pseudoTag, "pseudo element without tag"); - undisplayedContext = aPresContext->ResolvePseudoStyleContextFor(localContent, - pseudoTag, - newContext); + undisplayedContext = styleSet->ResolvePseudoStyleFor(localContent, + pseudoTag, + newContext); } if (undisplayedContext) { const nsStyleDisplay* display = undisplayedContext->GetStyleDisplay(); diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 77d17931605..75b150182ff 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -47,6 +47,7 @@ class nsIView; #include "prtypes.h" #include "nsStyleContext.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" /** * nsLayoutUtils is a namespace class used for various helper @@ -162,9 +163,8 @@ public: nsRefPtr pseudoContext; if (aContent) { - pseudoContext = aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext); + pseudoContext = aPresContext->StyleSet()-> + ProbePseudoStyleFor(aContent, aPseudoElement, aStyleContext); } return pseudoContext != nsnull; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 3fe87211ff4..c4417843fba 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -573,7 +573,7 @@ nsPresContext::GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue) return rv; } -NS_IMETHODIMP +void nsPresContext::ClearStyleDataAndReflow() { if (mShell) { @@ -586,8 +586,6 @@ nsPresContext::ClearStyleDataAndReflow() // then we only need to repaint... mShell->StyleChangeReflow(); } - - return NS_OK; } void @@ -611,7 +609,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) if (mDeviceContext) { mDeviceContext->FlushFontCache(); - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } } @@ -680,13 +678,13 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) { NS_ASSERTION(doc, "expect document here"); if (doc) { - mBaseURL = doc->GetBaseURI(); + nsIURI *baseURI = doc->GetBaseURI(); - if (!mNeverAnimate && mBaseURL) { + if (!mNeverAnimate && baseURI) { PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; - mBaseURL->SchemeIs("chrome", &isChrome); - mBaseURL->SchemeIs("resource", &isRes); + baseURI->SchemeIs("chrome", &isChrome); + baseURI->SchemeIs("resource", &isRes); if (!isChrome && !isRes) mImageAnimationMode = mImageAnimationModePref; @@ -746,7 +744,7 @@ nsPresContext::Observe(nsISupports* aSubject, UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get()); if (mDeviceContext) { mDeviceContext->FlushFontCache(); - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } return NS_OK; } @@ -839,62 +837,11 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) mImageAnimationMode = aMode; } -NS_IMETHODIMP -nsPresContext::GetBaseURL(nsIURI** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mBaseURL; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -already_AddRefed -nsPresContext::ResolveStyleContextFor(nsIContent* aContent, - nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ResolveStyleFor(this, aContent, aParentContext); -} - -already_AddRefed -nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ResolveStyleForNonElement(this, aParentContext); -} - -already_AddRefed -nsPresContext::ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) -{ - return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, - aParentContext, nsnull); -} - -already_AddRefed -nsPresContext::ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) -{ - return mShell->StyleSet()->ResolvePseudoStyleFor(this, aParentContent, - aPseudoTag, aParentContext, - aComparator); -} - -already_AddRefed -nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ProbePseudoStyleFor(this, aParentContent, - aPseudoTag, aParentContext); -} - -NS_IMETHODIMP +nsresult nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) { nsRefPtr sc; - sc = ResolveStyleContextFor(aContent, nsnull); + sc = StyleSet()->ResolveStyleFor(aContent, nsnull); NS_ENSURE_TRUE(sc, NS_ERROR_FAILURE); *aResult = sc->GetStyleDisplay()->mBinding; @@ -1497,7 +1444,7 @@ NS_IMETHODIMP nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow) SetVisualMode(IsVisualCharset(mCharset) ); } if (mShell && aForceReflow) { - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } return NS_OK; } @@ -1621,7 +1568,8 @@ nsPresContext::SysColorChanged() // data without reflowing/updating views will lead to incorrect change hints // later, because when generating change hints, any style structs which have // been cleared and not reread are assumed to not be used at all. - return ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); + return NS_OK; } NS_IMETHODIMP diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 511df07a5d5..c241897f714 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -141,6 +141,9 @@ public: nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } +#ifdef _IMPL_NS_LAYOUT + nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); } +#endif nsIFrameManager* GetFrameManager() { return GetPresShell()->GetFrameManager(); } @@ -165,85 +168,22 @@ public: */ nsILookAndFeel* LookAndFeel() { return mLookAndFeel; } - /** - * Get base url for presentation - */ - NS_IMETHOD GetBaseURL(nsIURI** aURLResult) = 0; - /** * Get medium of presentation */ - NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; + nsIAtom* Medium() { return mMedium; } /** * Clear style data from the root frame downwards, and reflow. */ - NS_IMETHOD ClearStyleDataAndReflow(void) = 0; + virtual void ClearStyleDataAndReflow() = 0; - /** - * Resolve style for the given piece of content that will be a child - * of the aParentContext. Don't use this for pseudo frames. - */ - virtual already_AddRefed - ResolveStyleContextFor(nsIContent* aContent, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a non-element content node (i.e., one that is - * guaranteed not to match any rules). Eventually such nodes - * shouldn't have style contexts at all, but this at least prevents - * the rule matching. - * - * XXX This is temporary. It should go away when we stop creating - * style contexts for text nodes and placeholder frames. (We also use - * it once to create a style context for the nsFirstLetterFrame that - * represents everything except the first letter.) - * - */ - virtual already_AddRefed - ResolveStyleContextForNonElement(nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - - virtual already_AddRefed - ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - * - * Instead of matching solely on aPseudoTag, a comparator function can be - * passed in to test. - */ - virtual already_AddRefed - ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) = 0; - - /** - * Probe style for a pseudo frame within the given aParentContent & aParentContext. - * This will return nsnull id there are no explicit rules for the pseudo element. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - virtual already_AddRefed - ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - /** * Resolve a new style context for a content node and return the URL * for its XBL binding, or null if it has no binding specified in CSS. */ - NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; + virtual nsresult GetXBLBindingURL(nsIContent* aContent, + nsIURI** aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent @@ -568,6 +508,8 @@ protected: // from gfx back to layout. nsIEventStateManager* mEventManager; // [STRONG] nsILookAndFeel* mLookAndFeel; // [STRONG] + nsIAtom* mMedium; // initialized by subclass ctors; + // weak pointer to static atom nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index 511df07a5d5..c241897f714 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -141,6 +141,9 @@ public: nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } +#ifdef _IMPL_NS_LAYOUT + nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); } +#endif nsIFrameManager* GetFrameManager() { return GetPresShell()->GetFrameManager(); } @@ -165,85 +168,22 @@ public: */ nsILookAndFeel* LookAndFeel() { return mLookAndFeel; } - /** - * Get base url for presentation - */ - NS_IMETHOD GetBaseURL(nsIURI** aURLResult) = 0; - /** * Get medium of presentation */ - NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; + nsIAtom* Medium() { return mMedium; } /** * Clear style data from the root frame downwards, and reflow. */ - NS_IMETHOD ClearStyleDataAndReflow(void) = 0; + virtual void ClearStyleDataAndReflow() = 0; - /** - * Resolve style for the given piece of content that will be a child - * of the aParentContext. Don't use this for pseudo frames. - */ - virtual already_AddRefed - ResolveStyleContextFor(nsIContent* aContent, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a non-element content node (i.e., one that is - * guaranteed not to match any rules). Eventually such nodes - * shouldn't have style contexts at all, but this at least prevents - * the rule matching. - * - * XXX This is temporary. It should go away when we stop creating - * style contexts for text nodes and placeholder frames. (We also use - * it once to create a style context for the nsFirstLetterFrame that - * represents everything except the first letter.) - * - */ - virtual already_AddRefed - ResolveStyleContextForNonElement(nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - - virtual already_AddRefed - ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - * - * Instead of matching solely on aPseudoTag, a comparator function can be - * passed in to test. - */ - virtual already_AddRefed - ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) = 0; - - /** - * Probe style for a pseudo frame within the given aParentContent & aParentContext. - * This will return nsnull id there are no explicit rules for the pseudo element. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - virtual already_AddRefed - ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - /** * Resolve a new style context for a content node and return the URL * for its XBL binding, or null if it has no binding specified in CSS. */ - NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; + virtual nsresult GetXBLBindingURL(nsIContent* aContent, + nsIURI** aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent @@ -568,6 +508,8 @@ protected: // from gfx back to layout. nsIEventStateManager* mEventManager; // [STRONG] nsILookAndFeel* mLookAndFeel; // [STRONG] + nsIAtom* mMedium; // initialized by subclass ctors; + // weak pointer to static atom nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; diff --git a/layout/base/public/nsLayoutUtils.h b/layout/base/public/nsLayoutUtils.h index 77d17931605..75b150182ff 100644 --- a/layout/base/public/nsLayoutUtils.h +++ b/layout/base/public/nsLayoutUtils.h @@ -47,6 +47,7 @@ class nsIView; #include "prtypes.h" #include "nsStyleContext.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" /** * nsLayoutUtils is a namespace class used for various helper @@ -162,9 +163,8 @@ public: nsRefPtr pseudoContext; if (aContent) { - pseudoContext = aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext); + pseudoContext = aPresContext->StyleSet()-> + ProbePseudoStyleFor(aContent, aPseudoElement, aStyleContext); } return pseudoContext != nsnull; } diff --git a/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index 511df07a5d5..c241897f714 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -141,6 +141,9 @@ public: nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } +#ifdef _IMPL_NS_LAYOUT + nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); } +#endif nsIFrameManager* GetFrameManager() { return GetPresShell()->GetFrameManager(); } @@ -165,85 +168,22 @@ public: */ nsILookAndFeel* LookAndFeel() { return mLookAndFeel; } - /** - * Get base url for presentation - */ - NS_IMETHOD GetBaseURL(nsIURI** aURLResult) = 0; - /** * Get medium of presentation */ - NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; + nsIAtom* Medium() { return mMedium; } /** * Clear style data from the root frame downwards, and reflow. */ - NS_IMETHOD ClearStyleDataAndReflow(void) = 0; + virtual void ClearStyleDataAndReflow() = 0; - /** - * Resolve style for the given piece of content that will be a child - * of the aParentContext. Don't use this for pseudo frames. - */ - virtual already_AddRefed - ResolveStyleContextFor(nsIContent* aContent, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a non-element content node (i.e., one that is - * guaranteed not to match any rules). Eventually such nodes - * shouldn't have style contexts at all, but this at least prevents - * the rule matching. - * - * XXX This is temporary. It should go away when we stop creating - * style contexts for text nodes and placeholder frames. (We also use - * it once to create a style context for the nsFirstLetterFrame that - * represents everything except the first letter.) - * - */ - virtual already_AddRefed - ResolveStyleContextForNonElement(nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - - virtual already_AddRefed - ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - - /** - * Resolve style for a pseudo frame within the given aParentContent & aParentContext. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - * - * Instead of matching solely on aPseudoTag, a comparator function can be - * passed in to test. - */ - virtual already_AddRefed - ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) = 0; - - /** - * Probe style for a pseudo frame within the given aParentContent & aParentContext. - * This will return nsnull id there are no explicit rules for the pseudo element. - * The tag should be lowercase and inclue the colon. - * ie: NS_NewAtom(":first-line"); - */ - virtual already_AddRefed - ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) = 0; - /** * Resolve a new style context for a content node and return the URL * for its XBL binding, or null if it has no binding specified in CSS. */ - NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; + virtual nsresult GetXBLBindingURL(nsIContent* aContent, + nsIURI** aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent @@ -568,6 +508,8 @@ protected: // from gfx back to layout. nsIEventStateManager* mEventManager; // [STRONG] nsILookAndFeel* mLookAndFeel; // [STRONG] + nsIAtom* mMedium; // initialized by subclass ctors; + // weak pointer to static atom nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; diff --git a/layout/base/src/nsGalleyContext.cpp b/layout/base/src/nsGalleyContext.cpp index 7f344c765ae..06e114be1e8 100644 --- a/layout/base/src/nsGalleyContext.cpp +++ b/layout/base/src/nsGalleyContext.cpp @@ -44,7 +44,6 @@ public: GalleyContext(); ~GalleyContext(); - NS_IMETHOD GetMedium(nsIAtom** aMedium); NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { return NS_ERROR_FAILURE; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); @@ -54,24 +53,13 @@ public: GalleyContext::GalleyContext() { + mMedium = nsLayoutAtoms::screen; } GalleyContext::~GalleyContext() { } -NS_IMETHODIMP -GalleyContext::GetMedium(nsIAtom** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = nsLayoutAtoms::screen; - NS_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP GalleyContext::IsPaginated(PRBool* aResult) { diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index 3fe87211ff4..c4417843fba 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -573,7 +573,7 @@ nsPresContext::GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue) return rv; } -NS_IMETHODIMP +void nsPresContext::ClearStyleDataAndReflow() { if (mShell) { @@ -586,8 +586,6 @@ nsPresContext::ClearStyleDataAndReflow() // then we only need to repaint... mShell->StyleChangeReflow(); } - - return NS_OK; } void @@ -611,7 +609,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) if (mDeviceContext) { mDeviceContext->FlushFontCache(); - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } } @@ -680,13 +678,13 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) { NS_ASSERTION(doc, "expect document here"); if (doc) { - mBaseURL = doc->GetBaseURI(); + nsIURI *baseURI = doc->GetBaseURI(); - if (!mNeverAnimate && mBaseURL) { + if (!mNeverAnimate && baseURI) { PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; - mBaseURL->SchemeIs("chrome", &isChrome); - mBaseURL->SchemeIs("resource", &isRes); + baseURI->SchemeIs("chrome", &isChrome); + baseURI->SchemeIs("resource", &isRes); if (!isChrome && !isRes) mImageAnimationMode = mImageAnimationModePref; @@ -746,7 +744,7 @@ nsPresContext::Observe(nsISupports* aSubject, UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get()); if (mDeviceContext) { mDeviceContext->FlushFontCache(); - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } return NS_OK; } @@ -839,62 +837,11 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) mImageAnimationMode = aMode; } -NS_IMETHODIMP -nsPresContext::GetBaseURL(nsIURI** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mBaseURL; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -already_AddRefed -nsPresContext::ResolveStyleContextFor(nsIContent* aContent, - nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ResolveStyleFor(this, aContent, aParentContext); -} - -already_AddRefed -nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ResolveStyleForNonElement(this, aParentContext); -} - -already_AddRefed -nsPresContext::ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) -{ - return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, - aParentContext, nsnull); -} - -already_AddRefed -nsPresContext::ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) -{ - return mShell->StyleSet()->ResolvePseudoStyleFor(this, aParentContent, - aPseudoTag, aParentContext, - aComparator); -} - -already_AddRefed -nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) -{ - return mShell->StyleSet()->ProbePseudoStyleFor(this, aParentContent, - aPseudoTag, aParentContext); -} - -NS_IMETHODIMP +nsresult nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) { nsRefPtr sc; - sc = ResolveStyleContextFor(aContent, nsnull); + sc = StyleSet()->ResolveStyleFor(aContent, nsnull); NS_ENSURE_TRUE(sc, NS_ERROR_FAILURE); *aResult = sc->GetStyleDisplay()->mBinding; @@ -1497,7 +1444,7 @@ NS_IMETHODIMP nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow) SetVisualMode(IsVisualCharset(mCharset) ); } if (mShell && aForceReflow) { - ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); } return NS_OK; } @@ -1621,7 +1568,8 @@ nsPresContext::SysColorChanged() // data without reflowing/updating views will lead to incorrect change hints // later, because when generating change hints, any style structs which have // been cleared and not reread are assumed to not be used at all. - return ClearStyleDataAndReflow(); + nsPresContext::ClearStyleDataAndReflow(); + return NS_OK; } NS_IMETHODIMP diff --git a/layout/base/src/nsPresContext.h b/layout/base/src/nsPresContext.h index 51cd98c1bc4..203ebca75e8 100644 --- a/layout/base/src/nsPresContext.h +++ b/layout/base/src/nsPresContext.h @@ -71,33 +71,9 @@ public: NS_IMETHOD SetShell(nsIPresShell* aShell); virtual void SetCompatibilityMode(nsCompatibility aMode); virtual void SetImageAnimationMode(PRUint16 aMode); - NS_IMETHOD GetBaseURL(nsIURI** aURLResult); - NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; - NS_IMETHOD ClearStyleDataAndReflow(void); + virtual void ClearStyleDataAndReflow(); - virtual already_AddRefed - ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext); - - virtual already_AddRefed - ResolveStyleContextForNonElement(nsStyleContext* aParentContext); - - virtual already_AddRefed - ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext); - - virtual already_AddRefed - ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator); - - virtual already_AddRefed - ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext); - - NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult); + virtual nsresult GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult); NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext); NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult); @@ -245,8 +221,6 @@ protected: nsSupportsHashtable mImageLoaders; - nsCOMPtr mBaseURL; - PRPackedBool mImageAnimationStopped; // image animation stopped PRPackedBool mNeverAnimate; // never animate images diff --git a/layout/base/src/nsPrintContext.cpp b/layout/base/src/nsPrintContext.cpp index 23ebfb90a8e..18706438fa0 100644 --- a/layout/base/src/nsPrintContext.cpp +++ b/layout/base/src/nsPrintContext.cpp @@ -59,7 +59,6 @@ public: PrintContext(); ~PrintContext(); - NS_IMETHOD GetMedium(nsIAtom** aMedium); NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { return NS_ERROR_FAILURE; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); @@ -82,6 +81,7 @@ PrintContext::PrintContext() : // Printed images are never animated mImageAnimationMode = imgIContainer::kDontAnimMode; mNeverAnimate = PR_TRUE; + mMedium = nsLayoutAtoms::print; } PrintContext::~PrintContext() @@ -107,15 +107,6 @@ PrintContext::QueryInterface(REFNSIID aIID, void** aInstancePtr) return nsPresContext::QueryInterface(aIID, aInstancePtr); } -NS_IMETHODIMP -PrintContext::GetMedium(nsIAtom** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = nsLayoutAtoms::print; - NS_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP PrintContext::IsPaginated(PRBool* aResult) { diff --git a/layout/base/src/nsPrintPreviewContext.cpp b/layout/base/src/nsPrintPreviewContext.cpp index 22b938d718c..62f7b9b2ac6 100644 --- a/layout/base/src/nsPrintPreviewContext.cpp +++ b/layout/base/src/nsPrintPreviewContext.cpp @@ -56,7 +56,6 @@ public: // another class. Only the base class should use NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS_INHERITED - NS_IMETHOD GetMedium(nsIAtom** aMedium); NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { mCanPaginatedScroll = aResult; return NS_OK; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); @@ -85,6 +84,7 @@ PrintPreviewContext::PrintPreviewContext() : // Printed images are never animated mImageAnimationMode = imgIContainer::kDontAnimMode; mNeverAnimate = PR_TRUE; + mMedium = nsLayoutAtoms::print; } PrintPreviewContext::~PrintPreviewContext() @@ -108,15 +108,6 @@ PrintPreviewContext::QueryInterface(REFNSIID aIID, void** aInstancePtr) return nsPresContext::QueryInterface(aIID, aInstancePtr); } -NS_IMETHODIMP -PrintPreviewContext::GetMedium(nsIAtom** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = nsLayoutAtoms::print; - NS_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP PrintPreviewContext::IsPaginated(PRBool* aResult) { diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 4991027a6f5..0d61a5dbb2d 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -43,6 +43,7 @@ #include "nsHTMLAtoms.h" #include "nsCSSPseudoElements.h" #include "nsINameSpaceManager.h" +#include "nsStyleSet.h" #define ACTIVE "active" #define HOVER "hover" @@ -309,16 +310,17 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext) { // get all the styles nsStyleContext* context = mFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresContext->StyleSet(); // style for the inner such as a dotted line (Windows) - mInnerFocusStyle = aPresContext->ProbePseudoStyleContextFor(mFrame->GetContent(), - nsCSSPseudoElements::mozFocusInner, - context); + mInnerFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(), + nsCSSPseudoElements::mozFocusInner, + context); // style for outer focus like a ridged border (MAC). - mOuterFocusStyle = aPresContext->ProbePseudoStyleContextFor(mFrame->GetContent(), - nsCSSPseudoElements::mozFocusOuter, - context); + mOuterFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(), + nsCSSPseudoElements::mozFocusOuter, + context); } nsStyleContext* diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index cf05ebd7c8a..5fbd41d25d1 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -84,6 +84,7 @@ #include "nsIDOMNode.h" #include "nsGUIEvent.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -2031,15 +2032,17 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) } nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); + nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); if (NS_FAILED(rv)) { return rv; } if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); + styleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozDisplayComboboxControlFrame, + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // create a text frame and put it inside the block frame @@ -2047,7 +2050,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); @@ -2159,6 +2162,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (aContent == content.get()) { // Get PresShell nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); // Start by by creating a containing frame nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); @@ -2167,9 +2171,9 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, // create the style context for the anonymous block frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); + styleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozDisplayComboboxControlFrame, + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // Create a text frame and put it inside the block frame @@ -2177,7 +2181,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } // initialize the text frame diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index bc5700fffa1..3d302a1e9c4 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -51,6 +51,7 @@ #include "nsLayoutAtoms.h" #include "nsReflowPath.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" // MouseEvent suppression in PP #include "nsGUIEvent.h" @@ -237,7 +238,8 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = aPresContext->StyleSet()-> + ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } if (styleContext) { diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 760e53e17e8..730cb59fdce 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -71,6 +71,7 @@ #include "nsIServiceManager.h" #include "nsIDOMHTMLButtonElement.h" #include "nsIDOMHTMLInputElement.h" +#include "nsStyleSet.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -137,14 +138,15 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, } nsIFrame* areaFrame; - NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, flags); + nsIPresShell *shell = aPresContext->PresShell(); + NS_NewAreaFrame(shell, &areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::buttonContent, - mStyleContext); + styleContext = shell->StyleSet()->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::buttonContent, + mStyleContext); mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull); return rv; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index fc641b3aae7..58e016b7b5c 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -5935,10 +5935,14 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, pseudoElement = nsCSSPseudoElements::mozListNumber; break; } - nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); + + nsIPresShell *shell = aPresContext->PresShell(); + + nsRefPtr kidSC = shell->StyleSet()-> + ResolvePseudoStyleFor(mContent, pseudoElement, mStyleContext); // Create bullet frame - mBullet = new (aPresContext->PresShell()) nsBulletFrame; + mBullet = new (shell) nsBulletFrame; if (nsnull == mBullet) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index f0d6d070f16..11dda627530 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -44,6 +44,7 @@ #include "nsLineBox.h" #include "nsReflowPath.h" #include "nsCSSPseudoElements.h" +#include "nsStyleSet.h" class nsBlockReflowState; class nsBulletFrame; @@ -205,9 +206,9 @@ protected: already_AddRefed GetFirstLetterStyle(nsIPresContext* aPresContext) { - return aPresContext->ProbePseudoStyleContextFor(mContent, - nsCSSPseudoElements::firstLetter, - mStyleContext); + return aPresContext->StyleSet()-> + ProbePseudoStyleFor(mContent, + nsCSSPseudoElements::firstLetter, mStyleContext); } /* diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index d1fbfd6e0b1..41f58980d40 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -43,6 +43,7 @@ #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -142,7 +143,8 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext, // a style context like we would for a text node. nsStyleContext* parentStyleContext = aContext->GetParent(); if (parentStyleContext) { - newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + newSC = aPresContext->StyleSet()-> + ResolveStyleForNonElement(parentStyleContext); if (newSC) aContext = newSC; } @@ -370,7 +372,7 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext) if (kidContent) { NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT), "should contain only text nodes"); - sc = aPresContext->ResolveStyleContextForNonElement(mStyleContext); + sc = aPresContext->StyleSet()->ResolveStyleForNonElement(mStyleContext); if (sc) { kid->SetStyleContext(aPresContext, sc); } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 3895c857734..4cf82af24dc 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -56,6 +56,7 @@ #include "nsCSSPseudoElements.h" #include "nsCSSAnonBoxes.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 @@ -403,7 +404,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsRefPtr kidSC; nsresult result; - kidSC = aPresContext->ResolveStyleContextFor(child, mStyleContext); + kidSC = shell->StyleSet()->ResolveStyleFor(child, mStyleContext); if (tag == nsHTMLAtoms::frameset) { result = NS_NewHTMLFramesetFrame(shell, &frame); @@ -445,9 +446,9 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, // should just have null content, if we support that nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame; nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::framesetBlank, - mStyleContext); + pseudoStyleContext = shell->StyleSet()->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::framesetBlank, + mStyleContext); if(blankFrame) blankFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); @@ -979,6 +980,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); //printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight); // Always get the size so that the caller knows how big we are @@ -1073,9 +1075,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, PR_FALSE, PR_FALSE); nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSPseudoElements::horizontalFramesetBorder, - mStyleContext); + pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSPseudoElements::horizontalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); mChildCount++; @@ -1102,9 +1104,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, PR_TRUE, PR_FALSE); nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSPseudoElements::verticalFramesetBorder, - mStyleContext); + pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSPseudoElements::verticalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); mChildCount++; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 8f255f8b42c..e0d954e88cf 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -1053,9 +1053,10 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, // style context thus removing the :first-line style. This way // we behave as if an anonymous (unstyled) span was the child // of the parent frame. - nsRefPtr newSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::mozLineFrame, - parentContext); + nsRefPtr newSC; + newSC = aPresContext->StyleSet()-> + ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::mozLineFrame, parentContext); if (newSC) { // Switch to the new style context. SetStyleContext(aPresContext, newSC); diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 580ea011140..78e95542c61 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -94,6 +94,7 @@ #endif #include "nsGUIEvent.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" #include "nsBidiFrames.h" #include "nsBidiPresUtils.h" @@ -1006,9 +1007,9 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, if (aContent) { nsRefPtr sc; - sc = aPresContext->ProbePseudoStyleContextFor(aContent->GetParent(), - nsCSSPseudoElements::mozSelection, - aStyleContext); + sc = aPresContext->StyleSet()-> + ProbePseudoStyleFor(aContent->GetParent(), + nsCSSPseudoElements::mozSelection, aStyleContext); if (sc) { mSelectionPseudoStyle = PR_TRUE; const nsStyleBackground* bg = sc->GetStyleBackground(); diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index fc641b3aae7..58e016b7b5c 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -5935,10 +5935,14 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, pseudoElement = nsCSSPseudoElements::mozListNumber; break; } - nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); + + nsIPresShell *shell = aPresContext->PresShell(); + + nsRefPtr kidSC = shell->StyleSet()-> + ResolvePseudoStyleFor(mContent, pseudoElement, mStyleContext); // Create bullet frame - mBullet = new (aPresContext->PresShell()) nsBulletFrame; + mBullet = new (shell) nsBulletFrame; if (nsnull == mBullet) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/html/base/src/nsBlockFrame.h b/layout/html/base/src/nsBlockFrame.h index f0d6d070f16..11dda627530 100644 --- a/layout/html/base/src/nsBlockFrame.h +++ b/layout/html/base/src/nsBlockFrame.h @@ -44,6 +44,7 @@ #include "nsLineBox.h" #include "nsReflowPath.h" #include "nsCSSPseudoElements.h" +#include "nsStyleSet.h" class nsBlockReflowState; class nsBulletFrame; @@ -205,9 +206,9 @@ protected: already_AddRefed GetFirstLetterStyle(nsIPresContext* aPresContext) { - return aPresContext->ProbePseudoStyleContextFor(mContent, - nsCSSPseudoElements::firstLetter, - mStyleContext); + return aPresContext->StyleSet()-> + ProbePseudoStyleFor(mContent, + nsCSSPseudoElements::firstLetter, mStyleContext); } /* diff --git a/layout/html/base/src/nsFirstLetterFrame.cpp b/layout/html/base/src/nsFirstLetterFrame.cpp index d1fbfd6e0b1..41f58980d40 100644 --- a/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/layout/html/base/src/nsFirstLetterFrame.cpp @@ -43,6 +43,7 @@ #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -142,7 +143,8 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext, // a style context like we would for a text node. nsStyleContext* parentStyleContext = aContext->GetParent(); if (parentStyleContext) { - newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + newSC = aPresContext->StyleSet()-> + ResolveStyleForNonElement(parentStyleContext); if (newSC) aContext = newSC; } @@ -370,7 +372,7 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext) if (kidContent) { NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT), "should contain only text nodes"); - sc = aPresContext->ResolveStyleContextForNonElement(mStyleContext); + sc = aPresContext->StyleSet()->ResolveStyleForNonElement(mStyleContext); if (sc) { kid->SetStyleContext(aPresContext, sc); } diff --git a/layout/html/base/src/nsFrameManager.cpp b/layout/html/base/src/nsFrameManager.cpp index dd123aed5f8..1b113a14ca0 100644 --- a/layout/html/base/src/nsFrameManager.cpp +++ b/layout/html/base/src/nsFrameManager.cpp @@ -1556,6 +1556,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // that the frame has the last reference to it, so AddRef it here. nsStyleContext* oldContext = aFrame->GetStyleContext(); + nsStyleSet* styleSet = aPresContext->StyleSet(); if (oldContext) { oldContext->AddRef(); @@ -1594,7 +1595,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - newContext = aPresContext->ResolveStyleContextForNonElement(parentContext).get(); + newContext = styleSet->ResolveStyleForNonElement(parentContext).get(); } else if (pseudoTag) { nsIContent* pseudoContent = @@ -1602,9 +1603,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after) { // XXX what other pseudos do we need to treat like this? - newContext = aPresContext->ProbePseudoStyleContextFor(pseudoContent, - pseudoTag, - parentContext).get(); + newContext = styleSet->ProbePseudoStyleFor(pseudoContent, + pseudoTag, + parentContext).get(); if (!newContext) { // This pseudo should no longer exist; gotta reframe NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1615,15 +1616,15 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, newContext->AddRef(); } } else { - newContext = aPresContext->ResolvePseudoStyleContextFor(pseudoContent, - pseudoTag, - parentContext).get(); + newContext = styleSet->ResolvePseudoStyleFor(pseudoContent, + pseudoTag, + parentContext).get(); } } else { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - newContext = aPresContext->ResolveStyleContextFor(content, parentContext).get(); + newContext = styleSet->ResolveStyleFor(content, parentContext).get(); } NS_ASSERTION(newContext, "failed to get new style context"); if (newContext) { @@ -1680,9 +1681,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, NS_ASSERTION(pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement, "extra style context is not pseudo element"); - newExtraContext = aPresContext->ResolvePseudoStyleContextFor(content, - pseudoTag, - newContext).get(); + newExtraContext = styleSet->ResolvePseudoStyleFor(content, + pseudoTag, + newContext).get(); if (newExtraContext) { if (oldExtraContext != newExtraContext) { aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, @@ -1707,18 +1708,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsRefPtr undisplayedContext; pseudoTag = undisplayed->mStyle->GetPseudoType(); if (pseudoTag == nsnull) { // child content - undisplayedContext = aPresContext->ResolveStyleContextFor(undisplayed->mContent, - newContext); + undisplayedContext = styleSet->ResolveStyleFor(undisplayed->mContent, + newContext); } else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { - undisplayedContext = aPresContext->ResolveStyleContextForNonElement(newContext); + undisplayedContext = styleSet->ResolveStyleForNonElement(newContext); } else { // pseudo element NS_NOTREACHED("no pseudo elements in undisplayed map"); NS_ASSERTION(pseudoTag, "pseudo element without tag"); - undisplayedContext = aPresContext->ResolvePseudoStyleContextFor(localContent, - pseudoTag, - newContext); + undisplayedContext = styleSet->ResolvePseudoStyleFor(localContent, + pseudoTag, + newContext); } if (undisplayedContext) { const nsStyleDisplay* display = undisplayedContext->GetStyleDisplay(); diff --git a/layout/html/base/src/nsInlineFrame.cpp b/layout/html/base/src/nsInlineFrame.cpp index 8f255f8b42c..e0d954e88cf 100644 --- a/layout/html/base/src/nsInlineFrame.cpp +++ b/layout/html/base/src/nsInlineFrame.cpp @@ -1053,9 +1053,10 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, // style context thus removing the :first-line style. This way // we behave as if an anonymous (unstyled) span was the child // of the parent frame. - nsRefPtr newSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::mozLineFrame, - parentContext); + nsRefPtr newSC; + newSC = aPresContext->StyleSet()-> + ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::mozLineFrame, parentContext); if (newSC) { // Switch to the new style context. SetStyleContext(aPresContext, newSC); diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index 580ea011140..78e95542c61 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -94,6 +94,7 @@ #endif #include "nsGUIEvent.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" #include "nsBidiFrames.h" #include "nsBidiPresUtils.h" @@ -1006,9 +1007,9 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, if (aContent) { nsRefPtr sc; - sc = aPresContext->ProbePseudoStyleContextFor(aContent->GetParent(), - nsCSSPseudoElements::mozSelection, - aStyleContext); + sc = aPresContext->StyleSet()-> + ProbePseudoStyleFor(aContent->GetParent(), + nsCSSPseudoElements::mozSelection, aStyleContext); if (sc) { mSelectionPseudoStyle = PR_TRUE; const nsStyleBackground* bg = sc->GetStyleBackground(); diff --git a/layout/html/document/src/nsFrameSetFrame.cpp b/layout/html/document/src/nsFrameSetFrame.cpp index 3895c857734..4cf82af24dc 100644 --- a/layout/html/document/src/nsFrameSetFrame.cpp +++ b/layout/html/document/src/nsFrameSetFrame.cpp @@ -56,6 +56,7 @@ #include "nsCSSPseudoElements.h" #include "nsCSSAnonBoxes.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 @@ -403,7 +404,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsRefPtr kidSC; nsresult result; - kidSC = aPresContext->ResolveStyleContextFor(child, mStyleContext); + kidSC = shell->StyleSet()->ResolveStyleFor(child, mStyleContext); if (tag == nsHTMLAtoms::frameset) { result = NS_NewHTMLFramesetFrame(shell, &frame); @@ -445,9 +446,9 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, // should just have null content, if we support that nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame; nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::framesetBlank, - mStyleContext); + pseudoStyleContext = shell->StyleSet()->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::framesetBlank, + mStyleContext); if(blankFrame) blankFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); @@ -979,6 +980,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); //printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight); // Always get the size so that the caller knows how big we are @@ -1073,9 +1075,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, PR_FALSE, PR_FALSE); nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSPseudoElements::horizontalFramesetBorder, - mStyleContext); + pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSPseudoElements::horizontalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); mChildCount++; @@ -1102,9 +1104,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, PR_TRUE, PR_FALSE); nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSPseudoElements::verticalFramesetBorder, - mStyleContext); + pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSPseudoElements::verticalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); mChildCount++; diff --git a/layout/html/forms/src/nsButtonFrameRenderer.cpp b/layout/html/forms/src/nsButtonFrameRenderer.cpp index 4991027a6f5..0d61a5dbb2d 100644 --- a/layout/html/forms/src/nsButtonFrameRenderer.cpp +++ b/layout/html/forms/src/nsButtonFrameRenderer.cpp @@ -43,6 +43,7 @@ #include "nsHTMLAtoms.h" #include "nsCSSPseudoElements.h" #include "nsINameSpaceManager.h" +#include "nsStyleSet.h" #define ACTIVE "active" #define HOVER "hover" @@ -309,16 +310,17 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext) { // get all the styles nsStyleContext* context = mFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresContext->StyleSet(); // style for the inner such as a dotted line (Windows) - mInnerFocusStyle = aPresContext->ProbePseudoStyleContextFor(mFrame->GetContent(), - nsCSSPseudoElements::mozFocusInner, - context); + mInnerFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(), + nsCSSPseudoElements::mozFocusInner, + context); // style for outer focus like a ridged border (MAC). - mOuterFocusStyle = aPresContext->ProbePseudoStyleContextFor(mFrame->GetContent(), - nsCSSPseudoElements::mozFocusOuter, - context); + mOuterFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(), + nsCSSPseudoElements::mozFocusOuter, + context); } nsStyleContext* diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index cf05ebd7c8a..5fbd41d25d1 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -84,6 +84,7 @@ #include "nsIDOMNode.h" #include "nsGUIEvent.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -2031,15 +2032,17 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) } nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); + nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); if (NS_FAILED(rv)) { return rv; } if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); + styleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozDisplayComboboxControlFrame, + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // create a text frame and put it inside the block frame @@ -2047,7 +2050,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); @@ -2159,6 +2162,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (aContent == content.get()) { // Get PresShell nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); // Start by by creating a containing frame nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); @@ -2167,9 +2171,9 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, // create the style context for the anonymous block frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); + styleContext = styleSet->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozDisplayComboboxControlFrame, + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // Create a text frame and put it inside the block frame @@ -2177,7 +2181,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } // initialize the text frame diff --git a/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/layout/html/forms/src/nsGfxButtonControlFrame.cpp index bc5700fffa1..3d302a1e9c4 100644 --- a/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -51,6 +51,7 @@ #include "nsLayoutAtoms.h" #include "nsReflowPath.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" // MouseEvent suppression in PP #include "nsGUIEvent.h" @@ -237,7 +238,8 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); + textStyleContext = aPresContext->StyleSet()-> + ResolveStyleForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } if (styleContext) { diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index 760e53e17e8..730cb59fdce 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -71,6 +71,7 @@ #include "nsIServiceManager.h" #include "nsIDOMHTMLButtonElement.h" #include "nsIDOMHTMLInputElement.h" +#include "nsStyleSet.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -137,14 +138,15 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, } nsIFrame* areaFrame; - NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, flags); + nsIPresShell *shell = aPresContext->PresShell(); + NS_NewAreaFrame(shell, &areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::buttonContent, - mStyleContext); + styleContext = shell->StyleSet()->ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::buttonContent, + mStyleContext); mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull); return rv; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index d70e5bd69c4..3c45d7288dd 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1519,11 +1519,13 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe if (!aContent->IsContentOfType(nsIContent::eELEMENT)) return PR_FALSE; + nsStyleSet *styleSet = aPresShell->StyleSet(); + // Probe for the existence of the pseudo-element nsRefPtr pseudoStyleContext; - pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext); + pseudoStyleContext = styleSet->ProbePseudoStyleFor(aContent, + aPseudoElement, + aStyleContext); if (pseudoStyleContext) { // |ProbePseudoStyleContext| checks the 'display' property and the @@ -1540,9 +1542,8 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe } nsStyleContext* parentSC = aStyleContext->GetParent(); nsRefPtr wrapperSC; - wrapperSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, - wrapperPseudo, - parentSC); + wrapperSC = styleSet->ResolvePseudoStyleFor(nsnull, + wrapperPseudo, parentSC); // |aFrame| is already the correct parent. InitAndRestoreFrame(aPresContext, aState, aContent, aFrame, wrapperSC, nsnull, *aWrapperFrame); @@ -1572,7 +1573,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe // Create another pseudo style context to use for all the generated child // frames nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext); + textStyleContext = styleSet->ResolveStyleForNonElement(pseudoStyleContext); // Now create content objects (and child frames) for each value of the // 'content' property @@ -1917,9 +1918,9 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel nsIContent* parentContent = parentFrame->GetContent(); // create the SC for the inner table which will be the parent of the outer table's SC - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::table, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::table, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mTableOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mTableInner; @@ -1965,9 +1966,9 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRowGroup, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableRowGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRowGroup; @@ -2009,9 +2010,9 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableColGroup, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableColGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mColGroup; @@ -2051,9 +2052,9 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRow, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableRow, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRow; @@ -2094,9 +2095,9 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell parentStyle = parentFrame->GetStyleContext(); nsIContent* parentContent = parentFrame->GetContent(); - childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableCell, - parentStyle); + childStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(parentContent, + nsCSSAnonBoxes::tableCell, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mCellOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mCellInner; @@ -2462,9 +2463,8 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, // create the pseudo SC for the outer table as a child of the inner SC nsRefPtr outerStyleContext; - outerStyleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::tableOuter, - aStyleContext); + outerStyleContext = aPresShell->StyleSet()-> + ResolvePseudoStyleFor(aContent, nsCSSAnonBoxes::tableOuter, aStyleContext); // Init the table outer frame and see if we need to create a view, e.g. // the frame is absolutely positioned @@ -2854,9 +2854,10 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe // Resolve pseudo style and initialize the body cell frame nsRefPtr innerPseudoStyle; - innerPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::cellContent, - aStyleContext); + innerPseudoStyle = aPresShell->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::cellContent, aStyleContext); + InitAndRestoreFrame(aPresContext, aState, aContent, aNewCellOuterFrame, innerPseudoStyle, nsnull, aNewCellInnerFrame); @@ -3283,8 +3284,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, // --------- CREATE AREA OR BOX FRAME ------- nsRefPtr styleContext; - styleContext = aPresContext->ResolveStyleContextFor(aDocElement, - aParentStyleContext); + styleContext = aPresShell->StyleSet()->ResolveStyleFor(aDocElement, + aParentStyleContext); const nsStyleDisplay* display = styleContext->GetStyleDisplay(); @@ -3519,10 +3520,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // --------- BUILD VIEWPORT ----------- nsIFrame* viewportFrame = nsnull; nsRefPtr viewportPseudoStyle; + nsStyleSet *styleSet = aPresShell->StyleSet(); - viewportPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewport, - nsnull); + viewportPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::viewport, + nsnull); NS_NewViewportFrame(aPresShell, &viewportFrame); @@ -3652,7 +3654,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // see if the style is overflow: hidden, first on the document element nsRefPtr styleContext; - styleContext = aPresContext->ResolveStyleContextFor(aDocElement, nsnull); + styleContext = styleSet->ResolveStyleFor(aDocElement, nsnull); if (styleContext) { const nsStyleDisplay* display = styleContext->GetStyleDisplay(); if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN || @@ -3681,8 +3683,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, if (bodyElement) { nsRefPtr bodyContext; - bodyContext = aPresContext->ResolveStyleContextFor(bodyElement, - styleContext); + bodyContext = styleSet->ResolveStyleFor(bodyElement, styleContext); if (bodyContext) { const nsStyleDisplay* display = bodyContext->GetStyleDisplay(); if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN || @@ -3707,9 +3708,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // If paginated, make sure we don't put scrollbars in if (isPaginated && !printPreviewContext) - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - viewportPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + viewportPseudoStyle); else if (isScrollable) { // Build the frame. We give it the content we are wrapping which is the document, @@ -3718,9 +3719,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // resolve a context for the scrollframe nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewportScroll, - viewportPseudoStyle); + styleContext = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::viewportScroll, + viewportPseudoStyle); nsIFrame* newScrollableFrame = nsnull; @@ -3754,18 +3755,18 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } else { // If no scrollbars and xul, don't build a scrollframe at all. if (isXUL) { - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - viewportPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + viewportPseudoStyle); } else { // if HTML the always create a scrollframe so anchors work. That way you can scroll to // anchors even if we don't have scrollbars. // create a style context for the scrollport of the viewport nsRefPtr scrollPseudoStyle; - scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::scrolledContent, - viewportPseudoStyle); + scrollPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::scrolledContent, + viewportPseudoStyle); // create scrollframe nsIFrame* scrollFrame = nsnull; @@ -3775,9 +3776,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull); // resolve a new style for the root frame - rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - rootPseudo, - scrollPseudoStyle); + rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + rootPseudo, + scrollPseudoStyle); // Inform the view manager about the root scrollable view nsIView* view = scrollFrame->GetView(); @@ -3851,11 +3852,13 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, return rv; nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresShell->StyleSet(); nsRefPtr pagePseudoStyle; - pagePseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::page, - parentStyleContext); + pagePseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::page, + parentStyleContext); + // Initialize the page frame and force it to have a view. This makes printing of // the pages easier and faster. aPageFrame->Init(aPresContext, nsnull, aParentFrame, pagePseudoStyle, aPrevPageFrame); @@ -3867,9 +3870,10 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, NS_NewPageContentFrame(aPresShell, &aPageContentFrame); nsRefPtr pageContentPseudoStyle; - pageContentPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageContent, - pagePseudoStyle); + pageContentPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::pageContent, + pagePseudoStyle); + // Initialize the page content frame and force it to have a view. Also make it the // containing block for fixed elements which are repeated on every page. aPageContentFrame->Init(aPresContext, nsnull, aPageFrame, pageContentPseudoStyle, nsnull); @@ -3903,7 +3907,8 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, // The placeholder frame gets a pseudo style context nsRefPtr placeholderStyle; nsStyleContext* parentContext = aStyleContext->GetParent(); - placeholderStyle = aPresContext->ResolveStyleContextForNonElement(parentContext); + placeholderStyle = aPresShell->StyleSet()-> + ResolveStyleForNonElement(parentContext); placeholderFrame->Init(aPresContext, aContent, aParentFrame, placeholderStyle, nsnull); @@ -3935,9 +3940,9 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel } nsRefPtr radioStyle; - radioStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::radio, - aStyleContext); + radioStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::radio, + aStyleContext); nsIRadioControlFrame* radio = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&radio))) { radio->SetRadioButtonFaceStyleContext(radioStyle); @@ -3960,9 +3965,9 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell } nsRefPtr checkboxStyle; - checkboxStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::check, - aStyleContext); + checkboxStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::check, + aStyleContext); nsICheckboxControlFrame* checkbox = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsICheckboxControlFrame), (void**)&checkbox))) { @@ -4049,9 +4054,9 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, // Resolve psuedo element style for the dropdown list nsRefPtr listStyle; - listStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::dropDownList, - aStyleContext); + listStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::dropDownList, + aStyleContext); // Initialize the scroll frame positioned. Note that it is NOT // initialized as absolutely positioned. @@ -4303,9 +4308,9 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel // Resolve style and initialize the frame nsRefPtr styleContext; - styleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::fieldsetContent, - aStyleContext); + styleContext = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::fieldsetContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, styleContext, nsnull, areaFrame); @@ -5788,17 +5793,19 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh // we used the style that was passed in. So resolve another one. nsRefPtr scrollPseudoStyle; - scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - contentStyle); + nsStyleSet *styleSet = aPresShell->StyleSet(); + + scrollPseudoStyle = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::scrolledContent, + contentStyle); contentStyle = scrollPseudoStyle; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, contentStyle, nsnull, scrollFrame); - nsStyleContext* aScrolledChildStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - aScrolledPseudo, - contentStyle).get(); + nsStyleContext* aScrolledChildStyle = styleSet->ResolvePseudoStyleFor(aContent, + aScrolledPseudo, + contentStyle).get(); aScrollableFrame = scrollFrame; @@ -6509,15 +6516,17 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, parentStyleContext = parentStyleContext->GetParent(); } + nsStyleSet *styleSet = aPresContext->StyleSet(); + if (aContent->IsContentOfType(nsIContent::eELEMENT)) { - return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext); + return styleSet->ResolveStyleFor(aContent, parentStyleContext); } else { NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName, "shouldn't waste time creating style contexts for " "comments and processing instructions"); - return aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + return styleSet->ResolveStyleForNonElement(parentStyleContext); } } @@ -6618,14 +6627,15 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, // block so that it can mix better with other surrounding MathML markups nsStyleContext* parentContext = aParentFrame->GetStyleContext(); + nsStyleSet *styleSet = aPresShell->StyleSet(); // first, create a MathML mrow frame that will wrap the block frame rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); if (NS_FAILED(rv)) return rv; nsRefPtr mrowContext; - mrowContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozMathInline, - parentContext); + mrowContext = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::mozMathInline, + parentContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, mrowContext, nsnull, newFrame); @@ -6634,16 +6644,16 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, rv = NS_NewBlockFrame(aPresShell, &blockFrame); if (NS_FAILED(rv)) return rv; nsRefPtr blockContext; - blockContext = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mrowContext); + blockContext = styleSet->ResolvePseudoStyleFor(aContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mrowContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, blockContext, nsnull, blockFrame); // then, create the table frame itself nsRefPtr tableContext; - tableContext = aPresContext->ResolveStyleContextFor(aContent, - blockContext); + tableContext = styleSet->ResolveStyleFor(aContent, blockContext); + nsFrameItems tempItems; nsIFrame* outerTable; nsIFrame* innerTable; @@ -6923,9 +6933,9 @@ nsCSSFrameConstructor::ConstructPageBreakFrame(nsIPresShell* aPresShe nsFrameItems& aFrameItems) { nsRefPtr pseudoStyle; - pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageBreak, - aStyleContext); + pseudoStyle = aPresShell->StyleSet()->ResolvePseudoStyleFor(nsnull, + nsCSSAnonBoxes::pageBreak, + aStyleContext); nsIFrame* pageBreakFrame; nsresult rv = NS_NewPageBreakFrame(aPresShell, &pageBreakFrame); if (NS_SUCCEEDED(rv)) { @@ -10197,7 +10207,8 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, NS_NewTextFrame(aPresShell, &textFrame); nsRefPtr textStyleContext; - textStyleContext = aPresContext->ResolveStyleContextForNonElement(aStyleContext); + textStyleContext = aPresShell->StyleSet()-> + ResolveStyleForNonElement(aStyleContext); textFrame->Init(aPresContext, altTextContent, containerFrame, textStyleContext, nsnull); @@ -11214,15 +11225,15 @@ nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIPresContext* aPresContex nsIContent* aContent) { nsresult result = NS_OK; - nsCOMPtr frameManager; - aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); + nsIPresShell *shell = aPresContext->PresShell(); + nsIFrameManager *frameManager = shell->GetFrameManager(); nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent); if (oldContext) { // The parent has a frame, so try resolving a new context. - nsRefPtr newContext = - aPresContext->ResolveStyleContextFor(aContent, - oldContext->GetParent()); + nsRefPtr newContext = shell->StyleSet()-> + ResolveStyleFor(aContent, oldContext->GetParent()); + frameManager->ChangeUndisplayedContent(aContent, newContext); if (newContext->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_NONE) { result = RecreateFramesForContent(aPresContext, aContent); @@ -11330,9 +11341,9 @@ nsCSSFrameConstructor::GetFirstLetterStyle(nsIPresContext* aPresContext, nsStyleContext* aStyleContext) { if (aContent) { - return aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLetter, - aStyleContext); + return aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSPseudoElements::firstLetter, aStyleContext); } return nsnull; } @@ -11343,9 +11354,9 @@ nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, nsStyleContext* aStyleContext) { if (aContent) { - return aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLine, - aStyleContext); + return aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, + nsCSSPseudoElements::firstLine, aStyleContext); } return nsnull; } @@ -11883,6 +11894,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( { // Create the first-letter-frame nsIFrame* letterFrame; + nsStyleSet *styleSet = aPresShell->StyleSet(); NS_NewFirstLetterFrame(aPresShell, &letterFrame); InitAndRestoreFrame(aPresContext, aState, aTextContent, @@ -11893,7 +11905,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // letter frame and will have the float property set on it; the text // frame shouldn't have that set). nsRefPtr textSC; - textSC = aPresContext->ResolveStyleContextForNonElement(aStyleContext); + textSC = styleSet->ResolveStyleForNonElement(aStyleContext); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, aTextFrame); @@ -11920,7 +11932,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( nsStyleContext* parentStyleContext = aStyleContext->GetParent(); if (parentStyleContext) { nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); + newSC = styleSet->ResolveStyleForNonElement(parentStyleContext); if (newSC) { nextTextFrame->SetStyleContext(aPresContext, newSC); } @@ -11983,9 +11995,11 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex letterFrame->Init(aPresContext, aTextContent, aParentFrame, sc, nsnull); nsRefPtr textSC; - textSC = aPresContext->ResolveStyleContextForNonElement(sc); + textSC = aPresContext->StyleSet()->ResolveStyleForNonElement(sc); + InitAndRestoreFrame(aPresContext, aState, aTextContent, - letterFrame, textSC, nsnull, textFrame); + letterFrame, textSC, nsnull, textFrame); + letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame); aResult.childList = aResult.lastChild = letterFrame; } @@ -12183,7 +12197,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( return NS_OK; } nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); + newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); if (!newSC) { return NS_OK; } @@ -12271,7 +12285,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, break; } nsRefPtr newSC; - newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); + newSC = aPresShell->StyleSet()->ResolveStyleForNonElement(parentSC); if (!newSC) { break; } @@ -12638,8 +12652,8 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, } nsRefPtr blockSC; - blockSC = aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, - aStyleContext); + blockSC = aPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, blockStyle, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, blockSC, nsnull, blockFrame); @@ -13102,9 +13116,9 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, nsStyleContext* styleContext = aFrame->GetStyleContext(); nsRefPtr blockSC; - blockSC = aPresContext->ResolvePseudoStyleContextFor(content, - nsCSSAnonBoxes::mozAnonymousBlock, - styleContext); + blockSC = shell->StyleSet()->ResolvePseudoStyleFor(content, + nsCSSAnonBoxes::mozAnonymousBlock, + styleContext); InitAndRestoreFrame(aPresContext, aState, content, nsnull, blockSC, nsnull, blockFrame); diff --git a/layout/html/table/src/Makefile.in b/layout/html/table/src/Makefile.in index b783f878c0c..7842fe01a38 100644 --- a/layout/html/table/src/Makefile.in +++ b/layout/html/table/src/Makefile.in @@ -38,6 +38,7 @@ REQUIRES = xpcom \ view \ accessibility \ necko \ + webshell \ $(NULL) CPPSRCS = \ diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 4f26cc84dc1..43784089c48 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -76,6 +76,7 @@ #include "nsLayoutErrors.h" #include "nsAutoPtr.h" #include "nsCSSFrameConstructor.h" +#include "nsStyleSet.h" /******************************************************************************** @@ -814,15 +815,15 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, nsTableColGroupType aColGroupType) { nsIContent* colGroupContent = GetContent(); + nsIPresShell *shell = aPresContext.PresShell(); nsRefPtr colGroupStyle; - colGroupStyle = aPresContext.ResolvePseudoStyleContextFor(colGroupContent, - nsCSSAnonBoxes::tableColGroup, - mStyleContext); + colGroupStyle = shell->StyleSet()->ResolvePseudoStyleFor(colGroupContent, + nsCSSAnonBoxes::tableColGroup, + mStyleContext); // Create a col group frame nsIFrame* newFrame; - nsresult result = NS_NewTableColGroupFrame(aPresContext.PresShell(), - &newFrame); + nsresult result = NS_NewTableColGroupFrame(shell, &newFrame); if (NS_SUCCEEDED(result) && newFrame) { ((nsTableColGroupFrame *)newFrame)->SetColType(aColGroupType); newFrame->Init(&aPresContext, colGroupContent, this, colGroupStyle, nsnull); @@ -898,6 +899,7 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, { *aFirstNewFrame = nsnull; nsIFrame* lastColFrame = nsnull; + nsIPresShell *shell = aPresContext.PresShell(); // Get the last col frame nsIFrame* childFrame = aColGroupFrame.GetFirstChild(nsnull); @@ -926,16 +928,16 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, // all other anonymous cols use a pseudo style context of the col group iContent = aColGroupFrame.GetContent(); parentStyleContext = aColGroupFrame.GetStyleContext(); - styleContext = aPresContext.ResolvePseudoStyleContextFor(iContent, - nsCSSAnonBoxes::tableCol, - parentStyleContext); + styleContext = shell->StyleSet()->ResolvePseudoStyleFor(iContent, + nsCSSAnonBoxes::tableCol, + parentStyleContext); } // ASSERTION to check for bug 54454 sneaking back in... NS_ASSERTION(iContent, "null content in CreateAnonymousColFrames"); // create the new col frame nsIFrame* colFrame; - NS_NewTableColFrame(aPresContext.PresShell(), &colFrame); + NS_NewTableColFrame(shell, &colFrame); ((nsTableColFrame *) colFrame)->SetColType(aColType); colFrame->Init(&aPresContext, iContent, &aColGroupFrame, styleContext, nsnull); diff --git a/layout/html/tests/TestInlineFrame.cpp b/layout/html/tests/TestInlineFrame.cpp index 36d388b9262..f11b9408cd3 100644 --- a/layout/html/tests/TestInlineFrame.cpp +++ b/layout/html/tests/TestInlineFrame.cpp @@ -50,6 +50,7 @@ #include "nsInlineFrame.h" #include "nsIAtom.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" /////////////////////////////////////////////////////////////////////////////// // @@ -291,7 +292,8 @@ TestReflowUnmapped(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -384,7 +386,8 @@ TestChildrenThatDontFit(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -556,7 +559,8 @@ TestOverflow(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -668,7 +672,8 @@ TestPushingPulling(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -1089,7 +1094,8 @@ TestSplittableChildren(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -1448,7 +1454,8 @@ TestMaxElementSize(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext; + styleContext = presContext->StyleSet()->ResolveStyleFor(b, nsnull); f->SetStyleContext(presContext,styleContext); diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 02c0afa0ccd..db66575508e 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -45,6 +45,7 @@ #include "nsMathMLChar.h" #include "nsMathMLContainerFrame.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" NS_DEFINE_CID(kInlineFrameCID, NS_INLINE_FRAME_CID); @@ -712,9 +713,10 @@ nsMathMLContainerFrame::WrapForeignFrames(nsIPresContext* aPresContext) &wrapper); if (NS_FAILED(rv)) return rv; nsRefPtr newStyleContext; - newStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mStyleContext); + newStyleContext = aPresContext->StyleSet()-> + ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mStyleContext); rv = wrapper->Init(aPresContext, mContent, this, newStyleContext, nsnull); if (NS_FAILED(rv)) { wrapper->Destroy(aPresContext); diff --git a/layout/mathml/base/src/nsMathMLFrame.cpp b/layout/mathml/base/src/nsMathMLFrame.cpp index 39f4fa4defc..695815f55d7 100644 --- a/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/layout/mathml/base/src/nsMathMLFrame.cpp @@ -38,6 +38,7 @@ #include "nsIURI.h" #include "nsContentCID.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); @@ -117,8 +118,9 @@ nsMathMLFrame::ResolveMathMLCharStyle(nsIPresContext* aPresContext, nsCSSAnonBoxes::mozMathStretchy : nsCSSAnonBoxes::mozMathAnonymous; // savings nsRefPtr newStyleContext; - newStyleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, pseudoStyle, - aParentStyleContext); + newStyleContext = aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, pseudoStyle, aParentStyleContext); + if (newStyleContext) aMathMLChar->SetStyleContext(newStyleContext); } @@ -505,7 +507,7 @@ GetMathMLAttributeStyleSheet(nsIPresContext* aPresContext, *aSheet = nsnull; // first, look if the attribute stylesheet is already there - nsStyleSet *styleSet = aPresContext->PresShell()->StyleSet(); + nsStyleSet *styleSet = aPresContext->StyleSet(); NS_ASSERTION(styleSet, "no style set"); nsAutoString title; diff --git a/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 1a0740c15d3..75caa17c830 100644 --- a/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -45,6 +45,7 @@ #include "nsMathMLmactionFrame.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" // // -- bind actions to a subexpression - implementation @@ -142,8 +143,9 @@ nsMathMLmactionFrame::Init(nsIPresContext* aPresContext, // then, re-resolve our style nsStyleContext* parentStyleContext = aParent->GetStyleContext(); - newStyleContext = aPresContext->ResolveStyleContextFor(aContent, - parentStyleContext); + newStyleContext = aPresContext->StyleSet()-> + ResolveStyleFor(aContent, parentStyleContext); + if (!newStyleContext) mRestyle.Truncate(); else { diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index ce7ad161c8d..5f95a27fc0e 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -59,6 +59,7 @@ #include "nsIDocument.h" #include "nsCSSPseudoElements.h" +#include "nsStyleSet.h" #if defined(DEBUG_bzbarsky) || defined(DEBUG_caillon) #define DEBUG_ComputedDOMStyle @@ -2912,10 +2913,12 @@ nsComputedDOMStyle::GetStyleData(nsStyleStructID aID, presShell->GetPresContext(getter_AddRefs(pctx)); if (pctx) { nsStyleContext* sctx; + nsStyleSet *styleSet = presShell->StyleSet(); if (!mPseudo) { - sctx = pctx->ResolveStyleContextFor(mContent, nsnull).get(); + sctx = styleSet->ResolveStyleFor(mContent, nsnull).get(); } else { - sctx = pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull).get(); + sctx = styleSet->ResolvePseudoStyleFor(mContent, mPseudo, + nsnull).get(); } if (sctx) { aStyleStruct = sctx->GetStyleData(aID); diff --git a/layout/style/nsInspectorCSSUtils.cpp b/layout/style/nsInspectorCSSUtils.cpp index 5b1f4e79ce8..20771ec20a6 100644 --- a/layout/style/nsInspectorCSSUtils.cpp +++ b/layout/style/nsInspectorCSSUtils.cpp @@ -45,6 +45,7 @@ #include "nsIPresShell.h" #include "nsAutoPtr.h" #include "nsIFrame.h" +#include "nsStyleSet.h" nsInspectorCSSUtils::nsInspectorCSSUtils() { @@ -159,10 +160,12 @@ nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, if (!presContext) return nsnull; - if (aContent->IsContentOfType(nsIContent::eELEMENT)) - return presContext->ResolveStyleContextFor(aContent, parentContext); + nsStyleSet *styleSet = aPresShell->StyleSet(); - return presContext->ResolveStyleContextForNonElement(parentContext); + if (aContent->IsContentOfType(nsIContent::eELEMENT)) + return styleSet->ResolveStyleFor(aContent, parentContext); + + return styleSet->ResolveStyleForNonElement(parentContext); } NS_IMETHODIMP diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 5d58ca76d8a..d0605336886 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -317,11 +317,10 @@ nsStyleSet::EnableQuirkStyleSheet(PRBool aEnable) struct RulesMatchingData : public ElementRuleProcessorData { RulesMatchingData(nsIPresContext* aPresContext, - nsIAtom* aMedium, nsIContent* aContent, nsRuleWalker* aRuleWalker) : ElementRuleProcessorData(aPresContext, aContent, aRuleWalker), - mMedium(aMedium) + mMedium(aPresContext->Medium()) { } nsIAtom* mMedium; @@ -504,27 +503,24 @@ PRBool nsStyleSet::BuildDefaultStyleData(nsIPresContext* aPresContext) } already_AddRefed -nsStyleSet::ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, +nsStyleSet::ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext* presContext = PresContext(); NS_ASSERTION(aContent, "must have content"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(aContent->IsContentOfType(nsIContent::eELEMENT), "content must be element"); - if (aContent && aPresContext) { + if (aContent && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - RulesMatchingData data(aPresContext, medium, aContent, mRuleWalker); + RulesMatchingData data(presContext, aContent, mRuleWalker); FileRules(EnumRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, nsnull).get(); + result = GetContext(presContext, aParentContext, nsnull).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -535,19 +531,17 @@ nsStyleSet::ResolveStyleFor(nsIPresContext* aPresContext, } already_AddRefed -nsStyleSet::ResolveStyleForNonElement(nsIPresContext* aPresContext, - nsStyleContext* aParentContext) +nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); - NS_ASSERTION(aPresContext, "must have pres context"); - - if (aPresContext) { + if (presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - result = GetContext(aPresContext, aParentContext, + result = GetContext(presContext, aParentContext, nsCSSAnonBoxes::mozNonElement).get(); NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root"); } @@ -559,14 +553,13 @@ nsStyleSet::ResolveStyleForNonElement(nsIPresContext* aPresContext, struct PseudoRulesMatchingData : public PseudoRuleProcessorData { PseudoRulesMatchingData(nsIPresContext* aPresContext, - nsIAtom* aMedium, nsIContent* aParentContent, nsIAtom* aPseudoTag, nsICSSPseudoComparator* aComparator, nsRuleWalker* aRuleWalker) : PseudoRuleProcessorData(aPresContext, aParentContent, aPseudoTag, aComparator, aRuleWalker), - mMedium(aMedium) + mMedium(aPresContext->Medium()) { } nsIAtom* mMedium; @@ -582,32 +575,29 @@ EnumPseudoRulesMatching(nsIStyleRuleProcessor* aProcessor, void* aData) } already_AddRefed -nsStyleSet::ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, +nsStyleSet::ResolvePseudoStyleFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, nsStyleContext* aParentContext, nsICSSPseudoComparator* aComparator) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); NS_ASSERTION(aPseudoTag, "must have pseudo tag"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(!aParentContent || aParentContent->IsContentOfType(nsIContent::eELEMENT), "content (if non-null) must be element"); - if (aPseudoTag && aPresContext) { + if (aPseudoTag && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - PseudoRulesMatchingData data(aPresContext, medium, aParentContent, - aPseudoTag, aComparator, mRuleWalker); + PseudoRulesMatchingData data(presContext, aParentContent, aPseudoTag, + aComparator, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); + result = GetContext(presContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -618,32 +608,29 @@ nsStyleSet::ResolvePseudoStyleFor(nsIPresContext* aPresContext, } already_AddRefed -nsStyleSet::ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext) +nsStyleSet::ProbePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; + nsIPresContext *presContext = PresContext(); NS_ASSERTION(aPseudoTag, "must have pseudo tag"); - NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(!aParentContent || aParentContent->IsContentOfType(nsIContent::eELEMENT), "content (if non-null) must be element"); - if (aPseudoTag && aPresContext) { + if (aPseudoTag && presContext) { if (mRuleProcessors[eAgentSheet].Count() || mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count()) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - PseudoRulesMatchingData data(aPresContext, medium, aParentContent, - aPseudoTag, nsnull, mRuleWalker); + PseudoRulesMatchingData data(presContext, aParentContent, aPseudoTag, + nsnull, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); if (!mRuleWalker->AtRoot()) - result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); + result = GetContext(presContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -762,10 +749,10 @@ nsStyleSet::ReParentStyleContext(nsIPresContext* aPresContext, } struct StatefulData : public StateRuleProcessorData { - StatefulData(nsIPresContext* aPresContext, nsIAtom* aMedium, + StatefulData(nsIPresContext* aPresContext, nsIContent* aContent, PRInt32 aStateMask) : StateRuleProcessorData(aPresContext, aContent, aStateMask), - mMedium(aMedium), + mMedium(aPresContext->Medium()), mHint(nsReStyleHint(0)) {} nsIAtom* mMedium; @@ -795,9 +782,7 @@ nsStyleSet::HasStateDependentStyle(nsIPresContext* aPresContext, mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count())) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - StatefulData data(aPresContext, medium, aContent, aStateMask); + StatefulData data(aPresContext, aContent, aStateMask); WalkRuleProcessors(SheetHasStatefulStyle, &data); result = data.mHint; } @@ -806,10 +791,10 @@ nsStyleSet::HasStateDependentStyle(nsIPresContext* aPresContext, } struct AttributeData : public AttributeRuleProcessorData { - AttributeData(nsIPresContext* aPresContext, nsIAtom* aMedium, - nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) + AttributeData(nsIPresContext* aPresContext, + nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType), - mMedium(aMedium), + mMedium(aPresContext->Medium()), mHint(nsReStyleHint(0)) {} nsIAtom* mMedium; @@ -840,9 +825,7 @@ nsStyleSet::HasAttributeDependentStyle(nsIPresContext* aPresContext, mRuleProcessors[eUserSheet].Count() || mRuleProcessors[eDocSheet].Count() || mRuleProcessors[eOverrideSheet].Count())) { - nsCOMPtr medium; - aPresContext->GetMedium(getter_AddRefs(medium)); - AttributeData data(aPresContext, medium, aContent, aAttribute, aModType); + AttributeData data(aPresContext, aContent, aAttribute, aModType); WalkRuleProcessors(SheetHasAttributeStyle, &data); result = data.mHint; } diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index fe00880c66f..11b51b3f257 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -75,9 +75,7 @@ class nsStyleSet // get a style context for a non-pseudo frame. already_AddRefed - ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsStyleContext* aParentContext); + ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext); // Get a style context for a non-element (which no rules will match). // Eventually, this should go away and we shouldn't even create style @@ -90,26 +88,23 @@ class nsStyleSet // represents everything except the first letter.) // already_AddRefed - ResolveStyleForNonElement(nsIPresContext* aPresContext, - nsStyleContext* aParentContext); + ResolveStyleForNonElement(nsStyleContext* aParentContext); // get a style context for a pseudo-element (i.e., // |aPseudoTag == nsCOMPtr(do_GetAtom(":first-line"))|; already_AddRefed - ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator = nsnull); + ResolvePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator = nsnull); // This funtions just like ResolvePseudoStyleFor except that it will // return nsnull if there are no explicit style rules for that // pseudo element. already_AddRefed - ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsStyleContext* aParentContext); + ProbePseudoStyleFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext); // Begin ignoring style context destruction, to avoid lots of unnecessary // work on document teardown. @@ -213,6 +208,8 @@ class nsStyleSet nsStyleContext* aParentContext, nsIAtom* aPseudoTag); + nsIPresContext* PresContext() { return mRuleTree->GetPresContext(); } + static nsIURI *gQuirkURI; nsCOMArray mSheets[eSheetTypeCount]; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 4f26cc84dc1..43784089c48 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -76,6 +76,7 @@ #include "nsLayoutErrors.h" #include "nsAutoPtr.h" #include "nsCSSFrameConstructor.h" +#include "nsStyleSet.h" /******************************************************************************** @@ -814,15 +815,15 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, nsTableColGroupType aColGroupType) { nsIContent* colGroupContent = GetContent(); + nsIPresShell *shell = aPresContext.PresShell(); nsRefPtr colGroupStyle; - colGroupStyle = aPresContext.ResolvePseudoStyleContextFor(colGroupContent, - nsCSSAnonBoxes::tableColGroup, - mStyleContext); + colGroupStyle = shell->StyleSet()->ResolvePseudoStyleFor(colGroupContent, + nsCSSAnonBoxes::tableColGroup, + mStyleContext); // Create a col group frame nsIFrame* newFrame; - nsresult result = NS_NewTableColGroupFrame(aPresContext.PresShell(), - &newFrame); + nsresult result = NS_NewTableColGroupFrame(shell, &newFrame); if (NS_SUCCEEDED(result) && newFrame) { ((nsTableColGroupFrame *)newFrame)->SetColType(aColGroupType); newFrame->Init(&aPresContext, colGroupContent, this, colGroupStyle, nsnull); @@ -898,6 +899,7 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, { *aFirstNewFrame = nsnull; nsIFrame* lastColFrame = nsnull; + nsIPresShell *shell = aPresContext.PresShell(); // Get the last col frame nsIFrame* childFrame = aColGroupFrame.GetFirstChild(nsnull); @@ -926,16 +928,16 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, // all other anonymous cols use a pseudo style context of the col group iContent = aColGroupFrame.GetContent(); parentStyleContext = aColGroupFrame.GetStyleContext(); - styleContext = aPresContext.ResolvePseudoStyleContextFor(iContent, - nsCSSAnonBoxes::tableCol, - parentStyleContext); + styleContext = shell->StyleSet()->ResolvePseudoStyleFor(iContent, + nsCSSAnonBoxes::tableCol, + parentStyleContext); } // ASSERTION to check for bug 54454 sneaking back in... NS_ASSERTION(iContent, "null content in CreateAnonymousColFrames"); // create the new col frame nsIFrame* colFrame; - NS_NewTableColFrame(aPresContext.PresShell(), &colFrame); + NS_NewTableColFrame(shell, &colFrame); ((nsTableColFrame *) colFrame)->SetColType(aColType); colFrame->Init(&aPresContext, iContent, &aColGroupFrame, styleContext, nsnull); diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index 3e63b1d5ca5..4d3ed70fb07 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -67,6 +67,7 @@ #include "nsIFontMetrics.h" #include "nsITimer.h" #include "nsAutoPtr.h" +#include "nsStyleSet.h" /////////////// nsListScrollSmoother ////////////////// @@ -710,8 +711,9 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState) if (firstRowContent) { nsRefPtr styleContext; - styleContext = aBoxLayoutState.GetPresContext()->ResolveStyleContextFor(firstRowContent, - nsnull); + nsIPresContext *presContext = aBoxLayoutState.GetPresContext(); + styleContext = presContext->StyleSet()-> + ResolveStyleFor(firstRowContent, nsnull); nscoord width = 0; nsMargin margin(0,0,0,0); diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index dd66ab16da4..12d5b8e0f29 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -75,6 +75,7 @@ #include "nsGUIEvent.h" #include "nsAutoPtr.h" #include "nsContentCID.h" +#include "nsStyleSet.h" const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32 // was used in nsSplitterFrame::Init but now commented out @@ -353,7 +354,8 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext, aContent->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("vertical"), PR_FALSE); nsStyleContext* parent = aContext->GetParent(); - newContext = aPresContext->ResolveStyleContextFor(aContent, parent); + newContext = aPresContext->StyleSet()-> + ResolveStyleFor(aContent, parent); aContext = newContext; } } diff --git a/layout/xul/base/src/tree/src/Makefile.in b/layout/xul/base/src/tree/src/Makefile.in index 2b395261f8e..459e1b867db 100644 --- a/layout/xul/base/src/tree/src/Makefile.in +++ b/layout/xul/base/src/tree/src/Makefile.in @@ -42,6 +42,7 @@ REQUIRES = xpcom \ imglib2 \ xpconnect \ js \ + webshell \ $(NULL) CPPSRCS = \ diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index eac8fb8b6f7..36e2b91ff40 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -94,6 +94,7 @@ #include "imgIContainer.h" #include "imgIContainerObserver.h" #include "imgILoader.h" +#include "nsStyleSet.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" @@ -176,10 +177,9 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator, result = NS_STATIC_CAST(nsStyleContext*, mCache->Get(currState)); if (!result) { // We missed the cache. Resolve this pseudo-style. - result = aPresContext->ResolvePseudoStyleWithComparator(aContent, - aPseudoElement, - aContext, - aComparator).get(); + result = aPresContext->StyleSet()-> + ResolvePseudoStyleFor(aContent, aPseudoElement, + aContext, aComparator).get(); // Put the style context in our table, transferring the owning reference to the table. if (!mCache) {