diff --git a/mozilla/content/base/public/nsIStyleRuleProcessor.h b/mozilla/content/base/public/nsIStyleRuleProcessor.h index 78f2f2ab24d..ac4a7517775 100644 --- a/mozilla/content/base/public/nsIStyleRuleProcessor.h +++ b/mozilla/content/base/public/nsIStyleRuleProcessor.h @@ -48,7 +48,6 @@ class nsISizeOfHandler; class nsIStyleSheet; -class nsIStyleContext; class nsIPresContext; class nsIContent; class nsIStyledContent; diff --git a/mozilla/content/base/public/nsIStyleSheet.h b/mozilla/content/base/public/nsIStyleSheet.h index a31423ebc5c..9e830d71dd3 100644 --- a/mozilla/content/base/public/nsIStyleSheet.h +++ b/mozilla/content/base/public/nsIStyleSheet.h @@ -51,7 +51,6 @@ class nsISupportsArray; class nsIPresContext; class nsIContent; class nsIDocument; -class nsIStyleContext; class nsIStyleRuleProcessor; // IID for the nsIStyleSheet interface {8c4a80a0-ad6a-11d1-8031-006008159b5a} diff --git a/mozilla/content/base/public/nsIStyledContent.h b/mozilla/content/base/public/nsIStyledContent.h index 9b9a6f3339e..852c99d74b6 100644 --- a/mozilla/content/base/public/nsIStyledContent.h +++ b/mozilla/content/base/public/nsIStyledContent.h @@ -43,7 +43,6 @@ class nsString; class nsIStyleRule; -class nsIStyleContext; class nsISupportsArray; class nsRuleWalker; diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 39d8afbec3b..5655bfd8e0e 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -2585,13 +2585,10 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale, PRBool a nsIFrame * frame; aPO->mParent->mPresShell->GetPrimaryFrameFor(aPO->mContent, &frame); if (frame) { - nsCOMPtr sc; - frame->GetStyleContext(getter_AddRefs(sc)); - if (sc) { - const nsStyleVisibility* vis = (const nsStyleVisibility*)sc->GetStyleData(eStyleStruct_Visibility); - if (!vis->IsVisible()) { - aPO->mDontPrint = PR_TRUE; - } + const nsStyleVisibility* vis; + ::GetStyleData(frame, &vis); + if (!vis->IsVisible()) { + aPO->mDontPrint = PR_TRUE; } } } diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 9d688900ec4..270f7bc6cef 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -52,6 +52,7 @@ #include "nsThemeConstants.h" #include "nsITheme.h" #include "pldhash.h" +#include "nsStyleContext.h" /* * For storage of an |nsRuleNode|'s children in a linked list. @@ -198,7 +199,7 @@ nsString& Unquote(nsString& aString) nscoord CalcLength(const nsCSSValue& aValue, const nsFont* aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, PRBool& aInherited) { @@ -269,7 +270,7 @@ nscoord CalcLength(const nsCSSValue& aValue, static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord, const nsStyleCoord& aParentCoord, - PRInt32 aMask, nsIStyleContext* aStyleContext, + PRInt32 aMask, nsStyleContext* aStyleContext, nsIPresContext* aPresContext, PRBool& aInherited) { PRBool result = PR_TRUE; @@ -1207,7 +1208,7 @@ nsRuleNode::CheckSpecifiedProperties(const nsStyleStructID aSID, } const nsStyleStruct* -nsRuleNode::GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetDisplayData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataDisplay displayData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Display, mPresContext, aContext); @@ -1221,7 +1222,7 @@ nsRuleNode::GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetVisibilityData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataDisplay displayData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Visibility, mPresContext, aContext); @@ -1231,7 +1232,7 @@ nsRuleNode::GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTextData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTextData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataText textData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Text, mPresContext, aContext); @@ -1241,7 +1242,7 @@ nsRuleNode::GetTextData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTextResetData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataText textData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_TextReset, mPresContext, aContext); @@ -1251,7 +1252,7 @@ nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetUserInterfaceData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataUserInterface uiData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_UserInterface, mPresContext, aContext); @@ -1263,7 +1264,7 @@ nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetUIResetData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataUserInterface uiData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_UIReset, mPresContext, aContext); @@ -1275,7 +1276,7 @@ nsRuleNode::GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetFontData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetFontData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataFont fontData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Font, mPresContext, aContext); @@ -1285,7 +1286,7 @@ nsRuleNode::GetFontData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetColorData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetColorData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataColor colorData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Color, mPresContext, aContext); @@ -1295,7 +1296,7 @@ nsRuleNode::GetColorData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetBackgroundData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataColor colorData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Background, mPresContext, aContext); @@ -1305,7 +1306,7 @@ nsRuleNode::GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetMarginData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetMarginData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Margin, mPresContext, aContext); @@ -1321,7 +1322,7 @@ nsRuleNode::GetMarginData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetBorderData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetBorderData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Border, mPresContext, aContext); @@ -1351,7 +1352,7 @@ nsRuleNode::GetBorderData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetPaddingData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Padding, mPresContext, aContext); @@ -1367,7 +1368,7 @@ nsRuleNode::GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetOutlineData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Outline, mPresContext, aContext); @@ -1383,7 +1384,7 @@ nsRuleNode::GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetListData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetListData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataList listData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_List, mPresContext, aContext); @@ -1398,7 +1399,7 @@ nsRuleNode::GetListData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetPositionData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetPositionData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataPosition posData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Position, mPresContext, aContext); @@ -1413,7 +1414,7 @@ nsRuleNode::GetPositionData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTableData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTableData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataTable tableData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Table, mPresContext, aContext); @@ -1423,7 +1424,7 @@ nsRuleNode::GetTableData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTableBorderData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataTable tableData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_TableBorder, mPresContext, aContext); @@ -1433,7 +1434,7 @@ nsRuleNode::GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetContentData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetContentData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataContent contentData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Content, mPresContext, aContext); @@ -1446,7 +1447,7 @@ nsRuleNode::GetContentData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetQuotesData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataContent contentData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Quotes, mPresContext, aContext); @@ -1459,7 +1460,7 @@ nsRuleNode::GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData) #ifdef INCLUDE_XUL const nsStyleStruct* -nsRuleNode::GetXULData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetXULData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataXUL xulData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_XUL, mPresContext, aContext); @@ -1471,7 +1472,7 @@ nsRuleNode::GetXULData(nsIStyleContext* aContext, PRBool aComputeData) #ifdef MOZ_SVG const nsStyleStruct* -nsRuleNode::GetSVGData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetSVGData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataSVG svgData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_SVG, mPresContext, aContext); @@ -1483,7 +1484,7 @@ nsRuleNode::GetSVGData(nsIStyleContext* aContext, PRBool aComputeData) const nsStyleStruct* nsRuleNode::WalkRuleTree(const nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData, PRBool aComputeData) @@ -1591,7 +1592,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID, // All information must necessarily be inherited from our parent style context. // In the absence of any computed data in the rule tree and with // no rules specified that didn't have values of 'inherit', we should check our parent. - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); if (parentContext) { // We have a parent, and so we should just inherit from the parent. // Set the inherit bits on our context. These bits tell the style context that @@ -1654,7 +1655,7 @@ IsChrome(nsIPresContext* aPresContext) } const nsStyleStruct* -nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext) +nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext) { switch (aSID) { case eStyleStruct_Font: @@ -1817,7 +1818,7 @@ nsRuleNode::gComputeStyleDataFn[] = { }; static void -SetFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, +SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aChromeOverride, PRBool aIsGeneric, const nsRuleDataFont& aFontData, const nsFont& aDefaultFont, const nsStyleFont* aParentFont, @@ -2106,14 +2107,14 @@ SetFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, // up to the root where default values come from the presentation context) // - re-apply cascading rules from there without caching intermediate values static void -SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, +SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext, const nsRuleDataFont& aFontData, PRUint8 aGenericFontID, nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aChromeOverride, nsStyleFont* aFont) { // walk up the contexts until a context with the desired generic font nsAutoVoidArray contextPath; - nsCOMPtr higherContext = aContext->GetParent(); + nsStyleContext* higherContext = aContext->GetParent(); while (higherContext) { contextPath.AppendElement(higherContext); const nsStyleFont* higherFont = (const nsStyleFont*)higherContext->GetStyleData(eStyleStruct_Font); @@ -2135,7 +2136,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, PRInt32 i = contextPath.Count() - 1; PRBool zoom = PR_TRUE; if (higherContext) { - nsIStyleContext* context = (nsIStyleContext*)contextPath[i]; + nsStyleContext* context = (nsStyleContext*)contextPath[i]; nsStyleFont* tmpFont = (nsStyleFont*)context->GetStyleData(eStyleStruct_Font); parentFont.mFlags = tmpFont->mFlags; parentFont.mFont = tmpFont->mFont; @@ -2155,7 +2156,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, nsCOMPtr rule; for (; i >= 0; --i) { - nsIStyleContext* context = (nsIStyleContext*)contextPath[i]; + nsStyleContext* context = (nsStyleContext*)contextPath[i]; nsRuleDataFont fontData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Font, aPresContext, context); ruleData.mFontData = &fontData; @@ -2203,11 +2204,11 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, const nsStyleStruct* nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataFont& fontData = NS_STATIC_CAST(const nsRuleDataFont&, aData); nsStyleFont* font = nsnull; @@ -2333,11 +2334,11 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataText& textData = NS_STATIC_CAST(const nsRuleDataText&, aData); nsStyleText* text = nsnull; @@ -2454,11 +2455,11 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataText& textData = NS_STATIC_CAST(const nsRuleDataText&, aData); nsStyleTextReset* text; @@ -2537,12 +2538,12 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataUserInterface& uiData = NS_STATIC_CAST(const nsRuleDataUserInterface&, aData); nsStyleUserInterface* ui = nsnull; @@ -2649,11 +2650,11 @@ nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataUserInterface& uiData = NS_STATIC_CAST(const nsRuleDataUserInterface&, aData); nsStyleUIReset* ui; @@ -2739,11 +2740,11 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataDisplay& displayData = NS_STATIC_CAST(const nsRuleDataDisplay&, aData); nsStyleDisplay* display; @@ -2755,8 +2756,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, display = new (mPresContext) nsStyleDisplay(); const nsStyleDisplay* parentDisplay = display; - nsCOMPtr pseudoTag; - aContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsCOMPtr pseudoTag = aContext->GetPseudoType(); PRBool generatedContent = (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after); @@ -2998,11 +2998,11 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataDisplay& displayData = NS_STATIC_CAST(const nsRuleDataDisplay&, aData); nsStyleVisibility* visibility = nsnull; @@ -3107,11 +3107,11 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataColor& colorData = NS_STATIC_CAST(const nsRuleDataColor&, aData); nsStyleColor* color = nsnull; @@ -3164,11 +3164,11 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataColor& colorData = NS_STATIC_CAST(const nsRuleDataColor&, aData); nsStyleBackground* bg; @@ -3354,11 +3354,11 @@ static const CSSRectSide gCSSSides[] = { const nsStyleStruct* nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleMargin* margin; @@ -3411,11 +3411,11 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleBorder* border; @@ -3517,7 +3517,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, // computed (unlike for the element where this will be used, for // which the color could be specified on a more specific rule). const nsStyleColor *parentColor; - ::GetStyleData(parentContext.get(), &parentColor); + ::GetStyleData(parentContext, &parentColor); border->SetBorderColor(side, parentColor->mColor); } else border->SetBorderColor(side, borderColor); @@ -3579,11 +3579,11 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStylePadding* padding; @@ -3636,11 +3636,11 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleOutline* outline; @@ -3709,11 +3709,11 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataList& listData = NS_STATIC_CAST(const nsRuleDataList&, aData); nsStyleList* list = nsnull; @@ -3826,11 +3826,11 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataPosition& posData = NS_STATIC_CAST(const nsRuleDataPosition&, aData); nsStylePosition* pos; @@ -3935,11 +3935,11 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataTable& tableData = NS_STATIC_CAST(const nsRuleDataTable&, aData); nsStyleTable* table; @@ -4006,11 +4006,11 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataTable& tableData = NS_STATIC_CAST(const nsRuleDataTable&, aData); nsStyleTableBorder* table = nsnull; @@ -4105,11 +4105,11 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataContent& contentData = NS_STATIC_CAST(const nsRuleDataContent&, aData); nsStyleContent* content; @@ -4301,11 +4301,11 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataContent& contentData = NS_STATIC_CAST(const nsRuleDataContent&, aData); nsStyleQuotes* quotes = nsnull; @@ -4395,11 +4395,11 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataXUL& xulData = NS_STATIC_CAST(const nsRuleDataXUL&, aData); nsStyleXUL* xul = nsnull; @@ -4517,7 +4517,7 @@ SetSVGOpacity(const nsCSSValue& aValue, float parentOpacity, float& opacity, PRB static void SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length, - nsIStyleContext* aContext, nsIPresContext* aPresContext, PRBool& aInherited) + nsStyleContext* aContext, nsIPresContext* aPresContext, PRBool& aInherited) { nsStyleCoord coord; PRBool dummy; @@ -4545,11 +4545,11 @@ SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length, const nsStyleStruct* nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); nsStyleSVG* svg = nsnull; nsStyleSVG* parentSVG = svg; @@ -4692,7 +4692,7 @@ nsRuleNode::gGetStyleDataFn[] = { const nsStyleStruct* nsRuleNode::GetStyleData(nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, PRBool aComputeData) { const nsStyleStruct* cachedData = mStyleData.GetStyleData(aSID); diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index 13428a4cd56..ed785cfac24 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -54,6 +54,7 @@ #include "nsRuleNode.h" #include "nsUnitConversion.h" +#include "nsStyleContext.h" #ifdef DEBUG // #define NOISY_DEBUG @@ -61,87 +62,8 @@ //---------------------------------------------------------------------- -class nsStyleContext : public nsIStyleContext -{ -public: - nsStyleContext(nsIStyleContext* aParent, nsIAtom* aPseudoTag, - nsRuleNode* aRuleNode, nsIPresContext* aPresContext); - virtual ~nsStyleContext(); - void* operator new(size_t sz, nsIPresContext* aPresContext) CPP_THROW_NEW; - void Destroy(); - - NS_DECL_ISUPPORTS - - virtual already_AddRefed GetParent(void) const; - NS_IMETHOD GetFirstChild(nsIStyleContext** aContext); - - NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const; - - NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules, - nsIStyleContext*& aResult); - - virtual PRBool Equals(const nsIStyleContext* aOther) const; - virtual PRBool HasTextDecorations() { return mBits & NS_STYLE_HAS_TEXT_DECORATIONS; }; - - NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding); - - NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct); - NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct); - - NS_IMETHOD GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; return NS_OK; }; - NS_IMETHOD AddStyleBit(const PRUint32& aBit) { mBits |= aBit; return NS_OK; }; - NS_IMETHOD GetStyleBits(PRUint32* aBits) { *aBits = mBits; return NS_OK; }; - - virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID); - const nsStyleStruct* PeekStyleData(nsStyleStructID aSID); - - virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID); - - virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule); - - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule); - - NS_IMETHOD CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint); - -#ifdef DEBUG - virtual void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); - - virtual void List(FILE* out, PRInt32 aIndent); - - virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize); -#endif - -protected: - void AppendChild(nsStyleContext* aChild); - void RemoveChild(nsStyleContext* aChild); - - void ApplyStyleFixups(nsIPresContext* aPresContext); - - nsStyleContext* mParent; - nsStyleContext* mChild; - nsStyleContext* mEmptyChild; - nsStyleContext* mPrevSibling; - nsStyleContext* mNextSibling; - - // If this style context is for a pseudo-element, the pseudo-element - // atom. Otherwise, null. - nsCOMPtr mPseudoTag; - - nsRuleNode* mRuleNode; - - // |mCachedStyleData| points to both structs that are owned by this - // style context and structs that are owned by one of this style - // context's ancestors (which are indirectly owned since this style - // context owns a reference to its parent). If the bit in |mBits| is - // set for a struct, that means that the pointer for that struct is - // owned by an ancestor rather than by this style context. - nsCachedStyleData mCachedStyleData; // Our cached style data. - PRUint32 mBits; // Which structs are inherited from the - // parent context. -}; - -nsStyleContext::nsStyleContext(nsIStyleContext* aParent, +nsStyleContext::nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag, nsRuleNode* aRuleNode, nsIPresContext* aPresContext) @@ -150,13 +72,13 @@ nsStyleContext::nsStyleContext(nsIStyleContext* aParent, mEmptyChild(nsnull), mPseudoTag(aPseudoTag), mRuleNode(aRuleNode), - mBits(0) + mBits(0), + mRefCnt(0) { - mNextSibling = this; mPrevSibling = this; if (mParent) { - NS_ADDREF(mParent); + mParent->AddRef(); mParent->AppendChild(this); } @@ -173,7 +95,7 @@ nsStyleContext::~nsStyleContext() if (mParent) { mParent->RemoveChild(this); - NS_RELEASE(mParent); + mParent->Release(); } // Free up our data structs. @@ -184,24 +106,6 @@ nsStyleContext::~nsStyleContext() } } -NS_IMPL_ADDREF(nsStyleContext) -NS_IMPL_RELEASE_WITH_DESTROY(nsStyleContext, Destroy()) -NS_IMPL_QUERY_INTERFACE1(nsStyleContext, nsIStyleContext) - -already_AddRefed nsStyleContext::GetParent(void) const -{ - NS_IF_ADDREF(mParent); - return mParent; -} - -NS_IMETHODIMP -nsStyleContext::GetFirstChild(nsIStyleContext** aContext) -{ - *aContext = mChild; - NS_IF_ADDREF(*aContext); - return NS_OK; -} - void nsStyleContext::AppendChild(nsStyleContext* aChild) { if (aChild->mRuleNode->IsRoot()) { @@ -263,23 +167,22 @@ void nsStyleContext::RemoveChild(nsStyleContext* aChild) aChild->mPrevSibling = aChild; } -NS_IMETHODIMP -nsStyleContext::GetPseudoType(nsIAtom*& aPseudoTag) const +already_AddRefed +nsStyleContext::GetPseudoType() const { - aPseudoTag = mPseudoTag; - NS_IF_ADDREF(aPseudoTag); - return NS_OK; + nsIAtom* pseudoTag = mPseudoTag; + NS_IF_ADDREF(pseudoTag); + return pseudoTag; } -NS_IMETHODIMP +already_AddRefed nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag, - nsRuleNode* aRuleNode, - nsIStyleContext*& aResult) + nsRuleNode* aRuleNode) { PRUint32 threshold = 10; // The # of siblings we're willing to examine // before just giving this whole thing up. - aResult = nsnull; + nsStyleContext* aResult = nsnull; if ((nsnull != mChild) || (nsnull != mEmptyChild)) { nsStyleContext* child; @@ -313,12 +216,15 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag, } while (child != mChild); } } - NS_IF_ADDREF(aResult); - return NS_OK; + + if (aResult) + aResult->AddRef(); + + return aResult; } -PRBool nsStyleContext::Equals(const nsIStyleContext* aOther) const +PRBool nsStyleContext::Equals(const nsStyleContext* aOther) const { PRBool result = PR_TRUE; const nsStyleContext* other = (nsStyleContext*)aOther; @@ -358,7 +264,7 @@ inline const nsStyleStruct* nsStyleContext::PeekStyleData(nsStyleStructID aSID) return mRuleNode->GetStyleData(aSID, this, PR_FALSE); // Our rule node will take care of it for us. } -NS_IMETHODIMP +void nsStyleContext::GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding) { nsMargin border, padding; @@ -370,8 +276,6 @@ nsStyleContext::GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding) aBorderPadding.SetBorderPadding(border); } } - - return NS_OK; } // This is an evil evil function, since it forces you to alloc your own separate copy of @@ -421,14 +325,7 @@ nsStyleContext::GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleSt return result; } -NS_IMETHODIMP -nsStyleContext::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) -{ - *aStruct = GetStyleData(aSID); - return NS_OK; -} - -NS_IMETHODIMP +void nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) { // This method should only be called from nsRuleNode! It is not a public @@ -461,8 +358,6 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) } char* dataSlot = resetOrInherit + info.mInheritResetOffset; *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot) = aStruct; - - return NS_OK; } void @@ -497,7 +392,7 @@ nsStyleContext::ApplyStyleFixups(nsIPresContext* aPresContext) } } -nsresult +void nsStyleContext::ClearCachedDataForRule(nsIStyleRule* aInlineStyleRule) { mRuleNode->ClearCachedData(aInlineStyleRule); // XXXdwh. If we're willing to *really* special case @@ -505,10 +400,9 @@ nsStyleContext::ClearCachedDataForRule(nsIStyleRule* aInlineStyleRule) // that actually changed. For example, if someone changes // style.left, we really only need to blow away cached // data in the position struct. - return NS_OK; } -nsresult +void nsStyleContext::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule) { PRBool matched = PR_TRUE; @@ -541,13 +435,12 @@ nsStyleContext::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule child = child->mNextSibling; } while (mEmptyChild != child); } - - return NS_OK; } -NS_IMETHODIMP -nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint) +nsChangeHint +nsStyleContext::CalcStyleDifference(nsStyleContext* aOther) { + nsChangeHint hint = NS_STYLE_HINT_NONE; if (aOther) { // If our rule nodes are the same, then we are looking at the same style // data. We know this because CalcStyleDifference is always called on two @@ -557,72 +450,70 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint nsRuleNode* ruleNode; aOther->GetRuleNode(&ruleNode); if (ruleNode == mRuleNode) - return NS_OK; + return hint; nsChangeHint maxHint = NS_STYLE_HINT_FRAMECHANGE; // We begin by examining those style structs that are capable of causing the maximal // difference, a FRAMECHANGE. // FRAMECHANGE Structs: Display, XUL, Content, UserInterface, Visibility, Quotes - if (!NS_IsHintSubset(maxHint, aHint)) { - const nsStyleDisplay* display = (const nsStyleDisplay*)PeekStyleData(eStyleStruct_Display); - if (display) { - const nsStyleDisplay* otherDisplay = (const nsStyleDisplay*)aOther->GetStyleData(eStyleStruct_Display); - if (display != otherDisplay) { - NS_UpdateHint(aHint, display->CalcDifference(*otherDisplay)); - } + const nsStyleDisplay* display = (const nsStyleDisplay*)PeekStyleData(eStyleStruct_Display); + if (display) { + const nsStyleDisplay* otherDisplay = (const nsStyleDisplay*)aOther->GetStyleData(eStyleStruct_Display); + if (display != otherDisplay) { + NS_UpdateHint(hint, display->CalcDifference(*otherDisplay)); } } #ifdef INCLUDE_XUL - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleXUL* xul = (const nsStyleXUL*)PeekStyleData(eStyleStruct_XUL); if (xul) { const nsStyleXUL* otherXUL = (const nsStyleXUL*)aOther->GetStyleData(eStyleStruct_XUL); if (xul != otherXUL) { - NS_UpdateHint(aHint, xul->CalcDifference(*otherXUL)); + NS_UpdateHint(hint, xul->CalcDifference(*otherXUL)); } } } #endif - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleContent* content = (const nsStyleContent*)PeekStyleData(eStyleStruct_Content); if (content) { const nsStyleContent* otherContent = (const nsStyleContent*)aOther->GetStyleData(eStyleStruct_Content); if (content != otherContent) { - NS_UpdateHint(aHint, content->CalcDifference(*otherContent)); + NS_UpdateHint(hint, content->CalcDifference(*otherContent)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleUserInterface* ui = (const nsStyleUserInterface*)PeekStyleData(eStyleStruct_UserInterface); if (ui) { const nsStyleUserInterface* otherUI = (const nsStyleUserInterface*)aOther->GetStyleData(eStyleStruct_UserInterface); if (ui != otherUI) { - NS_UpdateHint(aHint, ui->CalcDifference(*otherUI)); + NS_UpdateHint(hint, ui->CalcDifference(*otherUI)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleVisibility* vis = (const nsStyleVisibility*)PeekStyleData(eStyleStruct_Visibility); if (vis) { const nsStyleVisibility* otherVis = (const nsStyleVisibility*)aOther->GetStyleData(eStyleStruct_Visibility); if (vis != otherVis) { - NS_UpdateHint(aHint, vis->CalcDifference(*otherVis)); + NS_UpdateHint(hint, vis->CalcDifference(*otherVis)); } } } #ifdef MOZ_SVG - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleSVG* svg = (const nsStyleSVG*)PeekStyleData(eStyleStruct_SVG); if (svg) { const nsStyleSVG* otherSVG = (const nsStyleSVG*)aOther->GetStyleData(eStyleStruct_SVG); if (svg != otherSVG) { - NS_UpdateHint(aHint, svg->CalcDifference(*otherSVG)); + NS_UpdateHint(hint, svg->CalcDifference(*otherSVG)); } } } @@ -630,12 +521,12 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // If the quotes implementation is ever going to change we might not need // a framechange here and a reflow should be sufficient. See bug 35768. - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleQuotes* quotes = (const nsStyleQuotes*)PeekStyleData(eStyleStruct_Quotes); if (quotes) { const nsStyleQuotes* otherQuotes = (const nsStyleQuotes*)aOther->GetStyleData(eStyleStruct_Quotes); if (quotes != otherQuotes) { - NS_UpdateHint(aHint, quotes->CalcDifference(*otherQuotes)); + NS_UpdateHint(hint, quotes->CalcDifference(*otherQuotes)); } } } @@ -646,102 +537,102 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // The following structs cause (as their maximal difference) a reflow to occur. // REFLOW Structs: Font, Margin, Padding, Border, List, Position, Text, TextReset, // Table, TableBorder - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleFont* font = (const nsStyleFont*)PeekStyleData(eStyleStruct_Font); if (font) { const nsStyleFont* otherFont = (const nsStyleFont*)aOther->GetStyleData(eStyleStruct_Font); if (font != otherFont) { - NS_UpdateHint(aHint, font->CalcDifference(*otherFont)); + NS_UpdateHint(hint, font->CalcDifference(*otherFont)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleMargin* margin = (const nsStyleMargin*)PeekStyleData(eStyleStruct_Margin); if (margin) { const nsStyleMargin* otherMargin = (const nsStyleMargin*)aOther->GetStyleData(eStyleStruct_Margin); if (margin != otherMargin) { - NS_UpdateHint(aHint, margin->CalcDifference(*otherMargin)); + NS_UpdateHint(hint, margin->CalcDifference(*otherMargin)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStylePadding* padding = (const nsStylePadding*)PeekStyleData(eStyleStruct_Padding); if (padding) { const nsStylePadding* otherPadding = (const nsStylePadding*)aOther->GetStyleData(eStyleStruct_Padding); if (padding != otherPadding) { - NS_UpdateHint(aHint, padding->CalcDifference(*otherPadding)); + NS_UpdateHint(hint, padding->CalcDifference(*otherPadding)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleBorder* border = (const nsStyleBorder*)PeekStyleData(eStyleStruct_Border); if (border) { const nsStyleBorder* otherBorder = (const nsStyleBorder*)aOther->GetStyleData(eStyleStruct_Border); if (border != otherBorder) { - NS_UpdateHint(aHint, border->CalcDifference(*otherBorder)); + NS_UpdateHint(hint, border->CalcDifference(*otherBorder)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleList* list = (const nsStyleList*)PeekStyleData(eStyleStruct_List); if (list) { const nsStyleList* otherList = (const nsStyleList*)aOther->GetStyleData(eStyleStruct_List); if (list != otherList) { - NS_UpdateHint(aHint, list->CalcDifference(*otherList)); + NS_UpdateHint(hint, list->CalcDifference(*otherList)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStylePosition* pos = (const nsStylePosition*)PeekStyleData(eStyleStruct_Position); if (pos) { const nsStylePosition* otherPosition = (const nsStylePosition*)aOther->GetStyleData(eStyleStruct_Position); if (pos != otherPosition) { - NS_UpdateHint(aHint, pos->CalcDifference(*otherPosition)); + NS_UpdateHint(hint, pos->CalcDifference(*otherPosition)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleText* text = (const nsStyleText*)PeekStyleData(eStyleStruct_Text); if (text) { const nsStyleText* otherText = (const nsStyleText*)aOther->GetStyleData(eStyleStruct_Text); if (text != otherText) { - NS_UpdateHint(aHint, text->CalcDifference(*otherText)); + NS_UpdateHint(hint, text->CalcDifference(*otherText)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTextReset* text = (const nsStyleTextReset*)PeekStyleData(eStyleStruct_TextReset); if (text) { const nsStyleTextReset* otherText = (const nsStyleTextReset*)aOther->GetStyleData(eStyleStruct_TextReset); if (text != otherText) { - NS_UpdateHint(aHint, text->CalcDifference(*otherText)); + NS_UpdateHint(hint, text->CalcDifference(*otherText)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTable* table = (const nsStyleTable*)PeekStyleData(eStyleStruct_Table); if (table) { const nsStyleTable* otherTable = (const nsStyleTable*)aOther->GetStyleData(eStyleStruct_Table); if (table != otherTable) { - NS_UpdateHint(aHint, table->CalcDifference(*otherTable)); + NS_UpdateHint(hint, table->CalcDifference(*otherTable)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTableBorder* table = (const nsStyleTableBorder*)PeekStyleData(eStyleStruct_TableBorder); if (table) { const nsStyleTableBorder* otherTable = (const nsStyleTableBorder*)aOther->GetStyleData(eStyleStruct_TableBorder); if (table != otherTable) { - NS_UpdateHint(aHint, table->CalcDifference(*otherTable)); + NS_UpdateHint(hint, table->CalcDifference(*otherTable)); } } } @@ -752,47 +643,47 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // The following structs cause (as their maximal difference) a re-render to occur. // VISUAL Structs: Color, Background, Outline, UIReset - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleColor* color = (const nsStyleColor*)PeekStyleData(eStyleStruct_Color); if (color) { const nsStyleColor* otherColor = (const nsStyleColor*)aOther->GetStyleData(eStyleStruct_Color); if (color != otherColor) { - NS_UpdateHint(aHint, color->CalcDifference(*otherColor)); + NS_UpdateHint(hint, color->CalcDifference(*otherColor)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleBackground* background = (const nsStyleBackground*)PeekStyleData(eStyleStruct_Background); if (background) { const nsStyleBackground* otherBackground = (const nsStyleBackground*)aOther->GetStyleData(eStyleStruct_Background); if (background != otherBackground) { - NS_UpdateHint(aHint, background->CalcDifference(*otherBackground)); + NS_UpdateHint(hint, background->CalcDifference(*otherBackground)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleOutline* outline = (const nsStyleOutline*)PeekStyleData(eStyleStruct_Outline); if (outline) { const nsStyleOutline* otherOutline = (const nsStyleOutline*)aOther->GetStyleData(eStyleStruct_Outline); if (outline != otherOutline) { - NS_UpdateHint(aHint, outline->CalcDifference(*otherOutline)); + NS_UpdateHint(hint, outline->CalcDifference(*otherOutline)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleUIReset* ui = (const nsStyleUIReset*)PeekStyleData(eStyleStruct_UIReset); if (ui) { const nsStyleUIReset* otherUI = (const nsStyleUIReset*)aOther->GetStyleData(eStyleStruct_UIReset); if (ui != otherUI) { - NS_UpdateHint(aHint, ui->CalcDifference(*otherUI)); + NS_UpdateHint(hint, ui->CalcDifference(*otherUI)); } } } } - return NS_OK; + return hint; } #ifdef DEBUG @@ -802,7 +693,7 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent) PRInt32 ix; for (ix = aIndent; --ix >= 0; ) fputs(" ", out); fprintf(out, "%p(%d) parent=%p ", - (void*)this, mRefCnt.get(), (void *)mParent); + (void*)this, mRefCnt, (void *)mParent); if (mPseudoTag) { nsAutoString buffer; mPseudoTag->ToString(buffer); @@ -1176,24 +1067,16 @@ nsStyleContext::Destroy() presContext->FreeToShell(sizeof(nsStyleContext), this); } -NS_EXPORT nsresult -NS_NewStyleContext(nsIStyleContext** aInstancePtrResult, - nsIStyleContext* aParentContext, +already_AddRefed +NS_NewStyleContext(nsStyleContext* aParentContext, nsIAtom* aPseudoTag, nsRuleNode* aRuleNode, nsIPresContext* aPresContext) { - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag, aRuleNode, aPresContext); - if (!context) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return CallQueryInterface(context, aInstancePtrResult); + if (context) + context->AddRef(); + return context; } diff --git a/mozilla/content/base/src/nsStyleSet.cpp b/mozilla/content/base/src/nsStyleSet.cpp index cec07984b8f..9e4c35e439a 100644 --- a/mozilla/content/base/src/nsStyleSet.cpp +++ b/mozilla/content/base/src/nsStyleSet.cpp @@ -149,24 +149,27 @@ public: NS_IMETHOD NotifyStyleSheetStateChanged(PRBool aDisabled); - virtual nsIStyleContext* ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ResolveStyleFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aParentContext); - virtual nsIStyleContext* ResolveStyleForNonElement( - nsIPresContext* aPresContext, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ResolveStyleForNonElement(nsIPresContext* aPresContext, + nsStyleContext* aParentContext); - virtual nsIStyleContext* ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator = nsnull); + virtual already_AddRefed + ResolvePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator = nsnull); - virtual nsIStyleContext* ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ProbePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext); NS_IMETHOD Shutdown(); @@ -189,7 +192,7 @@ public: virtual nsresult AddRuleNodeMapping(nsRuleNode* aRuleNode); - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext); + virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsStyleContext* aContext); virtual nsresult GetStyleFrameConstruction(nsIStyleFrameConstruction** aResult) { *aResult = mFrameConstructor; @@ -197,10 +200,10 @@ public: return NS_OK; } - NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, - nsIStyleContext* aNewParentContext, - nsIStyleContext** aNewStyleContext); + virtual already_AddRefed + ReParentStyleContext(nsIPresContext* aPresContext, + nsStyleContext* aStyleContext, + nsStyleContext* aNewParentContext); NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext, nsIContent* aContent, @@ -335,9 +338,9 @@ protected: void WalkRuleProcessors(nsISupportsArrayEnumFunc aFunc, RuleProcessorData* aData); - nsIStyleContext* GetContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - nsIAtom* aPseudoTag); + already_AddRefed GetContext(nsIPresContext* aPresContext, + nsStyleContext* aParentContext, + nsIAtom* aPseudoTag); #ifdef DEBUG void List(FILE* out, PRInt32 aIndent, nsISupportsArray* aSheets); @@ -999,15 +1002,16 @@ EnumRulesMatching(nsISupports* aProcessor, void* aData) * generation. (It works for cousins of the same generation since * |aParentContext| could itself be a shared context.) */ -nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - nsIAtom* aPseudoTag) +already_AddRefed +StyleSetImpl::GetContext(nsIPresContext* aPresContext, + nsStyleContext* aParentContext, + nsIAtom* aPseudoTag) { - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode(); if (aParentContext) - aParentContext->FindChildWithRules(aPseudoTag, ruleNode, result); + result = aParentContext->FindChildWithRules(aPseudoTag, ruleNode).get(); #ifdef NOISY_DEBUG if (result) @@ -1017,8 +1021,8 @@ nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext, #endif if (!result) - NS_NewStyleContext(&result, aParentContext, aPseudoTag, ruleNode, - aPresContext); + result = NS_NewStyleContext(aParentContext, aPseudoTag, ruleNode, + aPresContext).get(); return result; } @@ -1150,14 +1154,15 @@ void StyleSetImpl::EnsureRuleWalker(nsIPresContext* aPresContext) mRuleWalker = new nsRuleWalker(mRuleTree); } -nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolveStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aContent, "must have content"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1175,7 +1180,7 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, aPresContext->GetMedium(getter_AddRefs(medium)); RulesMatchingData data(aPresContext, medium, aContent, mRuleWalker); FileRules(EnumRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, nsnull); + result = GetContext(aPresContext, aParentContext, nsnull).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1187,14 +1192,14 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, return result; } -nsIStyleContext* StyleSetImpl::ResolveStyleForNonElement( - nsIPresContext* aPresContext, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ResolveStyleForNonElement(nsIPresContext* aPresContext, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolveStyleForNonElement(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPresContext, "must have pres context"); @@ -1206,7 +1211,7 @@ nsIStyleContext* StyleSetImpl::ResolveStyleForNonElement( mOverrideRuleProcessors) { EnsureRuleWalker(aPresContext); result = GetContext(aPresContext, aParentContext, - nsCSSAnonBoxes::mozNonElement); + nsCSSAnonBoxes::mozNonElement).get(); NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root"); } } @@ -1242,16 +1247,17 @@ EnumPseudoRulesMatching(nsISupports* aProcessor, void* aData) return PR_TRUE; } -nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) +already_AddRefed +StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolvePseudoStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPseudoTag, "must have pseudo tag"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1272,7 +1278,7 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex aPseudoTag, aComparator, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, aPseudoTag); + result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1284,15 +1290,16 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex return result; } -nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ProbePseudoStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPseudoTag, "must have pseudo tag"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1314,7 +1321,7 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, FileRules(EnumPseudoRulesMatching, &data); if (!mRuleWalker->AtRoot()) - result = GetContext(aPresContext, aParentContext, aPseudoTag); + result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1397,7 +1404,7 @@ StyleSetImpl::ClearCachedDataInRuleTree(nsIStyleRule* aInlineStyleRule) } nsresult -StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext) +StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsStyleContext* aContext) { // XXXdwh. If we're willing to *really* optimize this // invalidation, we could only invalidate the struct data @@ -1450,8 +1457,7 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIFrame* rootFrame; shell->GetRootFrame(&rootFrame); if (rootFrame) { - nsCOMPtr rootContext; - rootFrame->GetStyleContext(getter_AddRefs(rootContext)); + nsStyleContext* rootContext = rootFrame->GetStyleContext(); if (rootContext) rootContext->ClearStyleData(aPresContext, aRule); } @@ -1460,46 +1466,38 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, return NS_OK; } -NS_IMETHODIMP +already_AddRefed StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, - nsIStyleContext* aNewParentContext, - nsIStyleContext** aNewStyleContext) + nsStyleContext* aStyleContext, + nsStyleContext* aNewParentContext) { NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(aStyleContext, "must have style context"); - NS_ASSERTION(aNewStyleContext, "must have new style context"); - nsresult result = NS_ERROR_NULL_POINTER; - - if (aPresContext && aStyleContext && aNewStyleContext) { - nsCOMPtr oldParent = aStyleContext->GetParent(); + if (aPresContext && aStyleContext) { + nsStyleContext* oldParent = aStyleContext->GetParent(); if (oldParent == aNewParentContext) { - result = NS_OK; - NS_ADDREF(aStyleContext); // for return - *aNewStyleContext = aStyleContext; + aStyleContext->AddRef(); + return aStyleContext; } else { // really a new parent - nsIStyleContext* newChild = nsnull; - nsCOMPtr pseudoTag; - aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsStyleContext* newChild = nsnull; + nsCOMPtr pseudoTag = aStyleContext->GetPseudoType(); nsRuleNode* ruleNode; aStyleContext->GetRuleNode(&ruleNode); - if (aNewParentContext) { - result = aNewParentContext->FindChildWithRules(pseudoTag, ruleNode, newChild); - } - if (newChild) { // new parent already has one - *aNewStyleContext = newChild; - } + if (aNewParentContext) + newChild = aNewParentContext->FindChildWithRules(pseudoTag, ruleNode).get(); + if (newChild) // new parent already has one + return newChild; else { // need to make one in the new parent - result = NS_NewStyleContext(aNewStyleContext, aNewParentContext, pseudoTag, - ruleNode, aPresContext); + return NS_NewStyleContext(aNewParentContext, pseudoTag, ruleNode, + aPresContext); } } } - return result; + return nsnull; } struct StatefulData : public StateRuleProcessorData { @@ -1764,8 +1762,7 @@ void StyleSetImpl::List(FILE* out, PRInt32 aIndent) void StyleSetImpl::ListContexts(nsIFrame* aRootFrame, FILE* out, PRInt32 aIndent) { - nsCOMPtr sc; - aRootFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aRootFrame->GetStyleContext(); if (sc) sc->List(out, aIndent); } diff --git a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp index dcd6e39f9a0..6b0d0f4b27b 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp @@ -47,6 +47,7 @@ #include "nsIPresContext.h" #include "nsRuleNode.h" #include "nsHTMLAttributes.h" +#include "nsStyleContext.h" class nsHTMLSharedLeafElement : public nsGenericHTMLLeafElement, diff --git a/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp index dcd6e39f9a0..6b0d0f4b27b 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp @@ -47,6 +47,7 @@ #include "nsIPresContext.h" #include "nsRuleNode.h" #include "nsHTMLAttributes.h" +#include "nsStyleContext.h" class nsHTMLSharedLeafElement : public nsGenericHTMLLeafElement, diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 1a76de9fa0a..bf5b59c7974 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -50,6 +50,7 @@ #include "nsIPresContext.h" #include "nsHTMLParts.h" #include "nsRuleNode.h" +#include "nsStyleContext.h" /* for collections */ #include "nsIDOMElement.h" diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 094f93c1219..694f5a85ac8 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -55,11 +55,12 @@ #include "nsIScrollable.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIViewManager.h" #include "nsIStringBundle.h" #include "nsIPrefService.h" #include "nsITextToSubURI.h" +#include "nsAutoPtr.h" #define NSIMAGEDOCUMENT_PROPERTIES_URI "chrome://communicator/locale/layout/ImageDocument.properties" #define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing" @@ -594,9 +595,8 @@ nsImageDocument::CheckOverflowing() nsRect visibleArea; context->GetVisibleArea(visibleArea); - nsCOMPtr styleContext; nsCOMPtr content = do_QueryInterface(mBodyContent); - context->ResolveStyleContextFor(content, nsnull, getter_AddRefs(styleContext)); + nsRefPtr styleContext = context->ResolveStyleContextFor(content, nsnull); const nsStyleMargin* marginData = (const nsStyleMargin*)styleContext->GetStyleData(eStyleStruct_Margin); diff --git a/mozilla/content/html/style/public/nsStyleUtil.h b/mozilla/content/html/style/public/nsStyleUtil.h index 5a33ee77bdd..6393e157d98 100644 --- a/mozilla/content/html/style/public/nsStyleUtil.h +++ b/mozilla/content/html/style/public/nsStyleUtil.h @@ -42,7 +42,6 @@ #include "nsIPresContext.h" #include "nsILinkHandler.h" // for nsLinkState -class nsIStyleContext; struct nsStyleBackground; enum nsFontSizeType { diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index 88d21e667f1..3795eb52a37 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -73,6 +73,7 @@ #include "nsISizeOfHandler.h" #include "nsContentUtils.h" +#include "nsContentErrors.h" // #define DEBUG_REFS diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp index 9c5cf771a27..685367036d5 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp @@ -44,7 +44,7 @@ #include "nsDOMError.h" #include "nsIDOMCSS2Properties.h" #include "nsIDOMElement.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIScrollableFrame.h" #include "nsContentUtils.h" #include "prprf.h" @@ -3034,18 +3034,16 @@ nsComputedDOMStyle::GetStyleData(nsStyleStructID aID, nsCOMPtr pctx; presShell->GetPresContext(getter_AddRefs(pctx)); if (pctx) { - nsCOMPtr sctx; + nsStyleContext* sctx; if (!mPseudo) { - pctx->ResolveStyleContextFor(mContent, nsnull, - getter_AddRefs(sctx)); + sctx = pctx->ResolveStyleContextFor(mContent, nsnull).get(); } else { - pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull, - getter_AddRefs(sctx)); + sctx = pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull).get(); } if (sctx) { aStyleStruct = sctx->GetStyleData(aID); } - mStyleContextHolder = sctx; + mStyleContextHolder = dont_AddRef(sctx); // transfer ref from sctx } } NS_ASSERTION(aStyleStruct, "Failed to get a style struct"); diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.h b/mozilla/content/html/style/src/nsComputedDOMStyle.h index cdcd52b9dd3..e51d29ee2f4 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.h +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.h @@ -53,6 +53,7 @@ #include "nsIFrame.h" #include "nsCOMPtr.h" #include "nsWeakReference.h" +#include "nsAutoPtr.h" class nsComputedDOMStyle : public nsIComputedDOMStyle { @@ -302,7 +303,7 @@ private: * When a frame is unavailable, strong reference to the * style context while we're accessing the data from in. */ - nsCOMPtr mStyleContextHolder; + nsRefPtr mStyleContextHolder; nsCOMPtr mPseudo; float mT2P; /* For unit conversions */ diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 9400f2caa72..bd1ff22e153 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -42,7 +42,7 @@ #include "nsIStyleRuleProcessor.h" #include "nsIStyleRule.h" #include "nsIFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsHTMLAtoms.h" #include "nsIPresContext.h" #include "nsIEventStateManager.h" @@ -393,7 +393,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa { nsStyleText* text = (nsStyleText*)aStyleStruct; if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) { - nsCOMPtr parentContext = aRuleData->mStyleContext->GetParent(); + nsStyleContext* parentContext = aRuleData->mStyleContext->GetParent(); if (parentContext) { const nsStyleText* parentStyleText = @@ -426,7 +426,7 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct, { if (!aStyleStruct || !aRuleData || !aRuleData->mPresContext) return; - nsCOMPtr tableContext = aRuleData->mStyleContext->GetParent(); + nsStyleContext* tableContext = aRuleData->mStyleContext->GetParent(); if (!tableContext) return; if (!aGroup) { diff --git a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp index 9d073a32cd3..b327a0ab4b5 100644 --- a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp +++ b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp @@ -43,6 +43,8 @@ #include "nsLayoutAtoms.h" #include "nsIDocument.h" #include "nsIPresShell.h" +#include "nsAutoPtr.h" +#include "nsIFrame.h" nsInspectorCSSUtils::nsInspectorCSSUtils() { @@ -113,18 +115,12 @@ nsInspectorCSSUtils::AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect) return NS_OK; } -nsresult -nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) +nsStyleContext* +nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame) { - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); - if (!styleContext) { - // Caller returns rv on through, and this does not seem - // exception-worthy. - *aStyleContext = nsnull; - return NS_OK; - } + nsStyleContext* styleContext = aFrame->GetStyleContext(); + if (!styleContext) + return nsnull; /* For tables the primary frame is the "outer frame" but the style * rules are applied to the "inner frame". Luckily, the "outer @@ -133,45 +129,42 @@ nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame, */ nsCOMPtr frameType; aFrame->GetFrameType(getter_AddRefs(frameType)); - if (frameType == nsLayoutAtoms::tableOuterFrame) { - *aStyleContext = styleContext->GetParent().get(); - } else { - *aStyleContext = styleContext; - NS_ADDREF(*aStyleContext); - } - return NS_OK; + if (frameType == nsLayoutAtoms::tableOuterFrame) + return styleContext->GetParent(); + + return styleContext; } -nsresult +already_AddRefed nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, - nsIPresShell* aPresShell, - nsIStyleContext** aStyleContext) + nsIPresShell* aPresShell) { nsIFrame* frame = nsnull; aPresShell->GetPrimaryFrameFor(aContent, &frame); - if (frame) - return GetStyleContextForFrame(frame, aStyleContext); + if (frame) { + nsStyleContext* result = GetStyleContextForFrame(frame); + // this function returns an addrefed style context + if (result) + result->AddRef(); + return result; + } // No frame has been created, so resolve the style ourselves - nsCOMPtr parentContext; + nsRefPtr parentContext; nsCOMPtr parent; aContent->GetParent(*getter_AddRefs(parent)); - if (parent) { - nsresult rv = GetStyleContextForContent(parent, aPresShell, - getter_AddRefs(parentContext)); - NS_ENSURE_SUCCESS(rv, rv); - } + if (parent) + parentContext = GetStyleContextForContent(parent, aPresShell); nsCOMPtr presContext; aPresShell->GetPresContext(getter_AddRefs(presContext)); - NS_ENSURE_TRUE(presContext, NS_ERROR_UNEXPECTED); + if (!presContext) + return nsnull; if (aContent->IsContentOfType(nsIContent::eELEMENT)) - return presContext->ResolveStyleContextFor(aContent, parentContext, - aStyleContext); + return presContext->ResolveStyleContextFor(aContent, parentContext); - return presContext->ResolveStyleContextForNonElement(parentContext, - aStyleContext); + return presContext->ResolveStyleContextForNonElement(parentContext); } NS_IMETHODIMP @@ -188,10 +181,7 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent, doc->GetShellAt(0, getter_AddRefs(presShell)); NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED); - nsCOMPtr sContext; - nsresult rv = GetStyleContextForContent(aContent, presShell, - getter_AddRefs(sContext)); - NS_ENSURE_SUCCESS(rv, rv); - - return sContext->GetRuleNode(aRuleNode); + nsRefPtr sContext = GetStyleContextForContent(aContent, presShell); + sContext->GetRuleNode(aRuleNode); + return NS_OK; } diff --git a/mozilla/content/html/style/src/nsInspectorCSSUtils.h b/mozilla/content/html/style/src/nsInspectorCSSUtils.h index eef6a8176a3..65158b2b7a3 100644 --- a/mozilla/content/html/style/src/nsInspectorCSSUtils.h +++ b/mozilla/content/html/style/src/nsInspectorCSSUtils.h @@ -41,9 +41,10 @@ #define nsInspectorCSSUtils_h___ #include "nsIInspectorCSSUtils.h" +#include "nsStyleContext.h" +#include "nsAutoPtr.h" class nsIPresShell; -class nsIStyleContext; class nsInspectorCSSUtils : public nsIInspectorCSSUtils { @@ -64,11 +65,10 @@ public: nsRuleNode** aRuleNode); private: - nsresult GetStyleContextForContent(nsIContent* aContent, - nsIPresShell* aPresShell, - nsIStyleContext** aStyleContext); - nsresult GetStyleContextForFrame(nsIFrame* aFrame, - nsIStyleContext** aStyleContext); + already_AddRefed + GetStyleContextForContent(nsIContent* aContent, nsIPresShell* aPresShell); + + nsStyleContext* GetStyleContextForFrame(nsIFrame* aFrame); }; #endif /* nsInspectorCSSUtils_h___ */ diff --git a/mozilla/content/shared/public/Makefile.in b/mozilla/content/shared/public/Makefile.in index c9c8dc45f23..8f1924fd5ea 100644 --- a/mozilla/content/shared/public/Makefile.in +++ b/mozilla/content/shared/public/Makefile.in @@ -50,6 +50,7 @@ nsLayoutAtomList.h \ nsLayoutAtoms.h \ nsRuleNode.h \ nsRuleWalker.h \ +nsStyleContext.h \ nsStyleCoord.h \ nsStyleStruct.h \ nsStyleStructList.h \ diff --git a/mozilla/content/shared/public/nsRuleNode.h b/mozilla/content/shared/public/nsRuleNode.h index 746e6dd01df..fe978d1ab8c 100644 --- a/mozilla/content/shared/public/nsRuleNode.h +++ b/mozilla/content/shared/public/nsRuleNode.h @@ -42,13 +42,13 @@ #include "nsCOMPtr.h" #include "nsIStyleRule.h" -#include "nsIFrame.h" #include "nsFixedSizeAllocator.h" #include "nsIPresContext.h" #include "nsCSSDeclaration.h" #include "nsILanguageAtomService.h" +#include "nsStyleStruct.h" -class nsIStyleContext; +class nsStyleContext; struct nsRuleList; struct PLDHashTable; @@ -245,7 +245,7 @@ struct nsRuleData nsStyleStructID mSID; PRPackedBool mCanStoreInRuleTree; nsIPresContext* mPresContext; - nsIStyleContext* mStyleContext; + nsStyleContext* mStyleContext; nsPostResolveFunc mPostResolveCallback; nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! nsRuleDataDisplay* mDisplayData; @@ -266,7 +266,7 @@ struct nsRuleData nsRuleDataSVG* mSVGData; #endif - nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext) + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), @@ -409,89 +409,89 @@ protected: void PropagateDependentBit(PRUint32 aBit, nsRuleNode* aHighestNode); void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode); - const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext); + const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext); - const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsIStyleContext* aContext, + const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext, nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData, PRBool aComputeData); const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsRuleDataStruct& aDisplayData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsRuleDataStruct& aDisplayData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsRuleDataStruct& aFontData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsRuleDataStruct& aColorData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsRuleDataStruct& aColorData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsRuleDataStruct& aListData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsRuleDataStruct& aPositionData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #ifdef INCLUDE_XUL const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsRuleDataStruct& aXULData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #endif #ifdef MOZ_SVG const nsStyleStruct* ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #endif @@ -499,7 +499,7 @@ protected: typedef const nsStyleStruct* (nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aStartData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); @@ -509,33 +509,33 @@ protected: inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct); const nsStyleStruct* GetParentData(const nsStyleStructID aSID); - const nsStyleStruct* GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetFontData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetColorData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetMarginData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetBorderData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetListData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetPositionData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTableData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetContentData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTextData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetDisplayData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetVisibilityData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetFontData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetColorData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetBackgroundData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetMarginData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetBorderData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetPaddingData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetOutlineData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetListData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetPositionData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTableData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTableBorderData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetContentData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetQuotesData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTextData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTextResetData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetUserInterfaceData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetUIResetData(nsStyleContext* aContext, PRBool aComputeData); #ifdef INCLUDE_XUL - const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetXULData(nsStyleContext* aContext, PRBool aComputeData); #endif #ifdef MOZ_SVG - const nsStyleStruct* GetSVGData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetSVGData(nsStyleContext* aContext, PRBool aComputeData); #endif - typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*, PRBool); + typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsStyleContext*, PRBool); static GetStyleDataFn gGetStyleDataFn[]; public: @@ -568,7 +568,7 @@ public: nsresult GetPresContext(nsIPresContext** aResult); nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched); const nsStyleStruct* GetStyleData(nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, PRBool aComputeData); }; diff --git a/mozilla/content/shared/public/nsStyleContext.h b/mozilla/content/shared/public/nsStyleContext.h new file mode 100644 index 00000000000..974f6bb87eb --- /dev/null +++ b/mozilla/content/shared/public/nsStyleContext.h @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Hyatt + * Pierre Phaneuf + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _nsStyleContext_h_ +#define _nsStyleContext_h_ + +#include "nsRuleNode.h" + +class nsIPresContext; +class nsIAtom; + +class nsStyleContext +{ +public: + nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag, + nsRuleNode* aRuleNode, nsIPresContext* aPresContext); + ~nsStyleContext(); + + void* operator new(size_t sz, nsIPresContext* aPresContext) CPP_THROW_NEW; + void Destroy(); + + void AddRef() { + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsStyleContext", sizeof(nsStyleContext)); + } + + void Release() { + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsStyleContext"); + if (mRefCnt == 0) { + mRefCnt = 1; + Destroy(); + } + } + + nsStyleContext* GetParent() const { return mParent; } + + nsStyleContext* GetFirstChild() const { return mChild; } + + already_AddRefed GetPseudoType() const; + + already_AddRefed + FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules); + + PRBool Equals(const nsStyleContext* aOther) const; + PRBool HasTextDecorations() { return mBits & NS_STYLE_HAS_TEXT_DECORATIONS; }; + + void GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding); + + void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct); + + void GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; } + void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; } + void GetStyleBits(PRUint32* aBits) { *aBits = mBits; } + + const nsStyleStruct* GetStyleData(nsStyleStructID aSID); + const nsStyleStruct* PeekStyleData(nsStyleStructID aSID); + + nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID); + + void ClearCachedDataForRule(nsIStyleRule* aRule); + + void ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule); + + nsChangeHint CalcStyleDifference(nsStyleContext* aOther); + +#ifdef DEBUG + void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); + + void List(FILE* out, PRInt32 aIndent); + + void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize); +#endif + +protected: + void AppendChild(nsStyleContext* aChild); + void RemoveChild(nsStyleContext* aChild); + + void ApplyStyleFixups(nsIPresContext* aPresContext); + + nsStyleContext* mParent; + nsStyleContext* mChild; + nsStyleContext* mEmptyChild; + nsStyleContext* mPrevSibling; + nsStyleContext* mNextSibling; + + // If this style context is for a pseudo-element, the pseudo-element + // atom. Otherwise, null. + nsCOMPtr mPseudoTag; + + nsRuleNode* mRuleNode; + + // |mCachedStyleData| points to both structs that are owned by this + // style context and structs that are owned by one of this style + // context's ancestors (which are indirectly owned since this style + // context owns a reference to its parent). If the bit in |mBits| is + // set for a struct, that means that the pointer for that struct is + // owned by an ancestor rather than by this style context. + nsCachedStyleData mCachedStyleData; // Our cached style data. + PRUint32 mBits; // Which structs are inherited from the + // parent context. + PRUint32 mRefCnt; +}; + +already_AddRefed +NS_NewStyleContext(nsStyleContext* aParentContext, + nsIAtom* aPseudoTag, + nsRuleNode* aRuleNode, + nsIPresContext* aPresContext); + + +// typesafe way to access style data. See nsStyleStruct.h and also +// overloaded function in nsIFrame.h. +template +inline void +GetStyleData(nsStyleContext* aStyleContext, const T** aStyleStruct) +{ + *aStyleStruct = NS_STATIC_CAST(const T*, + aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T))); +} + +#endif diff --git a/mozilla/content/shared/public/nsStyleStruct.h b/mozilla/content/shared/public/nsStyleStruct.h index dd99d7931b8..92935245f44 100644 --- a/mozilla/content/shared/public/nsStyleStruct.h +++ b/mozilla/content/shared/public/nsStyleStruct.h @@ -1219,7 +1219,7 @@ inline nsBorderEdges::nsBorderEdges() // typesafe mechanisms for accessing style data, global function // templates |GetStyleData(nsIFrame*, const T**)| and -// |GetStyleData(nsIStyleContext*, const T**)|, where T is derived from -// nsStyleStruct, are located in nsIStyleContext.h and nsIFrame.h +// |GetStyleData(nsStyleContext*, const T**)|, where T is derived from +// nsStyleStruct, are located in nsStyleContext.h and nsIFrame.h #endif /* nsStyleStruct_h___ */ diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index 49e83428e16..2ab1fa3fc69 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -78,8 +78,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord, nsIFrame* parentFrame; aFrame->GetParent(&parentFrame); // XXX may not be direct parent... if (nsnull != parentFrame) { - nsIStyleContext* parentContext; - parentFrame->GetStyleContext(&parentContext); + nsStyleContext* parentContext = parentFrame->GetStyleContext(); if (nsnull != parentContext) { nsMargin parentSpacing; switch (aSpacing) { @@ -111,7 +110,6 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord, case NS_SIDE_RIGHT: result = parentSpacing.right; break; case NS_SIDE_BOTTOM: result = parentSpacing.bottom; break; } - NS_RELEASE(parentContext); } } break; diff --git a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp index dd548bcf1aa..6120ffffccb 100644 --- a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp +++ b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp @@ -57,7 +57,7 @@ #include "nsXBLAtoms.h" #include "nsINameSpaceManager.h" #include "nsIFrameManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" NS_IMPL_ISUPPORTS1(nsXBLResourceLoader, nsICSSLoaderObserver) @@ -279,8 +279,7 @@ nsXBLResourceLoader::NotifyBoundElements() // Check to see if it's in the undisplayed content map. nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); - nsCOMPtr sc; - frameManager->GetUndisplayedContent(content, getter_AddRefs(sc)); + nsStyleContext* sc = frameManager->GetUndisplayedContent(content); if (!sc) { nsCOMPtr obs(do_QueryInterface(shell)); obs->ContentInserted(doc, parent, content, index); diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index b8319f8b67a..762307d1d50 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -88,7 +88,7 @@ #include "nsIPresShell.h" #include "nsIDocumentObserver.h" #include "nsIFrameManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIXULPrototypeCache.h" #include "nsIDOMLoadListener.h" @@ -173,8 +173,7 @@ public: // Check to see if it's in the undisplayed content map. nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); - nsCOMPtr sc; - frameManager->GetUndisplayedContent(mBoundElement, getter_AddRefs(sc)); + nsStyleContext* sc = frameManager->GetUndisplayedContent(mBoundElement); if (!sc) { nsCOMPtr obs(do_QueryInterface(shell)); obs->ContentInserted(doc, parent, mBoundElement, index); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index ec0c4d3de45..dcd32f1ee36 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -148,6 +148,7 @@ #include "nsISizeOfHandler.h" #include "nsReadableUtils.h" #include "nsITimelineService.h" +#include "nsIFrame.h" class nsIWebShell; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp index e7879d8abde..87db5aa0ff4 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp @@ -52,7 +52,7 @@ #include "TypeInState.h" #include "nsIServiceManager.h" - +#include "nsCRT.h" #include "nsIContent.h" #include "nsIContentIterator.h" #include "nsIDOMNode.h" @@ -66,7 +66,6 @@ #include "nsIDOMNSRange.h" #include "nsIDOMCharacterData.h" #include "nsIEnumerator.h" -#include "nsIStyleContext.h" #include "nsIPresShell.h" #include "nsLayoutCID.h" #include "nsIPrefBranch.h" diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index ed37179c4eb..0e8bd493d5f 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -126,14 +126,13 @@ CreateBidiContinuation(nsIPresContext* aPresContext, if (!(*aNewFrame) ) { return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext) ); + nsStyleContext* styleContext = aFrame->GetStyleContext(); - NS_ASSERTION(presShell, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation"); + NS_ASSERTION(styleContext, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation"); aFrame->GetParent(&parent); - NS_ASSERTION(presShell, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation"); + NS_ASSERTION(parent, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation"); (*aNewFrame)->Init(aPresContext, aContent, parent, styleContext, nsnull); diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index dbf07098ab9..e50f0b19b51 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -114,6 +114,7 @@ #include "nsCSSRendering.h" #include "nsISelectElement.h" #include "nsLayoutErrors.h" +#include "nsAutoPtr.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -1024,7 +1025,7 @@ AdjustOutOfFlowFrameParentPtrs(nsIPresContext* aPresContext, */ static void MoveChildrenTo(nsIPresContext* aPresContext, - nsIStyleContext* aNewParentSC, + nsStyleContext* aNewParentSC, nsIFrame* aNewParent, nsIFrame* aFrameList, nsFrameConstructorState* aState) @@ -1376,7 +1377,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nsIDocument* aDocument, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsStyleContent* aStyleContent, PRUint32 aContentIndex, nsIFrame** aFrame) @@ -1568,7 +1569,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIFrame* aFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement, nsIFrame** aWrapperFrame, nsIFrame** aResult) @@ -1579,9 +1580,10 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe return PR_FALSE; // Probe for the existence of the pseudo-element - nsCOMPtr pseudoStyleContext; - aPresContext->ProbePseudoStyleContextFor(aContent, aPseudoElement, aStyleContext, - getter_AddRefs(pseudoStyleContext)); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, + aPseudoElement, + aStyleContext); if (pseudoStyleContext) { const nsStyleDisplay* display; @@ -1609,10 +1611,11 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe NS_NewInlineFrame(aPresShell, aWrapperFrame); wrapperPseudo = nsCSSAnonBoxes::mozGCWrapperInline; } - nsCOMPtr parentSC = aStyleContext->GetParent(); - nsCOMPtr wrapperSC; - aPresContext->ResolvePseudoStyleContextFor(nsnull, wrapperPseudo, - parentSC, getter_AddRefs(wrapperSC)); + nsStyleContext* parentSC = aStyleContext->GetParent(); + nsRefPtr wrapperSC; + wrapperSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, + wrapperPseudo, + parentSC); // |aFrame| is already the correct parent. InitAndRestoreFrame(aPresContext, aState, aContent, aFrame, wrapperSC, nsnull, *aWrapperFrame); @@ -1643,9 +1646,8 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe // Create another pseudo style context to use for all the generated child // frames - nsIStyleContext* textStyleContext; - aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext, - &textStyleContext); + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext); // Now create content objects (and child frames) for each value of the // 'content' property @@ -1665,7 +1667,6 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe } } - NS_RELEASE(textStyleContext); if (childFrames.childList) { containerFrame->SetInitialChildList(aPresContext, nsnull, childFrames.childList); } @@ -1683,7 +1684,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell, nsIPresContext *aPresContext, nsIContent *aContent, nsIFrame *&aFrame, - nsIStyleContext *aStyleContext) + nsStyleContext *aStyleContext) { nsCOMPtr control = do_QueryInterface(aContent); NS_ASSERTION(control, "input is not an nsIFormControl!"); @@ -1991,18 +1992,17 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel ? aState.mPseudoFrames.mCellInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); // create the SC for the inner table which will be the parent of the outer table's SC - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::table, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::table, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mTableOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mTableInner; @@ -2011,7 +2011,7 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel PRBool pseudoParent; nsFrameItems items; rv = ConstructTableFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudoOuter.mFrame, pseudoInner.mFrame, pseudoParent); @@ -2042,17 +2042,16 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS ? aState.mPseudoFrames.mTableInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRowGroup, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableRowGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRowGroup; @@ -2060,7 +2059,7 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS PRBool pseudoParent; nsFrameItems items; rv = ConstructTableRowGroupFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2088,17 +2087,16 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS ? aState.mPseudoFrames.mTableInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableColGroup, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableColGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mColGroup; @@ -2106,7 +2104,7 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS PRBool pseudoParent; nsFrameItems items; rv = ConstructTableColGroupFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; ((nsTableColGroupFrame*)pseudo.mFrame)->SetType(eColGroupAnonymousCol); @@ -2132,17 +2130,16 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, ? aState.mPseudoFrames.mRowGroup.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRow, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableRow, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRow; @@ -2150,7 +2147,7 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, PRBool pseudoParent; nsFrameItems items; rv = ConstructTableRowFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2177,17 +2174,16 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell ? aState.mPseudoFrames.mRow.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableCell, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableCell, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mCellOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mCellInner; @@ -2196,7 +2192,7 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell PRBool pseudoParent; nsFrameItems items; rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudoOuter.mFrame, pseudoInner.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2528,7 +2524,7 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2557,11 +2553,10 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, } // create the pseudo SC for the outer table as a child of the inner SC - nsCOMPtr outerStyleContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::tableOuter, - aStyleContext, - getter_AddRefs(outerStyleContext)); + nsRefPtr outerStyleContext; + outerStyleContext = aPresContext->ResolvePseudoStyleContextFor(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 @@ -2610,7 +2605,7 @@ nsCSSFrameConstructor::ConstructTableCaptionFrame(nsIPresShell* aPres nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -2656,7 +2651,7 @@ nsCSSFrameConstructor::ConstructTableRowGroupFrame(nsIPresShell* aPre nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2731,7 +2726,7 @@ nsCSSFrameConstructor::ConstructTableColGroupFrame(nsIPresShell* aPre nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2781,7 +2776,7 @@ nsCSSFrameConstructor::ConstructTableRowFrame(nsIPresShell* aPresShel nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2836,7 +2831,7 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2860,8 +2855,7 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel rv = aTableCreator.CreateTableColFrame(&aNewFrame); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context - nsCOMPtr parentStyleContext; - parentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = parentFrame->GetStyleContext(); if (aIsPseudoParent) { aPresContext->ReParentStyleContext(aNewFrame, parentStyleContext); } @@ -2872,11 +2866,11 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel if (cgContent) { cgContent->GetSpan(&span); nsIFrame* lastCol = aNewFrame; - nsCOMPtr styleContext; + nsStyleContext* styleContext; for (PRInt32 spanX = 1; spanX < span; spanX++) { // The same content node should always resolve to the same style context. if (1 == spanX) - aNewFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aNewFrame->GetStyleContext(); nsIFrame* newCol; rv = aTableCreator.CreateTableColFrame(&newCol); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, @@ -2908,7 +2902,7 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2953,11 +2947,10 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe } // Resolve pseudo style and initialize the body cell frame - nsCOMPtr innerPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::cellContent, - aStyleContext, - getter_AddRefs(innerPseudoStyle)); + nsRefPtr innerPseudoStyle; + innerPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::cellContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aNewCellOuterFrame, innerPseudoStyle, nsnull, aNewCellInnerFrame); @@ -2998,7 +2991,7 @@ nsCSSFrameConstructor::MustGeneratePseudoParent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIAtom* aTag, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { if (!aStyleContext) return PR_FALSE; @@ -3029,7 +3022,7 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsIPresShell* aPres nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -3116,8 +3109,7 @@ nsCSSFrameConstructor::TableProcessChildren(nsIPresShell* aPresShell, nsCOMPtr parentFrameType; aParentFrame->GetFrameType(getter_AddRefs(parentFrameType)); - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); ChildIterator iter, last; for (ChildIterator::Init(aContent, &iter, &last); @@ -3153,7 +3145,7 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresShell* aPresShell, nsIContent* aParentContent, nsIFrame* aParentFrame, nsIAtom* aParentFrameType, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aCaption) @@ -3164,11 +3156,11 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresShell* aPresShell, PRBool isPseudoParent = PR_FALSE; nsIFrame* childFrame = nsnull; - nsCOMPtr childStyleContext; + nsRefPtr childStyleContext; // Resolve the style context and get its display - ResolveStyleContext(aPresContext, aParentFrame, aChildContent, - getter_AddRefs(childStyleContext)); + childStyleContext = ResolveStyleContext(aPresContext, aParentFrame, + aChildContent); const nsStyleDisplay* styleDisplay = (const nsStyleDisplay*) childStyleContext->GetStyleData(eStyleStruct_Display); @@ -3294,8 +3286,7 @@ nsCSSFrameConstructor:: GetDisplay(nsIFrame* aFrame) if (nsnull == aFrame) { return nsnull; } - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); const nsStyleDisplay* display = (const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display); return display; @@ -3334,7 +3325,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aDocElement, nsIFrame* aParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame*& aNewFrame) { // how the root frame hierarchy should look @@ -3405,9 +3396,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } // --------- CREATE AREA OR BOX FRAME ------- - nsCOMPtr styleContext; - aPresContext->ResolveStyleContextFor(aDocElement, aParentStyleContext, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolveStyleContextFor(aDocElement, + aParentStyleContext); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -3432,10 +3423,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } if (resolveStyle) { - rv = ResolveStyleContext(aPresContext, aParentFrame, aDocElement, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) - return rv; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, + aDocElement); } } @@ -3454,19 +3443,18 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, // build a scrollframe if ((!isPaginated || (isPaginated && printPreviewContext)) && isScrollable) { nsIFrame* newScrollFrame = nsnull; - nsCOMPtr newContext; + nsRefPtr newContext; - BeginBuildingScrollFrame( aPresShell, aPresContext, - aState, - aDocElement, - styleContext, - aParentFrame, - nsCSSAnonBoxes::scrolledContent, - mDocument, - PR_FALSE, - scrollFrame, - newContext, - newScrollFrame); + newContext = BeginBuildingScrollFrame( aPresShell, aPresContext, + aState, + aDocElement, + styleContext, + aParentFrame, + nsCSSAnonBoxes::scrolledContent, + mDocument, + PR_FALSE, + scrollFrame, + newScrollFrame); styleContext = newContext; aParentFrame = newScrollFrame; @@ -3484,7 +3472,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, if (NS_FAILED(rv)) { return rv; } - contentFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = contentFrame->GetStyleContext(); } else { // otherwise build a box or a block #if defined(MOZ_SVG) @@ -3663,11 +3651,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // --------- BUILD VIEWPORT ----------- nsIFrame* viewportFrame = nsnull; - nsCOMPtr viewportPseudoStyle; + nsRefPtr viewportPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::viewport, - nsnull, - getter_AddRefs(viewportPseudoStyle)); + viewportPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::viewport, + nsnull); NS_NewViewportFrame(aPresShell, &viewportFrame); @@ -3804,9 +3792,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, NS_ASSERTION(!isXUL, "XUL documents should never be scrollable - see above"); // see if the style is overflow: hidden, first on the document element - nsCOMPtr styleContext; - aPresContext->ResolveStyleContextFor(aDocElement, nsnull, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolveStyleContextFor(aDocElement, nsnull); if (styleContext) { const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -3846,9 +3833,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } } if (bodyElement) { - nsCOMPtr bodyContext; - aPresContext->ResolveStyleContextFor(bodyElement, styleContext, - getter_AddRefs(bodyContext)); + nsRefPtr bodyContext; + bodyContext = aPresContext->ResolveStyleContextFor(bodyElement, + styleContext); if (bodyContext) { const nsStyleDisplay* display = (const nsStyleDisplay*) bodyContext->GetStyleData(eStyleStruct_Display); @@ -3864,7 +3851,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } nsIFrame* newFrame = rootFrame; - nsCOMPtr rootPseudoStyle; + nsRefPtr rootPseudoStyle; // we must create a state because if the scrollbars are GFX it needs the // state to build the scrollbar frames. nsFrameConstructorState state(aPresContext, @@ -3876,9 +3863,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // If paginated, make sure we don't put scrollbars in if (isPaginated && !printPreviewContext) - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - viewportPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + rootPseudo, + viewportPseudoStyle); else if (isScrollable) { // Build the frame. We give it the content we are wrapping which is the document, @@ -3886,27 +3873,25 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // frame and the scrollable view if one was created. // resolve a context for the scrollframe - nsCOMPtr styleContext; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewportScroll, - viewportPseudoStyle, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::viewportScroll, + viewportPseudoStyle); nsIFrame* newScrollableFrame = nsnull; - BeginBuildingScrollFrame( aPresShell, - aPresContext, - state, - aDocElement, - styleContext, - viewportFrame, - rootPseudo, - mDocument, - PR_TRUE, - newFrame, - rootPseudoStyle, - newScrollableFrame); + rootPseudoStyle = BeginBuildingScrollFrame( aPresShell, + aPresContext, + state, + aDocElement, + styleContext, + viewportFrame, + rootPseudo, + mDocument, + PR_TRUE, + newFrame, + newScrollableFrame); // Inform the view manager about the root scrollable view nsIView* view = nsnull; @@ -3928,19 +3913,18 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } else { // If no scrollbars and xul, don't build a scrollframe at all. if (isXUL) { - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - viewportPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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 - nsCOMPtr scrollPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::scrolledContent, - viewportPseudoStyle, - getter_AddRefs(scrollPseudoStyle)); + nsRefPtr scrollPseudoStyle; + scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::scrolledContent, + viewportPseudoStyle); // create scrollframe nsIFrame* scrollFrame = nsnull; @@ -3950,9 +3934,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull); // resolve a new style for the root frame - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - scrollPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + rootPseudo, + scrollPseudoStyle); // Inform the view manager about the root scrollable view nsIView* view = nsnull; @@ -3995,7 +3979,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // Create the first page // Set the initial child lists nsIFrame *pageFrame, *pageContentFrame; - ConstructPageFrame(aPresShell, aPresContext, rootFrame, nsnull, + ConstructPageFrame(aPresShell, aPresContext, rootFrame, nsnull, pageFrame, pageContentFrame); rootFrame->SetInitialChildList(aPresContext, nsnull, pageFrame); @@ -4014,7 +3998,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } NS_IMETHODIMP -nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, +nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame* aPrevPageFrame, @@ -4026,13 +4010,12 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, if (NS_FAILED(rv)) return rv; - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); - nsCOMPtr pagePseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::page, - parentStyleContext, - getter_AddRefs(pagePseudoStyle)); + nsRefPtr pagePseudoStyle; + pagePseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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); @@ -4043,10 +4026,10 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, NS_NewPageContentFrame(aPresShell, &aPageContentFrame); - nsCOMPtr pageContentPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::pageContent, - pagePseudoStyle, - getter_AddRefs(pageContentPseudoStyle)); + nsRefPtr pageContentPseudoStyle; + pageContentPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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); @@ -4098,7 +4081,7 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, nsIFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame** aPlaceholderFrame) { @@ -4107,10 +4090,9 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, if (NS_SUCCEEDED(rv)) { // The placeholder frame gets a pseudo style context - nsCOMPtr placeholderStyle; - nsCOMPtr parentContext = aStyleContext->GetParent(); - aPresContext->ResolveStyleContextForNonElement(parentContext, - getter_AddRefs(placeholderStyle)); + nsRefPtr placeholderStyle; + nsStyleContext* parentContext = aStyleContext->GetParent(); + placeholderStyle = aPresContext->ResolveStyleContextForNonElement(parentContext); placeholderFrame->Init(aPresContext, aContent, aParentFrame, placeholderStyle, nsnull); @@ -4183,7 +4165,7 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { nsresult rv = NS_OK; if (GetFormElementRenderingMode(aPresContext, eWidgetType_Radio) == eWidgetRendering_Gfx) @@ -4196,11 +4178,10 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel return rv; } - nsCOMPtr radioStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::radio, - aStyleContext, - getter_AddRefs(radioStyle)); + nsRefPtr radioStyle; + radioStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::radio, + aStyleContext); nsIRadioControlFrame* radio = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&radio))) { radio->SetRadioButtonFaceStyleContext(radioStyle); @@ -4214,7 +4195,7 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { nsresult rv = NS_OK; if (GetFormElementRenderingMode(aPresContext, eWidgetType_Checkbox) == eWidgetRendering_Gfx) @@ -4227,9 +4208,10 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell aNewFrame = nsnull; } - nsCOMPtr checkboxStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, nsCSSAnonBoxes::check, - aStyleContext, getter_AddRefs(checkboxStyle)); + nsRefPtr checkboxStyle; + checkboxStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::check, + aStyleContext); nsICheckboxControlFrame* checkbox = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsICheckboxControlFrame), (void**)&checkbox))) { @@ -4329,7 +4311,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -4399,11 +4381,10 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, comboBox->SetDropDown(listFrame); // Resolve psuedo element style for the dropdown list - nsCOMPtr listStyle; - rv = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::dropDownList, - aStyleContext, - getter_AddRefs(listStyle)); + nsRefPtr listStyle; + listStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::dropDownList, + aStyleContext); // Initialize the scroll frame positioned. Note that it is NOT // initialized as absolutely positioned. @@ -4511,7 +4492,7 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell, nsIFrame* scrolledFrame, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsAbsolutelyPositioned, PRBool aIsFixedPositioned, PRBool aCreateBlock) @@ -4525,81 +4506,79 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell, geometricParent = aState.mFixedItems.containingBlock; } - nsCOMPtr scrollPseudoStyle; - nsCOMPtr scrolledPseudoStyle; + nsRefPtr scrolledPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - aStyleContext, - getter_AddRefs(scrolledPseudoStyle)); + scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::scrolledContent, + aStyleContext); - InitAndRestoreFrame(aPresContext, aState, aContent, - geometricParent, aStyleContext, nsnull, scrollFrame); + InitAndRestoreFrame(aPresContext, aState, aContent, + geometricParent, aStyleContext, nsnull, scrollFrame); - // Initialize the frame and force it to have a view - // the scrolled frame is anonymous and does not have a content node - InitAndRestoreFrame(aPresContext, aState, aContent, - scrollFrame, scrolledPseudoStyle, nsnull, scrolledFrame); + // Initialize the frame and force it to have a view + // the scrolled frame is anonymous and does not have a content node + InitAndRestoreFrame(aPresContext, aState, aContent, + scrollFrame, scrolledPseudoStyle, nsnull, scrolledFrame); - nsHTMLContainerFrame::CreateViewForFrame(aPresContext, scrolledFrame, + nsHTMLContainerFrame::CreateViewForFrame(aPresContext, scrolledFrame, scrolledPseudoStyle, nsnull, PR_TRUE); - // The area frame is a floater container - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - nsFrameConstructorSaveState floaterSaveState; - aState.PushFloaterContainingBlock(scrolledFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + // The area frame is a floater container + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + nsFrameConstructorSaveState floaterSaveState; + aState.PushFloaterContainingBlock(scrolledFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); - // Process children - nsFrameConstructorSaveState absoluteSaveState; - nsFrameItems childItems; - PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || - aIsFixedPositioned; + // Process children + nsFrameConstructorSaveState absoluteSaveState; + nsFrameItems childItems; + PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || + aIsFixedPositioned; - if (isPositionedContainingBlock) { - // The area frame becomes a container for child frames that are - // absolutely positioned - aState.PushAbsoluteContainingBlock(aPresContext, scrolledFrame, absoluteSaveState); - } - - ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, - childItems, PR_TRUE); + if (isPositionedContainingBlock) { + // The area frame becomes a container for child frames that are + // absolutely positioned + aState.PushAbsoluteContainingBlock(aPresContext, scrolledFrame, absoluteSaveState); + } - // if a select is being created with zero options we need to create - // a special pseudo frame so it can be sized as best it can - nsCOMPtr selectElement; - nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), - (void**)getter_AddRefs(selectElement)); - if (NS_SUCCEEDED(result) && selectElement) { - AddDummyFrameToSelect(aPresContext, aPresShell, aState, - scrollFrame, scrolledFrame, &childItems, - aContent, selectElement); - } - ////////////////////////////////////////////////// - ////////////////////////////////////////////////// - - // Set the scrolled frame's initial child lists - scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); - if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { - scrolledFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } + ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, + childItems, PR_TRUE); - if (aState.mFloatedItems.childList) { - scrolledFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); - } + // if a select is being created with zero options we need to create + // a special pseudo frame so it can be sized as best it can + nsCOMPtr selectElement; + nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), + (void**)getter_AddRefs(selectElement)); + if (NS_SUCCEEDED(result) && selectElement) { + AddDummyFrameToSelect(aPresContext, aPresShell, aState, + scrollFrame, scrolledFrame, &childItems, + aContent, selectElement); + } + ////////////////////////////////////////////////// + ////////////////////////////////////////////////// + + // Set the scrolled frame's initial child lists + scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); + if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { + scrolledFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } + + if (aState.mFloatedItems.childList) { + scrolledFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } // Set the scroll frame's initial child list scrollFrame->SetInitialChildList(aPresContext, nsnull, scrolledFrame); - + return NS_OK; } @@ -4615,7 +4594,7 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -4656,81 +4635,81 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); // Resolve style and initialize the frame - nsIStyleContext* styleContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, nsCSSAnonBoxes::fieldsetContent, - aStyleContext, &styleContext); + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::fieldsetContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, styleContext, nsnull, areaFrame); - NS_RELEASE(styleContext); - // The area frame is a floater container - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - nsFrameConstructorSaveState floaterSaveState; - aState.PushFloaterContainingBlock(areaFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + // The area frame is a floater container + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + nsFrameConstructorSaveState floaterSaveState; + aState.PushFloaterContainingBlock(areaFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); - // Process children - nsFrameConstructorSaveState absoluteSaveState; - nsFrameItems childItems; - PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || - aIsFixedPositioned; + // Process children + nsFrameConstructorSaveState absoluteSaveState; + nsFrameItems childItems; + PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || + aIsFixedPositioned; - if (isPositionedContainingBlock) { - // The area frame becomes a container for child frames that are - // absolutely positioned - aState.PushAbsoluteContainingBlock(aPresContext, areaFrame, absoluteSaveState); - } - - ProcessChildren(aPresShell, aPresContext, aState, aContent, areaFrame, PR_FALSE, - childItems, PR_TRUE); + if (isPositionedContainingBlock) { + // The area frame becomes a container for child frames that are + // absolutely positioned + aState.PushAbsoluteContainingBlock(aPresContext, areaFrame, absoluteSaveState); + } - static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); - nsIFrame * child = childItems.childList; - nsIFrame * previous = nsnull; - nsIFrame* legendFrame = nsnull; - while (nsnull != child) { - nsresult result = child->QueryInterface(kLegendFrameCID, (void**)&legendFrame); - if (NS_SUCCEEDED(result) && legendFrame) { - if (nsnull != previous) { - nsIFrame * nxt; - legendFrame->GetNextSibling(&nxt); - previous->SetNextSibling(nxt); - areaFrame->SetNextSibling(legendFrame); - legendFrame->SetParent(newFrame); - legendFrame->SetNextSibling(nsnull); - break; - } else { - nsIFrame * nxt; - legendFrame->GetNextSibling(&nxt); - childItems.childList = nxt; - areaFrame->SetNextSibling(legendFrame); - legendFrame->SetParent(newFrame); - legendFrame->SetNextSibling(nsnull); - break; - } + ProcessChildren(aPresShell, aPresContext, aState, aContent, areaFrame, PR_FALSE, + childItems, PR_TRUE); + + static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); + nsIFrame * child = childItems.childList; + nsIFrame * previous = nsnull; + nsIFrame* legendFrame = nsnull; + while (nsnull != child) { + nsresult result = child->QueryInterface(kLegendFrameCID, (void**)&legendFrame); + if (NS_SUCCEEDED(result) && legendFrame) { + if (nsnull != previous) { + nsIFrame * nxt; + legendFrame->GetNextSibling(&nxt); + previous->SetNextSibling(nxt); + areaFrame->SetNextSibling(legendFrame); + legendFrame->SetParent(newFrame); + legendFrame->SetNextSibling(nsnull); + break; + } else { + nsIFrame * nxt; + legendFrame->GetNextSibling(&nxt); + childItems.childList = nxt; + areaFrame->SetNextSibling(legendFrame); + legendFrame->SetParent(newFrame); + legendFrame->SetNextSibling(nsnull); + break; } - previous = child; - child->GetNextSibling(&child); } + previous = child; + child->GetNextSibling(&child); + } - // Set the scrolled frame's initial child lists - areaFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); - if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { - areaFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } + // Set the scrolled frame's initial child lists + areaFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); + if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { + areaFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } - if (aState.mFloatedItems.childList) { - areaFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); - } + if (aState.mFloatedItems.childList) { + areaFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } // Set the scroll frame's initial child list newFrame->SetInitialChildList(aPresContext, nsnull, areaFrame); @@ -4750,7 +4729,7 @@ nsCSSFrameConstructor::ConstructTextFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // process pending pseudo frames. whitespace doesn't have an effect. @@ -4793,7 +4772,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // Ignore the tag if it's not HTML content @@ -5404,7 +5383,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag, PRBool& aHaltProcessing) @@ -6041,18 +6020,17 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } #endif -nsresult +already_AddRefed nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aParentFrame, nsIAtom* aScrolledPseudo, nsIDocument* aDocument, PRBool aIsRoot, nsIFrame*& aNewFrame, - nsCOMPtr& aScrolledChildStyle, nsIFrame*& aScrollableFrame, nsIFrame* aScrollPortFrame) { @@ -6078,7 +6056,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsFrameItems anonymousItems; - nsCOMPtr contentStyle = dont_QueryInterface(aContentStyle); + nsRefPtr contentStyle = aContentStyle; PRBool isGfx = HasGfxScrollbars(); @@ -6092,11 +6070,10 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, aNewFrame = gfxScrollFrame; // we used the style that was passed in. So resolve another one. - nsCOMPtr scrollPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - contentStyle, - getter_AddRefs(scrollPseudoStyle)); + nsRefPtr scrollPseudoStyle; + scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::scrolledContent, + contentStyle); contentStyle = scrollPseudoStyle; InitAndRestoreFrame(aPresContext, aState, aContent, @@ -6110,13 +6087,9 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, parentFrame, contentStyle, nsnull, scrollFrame); } - // initialize the scrolled frame - nsCOMPtr scrolledPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - aScrolledPseudo, - contentStyle, - getter_AddRefs(scrolledPseudoStyle)); - + nsStyleContext* aScrolledChildStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + aScrolledPseudo, + contentStyle).get(); aScrollableFrame = scrollFrame; @@ -6127,13 +6100,11 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, } - aScrolledChildStyle = scrolledPseudoStyle; - if (printPreviewContext && noScalingOfTwips) { printPreviewContext->SetScalingOfTwips(PR_TRUE); } - return NS_OK; + return aScrolledChildStyle;; } nsresult @@ -6142,7 +6113,7 @@ nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIPresContext* aPresConte nsIContent* aContent, nsIFrame* aScrollFrame, nsIFrame* aScrolledFrame, - nsIStyleContext* aScrolledContentStyle) + nsStyleContext* aScrolledContentStyle) { // create a view @@ -6213,11 +6184,11 @@ nsCSSFrameConstructor::BuildScrollFrame (nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aScrolledFrame, nsIFrame* aParentFrame, nsIFrame*& aNewFrame, - nsIStyleContext*& aScrolledContentStyle, + nsStyleContext*& aScrolledContentStyle, nsIFrame* aScrollPortFrame) { // Check to see the type of parent frame so we know whether we need to @@ -6238,21 +6209,20 @@ nsCSSFrameConstructor::BuildScrollFrame (nsIPresShell* aPresShell, nsIFrame *scrollFrame; - nsCOMPtr scrolledContentStyle; + nsRefPtr scrolledContentStyle; - BeginBuildingScrollFrame(aPresShell, aPresContext, - aState, - aContent, - aContentStyle, - aParentFrame, - nsCSSAnonBoxes::scrolledContent, - mDocument, - PR_FALSE, - aNewFrame, - scrolledContentStyle, - scrollFrame, - aScrollPortFrame); + scrolledContentStyle = BeginBuildingScrollFrame(aPresShell, aPresContext, + aState, + aContent, + aContentStyle, + aParentFrame, + nsCSSAnonBoxes::scrolledContent, + mDocument, + PR_FALSE, + aNewFrame, + scrollFrame, + aScrollPortFrame); InitAndRestoreFrame(aPresContext, aState, aContent, scrollFrame, scrolledContentStyle, nsnull, aScrolledFrame); @@ -6287,7 +6257,7 @@ nsCSSFrameConstructor::BuildGfxScrollFrame (nsIPresShell* aPresShell, nsIContent* aContent, nsIDocument* aDocument, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsRoot, nsIFrame*& aNewFrame, nsFrameItems& aAnonymousFrames, @@ -6327,7 +6297,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre PRInt32 aNameSpaceID, nsIAtom* aTag, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { PRBool primaryFrameSet = PR_FALSE; @@ -6405,7 +6375,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre NS_BLOCK_SHRINK_WRAP | NS_BLOCK_MARGIN_ROOT); - nsIStyleContext* newStyle = nsnull; + nsStyleContext* newStyle; // Build the scrollframe it BuildScrollFrame(aPresShell, aPresContext, aState, aContent, aStyleContext, scrolledFrame, geometricParent, newFrame, newStyle); @@ -6444,7 +6414,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, childItems); - // Set the scrolled frame's initial child lists + // Set the scrolled frame's initial child lists scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { scrolledFrame->SetInitialChildList(aPresContext, @@ -6847,7 +6817,7 @@ nsCSSFrameConstructor::InitAndRestoreFrame(nsIPresContext* aPresContext nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow, nsIFrame* aNewFrame) { @@ -6870,21 +6840,16 @@ nsCSSFrameConstructor::InitAndRestoreFrame(nsIPresContext* aPresContext return rv; } -nsresult +already_AddRefed nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, nsIFrame* aParentFrame, - nsIContent* aContent, - nsIStyleContext** aStyleContext) + nsIContent* aContent) { - nsresult rv = NS_OK; // Resolve the style context based on the content object and the parent // style context - nsCOMPtr parentStyleContext; - - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); if (aContent->IsContentOfType(nsIContent::eELEMENT)) { - rv = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext, - aStyleContext); + return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext); } else { #ifdef DEBUG { @@ -6895,10 +6860,8 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, "comments and processing instructions"); } #endif - rv = aPresContext->ResolveStyleContextForNonElement(parentStyleContext, - aStyleContext); + return aPresContext->ResolveStyleContextForNonElement(parentStyleContext); } - return rv; } // MathML Mod - RBS @@ -6911,7 +6874,7 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // Make sure that we remain confined in the MathML world @@ -6951,104 +6914,101 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, aTag == nsMathMLAtoms::mn_ || aTag == nsMathMLAtoms::ms_ || aTag == nsMathMLAtoms::mtext_) - rv = NS_NewMathMLTokenFrame(aPresShell, &newFrame); + rv = NS_NewMathMLTokenFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mo_) - rv = NS_NewMathMLmoFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmoFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mfrac_) - rv = NS_NewMathMLmfracFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmfracFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msup_) - rv = NS_NewMathMLmsupFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsupFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msub_) - rv = NS_NewMathMLmsubFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsubFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msubsup_) - rv = NS_NewMathMLmsubsupFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsubsupFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::munder_) - rv = NS_NewMathMLmunderFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmunderFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mover_) - rv = NS_NewMathMLmoverFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmoverFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::munderover_) - rv = NS_NewMathMLmunderoverFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmunderoverFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mphantom_) - rv = NS_NewMathMLmphantomFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmphantomFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mpadded_) - rv = NS_NewMathMLmpaddedFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmpaddedFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mspace_) - rv = NS_NewMathMLmspaceFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmspaceFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mfenced_) - rv = NS_NewMathMLmfencedFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmfencedFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mmultiscripts_) - rv = NS_NewMathMLmmultiscriptsFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmmultiscriptsFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mstyle_) - rv = NS_NewMathMLmstyleFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmstyleFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msqrt_) - rv = NS_NewMathMLmsqrtFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsqrtFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mroot_) - rv = NS_NewMathMLmrootFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmrootFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::maction_) - rv = NS_NewMathMLmactionFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmactionFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mrow_ || aTag == nsMathMLAtoms::merror_ || aTag == nsMathMLAtoms::none_ || aTag == nsMathMLAtoms::mprescripts_ ) - rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); // CONSTRUCTION of MTABLE elements else if (aTag == nsMathMLAtoms::mtable_ && disp->mDisplay == NS_STYLE_DISPLAY_TABLE) { - // is an inline-table -- but this isn't yet supported. - // What we do here is to wrap the table in an anonymous containing - // block so that it can mix better with other surrounding MathML markups + // is an inline-table -- but this isn't yet supported. + // What we do here is to wrap the table in an anonymous containing + // block so that it can mix better with other surrounding MathML markups - nsCOMPtr parentContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentContext)); + nsStyleContext* parentContext = aParentFrame->GetStyleContext(); - // first, create a MathML mrow frame that will wrap the block frame - rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); - if (NS_FAILED(rv)) return rv; - nsCOMPtr mrowContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsMathMLAtoms::mozMathInline, - parentContext, - getter_AddRefs(mrowContext)); - InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, - mrowContext, nsnull, newFrame); + // 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, + nsMathMLAtoms::mozMathInline, + parentContext); + InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, + mrowContext, nsnull, newFrame); - // then, create a block frame that will wrap the table frame - nsIFrame* blockFrame; - rv = NS_NewBlockFrame(aPresShell, &blockFrame); - if (NS_FAILED(rv)) return rv; - nsCOMPtr blockContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mrowContext, - getter_AddRefs(blockContext)); - InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, - blockContext, nsnull, blockFrame); + // then, create a block frame that will wrap the table frame + nsIFrame* blockFrame; + rv = NS_NewBlockFrame(aPresShell, &blockFrame); + if (NS_FAILED(rv)) return rv; + nsRefPtr blockContext; + blockContext = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mrowContext); + InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, + blockContext, nsnull, blockFrame); - // then, create the table frame itself - nsCOMPtr tableContext; - aPresContext->ResolveStyleContextFor(aContent, blockContext, - getter_AddRefs(tableContext)); - nsFrameItems tempItems; - nsIFrame* outerTable; - nsIFrame* innerTable; - PRBool pseudoParent; - nsMathMLmtableCreator mathTableCreator(aPresShell); - rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, - blockFrame, tableContext, mathTableCreator, - PR_FALSE, tempItems, outerTable, innerTable, pseudoParent); - // Note: table construction function takes care of initializing the frame, - // processing children, and setting the initial child list + // then, create the table frame itself + nsRefPtr tableContext; + tableContext = aPresContext->ResolveStyleContextFor(aContent, + blockContext); + nsFrameItems tempItems; + nsIFrame* outerTable; + nsIFrame* innerTable; + PRBool pseudoParent; + nsMathMLmtableCreator mathTableCreator(aPresShell); + rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, + blockFrame, tableContext, mathTableCreator, + PR_FALSE, tempItems, outerTable, innerTable, pseudoParent); + // Note: table construction function takes care of initializing the frame, + // processing children, and setting the initial child list - // set the outerTable as the initial child of the anonymous block - blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable); + // set the outerTable as the initial child of the anonymous block + blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable); - // set the block frame as the initial child of the mrow frame - newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame); + // set the block frame as the initial child of the mrow frame + newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame); - // add the new frame to the flow - aFrameItems.AddChild(newFrame); + // add the new frame to the flow + aFrameItems.AddChild(newFrame); - return rv; + return rv; } // End CONSTRUCTION of MTABLE elements @@ -7060,7 +7020,7 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, rv = NS_NewMathMLmathFrame(aPresShell, &newFrame, isBlock); } else { - return rv; + return rv; } // If we succeeded in creating a frame then initialize it, process its @@ -7137,7 +7097,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { NS_ASSERTION(NS_SUCCEEDED(aContent->GetNameSpaceID(aNameSpaceID)) && @@ -7273,7 +7233,7 @@ nsCSSFrameConstructor::PageBreakBefore(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { const nsStyleDisplay* display = (const nsStyleDisplay*) @@ -7298,14 +7258,13 @@ nsCSSFrameConstructor::ConstructPageBreakFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { - nsCOMPtr pseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageBreak, - aStyleContext, - getter_AddRefs(pseudoStyle)); + nsRefPtr pseudoStyle; + pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::pageBreak, + aStyleContext); nsIFrame* pageBreakFrame; nsresult rv = NS_NewPageBreakFrame(aPresShell, &pageBreakFrame); if (NS_SUCCEEDED(rv)) { @@ -7343,31 +7302,28 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell, tag == nsLayoutAtoms::processingInstructionTagName) return rv; - nsCOMPtr styleContext; - rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aContent); - if (NS_SUCCEEDED(rv)) { - PRInt32 nameSpaceID; - aContent->GetNameSpaceID(nameSpaceID); + PRInt32 nameSpaceID; + aContent->GetNameSpaceID(nameSpaceID); - PRBool pageBreakAfter = PR_FALSE; - PRBool paginated; - aPresContext->IsPaginated(&paginated); + PRBool pageBreakAfter = PR_FALSE; + PRBool paginated; + aPresContext->IsPaginated(&paginated); - if (paginated) { - // See if there is a page break before, if so construct one. Also see if there is one after - pageBreakAfter = PageBreakBefore(aPresShell, aPresContext, aState, aContent, - aParentFrame, styleContext, aFrameItems); - } - // construct the frame - rv = ConstructFrameInternal(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, nameSpaceID, styleContext, aFrameItems, PR_FALSE); - if (NS_SUCCEEDED(rv) && pageBreakAfter) { - // Construct the page break after - ConstructPageBreakFrame(aPresShell, aPresContext, aState, aContent, - aParentFrame, styleContext, aFrameItems); - } + if (paginated) { + // See if there is a page break before, if so construct one. Also see if there is one after + pageBreakAfter = PageBreakBefore(aPresShell, aPresContext, aState, aContent, + aParentFrame, styleContext, aFrameItems); + } + // construct the frame + rv = ConstructFrameInternal(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, nameSpaceID, styleContext, aFrameItems, PR_FALSE); + if (NS_SUCCEEDED(rv) && pageBreakAfter) { + // Construct the page break after + ConstructPageBreakFrame(aPresShell, aPresContext, aState, aContent, + aParentFrame, styleContext, aFrameItems); } return rv; @@ -7382,7 +7338,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag) { @@ -7391,7 +7347,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe // can then be extended arbitrarily. const nsStyleDisplay* display = (const nsStyleDisplay*) aStyleContext->GetStyleData(eStyleStruct_Display); - nsCOMPtr styleContext(aStyleContext); + nsRefPtr styleContext(aStyleContext); nsCOMPtr binding; if (!aXBLBaseTag) { @@ -7409,10 +7365,8 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe return NS_OK; if (resolveStyle) { - rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) - return rv; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, + aContent); } nsCOMPtr baseTag; @@ -7460,7 +7414,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe // do it now, when constructing frames. See bug 115291. { const nsStyleVisibility *vis; - GetStyleData(styleContext.get(), &vis); + GetStyleData(styleContext, &vis); } nsIFrame* lastChild = aFrameItems.lastChild; @@ -7623,9 +7577,8 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte if (NS_SUCCEEDED(rv)) { // Create the new document element hierarchy nsIFrame* newChild; - nsCOMPtr rootPseudoStyle; + nsStyleContext* rootPseudoStyle = docParentFrame->GetStyleContext(); - docParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle)); rv = ConstructDocElementFrame(shell, aPresContext, state, rootContent, docParentFrame, rootPseudoStyle, newChild); @@ -7831,22 +7784,17 @@ IsGeneratedContentFor(nsIContent* aContent, nsIFrame* aFrame, nsIAtom* aPseudoEl // First check the frame state bit aFrame->GetFrameState(&state); if (state & NS_FRAME_GENERATED_CONTENT) { - nsIContent* content; + nsCOMPtr content; // Check that it has the same content pointer - aFrame->GetContent(&content); + aFrame->GetContent(getter_AddRefs(content)); if (content == aContent) { - nsIStyleContext* styleContext; - nsIAtom* pseudoType; + nsStyleContext* styleContext = aFrame->GetStyleContext(); // See if the pseudo element type matches - aFrame->GetStyleContext(&styleContext); - styleContext->GetPseudoType(pseudoType); + nsCOMPtr pseudoType = styleContext->GetPseudoType(); result = (pseudoType == aPseudoElement); - NS_RELEASE(styleContext); - NS_IF_RELEASE(pseudoType); } - NS_IF_RELEASE(content); } return result; @@ -8117,8 +8065,8 @@ nsCSSFrameConstructor::IsValidSibling(nsIPresShell& aPresShell, nsIFrame* parent; aSibling.GetParent(&parent); - nsCOMPtr styleContext; - ResolveStyleContext(context, parent, &aContent, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(context, parent, &aContent); if (!styleContext) return PR_FALSE; const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -8534,8 +8482,8 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, aContainer->ChildAt(aNewIndexInContainer, *getter_AddRefs(child)); PRBool needReframe = !child; if (child && child->IsContentOfType(nsIContent::eELEMENT)) { - nsCOMPtr styleContext; - ResolveStyleContext(aPresContext, parentFrame, child, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, parentFrame, child); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); // XXX since the block child goes in the last inline of the sacred triad, frames would @@ -8573,8 +8521,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, PRBool haveFirstLetterStyle, haveFirstLineStyle; nsIFrame* containingBlock = state.mFloatedItems.containingBlock; nsCOMPtr blockContent; - nsCOMPtr blockSC; - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = containingBlock->GetStyleContext(); containingBlock->GetContent(getter_AddRefs(blockContent)); HaveSpecialBlockStyle(aPresContext, blockContent, blockSC, &haveFirstLetterStyle, @@ -8789,9 +8736,8 @@ nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext, listFrame->GetDummyFrame(&dummyFrame); if (!dummyFrame) { - nsCOMPtr styleContext; + nsStyleContext* styleContext = aParentFrame->GetStyleContext(); nsIFrame* generatedFrame = nsnull; - aParentFrame->GetStyleContext(getter_AddRefs(styleContext)); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aParentFrame, aContainer, styleContext, @@ -8894,8 +8840,8 @@ nsCSSFrameConstructor::NeedSpecialFrameReframe(nsIPresShell* aPresShell, // find out if aChild is a block or inline PRBool childIsBlock = PR_FALSE; if (aChild->IsContentOfType(nsIContent::eELEMENT)) { - nsCOMPtr styleContext; - ResolveStyleContext(aPresContext, aParentFrame, aChild, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aChild); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); childIsBlock = display->IsBlockLevel(); @@ -9060,8 +9006,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // InitialReflow. // Get the style context of the containing block frame - nsCOMPtr containerStyle; - mDocElementContainingBlock->GetStyleContext(getter_AddRefs(containerStyle)); + nsStyleContext* containerStyle = mDocElementContainingBlock->GetStyleContext(); // Create frames for the document element and its child elements nsIFrame* docElementFrame; @@ -9211,7 +9156,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // is not the normal structure and requires custom updating // logic. nsIFrame* containingBlock = state.mFloatedItems.containingBlock; - nsCOMPtr blockSC; + nsStyleContext* blockSC; nsCOMPtr blockContent; PRBool haveFirstLetterStyle = PR_FALSE; PRBool haveFirstLineStyle = PR_FALSE; @@ -9232,7 +9177,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, (NS_STYLE_DISPLAY_INLINE == parentDisplay->mDisplay) || (NS_STYLE_DISPLAY_INLINE_BLOCK == parentDisplay->mDisplay)) { // Recover the special style flags for the containing block - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + blockSC = containingBlock->GetStyleContext(); containingBlock->GetContent(getter_AddRefs(blockContent)); HaveSpecialBlockStyle(aPresContext, blockContent, blockSC, &haveFirstLetterStyle, @@ -9663,15 +9608,14 @@ nsCSSFrameConstructor::RemoveMappingsForFrameSubtree(nsIPresContext* aPresContex static PRBool HasPseudoStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement) { - nsCOMPtr pseudoStyleContext; + nsRefPtr pseudoStyleContext; if (aContent) { - aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext, - getter_AddRefs(pseudoStyleContext)); + pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, + aPseudoElement, + aStyleContext); } return pseudoStyleContext != nsnull; } @@ -9833,8 +9777,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, // :first-letter style applies. nsIFrame* containingBlock = GetFloaterContainingBlock(aPresContext, parentFrame); - nsCOMPtr blockSC; - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = containingBlock->GetStyleContext(); nsCOMPtr blockContent; containingBlock->GetContent(getter_AddRefs(blockContent)); PRBool haveFLS = HaveFirstLetterStyle(aPresContext, blockContent, blockSC); @@ -10322,8 +10265,7 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, // See if the block has first-letter style applied to it. nsCOMPtr blockContent; block->GetContent(getter_AddRefs(blockContent)); - nsCOMPtr blockSC; - block->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = block->GetStyleContext(); PRBool haveFirstLetterStyle = HaveFirstLetterStyle(aPresContext, blockContent, blockSC); if (haveFirstLetterStyle) { @@ -10701,7 +10643,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // check for inline style. we need to clear the data at the style // context's rule node whenever the inline style property changes. - nsCOMPtr styleContext; + nsStyleContext* styleContext; nsCOMPtr rule; PRBool inlineStyle = PR_FALSE; if (aAttribute == nsHTMLAtoms::style) { @@ -10712,13 +10654,14 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // This style rule exists and we need to blow away any computed // data that this rule cached in the rule tree. - if (primaryStyleFrame) - primaryStyleFrame->GetStyleContext(getter_AddRefs(styleContext)); - else { + if (primaryStyleFrame) { + styleContext = primaryStyleFrame->GetStyleContext(); + styleContext->AddRef(); + } else { // We might be in the undisplayed map. Retrieve the style context from there. nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); - frameManager->GetUndisplayedContent(aContent, getter_AddRefs(styleContext)); + styleContext = frameManager->GetUndisplayedContent(aContent); #ifdef DEBUG if (!styleContext) { nsCOMPtr parent; @@ -10733,6 +10676,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, #endif } } + if (styleContext) + styleContext->Release(); } // first see if we need to manage the style system: @@ -10937,7 +10882,7 @@ nsresult nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame*& aFrame) { @@ -10997,15 +10942,13 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, // Create a text frame to display the alt-text. It gets a pseudo-element // style context nsIFrame* textFrame; - nsIStyleContext* textStyleContext; - NS_NewTextFrame(aPresShell, &textFrame); - aPresContext->ResolveStyleContextForNonElement(aStyleContext, - &textStyleContext); + + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(aStyleContext); textFrame->Init(aPresContext, altTextContent, containerFrame, textStyleContext, nsnull); - NS_RELEASE(textStyleContext); containerFrame->SetInitialChildList(aPresContext, nsnull, textFrame); // Return the container frame @@ -11086,9 +11029,8 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, // Get parent frame and style context nsIFrame* parentFrame; - nsCOMPtr styleContext; aFrame->GetParent(&parentFrame); - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); // Get aFrame's content object and the tag name nsCOMPtr content; @@ -11338,7 +11280,7 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame) { nsIFrame* newFrame; @@ -11372,11 +11314,10 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, // the caption (that is what the thead is for). This code is not executed // anyway, because the caption was put in a different child list. nsIContent* caption; - nsIStyleContext* captionStyle; + nsStyleContext* captionStyle = childFrame->GetStyleContext(); const nsStyleDisplay* display; childFrame->GetContent(&caption); - childFrame->GetStyleContext(&captionStyle); display = (const nsStyleDisplay*)captionStyle->GetStyleData(eStyleStruct_Display); NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION == display->mDisplay, "expected caption"); @@ -11402,7 +11343,6 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, } newChildFrames.AddChild(captionFrame); NS_RELEASE(caption); - NS_RELEASE(captionStyle); } NS_IF_RELEASE(tableType); childFrame->GetNextSibling(&childFrame); @@ -11422,7 +11362,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame) { nsIFrame* newFrame; @@ -11441,10 +11381,9 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, aFrame->FirstChild(aPresContext, nsnull, &rowGroupFrame); while (rowGroupFrame) { // See if it's a header/footer - nsIStyleContext* rowGroupStyle; + nsStyleContext* rowGroupStyle = rowGroupFrame->GetStyleContext(); const nsStyleDisplay* display; - rowGroupFrame->GetStyleContext(&rowGroupStyle); display = (const nsStyleDisplay*)rowGroupStyle->GetStyleData(eStyleStruct_Display); if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == display->mDisplay) || @@ -11485,8 +11424,6 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, } } - NS_RELEASE(rowGroupStyle); - // Get the next row group frame rowGroupFrame->GetNextSibling(&rowGroupFrame); } @@ -11508,14 +11445,13 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresShell* aPresShell, { nsCOMPtr frameType; nsCOMPtr content; - nsCOMPtr styleContext; + nsStyleContext* styleContext = aFrame->GetStyleContext(); nsIFrame* newFrame = nsnull; nsresult rv = NS_OK; // Use the frame type to determine what type of frame to create aFrame->GetFrameType(getter_AddRefs(frameType)); aFrame->GetContent(getter_AddRefs(content)); - aFrame->GetStyleContext(getter_AddRefs(styleContext)); if (nsLayoutAtoms::textFrame == frameType) { rv = NS_NewContinuingTextFrame(aPresShell, &newFrame); @@ -11560,7 +11496,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresShell* aPresShell, } else if (nsLayoutAtoms::pageFrame == frameType) { nsIFrame* pageContentFrame; - rv = ConstructPageFrame(aPresShell, aPresContext, aParentFrame, aFrame, + rv = ConstructPageFrame(aPresShell, aPresContext, aParentFrame, aFrame, newFrame, pageContentFrame); } else if (nsLayoutAtoms::tableOuterFrame == frameType) { rv = CreateContinuingOuterTableFrame(aPresShell, aPresContext, aFrame, aParentFrame, @@ -12095,7 +12031,7 @@ nsresult nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, nsIContent* aContent, PRBool aInlineStyle, nsIStyleRule* aInlineStyleRule, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { // Is the frame `special'? If so, we need to reframe the containing // block *here*, rather than trying to remove and re-insert the @@ -12186,32 +12122,30 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, // Block frame construction code -nsIStyleContext* +already_AddRefed nsCSSFrameConstructor::GetFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - nsIStyleContext* fls = nsnull; if (aContent) { - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLetter, - aStyleContext, &fls); + return aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSPseudoElements::firstLetter, + aStyleContext); } - return fls; + return nsnull; } -nsIStyleContext* +already_AddRefed nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - nsIStyleContext* fls = nsnull; if (aContent) { - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLine, - aStyleContext, &fls); + return aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSPseudoElements::firstLine, + aStyleContext); } - return fls; + return nsnull; } // Predicate to see if a given content (block element) has @@ -12219,7 +12153,7 @@ nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, PRBool nsCSSFrameConstructor::HaveFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { return HasPseudoStyle(aPresContext, aContent, aStyleContext, nsCSSPseudoElements::firstLetter); @@ -12228,7 +12162,7 @@ nsCSSFrameConstructor::HaveFirstLetterStyle(nsIPresContext* aPresContext, PRBool nsCSSFrameConstructor::HaveFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { return HasPseudoStyle(aPresContext, aContent, aStyleContext, nsCSSPseudoElements::firstLine); @@ -12237,7 +12171,7 @@ nsCSSFrameConstructor::HaveFirstLineStyle(nsIPresContext* aPresContext, void nsCSSFrameConstructor::HaveSpecialBlockStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool* aHaveFirstLetterStyle, PRBool* aHaveFirstLineStyle) { @@ -12267,8 +12201,7 @@ nsCSSFrameConstructor::ProcessChildren(nsIPresShell* aPresShell, nsTableCreator* aTableCreator) { nsresult rv = NS_OK; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); if (aCanHaveGeneratedContent) { // Probe for generated content before @@ -12342,7 +12275,7 @@ nsCSSFrameConstructor::ProcessChildren(nsIPresShell* aPresShell, static void ReparentFrame(nsIPresContext* aPresContext, nsIFrame* aNewParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame* aFrame) { aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); @@ -12384,9 +12317,8 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame( } // Create line frame - nsCOMPtr parentStyle; - aFrame->GetStyleContext(getter_AddRefs(parentStyle)); - nsCOMPtr firstLineStyle( + nsStyleContext* parentStyle = aFrame->GetStyleContext(); + nsRefPtr firstLineStyle( getter_AddRefs(GetFirstLineStyle(aPresContext, aContent, parentStyle)) ); nsIFrame* lineFrame; @@ -12463,8 +12395,7 @@ nsCSSFrameConstructor::AppendFirstLineFrames( return rv; } nsIFrame* lineFrame = lastBlockKid; - nsCOMPtr firstLineStyle; - lineFrame->GetStyleContext(getter_AddRefs(firstLineStyle)); + nsStyleContext* firstLineStyle = lineFrame->GetStyleContext(); // Find the first and last inline frame in aFrameItems nsIFrame* kid = aFrameItems.childList; @@ -12540,8 +12471,7 @@ nsCSSFrameConstructor::InsertFirstLineFrames( if (frameType.get() == nsLayoutAtoms::lineFrame) { // We already have a first-line frame nsIFrame* lineFrame = firstBlockKid; - nsCOMPtr firstLineStyle; - lineFrame->GetStyleContext(getter_AddRefs(firstLineStyle)); + nsStyleContext* firstLineStyle = lineFrame->GetStyleContext(); if (isInline) { // Easy case: the new inline frame will go into the lineFrame. @@ -12569,9 +12499,8 @@ nsCSSFrameConstructor::InsertFirstLineFrames( rv = NS_NewFirstLineFrame(&lineFrame); if (NS_SUCCEEDED(rv)) { // Lookup first-line style context - nsCOMPtr parentStyle; - aBlockFrame->GetStyleContext(getter_AddRefs(parentStyle)); - nsCOMPtr firstLineStyle( + nsStyleContext* parentStyle = aBlockFrame->GetStyleContext(); + nsRefPtr firstLineStyle( getter_AddRefs(GetFirstLineStyle(aPresContext, aContent, parentStyle)) ); @@ -12758,7 +12687,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( nsIFrame* aTextFrame, nsIContent* aBlockContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aResult) { // Create the first-letter-frame @@ -12772,9 +12701,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // get a proper style context for it (the one passed in is for the // letter frame and will have the float property set on it; the text // frame shouldn't have that set). - nsCOMPtr textSC; - aPresContext->ResolveStyleContextForNonElement(aStyleContext, - getter_AddRefs(textSC)); + nsRefPtr textSC; + textSC = aPresContext->ResolveStyleContextForNonElement(aStyleContext); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, aTextFrame); @@ -12798,12 +12726,10 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( &nextTextFrame); // Repair the continuations style context - nsCOMPtr parentStyleContext; - parentStyleContext = getter_AddRefs(aStyleContext->GetParent()); + nsStyleContext* parentStyleContext = aStyleContext->GetParent(); if (parentStyleContext) { - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentStyleContext, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); if (newSC) { nextTextFrame->SetStyleContext(aPresContext, newSC); } @@ -12836,8 +12762,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex aParentFrame->GetContent(getter_AddRefs(parentContent)); // Get style context for the first-letter-frame - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); if (parentStyleContext) { // Use content from containing block so that we can actually // find a matching style rule. @@ -12846,7 +12771,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex getter_AddRefs(blockContent)); // Create first-letter style rule - nsCOMPtr sc = getter_AddRefs( + nsRefPtr sc = getter_AddRefs( GetFirstLetterStyle(aPresContext, blockContent, parentStyleContext)); if (sc) { // Create a new text frame (the original one will be discarded) @@ -12871,9 +12796,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex // Initialize the first-letter-frame. letterFrame->Init(aPresContext, aTextContent, aParentFrame, sc, nsnull); - nsCOMPtr textSC; - aPresContext->ResolveStyleContextForNonElement(sc, - getter_AddRefs(textSC)); + nsRefPtr textSC; + textSC = aPresContext->ResolveStyleContextForNonElement(sc); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, textFrame); letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame); @@ -13072,8 +12996,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( // Create a new text frame with the right style context that maps // all of the content that was previously part of the letter frame // (and probably continued elsewhere). - nsCOMPtr parentSC; - parentFrame->GetStyleContext(getter_AddRefs(parentSC)); + nsStyleContext* parentSC = parentFrame->GetStyleContext(); if (!parentSC) { return NS_OK; } @@ -13082,9 +13005,8 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( if (!textContent) { return NS_OK; } - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentSC, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); if (!newSC) { return NS_OK; } @@ -13172,8 +13094,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, } // Create a new textframe - nsCOMPtr parentSC; - aFrame->GetStyleContext(getter_AddRefs(parentSC)); + nsStyleContext* parentSC = aFrame->GetStyleContext(); if (!parentSC) { break; } @@ -13182,9 +13103,8 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, if (!textContent) { break; } - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentSC, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); if (!newSC) { break; } @@ -13307,20 +13227,17 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, GetFloaterContainingBlock(aPresContext, aParentFrame), mTempFrameTreeState); - nsCOMPtr styleContext; - rv = ResolveStyleContext(aPresContext, aParentFrame, aChild, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aChild); - if (NS_SUCCEEDED(rv)) { - // Pre-check for display "none" - only if we find that, do we create - // any frame at all - const nsStyleDisplay* display = (const nsStyleDisplay*) - styleContext->GetStyleData(eStyleStruct_Display); + // Pre-check for display "none" - only if we find that, do we create + // any frame at all + const nsStyleDisplay* display = (const nsStyleDisplay*) + styleContext->GetStyleData(eStyleStruct_Display); - if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { - *aNewFrame = nsnull; - return NS_OK; - } + if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { + *aNewFrame = nsnull; + return NS_OK; } nsCOMPtr tag; @@ -13392,7 +13309,7 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aNewFrame, PRBool aRelPos) { @@ -13468,12 +13385,12 @@ nsCSSFrameConstructor::ProcessBlockChildren(nsIPresShell* aPresShell, PRBool aParentIsBlock) { nsresult rv = NS_OK; - nsCOMPtr styleContext; + nsStyleContext* styleContext; if (aCanHaveGeneratedContent) { // Probe for generated content before nsIFrame* generatedFrame; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aFrame->GetStyleContext(); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aFrame, aContent, styleContext, nsCSSPseudoElements::before, nsnull, &generatedFrame)) { @@ -13544,7 +13461,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsPositioned, nsIFrame* aNewFrame, nsIFrame** aNewBlockFrame, @@ -13662,10 +13579,9 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, blockStyle = nsCSSAnonBoxes::mozAnonymousBlock; } - nsCOMPtr blockSC; - aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, - aStyleContext, - getter_AddRefs(blockSC)); + nsRefPtr blockSC; + blockSC = aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, blockSC, nsnull, blockFrame); @@ -13768,7 +13684,7 @@ nsCSSFrameConstructor::ProcessInlineChildren(nsIPresShell* aPresShell, PRBool* aKidsAllInline) { nsresult rv = NS_OK; - nsCOMPtr styleContext; + nsStyleContext* styleContext; // save the pseudo frame state nsPseudoFrames prevPseudoFrames; @@ -13777,7 +13693,7 @@ nsCSSFrameConstructor::ProcessInlineChildren(nsIPresShell* aPresShell, if (aCanHaveGeneratedContent) { // Probe for generated content before nsIFrame* generatedFrame; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aFrame->GetStyleContext(); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aFrame, aContent, styleContext, nsCSSPseudoElements::before, nsnull, &generatedFrame)) { @@ -14107,8 +14023,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (state & NS_FRAME_HAS_VIEW) { // ...create a new view for the block child, and reparent views - nsCOMPtr sc; - aLeftInlineChildFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aLeftInlineChildFrame->GetStyleContext(); nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aBlockChildFrame, sc, nsnull, PR_FALSE); @@ -14144,14 +14059,12 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (! blockFrame) return NS_ERROR_OUT_OF_MEMORY; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); - nsCOMPtr blockSC; - aPresContext->ResolvePseudoStyleContextFor(content, - nsCSSAnonBoxes::mozAnonymousBlock, - styleContext, - getter_AddRefs(blockSC)); + nsRefPtr blockSC; + blockSC = aPresContext->ResolvePseudoStyleContextFor(content, + nsCSSAnonBoxes::mozAnonymousBlock, + styleContext); InitAndRestoreFrame(aPresContext, aState, content, nsnull, blockSC, nsnull, blockFrame); diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index a62d6aa2376..2a4642a5ffb 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -50,7 +50,7 @@ class nsIDocument; struct nsFrameItems; struct nsAbsoluteItems; struct nsTableCreator; -class nsIStyleContext; +class nsStyleContext; struct nsTableList; struct nsStyleContent; struct nsStyleDisplay; @@ -204,14 +204,14 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow, nsIFrame* aNewFrame); - nsresult ResolveStyleContext(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIContent* aContent, - nsIStyleContext** aStyleContext); + already_AddRefed + ResolveStyleContext(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIContent* aContent); nsresult ConstructFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, @@ -225,7 +225,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aDocElement, nsIFrame* aParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame*& aNewFrame); nsresult ConstructDocElementTableFrame(nsIPresShell* aPresShell, @@ -239,7 +239,7 @@ protected: nsIDocument* aDocument, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsStyleContent* aStyleContent, PRUint32 aContentIndex, nsIFrame** aFrame); @@ -249,7 +249,7 @@ protected: nsFrameConstructorState& aState, nsIFrame* aFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement, nsIFrame** aWrapperFrame, nsIFrame** aResult); @@ -267,7 +267,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -280,7 +280,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -291,7 +291,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -303,7 +303,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -315,7 +315,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -327,7 +327,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -339,7 +339,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -351,14 +351,14 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, nsIContent* aContent, - nsIStyleContext* aContext); + nsStyleContext* aContext); nsresult ConstructTableForeignFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -449,7 +449,7 @@ protected: nsIContent* aParentContent, nsIFrame* aParentFrame, nsIAtom* aParentFrameType, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aCaption); @@ -463,14 +463,14 @@ protected: nsIFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame** aPlaceholderFrame); nsresult ConstructAlternateFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame*& aFrame); @@ -481,13 +481,13 @@ protected: nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult ConstructCheckboxControlFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult ConstructButtonControlFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, @@ -505,7 +505,7 @@ protected: nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -519,7 +519,7 @@ protected: nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -531,7 +531,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructPageBreakFrame(nsIPresShell* aPresShell, @@ -539,7 +539,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); // Construct a page break frame if page-break-before:always is set in aStyleContext @@ -550,7 +550,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructHTMLFrame(nsIPresShell* aPresShell, @@ -560,7 +560,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructFrameInternal( nsIPresShell* aPresShell, @@ -570,7 +570,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag); @@ -600,7 +600,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); #endif @@ -612,7 +612,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag, PRBool& aHaltProcessing); @@ -628,7 +628,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); #endif @@ -640,7 +640,7 @@ protected: PRInt32 aNameSpaceID, nsIAtom* aTag, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ProcessChildren(nsIPresShell* aPresShell, @@ -657,7 +657,7 @@ protected: nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame*& aFrame, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult AddDummyFrameToSelect(nsIPresContext* aPresContext, nsIPresShell* aPresShell, @@ -697,28 +697,27 @@ protected: nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aScrolledFrame, nsIFrame* aParentFrame, nsIFrame*& aNewFrame, - nsIStyleContext*& aScrolledChildStyle, + nsStyleContext*& aScrolledChildStyle, nsIFrame* aScrollPort = nsnull); // Builds the initial ScrollFrame: // if Gfx scrollbasrs in ares, it creates a GfxScrollFrame, otherwise it creates a ScrollFrame // - nsresult + already_AddRefed BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aParentFrame, nsIAtom* aScrolledPseudo, nsIDocument* aDocument, PRBool aIsRoot, nsIFrame*& aNewFrame, - nsCOMPtr& aScrolledChildStyle, nsIFrame*& aScrollableFrame, nsIFrame* aScrollPort = nsnull); @@ -731,7 +730,7 @@ protected: nsIContent* aContent, nsIFrame* aScrollFrame, nsIFrame* aScrolledFrame, - nsIStyleContext* scrolledPseudoStyle); + nsStyleContext* scrolledPseudoStyle); // Creates a new GfxScrollFrame, Initializes it, and creates a scroll port for it // @@ -742,7 +741,7 @@ protected: nsIContent* aContent, nsIDocument* aDocument, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsRoot, nsIFrame*& aNewFrame, nsFrameItems& aAnonymousFrames, @@ -757,7 +756,7 @@ protected: nsIFrame* scrolledFrame, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsAbsolutelyPositioned, PRBool aIsFixedPositioned, PRBool aCreateBlock); @@ -771,7 +770,7 @@ protected: nsIContent* aContent, PRBool aInlineStyle = PR_FALSE, nsIStyleRule* aRule = nsnull, - nsIStyleContext* aContext = nsnull); + nsStyleContext* aContext = nsnull); nsresult RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, nsIContent* aContent, @@ -782,7 +781,7 @@ protected: nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame); nsresult CreateContinuingTableFrame(nsIPresShell* aPresShell, @@ -790,32 +789,34 @@ protected: nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame); //---------------------------------------- // Methods support creating block frames and their children - static nsIStyleContext* GetFirstLetterStyle(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aStyleContext); + static already_AddRefed + GetFirstLetterStyle(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aStyleContext); - static nsIStyleContext* GetFirstLineStyle(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aStyleContext); + static already_AddRefed + GetFirstLineStyle(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aStyleContext); static PRBool HaveFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); static PRBool HaveFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); static void HaveSpecialBlockStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool* aHaveFirstLetterStyle, PRBool* aHaveFirstLineStyle); @@ -829,7 +830,7 @@ protected: const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aNewFrame, PRBool aRelPos); @@ -848,7 +849,7 @@ protected: const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsPositioned, nsIFrame* aNewFrame, nsIFrame** aNewBlockFrame, @@ -925,7 +926,7 @@ protected: nsIFrame* aTextFrame, nsIContent* aBlockContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aResult); nsresult CreateLetterFrame(nsIPresShell* aPresShell, diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 60d446d824e..cfb8d8bc5fd 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -43,7 +43,7 @@ #include "nsRect.h" #include "nsIViewManager.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIScrollableView.h" #include "nsLayoutAtoms.h" #include "nsIDrawingSurface.h" @@ -1562,8 +1562,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, // use this guy's color nsIFrame *pFrame = nsnull; if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) && pFrame) { - nsIStyleContext *pContext = nsnull; - pFrame->GetStyleContext(&pContext); + nsStyleContext *pContext = pFrame->GetStyleContext(); if (pContext) { const nsStyleBackground* color = (const nsStyleBackground*)pContext->GetStyleData(eStyleStruct_Background); NS_ASSERTION(color,"ColorStyleData should not be null"); @@ -1572,7 +1571,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, // set the reslt to TRUE to indicate we mapped the color result = PR_TRUE; } - NS_RELEASE(pContext); }// if context }// if frame }// if tag == html or body @@ -1672,7 +1670,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext, const nsRect& aDirtyRect, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap, nscoord aHardBorderSize, @@ -2070,7 +2068,7 @@ void nsCSSRendering::PaintOutline(nsIPresContext* aPresContext, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, const nsStyleOutline& aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap) { @@ -2233,7 +2231,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext* aPresContext, const nsRect& aDirtyRect, const nsRect& aBorderArea, nsBorderEdges * aBorderEdges, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap) { @@ -2527,11 +2525,11 @@ GetRootScrollableFrame(nsIPresContext* aPresContext, nsIFrame* aRootFrame) } const nsStyleBackground* -nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext, +nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext, PRBool aStartAtParent /*= PR_FALSE*/) { const nsStyleBackground* result = nsnull; - nsCOMPtr context; + nsStyleContext* context; if (aStartAtParent) { context = aContext->GetParent(); } else { @@ -2543,7 +2541,7 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext, // Have to .get() because some compilers won't match the template // otherwise (they don't look for implicit type conversions while doing // template matching?). - ::GetStyleData(context.get(), &result); + ::GetStyleData(context, &result); if (0 == (result->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) break; @@ -2609,7 +2607,7 @@ FindCanvasBackground(nsIPresContext* aPresContext, // for printing and print preview.. this should be a pageContentFrame nsCOMPtr frameType; - nsCOMPtr parentContext; + nsStyleContext* parentContext; firstChild->GetFrameType(getter_AddRefs(frameType)); if ( (frameType == nsLayoutAtoms::pageContentFrame) ){ @@ -2617,11 +2615,11 @@ FindCanvasBackground(nsIPresContext* aPresContext, // pageContentframe does not have content while(firstChild){ for (nsIFrame* kidFrame = firstChild; nsnull != kidFrame; ) { - kidFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = kidFrame->GetStyleContext(); // Need to .get() because some compilers will not do the // implicit .get() to match the template. // See also rev 3.188 of this file. - ::GetStyleData(parentContext.get(), &result); + ::GetStyleData(parentContext, &result); if (!result->IsTransparent()) { GetStyleData(kidFrame, aBackground); return PR_TRUE; @@ -3504,7 +3502,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, const nsRect& aBorderArea, const nsStyleBorder* aBorderStyle, const nsStyleOutline* aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, PRInt16 aBorderRadius[4], nsRect* aGap, @@ -3643,7 +3641,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, */ void nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext, - const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext, + const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext, PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel, PRBool aIsOutline) { diff --git a/mozilla/layout/base/nsCSSRendering.h b/mozilla/layout/base/nsCSSRendering.h index a12f889f35e..ce3e138e10c 100644 --- a/mozilla/layout/base/nsCSSRendering.h +++ b/mozilla/layout/base/nsCSSRendering.h @@ -39,7 +39,7 @@ #include "nsIRenderingContext.h" struct nsPoint; -class nsIStyleContext; +class nsStyleContext; class nsIPresContext; class nsCSSRendering { @@ -58,7 +58,7 @@ public: const nsRect& aDirtyRect, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0, nscoord aHardBorderSize = 0, @@ -79,7 +79,7 @@ public: const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, const nsStyleOutline& aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0); @@ -100,7 +100,7 @@ public: const nsRect& aDirtyRect, const nsRect& aBorderArea, nsBorderEdges * aBorderEdges, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0); @@ -123,7 +123,7 @@ public: * you want. */ static const nsStyleBackground* - FindNonTransparentBackground(nsIStyleContext* aContext, + FindNonTransparentBackground(nsStyleContext* aContext, PRBool aStartAtParent = PR_FALSE); /** @@ -232,13 +232,13 @@ protected: const nsRect& aBorderArea, const nsStyleBorder* aBorderStyle, const nsStyleOutline* aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, PRInt16 aBorderRadius[4],nsRect* aGap = 0, PRBool aIsOutline=PR_FALSE); static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext, - const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext, + const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext, PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel, PRBool aIsOutline=PR_FALSE); diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 7975898b4f6..10a01caf312 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -34,7 +34,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIStyleSet.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleChangeList.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" @@ -77,6 +77,7 @@ #include "nsDummyLayoutRequest.h" #include "nsLayoutErrors.h" #include "nsLayoutUtils.h" +#include "nsAutoPtr.h" #ifdef DEBUG //#define NOISY_DEBUG @@ -199,7 +200,7 @@ MOZ_DECL_CTOR_COUNTER(UndisplayedNode) class UndisplayedNode { public: - UndisplayedNode(nsIContent* aContent, nsIStyleContext* aStyle) + UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle) : mContent(aContent), mStyle(aStyle), mNext(nsnull) @@ -214,7 +215,7 @@ public: } nsCOMPtr mContent; - nsCOMPtr mStyle; + nsRefPtr mStyle; UndisplayedNode* mNext; }; @@ -225,7 +226,7 @@ public: UndisplayedNode* GetFirstNode(nsIContent* aParentContent); - nsresult AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, nsIStyleContext* aStyle); + nsresult AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, nsStyleContext* aStyle); nsresult RemoveNodeFor(nsIContent* aParentContent, UndisplayedNode* aNode); nsresult RemoveNodesFor(nsIContent* aParentContent); @@ -300,8 +301,8 @@ public: NS_IMETHOD ClearPlaceholderFrameMap(); // Undisplayed content functions - NS_IMETHOD GetUndisplayedContent(nsIContent* aContent, nsIStyleContext** aStyleContext); - NS_IMETHOD SetUndisplayedContent(nsIContent* aContent, nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetUndisplayedContent(nsIContent* aContent); + virtual void SetUndisplayedContent(nsIContent* aContent, nsStyleContext* aStyleContext); NS_IMETHOD ClearUndisplayedContentIn(nsIContent* aContent, nsIContent* aParentContent); NS_IMETHOD ClearAllUndisplayedContentIn(nsIContent* aParentContent); NS_IMETHOD ClearUndisplayedContentMap(); @@ -337,7 +338,7 @@ public: NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aNewParentContext); + nsStyleContext* aNewParentContext); NS_IMETHOD ComputeStyleChangeFor(nsIPresContext* aPresContext, nsIFrame* aFrame, PRInt32 aAttrNameSpaceID, @@ -834,36 +835,32 @@ FrameManager::ClearPlaceholderFrameMap() //---------------------------------------------------------------------- -NS_IMETHODIMP -FrameManager::GetUndisplayedContent(nsIContent* aContent, nsIStyleContext** aResult) +nsStyleContext* +FrameManager::GetUndisplayedContent(nsIContent* aContent) { - NS_ENSURE_ARG_POINTER(aContent); - *aResult = nsnull; // initialize out param - - if (!mUndisplayedMap) - return NS_OK; + if (!aContent || !mUndisplayedMap) + return nsnull; nsCOMPtr parent; aContent->GetParent(*getter_AddRefs(parent)); if (!parent) - return NS_OK; + return nsnull; for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent); node; node = node->mNext) { - if (node->mContent == aContent) { - *aResult = node->mStyle; - NS_ADDREF(*aResult); - return NS_OK; - } + if (node->mContent == aContent) + return node->mStyle; } - return NS_OK; + + return nsnull; } -NS_IMETHODIMP +void FrameManager::SetUndisplayedContent(nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); + if (!mPresShell) + return; #ifdef DEBUG_UNDISPLAYED_MAP static int i = 0; @@ -874,17 +871,14 @@ FrameManager::SetUndisplayedContent(nsIContent* aContent, mUndisplayedMap = new UndisplayedMap; } if (mUndisplayedMap) { - nsresult result = NS_OK; nsIContent* parent = nsnull; aContent->GetParent(parent); NS_ASSERTION(parent, "undisplayed content must have a parent"); if (parent) { - result = mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); + mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); NS_RELEASE(parent); } - return result; } - return NS_ERROR_OUT_OF_MEMORY; } NS_IMETHODIMP @@ -908,8 +902,7 @@ FrameManager::ClearUndisplayedContentIn(nsIContent* aContent, nsIContent* aParen #endif #ifdef DEBUG // make sure that there are no more entries for the same content - nsIStyleContext *context = nsnull; - GetUndisplayedContent(aContent, &context); + nsStyleContext *context = GetUndisplayedContent(aContent); NS_ASSERTION(context == nsnull, "Found more undisplayed content data after removal"); #endif return rv; @@ -1306,7 +1299,7 @@ FrameManager::CantRenderReplacedElement(nsIPresContext* aPresContext, #ifdef NS_DEBUG static void -DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) +DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) { if (aFrame) { fputs("frame: ", stdout); @@ -1322,14 +1315,12 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) if (aContext) { fprintf(stdout, " style: %p ", NS_STATIC_CAST(void*, aContext)); - nsIAtom* pseudoTag; - aContext->GetPseudoType(pseudoTag); + nsCOMPtr pseudoTag = aContext->GetPseudoType(); if (pseudoTag) { nsAutoString buffer; pseudoTag->ToString(buffer); fputs(NS_LossyConvertUCS2toASCII(buffer).get(), stdout); fputs(" ", stdout); - NS_RELEASE(pseudoTag); } /* XXXdwh fix debugging here. Need to add a List method to nsRuleNode @@ -1356,11 +1347,11 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) } static void -VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2) +VerifySameTree(nsStyleContext* aContext1, nsStyleContext* aContext2) { - nsCOMPtr top1 = aContext1; - nsCOMPtr top2 = aContext2; - nsCOMPtr parent; + nsStyleContext* top1 = aContext1; + nsStyleContext* top2 = aContext2; + nsStyleContext* parent; for (;;) { parent = top1->GetParent(); if (!parent) @@ -1379,14 +1370,11 @@ VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2) static void VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aContext, nsIStyleContext* aParentContext) + nsStyleContext* aContext, nsStyleContext* aParentContext) { // get the contexts not provided if (!aContext) { - aFrame->GetStyleContext(&aContext); - } else { - // addref here so we can release at end - NS_ADDREF(aContext); + aContext = aFrame->GetStyleContext(); } if (!aParentContext) { @@ -1400,15 +1388,12 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, aFrame->GetParentStyleContextFrame(aPresContext, &providerFrame, &providerIsChild); if (providerFrame) - providerFrame->GetStyleContext(&aParentContext); + aParentContext = providerFrame->GetStyleContext(); // aParentContext could still be null - } else { - // addref the parent context so we can release it at end - NS_ADDREF(aParentContext); } NS_ASSERTION(aContext, "Failure to get required contexts"); - nsCOMPtr actualParentContext = aContext->GetParent(); + nsStyleContext* actualParentContext = aContext->GetParent(); if (aParentContext) { if (aParentContext != actualParentContext) { @@ -1434,17 +1419,12 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, fputs("Should be null\n\n", stdout); } } - - NS_IF_RELEASE(aParentContext); - NS_IF_RELEASE(aContext); } static void -VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIStyleContext* aParentContext) +VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsStyleContext* aParentContext) { - nsIStyleContext* context; - aFrame->GetStyleContext(&context); - + nsStyleContext* context = aFrame->GetStyleContext(); VerifyContextParent(aPresContext, aFrame, context, nsnull); PRInt32 listIndex = 0; @@ -1488,18 +1468,15 @@ VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIStyleContext* // do additional contexts PRInt32 contextIndex = -1; - while (1 == 1) { - nsIStyleContext* extraContext = nsnull; - aFrame->GetAdditionalStyleContext(++contextIndex, &extraContext); + while (1) { + nsStyleContext* extraContext = aFrame->GetAdditionalStyleContext(++contextIndex); if (extraContext) { VerifyContextParent(aPresContext, aFrame, extraContext, context); - NS_RELEASE(extraContext); } else { break; } } - NS_RELEASE(context); } NS_IMETHODIMP @@ -1507,9 +1484,8 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram { NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); if (aFrame) { - nsCOMPtr context; - aFrame->GetStyleContext(getter_AddRefs(context)); - nsCOMPtr parentContext = context->GetParent(); + nsStyleContext* context = aFrame->GetStyleContext(); + nsStyleContext* parentContext = context->GetParent(); VerifyStyleTree(aPresContext, aFrame, parentContext); } return NS_OK; @@ -1520,7 +1496,7 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram NS_IMETHODIMP FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) + nsStyleContext* aNewParentContext) { NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); nsresult result = NS_ERROR_NULL_POINTER; @@ -1529,15 +1505,13 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, DebugVerifyStyleTree(aPresContext, aFrame); #endif - nsIStyleContext* oldContext = nsnull; - aFrame->GetStyleContext(&oldContext); - + nsStyleContext* oldContext = aFrame->GetStyleContext(); if (oldContext) { - nsIStyleContext* newContext = nsnull; - result = mStyleSet->ReParentStyleContext(aPresContext, - oldContext, aNewParentContext, - &newContext); - if (NS_SUCCEEDED(result) && newContext) { + nsRefPtr newContext; + result = NS_OK; + newContext = mStyleSet->ReParentStyleContext(aPresContext, oldContext, + aNewParentContext); + if (newContext) { if (newContext != oldContext) { PRInt32 listIndex = 0; nsIAtom* childList = nsnull; @@ -1561,10 +1535,8 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, result = ReParentStyleContext(aPresContext, outOfFlowFrame, newContext); // reparent placeholder's context under out of flow frame - nsIStyleContext* outOfFlowContext; - outOfFlowFrame->GetStyleContext(&outOfFlowContext); + nsStyleContext* outOfFlowContext = outOfFlowFrame->GetStyleContext(); ReParentStyleContext(aPresContext, child, outOfFlowContext); - NS_RELEASE(outOfFlowContext); } else { // regular frame result = ReParentStyleContext(aPresContext, child, newContext); @@ -1583,20 +1555,15 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, // do additional contexts PRInt32 contextIndex = -1; - while (1 == 1) { - nsIStyleContext* oldExtraContext = nsnull; - result = aFrame->GetAdditionalStyleContext(++contextIndex, &oldExtraContext); - if (NS_SUCCEEDED(result)) { - if (oldExtraContext) { - nsIStyleContext* newExtraContext = nsnull; - result = mStyleSet->ReParentStyleContext(aPresContext, - oldExtraContext, newContext, - &newExtraContext); - if (NS_SUCCEEDED(result) && newExtraContext) { - aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); - NS_RELEASE(newExtraContext); - } - NS_RELEASE(oldExtraContext); + while (1) { + nsStyleContext* oldExtraContext = aFrame->GetAdditionalStyleContext(++contextIndex); + if (oldExtraContext) { + nsRefPtr newExtraContext; + newExtraContext = mStyleSet->ReParentStyleContext(aPresContext, + oldExtraContext, + newContext); + if (newExtraContext) { + aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); } } else { @@ -1608,16 +1575,14 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, VerifyStyleTree(aPresContext, aFrame, aNewParentContext); #endif } - NS_RELEASE(newContext); } - NS_RELEASE(oldContext); } } return result; } static PRBool -HasAttributeContent(nsIStyleContext* aStyleContext, +HasAttributeContent(nsStyleContext* aStyleContext, PRInt32 aNameSpaceID, nsIAtom* aAttribute) { @@ -1659,12 +1624,12 @@ HasAttributeContent(nsIStyleContext* aStyleContext, } static nsChangeHint -CaptureChange(nsIStyleContext* aOldContext, nsIStyleContext* aNewContext, +CaptureChange(nsStyleContext* aOldContext, nsStyleContext* aNewContext, nsIFrame* aFrame, nsIContent* aContent, nsStyleChangeList& aChangeList, nsChangeHint aMinChange) { nsChangeHint ourChange = NS_STYLE_HINT_NONE; - aOldContext->CalcStyleDifference(aNewContext, ourChange); + ourChange = aOldContext->CalcStyleDifference(aNewContext); if (NS_UpdateHint(aMinChange, ourChange)) { aChangeList.AppendChange(aFrame, aContent, ourChange); } @@ -1685,11 +1650,16 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // duplication. (Or should we just let |GetContext| handle that?) // Getting the hint would be nice too, but that's harder. - nsIStyleContext* oldContext = nsnull; - nsresult result = aFrame->GetStyleContext(&oldContext); - if (NS_SUCCEEDED(result) && oldContext) { - nsIAtom* pseudoTag = nsnull; - oldContext->GetPseudoType(pseudoTag); + // XXXbryner we may be able to avoid some of the refcounting goop here. + // We do need a reference to oldContext for the lifetime of this function, and it's possible + // that the frame has the last reference to it, so AddRef it here. + + nsStyleContext* oldContext = aFrame->GetStyleContext(); + nsresult result = NS_OK; + + if (oldContext) { + oldContext->AddRef(); + nsCOMPtr pseudoTag = oldContext->GetPseudoType(); nsIContent* localContent = nsnull; nsIContent* content = nsnull; result = aFrame->GetContent(&localContent); @@ -1707,7 +1677,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } } - nsCOMPtr parentContext; + nsStyleContext* parentContext; nsIFrame* resolvedChild = nsnull; // Get the frame providing the parent style context. If it is a // child, then resolve the provider first. @@ -1717,7 +1687,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, &providerFrame, &providerIsChild); if (!providerIsChild) { if (providerFrame) - providerFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = providerFrame->GetStyleContext(); + else + parentContext = nsnull; } else { // resolve the provider here (before aFrame below) @@ -1726,19 +1698,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aMinChange, aResultChange); // The provider's new context becomes the parent context of // aFrame's context. - providerFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = providerFrame->GetStyleContext(); // Set |resolvedChild| so we don't bother resolving the // provider again. resolvedChild = providerFrame; } // do primary context - nsIStyleContext* newContext = nsnull; + nsStyleContext* newContext = nsnull; if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - aPresContext->ResolveStyleContextForNonElement(parentContext, - &newContext); + newContext = aPresContext->ResolveStyleContextForNonElement(parentContext).get(); } else if (pseudoTag) { nsIContent* pseudoContent = @@ -1746,9 +1717,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after) { // XXX what other pseudos do we need to treat like this? - aPresContext->ProbePseudoStyleContextFor(pseudoContent, pseudoTag, - parentContext, - &newContext); + newContext = aPresContext->ProbePseudoStyleContextFor(pseudoContent, + pseudoTag, + parentContext).get(); if (!newContext) { // This pseudo should no longer exist; gotta reframe NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1756,20 +1727,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsChangeHint_ReconstructFrame); // We're reframing anyway; just keep the same context newContext = oldContext; - NS_ADDREF(newContext); + newContext->AddRef(); } } else { - aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, - parentContext, - &newContext); + newContext = aPresContext->ResolvePseudoStyleContextFor(pseudoContent, + pseudoTag, + parentContext).get(); } - NS_RELEASE(pseudoTag); } else { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - aPresContext->ResolveStyleContextFor(content, parentContext, - &newContext); + newContext = aPresContext->ResolveStyleContextFor(content, parentContext).get(); } NS_ASSERTION(newContext, "failed to get new style context"); if (newContext) { @@ -1783,9 +1752,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // we can use FindChildWithRules to keep a lot of the old // style contexts around. However, we need to start from the // same root. - NS_RELEASE(newContext); + newContext->Release(); newContext = oldContext; - NS_ADDREF(newContext); + newContext->AddRef(); } } @@ -1816,7 +1785,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); } } - NS_RELEASE(oldContext); + oldContext->Release(); } else { NS_ERROR("resolve style context failed"); @@ -1827,40 +1796,37 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // do additional contexts PRInt32 contextIndex = -1; while (1 == 1) { - nsIStyleContext* oldExtraContext = nsnull; - result = aFrame->GetAdditionalStyleContext(++contextIndex, &oldExtraContext); - if (NS_SUCCEEDED(result)) { - if (oldExtraContext) { - nsIStyleContext* newExtraContext = nsnull; - oldExtraContext->GetPseudoType(pseudoTag); - NS_ASSERTION(pseudoTag && - pseudoTag != nsCSSAnonBoxes::mozNonElement, - "extra style context is not pseudo element"); - result = aPresContext->ResolvePseudoStyleContextFor(content, pseudoTag, newContext, - &newExtraContext); - NS_RELEASE(pseudoTag); - if (NS_SUCCEEDED(result) && newExtraContext) { - if (oldExtraContext != newExtraContext) { - aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, - content, aChangeList, aMinChange); - if (!(aMinChange & (nsChangeHint_ReconstructFrame | nsChangeHint_ReconstructDoc))) { - aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); - } + nsStyleContext* oldExtraContext = nsnull; + oldExtraContext = aFrame->GetAdditionalStyleContext(++contextIndex); + if (oldExtraContext) { + nsStyleContext* newExtraContext = nsnull; + pseudoTag = oldExtraContext->GetPseudoType(); + NS_ASSERTION(pseudoTag && + pseudoTag != nsCSSAnonBoxes::mozNonElement, + "extra style context is not pseudo element"); + newExtraContext = aPresContext->ResolvePseudoStyleContextFor(content, + pseudoTag, + newContext).get(); + if (newExtraContext) { + if (oldExtraContext != newExtraContext) { + aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, + content, aChangeList, aMinChange); + if (!(aMinChange & (nsChangeHint_ReconstructFrame | nsChangeHint_ReconstructDoc))) { + aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); } - else { -#if 0 - // XXXldb |oldContext| is null by this point, so this will - // never do anything. - if (pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement && - aAttribute && (aMinChange < NS_STYLE_HINT_REFLOW) && - HasAttributeContent(oldContext, aAttrNameSpaceID, aAttribute)) { - aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); - } -#endif - } - NS_RELEASE(newExtraContext); } - NS_RELEASE(oldExtraContext); + else { +#if 0 + // XXXldb |oldContext| is null by this point, so this will + // never do anything. + if (pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement && + aAttribute && (aMinChange < NS_STYLE_HINT_REFLOW) && + HasAttributeContent(oldContext, aAttrNameSpaceID, aAttribute)) { + aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); + } +#endif + } + newExtraContext->Release(); } } else { @@ -1873,23 +1839,22 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, for (UndisplayedNode* undisplayed = mUndisplayedMap->GetFirstNode(localContent); undisplayed; undisplayed = undisplayed->mNext) { - nsCOMPtr undisplayedContext; - undisplayed->mStyle->GetPseudoType(pseudoTag); + nsRefPtr undisplayedContext; + pseudoTag = undisplayed->mStyle->GetPseudoType(); if (pseudoTag == nsnull) { // child content - aPresContext->ResolveStyleContextFor(undisplayed->mContent, - newContext, getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolveStyleContextFor(undisplayed->mContent, + newContext).get(); } else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { - aPresContext->ResolveStyleContextForNonElement(newContext, - getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolveStyleContextForNonElement(newContext).get(); } else { // pseudo element NS_NOTREACHED("no pseudo elements in undisplayed map"); NS_ASSERTION(pseudoTag, "pseudo element without tag"); - aPresContext->ResolvePseudoStyleContextFor(localContent, pseudoTag, - newContext, getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolvePseudoStyleContextFor(localContent, + pseudoTag, + newContext).get(); } - NS_IF_RELEASE(pseudoTag); if (undisplayedContext) { const nsStyleDisplay* display; ::GetStyleData(undisplayedContext.get(), &display); @@ -1925,11 +1890,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aPresContext); if (!beforeFrame) { // Look for a new :before style context - nsCOMPtr newBeforeContext; - aPresContext->ProbePseudoStyleContextFor(localContent, + nsRefPtr newBeforeContext = aPresContext->ProbePseudoStyleContextFor(localContent, nsCSSPseudoElements::before, - newContext, - getter_AddRefs(newBeforeContext)); + newContext); if (newBeforeContext) { // Have to create the new :before frame NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1952,11 +1915,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // Getting the :after frame is // more expensive than getting the pseudo context, so get the // pseudo context first. - nsCOMPtr newAfterContext; - aPresContext->ProbePseudoStyleContextFor(localContent, + nsRefPtr newAfterContext = aPresContext->ProbePseudoStyleContextFor(localContent, nsCSSPseudoElements::after, - newContext, - getter_AddRefs(newAfterContext)); + newContext); if (newAfterContext) { // Check whether we already have an :after frame nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(aFrame, @@ -2033,7 +1994,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // XXX need to do overflow frames??? } - NS_RELEASE(newContext); + newContext->Release(); NS_IF_RELEASE(localContent); } } @@ -2667,7 +2628,7 @@ UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode, nsIContent* aParentContent nsresult UndisplayedMap::AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, - nsIStyleContext* aStyle) + nsStyleContext* aStyle) { UndisplayedNode* node = new UndisplayedNode(aChild, aStyle); if (! node) { diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index b0ed3065a8c..8e18a9ce5fb 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -59,7 +59,7 @@ class nsString; class nsAString; class nsStringArray; class nsICaret; -class nsIStyleContext; +class nsStyleContext; class nsIFrameSelection; class nsIFrameManager; class nsILayoutHistoryState; @@ -258,13 +258,6 @@ public: NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame) const = 0; - /** Returns the style context associated with the frame. - * Used by code outside of layout that can't use nsIFrame methods to get - * the style context directly. - */ - NS_IMETHOD GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const = 0; - /** * Returns a layout object associated with the primary frame for the content object. * diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp index 555f0cae0d7..a298b098fde 100644 --- a/mozilla/layout/base/nsImageLoader.cpp +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -41,7 +41,7 @@ #include "nsIViewManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver) @@ -240,8 +240,8 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect) // Invalidate the entire frame only if the frame has a tiled background // image, otherwise just invalidate the intersection of the frame's bounds // with the damaged rect. - nsCOMPtr styleContext; - mFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext; + mFrame->GetStyleContext(&styleContext); const nsStyleBackground* bg = (const nsStyleBackground*)styleContext->GetStyleData(eStyleStruct_Background); if ((bg->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) || diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 127f8737c3f..daa34f750ff 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -48,7 +48,7 @@ #include "nsIRenderingContext.h" #include "nsIURL.h" #include "nsIDocument.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLayoutAtoms.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" @@ -69,6 +69,7 @@ #include "nsContentPolicyUtils.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMDocument.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" #endif // IBMBIDI @@ -934,26 +935,18 @@ nsPresContext::GetBaseURL(nsIURI** aResult) return NS_OK; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ResolveStyleFor(this, aContent, aParentContext); - if (nsnull == result) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } + if (NS_SUCCEEDED(rv) && set) { + // return the addref'd style context + return set->ResolveStyleFor(this, aContent, aParentContext); } - *aResult = result; - return rv; + + return nsnull; } NS_IMETHODIMP @@ -961,92 +954,71 @@ nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent, int aSID, const nsStyleStruct*& aStyleStruct) { - nsCOMPtr sc; - nsresult rv = ResolveStyleContextFor(aContent, nsnull, getter_AddRefs(sc)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr sc = ResolveStyleContextFor(aContent, nsnull); + if (!sc) return NS_ERROR_FAILURE; aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID); return aStyleStruct ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsPresContext::ResolveStyleContextForNonElement( - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) +already_AddRefed +nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); if (NS_SUCCEEDED(rv) && set) { - result = set->ResolveStyleForNonElement(this, aParentContext); - if (!result) - rv = NS_ERROR_OUT_OF_MEMORY; + // return addrefed style context + return set->ResolveStyleForNonElement(this, aParentContext); } - *aResult = result; - return rv; + + return nsnull; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolvePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, aParentContext, - nsnull, aResult); + return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, + aParentContext, nsnull); } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolvePseudoStyleWithComparator(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult) + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ResolvePseudoStyleFor(this, aParentContent, aPseudoTag, - aParentContext, aComparator); - if (nsnull == result) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } + if (NS_SUCCEEDED(rv) && set) { + // return addrefed style context + return set->ResolvePseudoStyleFor(this, aParentContent, aPseudoTag, + aParentContext, aComparator); } - *aResult = result; - return rv; + + return nsnull; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ProbePseudoStyleFor(this, aParentContent, aPseudoTag, - aParentContext); - } + if (NS_SUCCEEDED(rv) && set) { + // return addrefed style context + return set->ProbePseudoStyleFor(this, aParentContent, aPseudoTag, + aParentContext); } - *aResult = result; - return rv; + + return nsnull; } NS_IMETHODIMP nsPresContext::ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) + nsStyleContext* aNewParentContext) { NS_PRECONDITION(aFrame, "null ptr"); if (! aFrame) { diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 98cbb80d9ec..05af526ea97 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -43,6 +43,7 @@ #include "nsAString.h" #include "nsIRequest.h" #include "nsCompatibility.h" +#include "nsCOMPtr.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -61,7 +62,7 @@ class nsIImage; class nsILinkHandler; class nsIPresShell; class nsIPref; -class nsIStyleContext; +class nsStyleContext; class nsIAtom; class nsString; class nsIEventStateManager; @@ -192,9 +193,9 @@ public: * Resolve style for the given piece of content that will be a child * of the aParentContext. Don't use this for pseudo frames. */ - NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolveStyleContextFor(nsIContent* aContent, + nsStyleContext* aParentContext) = 0; /** * Resolve the given style struct for a content node. @@ -221,19 +222,19 @@ public: * represents everything except the first letter.) * */ - NS_IMETHOD ResolveStyleContextForNonElement( - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + 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"); */ - NS_IMETHOD ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + + virtual already_AddRefed + ResolvePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * Resolve style for a pseudo frame within the given aParentContent & aParentContext. @@ -243,11 +244,11 @@ public: * Instead of matching solely on aPseudoTag, a comparator function can be * passed in to test. */ - NS_IMETHOD ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolvePseudoStyleWithComparator(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) = 0; /** * Probe style for a pseudo frame within the given aParentContent & aParentContext. @@ -255,17 +256,17 @@ public: * The tag should be lowercase and inclue the colon. * ie: NS_NewAtom(":first-line"); */ - NS_IMETHOD ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ProbePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * For a given frame tree, get a new style context that is the equivalent * but within a new parent */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) = 0; + nsStyleContext* aNewParentContext) = 0; NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 175bcf7574a..360a5c61e86 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -79,6 +79,7 @@ #include "nsHTMLAtoms.h" #include "nsCSSPseudoElements.h" #include "nsCOMPtr.h" +#include "nsAutoPtr.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" #include "nsWeakReference.h" @@ -1052,8 +1053,6 @@ public: NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame) const; - NS_IMETHOD GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const; NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent, nsISupports** aResult) const; NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, @@ -4619,14 +4618,13 @@ PresShell::GetGeneratedContentIterator(nsIContent* aContent, } else { // Avoid finding the :after frame unless we need to (it's // expensive). Instead probe for the existence of the pseudo-element - nsCOMPtr styleContext; - nsCOMPtr pseudoStyleContext; + nsStyleContext *styleContext; + nsRefPtr pseudoStyleContext; - primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); - mPresContext->ProbePseudoStyleContextFor(aContent, - nsCSSPseudoElements::after, - styleContext, - getter_AddRefs(pseudoStyleContext)); + styleContext = primaryFrame->GetStyleContext(); + pseudoStyleContext = mPresContext->ProbePseudoStyleContextFor(aContent, + nsCSSPseudoElements::after, + styleContext); if (pseudoStyleContext) { nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(primaryFrame, mPresContext); @@ -5558,16 +5556,6 @@ PresShell::GetPrimaryFrameFor(nsIContent* aContent, return rv; } -NS_IMETHODIMP -PresShell::GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const -{ - if (!aFrame || !aStyleContext) { - return NS_ERROR_NULL_POINTER; - } - return (aFrame->GetStyleContext(aStyleContext)); -} - NS_IMETHODIMP PresShell::GetLayoutObjectFor(nsIContent* aContent, nsISupports** aResult) const diff --git a/mozilla/layout/base/nsStyleConsts.h b/mozilla/layout/base/nsStyleConsts.h index af52e199fab..966fb4abe93 100644 --- a/mozilla/layout/base/nsStyleConsts.h +++ b/mozilla/layout/base/nsStyleConsts.h @@ -39,7 +39,7 @@ #include "nsFont.h" -// XXX fold this into nsIStyleContext and group by nsStyleXXX struct +// XXX fold this into nsStyleContext and group by nsStyleXXX struct // Indicies into border/padding/margin arrays #define NS_SIDE_TOP 0 diff --git a/mozilla/layout/base/public/MANIFEST b/mozilla/layout/base/public/MANIFEST index 07bae6ef9a1..3e48eacf0bd 100644 --- a/mozilla/layout/base/public/MANIFEST +++ b/mozilla/layout/base/public/MANIFEST @@ -36,7 +36,6 @@ nsIReflowCallback.h nsIScrollableFrame.h nsIScrollableViewProvider.h nsIStatefulFrame.h -nsIStyleContext.h nsIStyleFrameConstruction.h nsIStyleSet.h nsITextFrame.h diff --git a/mozilla/layout/base/public/Makefile.in b/mozilla/layout/base/public/Makefile.in index e6053ee0817..7a6fd7a423b 100644 --- a/mozilla/layout/base/public/Makefile.in +++ b/mozilla/layout/base/public/Makefile.in @@ -64,7 +64,6 @@ nsIReflowCallback.h \ nsIScrollableFrame.h \ nsIScrollableViewProvider.h \ nsIStatefulFrame.h \ -nsIStyleContext.h \ nsIStyleFrameConstruction.h \ nsIStyleSet.h \ nsLayoutErrors.h \ diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index adb6fceba85..2850ae5976f 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -47,7 +47,7 @@ #include "nsISupports.h" #include "nsEvent.h" #include "nsStyleStruct.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" /** @@ -418,7 +418,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) = 0; /** @@ -553,24 +553,21 @@ public: NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end) const = 0; /** - * Get the style context associated with this frame. Note that GetStyleContext() - * adds a reference to the style context so the caller must do a release. + * Get the style context associated with this frame. * - * @see nsISupports#Release() */ - nsresult GetStyleContext(nsIStyleContext** aStyleContext) const { - *aStyleContext = mStyleContext; NS_IF_ADDREF(*aStyleContext); return NS_OK; - } - nsresult SetStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aContext) { + nsStyleContext* GetStyleContext() const { return mStyleContext; } + void SetStyleContext(nsIPresContext* aPresContext, nsStyleContext* aContext) + { if (aContext != mStyleContext) { - NS_IF_RELEASE(mStyleContext); - if (nsnull != aContext) { - mStyleContext = aContext; - NS_ADDREF(aContext); + if (mStyleContext) + mStyleContext->Release(); + mStyleContext = aContext; + if (aContext) { + aContext->AddRef(); DidSetStyleContext(aPresContext); } } - return NS_OK; } // Style post processing hook @@ -596,13 +593,6 @@ public: } #endif - // Fill a style struct with data - nsresult GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const { - NS_ASSERTION(mStyleContext, "No style context found!"); - mStyleContext->GetStyle(aSID, aStruct); - return NS_OK; - } - // Utility function: more convenient than 2 calls to GetStyleData to get border and padding NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0; @@ -616,10 +606,10 @@ public: * The indicies must be consecutive and implementations MUST return an * NS_ERROR_INVALID_ARG if asked for an index that is out of range. */ - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const = 0; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) = 0; + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const = 0; + + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext) = 0; /** * Accessor functions for geometric parent @@ -1239,7 +1229,7 @@ protected: // Members nsRect mRect; nsIContent* mContent; - nsIStyleContext* mStyleContext; + nsStyleContext* mStyleContext; nsIFrame* mParent; nsIFrame* mNextSibling; // singly-linked list of frames nsFrameState mState; @@ -1250,7 +1240,7 @@ private: }; // typesafe way to access style data. See comment in nsStyleStruct.h -// and also overloaded function in nsIStyleContext.h +// and also overloaded function in nsStyleContext.h template inline void GetStyleData(nsIFrame* aFrame, const T** aStyleStruct) diff --git a/mozilla/layout/base/public/nsIFrameManager.h b/mozilla/layout/base/public/nsIFrameManager.h index a1182e031d0..81efb4699b8 100644 --- a/mozilla/layout/base/public/nsIFrameManager.h +++ b/mozilla/layout/base/public/nsIFrameManager.h @@ -48,7 +48,7 @@ class nsIContent; class nsIPresContext; class nsIPresShell; class nsIStyleSet; -class nsIStyleContext; +class nsStyleContext; class nsILayoutHistoryState; class nsStyleChangeList; class nsPlaceholderFrame; @@ -107,8 +107,9 @@ public: NS_IMETHOD ClearPlaceholderFrameMap() = 0; // Mapping undisplayed content - NS_IMETHOD GetUndisplayedContent(nsIContent* aContent, nsIStyleContext** aStyleContext)=0; - NS_IMETHOD SetUndisplayedContent(nsIContent* aContent, nsIStyleContext* aStyleContext) = 0; + virtual nsStyleContext* GetUndisplayedContent(nsIContent* aContent) = 0; + virtual void SetUndisplayedContent(nsIContent* aContent, + nsStyleContext* aStyleContext) = 0; NS_IMETHOD ClearUndisplayedContentIn(nsIContent* aContent, nsIContent* aParentContent) = 0; NS_IMETHOD ClearAllUndisplayedContentIn(nsIContent* aParentContent) = 0; NS_IMETHOD ClearUndisplayedContentMap() = 0; @@ -149,7 +150,7 @@ public: // new given parent style context NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) = 0; + nsStyleContext* aNewParentContext) = 0; // Re-resolve style contexts for frame tree NS_IMETHOD ComputeStyleChangeFor(nsIPresContext* aPresContext, diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 98cbb80d9ec..05af526ea97 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -43,6 +43,7 @@ #include "nsAString.h" #include "nsIRequest.h" #include "nsCompatibility.h" +#include "nsCOMPtr.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -61,7 +62,7 @@ class nsIImage; class nsILinkHandler; class nsIPresShell; class nsIPref; -class nsIStyleContext; +class nsStyleContext; class nsIAtom; class nsString; class nsIEventStateManager; @@ -192,9 +193,9 @@ public: * Resolve style for the given piece of content that will be a child * of the aParentContext. Don't use this for pseudo frames. */ - NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolveStyleContextFor(nsIContent* aContent, + nsStyleContext* aParentContext) = 0; /** * Resolve the given style struct for a content node. @@ -221,19 +222,19 @@ public: * represents everything except the first letter.) * */ - NS_IMETHOD ResolveStyleContextForNonElement( - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + 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"); */ - NS_IMETHOD ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + + virtual already_AddRefed + ResolvePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * Resolve style for a pseudo frame within the given aParentContent & aParentContext. @@ -243,11 +244,11 @@ public: * Instead of matching solely on aPseudoTag, a comparator function can be * passed in to test. */ - NS_IMETHOD ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolvePseudoStyleWithComparator(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) = 0; /** * Probe style for a pseudo frame within the given aParentContent & aParentContext. @@ -255,17 +256,17 @@ public: * The tag should be lowercase and inclue the colon. * ie: NS_NewAtom(":first-line"); */ - NS_IMETHOD ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ProbePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * For a given frame tree, get a new style context that is the equivalent * but within a new parent */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) = 0; + nsStyleContext* aNewParentContext) = 0; NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; diff --git a/mozilla/layout/base/public/nsIPresShell.h b/mozilla/layout/base/public/nsIPresShell.h index b0ed3065a8c..8e18a9ce5fb 100644 --- a/mozilla/layout/base/public/nsIPresShell.h +++ b/mozilla/layout/base/public/nsIPresShell.h @@ -59,7 +59,7 @@ class nsString; class nsAString; class nsStringArray; class nsICaret; -class nsIStyleContext; +class nsStyleContext; class nsIFrameSelection; class nsIFrameManager; class nsILayoutHistoryState; @@ -258,13 +258,6 @@ public: NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame) const = 0; - /** Returns the style context associated with the frame. - * Used by code outside of layout that can't use nsIFrame methods to get - * the style context directly. - */ - NS_IMETHOD GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const = 0; - /** * Returns a layout object associated with the primary frame for the content object. * diff --git a/mozilla/layout/base/public/nsIStyleContext.h b/mozilla/layout/base/public/nsIStyleContext.h deleted file mode 100644 index cb22178abc7..00000000000 --- a/mozilla/layout/base/public/nsIStyleContext.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsIStyleContext_h___ -#define nsIStyleContext_h___ - -#include "nsISupports.h" -#include "nsColor.h" -#include "nsCoord.h" -#include "nsMargin.h" -#include "nsRect.h" -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsStyleCoord.h" -#include "nsStyleStruct.h" -#include "nsStyleConsts.h" -#include "nsChangeHint.h" -#include "nsCOMPtr.h" -#include "nsILanguageAtom.h" - -class nsISizeOfHandler; - -class nsIFrame; -class nsIStyleSet; -class nsIPresContext; -class nsISupportsArray; -class nsIStyleContext; -class nsRuleNode; - -//---------------------------------------------------------------------- - -#define NS_ISTYLECONTEXT_IID \ - { 0x26a4d970, 0xa342, 0x11d1, \ - {0x89, 0x74, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } - -class nsIStyleContext : public nsISupports { -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLECONTEXT_IID) - - virtual PRBool Equals(const nsIStyleContext* aOther) const = 0; - - virtual already_AddRefed GetParent(void) const = 0; - NS_IMETHOD GetFirstChild(nsIStyleContext** aContext)=0; - - NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const = 0; - - NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag, - nsRuleNode* aRules, - nsIStyleContext*& aResult) = 0; - - virtual PRBool HasTextDecorations()=0; - - - NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding)=0; - - // This method computes the effective difference between two contexts that are both at the - // same position in the style context tree. The |this| parameter must always - // be the old context. This method will only peek at style data on the old - // context, and will not instantiate new data in order to compute a difference. - // That is why the old context must always be used (since the new context will - // have no data on it yet) for determining the actual difference. - NS_IMETHOD CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint) = 0; - - NS_IMETHOD GetRuleNode(nsRuleNode** aResult)=0; - NS_IMETHOD AddStyleBit(const PRUint32& aBit)=0; - NS_IMETHOD GetStyleBits(PRUint32* aBits)=0; - -#ifdef DEBUG - // debugging - virtual void List(FILE* out, PRInt32 aIndent) = 0; - virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) = 0; - virtual void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)=0; -#endif - - // XXXdwh Make this function private. It should not be possible to call this - // function from layout. - // Fill a style struct with data. - NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) = 0; - - // Get the data for a style struct. - NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) = 0; - - virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID) = 0; - - // Avoid using this method at all costs. It defeats sharing of style data, forcing the context - // to have its own unique copy. At the moment the only supported structs are text, background, and - // display. Don't add support for new structs or use this method without careful consideration! -dwh - virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID) = 0; - - // Used only for inline style. - virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule) = 0; - - // Used to clear away the style data for a given style context if it matches the specified |aRule|. - // If |aRule| is null, then the style data is always blown away. - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule) = 0; -}; - - -// this is private to nsStyleSet, don't call it -extern NS_EXPORT nsresult - NS_NewStyleContext(nsIStyleContext** aInstancePtrResult, - nsIStyleContext* aParentContext, - nsIAtom* aPseudoType, - nsRuleNode* aRuleNode, - nsIPresContext* aPresContext); - -// typesafe way to access style data. See nsStyleStruct.h and also -// overloaded function in nsIFrame.h. -template -inline void -GetStyleData(nsIStyleContext* aStyleContext, const T** aStyleStruct) -{ - *aStyleStruct = NS_STATIC_CAST(const T*, - aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T))); -} - -#endif /* nsIStyleContext_h___ */ diff --git a/mozilla/layout/base/public/nsIStyleSet.h b/mozilla/layout/base/public/nsIStyleSet.h index 75e751e43d5..37226cecf00 100644 --- a/mozilla/layout/base/public/nsIStyleSet.h +++ b/mozilla/layout/base/public/nsIStyleSet.h @@ -41,11 +41,12 @@ #include #include "nsISupports.h" #include "nsChangeHint.h" +#include "nsCOMPtr.h" class nsIAtom; class nsIStyleRule; class nsIStyleSheet; -class nsIStyleContext; +class nsStyleContext; class nsIStyleRuleSupplier; class nsIStyleFrameConstruction; class nsIPresContext; @@ -141,7 +142,7 @@ public: // |aContext| provides an additional hint that a specific style context has changed, and // that the entire rule tree need not be searched for occurrences of |aRule|. It is // only specified in the inline style case, i.e., when the inline style attribute changes. - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext) = 0; + virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsStyleContext* aContext) = 0; // enable / disable the Quirk style sheet: // returns NS_FAILURE if none is found, otherwise NS_OK @@ -150,10 +151,11 @@ public: NS_IMETHOD NotifyStyleSheetStateChanged(PRBool aApplicable) = 0; - // get a style context for a non-pseudo frame - virtual nsIStyleContext* ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aParentContext) = 0; + // get a style context for a non-pseudo frame. + virtual already_AddRefed + ResolveStyleFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aParentContext) = 0; // 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 @@ -165,34 +167,36 @@ public: // it once to create a style context for the nsFirstLetterFrame that // represents everything except the first letter.) // - virtual nsIStyleContext* ResolveStyleForNonElement( - nsIPresContext* aPresContext, - nsIStyleContext* aParentContext) = 0; + virtual already_AddRefed + ResolveStyleForNonElement(nsIPresContext* aPresContext, + nsStyleContext* aParentContext) = 0; // get a style context for a pseudo-element (i.e., // |aPseudoTag == nsCOMPtr(do_GetAtom(":first-line"))|; - virtual nsIStyleContext* ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator = nsnull) = 0; + virtual already_AddRefed + ResolvePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator = nsnull) = 0; // This funtions just like ResolvePseudoStyleFor except that it will // return nsnull if there are no explicit style rules for that - // pseudo element - virtual nsIStyleContext* ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext) = 0; + // pseudo element. + virtual already_AddRefed + ProbePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; NS_IMETHOD Shutdown()=0; // Get a new style context that lives in a different parent // The new context will be the same as the old if the new parent == the old parent - NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, - nsIStyleContext* aNewParentContext, - nsIStyleContext** aNewStyleContext) = 0; + virtual already_AddRefed + ReParentStyleContext(nsIPresContext* aPresContext, + nsStyleContext* aStyleContext, + nsStyleContext* aNewParentContext) = 0; // Test if style is dependent on content state NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext, diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 98cbb80d9ec..05af526ea97 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -43,6 +43,7 @@ #include "nsAString.h" #include "nsIRequest.h" #include "nsCompatibility.h" +#include "nsCOMPtr.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -61,7 +62,7 @@ class nsIImage; class nsILinkHandler; class nsIPresShell; class nsIPref; -class nsIStyleContext; +class nsStyleContext; class nsIAtom; class nsString; class nsIEventStateManager; @@ -192,9 +193,9 @@ public: * Resolve style for the given piece of content that will be a child * of the aParentContext. Don't use this for pseudo frames. */ - NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolveStyleContextFor(nsIContent* aContent, + nsStyleContext* aParentContext) = 0; /** * Resolve the given style struct for a content node. @@ -221,19 +222,19 @@ public: * represents everything except the first letter.) * */ - NS_IMETHOD ResolveStyleContextForNonElement( - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + 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"); */ - NS_IMETHOD ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + + virtual already_AddRefed + ResolvePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * Resolve style for a pseudo frame within the given aParentContent & aParentContext. @@ -243,11 +244,11 @@ public: * Instead of matching solely on aPseudoTag, a comparator function can be * passed in to test. */ - NS_IMETHOD ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ResolvePseudoStyleWithComparator(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) = 0; /** * Probe style for a pseudo frame within the given aParentContent & aParentContext. @@ -255,17 +256,17 @@ public: * The tag should be lowercase and inclue the colon. * ie: NS_NewAtom(":first-line"); */ - NS_IMETHOD ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) = 0; + virtual already_AddRefed + ProbePseudoStyleContextFor(nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) = 0; /** * For a given frame tree, get a new style context that is the equivalent * but within a new parent */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) = 0; + nsStyleContext* aNewParentContext) = 0; NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; diff --git a/mozilla/layout/base/public/nsStyleConsts.h b/mozilla/layout/base/public/nsStyleConsts.h index af52e199fab..966fb4abe93 100644 --- a/mozilla/layout/base/public/nsStyleConsts.h +++ b/mozilla/layout/base/public/nsStyleConsts.h @@ -39,7 +39,7 @@ #include "nsFont.h" -// XXX fold this into nsIStyleContext and group by nsStyleXXX struct +// XXX fold this into nsStyleContext and group by nsStyleXXX struct // Indicies into border/padding/margin arrays #define NS_SIDE_TOP 0 diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index ed37179c4eb..0e8bd493d5f 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -126,14 +126,13 @@ CreateBidiContinuation(nsIPresContext* aPresContext, if (!(*aNewFrame) ) { return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext) ); + nsStyleContext* styleContext = aFrame->GetStyleContext(); - NS_ASSERTION(presShell, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation"); + NS_ASSERTION(styleContext, "Frame has no styleContext in nsBidiPresUtils::CreateBidiContinuation"); aFrame->GetParent(&parent); - NS_ASSERTION(presShell, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation"); + NS_ASSERTION(parent, "Couldn't get frame parent in nsBidiPresUtils::CreateBidiContinuation"); (*aNewFrame)->Init(aPresContext, aContent, parent, styleContext, nsnull); diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp index 555f0cae0d7..a298b098fde 100644 --- a/mozilla/layout/base/src/nsImageLoader.cpp +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -41,7 +41,7 @@ #include "nsIViewManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver) @@ -240,8 +240,8 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect) // Invalidate the entire frame only if the frame has a tiled background // image, otherwise just invalidate the intersection of the frame's bounds // with the damaged rect. - nsCOMPtr styleContext; - mFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext; + mFrame->GetStyleContext(&styleContext); const nsStyleBackground* bg = (const nsStyleBackground*)styleContext->GetStyleData(eStyleStruct_Background); if ((bg->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) || diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 127f8737c3f..daa34f750ff 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -48,7 +48,7 @@ #include "nsIRenderingContext.h" #include "nsIURL.h" #include "nsIDocument.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLayoutAtoms.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" @@ -69,6 +69,7 @@ #include "nsContentPolicyUtils.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMDocument.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" #endif // IBMBIDI @@ -934,26 +935,18 @@ nsPresContext::GetBaseURL(nsIURI** aResult) return NS_OK; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ResolveStyleFor(this, aContent, aParentContext); - if (nsnull == result) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } + if (NS_SUCCEEDED(rv) && set) { + // return the addref'd style context + return set->ResolveStyleFor(this, aContent, aParentContext); } - *aResult = result; - return rv; + + return nsnull; } NS_IMETHODIMP @@ -961,92 +954,71 @@ nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent, int aSID, const nsStyleStruct*& aStyleStruct) { - nsCOMPtr sc; - nsresult rv = ResolveStyleContextFor(aContent, nsnull, getter_AddRefs(sc)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr sc = ResolveStyleContextFor(aContent, nsnull); + if (!sc) return NS_ERROR_FAILURE; aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID); return aStyleStruct ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsPresContext::ResolveStyleContextForNonElement( - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) +already_AddRefed +nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); if (NS_SUCCEEDED(rv) && set) { - result = set->ResolveStyleForNonElement(this, aParentContext); - if (!result) - rv = NS_ERROR_OUT_OF_MEMORY; + // return addrefed style context + return set->ResolveStyleForNonElement(this, aParentContext); } - *aResult = result; - return rv; + + return nsnull; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolvePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, aParentContext, - nsnull, aResult); + return ResolvePseudoStyleWithComparator(aParentContent, aPseudoTag, + aParentContext, nsnull); } -NS_IMETHODIMP +already_AddRefed nsPresContext::ResolvePseudoStyleWithComparator(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult) + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ResolvePseudoStyleFor(this, aParentContent, aPseudoTag, - aParentContext, aComparator); - if (nsnull == result) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } + if (NS_SUCCEEDED(rv) && set) { + // return addrefed style context + return set->ResolvePseudoStyleFor(this, aParentContent, aPseudoTag, + aParentContext, aComparator); } - *aResult = result; - return rv; + + return nsnull; } -NS_IMETHODIMP +already_AddRefed nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult) + nsStyleContext* aParentContext) { - NS_PRECONDITION(aResult, "null out param"); - - nsIStyleContext* result = nsnull; nsCOMPtr set; nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); - if (NS_SUCCEEDED(rv)) { - if (set) { - result = set->ProbePseudoStyleFor(this, aParentContent, aPseudoTag, - aParentContext); - } + if (NS_SUCCEEDED(rv) && set) { + // return addrefed style context + return set->ProbePseudoStyleFor(this, aParentContent, aPseudoTag, + aParentContext); } - *aResult = result; - return rv; + + return nsnull; } NS_IMETHODIMP nsPresContext::ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) + nsStyleContext* aNewParentContext) { NS_PRECONDITION(aFrame, "null ptr"); if (! aFrame) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 8d364829865..0f2461430d6 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -84,29 +84,35 @@ public: NS_IMETHOD GetBaseURL(nsIURI** aURLResult); NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; NS_IMETHOD ClearStyleDataAndReflow(void); - NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult); + + virtual already_AddRefed + ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext); + NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent, int aSID, const nsStyleStruct*& aStyleStruct); - NS_IMETHOD ResolveStyleContextForNonElement(nsIStyleContext* aParentContext, - nsIStyleContext** aResult); - NS_IMETHOD ResolvePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult); - NS_IMETHOD ResolvePseudoStyleWithComparator(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator, - nsIStyleContext** aResult); - NS_IMETHOD ProbePseudoStyleContextFor(nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsIStyleContext** aResult); + + 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 ReParentStyleContext(nsIFrame* aFrame, - nsIStyleContext* aNewParentContext); + nsStyleContext* aNewParentContext); NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult); NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult); NS_IMETHOD FreeToShell(size_t aSize, void* aFreeChunk); diff --git a/mozilla/layout/forms/nsButtonFrameRenderer.cpp b/mozilla/layout/forms/nsButtonFrameRenderer.cpp index ac98d993321..51c05b6890a 100644 --- a/mozilla/layout/forms/nsButtonFrameRenderer.cpp +++ b/mozilla/layout/forms/nsButtonFrameRenderer.cpp @@ -145,7 +145,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext, GetButtonOuterFocusRect(aRect, rect); const nsStyleBorder* border; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*,mOuterFocusStyle), &border); + ::GetStyleData(mOuterFocusStyle, &border); nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame, aDirtyRect, rect, *border, mOuterFocusStyle, 0); } @@ -156,7 +156,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext, GetButtonInnerFocusRect(aRect, rect); const nsStyleBorder* border; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*,mInnerFocusStyle), &border); + ::GetStyleData(mInnerFocusStyle, &border); nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame, aDirtyRect, rect, *border, mInnerFocusStyle, 0); } @@ -174,8 +174,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext, nsRect buttonRect; GetButtonRect(aRect, buttonRect); - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); const nsStyleBorder* border = (const nsStyleBorder*)context->GetStyleData(eStyleStruct_Border); @@ -247,8 +246,7 @@ nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding() nsMargin nsButtonFrameRenderer::GetButtonBorderAndPadding() { - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); nsMargin innerFocusBorderAndPadding(0,0,0,0); nsStyleBorderPadding bPad; @@ -324,52 +322,38 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext) // get all the styles nsCOMPtr content; mFrame->GetContent(getter_AddRefs(content)); - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); // style for the inner such as a dotted line (Windows) - aPresContext->ProbePseudoStyleContextFor(content, nsCSSPseudoElements::mozFocusInner, context, - getter_AddRefs(mInnerFocusStyle)); + mInnerFocusStyle = aPresContext->ProbePseudoStyleContextFor(content, + nsCSSPseudoElements::mozFocusInner, + context); // style for outer focus like a ridged border (MAC). - aPresContext->ProbePseudoStyleContextFor(content, nsCSSPseudoElements::mozFocusOuter, context, - getter_AddRefs(mOuterFocusStyle)); + mOuterFocusStyle = aPresContext->ProbePseudoStyleContextFor(content, + nsCSSPseudoElements::mozFocusOuter, + context); } -nsresult -nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const +nsStyleContext* +nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { - case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: - *aStyleContext = mInnerFocusStyle; - NS_IF_ADDREF(*aStyleContext); - break; + return mInnerFocusStyle; case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: - *aStyleContext = mOuterFocusStyle; - NS_IF_ADDREF(*aStyleContext); - break; + return mOuterFocusStyle; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -nsresult -nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext) +void +nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { - case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: mInnerFocusStyle = aStyleContext; break; @@ -377,5 +361,4 @@ nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleCo mOuterFocusStyle = aStyleContext; break; } - return NS_OK; } diff --git a/mozilla/layout/forms/nsButtonFrameRenderer.h b/mozilla/layout/forms/nsButtonFrameRenderer.h index a5878958bfc..3e605c0139b 100644 --- a/mozilla/layout/forms/nsButtonFrameRenderer.h +++ b/mozilla/layout/forms/nsButtonFrameRenderer.h @@ -44,7 +44,7 @@ #define nsButtonFrameRenderer_h___ #include "nsCoord.h" -#include "nsCOMPtr.h" +#include "nsAutoPtr.h" #include "nsFrame.h" class nsStyleChangeList; @@ -98,8 +98,8 @@ public: virtual nsMargin GetFullButtonBorderAndPadding(); virtual nsMargin GetAddedButtonBorderAndPadding(); - virtual nsresult GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const; - virtual nsresult SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetStyleContext(PRInt32 aIndex) const; + virtual void SetStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext); virtual void ReResolveStyles(nsIPresContext* aPresContext); virtual void Redraw(nsIPresContext* aPresContext); @@ -111,9 +111,9 @@ protected: private: // cached styles for focus and outline. - nsCOMPtr mBorderStyle; - nsCOMPtr mInnerFocusStyle; - nsCOMPtr mOuterFocusStyle; + nsRefPtr mBorderStyle; + nsRefPtr mInnerFocusStyle; + nsRefPtr mOuterFocusStyle; nsFrame* mFrame; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index b6802dc3e2d..0d8d6683bca 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -83,6 +83,7 @@ #include "nsIServiceManager.h" #include "nsIDOMNode.h" #include "nsGUIEvent.h" +#include "nsAutoPtr.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -376,7 +377,7 @@ NS_IMETHODIMP nsComboboxControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // Need to hold on the pres context because it is used later in methods @@ -2161,23 +2162,18 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous frame - nsCOMPtr styleContext; - rv = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) { return rv; } + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // create a text frame and put it inside the block frame rv = NS_NewTextFrame(shell, &mTextFrame); if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); @@ -2301,23 +2297,18 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous block frame - nsCOMPtr styleContext; - rv = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) { return rv; } + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // Create a text frame and put it inside the block frame rv = NS_NewTextFrame(shell, &mTextFrame); if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } // initialize the text frame diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index 1773ffa8aee..6057ab3eb6f 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -110,7 +110,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aCX, diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp index 4ae7e35ea0e..5ab147cc0ff 100644 --- a/mozilla/layout/forms/nsFieldSetFrame.cpp +++ b/mozilla/layout/forms/nsFieldSetFrame.cpp @@ -54,7 +54,6 @@ #include "nsHTMLParts.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" -#include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsFont.h" #include "nsCOMPtr.h" diff --git a/mozilla/layout/forms/nsFileControlFrame.h b/mozilla/layout/forms/nsFileControlFrame.h index eb8f55817e1..f94f10e7c5d 100644 --- a/mozilla/layout/forms/nsFileControlFrame.h +++ b/mozilla/layout/forms/nsFileControlFrame.h @@ -65,7 +65,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index e3de8dc461b..0438964bb6a 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -41,7 +41,6 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIView.h" diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index 665f49030d3..d82d058d0f7 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -44,7 +44,6 @@ #include "nsIWidget.h" #include "nsLeafFrame.h" #include "nsCoord.h" -#include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsCOMPtr.h" diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index a81911af453..d299b496419 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -41,7 +41,7 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIView.h" @@ -250,7 +250,7 @@ nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFra nsresult nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame, nsIPresContext* aPresContext, - nsIStyleContext * aStyleContext, + nsStyleContext * aStyleContext, const nsFont*& aFont) { const nsStyleFont* styleFont = (const nsStyleFont*)aStyleContext->GetStyleData(eStyleStruct_Font); diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index 9b97d801213..e7f160cd15c 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -50,7 +50,7 @@ class nsIView; class nsIPresContext; class nsStyleCoord; class nsIPresState; -class nsIStyleContext; +class nsStyleContext; #define CSS_NOTSET -1 #define ATTR_NOTSET -1 @@ -96,7 +96,7 @@ public: // XXX This could be removed now that we no longer have form quirks. static nsresult GetFont(nsIFormControlFrame * aFormFrame, nsIPresContext* aPresContext, - nsIStyleContext * aStyleContext, + nsStyleContext * aStyleContext, const nsFont*& aFont); // returns the an addref'ed FontMetrics for the default font for the frame @@ -330,9 +330,9 @@ public: const nsRect& aDirtyRect, const nsRect& aRect, PRBool aShift, PRBool aShowFocus, PRBool aDisabled, PRBool aDrawOutline, - nsIStyleContext* aOutlineStyle, - nsIStyleContext* aFocusStyle, - nsIStyleContext* aStyleContext, nsString& aLabel, + nsStyleContext* aOutlineStyle, + nsStyleContext* aFocusStyle, + nsStyleContext* aStyleContext, nsString& aLabel, nsIFrame* aForFrame); static void StyleChangeReflow(nsIPresContext* aPresContext, diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 865694d659d..c321e1d2127 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -50,6 +50,7 @@ #include "nsIDOMNode.h" #include "nsLayoutAtoms.h" #include "nsReflowPath.h" +#include "nsAutoPtr.h" // MouseEvent suppression in PP #include "nsGUIEvent.h" @@ -253,17 +254,13 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * parentFrame = mFrames.FirstChild(); - nsCOMPtr styleContext; - parentFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = parentFrame->GetStyleContext(); rv = NS_NewTextFrame(shell, &newFrame); if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } if (styleContext) { diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp index 20d49fe67a8..1388f22b18a 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -82,7 +82,8 @@ nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame() nsGfxCheckboxControlFrame::~nsGfxCheckboxControlFrame() { - NS_IF_RELEASE(mCheckButtonFaceStyle); + if (mCheckButtonFaceStyle) + mCheckButtonFaceStyle->Release(); } @@ -120,53 +121,43 @@ NS_IMETHODIMP nsGfxCheckboxControlFrame::GetAccessible(nsIAccessible** aAccessib //-------------------------------------------------------------- NS_IMETHODIMP -nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext) +nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsStyleContext *aCheckboxFaceStyleContext) { mCheckButtonFaceStyle = aCheckboxFaceStyleContext; - NS_ADDREF(mCheckButtonFaceStyle); + mCheckButtonFaceStyle->AddRef(); return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP -nsGfxCheckboxControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsGfxCheckboxControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_GFX_CHECKBOX_CONTROL_FRAME_FACE_CONTEXT_INDEX: - *aStyleContext = mCheckButtonFaceStyle; - NS_IF_ADDREF(*aStyleContext); + return mCheckButtonFaceStyle; break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP +void nsGfxCheckboxControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_GFX_CHECKBOX_CONTROL_FRAME_FACE_CONTEXT_INDEX: - NS_IF_RELEASE(mCheckButtonFaceStyle); + if (mCheckButtonFaceStyle) + mCheckButtonFaceStyle->Release(); mCheckButtonFaceStyle = aStyleContext; - NS_IF_ADDREF(aStyleContext); + if (aStyleContext) + aStyleContext->AddRef(); break; } - return NS_OK; } diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h index 80e8bd7a67e..cdca5edde99 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h @@ -77,13 +77,12 @@ public: //nsICheckboxControlFrame methods - NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext); + NS_IMETHOD SetCheckboxFaceStyleContext(nsStyleContext *aCheckboxFaceStyleContext); NS_IMETHOD OnChecked(nsIPresContext* aPresContext, PRBool aChecked); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); // nsIFormControlFrame NS_IMETHOD OnContentReset(); @@ -110,7 +109,7 @@ protected: //GFX-rendered state variables PRBool mInClickEvent; - nsIStyleContext* mCheckButtonFaceStyle; + nsStyleContext* mCheckButtonFaceStyle; private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp index bb479832eef..8bf0401f39a 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp @@ -77,7 +77,8 @@ nsGfxRadioControlFrame::nsGfxRadioControlFrame() nsGfxRadioControlFrame::~nsGfxRadioControlFrame() { - NS_IF_RELEASE(mRadioButtonFaceStyle); + if (mRadioButtonFaceStyle) + mRadioButtonFaceStyle->Release(); } // Frames are not refcounted, no need to AddRef @@ -110,50 +111,40 @@ NS_IMETHODIMP nsGfxRadioControlFrame::GetAccessible(nsIAccessible** aAccessible) #endif //-------------------------------------------------------------- -NS_IMETHODIMP -nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: - *aStyleContext = mRadioButtonFaceStyle; - NS_IF_ADDREF(*aStyleContext); + return mRadioButtonFaceStyle; break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP +void nsGfxRadioControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: - NS_IF_RELEASE(mRadioButtonFaceStyle); + if (mRadioButtonFaceStyle) + mRadioButtonFaceStyle->Release(); mRadioButtonFaceStyle = aStyleContext; - NS_IF_ADDREF(aStyleContext); + if (aStyleContext) + aStyleContext->AddRef(); break; } - return NS_OK; } //-------------------------------------------------------------- NS_IMETHODIMP -nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) +nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext) { mRadioButtonFaceStyle = aRadioButtonFaceStyleContext; - NS_ADDREF(mRadioButtonFaceStyle); + mRadioButtonFaceStyle->AddRef(); return NS_OK; } diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.h b/mozilla/layout/forms/nsGfxRadioControlFrame.h index b04f5debf6d..1d9a40b0dc8 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.h +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.h @@ -62,16 +62,15 @@ public: //nsIRadioControlFrame methods NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext); + NS_IMETHOD SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext); #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); #endif NS_IMETHOD OnChecked(nsIPresContext* aPresContext, PRBool aChecked); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, @@ -106,7 +105,7 @@ public: protected: //GFX-rendered state variables - nsIStyleContext* mRadioButtonFaceStyle; + nsStyleContext* mRadioButtonFaceStyle; private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index d90f1f9a49f..ad4771d04d9 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -47,7 +47,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsISupports.h" @@ -123,7 +123,7 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -145,13 +145,11 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame - nsIStyleContext* styleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::buttonContent, - mStyleContext, - &styleContext); + mStyleContext); mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull); - NS_RELEASE(styleContext); return rv; } @@ -333,14 +331,14 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext* aPresContext, // nsCOMPtr shell; nsCOMPtr frameManager; - nsCOMPtr newParentContext; + nsStyleContext* newParentContext; aPresContext->GetShell(getter_AddRefs(shell)); if (shell) { shell->GetFrameManager(getter_AddRefs(frameManager)); } // get the new parent context from the first child: that is the frame that the // subsequent children will be made children of - mFrames.FirstChild()->GetStyleContext(getter_AddRefs(newParentContext)); + newParentContext = mFrames.FirstChild()->GetStyleContext(); // Set the parent for each of the child frames for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) { @@ -691,18 +689,17 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsAString& a return NS_OK; } -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - return mRenderer.GetStyleContext(aIndex, aStyleContext); + return mRenderer.GetStyleContext(aIndex); } -NS_IMETHODIMP +void nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - return mRenderer.SetStyleContext(aIndex, aStyleContext); + mRenderer.SetStyleContext(aIndex, aStyleContext); } diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.h b/mozilla/layout/forms/nsHTMLButtonControlFrame.h index 95a5f7c3c8a..037bee97364 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.h +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.h @@ -48,7 +48,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsISupports.h" @@ -102,13 +102,12 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, nsIPresShell& aPresShell, diff --git a/mozilla/layout/forms/nsICheckboxControlFrame.h b/mozilla/layout/forms/nsICheckboxControlFrame.h index e74b399816d..f22525fdeab 100644 --- a/mozilla/layout/forms/nsICheckboxControlFrame.h +++ b/mozilla/layout/forms/nsICheckboxControlFrame.h @@ -39,7 +39,7 @@ #define nsICheckControlFrame_h___ #include "nsISupports.h" -class nsIStyleContext; +class nsStyleContext; class nsIPresContext; // IID for the nsICheckControlFrame class @@ -61,7 +61,7 @@ public: * Sets the Pseudo Style Contexts for the Check button */ NS_IMETHOD SetCheckboxFaceStyleContext( - nsIStyleContext* aCheckboxFaceStyleContext) = 0; + nsStyleContext* aCheckboxFaceStyleContext) = 0; /** * Called by content when checkbox "checked" changes diff --git a/mozilla/layout/forms/nsIRadioControlFrame.h b/mozilla/layout/forms/nsIRadioControlFrame.h index 3da9d8674e1..d5f944bf287 100644 --- a/mozilla/layout/forms/nsIRadioControlFrame.h +++ b/mozilla/layout/forms/nsIRadioControlFrame.h @@ -39,7 +39,7 @@ #define nsIRadioControlFrame_h___ #include "nsISupports.h" -class nsIStyleContext; +class nsStyleContext; // IID for the nsIRadioControlFrame class // {06450E00-24D9-11d3-966B-00105A1B1B76} @@ -61,7 +61,7 @@ public: * Sets the Pseudo Style Contexts for the Radio button */ - NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) = 0; + NS_IMETHOD SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext) = 0; /** * Called by content when the radio button's state changes diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index e9aa0d5e4a2..c8208591e4c 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -44,7 +44,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIViewManager.h" @@ -91,7 +91,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -260,7 +260,7 @@ NS_IMETHODIMP nsImageControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // call our base class diff --git a/mozilla/layout/forms/nsIsIndexFrame.h b/mozilla/layout/forms/nsIsIndexFrame.h index 4f615654b51..e595ef3123b 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.h +++ b/mozilla/layout/forms/nsIsIndexFrame.h @@ -72,7 +72,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 99363b0f6f1..2ef29851dab 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -1091,8 +1091,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, mPresContext->GetShell(getter_AddRefs(presShell)); nsresult result = presShell->GetPrimaryFrameFor(option, &optFrame); if (NS_SUCCEEDED(result) && optFrame != nsnull) { - nsCOMPtr optStyle; - optFrame->GetStyleContext(getter_AddRefs(optStyle)); + nsStyleContext* optStyle = optFrame->GetStyleContext(); if (optStyle) { const nsStyleFont* styleFont = (const nsStyleFont*)optStyle->GetStyleData(eStyleStruct_Font); nsCOMPtr deviceContext; @@ -1751,7 +1750,7 @@ NS_IMETHODIMP nsListControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; diff --git a/mozilla/layout/forms/nsListControlFrame.h b/mozilla/layout/forms/nsListControlFrame.h index f71b21e7ef0..897302b5db3 100644 --- a/mozilla/layout/forms/nsListControlFrame.h +++ b/mozilla/layout/forms/nsListControlFrame.h @@ -201,7 +201,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD DidReflow(nsIPresContext* aPresContext, diff --git a/mozilla/layout/generic/nsAreaFrame.cpp b/mozilla/layout/generic/nsAreaFrame.cpp index bab53c25640..27fd2843e28 100644 --- a/mozilla/layout/generic/nsAreaFrame.cpp +++ b/mozilla/layout/generic/nsAreaFrame.cpp @@ -36,7 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAreaFrame.h" #include "nsBlockBandData.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIViewManager.h" @@ -143,7 +143,7 @@ NS_IMETHODIMP nsAreaFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBlockFrame::Init(aPresContext, diff --git a/mozilla/layout/generic/nsAreaFrame.h b/mozilla/layout/generic/nsAreaFrame.h index 96a4abc9bc0..add72c3cd9a 100644 --- a/mozilla/layout/generic/nsAreaFrame.h +++ b/mozilla/layout/generic/nsAreaFrame.h @@ -62,7 +62,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 370d72c812e..508cd9989c8 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -53,7 +53,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIView.h" #include "nsIFontMetrics.h" #include "nsHTMLParts.h" @@ -75,6 +75,7 @@ #include "plstr.h" #include "nsGUIEvent.h" #include "nsLayoutErrors.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" @@ -198,13 +199,11 @@ DumpStyleGeneaology(nsIFrame* aFrame, const char* gap) fputs(gap, stdout); nsFrame::ListTag(stdout, aFrame); printf(": "); - nsIStyleContext* sc; - aFrame->GetStyleContext(&sc); + nsStyleContext* sc = aFrame->GetStyleContext(); while (nsnull != sc) { - nsIStyleContext* psc; + nsStyleContext* psc; printf("%p ", sc); psc = sc->GetParent(); - NS_RELEASE(sc); sc = psc; } printf("\n"); @@ -5554,7 +5553,7 @@ nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext, // first check to see if we are visible if (aCheckVis) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { *aIsVisible = PR_FALSE; return NS_OK; @@ -6308,7 +6307,7 @@ NS_IMETHODIMP nsBlockFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { if (aPrevInFlow) { @@ -6323,7 +6322,7 @@ nsBlockFrame::Init(nsIPresContext* aPresContext, return rv; } -nsIStyleContext* +already_AddRefed nsBlockFrame::GetFirstLetterStyle(nsIPresContext* aPresContext) { // This check is here because nsComboboxControlFrame creates @@ -6336,11 +6335,9 @@ nsBlockFrame::GetFirstLetterStyle(nsIPresContext* aPresContext) if (!mContent->IsContentOfType(nsIContent::eELEMENT)) return nsnull; - nsIStyleContext* fls; - aPresContext->ProbePseudoStyleContextFor(mContent, - nsCSSPseudoElements::firstLetter, - mStyleContext, &fls); - return fls; + return aPresContext->ProbePseudoStyleContextFor(mContent, + nsCSSPseudoElements::firstLetter, + mStyleContext); } NS_IMETHODIMP @@ -6360,14 +6357,13 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, // Lookup up the two pseudo style contexts if (nsnull == mPrevInFlow) { - nsIStyleContext* firstLetterStyle = GetFirstLetterStyle(aPresContext); + nsRefPtr firstLetterStyle = GetFirstLetterStyle(aPresContext); if (nsnull != firstLetterStyle) { mState |= NS_BLOCK_HAS_FIRST_LETTER_STYLE; #ifdef NOISY_FIRST_LETTER ListTag(stdout); printf(": first-letter style found\n"); #endif - NS_RELEASE(firstLetterStyle); } } @@ -6398,9 +6394,7 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, pseudoElement = nsCSSPseudoElements::mozListNumber; break; } - nsIStyleContext* kidSC; - aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, - mStyleContext, &kidSC); + nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); // Create bullet frame nsCOMPtr shell; @@ -6408,11 +6402,9 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, mBullet = new (shell.get()) nsBulletFrame; if (nsnull == mBullet) { - NS_RELEASE(kidSC); return NS_ERROR_OUT_OF_MEMORY; } mBullet->Init(aPresContext, mContent, this, kidSC, nsnull); - NS_RELEASE(kidSC); // If the list bullet frame should be positioned inside then add // it to the flow now. diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index 8ec8a718201..623cff9ad41 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/nsBlockFrame.h @@ -99,7 +99,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -210,7 +210,7 @@ protected: nsBlockFrame(); virtual ~nsBlockFrame(); - nsIStyleContext* GetFirstLetterStyle(nsIPresContext* aPresContext); + already_AddRefed GetFirstLetterStyle(nsIPresContext* aPresContext); /* * Overides member function of nsHTMLContainerFrame. Needed to handle the diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp index e35bfb713da..a1b6318e83a 100644 --- a/mozilla/layout/generic/nsBlockReflowContext.cpp +++ b/mozilla/layout/generic/nsBlockReflowContext.cpp @@ -42,7 +42,7 @@ #include "nsIFontMetrics.h" #include "nsIPresContext.h" #include "nsIContent.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsHTMLReflowCommand.h" #include "nsHTMLContainerFrame.h" #include "nsBlockFrame.h" @@ -786,8 +786,7 @@ nsStyleUnit nsBlockReflowContext::GetRealMarginLeftUnit() { nsStyleUnit unit = eStyleUnit_Inherit; - nsCOMPtr sc; - mFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = mFrame->GetStyleContext(); while (sc && eStyleUnit_Inherit == unit) { // Get parent style context sc = sc->GetParent(); @@ -807,8 +806,7 @@ nsStyleUnit nsBlockReflowContext::GetRealMarginRightUnit() { nsStyleUnit unit = eStyleUnit_Inherit; - nsCOMPtr sc; - mFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = mFrame->GetStyleContext(); while (sc && eStyleUnit_Inherit == unit) { // Get parent style context sc = sc->GetParent(); diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index 2212c45faa6..eed04aea899 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -113,7 +113,7 @@ NS_IMETHODIMP nsBulletFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/generic/nsBulletFrame.h b/mozilla/layout/generic/nsBulletFrame.h index db8e0631bc1..25cb6643fe5 100644 --- a/mozilla/layout/generic/nsBulletFrame.h +++ b/mozilla/layout/generic/nsBulletFrame.h @@ -38,7 +38,7 @@ #define nsBulletFrame_h___ #include "nsFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "imgIRequest.h" #include "imgIDecoderObserver.h" @@ -57,7 +57,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD Paint(nsIPresContext* aCX, diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 779914bd1fd..d7a65cea61c 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -39,7 +39,7 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsRect.h" #include "nsPoint.h" #include "nsGUIEvent.h" @@ -84,7 +84,7 @@ NS_IMETHODIMP nsContainerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -514,7 +514,7 @@ NonZeroStyleCoord(const nsStyleCoord& aCoord) { } static PRBool -HasNonZeroBorderRadius(nsIStyleContext* aStyleContext) { +HasNonZeroBorderRadius(nsStyleContext* aStyleContext) { const nsStyleBorder* border; ::GetStyleData(aStyleContext, &border); @@ -534,7 +534,7 @@ HasNonZeroBorderRadius(nsIStyleContext* aStyleContext) { static void SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -735,8 +735,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // detect whether it has or not. Likewise, whether the view size // has changed or not, we may need to change the transparency // state even if there is no clip. - nsCOMPtr savedStyleContext; - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + nsStyleContext* savedStyleContext = aFrame->GetStyleContext(); SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, savedStyleContext, aView, aFlags); } } @@ -744,7 +743,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, void nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -752,10 +751,8 @@ nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, return; } - nsCOMPtr savedStyleContext; if (nsnull == aStyleContext) { - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); - aStyleContext = savedStyleContext; + aStyleContext = aFrame->GetStyleContext(); } SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); @@ -764,7 +761,7 @@ nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, void nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -775,10 +772,8 @@ nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, nsCOMPtr vm; aView->GetViewManager(*getter_AddRefs(vm)); - nsCOMPtr savedStyleContext; if (nsnull == aStyleContext) { - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); - aStyleContext = savedStyleContext; + aStyleContext = aFrame->GetStyleContext(); } const nsStyleVisibility* vis; @@ -859,7 +854,7 @@ nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, PRBool nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { const nsStyleVisibility* vis; ::GetStyleData(aStyleContext, &vis); @@ -887,8 +882,7 @@ nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, return PR_TRUE; } - nsCOMPtr pseudoTag; - aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsCOMPtr pseudoTag = aStyleContext->GetPseudoType(); if (pseudoTag == nsCSSAnonBoxes::scrolledContent) { return PR_TRUE; } diff --git a/mozilla/layout/generic/nsContainerFrame.h b/mozilla/layout/generic/nsContainerFrame.h index 444d9efcd2d..8b859a1701b 100644 --- a/mozilla/layout/generic/nsContainerFrame.h +++ b/mozilla/layout/generic/nsContainerFrame.h @@ -57,7 +57,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -118,7 +118,7 @@ public: // @param aStyleContext can be null, in which case the frame's style context is used static void SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags = 0); @@ -132,13 +132,13 @@ public: // @param aStyleContext can be null, in which case the frame's style context is used static void SyncFrameViewProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags = 0); // Returns PR_TRUE if the frame requires a view static PRBool FrameNeedsView(nsIPresContext* aPresContext, - nsIFrame* aFrame, nsIStyleContext* aStyleContext); + nsIFrame* aFrame, nsStyleContext* aStyleContext); /** * Invokes the WillReflow() function, positions the frame and its view (if diff --git a/mozilla/layout/generic/nsFirstLetterFrame.cpp b/mozilla/layout/generic/nsFirstLetterFrame.cpp index 970f1acda2a..b8b5ef0f4ae 100644 --- a/mozilla/layout/generic/nsFirstLetterFrame.cpp +++ b/mozilla/layout/generic/nsFirstLetterFrame.cpp @@ -37,11 +37,12 @@ #include "nsCOMPtr.h" #include "nsHTMLContainerFrame.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" #include "nsLineLayout.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" +#include "nsAutoPtr.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -52,7 +53,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -128,23 +129,18 @@ NS_IMETHODIMP nsFirstLetterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; - nsCOMPtr newSC; + nsRefPtr newSC; if (aPrevInFlow) { // Get proper style context for ourselves. We're creating the frame // that represents everything *except* the first letter, so just create // a style context like we would for a text node. - nsCOMPtr parentStyleContext = aContext->GetParent(); + nsStyleContext* parentStyleContext = aContext->GetParent(); if (parentStyleContext) { - rv = aPresContext->ResolveStyleContextForNonElement( - parentStyleContext, - getter_AddRefs(newSC)); - if (NS_FAILED(rv)) - return rv; - + newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); if (newSC) aContext = newSC; } @@ -350,14 +346,13 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext) // are reflowed) nsIFrame* kid = mFrames.FirstChild(); if (kid) { - nsCOMPtr sc; + nsRefPtr sc; nsCOMPtr kidContent; kid->GetContent(getter_AddRefs(kidContent)); if (kidContent) { NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT), "should contain only text nodes"); - aPresContext->ResolveStyleContextForNonElement(mStyleContext, - getter_AddRefs(sc)); + sc = aPresContext->ResolveStyleContextForNonElement(mStyleContext); if (sc) { kid->SetStyleContext(aPresContext, sc); } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 65cc21badaf..5fe6b2a23cd 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -44,7 +44,7 @@ #include "nsIAtom.h" #include "nsIArena.h" #include "nsString.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsIPresContext.h" @@ -397,7 +397,7 @@ nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult) //end selection service // a handy utility to set font -void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC) +void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC) { const nsStyleFont *font = (const nsStyleFont*) aSC->GetStyleData(eStyleStruct_Font); @@ -479,7 +479,8 @@ nsFrame::~nsFrame() MOZ_COUNT_DTOR(nsFrame); NS_IF_RELEASE(mContent); - NS_IF_RELEASE(mStyleContext); + if (mStyleContext) + mStyleContext->Release(); } ///////////////////////////////////////////////////////////////////////////// @@ -525,7 +526,7 @@ NS_IMETHODIMP nsFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mContent = aContent; @@ -554,7 +555,8 @@ nsFrame::Init(nsIPresContext* aPresContext, mState |= state & (NS_FRAME_INDEPENDENT_SELECTION | NS_FRAME_GENERATED_CONTENT); } - return SetStyleContext(aPresContext, aContext); + SetStyleContext(aPresContext, aContext); + return NS_OK; } NS_IMETHODIMP nsFrame::SetInitialChildList(nsIPresContext* aPresContext, @@ -688,25 +690,18 @@ NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const { return NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { NS_PRECONDITION(aIndex >= 0, "invalid index number"); - NS_ASSERTION(aStyleContext, "null ptr"); - if (! aStyleContext) { - return NS_ERROR_NULL_POINTER; - } - *aStyleContext = nsnull; - return NS_ERROR_INVALID_ARG; + return nsnull; } -NS_IMETHODIMP +void nsFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { NS_PRECONDITION(aIndex >= 0, "invalid index number"); - return ((aIndex < 0) ? NS_ERROR_INVALID_ARG : NS_OK); } // Child frame enumeration @@ -2103,7 +2098,7 @@ nsFrame::GetFrameForPoint(nsIPresContext* aPresContext, if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) && (mRect.Contains(aPoint))) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)((nsStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); if (vis->IsVisible()) { *aFrame = this; return NS_OK; @@ -2898,7 +2893,7 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext, // first check to see if we are visible if (aCheckVis) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)((nsStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { *aIsVisible = PR_FALSE; return NS_OK; diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 69579b87143..6973021546b 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -112,7 +112,7 @@ #endif // handy utilities -extern void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC); +extern void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC); //---------------------------------------------------------------------- @@ -158,7 +158,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -183,10 +183,9 @@ public: nsIFrame* aNewFrame); NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const; - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const; NS_IMETHOD FirstChild(nsIPresContext* aPresContext, nsIAtom* aListName, diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 4e0fbb94764..29b227f1d21 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -65,7 +65,7 @@ #include "nsHTMLAtoms.h" #include "nsIScrollableView.h" #include "nsStyleCoord.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIDocumentLoader.h" #include "nsFrameSetFrame.h" @@ -94,6 +94,7 @@ #include "nsIRenderingContext.h" #include "nsIFrameFrame.h" #include "nsIPluginViewer.h" +#include "nsAutoPtr.h" // For Accessibility #ifdef ACCESSIBILITY @@ -156,7 +157,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -240,7 +241,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); void GetParentContent(nsIContent** aContent); @@ -338,7 +339,7 @@ NS_IMETHODIMP nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; @@ -412,16 +413,10 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, mFrames.SetFrames(firstChild); // Resolve the style context for the inner frame nsresult rv = NS_OK; - nsIStyleContext *innerStyleContext = nsnull; - rv = aPresContext->ResolveStyleContextFor(mContent, mStyleContext, - &innerStyleContext); - if (NS_SUCCEEDED(rv)) { - rv = firstChild->Init(aPresContext, mContent, this, innerStyleContext, nsnull); - // have to release the context: Init does its own AddRef... - NS_RELEASE(innerStyleContext); - } else { - NS_WARNING( "Error resolving style for InnerFrame in nsHTMLFrameOuterFrame"); - } + nsRefPtr innerStyleContext; + innerStyleContext = aPresContext->ResolveStyleContextFor(mContent, + mStyleContext); + rv = firstChild->Init(aPresContext, mContent, this, innerStyleContext, nsnull); if (NS_FAILED(rv)){ NS_WARNING( "Error initializing InnerFrame in nsHTMLFrameOuterFrame"); return rv; @@ -1192,7 +1187,7 @@ NS_IMETHODIMP nsHTMLFrameInnerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext, diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 013eff7993a..ca734b8be83 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -38,7 +38,7 @@ #include "nsIScrollableView.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIDocumentLoader.h" #include "nsHTMLParts.h" #include "nsILookAndFeel.h" @@ -54,6 +54,7 @@ #include "nsINameSpaceManager.h" #include "nsCSSPseudoElements.h" #include "nsCSSAnonBoxes.h" +#include "nsAutoPtr.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 @@ -317,7 +318,7 @@ NS_IMETHODIMP nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -408,11 +409,10 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsCOMPtr tag; child->GetTag(*getter_AddRefs(tag)); if (tag == nsHTMLAtoms::frameset || tag == nsHTMLAtoms::frame) { - nsCOMPtr kidSC; + nsRefPtr kidSC; nsresult result; - aPresContext->ResolveStyleContextFor(child, mStyleContext, - getter_AddRefs(kidSC)); + kidSC = aPresContext->ResolveStyleContextFor(child, mStyleContext); if (tag == nsHTMLAtoms::frameset) { result = NS_NewHTMLFramesetFrame(shell, &frame); @@ -453,10 +453,10 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, // XXX the blank frame is using the content of its parent - at some point it // should just have null content, if we support that nsHTMLFramesetBlankFrame* blankFrame = new (shell.get()) nsHTMLFramesetBlankFrame; - nsCOMPtr pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::framesetBlank, mStyleContext, - getter_AddRefs(pseudoStyleContext)); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::framesetBlank, + mStyleContext); if(blankFrame) blankFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); @@ -1080,12 +1080,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, offset.y += lastSize.height; if (firstTime) { // create horizontal border borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_FALSE, PR_FALSE); - nsIStyleContext* pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::horizontalFramesetBorder, - mStyleContext, - &pseudoStyleContext); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsCSSPseudoElements::horizontalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); - NS_RELEASE(pseudoStyleContext); mChildCount++; lastChild->SetNextSibling(borderFrame); @@ -1108,12 +1107,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_TRUE, PR_FALSE); - nsIStyleContext* pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::verticalFramesetBorder, - mStyleContext, - &pseudoStyleContext); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsCSSPseudoElements::verticalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); - NS_RELEASE(pseudoStyleContext); mChildCount++; lastChild->SetNextSibling(borderFrame); diff --git a/mozilla/layout/generic/nsFrameSetFrame.h b/mozilla/layout/generic/nsFrameSetFrame.h index 22abd4f6892..6426af8a062 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.h +++ b/mozilla/layout/generic/nsFrameSetFrame.h @@ -120,7 +120,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); static PRBool gDragInProgress; diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index ac4b86ef12e..e8b129923a4 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -470,7 +470,7 @@ NS_IMETHODIMP nsGfxScrollFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; diff --git a/mozilla/layout/generic/nsGfxScrollFrame.h b/mozilla/layout/generic/nsGfxScrollFrame.h index 00f3e2c6566..5b0a31932a4 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.h +++ b/mozilla/layout/generic/nsGfxScrollFrame.h @@ -64,7 +64,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); virtual ~nsGfxScrollFrame(); diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 80837fe114e..874e4f7bfd2 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -38,7 +38,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsLayoutAtoms.h" @@ -188,10 +188,9 @@ nsHTMLContainerFrame::GetTextDecorations(nsIPresContext* aPresContext, for (nsIFrame *frame = this; frame && decorMask; frame->GetParent(&frame)) { // find text-decorations. "Inherit" from parent *block* frames - nsCOMPtr styleContext; - frame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = frame->GetStyleContext(); const nsStyleDisplay* styleDisplay; - ::GetStyleData(styleContext.get(), &styleDisplay); + ::GetStyleData(styleContext, &styleDisplay); if (!styleDisplay->IsBlockLevel() && styleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) { // If an inline frame is discovered while walking up the tree, @@ -200,12 +199,12 @@ nsHTMLContainerFrame::GetTextDecorations(nsIPresContext* aPresContext, break; } - ::GetStyleData(styleContext.get(), &styleText); + ::GetStyleData(styleContext, &styleText); PRUint8 decors = decorMask & styleText->mTextDecoration; if (decors) { // A *new* text-decoration is found. const nsStyleColor* styleColor; - ::GetStyleData(styleContext.get(), &styleColor); + ::GetStyleData(styleContext, &styleColor); if (NS_STYLE_TEXT_DECORATION_UNDERLINE & decors) { aUnderColor = styleColor->mColor; @@ -605,7 +604,7 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aContentParentFrame, PRBool aForce) { diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.h b/mozilla/layout/generic/nsHTMLContainerFrame.h index 9286da05dc0..2b45df58bb9 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.h +++ b/mozilla/layout/generic/nsHTMLContainerFrame.h @@ -94,7 +94,7 @@ public: */ static nsresult CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aContentParentFrame, PRBool aForce); diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index b5324332a0d..549422003b5 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -41,7 +41,7 @@ #include "nsIDocument.h" #include "nsReflowPath.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsViewsCID.h" #include "nsIView.h" #include "nsIViewManager.h" @@ -95,7 +95,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); @@ -223,7 +223,7 @@ NS_IMETHODIMP CanvasFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext,aContent,aParent,aContext,aPrevInFlow); diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 3e0d92bdbad..35b5cbf03c5 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -621,8 +621,7 @@ GetNearestContainingBlock(nsIFrame* aFrame, nsMargin& aContentArea) // it's percentage based (for example) then just ignore it nsStyleBorderPadding bPad; nsMargin borderPadding; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); styleContext->GetBorderPaddingFor(bPad); if (bPad.GetBorderPadding(borderPadding)) { aContentArea.left += borderPadding.left; @@ -2317,7 +2316,7 @@ GetNormalLineHeight(nsIFontMetrics* aFontMetrics) static nscoord ComputeLineHeight(nsIPresContext* aPresContext, nsIRenderingContext* aRenderingContext, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { NS_PRECONDITION(nsnull != aRenderingContext, "no rendering context"); @@ -2377,8 +2376,7 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext, nsIFrame* aFrame) { nscoord lineHeight = -1; - nsCOMPtr sc; - aFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aFrame->GetStyleContext(); if (sc) { lineHeight = ComputeLineHeight(aPresContext, aRenderingContext, sc); } @@ -2427,8 +2425,7 @@ nsHTMLReflowState::ComputeHorizontalValue(nscoord aContainingBlockWidth, // pretend its zero... } else { - nsCOMPtr styleContext; - frame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = frame->GetStyleContext(); SetFontFromStyle(rendContext, styleContext); nscoord fontWidth; rendContext->GetWidth('M', fontWidth); diff --git a/mozilla/layout/generic/nsIAnonymousContentCreator.h b/mozilla/layout/generic/nsIAnonymousContentCreator.h index 6e563b221f2..2f0b0fa982a 100644 --- a/mozilla/layout/generic/nsIAnonymousContentCreator.h +++ b/mozilla/layout/generic/nsIAnonymousContentCreator.h @@ -46,7 +46,6 @@ class nsIPresContext; class nsISupportsArray; class nsIAtom; -class nsIStyleContext; class nsIFrame; diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index adb6fceba85..2850ae5976f 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -47,7 +47,7 @@ #include "nsISupports.h" #include "nsEvent.h" #include "nsStyleStruct.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" /** @@ -418,7 +418,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) = 0; /** @@ -553,24 +553,21 @@ public: NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end) const = 0; /** - * Get the style context associated with this frame. Note that GetStyleContext() - * adds a reference to the style context so the caller must do a release. + * Get the style context associated with this frame. * - * @see nsISupports#Release() */ - nsresult GetStyleContext(nsIStyleContext** aStyleContext) const { - *aStyleContext = mStyleContext; NS_IF_ADDREF(*aStyleContext); return NS_OK; - } - nsresult SetStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aContext) { + nsStyleContext* GetStyleContext() const { return mStyleContext; } + void SetStyleContext(nsIPresContext* aPresContext, nsStyleContext* aContext) + { if (aContext != mStyleContext) { - NS_IF_RELEASE(mStyleContext); - if (nsnull != aContext) { - mStyleContext = aContext; - NS_ADDREF(aContext); + if (mStyleContext) + mStyleContext->Release(); + mStyleContext = aContext; + if (aContext) { + aContext->AddRef(); DidSetStyleContext(aPresContext); } } - return NS_OK; } // Style post processing hook @@ -596,13 +593,6 @@ public: } #endif - // Fill a style struct with data - nsresult GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const { - NS_ASSERTION(mStyleContext, "No style context found!"); - mStyleContext->GetStyle(aSID, aStruct); - return NS_OK; - } - // Utility function: more convenient than 2 calls to GetStyleData to get border and padding NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0; @@ -616,10 +606,10 @@ public: * The indicies must be consecutive and implementations MUST return an * NS_ERROR_INVALID_ARG if asked for an index that is out of range. */ - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const = 0; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) = 0; + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const = 0; + + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext) = 0; /** * Accessor functions for geometric parent @@ -1239,7 +1229,7 @@ protected: // Members nsRect mRect; nsIContent* mContent; - nsIStyleContext* mStyleContext; + nsStyleContext* mStyleContext; nsIFrame* mParent; nsIFrame* mNextSibling; // singly-linked list of frames nsFrameState mState; @@ -1250,7 +1240,7 @@ private: }; // typesafe way to access style data. See comment in nsStyleStruct.h -// and also overloaded function in nsIStyleContext.h +// and also overloaded function in nsStyleContext.h template inline void GetStyleData(nsIFrame* aFrame, const T** aStyleStruct) diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index fb3282cd91f..280c90dc0f8 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -48,7 +48,7 @@ #include "nsIHTMLContent.h" #include "nsIDocument.h" #include "nsINodeInfo.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsImageMap.h" #include "nsILinkHandler.h" @@ -304,7 +304,7 @@ NS_IMETHODIMP nsImageFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsSplittableFrame::Init(aPresContext, aContent, aParent, @@ -1296,7 +1296,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, // inline-level or block-level, respectively. (See CSS2 9.5, which // is the rationale for paint layers.) const nsStyleDisplay *display; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*, mStyleContext), &display); + ::GetStyleData(mStyleContext, &display); nsFramePaintLayer backgroundLayer = display->IsBlockLevel() ? NS_FRAME_PAINT_LAYER_BACKGROUND : NS_FRAME_PAINT_LAYER_FOREGROUND; diff --git a/mozilla/layout/generic/nsImageFrame.h b/mozilla/layout/generic/nsImageFrame.h index 3894960a5bd..fc1093f250e 100644 --- a/mozilla/layout/generic/nsImageFrame.h +++ b/mozilla/layout/generic/nsImageFrame.h @@ -96,7 +96,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index 1d38da366f3..a9bfa4786c7 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -39,7 +39,7 @@ #include "nsBlockFrame.h" #include "nsHTMLAtoms.h" #include "nsHTMLParts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -48,6 +48,7 @@ #include "nsLayoutAtoms.h" #include "nsCSSAnonBoxes.h" #include "nsReflowPath.h" +#include "nsAutoPtr.h" #ifdef ACCESSIBILITY #include "nsIServiceManager.h" #include "nsIAccessibilityService.h" @@ -943,7 +944,7 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible) static void ReParentChildListStyle(nsIPresContext* aPresContext, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsFrameList& aFrameList) { nsIFrame* kid = aFrameList.FirstChild(); @@ -1090,26 +1091,22 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, // proper parent context. nsIFrame* parentFrame; first->GetParent(&parentFrame); - nsIStyleContext* parentContext; - parentFrame->GetStyleContext(&parentContext); + nsStyleContext* parentContext = parentFrame->GetStyleContext(); if (parentContext) { // Create a new style context that is a child of the parent // 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. - nsIStyleContext* newSC; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::mozLineFrame, parentContext, &newSC); + nsRefPtr newSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::mozLineFrame, + parentContext); if (newSC) { // Switch to the new style context. SetStyleContext(aPresContext, newSC); // Re-resolve all children ReParentChildListStyle(aPresContext, mStyleContext, mFrames); - - NS_RELEASE(newSC); } - NS_RELEASE(parentContext); } } } diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 1096a940843..c3507d52a10 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -45,7 +45,7 @@ #include "nsStyleConsts.h" #include "nsHTMLContainerFrame.h" #include "nsSpaceManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsIFontMetrics.h" #include "nsIRenderingContext.h" @@ -2097,8 +2097,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - nsCOMPtr styleContext; - spanFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = spanFrame->GetStyleContext(); nsIRenderingContext* rc = mBlockReflowState->rendContext; SetFontFromStyle(mBlockReflowState->rendContext, styleContext); nsCOMPtr fm; diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index ee1b9d74308..e92e3b22ef5 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -118,7 +118,7 @@ #include "nsIPrefService.h" // XXX For temporary paint code -#include "nsIStyleContext.h" +#include "nsStyleContext.h" // For mime types #include "nsMimeTypes.h" @@ -577,7 +577,7 @@ NS_IMETHODIMP nsObjectFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsObjectFrameSuper::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/generic/nsObjectFrame.h b/mozilla/layout/generic/nsObjectFrame.h index b931fdc351c..f924471bc6d 100644 --- a/mozilla/layout/generic/nsObjectFrame.h +++ b/mozilla/layout/generic/nsObjectFrame.h @@ -64,7 +64,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, diff --git a/mozilla/layout/generic/nsPageContentFrame.cpp b/mozilla/layout/generic/nsPageContentFrame.cpp index 8d6d490815d..202746c761e 100644 --- a/mozilla/layout/generic/nsPageContentFrame.cpp +++ b/mozilla/layout/generic/nsPageContentFrame.cpp @@ -38,7 +38,6 @@ #include "nsHTMLParts.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 07c544b42ab..817d8956eb8 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -38,7 +38,7 @@ #include "nsHTMLParts.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index 49820fca39e..83ee0f7b7a1 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -39,7 +39,6 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" #include "nsLayoutAtoms.h" nsresult diff --git a/mozilla/layout/generic/nsSplittableFrame.cpp b/mozilla/layout/generic/nsSplittableFrame.cpp index abf0864dc48..2e201b1292d 100644 --- a/mozilla/layout/generic/nsSplittableFrame.cpp +++ b/mozilla/layout/generic/nsSplittableFrame.cpp @@ -37,14 +37,14 @@ #include "nsSplittableFrame.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsISizeOfHandler.h" NS_IMETHODIMP nsSplittableFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/generic/nsSplittableFrame.h b/mozilla/layout/generic/nsSplittableFrame.h index cb402792b03..f2db6b93a61 100644 --- a/mozilla/layout/generic/nsSplittableFrame.h +++ b/mozilla/layout/generic/nsSplittableFrame.h @@ -46,7 +46,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 8552b4f678e..9864ce512d5 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -50,7 +50,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCoord.h" #include "nsIFontMetrics.h" #include "nsIRenderingContext.h" @@ -91,6 +91,7 @@ #include "nsIAccessibilityService.h" #endif #include "nsGUIEvent.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiFrames.h" @@ -536,7 +537,7 @@ public: TextStyle(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* sc) + nsStyleContext* sc) { mFont = nsnull; mText = nsnull; @@ -679,7 +680,7 @@ public: PRUnichar* aBuffer, PRInt32 aLength, PRInt32 aNumSpaces); void PaintTextDecorations(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aStyle, nscoord aX, nscoord aY, nscoord aWidth, @@ -691,12 +692,12 @@ public: void PaintTextSlowly(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord aX, nscoord aY); void RenderString(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aStyle, PRUnichar* aBuffer, PRInt32 aLength, @@ -748,13 +749,13 @@ public: void PaintUnicodeText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord dx, nscoord dy); void PaintAsciiText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord dx, nscoord dy); @@ -874,7 +875,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); @@ -901,7 +902,7 @@ NS_IMETHODIMP nsContinuingTextFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -1006,7 +1007,7 @@ public: DrawSelectionIterator(nsIContent *aContent, const SelectionDetails *aSelDetails, PRUnichar *aText, PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, PRInt16 aSelectionStatus, nsIPresContext *aPresContext, - nsIStyleContext *aStyleContext); + nsStyleContext *aStyleContext); ~DrawSelectionIterator(); PRBool First(); PRBool Next(); @@ -1051,7 +1052,7 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, nsTextFrame::TextStyle &aTextStyle, PRInt16 aSelectionStatus, nsIPresContext *aPresContext, - nsIStyleContext *aStyleContext) + nsStyleContext *aStyleContext) :mOldStyle(aTextStyle) { mDetails = aSelDetails; @@ -1065,13 +1066,13 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, mSelectionPseudoBGIsTransparent = PR_FALSE; if (aContent) { - nsIStyleContext *sc = nsnull; nsCOMPtr parentContent; aContent->GetParent(*getter_AddRefs(parentContent)); - aPresContext->ProbePseudoStyleContextFor(parentContent, - nsCSSPseudoElements::mozSelection, - aStyleContext, &sc); - if (nsnull != sc) { + nsRefPtr sc; + sc = aPresContext->ProbePseudoStyleContextFor(parentContent, + nsCSSPseudoElements::mozSelection, + aStyleContext); + if (sc) { mSelectionPseudoStyle = PR_TRUE; const nsStyleBackground* bg = (const nsStyleBackground*)sc->GetStyleData(eStyleStruct_Background); mSelectionPseudoBGIsTransparent = PRBool(bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT); @@ -1079,7 +1080,6 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, mSelectionPseudoBGcolor = bg->mBackgroundColor; const nsStyleColor* color =(const nsStyleColor*) sc->GetStyleData(eStyleStruct_Color); mSelectionPseudoFGcolor = color->mColor; - NS_RELEASE(sc); } } @@ -1510,7 +1510,7 @@ nsTextFrame::Paint(nsIPresContext* aPresContext, if ((0 != (mState & TEXT_BLINK_ON)) && nsBlinkTimer::GetBlinkIsOff()) { return NS_OK; } - nsIStyleContext* sc = mStyleContext; + nsStyleContext* sc = mStyleContext; PRBool isVisible; if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) { TextStyle ts(aPresContext, aRenderingContext, mStyleContext); @@ -1822,7 +1822,7 @@ RenderSelectionCursor(nsIRenderingContext& aRenderingContext, void nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aTextStyle, nscoord aX, nscoord aY, nscoord aWidth, @@ -1849,19 +1849,19 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE | NS_STYLE_TEXT_DECORATION_LINE_THROUGH; - nsCOMPtr context = aStyleContext; + nsStyleContext* context = aStyleContext; PRBool hasDecorations = context->HasTextDecorations(); while (hasDecorations) { const nsStyleTextReset* styleText; - ::GetStyleData(context.get(), &styleText); + ::GetStyleData(context, &styleText); if (!useOverride && (NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL & styleText->mTextDecoration)) { // This handles the La // la la case. The link underline should be green. const nsStyleColor* styleColor; - ::GetStyleData(context.get(), &styleColor); + ::GetStyleData(context, &styleColor); useOverride = PR_TRUE; overrideColor = styleColor->mColor; } @@ -1869,7 +1869,7 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, PRUint8 useDecorations = decorMask & styleText->mTextDecoration; if (useDecorations) {// a decoration defined here const nsStyleColor* styleColor; - ::GetStyleData(context.get(), &styleColor); + ::GetStyleData(context, &styleColor); if (NS_STYLE_TEXT_DECORATION_UNDERLINE & useDecorations) { underColor = useOverride ? overrideColor : styleColor->mColor; @@ -2293,7 +2293,7 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, void nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -2698,7 +2698,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, void nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aTextStyle, PRUnichar* aBuffer, PRInt32 aLength, @@ -3010,7 +3010,7 @@ nsTextFrame::ComputeExtraJustificationSpacing(nsIRenderingContext& aRenderingCon void nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -3197,7 +3197,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, void nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -6011,8 +6011,7 @@ nsTextFrame::ComputeWordFragmentDimensions(nsIPresContext* aPresContext, if((*aStop) && (wordLen == 0)) return dimensions; // 0; - nsCOMPtr sc; - aTextFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aTextFrame->GetStyleContext(); if (sc) { // Measure the piece of text. Note that we have to select the // appropriate font into the text first because the rendering diff --git a/mozilla/layout/html/base/src/nsAreaFrame.cpp b/mozilla/layout/html/base/src/nsAreaFrame.cpp index bab53c25640..27fd2843e28 100644 --- a/mozilla/layout/html/base/src/nsAreaFrame.cpp +++ b/mozilla/layout/html/base/src/nsAreaFrame.cpp @@ -36,7 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAreaFrame.h" #include "nsBlockBandData.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIViewManager.h" @@ -143,7 +143,7 @@ NS_IMETHODIMP nsAreaFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBlockFrame::Init(aPresContext, diff --git a/mozilla/layout/html/base/src/nsAreaFrame.h b/mozilla/layout/html/base/src/nsAreaFrame.h index 96a4abc9bc0..add72c3cd9a 100644 --- a/mozilla/layout/html/base/src/nsAreaFrame.h +++ b/mozilla/layout/html/base/src/nsAreaFrame.h @@ -62,7 +62,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 370d72c812e..508cd9989c8 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -53,7 +53,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIView.h" #include "nsIFontMetrics.h" #include "nsHTMLParts.h" @@ -75,6 +75,7 @@ #include "plstr.h" #include "nsGUIEvent.h" #include "nsLayoutErrors.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" @@ -198,13 +199,11 @@ DumpStyleGeneaology(nsIFrame* aFrame, const char* gap) fputs(gap, stdout); nsFrame::ListTag(stdout, aFrame); printf(": "); - nsIStyleContext* sc; - aFrame->GetStyleContext(&sc); + nsStyleContext* sc = aFrame->GetStyleContext(); while (nsnull != sc) { - nsIStyleContext* psc; + nsStyleContext* psc; printf("%p ", sc); psc = sc->GetParent(); - NS_RELEASE(sc); sc = psc; } printf("\n"); @@ -5554,7 +5553,7 @@ nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext, // first check to see if we are visible if (aCheckVis) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { *aIsVisible = PR_FALSE; return NS_OK; @@ -6308,7 +6307,7 @@ NS_IMETHODIMP nsBlockFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { if (aPrevInFlow) { @@ -6323,7 +6322,7 @@ nsBlockFrame::Init(nsIPresContext* aPresContext, return rv; } -nsIStyleContext* +already_AddRefed nsBlockFrame::GetFirstLetterStyle(nsIPresContext* aPresContext) { // This check is here because nsComboboxControlFrame creates @@ -6336,11 +6335,9 @@ nsBlockFrame::GetFirstLetterStyle(nsIPresContext* aPresContext) if (!mContent->IsContentOfType(nsIContent::eELEMENT)) return nsnull; - nsIStyleContext* fls; - aPresContext->ProbePseudoStyleContextFor(mContent, - nsCSSPseudoElements::firstLetter, - mStyleContext, &fls); - return fls; + return aPresContext->ProbePseudoStyleContextFor(mContent, + nsCSSPseudoElements::firstLetter, + mStyleContext); } NS_IMETHODIMP @@ -6360,14 +6357,13 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, // Lookup up the two pseudo style contexts if (nsnull == mPrevInFlow) { - nsIStyleContext* firstLetterStyle = GetFirstLetterStyle(aPresContext); + nsRefPtr firstLetterStyle = GetFirstLetterStyle(aPresContext); if (nsnull != firstLetterStyle) { mState |= NS_BLOCK_HAS_FIRST_LETTER_STYLE; #ifdef NOISY_FIRST_LETTER ListTag(stdout); printf(": first-letter style found\n"); #endif - NS_RELEASE(firstLetterStyle); } } @@ -6398,9 +6394,7 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, pseudoElement = nsCSSPseudoElements::mozListNumber; break; } - nsIStyleContext* kidSC; - aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, - mStyleContext, &kidSC); + nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); // Create bullet frame nsCOMPtr shell; @@ -6408,11 +6402,9 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, mBullet = new (shell.get()) nsBulletFrame; if (nsnull == mBullet) { - NS_RELEASE(kidSC); return NS_ERROR_OUT_OF_MEMORY; } mBullet->Init(aPresContext, mContent, this, kidSC, nsnull); - NS_RELEASE(kidSC); // If the list bullet frame should be positioned inside then add // it to the flow now. diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index 8ec8a718201..623cff9ad41 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.h +++ b/mozilla/layout/html/base/src/nsBlockFrame.h @@ -99,7 +99,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -210,7 +210,7 @@ protected: nsBlockFrame(); virtual ~nsBlockFrame(); - nsIStyleContext* GetFirstLetterStyle(nsIPresContext* aPresContext); + already_AddRefed GetFirstLetterStyle(nsIPresContext* aPresContext); /* * Overides member function of nsHTMLContainerFrame. Needed to handle the diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp index e35bfb713da..a1b6318e83a 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp @@ -42,7 +42,7 @@ #include "nsIFontMetrics.h" #include "nsIPresContext.h" #include "nsIContent.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsHTMLReflowCommand.h" #include "nsHTMLContainerFrame.h" #include "nsBlockFrame.h" @@ -786,8 +786,7 @@ nsStyleUnit nsBlockReflowContext::GetRealMarginLeftUnit() { nsStyleUnit unit = eStyleUnit_Inherit; - nsCOMPtr sc; - mFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = mFrame->GetStyleContext(); while (sc && eStyleUnit_Inherit == unit) { // Get parent style context sc = sc->GetParent(); @@ -807,8 +806,7 @@ nsStyleUnit nsBlockReflowContext::GetRealMarginRightUnit() { nsStyleUnit unit = eStyleUnit_Inherit; - nsCOMPtr sc; - mFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = mFrame->GetStyleContext(); while (sc && eStyleUnit_Inherit == unit) { // Get parent style context sc = sc->GetParent(); diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp index 2212c45faa6..eed04aea899 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.cpp +++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp @@ -113,7 +113,7 @@ NS_IMETHODIMP nsBulletFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/html/base/src/nsBulletFrame.h b/mozilla/layout/html/base/src/nsBulletFrame.h index db8e0631bc1..25cb6643fe5 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.h +++ b/mozilla/layout/html/base/src/nsBulletFrame.h @@ -38,7 +38,7 @@ #define nsBulletFrame_h___ #include "nsFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "imgIRequest.h" #include "imgIDecoderObserver.h" @@ -57,7 +57,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD Paint(nsIPresContext* aCX, diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 779914bd1fd..d7a65cea61c 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -39,7 +39,7 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsRect.h" #include "nsPoint.h" #include "nsGUIEvent.h" @@ -84,7 +84,7 @@ NS_IMETHODIMP nsContainerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -514,7 +514,7 @@ NonZeroStyleCoord(const nsStyleCoord& aCoord) { } static PRBool -HasNonZeroBorderRadius(nsIStyleContext* aStyleContext) { +HasNonZeroBorderRadius(nsStyleContext* aStyleContext) { const nsStyleBorder* border; ::GetStyleData(aStyleContext, &border); @@ -534,7 +534,7 @@ HasNonZeroBorderRadius(nsIStyleContext* aStyleContext) { static void SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -735,8 +735,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // detect whether it has or not. Likewise, whether the view size // has changed or not, we may need to change the transparency // state even if there is no clip. - nsCOMPtr savedStyleContext; - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + nsStyleContext* savedStyleContext = aFrame->GetStyleContext(); SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, savedStyleContext, aView, aFlags); } } @@ -744,7 +743,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, void nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -752,10 +751,8 @@ nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, return; } - nsCOMPtr savedStyleContext; if (nsnull == aStyleContext) { - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); - aStyleContext = savedStyleContext; + aStyleContext = aFrame->GetStyleContext(); } SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); @@ -764,7 +761,7 @@ nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, void nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags) { @@ -775,10 +772,8 @@ nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, nsCOMPtr vm; aView->GetViewManager(*getter_AddRefs(vm)); - nsCOMPtr savedStyleContext; if (nsnull == aStyleContext) { - aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); - aStyleContext = savedStyleContext; + aStyleContext = aFrame->GetStyleContext(); } const nsStyleVisibility* vis; @@ -859,7 +854,7 @@ nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, PRBool nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { const nsStyleVisibility* vis; ::GetStyleData(aStyleContext, &vis); @@ -887,8 +882,7 @@ nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, return PR_TRUE; } - nsCOMPtr pseudoTag; - aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsCOMPtr pseudoTag = aStyleContext->GetPseudoType(); if (pseudoTag == nsCSSAnonBoxes::scrolledContent) { return PR_TRUE; } diff --git a/mozilla/layout/html/base/src/nsContainerFrame.h b/mozilla/layout/html/base/src/nsContainerFrame.h index 444d9efcd2d..8b859a1701b 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.h +++ b/mozilla/layout/html/base/src/nsContainerFrame.h @@ -57,7 +57,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -118,7 +118,7 @@ public: // @param aStyleContext can be null, in which case the frame's style context is used static void SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags = 0); @@ -132,13 +132,13 @@ public: // @param aStyleContext can be null, in which case the frame's style context is used static void SyncFrameViewProperties(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIView* aView, PRUint32 aFlags = 0); // Returns PR_TRUE if the frame requires a view static PRBool FrameNeedsView(nsIPresContext* aPresContext, - nsIFrame* aFrame, nsIStyleContext* aStyleContext); + nsIFrame* aFrame, nsStyleContext* aStyleContext); /** * Invokes the WillReflow() function, positions the frame and its view (if diff --git a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp index 970f1acda2a..b8b5ef0f4ae 100644 --- a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp @@ -37,11 +37,12 @@ #include "nsCOMPtr.h" #include "nsHTMLContainerFrame.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" #include "nsLineLayout.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" +#include "nsAutoPtr.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -52,7 +53,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -128,23 +129,18 @@ NS_IMETHODIMP nsFirstLetterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; - nsCOMPtr newSC; + nsRefPtr newSC; if (aPrevInFlow) { // Get proper style context for ourselves. We're creating the frame // that represents everything *except* the first letter, so just create // a style context like we would for a text node. - nsCOMPtr parentStyleContext = aContext->GetParent(); + nsStyleContext* parentStyleContext = aContext->GetParent(); if (parentStyleContext) { - rv = aPresContext->ResolveStyleContextForNonElement( - parentStyleContext, - getter_AddRefs(newSC)); - if (NS_FAILED(rv)) - return rv; - + newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); if (newSC) aContext = newSC; } @@ -350,14 +346,13 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext) // are reflowed) nsIFrame* kid = mFrames.FirstChild(); if (kid) { - nsCOMPtr sc; + nsRefPtr sc; nsCOMPtr kidContent; kid->GetContent(getter_AddRefs(kidContent)); if (kidContent) { NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT), "should contain only text nodes"); - aPresContext->ResolveStyleContextForNonElement(mStyleContext, - getter_AddRefs(sc)); + sc = aPresContext->ResolveStyleContextForNonElement(mStyleContext); if (sc) { kid->SetStyleContext(aPresContext, sc); } diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 65cc21badaf..5fe6b2a23cd 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -44,7 +44,7 @@ #include "nsIAtom.h" #include "nsIArena.h" #include "nsString.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsIPresContext.h" @@ -397,7 +397,7 @@ nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult) //end selection service // a handy utility to set font -void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC) +void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC) { const nsStyleFont *font = (const nsStyleFont*) aSC->GetStyleData(eStyleStruct_Font); @@ -479,7 +479,8 @@ nsFrame::~nsFrame() MOZ_COUNT_DTOR(nsFrame); NS_IF_RELEASE(mContent); - NS_IF_RELEASE(mStyleContext); + if (mStyleContext) + mStyleContext->Release(); } ///////////////////////////////////////////////////////////////////////////// @@ -525,7 +526,7 @@ NS_IMETHODIMP nsFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mContent = aContent; @@ -554,7 +555,8 @@ nsFrame::Init(nsIPresContext* aPresContext, mState |= state & (NS_FRAME_INDEPENDENT_SELECTION | NS_FRAME_GENERATED_CONTENT); } - return SetStyleContext(aPresContext, aContext); + SetStyleContext(aPresContext, aContext); + return NS_OK; } NS_IMETHODIMP nsFrame::SetInitialChildList(nsIPresContext* aPresContext, @@ -688,25 +690,18 @@ NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const { return NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { NS_PRECONDITION(aIndex >= 0, "invalid index number"); - NS_ASSERTION(aStyleContext, "null ptr"); - if (! aStyleContext) { - return NS_ERROR_NULL_POINTER; - } - *aStyleContext = nsnull; - return NS_ERROR_INVALID_ARG; + return nsnull; } -NS_IMETHODIMP +void nsFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { NS_PRECONDITION(aIndex >= 0, "invalid index number"); - return ((aIndex < 0) ? NS_ERROR_INVALID_ARG : NS_OK); } // Child frame enumeration @@ -2103,7 +2098,7 @@ nsFrame::GetFrameForPoint(nsIPresContext* aPresContext, if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) && (mRect.Contains(aPoint))) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)((nsStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); if (vis->IsVisible()) { *aFrame = this; return NS_OK; @@ -2898,7 +2893,7 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext, // first check to see if we are visible if (aCheckVis) { const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)((nsStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { *aIsVisible = PR_FALSE; return NS_OK; diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 69579b87143..6973021546b 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -112,7 +112,7 @@ #endif // handy utilities -extern void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC); +extern void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC); //---------------------------------------------------------------------- @@ -158,7 +158,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -183,10 +183,9 @@ public: nsIFrame* aNewFrame); NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const; - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const; NS_IMETHOD FirstChild(nsIPresContext* aPresContext, nsIAtom* aListName, diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index 7975898b4f6..10a01caf312 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -34,7 +34,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIStyleSet.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleChangeList.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" @@ -77,6 +77,7 @@ #include "nsDummyLayoutRequest.h" #include "nsLayoutErrors.h" #include "nsLayoutUtils.h" +#include "nsAutoPtr.h" #ifdef DEBUG //#define NOISY_DEBUG @@ -199,7 +200,7 @@ MOZ_DECL_CTOR_COUNTER(UndisplayedNode) class UndisplayedNode { public: - UndisplayedNode(nsIContent* aContent, nsIStyleContext* aStyle) + UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle) : mContent(aContent), mStyle(aStyle), mNext(nsnull) @@ -214,7 +215,7 @@ public: } nsCOMPtr mContent; - nsCOMPtr mStyle; + nsRefPtr mStyle; UndisplayedNode* mNext; }; @@ -225,7 +226,7 @@ public: UndisplayedNode* GetFirstNode(nsIContent* aParentContent); - nsresult AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, nsIStyleContext* aStyle); + nsresult AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, nsStyleContext* aStyle); nsresult RemoveNodeFor(nsIContent* aParentContent, UndisplayedNode* aNode); nsresult RemoveNodesFor(nsIContent* aParentContent); @@ -300,8 +301,8 @@ public: NS_IMETHOD ClearPlaceholderFrameMap(); // Undisplayed content functions - NS_IMETHOD GetUndisplayedContent(nsIContent* aContent, nsIStyleContext** aStyleContext); - NS_IMETHOD SetUndisplayedContent(nsIContent* aContent, nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetUndisplayedContent(nsIContent* aContent); + virtual void SetUndisplayedContent(nsIContent* aContent, nsStyleContext* aStyleContext); NS_IMETHOD ClearUndisplayedContentIn(nsIContent* aContent, nsIContent* aParentContent); NS_IMETHOD ClearAllUndisplayedContentIn(nsIContent* aParentContent); NS_IMETHOD ClearUndisplayedContentMap(); @@ -337,7 +338,7 @@ public: NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aNewParentContext); + nsStyleContext* aNewParentContext); NS_IMETHOD ComputeStyleChangeFor(nsIPresContext* aPresContext, nsIFrame* aFrame, PRInt32 aAttrNameSpaceID, @@ -834,36 +835,32 @@ FrameManager::ClearPlaceholderFrameMap() //---------------------------------------------------------------------- -NS_IMETHODIMP -FrameManager::GetUndisplayedContent(nsIContent* aContent, nsIStyleContext** aResult) +nsStyleContext* +FrameManager::GetUndisplayedContent(nsIContent* aContent) { - NS_ENSURE_ARG_POINTER(aContent); - *aResult = nsnull; // initialize out param - - if (!mUndisplayedMap) - return NS_OK; + if (!aContent || !mUndisplayedMap) + return nsnull; nsCOMPtr parent; aContent->GetParent(*getter_AddRefs(parent)); if (!parent) - return NS_OK; + return nsnull; for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent); node; node = node->mNext) { - if (node->mContent == aContent) { - *aResult = node->mStyle; - NS_ADDREF(*aResult); - return NS_OK; - } + if (node->mContent == aContent) + return node->mStyle; } - return NS_OK; + + return nsnull; } -NS_IMETHODIMP +void FrameManager::SetUndisplayedContent(nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); + if (!mPresShell) + return; #ifdef DEBUG_UNDISPLAYED_MAP static int i = 0; @@ -874,17 +871,14 @@ FrameManager::SetUndisplayedContent(nsIContent* aContent, mUndisplayedMap = new UndisplayedMap; } if (mUndisplayedMap) { - nsresult result = NS_OK; nsIContent* parent = nsnull; aContent->GetParent(parent); NS_ASSERTION(parent, "undisplayed content must have a parent"); if (parent) { - result = mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); + mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext); NS_RELEASE(parent); } - return result; } - return NS_ERROR_OUT_OF_MEMORY; } NS_IMETHODIMP @@ -908,8 +902,7 @@ FrameManager::ClearUndisplayedContentIn(nsIContent* aContent, nsIContent* aParen #endif #ifdef DEBUG // make sure that there are no more entries for the same content - nsIStyleContext *context = nsnull; - GetUndisplayedContent(aContent, &context); + nsStyleContext *context = GetUndisplayedContent(aContent); NS_ASSERTION(context == nsnull, "Found more undisplayed content data after removal"); #endif return rv; @@ -1306,7 +1299,7 @@ FrameManager::CantRenderReplacedElement(nsIPresContext* aPresContext, #ifdef NS_DEBUG static void -DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) +DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) { if (aFrame) { fputs("frame: ", stdout); @@ -1322,14 +1315,12 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) if (aContext) { fprintf(stdout, " style: %p ", NS_STATIC_CAST(void*, aContext)); - nsIAtom* pseudoTag; - aContext->GetPseudoType(pseudoTag); + nsCOMPtr pseudoTag = aContext->GetPseudoType(); if (pseudoTag) { nsAutoString buffer; pseudoTag->ToString(buffer); fputs(NS_LossyConvertUCS2toASCII(buffer).get(), stdout); fputs(" ", stdout); - NS_RELEASE(pseudoTag); } /* XXXdwh fix debugging here. Need to add a List method to nsRuleNode @@ -1356,11 +1347,11 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext) } static void -VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2) +VerifySameTree(nsStyleContext* aContext1, nsStyleContext* aContext2) { - nsCOMPtr top1 = aContext1; - nsCOMPtr top2 = aContext2; - nsCOMPtr parent; + nsStyleContext* top1 = aContext1; + nsStyleContext* top2 = aContext2; + nsStyleContext* parent; for (;;) { parent = top1->GetParent(); if (!parent) @@ -1379,14 +1370,11 @@ VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2) static void VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aContext, nsIStyleContext* aParentContext) + nsStyleContext* aContext, nsStyleContext* aParentContext) { // get the contexts not provided if (!aContext) { - aFrame->GetStyleContext(&aContext); - } else { - // addref here so we can release at end - NS_ADDREF(aContext); + aContext = aFrame->GetStyleContext(); } if (!aParentContext) { @@ -1400,15 +1388,12 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, aFrame->GetParentStyleContextFrame(aPresContext, &providerFrame, &providerIsChild); if (providerFrame) - providerFrame->GetStyleContext(&aParentContext); + aParentContext = providerFrame->GetStyleContext(); // aParentContext could still be null - } else { - // addref the parent context so we can release it at end - NS_ADDREF(aParentContext); } NS_ASSERTION(aContext, "Failure to get required contexts"); - nsCOMPtr actualParentContext = aContext->GetParent(); + nsStyleContext* actualParentContext = aContext->GetParent(); if (aParentContext) { if (aParentContext != actualParentContext) { @@ -1434,17 +1419,12 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame, fputs("Should be null\n\n", stdout); } } - - NS_IF_RELEASE(aParentContext); - NS_IF_RELEASE(aContext); } static void -VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIStyleContext* aParentContext) +VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsStyleContext* aParentContext) { - nsIStyleContext* context; - aFrame->GetStyleContext(&context); - + nsStyleContext* context = aFrame->GetStyleContext(); VerifyContextParent(aPresContext, aFrame, context, nsnull); PRInt32 listIndex = 0; @@ -1488,18 +1468,15 @@ VerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIStyleContext* // do additional contexts PRInt32 contextIndex = -1; - while (1 == 1) { - nsIStyleContext* extraContext = nsnull; - aFrame->GetAdditionalStyleContext(++contextIndex, &extraContext); + while (1) { + nsStyleContext* extraContext = aFrame->GetAdditionalStyleContext(++contextIndex); if (extraContext) { VerifyContextParent(aPresContext, aFrame, extraContext, context); - NS_RELEASE(extraContext); } else { break; } } - NS_RELEASE(context); } NS_IMETHODIMP @@ -1507,9 +1484,8 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram { NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); if (aFrame) { - nsCOMPtr context; - aFrame->GetStyleContext(getter_AddRefs(context)); - nsCOMPtr parentContext = context->GetParent(); + nsStyleContext* context = aFrame->GetStyleContext(); + nsStyleContext* parentContext = context->GetParent(); VerifyStyleTree(aPresContext, aFrame, parentContext); } return NS_OK; @@ -1520,7 +1496,7 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram NS_IMETHODIMP FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aNewParentContext) + nsStyleContext* aNewParentContext) { NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); nsresult result = NS_ERROR_NULL_POINTER; @@ -1529,15 +1505,13 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, DebugVerifyStyleTree(aPresContext, aFrame); #endif - nsIStyleContext* oldContext = nsnull; - aFrame->GetStyleContext(&oldContext); - + nsStyleContext* oldContext = aFrame->GetStyleContext(); if (oldContext) { - nsIStyleContext* newContext = nsnull; - result = mStyleSet->ReParentStyleContext(aPresContext, - oldContext, aNewParentContext, - &newContext); - if (NS_SUCCEEDED(result) && newContext) { + nsRefPtr newContext; + result = NS_OK; + newContext = mStyleSet->ReParentStyleContext(aPresContext, oldContext, + aNewParentContext); + if (newContext) { if (newContext != oldContext) { PRInt32 listIndex = 0; nsIAtom* childList = nsnull; @@ -1561,10 +1535,8 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, result = ReParentStyleContext(aPresContext, outOfFlowFrame, newContext); // reparent placeholder's context under out of flow frame - nsIStyleContext* outOfFlowContext; - outOfFlowFrame->GetStyleContext(&outOfFlowContext); + nsStyleContext* outOfFlowContext = outOfFlowFrame->GetStyleContext(); ReParentStyleContext(aPresContext, child, outOfFlowContext); - NS_RELEASE(outOfFlowContext); } else { // regular frame result = ReParentStyleContext(aPresContext, child, newContext); @@ -1583,20 +1555,15 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, // do additional contexts PRInt32 contextIndex = -1; - while (1 == 1) { - nsIStyleContext* oldExtraContext = nsnull; - result = aFrame->GetAdditionalStyleContext(++contextIndex, &oldExtraContext); - if (NS_SUCCEEDED(result)) { - if (oldExtraContext) { - nsIStyleContext* newExtraContext = nsnull; - result = mStyleSet->ReParentStyleContext(aPresContext, - oldExtraContext, newContext, - &newExtraContext); - if (NS_SUCCEEDED(result) && newExtraContext) { - aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); - NS_RELEASE(newExtraContext); - } - NS_RELEASE(oldExtraContext); + while (1) { + nsStyleContext* oldExtraContext = aFrame->GetAdditionalStyleContext(++contextIndex); + if (oldExtraContext) { + nsRefPtr newExtraContext; + newExtraContext = mStyleSet->ReParentStyleContext(aPresContext, + oldExtraContext, + newContext); + if (newExtraContext) { + aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); } } else { @@ -1608,16 +1575,14 @@ FrameManager::ReParentStyleContext(nsIPresContext* aPresContext, VerifyStyleTree(aPresContext, aFrame, aNewParentContext); #endif } - NS_RELEASE(newContext); } - NS_RELEASE(oldContext); } } return result; } static PRBool -HasAttributeContent(nsIStyleContext* aStyleContext, +HasAttributeContent(nsStyleContext* aStyleContext, PRInt32 aNameSpaceID, nsIAtom* aAttribute) { @@ -1659,12 +1624,12 @@ HasAttributeContent(nsIStyleContext* aStyleContext, } static nsChangeHint -CaptureChange(nsIStyleContext* aOldContext, nsIStyleContext* aNewContext, +CaptureChange(nsStyleContext* aOldContext, nsStyleContext* aNewContext, nsIFrame* aFrame, nsIContent* aContent, nsStyleChangeList& aChangeList, nsChangeHint aMinChange) { nsChangeHint ourChange = NS_STYLE_HINT_NONE; - aOldContext->CalcStyleDifference(aNewContext, ourChange); + ourChange = aOldContext->CalcStyleDifference(aNewContext); if (NS_UpdateHint(aMinChange, ourChange)) { aChangeList.AppendChange(aFrame, aContent, ourChange); } @@ -1685,11 +1650,16 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // duplication. (Or should we just let |GetContext| handle that?) // Getting the hint would be nice too, but that's harder. - nsIStyleContext* oldContext = nsnull; - nsresult result = aFrame->GetStyleContext(&oldContext); - if (NS_SUCCEEDED(result) && oldContext) { - nsIAtom* pseudoTag = nsnull; - oldContext->GetPseudoType(pseudoTag); + // XXXbryner we may be able to avoid some of the refcounting goop here. + // We do need a reference to oldContext for the lifetime of this function, and it's possible + // that the frame has the last reference to it, so AddRef it here. + + nsStyleContext* oldContext = aFrame->GetStyleContext(); + nsresult result = NS_OK; + + if (oldContext) { + oldContext->AddRef(); + nsCOMPtr pseudoTag = oldContext->GetPseudoType(); nsIContent* localContent = nsnull; nsIContent* content = nsnull; result = aFrame->GetContent(&localContent); @@ -1707,7 +1677,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, } } - nsCOMPtr parentContext; + nsStyleContext* parentContext; nsIFrame* resolvedChild = nsnull; // Get the frame providing the parent style context. If it is a // child, then resolve the provider first. @@ -1717,7 +1687,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, &providerFrame, &providerIsChild); if (!providerIsChild) { if (providerFrame) - providerFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = providerFrame->GetStyleContext(); + else + parentContext = nsnull; } else { // resolve the provider here (before aFrame below) @@ -1726,19 +1698,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aMinChange, aResultChange); // The provider's new context becomes the parent context of // aFrame's context. - providerFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = providerFrame->GetStyleContext(); // Set |resolvedChild| so we don't bother resolving the // provider again. resolvedChild = providerFrame; } // do primary context - nsIStyleContext* newContext = nsnull; + nsStyleContext* newContext = nsnull; if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - aPresContext->ResolveStyleContextForNonElement(parentContext, - &newContext); + newContext = aPresContext->ResolveStyleContextForNonElement(parentContext).get(); } else if (pseudoTag) { nsIContent* pseudoContent = @@ -1746,9 +1717,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, if (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after) { // XXX what other pseudos do we need to treat like this? - aPresContext->ProbePseudoStyleContextFor(pseudoContent, pseudoTag, - parentContext, - &newContext); + newContext = aPresContext->ProbePseudoStyleContextFor(pseudoContent, + pseudoTag, + parentContext).get(); if (!newContext) { // This pseudo should no longer exist; gotta reframe NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1756,20 +1727,18 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, nsChangeHint_ReconstructFrame); // We're reframing anyway; just keep the same context newContext = oldContext; - NS_ADDREF(newContext); + newContext->AddRef(); } } else { - aPresContext->ResolvePseudoStyleContextFor(pseudoContent, pseudoTag, - parentContext, - &newContext); + newContext = aPresContext->ResolvePseudoStyleContextFor(pseudoContent, + pseudoTag, + parentContext).get(); } - NS_RELEASE(pseudoTag); } else { NS_ASSERTION(localContent, "non pseudo-element frame without content node"); - aPresContext->ResolveStyleContextFor(content, parentContext, - &newContext); + newContext = aPresContext->ResolveStyleContextFor(content, parentContext).get(); } NS_ASSERTION(newContext, "failed to get new style context"); if (newContext) { @@ -1783,9 +1752,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // we can use FindChildWithRules to keep a lot of the old // style contexts around. However, we need to start from the // same root. - NS_RELEASE(newContext); + newContext->Release(); newContext = oldContext; - NS_ADDREF(newContext); + newContext->AddRef(); } } @@ -1816,7 +1785,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); } } - NS_RELEASE(oldContext); + oldContext->Release(); } else { NS_ERROR("resolve style context failed"); @@ -1827,40 +1796,37 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // do additional contexts PRInt32 contextIndex = -1; while (1 == 1) { - nsIStyleContext* oldExtraContext = nsnull; - result = aFrame->GetAdditionalStyleContext(++contextIndex, &oldExtraContext); - if (NS_SUCCEEDED(result)) { - if (oldExtraContext) { - nsIStyleContext* newExtraContext = nsnull; - oldExtraContext->GetPseudoType(pseudoTag); - NS_ASSERTION(pseudoTag && - pseudoTag != nsCSSAnonBoxes::mozNonElement, - "extra style context is not pseudo element"); - result = aPresContext->ResolvePseudoStyleContextFor(content, pseudoTag, newContext, - &newExtraContext); - NS_RELEASE(pseudoTag); - if (NS_SUCCEEDED(result) && newExtraContext) { - if (oldExtraContext != newExtraContext) { - aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, - content, aChangeList, aMinChange); - if (!(aMinChange & (nsChangeHint_ReconstructFrame | nsChangeHint_ReconstructDoc))) { - aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); - } + nsStyleContext* oldExtraContext = nsnull; + oldExtraContext = aFrame->GetAdditionalStyleContext(++contextIndex); + if (oldExtraContext) { + nsStyleContext* newExtraContext = nsnull; + pseudoTag = oldExtraContext->GetPseudoType(); + NS_ASSERTION(pseudoTag && + pseudoTag != nsCSSAnonBoxes::mozNonElement, + "extra style context is not pseudo element"); + newExtraContext = aPresContext->ResolvePseudoStyleContextFor(content, + pseudoTag, + newContext).get(); + if (newExtraContext) { + if (oldExtraContext != newExtraContext) { + aMinChange = CaptureChange(oldExtraContext, newExtraContext, aFrame, + content, aChangeList, aMinChange); + if (!(aMinChange & (nsChangeHint_ReconstructFrame | nsChangeHint_ReconstructDoc))) { + aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext); } - else { -#if 0 - // XXXldb |oldContext| is null by this point, so this will - // never do anything. - if (pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement && - aAttribute && (aMinChange < NS_STYLE_HINT_REFLOW) && - HasAttributeContent(oldContext, aAttrNameSpaceID, aAttribute)) { - aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); - } -#endif - } - NS_RELEASE(newExtraContext); } - NS_RELEASE(oldExtraContext); + else { +#if 0 + // XXXldb |oldContext| is null by this point, so this will + // never do anything. + if (pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement && + aAttribute && (aMinChange < NS_STYLE_HINT_REFLOW) && + HasAttributeContent(oldContext, aAttrNameSpaceID, aAttribute)) { + aChangeList.AppendChange(aFrame, content, NS_STYLE_HINT_REFLOW); + } +#endif + } + newExtraContext->Release(); } } else { @@ -1873,23 +1839,22 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, for (UndisplayedNode* undisplayed = mUndisplayedMap->GetFirstNode(localContent); undisplayed; undisplayed = undisplayed->mNext) { - nsCOMPtr undisplayedContext; - undisplayed->mStyle->GetPseudoType(pseudoTag); + nsRefPtr undisplayedContext; + pseudoTag = undisplayed->mStyle->GetPseudoType(); if (pseudoTag == nsnull) { // child content - aPresContext->ResolveStyleContextFor(undisplayed->mContent, - newContext, getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolveStyleContextFor(undisplayed->mContent, + newContext).get(); } else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) { - aPresContext->ResolveStyleContextForNonElement(newContext, - getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolveStyleContextForNonElement(newContext).get(); } else { // pseudo element NS_NOTREACHED("no pseudo elements in undisplayed map"); NS_ASSERTION(pseudoTag, "pseudo element without tag"); - aPresContext->ResolvePseudoStyleContextFor(localContent, pseudoTag, - newContext, getter_AddRefs(undisplayedContext)); + undisplayedContext = aPresContext->ResolvePseudoStyleContextFor(localContent, + pseudoTag, + newContext).get(); } - NS_IF_RELEASE(pseudoTag); if (undisplayedContext) { const nsStyleDisplay* display; ::GetStyleData(undisplayedContext.get(), &display); @@ -1925,11 +1890,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, aPresContext); if (!beforeFrame) { // Look for a new :before style context - nsCOMPtr newBeforeContext; - aPresContext->ProbePseudoStyleContextFor(localContent, + nsRefPtr newBeforeContext = aPresContext->ProbePseudoStyleContextFor(localContent, nsCSSPseudoElements::before, - newContext, - getter_AddRefs(newBeforeContext)); + newContext); if (newBeforeContext) { // Have to create the new :before frame NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame); @@ -1952,11 +1915,9 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // Getting the :after frame is // more expensive than getting the pseudo context, so get the // pseudo context first. - nsCOMPtr newAfterContext; - aPresContext->ProbePseudoStyleContextFor(localContent, + nsRefPtr newAfterContext = aPresContext->ProbePseudoStyleContextFor(localContent, nsCSSPseudoElements::after, - newContext, - getter_AddRefs(newAfterContext)); + newContext); if (newAfterContext) { // Check whether we already have an :after frame nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(aFrame, @@ -2033,7 +1994,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext, // XXX need to do overflow frames??? } - NS_RELEASE(newContext); + newContext->Release(); NS_IF_RELEASE(localContent); } } @@ -2667,7 +2628,7 @@ UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode, nsIContent* aParentContent nsresult UndisplayedMap::AddNodeFor(nsIContent* aParentContent, nsIContent* aChild, - nsIStyleContext* aStyle) + nsStyleContext* aStyle) { UndisplayedNode* node = new UndisplayedNode(aChild, aStyle); if (! node) { diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index ac4b86ef12e..e8b129923a4 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -470,7 +470,7 @@ NS_IMETHODIMP nsGfxScrollFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.h b/mozilla/layout/html/base/src/nsGfxScrollFrame.h index 00f3e2c6566..5b0a31932a4 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.h +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.h @@ -64,7 +64,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); virtual ~nsGfxScrollFrame(); diff --git a/mozilla/layout/html/base/src/nsHRFrame.cpp b/mozilla/layout/html/base/src/nsHRFrame.cpp index e81abb6f08b..4aac9bd333e 100644 --- a/mozilla/layout/html/base/src/nsHRFrame.cpp +++ b/mozilla/layout/html/base/src/nsHRFrame.cpp @@ -39,10 +39,9 @@ #include "nsIHTMLContent.h" #include "nsLeafFrame.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCSSColorUtils.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" #include "nsHTMLAtoms.h" #include "nsIFontMetrics.h" #include "nsStyleConsts.h" @@ -112,7 +111,7 @@ HRuleFrame::Paint(nsIPresContext* aPresContext, } const nsStyleVisibility* vis = - (const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); + (const nsStyleVisibility*)((nsStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 80837fe114e..874e4f7bfd2 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -38,7 +38,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsLayoutAtoms.h" @@ -188,10 +188,9 @@ nsHTMLContainerFrame::GetTextDecorations(nsIPresContext* aPresContext, for (nsIFrame *frame = this; frame && decorMask; frame->GetParent(&frame)) { // find text-decorations. "Inherit" from parent *block* frames - nsCOMPtr styleContext; - frame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = frame->GetStyleContext(); const nsStyleDisplay* styleDisplay; - ::GetStyleData(styleContext.get(), &styleDisplay); + ::GetStyleData(styleContext, &styleDisplay); if (!styleDisplay->IsBlockLevel() && styleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) { // If an inline frame is discovered while walking up the tree, @@ -200,12 +199,12 @@ nsHTMLContainerFrame::GetTextDecorations(nsIPresContext* aPresContext, break; } - ::GetStyleData(styleContext.get(), &styleText); + ::GetStyleData(styleContext, &styleText); PRUint8 decors = decorMask & styleText->mTextDecoration; if (decors) { // A *new* text-decoration is found. const nsStyleColor* styleColor; - ::GetStyleData(styleContext.get(), &styleColor); + ::GetStyleData(styleContext, &styleColor); if (NS_STYLE_TEXT_DECORATION_UNDERLINE & decors) { aUnderColor = styleColor->mColor; @@ -605,7 +604,7 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aContentParentFrame, PRBool aForce) { diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h index 9286da05dc0..2b45df58bb9 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h @@ -94,7 +94,7 @@ public: */ static nsresult CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aContentParentFrame, PRBool aForce); diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index b5324332a0d..549422003b5 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -41,7 +41,7 @@ #include "nsIDocument.h" #include "nsReflowPath.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsViewsCID.h" #include "nsIView.h" #include "nsIViewManager.h" @@ -95,7 +95,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); @@ -223,7 +223,7 @@ NS_IMETHODIMP CanvasFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext,aContent,aParent,aContext,aPrevInFlow); diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index 3e0d92bdbad..35b5cbf03c5 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -621,8 +621,7 @@ GetNearestContainingBlock(nsIFrame* aFrame, nsMargin& aContentArea) // it's percentage based (for example) then just ignore it nsStyleBorderPadding bPad; nsMargin borderPadding; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); styleContext->GetBorderPaddingFor(bPad); if (bPad.GetBorderPadding(borderPadding)) { aContentArea.left += borderPadding.left; @@ -2317,7 +2316,7 @@ GetNormalLineHeight(nsIFontMetrics* aFontMetrics) static nscoord ComputeLineHeight(nsIPresContext* aPresContext, nsIRenderingContext* aRenderingContext, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { NS_PRECONDITION(nsnull != aRenderingContext, "no rendering context"); @@ -2377,8 +2376,7 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext, nsIFrame* aFrame) { nscoord lineHeight = -1; - nsCOMPtr sc; - aFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aFrame->GetStyleContext(); if (sc) { lineHeight = ComputeLineHeight(aPresContext, aRenderingContext, sc); } @@ -2427,8 +2425,7 @@ nsHTMLReflowState::ComputeHorizontalValue(nscoord aContainingBlockWidth, // pretend its zero... } else { - nsCOMPtr styleContext; - frame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = frame->GetStyleContext(); SetFontFromStyle(rendContext, styleContext); nscoord fontWidth; rendContext->GetWidth('M', fontWidth); diff --git a/mozilla/layout/html/base/src/nsIAnonymousContentCreator.h b/mozilla/layout/html/base/src/nsIAnonymousContentCreator.h index 6e563b221f2..2f0b0fa982a 100644 --- a/mozilla/layout/html/base/src/nsIAnonymousContentCreator.h +++ b/mozilla/layout/html/base/src/nsIAnonymousContentCreator.h @@ -46,7 +46,6 @@ class nsIPresContext; class nsISupportsArray; class nsIAtom; -class nsIStyleContext; class nsIFrame; diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index fb3282cd91f..280c90dc0f8 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -48,7 +48,7 @@ #include "nsIHTMLContent.h" #include "nsIDocument.h" #include "nsINodeInfo.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsImageMap.h" #include "nsILinkHandler.h" @@ -304,7 +304,7 @@ NS_IMETHODIMP nsImageFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsSplittableFrame::Init(aPresContext, aContent, aParent, @@ -1296,7 +1296,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, // inline-level or block-level, respectively. (See CSS2 9.5, which // is the rationale for paint layers.) const nsStyleDisplay *display; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*, mStyleContext), &display); + ::GetStyleData(mStyleContext, &display); nsFramePaintLayer backgroundLayer = display->IsBlockLevel() ? NS_FRAME_PAINT_LAYER_BACKGROUND : NS_FRAME_PAINT_LAYER_FOREGROUND; diff --git a/mozilla/layout/html/base/src/nsImageFrame.h b/mozilla/layout/html/base/src/nsImageFrame.h index 3894960a5bd..fc1093f250e 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.h +++ b/mozilla/layout/html/base/src/nsImageFrame.h @@ -96,7 +96,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index 1d38da366f3..a9bfa4786c7 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -39,7 +39,7 @@ #include "nsBlockFrame.h" #include "nsHTMLAtoms.h" #include "nsHTMLParts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -48,6 +48,7 @@ #include "nsLayoutAtoms.h" #include "nsCSSAnonBoxes.h" #include "nsReflowPath.h" +#include "nsAutoPtr.h" #ifdef ACCESSIBILITY #include "nsIServiceManager.h" #include "nsIAccessibilityService.h" @@ -943,7 +944,7 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible) static void ReParentChildListStyle(nsIPresContext* aPresContext, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsFrameList& aFrameList) { nsIFrame* kid = aFrameList.FirstChild(); @@ -1090,26 +1091,22 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, // proper parent context. nsIFrame* parentFrame; first->GetParent(&parentFrame); - nsIStyleContext* parentContext; - parentFrame->GetStyleContext(&parentContext); + nsStyleContext* parentContext = parentFrame->GetStyleContext(); if (parentContext) { // Create a new style context that is a child of the parent // 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. - nsIStyleContext* newSC; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::mozLineFrame, parentContext, &newSC); + nsRefPtr newSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::mozLineFrame, + parentContext); if (newSC) { // Switch to the new style context. SetStyleContext(aPresContext, newSC); // Re-resolve all children ReParentChildListStyle(aPresContext, mStyleContext, mFrames); - - NS_RELEASE(newSC); } - NS_RELEASE(parentContext); } } } diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 1096a940843..c3507d52a10 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -45,7 +45,7 @@ #include "nsStyleConsts.h" #include "nsHTMLContainerFrame.h" #include "nsSpaceManager.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsIFontMetrics.h" #include "nsIRenderingContext.h" @@ -2097,8 +2097,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - nsCOMPtr styleContext; - spanFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = spanFrame->GetStyleContext(); nsIRenderingContext* rc = mBlockReflowState->rendContext; SetFontFromStyle(mBlockReflowState->rendContext, styleContext); nsCOMPtr fm; diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index ee1b9d74308..e92e3b22ef5 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -118,7 +118,7 @@ #include "nsIPrefService.h" // XXX For temporary paint code -#include "nsIStyleContext.h" +#include "nsStyleContext.h" // For mime types #include "nsMimeTypes.h" @@ -577,7 +577,7 @@ NS_IMETHODIMP nsObjectFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsObjectFrameSuper::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.h b/mozilla/layout/html/base/src/nsObjectFrame.h index b931fdc351c..f924471bc6d 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.h +++ b/mozilla/layout/html/base/src/nsObjectFrame.h @@ -64,7 +64,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, diff --git a/mozilla/layout/html/base/src/nsPageContentFrame.cpp b/mozilla/layout/html/base/src/nsPageContentFrame.cpp index 8d6d490815d..202746c761e 100644 --- a/mozilla/layout/html/base/src/nsPageContentFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageContentFrame.cpp @@ -38,7 +38,6 @@ #include "nsHTMLParts.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 07c544b42ab..817d8956eb8 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -38,7 +38,7 @@ #include "nsHTMLParts.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index 49820fca39e..83ee0f7b7a1 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -39,7 +39,6 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" #include "nsLayoutAtoms.h" nsresult diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 175bcf7574a..360a5c61e86 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -79,6 +79,7 @@ #include "nsHTMLAtoms.h" #include "nsCSSPseudoElements.h" #include "nsCOMPtr.h" +#include "nsAutoPtr.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" #include "nsWeakReference.h" @@ -1052,8 +1053,6 @@ public: NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame) const; - NS_IMETHOD GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const; NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent, nsISupports** aResult) const; NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, @@ -4619,14 +4618,13 @@ PresShell::GetGeneratedContentIterator(nsIContent* aContent, } else { // Avoid finding the :after frame unless we need to (it's // expensive). Instead probe for the existence of the pseudo-element - nsCOMPtr styleContext; - nsCOMPtr pseudoStyleContext; + nsStyleContext *styleContext; + nsRefPtr pseudoStyleContext; - primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); - mPresContext->ProbePseudoStyleContextFor(aContent, - nsCSSPseudoElements::after, - styleContext, - getter_AddRefs(pseudoStyleContext)); + styleContext = primaryFrame->GetStyleContext(); + pseudoStyleContext = mPresContext->ProbePseudoStyleContextFor(aContent, + nsCSSPseudoElements::after, + styleContext); if (pseudoStyleContext) { nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(primaryFrame, mPresContext); @@ -5558,16 +5556,6 @@ PresShell::GetPrimaryFrameFor(nsIContent* aContent, return rv; } -NS_IMETHODIMP -PresShell::GetStyleContextFor(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) const -{ - if (!aFrame || !aStyleContext) { - return NS_ERROR_NULL_POINTER; - } - return (aFrame->GetStyleContext(aStyleContext)); -} - NS_IMETHODIMP PresShell::GetLayoutObjectFor(nsIContent* aContent, nsISupports** aResult) const diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 58e1e54c9bc..745f2795af6 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -92,7 +92,7 @@ NS_IMETHODIMP nsScrollFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, diff --git a/mozilla/layout/html/base/src/nsScrollFrame.h b/mozilla/layout/html/base/src/nsScrollFrame.h index 6949811492c..c9065a3662e 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.h +++ b/mozilla/layout/html/base/src/nsScrollFrame.h @@ -60,7 +60,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); // Called to set the one and only child frame. Returns NS_ERROR_INVALID_ARG diff --git a/mozilla/layout/html/base/src/nsSplittableFrame.cpp b/mozilla/layout/html/base/src/nsSplittableFrame.cpp index abf0864dc48..2e201b1292d 100644 --- a/mozilla/layout/html/base/src/nsSplittableFrame.cpp +++ b/mozilla/layout/html/base/src/nsSplittableFrame.cpp @@ -37,14 +37,14 @@ #include "nsSplittableFrame.h" #include "nsIContent.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsISizeOfHandler.h" NS_IMETHODIMP nsSplittableFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/base/src/nsSplittableFrame.h b/mozilla/layout/html/base/src/nsSplittableFrame.h index cb402792b03..f2db6b93a61 100644 --- a/mozilla/layout/html/base/src/nsSplittableFrame.h +++ b/mozilla/layout/html/base/src/nsSplittableFrame.h @@ -46,7 +46,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 8552b4f678e..9864ce512d5 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -50,7 +50,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCoord.h" #include "nsIFontMetrics.h" #include "nsIRenderingContext.h" @@ -91,6 +91,7 @@ #include "nsIAccessibilityService.h" #endif #include "nsGUIEvent.h" +#include "nsAutoPtr.h" #ifdef IBMBIDI #include "nsBidiFrames.h" @@ -536,7 +537,7 @@ public: TextStyle(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* sc) + nsStyleContext* sc) { mFont = nsnull; mText = nsnull; @@ -679,7 +680,7 @@ public: PRUnichar* aBuffer, PRInt32 aLength, PRInt32 aNumSpaces); void PaintTextDecorations(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aStyle, nscoord aX, nscoord aY, nscoord aWidth, @@ -691,12 +692,12 @@ public: void PaintTextSlowly(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord aX, nscoord aY); void RenderString(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aStyle, PRUnichar* aBuffer, PRInt32 aLength, @@ -748,13 +749,13 @@ public: void PaintUnicodeText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord dx, nscoord dy); void PaintAsciiText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aStyle, nscoord dx, nscoord dy); @@ -874,7 +875,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); @@ -901,7 +902,7 @@ NS_IMETHODIMP nsContinuingTextFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -1006,7 +1007,7 @@ public: DrawSelectionIterator(nsIContent *aContent, const SelectionDetails *aSelDetails, PRUnichar *aText, PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, PRInt16 aSelectionStatus, nsIPresContext *aPresContext, - nsIStyleContext *aStyleContext); + nsStyleContext *aStyleContext); ~DrawSelectionIterator(); PRBool First(); PRBool Next(); @@ -1051,7 +1052,7 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, nsTextFrame::TextStyle &aTextStyle, PRInt16 aSelectionStatus, nsIPresContext *aPresContext, - nsIStyleContext *aStyleContext) + nsStyleContext *aStyleContext) :mOldStyle(aTextStyle) { mDetails = aSelDetails; @@ -1065,13 +1066,13 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, mSelectionPseudoBGIsTransparent = PR_FALSE; if (aContent) { - nsIStyleContext *sc = nsnull; nsCOMPtr parentContent; aContent->GetParent(*getter_AddRefs(parentContent)); - aPresContext->ProbePseudoStyleContextFor(parentContent, - nsCSSPseudoElements::mozSelection, - aStyleContext, &sc); - if (nsnull != sc) { + nsRefPtr sc; + sc = aPresContext->ProbePseudoStyleContextFor(parentContent, + nsCSSPseudoElements::mozSelection, + aStyleContext); + if (sc) { mSelectionPseudoStyle = PR_TRUE; const nsStyleBackground* bg = (const nsStyleBackground*)sc->GetStyleData(eStyleStruct_Background); mSelectionPseudoBGIsTransparent = PRBool(bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT); @@ -1079,7 +1080,6 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent, mSelectionPseudoBGcolor = bg->mBackgroundColor; const nsStyleColor* color =(const nsStyleColor*) sc->GetStyleData(eStyleStruct_Color); mSelectionPseudoFGcolor = color->mColor; - NS_RELEASE(sc); } } @@ -1510,7 +1510,7 @@ nsTextFrame::Paint(nsIPresContext* aPresContext, if ((0 != (mState & TEXT_BLINK_ON)) && nsBlinkTimer::GetBlinkIsOff()) { return NS_OK; } - nsIStyleContext* sc = mStyleContext; + nsStyleContext* sc = mStyleContext; PRBool isVisible; if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) { TextStyle ts(aPresContext, aRenderingContext, mStyleContext); @@ -1822,7 +1822,7 @@ RenderSelectionCursor(nsIRenderingContext& aRenderingContext, void nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aTextStyle, nscoord aX, nscoord aY, nscoord aWidth, @@ -1849,19 +1849,19 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE | NS_STYLE_TEXT_DECORATION_LINE_THROUGH; - nsCOMPtr context = aStyleContext; + nsStyleContext* context = aStyleContext; PRBool hasDecorations = context->HasTextDecorations(); while (hasDecorations) { const nsStyleTextReset* styleText; - ::GetStyleData(context.get(), &styleText); + ::GetStyleData(context, &styleText); if (!useOverride && (NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL & styleText->mTextDecoration)) { // This handles the La // la la case. The link underline should be green. const nsStyleColor* styleColor; - ::GetStyleData(context.get(), &styleColor); + ::GetStyleData(context, &styleColor); useOverride = PR_TRUE; overrideColor = styleColor->mColor; } @@ -1869,7 +1869,7 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext, PRUint8 useDecorations = decorMask & styleText->mTextDecoration; if (useDecorations) {// a decoration defined here const nsStyleColor* styleColor; - ::GetStyleData(context.get(), &styleColor); + ::GetStyleData(context, &styleColor); if (NS_STYLE_TEXT_DECORATION_UNDERLINE & useDecorations) { underColor = useOverride ? overrideColor : styleColor->mColor; @@ -2293,7 +2293,7 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, void nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -2698,7 +2698,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, void nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, TextStyle& aTextStyle, PRUnichar* aBuffer, PRInt32 aLength, @@ -3010,7 +3010,7 @@ nsTextFrame::ComputeExtraJustificationSpacing(nsIRenderingContext& aRenderingCon void nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -3197,7 +3197,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, void nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, TextStyle& aTextStyle, nscoord dx, nscoord dy) { @@ -6011,8 +6011,7 @@ nsTextFrame::ComputeWordFragmentDimensions(nsIPresContext* aPresContext, if((*aStop) && (wordLen == 0)) return dimensions; // 0; - nsCOMPtr sc; - aTextFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aTextFrame->GetStyleContext(); if (sc) { // Measure the piece of text. Note that we have to select the // appropriate font into the text first because the rendering diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 4e0fbb94764..29b227f1d21 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -65,7 +65,7 @@ #include "nsHTMLAtoms.h" #include "nsIScrollableView.h" #include "nsStyleCoord.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIDocumentLoader.h" #include "nsFrameSetFrame.h" @@ -94,6 +94,7 @@ #include "nsIRenderingContext.h" #include "nsIFrameFrame.h" #include "nsIPluginViewer.h" +#include "nsAutoPtr.h" // For Accessibility #ifdef ACCESSIBILITY @@ -156,7 +157,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -240,7 +241,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); void GetParentContent(nsIContent** aContent); @@ -338,7 +339,7 @@ NS_IMETHODIMP nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; @@ -412,16 +413,10 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, mFrames.SetFrames(firstChild); // Resolve the style context for the inner frame nsresult rv = NS_OK; - nsIStyleContext *innerStyleContext = nsnull; - rv = aPresContext->ResolveStyleContextFor(mContent, mStyleContext, - &innerStyleContext); - if (NS_SUCCEEDED(rv)) { - rv = firstChild->Init(aPresContext, mContent, this, innerStyleContext, nsnull); - // have to release the context: Init does its own AddRef... - NS_RELEASE(innerStyleContext); - } else { - NS_WARNING( "Error resolving style for InnerFrame in nsHTMLFrameOuterFrame"); - } + nsRefPtr innerStyleContext; + innerStyleContext = aPresContext->ResolveStyleContextFor(mContent, + mStyleContext); + rv = firstChild->Init(aPresContext, mContent, this, innerStyleContext, nsnull); if (NS_FAILED(rv)){ NS_WARNING( "Error initializing InnerFrame in nsHTMLFrameOuterFrame"); return rv; @@ -1192,7 +1187,7 @@ NS_IMETHODIMP nsHTMLFrameInnerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext, diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 013eff7993a..ca734b8be83 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -38,7 +38,7 @@ #include "nsIScrollableView.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIDocumentLoader.h" #include "nsHTMLParts.h" #include "nsILookAndFeel.h" @@ -54,6 +54,7 @@ #include "nsINameSpaceManager.h" #include "nsCSSPseudoElements.h" #include "nsCSSAnonBoxes.h" +#include "nsAutoPtr.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 @@ -317,7 +318,7 @@ NS_IMETHODIMP nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -408,11 +409,10 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, nsCOMPtr tag; child->GetTag(*getter_AddRefs(tag)); if (tag == nsHTMLAtoms::frameset || tag == nsHTMLAtoms::frame) { - nsCOMPtr kidSC; + nsRefPtr kidSC; nsresult result; - aPresContext->ResolveStyleContextFor(child, mStyleContext, - getter_AddRefs(kidSC)); + kidSC = aPresContext->ResolveStyleContextFor(child, mStyleContext); if (tag == nsHTMLAtoms::frameset) { result = NS_NewHTMLFramesetFrame(shell, &frame); @@ -453,10 +453,10 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, // XXX the blank frame is using the content of its parent - at some point it // should just have null content, if we support that nsHTMLFramesetBlankFrame* blankFrame = new (shell.get()) nsHTMLFramesetBlankFrame; - nsCOMPtr pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::framesetBlank, mStyleContext, - getter_AddRefs(pseudoStyleContext)); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::framesetBlank, + mStyleContext); if(blankFrame) blankFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); @@ -1080,12 +1080,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, offset.y += lastSize.height; if (firstTime) { // create horizontal border borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_FALSE, PR_FALSE); - nsIStyleContext* pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::horizontalFramesetBorder, - mStyleContext, - &pseudoStyleContext); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsCSSPseudoElements::horizontalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); - NS_RELEASE(pseudoStyleContext); mChildCount++; lastChild->SetNextSibling(borderFrame); @@ -1108,12 +1107,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_TRUE, PR_FALSE); - nsIStyleContext* pseudoStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::verticalFramesetBorder, - mStyleContext, - &pseudoStyleContext); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsCSSPseudoElements::verticalFramesetBorder, + mStyleContext); borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull); - NS_RELEASE(pseudoStyleContext); mChildCount++; lastChild->SetNextSibling(borderFrame); diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.h b/mozilla/layout/html/document/src/nsFrameSetFrame.h index 22abd4f6892..6426af8a062 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.h +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.h @@ -120,7 +120,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); static PRBool gDragInProgress; diff --git a/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h b/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h index e74b399816d..f22525fdeab 100644 --- a/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h +++ b/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h @@ -39,7 +39,7 @@ #define nsICheckControlFrame_h___ #include "nsISupports.h" -class nsIStyleContext; +class nsStyleContext; class nsIPresContext; // IID for the nsICheckControlFrame class @@ -61,7 +61,7 @@ public: * Sets the Pseudo Style Contexts for the Check button */ NS_IMETHOD SetCheckboxFaceStyleContext( - nsIStyleContext* aCheckboxFaceStyleContext) = 0; + nsStyleContext* aCheckboxFaceStyleContext) = 0; /** * Called by content when checkbox "checked" changes diff --git a/mozilla/layout/html/forms/public/nsIRadioControlFrame.h b/mozilla/layout/html/forms/public/nsIRadioControlFrame.h index 3da9d8674e1..d5f944bf287 100644 --- a/mozilla/layout/html/forms/public/nsIRadioControlFrame.h +++ b/mozilla/layout/html/forms/public/nsIRadioControlFrame.h @@ -39,7 +39,7 @@ #define nsIRadioControlFrame_h___ #include "nsISupports.h" -class nsIStyleContext; +class nsStyleContext; // IID for the nsIRadioControlFrame class // {06450E00-24D9-11d3-966B-00105A1B1B76} @@ -61,7 +61,7 @@ public: * Sets the Pseudo Style Contexts for the Radio button */ - NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) = 0; + NS_IMETHOD SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext) = 0; /** * Called by content when the radio button's state changes diff --git a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp index ac98d993321..51c05b6890a 100644 --- a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp +++ b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp @@ -145,7 +145,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext, GetButtonOuterFocusRect(aRect, rect); const nsStyleBorder* border; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*,mOuterFocusStyle), &border); + ::GetStyleData(mOuterFocusStyle, &border); nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame, aDirtyRect, rect, *border, mOuterFocusStyle, 0); } @@ -156,7 +156,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext, GetButtonInnerFocusRect(aRect, rect); const nsStyleBorder* border; - ::GetStyleData(NS_STATIC_CAST(nsIStyleContext*,mInnerFocusStyle), &border); + ::GetStyleData(mInnerFocusStyle, &border); nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame, aDirtyRect, rect, *border, mInnerFocusStyle, 0); } @@ -174,8 +174,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext, nsRect buttonRect; GetButtonRect(aRect, buttonRect); - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); const nsStyleBorder* border = (const nsStyleBorder*)context->GetStyleData(eStyleStruct_Border); @@ -247,8 +246,7 @@ nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding() nsMargin nsButtonFrameRenderer::GetButtonBorderAndPadding() { - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); nsMargin innerFocusBorderAndPadding(0,0,0,0); nsStyleBorderPadding bPad; @@ -324,52 +322,38 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext) // get all the styles nsCOMPtr content; mFrame->GetContent(getter_AddRefs(content)); - nsCOMPtr context; - mFrame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = mFrame->GetStyleContext(); // style for the inner such as a dotted line (Windows) - aPresContext->ProbePseudoStyleContextFor(content, nsCSSPseudoElements::mozFocusInner, context, - getter_AddRefs(mInnerFocusStyle)); + mInnerFocusStyle = aPresContext->ProbePseudoStyleContextFor(content, + nsCSSPseudoElements::mozFocusInner, + context); // style for outer focus like a ridged border (MAC). - aPresContext->ProbePseudoStyleContextFor(content, nsCSSPseudoElements::mozFocusOuter, context, - getter_AddRefs(mOuterFocusStyle)); + mOuterFocusStyle = aPresContext->ProbePseudoStyleContextFor(content, + nsCSSPseudoElements::mozFocusOuter, + context); } -nsresult -nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const +nsStyleContext* +nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { - case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: - *aStyleContext = mInnerFocusStyle; - NS_IF_ADDREF(*aStyleContext); - break; + return mInnerFocusStyle; case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: - *aStyleContext = mOuterFocusStyle; - NS_IF_ADDREF(*aStyleContext); - break; + return mOuterFocusStyle; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -nsresult -nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext) +void +nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { - case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: mInnerFocusStyle = aStyleContext; break; @@ -377,5 +361,4 @@ nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleCo mOuterFocusStyle = aStyleContext; break; } - return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h index a5878958bfc..3e605c0139b 100644 --- a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h +++ b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h @@ -44,7 +44,7 @@ #define nsButtonFrameRenderer_h___ #include "nsCoord.h" -#include "nsCOMPtr.h" +#include "nsAutoPtr.h" #include "nsFrame.h" class nsStyleChangeList; @@ -98,8 +98,8 @@ public: virtual nsMargin GetFullButtonBorderAndPadding(); virtual nsMargin GetAddedButtonBorderAndPadding(); - virtual nsresult GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const; - virtual nsresult SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetStyleContext(PRInt32 aIndex) const; + virtual void SetStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext); virtual void ReResolveStyles(nsIPresContext* aPresContext); virtual void Redraw(nsIPresContext* aPresContext); @@ -111,9 +111,9 @@ protected: private: // cached styles for focus and outline. - nsCOMPtr mBorderStyle; - nsCOMPtr mInnerFocusStyle; - nsCOMPtr mOuterFocusStyle; + nsRefPtr mBorderStyle; + nsRefPtr mInnerFocusStyle; + nsRefPtr mOuterFocusStyle; nsFrame* mFrame; diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index b6802dc3e2d..0d8d6683bca 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -83,6 +83,7 @@ #include "nsIServiceManager.h" #include "nsIDOMNode.h" #include "nsGUIEvent.h" +#include "nsAutoPtr.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -376,7 +377,7 @@ NS_IMETHODIMP nsComboboxControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // Need to hold on the pres context because it is used later in methods @@ -2161,23 +2162,18 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous frame - nsCOMPtr styleContext; - rv = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) { return rv; } + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // create a text frame and put it inside the block frame rv = NS_NewTextFrame(shell, &mTextFrame); if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); @@ -2301,23 +2297,18 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } // create the style context for the anonymous block frame - nsCOMPtr styleContext; - rv = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) { return rv; } + mStyleContext); if (!styleContext) { return NS_ERROR_NULL_POINTER; } // Create a text frame and put it inside the block frame rv = NS_NewTextFrame(shell, &mTextFrame); if (NS_FAILED(rv)) { return rv; } if (!mTextFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } // initialize the text frame diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h index 1773ffa8aee..6057ab3eb6f 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h @@ -110,7 +110,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aCX, diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp index 4ae7e35ea0e..5ab147cc0ff 100644 --- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp @@ -54,7 +54,6 @@ #include "nsHTMLParts.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" -#include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsFont.h" #include "nsCOMPtr.h" diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.h b/mozilla/layout/html/forms/src/nsFileControlFrame.h index eb8f55817e1..f94f10e7c5d 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.h +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.h @@ -65,7 +65,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index e3de8dc461b..0438964bb6a 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -41,7 +41,6 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIView.h" diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.h b/mozilla/layout/html/forms/src/nsFormControlFrame.h index 665f49030d3..d82d058d0f7 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.h +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.h @@ -44,7 +44,6 @@ #include "nsIWidget.h" #include "nsLeafFrame.h" #include "nsCoord.h" -#include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsCOMPtr.h" diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index a81911af453..d299b496419 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -41,7 +41,7 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIView.h" @@ -250,7 +250,7 @@ nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFra nsresult nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame, nsIPresContext* aPresContext, - nsIStyleContext * aStyleContext, + nsStyleContext * aStyleContext, const nsFont*& aFont) { const nsStyleFont* styleFont = (const nsStyleFont*)aStyleContext->GetStyleData(eStyleStruct_Font); diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.h b/mozilla/layout/html/forms/src/nsFormControlHelper.h index 9b97d801213..e7f160cd15c 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.h +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.h @@ -50,7 +50,7 @@ class nsIView; class nsIPresContext; class nsStyleCoord; class nsIPresState; -class nsIStyleContext; +class nsStyleContext; #define CSS_NOTSET -1 #define ATTR_NOTSET -1 @@ -96,7 +96,7 @@ public: // XXX This could be removed now that we no longer have form quirks. static nsresult GetFont(nsIFormControlFrame * aFormFrame, nsIPresContext* aPresContext, - nsIStyleContext * aStyleContext, + nsStyleContext * aStyleContext, const nsFont*& aFont); // returns the an addref'ed FontMetrics for the default font for the frame @@ -330,9 +330,9 @@ public: const nsRect& aDirtyRect, const nsRect& aRect, PRBool aShift, PRBool aShowFocus, PRBool aDisabled, PRBool aDrawOutline, - nsIStyleContext* aOutlineStyle, - nsIStyleContext* aFocusStyle, - nsIStyleContext* aStyleContext, nsString& aLabel, + nsStyleContext* aOutlineStyle, + nsStyleContext* aFocusStyle, + nsStyleContext* aStyleContext, nsString& aLabel, nsIFrame* aForFrame); static void StyleChangeReflow(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp index 865694d659d..c321e1d2127 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -50,6 +50,7 @@ #include "nsIDOMNode.h" #include "nsLayoutAtoms.h" #include "nsReflowPath.h" +#include "nsAutoPtr.h" // MouseEvent suppression in PP #include "nsGUIEvent.h" @@ -253,17 +254,13 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * parentFrame = mFrames.FirstChild(); - nsCOMPtr styleContext; - parentFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = parentFrame->GetStyleContext(); rv = NS_NewTextFrame(shell, &newFrame); if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr textStyleContext; - rv = aPresContext->ResolveStyleContextForNonElement( - styleContext, - getter_AddRefs(textStyleContext)); - if (NS_FAILED(rv)) { return rv; } + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(styleContext); if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } if (styleContext) { diff --git a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp index 20d49fe67a8..1388f22b18a 100644 --- a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp @@ -82,7 +82,8 @@ nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame() nsGfxCheckboxControlFrame::~nsGfxCheckboxControlFrame() { - NS_IF_RELEASE(mCheckButtonFaceStyle); + if (mCheckButtonFaceStyle) + mCheckButtonFaceStyle->Release(); } @@ -120,53 +121,43 @@ NS_IMETHODIMP nsGfxCheckboxControlFrame::GetAccessible(nsIAccessible** aAccessib //-------------------------------------------------------------- NS_IMETHODIMP -nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext) +nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsStyleContext *aCheckboxFaceStyleContext) { mCheckButtonFaceStyle = aCheckboxFaceStyleContext; - NS_ADDREF(mCheckButtonFaceStyle); + mCheckButtonFaceStyle->AddRef(); return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP -nsGfxCheckboxControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsGfxCheckboxControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_GFX_CHECKBOX_CONTROL_FRAME_FACE_CONTEXT_INDEX: - *aStyleContext = mCheckButtonFaceStyle; - NS_IF_ADDREF(*aStyleContext); + return mCheckButtonFaceStyle; break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP +void nsGfxCheckboxControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_GFX_CHECKBOX_CONTROL_FRAME_FACE_CONTEXT_INDEX: - NS_IF_RELEASE(mCheckButtonFaceStyle); + if (mCheckButtonFaceStyle) + mCheckButtonFaceStyle->Release(); mCheckButtonFaceStyle = aStyleContext; - NS_IF_ADDREF(aStyleContext); + if (aStyleContext) + aStyleContext->AddRef(); break; } - return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h index 80e8bd7a67e..cdca5edde99 100644 --- a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h @@ -77,13 +77,12 @@ public: //nsICheckboxControlFrame methods - NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext); + NS_IMETHOD SetCheckboxFaceStyleContext(nsStyleContext *aCheckboxFaceStyleContext); NS_IMETHOD OnChecked(nsIPresContext* aPresContext, PRBool aChecked); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); // nsIFormControlFrame NS_IMETHOD OnContentReset(); @@ -110,7 +109,7 @@ protected: //GFX-rendered state variables PRBool mInClickEvent; - nsIStyleContext* mCheckButtonFaceStyle; + nsStyleContext* mCheckButtonFaceStyle; private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp index bb479832eef..8bf0401f39a 100644 --- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp @@ -77,7 +77,8 @@ nsGfxRadioControlFrame::nsGfxRadioControlFrame() nsGfxRadioControlFrame::~nsGfxRadioControlFrame() { - NS_IF_RELEASE(mRadioButtonFaceStyle); + if (mRadioButtonFaceStyle) + mRadioButtonFaceStyle->Release(); } // Frames are not refcounted, no need to AddRef @@ -110,50 +111,40 @@ NS_IMETHODIMP nsGfxRadioControlFrame::GetAccessible(nsIAccessible** aAccessible) #endif //-------------------------------------------------------------- -NS_IMETHODIMP -nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: - *aStyleContext = mRadioButtonFaceStyle; - NS_IF_ADDREF(*aStyleContext); + return mRadioButtonFaceStyle; break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } //-------------------------------------------------------------- -NS_IMETHODIMP +void nsGfxRadioControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: - NS_IF_RELEASE(mRadioButtonFaceStyle); + if (mRadioButtonFaceStyle) + mRadioButtonFaceStyle->Release(); mRadioButtonFaceStyle = aStyleContext; - NS_IF_ADDREF(aStyleContext); + if (aStyleContext) + aStyleContext->AddRef(); break; } - return NS_OK; } //-------------------------------------------------------------- NS_IMETHODIMP -nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) +nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext) { mRadioButtonFaceStyle = aRadioButtonFaceStyleContext; - NS_ADDREF(mRadioButtonFaceStyle); + mRadioButtonFaceStyle->AddRef(); return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h index b04f5debf6d..1d9a40b0dc8 100644 --- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h @@ -62,16 +62,15 @@ public: //nsIRadioControlFrame methods NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext); + NS_IMETHOD SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext); #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); #endif NS_IMETHOD OnChecked(nsIPresContext* aPresContext, PRBool aChecked); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, @@ -106,7 +105,7 @@ public: protected: //GFX-rendered state variables - nsIStyleContext* mRadioButtonFaceStyle; + nsStyleContext* mRadioButtonFaceStyle; private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index d90f1f9a49f..ad4771d04d9 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -47,7 +47,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsISupports.h" @@ -123,7 +123,7 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -145,13 +145,11 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame - nsIStyleContext* styleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSAnonBoxes::buttonContent, - mStyleContext, - &styleContext); + mStyleContext); mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull); - NS_RELEASE(styleContext); return rv; } @@ -333,14 +331,14 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext* aPresContext, // nsCOMPtr shell; nsCOMPtr frameManager; - nsCOMPtr newParentContext; + nsStyleContext* newParentContext; aPresContext->GetShell(getter_AddRefs(shell)); if (shell) { shell->GetFrameManager(getter_AddRefs(frameManager)); } // get the new parent context from the first child: that is the frame that the // subsequent children will be made children of - mFrames.FirstChild()->GetStyleContext(getter_AddRefs(newParentContext)); + newParentContext = mFrames.FirstChild()->GetStyleContext(); // Set the parent for each of the child frames for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) { @@ -691,18 +689,17 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsAString& a return NS_OK; } -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - return mRenderer.GetStyleContext(aIndex, aStyleContext); + return mRenderer.GetStyleContext(aIndex); } -NS_IMETHODIMP +void nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - return mRenderer.SetStyleContext(aIndex, aStyleContext); + mRenderer.SetStyleContext(aIndex, aStyleContext); } diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h index 95a5f7c3c8a..037bee97364 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h @@ -48,7 +48,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsISupports.h" @@ -102,13 +102,12 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); - NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; - NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); + virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const; + virtual void SetAdditionalStyleContext(PRInt32 aIndex, + nsStyleContext* aStyleContext); NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, nsIPresShell& aPresShell, diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index e9aa0d5e4a2..c8208591e4c 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -44,7 +44,7 @@ #include "nsIRenderingContext.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsIViewManager.h" @@ -91,7 +91,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -260,7 +260,7 @@ NS_IMETHODIMP nsImageControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // call our base class diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.h b/mozilla/layout/html/forms/src/nsIsIndexFrame.h index 4f615654b51..e595ef3123b 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.h +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.h @@ -72,7 +72,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 99363b0f6f1..2ef29851dab 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -1091,8 +1091,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, mPresContext->GetShell(getter_AddRefs(presShell)); nsresult result = presShell->GetPrimaryFrameFor(option, &optFrame); if (NS_SUCCEEDED(result) && optFrame != nsnull) { - nsCOMPtr optStyle; - optFrame->GetStyleContext(getter_AddRefs(optStyle)); + nsStyleContext* optStyle = optFrame->GetStyleContext(); if (optStyle) { const nsStyleFont* styleFont = (const nsStyleFont*)optStyle->GetStyleData(eStyleStruct_Font); nsCOMPtr deviceContext; @@ -1751,7 +1750,7 @@ NS_IMETHODIMP nsListControlFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.h b/mozilla/layout/html/forms/src/nsListControlFrame.h index f71b21e7ef0..897302b5db3 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.h +++ b/mozilla/layout/html/forms/src/nsListControlFrame.h @@ -201,7 +201,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD DidReflow(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index dbf07098ab9..e50f0b19b51 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -114,6 +114,7 @@ #include "nsCSSRendering.h" #include "nsISelectElement.h" #include "nsLayoutErrors.h" +#include "nsAutoPtr.h" static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -1024,7 +1025,7 @@ AdjustOutOfFlowFrameParentPtrs(nsIPresContext* aPresContext, */ static void MoveChildrenTo(nsIPresContext* aPresContext, - nsIStyleContext* aNewParentSC, + nsStyleContext* aNewParentSC, nsIFrame* aNewParent, nsIFrame* aFrameList, nsFrameConstructorState* aState) @@ -1376,7 +1377,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nsIDocument* aDocument, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsStyleContent* aStyleContent, PRUint32 aContentIndex, nsIFrame** aFrame) @@ -1568,7 +1569,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIFrame* aFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement, nsIFrame** aWrapperFrame, nsIFrame** aResult) @@ -1579,9 +1580,10 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe return PR_FALSE; // Probe for the existence of the pseudo-element - nsCOMPtr pseudoStyleContext; - aPresContext->ProbePseudoStyleContextFor(aContent, aPseudoElement, aStyleContext, - getter_AddRefs(pseudoStyleContext)); + nsRefPtr pseudoStyleContext; + pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, + aPseudoElement, + aStyleContext); if (pseudoStyleContext) { const nsStyleDisplay* display; @@ -1609,10 +1611,11 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe NS_NewInlineFrame(aPresShell, aWrapperFrame); wrapperPseudo = nsCSSAnonBoxes::mozGCWrapperInline; } - nsCOMPtr parentSC = aStyleContext->GetParent(); - nsCOMPtr wrapperSC; - aPresContext->ResolvePseudoStyleContextFor(nsnull, wrapperPseudo, - parentSC, getter_AddRefs(wrapperSC)); + nsStyleContext* parentSC = aStyleContext->GetParent(); + nsRefPtr wrapperSC; + wrapperSC = aPresContext->ResolvePseudoStyleContextFor(nsnull, + wrapperPseudo, + parentSC); // |aFrame| is already the correct parent. InitAndRestoreFrame(aPresContext, aState, aContent, aFrame, wrapperSC, nsnull, *aWrapperFrame); @@ -1643,9 +1646,8 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe // Create another pseudo style context to use for all the generated child // frames - nsIStyleContext* textStyleContext; - aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext, - &textStyleContext); + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(pseudoStyleContext); // Now create content objects (and child frames) for each value of the // 'content' property @@ -1665,7 +1667,6 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe } } - NS_RELEASE(textStyleContext); if (childFrames.childList) { containerFrame->SetInitialChildList(aPresContext, nsnull, childFrames.childList); } @@ -1683,7 +1684,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell, nsIPresContext *aPresContext, nsIContent *aContent, nsIFrame *&aFrame, - nsIStyleContext *aStyleContext) + nsStyleContext *aStyleContext) { nsCOMPtr control = do_QueryInterface(aContent); NS_ASSERTION(control, "input is not an nsIFormControl!"); @@ -1991,18 +1992,17 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel ? aState.mPseudoFrames.mCellInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); // create the SC for the inner table which will be the parent of the outer table's SC - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::table, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::table, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mTableOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mTableInner; @@ -2011,7 +2011,7 @@ nsCSSFrameConstructor::CreatePseudoTableFrame(nsIPresShell* aPresShel PRBool pseudoParent; nsFrameItems items; rv = ConstructTableFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudoOuter.mFrame, pseudoInner.mFrame, pseudoParent); @@ -2042,17 +2042,16 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS ? aState.mPseudoFrames.mTableInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRowGroup, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableRowGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRowGroup; @@ -2060,7 +2059,7 @@ nsCSSFrameConstructor::CreatePseudoRowGroupFrame(nsIPresShell* aPresS PRBool pseudoParent; nsFrameItems items; rv = ConstructTableRowGroupFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2088,17 +2087,16 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS ? aState.mPseudoFrames.mTableInner.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableColGroup, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableColGroup, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mColGroup; @@ -2106,7 +2104,7 @@ nsCSSFrameConstructor::CreatePseudoColGroupFrame(nsIPresShell* aPresS PRBool pseudoParent; nsFrameItems items; rv = ConstructTableColGroupFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; ((nsTableColGroupFrame*)pseudo.mFrame)->SetType(eColGroupAnonymousCol); @@ -2132,17 +2130,16 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, ? aState.mPseudoFrames.mRowGroup.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableRow, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableRow, + parentStyle); nsPseudoFrameData& pseudo = aState.mPseudoFrames.mRow; @@ -2150,7 +2147,7 @@ nsCSSFrameConstructor::CreatePseudoRowFrame(nsIPresShell* aPresShell, PRBool pseudoParent; nsFrameItems items; rv = ConstructTableRowFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudo.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2177,17 +2174,16 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell ? aState.mPseudoFrames.mRow.mFrame : aParentFrameIn; if (!parentFrame) return rv; - nsCOMPtr parentStyle; nsCOMPtr parentContent; - nsCOMPtr childStyle; + nsStyleContext *parentStyle; + nsRefPtr childStyle; - parentFrame->GetStyleContext(getter_AddRefs(parentStyle)); + parentStyle = parentFrame->GetStyleContext(); parentFrame->GetContent(getter_AddRefs(parentContent)); - aPresContext->ResolvePseudoStyleContextFor(parentContent, - nsCSSAnonBoxes::tableCell, - parentStyle, - getter_AddRefs(childStyle)); + childStyle = aPresContext->ResolvePseudoStyleContextFor(parentContent, + nsCSSAnonBoxes::tableCell, + parentStyle); nsPseudoFrameData& pseudoOuter = aState.mPseudoFrames.mCellOuter; nsPseudoFrameData& pseudoInner = aState.mPseudoFrames.mCellInner; @@ -2196,7 +2192,7 @@ nsCSSFrameConstructor::CreatePseudoCellFrame(nsIPresShell* aPresShell PRBool pseudoParent; nsFrameItems items; rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, parentContent, - parentFrame, childStyle.get(), aTableCreator, + parentFrame, childStyle, aTableCreator, PR_TRUE, items, pseudoOuter.mFrame, pseudoInner.mFrame, pseudoParent); if (NS_FAILED(rv)) return rv; @@ -2528,7 +2524,7 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2557,11 +2553,10 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresShell* aPresShell, } // create the pseudo SC for the outer table as a child of the inner SC - nsCOMPtr outerStyleContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::tableOuter, - aStyleContext, - getter_AddRefs(outerStyleContext)); + nsRefPtr outerStyleContext; + outerStyleContext = aPresContext->ResolvePseudoStyleContextFor(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 @@ -2610,7 +2605,7 @@ nsCSSFrameConstructor::ConstructTableCaptionFrame(nsIPresShell* aPres nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -2656,7 +2651,7 @@ nsCSSFrameConstructor::ConstructTableRowGroupFrame(nsIPresShell* aPre nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2731,7 +2726,7 @@ nsCSSFrameConstructor::ConstructTableColGroupFrame(nsIPresShell* aPre nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2781,7 +2776,7 @@ nsCSSFrameConstructor::ConstructTableRowFrame(nsIPresShell* aPresShel nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2836,7 +2831,7 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2860,8 +2855,7 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel rv = aTableCreator.CreateTableColFrame(&aNewFrame); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context - nsCOMPtr parentStyleContext; - parentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = parentFrame->GetStyleContext(); if (aIsPseudoParent) { aPresContext->ReParentStyleContext(aNewFrame, parentStyleContext); } @@ -2872,11 +2866,11 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel if (cgContent) { cgContent->GetSpan(&span); nsIFrame* lastCol = aNewFrame; - nsCOMPtr styleContext; + nsStyleContext* styleContext; for (PRInt32 spanX = 1; spanX < span; spanX++) { // The same content node should always resolve to the same style context. if (1 == spanX) - aNewFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aNewFrame->GetStyleContext(); nsIFrame* newCol; rv = aTableCreator.CreateTableColFrame(&newCol); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, @@ -2908,7 +2902,7 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -2953,11 +2947,10 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresShell* aPresShe } // Resolve pseudo style and initialize the body cell frame - nsCOMPtr innerPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::cellContent, - aStyleContext, - getter_AddRefs(innerPseudoStyle)); + nsRefPtr innerPseudoStyle; + innerPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::cellContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aNewCellOuterFrame, innerPseudoStyle, nsnull, aNewCellInnerFrame); @@ -2998,7 +2991,7 @@ nsCSSFrameConstructor::MustGeneratePseudoParent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIAtom* aTag, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { if (!aStyleContext) return PR_FALSE; @@ -3029,7 +3022,7 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsIPresShell* aPres nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -3116,8 +3109,7 @@ nsCSSFrameConstructor::TableProcessChildren(nsIPresShell* aPresShell, nsCOMPtr parentFrameType; aParentFrame->GetFrameType(getter_AddRefs(parentFrameType)); - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); ChildIterator iter, last; for (ChildIterator::Init(aContent, &iter, &last); @@ -3153,7 +3145,7 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresShell* aPresShell, nsIContent* aParentContent, nsIFrame* aParentFrame, nsIAtom* aParentFrameType, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aCaption) @@ -3164,11 +3156,11 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresShell* aPresShell, PRBool isPseudoParent = PR_FALSE; nsIFrame* childFrame = nsnull; - nsCOMPtr childStyleContext; + nsRefPtr childStyleContext; // Resolve the style context and get its display - ResolveStyleContext(aPresContext, aParentFrame, aChildContent, - getter_AddRefs(childStyleContext)); + childStyleContext = ResolveStyleContext(aPresContext, aParentFrame, + aChildContent); const nsStyleDisplay* styleDisplay = (const nsStyleDisplay*) childStyleContext->GetStyleData(eStyleStruct_Display); @@ -3294,8 +3286,7 @@ nsCSSFrameConstructor:: GetDisplay(nsIFrame* aFrame) if (nsnull == aFrame) { return nsnull; } - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); const nsStyleDisplay* display = (const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display); return display; @@ -3334,7 +3325,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aDocElement, nsIFrame* aParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame*& aNewFrame) { // how the root frame hierarchy should look @@ -3405,9 +3396,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } // --------- CREATE AREA OR BOX FRAME ------- - nsCOMPtr styleContext; - aPresContext->ResolveStyleContextFor(aDocElement, aParentStyleContext, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolveStyleContextFor(aDocElement, + aParentStyleContext); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -3432,10 +3423,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } if (resolveStyle) { - rv = ResolveStyleContext(aPresContext, aParentFrame, aDocElement, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) - return rv; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, + aDocElement); } } @@ -3454,19 +3443,18 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, // build a scrollframe if ((!isPaginated || (isPaginated && printPreviewContext)) && isScrollable) { nsIFrame* newScrollFrame = nsnull; - nsCOMPtr newContext; + nsRefPtr newContext; - BeginBuildingScrollFrame( aPresShell, aPresContext, - aState, - aDocElement, - styleContext, - aParentFrame, - nsCSSAnonBoxes::scrolledContent, - mDocument, - PR_FALSE, - scrollFrame, - newContext, - newScrollFrame); + newContext = BeginBuildingScrollFrame( aPresShell, aPresContext, + aState, + aDocElement, + styleContext, + aParentFrame, + nsCSSAnonBoxes::scrolledContent, + mDocument, + PR_FALSE, + scrollFrame, + newScrollFrame); styleContext = newContext; aParentFrame = newScrollFrame; @@ -3484,7 +3472,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, if (NS_FAILED(rv)) { return rv; } - contentFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = contentFrame->GetStyleContext(); } else { // otherwise build a box or a block #if defined(MOZ_SVG) @@ -3663,11 +3651,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // --------- BUILD VIEWPORT ----------- nsIFrame* viewportFrame = nsnull; - nsCOMPtr viewportPseudoStyle; + nsRefPtr viewportPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::viewport, - nsnull, - getter_AddRefs(viewportPseudoStyle)); + viewportPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::viewport, + nsnull); NS_NewViewportFrame(aPresShell, &viewportFrame); @@ -3804,9 +3792,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, NS_ASSERTION(!isXUL, "XUL documents should never be scrollable - see above"); // see if the style is overflow: hidden, first on the document element - nsCOMPtr styleContext; - aPresContext->ResolveStyleContextFor(aDocElement, nsnull, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolveStyleContextFor(aDocElement, nsnull); if (styleContext) { const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -3846,9 +3833,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } } if (bodyElement) { - nsCOMPtr bodyContext; - aPresContext->ResolveStyleContextFor(bodyElement, styleContext, - getter_AddRefs(bodyContext)); + nsRefPtr bodyContext; + bodyContext = aPresContext->ResolveStyleContextFor(bodyElement, + styleContext); if (bodyContext) { const nsStyleDisplay* display = (const nsStyleDisplay*) bodyContext->GetStyleData(eStyleStruct_Display); @@ -3864,7 +3851,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } nsIFrame* newFrame = rootFrame; - nsCOMPtr rootPseudoStyle; + nsRefPtr rootPseudoStyle; // we must create a state because if the scrollbars are GFX it needs the // state to build the scrollbar frames. nsFrameConstructorState state(aPresContext, @@ -3876,9 +3863,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // If paginated, make sure we don't put scrollbars in if (isPaginated && !printPreviewContext) - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - viewportPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + rootPseudo, + viewportPseudoStyle); else if (isScrollable) { // Build the frame. We give it the content we are wrapping which is the document, @@ -3886,27 +3873,25 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // frame and the scrollable view if one was created. // resolve a context for the scrollframe - nsCOMPtr styleContext; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::viewportScroll, - viewportPseudoStyle, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::viewportScroll, + viewportPseudoStyle); nsIFrame* newScrollableFrame = nsnull; - BeginBuildingScrollFrame( aPresShell, - aPresContext, - state, - aDocElement, - styleContext, - viewportFrame, - rootPseudo, - mDocument, - PR_TRUE, - newFrame, - rootPseudoStyle, - newScrollableFrame); + rootPseudoStyle = BeginBuildingScrollFrame( aPresShell, + aPresContext, + state, + aDocElement, + styleContext, + viewportFrame, + rootPseudo, + mDocument, + PR_TRUE, + newFrame, + newScrollableFrame); // Inform the view manager about the root scrollable view nsIView* view = nsnull; @@ -3928,19 +3913,18 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } else { // If no scrollbars and xul, don't build a scrollframe at all. if (isXUL) { - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - viewportPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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 - nsCOMPtr scrollPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::scrolledContent, - viewportPseudoStyle, - getter_AddRefs(scrollPseudoStyle)); + nsRefPtr scrollPseudoStyle; + scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::scrolledContent, + viewportPseudoStyle); // create scrollframe nsIFrame* scrollFrame = nsnull; @@ -3950,9 +3934,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull); // resolve a new style for the root frame - aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, - scrollPseudoStyle, - getter_AddRefs(rootPseudoStyle)); + rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + rootPseudo, + scrollPseudoStyle); // Inform the view manager about the root scrollable view nsIView* view = nsnull; @@ -3995,7 +3979,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, // Create the first page // Set the initial child lists nsIFrame *pageFrame, *pageContentFrame; - ConstructPageFrame(aPresShell, aPresContext, rootFrame, nsnull, + ConstructPageFrame(aPresShell, aPresContext, rootFrame, nsnull, pageFrame, pageContentFrame); rootFrame->SetInitialChildList(aPresContext, nsnull, pageFrame); @@ -4014,7 +3998,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, } NS_IMETHODIMP -nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, +nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame* aPrevPageFrame, @@ -4026,13 +4010,12 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, if (NS_FAILED(rv)) return rv; - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); - nsCOMPtr pagePseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::page, - parentStyleContext, - getter_AddRefs(pagePseudoStyle)); + nsRefPtr pagePseudoStyle; + pagePseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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); @@ -4043,10 +4026,10 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, NS_NewPageContentFrame(aPresShell, &aPageContentFrame); - nsCOMPtr pageContentPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::pageContent, - pagePseudoStyle, - getter_AddRefs(pageContentPseudoStyle)); + nsRefPtr pageContentPseudoStyle; + pageContentPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(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); @@ -4098,7 +4081,7 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, nsIFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame** aPlaceholderFrame) { @@ -4107,10 +4090,9 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, if (NS_SUCCEEDED(rv)) { // The placeholder frame gets a pseudo style context - nsCOMPtr placeholderStyle; - nsCOMPtr parentContext = aStyleContext->GetParent(); - aPresContext->ResolveStyleContextForNonElement(parentContext, - getter_AddRefs(placeholderStyle)); + nsRefPtr placeholderStyle; + nsStyleContext* parentContext = aStyleContext->GetParent(); + placeholderStyle = aPresContext->ResolveStyleContextForNonElement(parentContext); placeholderFrame->Init(aPresContext, aContent, aParentFrame, placeholderStyle, nsnull); @@ -4183,7 +4165,7 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { nsresult rv = NS_OK; if (GetFormElementRenderingMode(aPresContext, eWidgetType_Radio) == eWidgetRendering_Gfx) @@ -4196,11 +4178,10 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIPresShell* aPresShel return rv; } - nsCOMPtr radioStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::radio, - aStyleContext, - getter_AddRefs(radioStyle)); + nsRefPtr radioStyle; + radioStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::radio, + aStyleContext); nsIRadioControlFrame* radio = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&radio))) { radio->SetRadioButtonFaceStyleContext(radioStyle); @@ -4214,7 +4195,7 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { nsresult rv = NS_OK; if (GetFormElementRenderingMode(aPresContext, eWidgetType_Checkbox) == eWidgetRendering_Gfx) @@ -4227,9 +4208,10 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell aNewFrame = nsnull; } - nsCOMPtr checkboxStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, nsCSSAnonBoxes::check, - aStyleContext, getter_AddRefs(checkboxStyle)); + nsRefPtr checkboxStyle; + checkboxStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::check, + aStyleContext); nsICheckboxControlFrame* checkbox = nsnull; if (aNewFrame != nsnull && NS_SUCCEEDED(aNewFrame->QueryInterface(NS_GET_IID(nsICheckboxControlFrame), (void**)&checkbox))) { @@ -4329,7 +4311,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -4399,11 +4381,10 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell, comboBox->SetDropDown(listFrame); // Resolve psuedo element style for the dropdown list - nsCOMPtr listStyle; - rv = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::dropDownList, - aStyleContext, - getter_AddRefs(listStyle)); + nsRefPtr listStyle; + listStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::dropDownList, + aStyleContext); // Initialize the scroll frame positioned. Note that it is NOT // initialized as absolutely positioned. @@ -4511,7 +4492,7 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell, nsIFrame* scrolledFrame, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsAbsolutelyPositioned, PRBool aIsFixedPositioned, PRBool aCreateBlock) @@ -4525,81 +4506,79 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell, geometricParent = aState.mFixedItems.containingBlock; } - nsCOMPtr scrollPseudoStyle; - nsCOMPtr scrolledPseudoStyle; + nsRefPtr scrolledPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - aStyleContext, - getter_AddRefs(scrolledPseudoStyle)); + scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::scrolledContent, + aStyleContext); - InitAndRestoreFrame(aPresContext, aState, aContent, - geometricParent, aStyleContext, nsnull, scrollFrame); + InitAndRestoreFrame(aPresContext, aState, aContent, + geometricParent, aStyleContext, nsnull, scrollFrame); - // Initialize the frame and force it to have a view - // the scrolled frame is anonymous and does not have a content node - InitAndRestoreFrame(aPresContext, aState, aContent, - scrollFrame, scrolledPseudoStyle, nsnull, scrolledFrame); + // Initialize the frame and force it to have a view + // the scrolled frame is anonymous and does not have a content node + InitAndRestoreFrame(aPresContext, aState, aContent, + scrollFrame, scrolledPseudoStyle, nsnull, scrolledFrame); - nsHTMLContainerFrame::CreateViewForFrame(aPresContext, scrolledFrame, + nsHTMLContainerFrame::CreateViewForFrame(aPresContext, scrolledFrame, scrolledPseudoStyle, nsnull, PR_TRUE); - // The area frame is a floater container - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - nsFrameConstructorSaveState floaterSaveState; - aState.PushFloaterContainingBlock(scrolledFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + // The area frame is a floater container + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + nsFrameConstructorSaveState floaterSaveState; + aState.PushFloaterContainingBlock(scrolledFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); - // Process children - nsFrameConstructorSaveState absoluteSaveState; - nsFrameItems childItems; - PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || - aIsFixedPositioned; + // Process children + nsFrameConstructorSaveState absoluteSaveState; + nsFrameItems childItems; + PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || + aIsFixedPositioned; - if (isPositionedContainingBlock) { - // The area frame becomes a container for child frames that are - // absolutely positioned - aState.PushAbsoluteContainingBlock(aPresContext, scrolledFrame, absoluteSaveState); - } - - ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, - childItems, PR_TRUE); + if (isPositionedContainingBlock) { + // The area frame becomes a container for child frames that are + // absolutely positioned + aState.PushAbsoluteContainingBlock(aPresContext, scrolledFrame, absoluteSaveState); + } - // if a select is being created with zero options we need to create - // a special pseudo frame so it can be sized as best it can - nsCOMPtr selectElement; - nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), - (void**)getter_AddRefs(selectElement)); - if (NS_SUCCEEDED(result) && selectElement) { - AddDummyFrameToSelect(aPresContext, aPresShell, aState, - scrollFrame, scrolledFrame, &childItems, - aContent, selectElement); - } - ////////////////////////////////////////////////// - ////////////////////////////////////////////////// - - // Set the scrolled frame's initial child lists - scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); - if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { - scrolledFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } + ProcessChildren(aPresShell, aPresContext, aState, aContent, scrolledFrame, PR_FALSE, + childItems, PR_TRUE); - if (aState.mFloatedItems.childList) { - scrolledFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); - } + // if a select is being created with zero options we need to create + // a special pseudo frame so it can be sized as best it can + nsCOMPtr selectElement; + nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), + (void**)getter_AddRefs(selectElement)); + if (NS_SUCCEEDED(result) && selectElement) { + AddDummyFrameToSelect(aPresContext, aPresShell, aState, + scrollFrame, scrolledFrame, &childItems, + aContent, selectElement); + } + ////////////////////////////////////////////////// + ////////////////////////////////////////////////// + + // Set the scrolled frame's initial child lists + scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); + if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { + scrolledFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } + + if (aState.mFloatedItems.childList) { + scrolledFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } // Set the scroll frame's initial child list scrollFrame->SetInitialChildList(aPresContext, nsnull, scrolledFrame); - + return NS_OK; } @@ -4615,7 +4594,7 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -4656,81 +4635,81 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); // Resolve style and initialize the frame - nsIStyleContext* styleContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, nsCSSAnonBoxes::fieldsetContent, - aStyleContext, &styleContext); + nsRefPtr styleContext; + styleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::fieldsetContent, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, styleContext, nsnull, areaFrame); - NS_RELEASE(styleContext); - // The area frame is a floater container - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - nsFrameConstructorSaveState floaterSaveState; - aState.PushFloaterContainingBlock(areaFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + // The area frame is a floater container + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + nsFrameConstructorSaveState floaterSaveState; + aState.PushFloaterContainingBlock(areaFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); - // Process children - nsFrameConstructorSaveState absoluteSaveState; - nsFrameItems childItems; - PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || - aIsFixedPositioned; + // Process children + nsFrameConstructorSaveState absoluteSaveState; + nsFrameItems childItems; + PRBool isPositionedContainingBlock = aIsAbsolutelyPositioned || + aIsFixedPositioned; - if (isPositionedContainingBlock) { - // The area frame becomes a container for child frames that are - // absolutely positioned - aState.PushAbsoluteContainingBlock(aPresContext, areaFrame, absoluteSaveState); - } - - ProcessChildren(aPresShell, aPresContext, aState, aContent, areaFrame, PR_FALSE, - childItems, PR_TRUE); + if (isPositionedContainingBlock) { + // The area frame becomes a container for child frames that are + // absolutely positioned + aState.PushAbsoluteContainingBlock(aPresContext, areaFrame, absoluteSaveState); + } - static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); - nsIFrame * child = childItems.childList; - nsIFrame * previous = nsnull; - nsIFrame* legendFrame = nsnull; - while (nsnull != child) { - nsresult result = child->QueryInterface(kLegendFrameCID, (void**)&legendFrame); - if (NS_SUCCEEDED(result) && legendFrame) { - if (nsnull != previous) { - nsIFrame * nxt; - legendFrame->GetNextSibling(&nxt); - previous->SetNextSibling(nxt); - areaFrame->SetNextSibling(legendFrame); - legendFrame->SetParent(newFrame); - legendFrame->SetNextSibling(nsnull); - break; - } else { - nsIFrame * nxt; - legendFrame->GetNextSibling(&nxt); - childItems.childList = nxt; - areaFrame->SetNextSibling(legendFrame); - legendFrame->SetParent(newFrame); - legendFrame->SetNextSibling(nsnull); - break; - } + ProcessChildren(aPresShell, aPresContext, aState, aContent, areaFrame, PR_FALSE, + childItems, PR_TRUE); + + static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); + nsIFrame * child = childItems.childList; + nsIFrame * previous = nsnull; + nsIFrame* legendFrame = nsnull; + while (nsnull != child) { + nsresult result = child->QueryInterface(kLegendFrameCID, (void**)&legendFrame); + if (NS_SUCCEEDED(result) && legendFrame) { + if (nsnull != previous) { + nsIFrame * nxt; + legendFrame->GetNextSibling(&nxt); + previous->SetNextSibling(nxt); + areaFrame->SetNextSibling(legendFrame); + legendFrame->SetParent(newFrame); + legendFrame->SetNextSibling(nsnull); + break; + } else { + nsIFrame * nxt; + legendFrame->GetNextSibling(&nxt); + childItems.childList = nxt; + areaFrame->SetNextSibling(legendFrame); + legendFrame->SetParent(newFrame); + legendFrame->SetNextSibling(nsnull); + break; } - previous = child; - child->GetNextSibling(&child); } + previous = child; + child->GetNextSibling(&child); + } - // Set the scrolled frame's initial child lists - areaFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); - if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { - areaFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } + // Set the scrolled frame's initial child lists + areaFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); + if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { + areaFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } - if (aState.mFloatedItems.childList) { - areaFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); - } + if (aState.mFloatedItems.childList) { + areaFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } // Set the scroll frame's initial child list newFrame->SetInitialChildList(aPresContext, nsnull, areaFrame); @@ -4750,7 +4729,7 @@ nsCSSFrameConstructor::ConstructTextFrame(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // process pending pseudo frames. whitespace doesn't have an effect. @@ -4793,7 +4772,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // Ignore the tag if it's not HTML content @@ -5404,7 +5383,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag, PRBool& aHaltProcessing) @@ -6041,18 +6020,17 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } #endif -nsresult +already_AddRefed nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aParentFrame, nsIAtom* aScrolledPseudo, nsIDocument* aDocument, PRBool aIsRoot, nsIFrame*& aNewFrame, - nsCOMPtr& aScrolledChildStyle, nsIFrame*& aScrollableFrame, nsIFrame* aScrollPortFrame) { @@ -6078,7 +6056,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsFrameItems anonymousItems; - nsCOMPtr contentStyle = dont_QueryInterface(aContentStyle); + nsRefPtr contentStyle = aContentStyle; PRBool isGfx = HasGfxScrollbars(); @@ -6092,11 +6070,10 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, aNewFrame = gfxScrollFrame; // we used the style that was passed in. So resolve another one. - nsCOMPtr scrollPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::scrolledContent, - contentStyle, - getter_AddRefs(scrollPseudoStyle)); + nsRefPtr scrollPseudoStyle; + scrollPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::scrolledContent, + contentStyle); contentStyle = scrollPseudoStyle; InitAndRestoreFrame(aPresContext, aState, aContent, @@ -6110,13 +6087,9 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, parentFrame, contentStyle, nsnull, scrollFrame); } - // initialize the scrolled frame - nsCOMPtr scrolledPseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(aContent, - aScrolledPseudo, - contentStyle, - getter_AddRefs(scrolledPseudoStyle)); - + nsStyleContext* aScrolledChildStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, + aScrolledPseudo, + contentStyle).get(); aScrollableFrame = scrollFrame; @@ -6127,13 +6100,11 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell, } - aScrolledChildStyle = scrolledPseudoStyle; - if (printPreviewContext && noScalingOfTwips) { printPreviewContext->SetScalingOfTwips(PR_TRUE); } - return NS_OK; + return aScrolledChildStyle;; } nsresult @@ -6142,7 +6113,7 @@ nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIPresContext* aPresConte nsIContent* aContent, nsIFrame* aScrollFrame, nsIFrame* aScrolledFrame, - nsIStyleContext* aScrolledContentStyle) + nsStyleContext* aScrolledContentStyle) { // create a view @@ -6213,11 +6184,11 @@ nsCSSFrameConstructor::BuildScrollFrame (nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aScrolledFrame, nsIFrame* aParentFrame, nsIFrame*& aNewFrame, - nsIStyleContext*& aScrolledContentStyle, + nsStyleContext*& aScrolledContentStyle, nsIFrame* aScrollPortFrame) { // Check to see the type of parent frame so we know whether we need to @@ -6238,21 +6209,20 @@ nsCSSFrameConstructor::BuildScrollFrame (nsIPresShell* aPresShell, nsIFrame *scrollFrame; - nsCOMPtr scrolledContentStyle; + nsRefPtr scrolledContentStyle; - BeginBuildingScrollFrame(aPresShell, aPresContext, - aState, - aContent, - aContentStyle, - aParentFrame, - nsCSSAnonBoxes::scrolledContent, - mDocument, - PR_FALSE, - aNewFrame, - scrolledContentStyle, - scrollFrame, - aScrollPortFrame); + scrolledContentStyle = BeginBuildingScrollFrame(aPresShell, aPresContext, + aState, + aContent, + aContentStyle, + aParentFrame, + nsCSSAnonBoxes::scrolledContent, + mDocument, + PR_FALSE, + aNewFrame, + scrollFrame, + aScrollPortFrame); InitAndRestoreFrame(aPresContext, aState, aContent, scrollFrame, scrolledContentStyle, nsnull, aScrolledFrame); @@ -6287,7 +6257,7 @@ nsCSSFrameConstructor::BuildGfxScrollFrame (nsIPresShell* aPresShell, nsIContent* aContent, nsIDocument* aDocument, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsRoot, nsIFrame*& aNewFrame, nsFrameItems& aAnonymousFrames, @@ -6327,7 +6297,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre PRInt32 aNameSpaceID, nsIAtom* aTag, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { PRBool primaryFrameSet = PR_FALSE; @@ -6405,7 +6375,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre NS_BLOCK_SHRINK_WRAP | NS_BLOCK_MARGIN_ROOT); - nsIStyleContext* newStyle = nsnull; + nsStyleContext* newStyle; // Build the scrollframe it BuildScrollFrame(aPresShell, aPresContext, aState, aContent, aStyleContext, scrolledFrame, geometricParent, newFrame, newStyle); @@ -6444,7 +6414,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, childItems); - // Set the scrolled frame's initial child lists + // Set the scrolled frame's initial child lists scrolledFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList); if (isPositionedContainingBlock && aState.mAbsoluteItems.childList) { scrolledFrame->SetInitialChildList(aPresContext, @@ -6847,7 +6817,7 @@ nsCSSFrameConstructor::InitAndRestoreFrame(nsIPresContext* aPresContext nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow, nsIFrame* aNewFrame) { @@ -6870,21 +6840,16 @@ nsCSSFrameConstructor::InitAndRestoreFrame(nsIPresContext* aPresContext return rv; } -nsresult +already_AddRefed nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, nsIFrame* aParentFrame, - nsIContent* aContent, - nsIStyleContext** aStyleContext) + nsIContent* aContent) { - nsresult rv = NS_OK; // Resolve the style context based on the content object and the parent // style context - nsCOMPtr parentStyleContext; - - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); if (aContent->IsContentOfType(nsIContent::eELEMENT)) { - rv = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext, - aStyleContext); + return aPresContext->ResolveStyleContextFor(aContent, parentStyleContext); } else { #ifdef DEBUG { @@ -6895,10 +6860,8 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIPresContext* aPresContext, "comments and processing instructions"); } #endif - rv = aPresContext->ResolveStyleContextForNonElement(parentStyleContext, - aStyleContext); + return aPresContext->ResolveStyleContextForNonElement(parentStyleContext); } - return rv; } // MathML Mod - RBS @@ -6911,7 +6874,7 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { // Make sure that we remain confined in the MathML world @@ -6951,104 +6914,101 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, aTag == nsMathMLAtoms::mn_ || aTag == nsMathMLAtoms::ms_ || aTag == nsMathMLAtoms::mtext_) - rv = NS_NewMathMLTokenFrame(aPresShell, &newFrame); + rv = NS_NewMathMLTokenFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mo_) - rv = NS_NewMathMLmoFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmoFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mfrac_) - rv = NS_NewMathMLmfracFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmfracFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msup_) - rv = NS_NewMathMLmsupFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsupFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msub_) - rv = NS_NewMathMLmsubFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsubFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msubsup_) - rv = NS_NewMathMLmsubsupFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsubsupFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::munder_) - rv = NS_NewMathMLmunderFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmunderFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mover_) - rv = NS_NewMathMLmoverFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmoverFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::munderover_) - rv = NS_NewMathMLmunderoverFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmunderoverFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mphantom_) - rv = NS_NewMathMLmphantomFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmphantomFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mpadded_) - rv = NS_NewMathMLmpaddedFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmpaddedFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mspace_) - rv = NS_NewMathMLmspaceFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmspaceFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mfenced_) - rv = NS_NewMathMLmfencedFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmfencedFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mmultiscripts_) - rv = NS_NewMathMLmmultiscriptsFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmmultiscriptsFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mstyle_) - rv = NS_NewMathMLmstyleFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmstyleFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::msqrt_) - rv = NS_NewMathMLmsqrtFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmsqrtFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mroot_) - rv = NS_NewMathMLmrootFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmrootFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::maction_) - rv = NS_NewMathMLmactionFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmactionFrame(aPresShell, &newFrame); else if (aTag == nsMathMLAtoms::mrow_ || aTag == nsMathMLAtoms::merror_ || aTag == nsMathMLAtoms::none_ || aTag == nsMathMLAtoms::mprescripts_ ) - rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); + rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); // CONSTRUCTION of MTABLE elements else if (aTag == nsMathMLAtoms::mtable_ && disp->mDisplay == NS_STYLE_DISPLAY_TABLE) { - // is an inline-table -- but this isn't yet supported. - // What we do here is to wrap the table in an anonymous containing - // block so that it can mix better with other surrounding MathML markups + // is an inline-table -- but this isn't yet supported. + // What we do here is to wrap the table in an anonymous containing + // block so that it can mix better with other surrounding MathML markups - nsCOMPtr parentContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentContext)); + nsStyleContext* parentContext = aParentFrame->GetStyleContext(); - // first, create a MathML mrow frame that will wrap the block frame - rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); - if (NS_FAILED(rv)) return rv; - nsCOMPtr mrowContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsMathMLAtoms::mozMathInline, - parentContext, - getter_AddRefs(mrowContext)); - InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, - mrowContext, nsnull, newFrame); + // 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, + nsMathMLAtoms::mozMathInline, + parentContext); + InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, + mrowContext, nsnull, newFrame); - // then, create a block frame that will wrap the table frame - nsIFrame* blockFrame; - rv = NS_NewBlockFrame(aPresShell, &blockFrame); - if (NS_FAILED(rv)) return rv; - nsCOMPtr blockContext; - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mrowContext, - getter_AddRefs(blockContext)); - InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, - blockContext, nsnull, blockFrame); + // then, create a block frame that will wrap the table frame + nsIFrame* blockFrame; + rv = NS_NewBlockFrame(aPresShell, &blockFrame); + if (NS_FAILED(rv)) return rv; + nsRefPtr blockContext; + blockContext = aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mrowContext); + InitAndRestoreFrame(aPresContext, aState, aContent, newFrame, + blockContext, nsnull, blockFrame); - // then, create the table frame itself - nsCOMPtr tableContext; - aPresContext->ResolveStyleContextFor(aContent, blockContext, - getter_AddRefs(tableContext)); - nsFrameItems tempItems; - nsIFrame* outerTable; - nsIFrame* innerTable; - PRBool pseudoParent; - nsMathMLmtableCreator mathTableCreator(aPresShell); - rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, - blockFrame, tableContext, mathTableCreator, - PR_FALSE, tempItems, outerTable, innerTable, pseudoParent); - // Note: table construction function takes care of initializing the frame, - // processing children, and setting the initial child list + // then, create the table frame itself + nsRefPtr tableContext; + tableContext = aPresContext->ResolveStyleContextFor(aContent, + blockContext); + nsFrameItems tempItems; + nsIFrame* outerTable; + nsIFrame* innerTable; + PRBool pseudoParent; + nsMathMLmtableCreator mathTableCreator(aPresShell); + rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, + blockFrame, tableContext, mathTableCreator, + PR_FALSE, tempItems, outerTable, innerTable, pseudoParent); + // Note: table construction function takes care of initializing the frame, + // processing children, and setting the initial child list - // set the outerTable as the initial child of the anonymous block - blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable); + // set the outerTable as the initial child of the anonymous block + blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable); - // set the block frame as the initial child of the mrow frame - newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame); + // set the block frame as the initial child of the mrow frame + newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame); - // add the new frame to the flow - aFrameItems.AddChild(newFrame); + // add the new frame to the flow + aFrameItems.AddChild(newFrame); - return rv; + return rv; } // End CONSTRUCTION of MTABLE elements @@ -7060,7 +7020,7 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell, rv = NS_NewMathMLmathFrame(aPresShell, &newFrame, isBlock); } else { - return rv; + return rv; } // If we succeeded in creating a frame then initialize it, process its @@ -7137,7 +7097,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { NS_ASSERTION(NS_SUCCEEDED(aContent->GetNameSpaceID(aNameSpaceID)) && @@ -7273,7 +7233,7 @@ nsCSSFrameConstructor::PageBreakBefore(nsIPresShell* aPresShell, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { const nsStyleDisplay* display = (const nsStyleDisplay*) @@ -7298,14 +7258,13 @@ nsCSSFrameConstructor::ConstructPageBreakFrame(nsIPresShell* aPresShe nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems) { - nsCOMPtr pseudoStyle; - aPresContext->ResolvePseudoStyleContextFor(nsnull, - nsCSSAnonBoxes::pageBreak, - aStyleContext, - getter_AddRefs(pseudoStyle)); + nsRefPtr pseudoStyle; + pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, + nsCSSAnonBoxes::pageBreak, + aStyleContext); nsIFrame* pageBreakFrame; nsresult rv = NS_NewPageBreakFrame(aPresShell, &pageBreakFrame); if (NS_SUCCEEDED(rv)) { @@ -7343,31 +7302,28 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell, tag == nsLayoutAtoms::processingInstructionTagName) return rv; - nsCOMPtr styleContext; - rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aContent); - if (NS_SUCCEEDED(rv)) { - PRInt32 nameSpaceID; - aContent->GetNameSpaceID(nameSpaceID); + PRInt32 nameSpaceID; + aContent->GetNameSpaceID(nameSpaceID); - PRBool pageBreakAfter = PR_FALSE; - PRBool paginated; - aPresContext->IsPaginated(&paginated); + PRBool pageBreakAfter = PR_FALSE; + PRBool paginated; + aPresContext->IsPaginated(&paginated); - if (paginated) { - // See if there is a page break before, if so construct one. Also see if there is one after - pageBreakAfter = PageBreakBefore(aPresShell, aPresContext, aState, aContent, - aParentFrame, styleContext, aFrameItems); - } - // construct the frame - rv = ConstructFrameInternal(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, nameSpaceID, styleContext, aFrameItems, PR_FALSE); - if (NS_SUCCEEDED(rv) && pageBreakAfter) { - // Construct the page break after - ConstructPageBreakFrame(aPresShell, aPresContext, aState, aContent, - aParentFrame, styleContext, aFrameItems); - } + if (paginated) { + // See if there is a page break before, if so construct one. Also see if there is one after + pageBreakAfter = PageBreakBefore(aPresShell, aPresContext, aState, aContent, + aParentFrame, styleContext, aFrameItems); + } + // construct the frame + rv = ConstructFrameInternal(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, nameSpaceID, styleContext, aFrameItems, PR_FALSE); + if (NS_SUCCEEDED(rv) && pageBreakAfter) { + // Construct the page break after + ConstructPageBreakFrame(aPresShell, aPresContext, aState, aContent, + aParentFrame, styleContext, aFrameItems); } return rv; @@ -7382,7 +7338,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag) { @@ -7391,7 +7347,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe // can then be extended arbitrarily. const nsStyleDisplay* display = (const nsStyleDisplay*) aStyleContext->GetStyleData(eStyleStruct_Display); - nsCOMPtr styleContext(aStyleContext); + nsRefPtr styleContext(aStyleContext); nsCOMPtr binding; if (!aXBLBaseTag) { @@ -7409,10 +7365,8 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe return NS_OK; if (resolveStyle) { - rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, - getter_AddRefs(styleContext)); - if (NS_FAILED(rv)) - return rv; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, + aContent); } nsCOMPtr baseTag; @@ -7460,7 +7414,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe // do it now, when constructing frames. See bug 115291. { const nsStyleVisibility *vis; - GetStyleData(styleContext.get(), &vis); + GetStyleData(styleContext, &vis); } nsIFrame* lastChild = aFrameItems.lastChild; @@ -7623,9 +7577,8 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte if (NS_SUCCEEDED(rv)) { // Create the new document element hierarchy nsIFrame* newChild; - nsCOMPtr rootPseudoStyle; + nsStyleContext* rootPseudoStyle = docParentFrame->GetStyleContext(); - docParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle)); rv = ConstructDocElementFrame(shell, aPresContext, state, rootContent, docParentFrame, rootPseudoStyle, newChild); @@ -7831,22 +7784,17 @@ IsGeneratedContentFor(nsIContent* aContent, nsIFrame* aFrame, nsIAtom* aPseudoEl // First check the frame state bit aFrame->GetFrameState(&state); if (state & NS_FRAME_GENERATED_CONTENT) { - nsIContent* content; + nsCOMPtr content; // Check that it has the same content pointer - aFrame->GetContent(&content); + aFrame->GetContent(getter_AddRefs(content)); if (content == aContent) { - nsIStyleContext* styleContext; - nsIAtom* pseudoType; + nsStyleContext* styleContext = aFrame->GetStyleContext(); // See if the pseudo element type matches - aFrame->GetStyleContext(&styleContext); - styleContext->GetPseudoType(pseudoType); + nsCOMPtr pseudoType = styleContext->GetPseudoType(); result = (pseudoType == aPseudoElement); - NS_RELEASE(styleContext); - NS_IF_RELEASE(pseudoType); } - NS_IF_RELEASE(content); } return result; @@ -8117,8 +8065,8 @@ nsCSSFrameConstructor::IsValidSibling(nsIPresShell& aPresShell, nsIFrame* parent; aSibling.GetParent(&parent); - nsCOMPtr styleContext; - ResolveStyleContext(context, parent, &aContent, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(context, parent, &aContent); if (!styleContext) return PR_FALSE; const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); @@ -8534,8 +8482,8 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, aContainer->ChildAt(aNewIndexInContainer, *getter_AddRefs(child)); PRBool needReframe = !child; if (child && child->IsContentOfType(nsIContent::eELEMENT)) { - nsCOMPtr styleContext; - ResolveStyleContext(aPresContext, parentFrame, child, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, parentFrame, child); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); // XXX since the block child goes in the last inline of the sacred triad, frames would @@ -8573,8 +8521,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, PRBool haveFirstLetterStyle, haveFirstLineStyle; nsIFrame* containingBlock = state.mFloatedItems.containingBlock; nsCOMPtr blockContent; - nsCOMPtr blockSC; - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = containingBlock->GetStyleContext(); containingBlock->GetContent(getter_AddRefs(blockContent)); HaveSpecialBlockStyle(aPresContext, blockContent, blockSC, &haveFirstLetterStyle, @@ -8789,9 +8736,8 @@ nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext, listFrame->GetDummyFrame(&dummyFrame); if (!dummyFrame) { - nsCOMPtr styleContext; + nsStyleContext* styleContext = aParentFrame->GetStyleContext(); nsIFrame* generatedFrame = nsnull; - aParentFrame->GetStyleContext(getter_AddRefs(styleContext)); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aParentFrame, aContainer, styleContext, @@ -8894,8 +8840,8 @@ nsCSSFrameConstructor::NeedSpecialFrameReframe(nsIPresShell* aPresShell, // find out if aChild is a block or inline PRBool childIsBlock = PR_FALSE; if (aChild->IsContentOfType(nsIContent::eELEMENT)) { - nsCOMPtr styleContext; - ResolveStyleContext(aPresContext, aParentFrame, aChild, getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aChild); const nsStyleDisplay* display = (const nsStyleDisplay*) styleContext->GetStyleData(eStyleStruct_Display); childIsBlock = display->IsBlockLevel(); @@ -9060,8 +9006,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // InitialReflow. // Get the style context of the containing block frame - nsCOMPtr containerStyle; - mDocElementContainingBlock->GetStyleContext(getter_AddRefs(containerStyle)); + nsStyleContext* containerStyle = mDocElementContainingBlock->GetStyleContext(); // Create frames for the document element and its child elements nsIFrame* docElementFrame; @@ -9211,7 +9156,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // is not the normal structure and requires custom updating // logic. nsIFrame* containingBlock = state.mFloatedItems.containingBlock; - nsCOMPtr blockSC; + nsStyleContext* blockSC; nsCOMPtr blockContent; PRBool haveFirstLetterStyle = PR_FALSE; PRBool haveFirstLineStyle = PR_FALSE; @@ -9232,7 +9177,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, (NS_STYLE_DISPLAY_INLINE == parentDisplay->mDisplay) || (NS_STYLE_DISPLAY_INLINE_BLOCK == parentDisplay->mDisplay)) { // Recover the special style flags for the containing block - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + blockSC = containingBlock->GetStyleContext(); containingBlock->GetContent(getter_AddRefs(blockContent)); HaveSpecialBlockStyle(aPresContext, blockContent, blockSC, &haveFirstLetterStyle, @@ -9663,15 +9608,14 @@ nsCSSFrameConstructor::RemoveMappingsForFrameSubtree(nsIPresContext* aPresContex static PRBool HasPseudoStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement) { - nsCOMPtr pseudoStyleContext; + nsRefPtr pseudoStyleContext; if (aContent) { - aPresContext->ProbePseudoStyleContextFor(aContent, - aPseudoElement, - aStyleContext, - getter_AddRefs(pseudoStyleContext)); + pseudoStyleContext = aPresContext->ProbePseudoStyleContextFor(aContent, + aPseudoElement, + aStyleContext); } return pseudoStyleContext != nsnull; } @@ -9833,8 +9777,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, // :first-letter style applies. nsIFrame* containingBlock = GetFloaterContainingBlock(aPresContext, parentFrame); - nsCOMPtr blockSC; - containingBlock->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = containingBlock->GetStyleContext(); nsCOMPtr blockContent; containingBlock->GetContent(getter_AddRefs(blockContent)); PRBool haveFLS = HaveFirstLetterStyle(aPresContext, blockContent, blockSC); @@ -10322,8 +10265,7 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, // See if the block has first-letter style applied to it. nsCOMPtr blockContent; block->GetContent(getter_AddRefs(blockContent)); - nsCOMPtr blockSC; - block->GetStyleContext(getter_AddRefs(blockSC)); + nsStyleContext* blockSC = block->GetStyleContext(); PRBool haveFirstLetterStyle = HaveFirstLetterStyle(aPresContext, blockContent, blockSC); if (haveFirstLetterStyle) { @@ -10701,7 +10643,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // check for inline style. we need to clear the data at the style // context's rule node whenever the inline style property changes. - nsCOMPtr styleContext; + nsStyleContext* styleContext; nsCOMPtr rule; PRBool inlineStyle = PR_FALSE; if (aAttribute == nsHTMLAtoms::style) { @@ -10712,13 +10654,14 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // This style rule exists and we need to blow away any computed // data that this rule cached in the rule tree. - if (primaryStyleFrame) - primaryStyleFrame->GetStyleContext(getter_AddRefs(styleContext)); - else { + if (primaryStyleFrame) { + styleContext = primaryStyleFrame->GetStyleContext(); + styleContext->AddRef(); + } else { // We might be in the undisplayed map. Retrieve the style context from there. nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); - frameManager->GetUndisplayedContent(aContent, getter_AddRefs(styleContext)); + styleContext = frameManager->GetUndisplayedContent(aContent); #ifdef DEBUG if (!styleContext) { nsCOMPtr parent; @@ -10733,6 +10676,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, #endif } } + if (styleContext) + styleContext->Release(); } // first see if we need to manage the style system: @@ -10937,7 +10882,7 @@ nsresult nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame*& aFrame) { @@ -10997,15 +10942,13 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, // Create a text frame to display the alt-text. It gets a pseudo-element // style context nsIFrame* textFrame; - nsIStyleContext* textStyleContext; - NS_NewTextFrame(aPresShell, &textFrame); - aPresContext->ResolveStyleContextForNonElement(aStyleContext, - &textStyleContext); + + nsRefPtr textStyleContext; + textStyleContext = aPresContext->ResolveStyleContextForNonElement(aStyleContext); textFrame->Init(aPresContext, altTextContent, containerFrame, textStyleContext, nsnull); - NS_RELEASE(textStyleContext); containerFrame->SetInitialChildList(aPresContext, nsnull, textFrame); // Return the container frame @@ -11086,9 +11029,8 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, // Get parent frame and style context nsIFrame* parentFrame; - nsCOMPtr styleContext; aFrame->GetParent(&parentFrame); - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); // Get aFrame's content object and the tag name nsCOMPtr content; @@ -11338,7 +11280,7 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame) { nsIFrame* newFrame; @@ -11372,11 +11314,10 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, // the caption (that is what the thead is for). This code is not executed // anyway, because the caption was put in a different child list. nsIContent* caption; - nsIStyleContext* captionStyle; + nsStyleContext* captionStyle = childFrame->GetStyleContext(); const nsStyleDisplay* display; childFrame->GetContent(&caption); - childFrame->GetStyleContext(&captionStyle); display = (const nsStyleDisplay*)captionStyle->GetStyleData(eStyleStruct_Display); NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION == display->mDisplay, "expected caption"); @@ -11402,7 +11343,6 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell, } newChildFrames.AddChild(captionFrame); NS_RELEASE(caption); - NS_RELEASE(captionStyle); } NS_IF_RELEASE(tableType); childFrame->GetNextSibling(&childFrame); @@ -11422,7 +11362,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame) { nsIFrame* newFrame; @@ -11441,10 +11381,9 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, aFrame->FirstChild(aPresContext, nsnull, &rowGroupFrame); while (rowGroupFrame) { // See if it's a header/footer - nsIStyleContext* rowGroupStyle; + nsStyleContext* rowGroupStyle = rowGroupFrame->GetStyleContext(); const nsStyleDisplay* display; - rowGroupFrame->GetStyleContext(&rowGroupStyle); display = (const nsStyleDisplay*)rowGroupStyle->GetStyleData(eStyleStruct_Display); if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == display->mDisplay) || @@ -11485,8 +11424,6 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, } } - NS_RELEASE(rowGroupStyle); - // Get the next row group frame rowGroupFrame->GetNextSibling(&rowGroupFrame); } @@ -11508,14 +11445,13 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresShell* aPresShell, { nsCOMPtr frameType; nsCOMPtr content; - nsCOMPtr styleContext; + nsStyleContext* styleContext = aFrame->GetStyleContext(); nsIFrame* newFrame = nsnull; nsresult rv = NS_OK; // Use the frame type to determine what type of frame to create aFrame->GetFrameType(getter_AddRefs(frameType)); aFrame->GetContent(getter_AddRefs(content)); - aFrame->GetStyleContext(getter_AddRefs(styleContext)); if (nsLayoutAtoms::textFrame == frameType) { rv = NS_NewContinuingTextFrame(aPresShell, &newFrame); @@ -11560,7 +11496,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresShell* aPresShell, } else if (nsLayoutAtoms::pageFrame == frameType) { nsIFrame* pageContentFrame; - rv = ConstructPageFrame(aPresShell, aPresContext, aParentFrame, aFrame, + rv = ConstructPageFrame(aPresShell, aPresContext, aParentFrame, aFrame, newFrame, pageContentFrame); } else if (nsLayoutAtoms::tableOuterFrame == frameType) { rv = CreateContinuingOuterTableFrame(aPresShell, aPresContext, aFrame, aParentFrame, @@ -12095,7 +12031,7 @@ nsresult nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, nsIContent* aContent, PRBool aInlineStyle, nsIStyleRule* aInlineStyleRule, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { // Is the frame `special'? If so, we need to reframe the containing // block *here*, rather than trying to remove and re-insert the @@ -12186,32 +12122,30 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, // Block frame construction code -nsIStyleContext* +already_AddRefed nsCSSFrameConstructor::GetFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - nsIStyleContext* fls = nsnull; if (aContent) { - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLetter, - aStyleContext, &fls); + return aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSPseudoElements::firstLetter, + aStyleContext); } - return fls; + return nsnull; } -nsIStyleContext* +already_AddRefed nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - nsIStyleContext* fls = nsnull; if (aContent) { - aPresContext->ResolvePseudoStyleContextFor(aContent, - nsCSSPseudoElements::firstLine, - aStyleContext, &fls); + return aPresContext->ResolvePseudoStyleContextFor(aContent, + nsCSSPseudoElements::firstLine, + aStyleContext); } - return fls; + return nsnull; } // Predicate to see if a given content (block element) has @@ -12219,7 +12153,7 @@ nsCSSFrameConstructor::GetFirstLineStyle(nsIPresContext* aPresContext, PRBool nsCSSFrameConstructor::HaveFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { return HasPseudoStyle(aPresContext, aContent, aStyleContext, nsCSSPseudoElements::firstLetter); @@ -12228,7 +12162,7 @@ nsCSSFrameConstructor::HaveFirstLetterStyle(nsIPresContext* aPresContext, PRBool nsCSSFrameConstructor::HaveFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { return HasPseudoStyle(aPresContext, aContent, aStyleContext, nsCSSPseudoElements::firstLine); @@ -12237,7 +12171,7 @@ nsCSSFrameConstructor::HaveFirstLineStyle(nsIPresContext* aPresContext, void nsCSSFrameConstructor::HaveSpecialBlockStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool* aHaveFirstLetterStyle, PRBool* aHaveFirstLineStyle) { @@ -12267,8 +12201,7 @@ nsCSSFrameConstructor::ProcessChildren(nsIPresShell* aPresShell, nsTableCreator* aTableCreator) { nsresult rv = NS_OK; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); if (aCanHaveGeneratedContent) { // Probe for generated content before @@ -12342,7 +12275,7 @@ nsCSSFrameConstructor::ProcessChildren(nsIPresShell* aPresShell, static void ReparentFrame(nsIPresContext* aPresContext, nsIFrame* aNewParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame* aFrame) { aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); @@ -12384,9 +12317,8 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame( } // Create line frame - nsCOMPtr parentStyle; - aFrame->GetStyleContext(getter_AddRefs(parentStyle)); - nsCOMPtr firstLineStyle( + nsStyleContext* parentStyle = aFrame->GetStyleContext(); + nsRefPtr firstLineStyle( getter_AddRefs(GetFirstLineStyle(aPresContext, aContent, parentStyle)) ); nsIFrame* lineFrame; @@ -12463,8 +12395,7 @@ nsCSSFrameConstructor::AppendFirstLineFrames( return rv; } nsIFrame* lineFrame = lastBlockKid; - nsCOMPtr firstLineStyle; - lineFrame->GetStyleContext(getter_AddRefs(firstLineStyle)); + nsStyleContext* firstLineStyle = lineFrame->GetStyleContext(); // Find the first and last inline frame in aFrameItems nsIFrame* kid = aFrameItems.childList; @@ -12540,8 +12471,7 @@ nsCSSFrameConstructor::InsertFirstLineFrames( if (frameType.get() == nsLayoutAtoms::lineFrame) { // We already have a first-line frame nsIFrame* lineFrame = firstBlockKid; - nsCOMPtr firstLineStyle; - lineFrame->GetStyleContext(getter_AddRefs(firstLineStyle)); + nsStyleContext* firstLineStyle = lineFrame->GetStyleContext(); if (isInline) { // Easy case: the new inline frame will go into the lineFrame. @@ -12569,9 +12499,8 @@ nsCSSFrameConstructor::InsertFirstLineFrames( rv = NS_NewFirstLineFrame(&lineFrame); if (NS_SUCCEEDED(rv)) { // Lookup first-line style context - nsCOMPtr parentStyle; - aBlockFrame->GetStyleContext(getter_AddRefs(parentStyle)); - nsCOMPtr firstLineStyle( + nsStyleContext* parentStyle = aBlockFrame->GetStyleContext(); + nsRefPtr firstLineStyle( getter_AddRefs(GetFirstLineStyle(aPresContext, aContent, parentStyle)) ); @@ -12758,7 +12687,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( nsIFrame* aTextFrame, nsIContent* aBlockContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aResult) { // Create the first-letter-frame @@ -12772,9 +12701,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // get a proper style context for it (the one passed in is for the // letter frame and will have the float property set on it; the text // frame shouldn't have that set). - nsCOMPtr textSC; - aPresContext->ResolveStyleContextForNonElement(aStyleContext, - getter_AddRefs(textSC)); + nsRefPtr textSC; + textSC = aPresContext->ResolveStyleContextForNonElement(aStyleContext); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, aTextFrame); @@ -12798,12 +12726,10 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( &nextTextFrame); // Repair the continuations style context - nsCOMPtr parentStyleContext; - parentStyleContext = getter_AddRefs(aStyleContext->GetParent()); + nsStyleContext* parentStyleContext = aStyleContext->GetParent(); if (parentStyleContext) { - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentStyleContext, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentStyleContext); if (newSC) { nextTextFrame->SetStyleContext(aPresContext, newSC); } @@ -12836,8 +12762,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex aParentFrame->GetContent(getter_AddRefs(parentContent)); // Get style context for the first-letter-frame - nsCOMPtr parentStyleContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); + nsStyleContext* parentStyleContext = aParentFrame->GetStyleContext(); if (parentStyleContext) { // Use content from containing block so that we can actually // find a matching style rule. @@ -12846,7 +12771,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex getter_AddRefs(blockContent)); // Create first-letter style rule - nsCOMPtr sc = getter_AddRefs( + nsRefPtr sc = getter_AddRefs( GetFirstLetterStyle(aPresContext, blockContent, parentStyleContext)); if (sc) { // Create a new text frame (the original one will be discarded) @@ -12871,9 +12796,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex // Initialize the first-letter-frame. letterFrame->Init(aPresContext, aTextContent, aParentFrame, sc, nsnull); - nsCOMPtr textSC; - aPresContext->ResolveStyleContextForNonElement(sc, - getter_AddRefs(textSC)); + nsRefPtr textSC; + textSC = aPresContext->ResolveStyleContextForNonElement(sc); InitAndRestoreFrame(aPresContext, aState, aTextContent, letterFrame, textSC, nsnull, textFrame); letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame); @@ -13072,8 +12996,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( // Create a new text frame with the right style context that maps // all of the content that was previously part of the letter frame // (and probably continued elsewhere). - nsCOMPtr parentSC; - parentFrame->GetStyleContext(getter_AddRefs(parentSC)); + nsStyleContext* parentSC = parentFrame->GetStyleContext(); if (!parentSC) { return NS_OK; } @@ -13082,9 +13005,8 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( if (!textContent) { return NS_OK; } - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentSC, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); if (!newSC) { return NS_OK; } @@ -13172,8 +13094,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, } // Create a new textframe - nsCOMPtr parentSC; - aFrame->GetStyleContext(getter_AddRefs(parentSC)); + nsStyleContext* parentSC = aFrame->GetStyleContext(); if (!parentSC) { break; } @@ -13182,9 +13103,8 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresContext* aPresContext, if (!textContent) { break; } - nsCOMPtr newSC; - aPresContext->ResolveStyleContextForNonElement(parentSC, - getter_AddRefs(newSC)); + nsRefPtr newSC; + newSC = aPresContext->ResolveStyleContextForNonElement(parentSC); if (!newSC) { break; } @@ -13307,20 +13227,17 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, GetFloaterContainingBlock(aPresContext, aParentFrame), mTempFrameTreeState); - nsCOMPtr styleContext; - rv = ResolveStyleContext(aPresContext, aParentFrame, aChild, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = ResolveStyleContext(aPresContext, aParentFrame, aChild); - if (NS_SUCCEEDED(rv)) { - // Pre-check for display "none" - only if we find that, do we create - // any frame at all - const nsStyleDisplay* display = (const nsStyleDisplay*) - styleContext->GetStyleData(eStyleStruct_Display); + // Pre-check for display "none" - only if we find that, do we create + // any frame at all + const nsStyleDisplay* display = (const nsStyleDisplay*) + styleContext->GetStyleData(eStyleStruct_Display); - if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { - *aNewFrame = nsnull; - return NS_OK; - } + if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { + *aNewFrame = nsnull; + return NS_OK; } nsCOMPtr tag; @@ -13392,7 +13309,7 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aNewFrame, PRBool aRelPos) { @@ -13468,12 +13385,12 @@ nsCSSFrameConstructor::ProcessBlockChildren(nsIPresShell* aPresShell, PRBool aParentIsBlock) { nsresult rv = NS_OK; - nsCOMPtr styleContext; + nsStyleContext* styleContext; if (aCanHaveGeneratedContent) { // Probe for generated content before nsIFrame* generatedFrame; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aFrame->GetStyleContext(); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aFrame, aContent, styleContext, nsCSSPseudoElements::before, nsnull, &generatedFrame)) { @@ -13544,7 +13461,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsPositioned, nsIFrame* aNewFrame, nsIFrame** aNewBlockFrame, @@ -13662,10 +13579,9 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, blockStyle = nsCSSAnonBoxes::mozAnonymousBlock; } - nsCOMPtr blockSC; - aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, - aStyleContext, - getter_AddRefs(blockSC)); + nsRefPtr blockSC; + blockSC = aPresContext->ResolvePseudoStyleContextFor(aContent, blockStyle, + aStyleContext); InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame, blockSC, nsnull, blockFrame); @@ -13768,7 +13684,7 @@ nsCSSFrameConstructor::ProcessInlineChildren(nsIPresShell* aPresShell, PRBool* aKidsAllInline) { nsresult rv = NS_OK; - nsCOMPtr styleContext; + nsStyleContext* styleContext; // save the pseudo frame state nsPseudoFrames prevPseudoFrames; @@ -13777,7 +13693,7 @@ nsCSSFrameConstructor::ProcessInlineChildren(nsIPresShell* aPresShell, if (aCanHaveGeneratedContent) { // Probe for generated content before nsIFrame* generatedFrame; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aFrame->GetStyleContext(); if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, aFrame, aContent, styleContext, nsCSSPseudoElements::before, nsnull, &generatedFrame)) { @@ -14107,8 +14023,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (state & NS_FRAME_HAS_VIEW) { // ...create a new view for the block child, and reparent views - nsCOMPtr sc; - aLeftInlineChildFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aLeftInlineChildFrame->GetStyleContext(); nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aBlockChildFrame, sc, nsnull, PR_FALSE); @@ -14144,14 +14059,12 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (! blockFrame) return NS_ERROR_OUT_OF_MEMORY; - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); - nsCOMPtr blockSC; - aPresContext->ResolvePseudoStyleContextFor(content, - nsCSSAnonBoxes::mozAnonymousBlock, - styleContext, - getter_AddRefs(blockSC)); + nsRefPtr blockSC; + blockSC = aPresContext->ResolvePseudoStyleContextFor(content, + nsCSSAnonBoxes::mozAnonymousBlock, + styleContext); InitAndRestoreFrame(aPresContext, aState, content, nsnull, blockSC, nsnull, blockFrame); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h index a62d6aa2376..2a4642a5ffb 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h @@ -50,7 +50,7 @@ class nsIDocument; struct nsFrameItems; struct nsAbsoluteItems; struct nsTableCreator; -class nsIStyleContext; +class nsStyleContext; struct nsTableList; struct nsStyleContent; struct nsStyleDisplay; @@ -204,14 +204,14 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow, nsIFrame* aNewFrame); - nsresult ResolveStyleContext(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIContent* aContent, - nsIStyleContext** aStyleContext); + already_AddRefed + ResolveStyleContext(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIContent* aContent); nsresult ConstructFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, @@ -225,7 +225,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aDocElement, nsIFrame* aParentFrame, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsIFrame*& aNewFrame); nsresult ConstructDocElementTableFrame(nsIPresShell* aPresShell, @@ -239,7 +239,7 @@ protected: nsIDocument* aDocument, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsStyleContent* aStyleContent, PRUint32 aContentIndex, nsIFrame** aFrame); @@ -249,7 +249,7 @@ protected: nsFrameConstructorState& aState, nsIFrame* aFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIAtom* aPseudoElement, nsIFrame** aWrapperFrame, nsIFrame** aResult); @@ -267,7 +267,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -280,7 +280,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -291,7 +291,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -303,7 +303,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -315,7 +315,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -327,7 +327,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -339,7 +339,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, PRBool aIsPseudo, nsFrameItems& aChildItems, @@ -351,14 +351,14 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, nsIContent* aContent, - nsIStyleContext* aContext); + nsStyleContext* aContext); nsresult ConstructTableForeignFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrameIn, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aNewFrame, @@ -449,7 +449,7 @@ protected: nsIContent* aParentContent, nsIFrame* aParentFrame, nsIAtom* aParentFrameType, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsTableCreator& aTableCreator, nsFrameItems& aChildItems, nsIFrame*& aCaption); @@ -463,14 +463,14 @@ protected: nsIFrameManager* aFrameManager, nsIContent* aContent, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame** aPlaceholderFrame); nsresult ConstructAlternateFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aParentFrame, nsIFrame*& aFrame); @@ -481,13 +481,13 @@ protected: nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult ConstructCheckboxControlFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame*& aNewFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult ConstructButtonControlFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, @@ -505,7 +505,7 @@ protected: nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -519,7 +519,7 @@ protected: nsIContent* aContent, nsIFrame* aParentFrame, nsIAtom* aTag, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame*& aNewFrame, PRBool& aProcessChildren, PRBool aIsAbsolutelyPositioned, @@ -531,7 +531,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructPageBreakFrame(nsIPresShell* aPresShell, @@ -539,7 +539,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); // Construct a page break frame if page-break-before:always is set in aStyleContext @@ -550,7 +550,7 @@ protected: nsFrameConstructorState& aState, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructHTMLFrame(nsIPresShell* aPresShell, @@ -560,7 +560,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ConstructFrameInternal( nsIPresShell* aPresShell, @@ -570,7 +570,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag); @@ -600,7 +600,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); #endif @@ -612,7 +612,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems, PRBool aXBLBaseTag, PRBool& aHaltProcessing); @@ -628,7 +628,7 @@ protected: nsIFrame* aParentFrame, nsIAtom* aTag, PRInt32 aNameSpaceID, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); #endif @@ -640,7 +640,7 @@ protected: PRInt32 aNameSpaceID, nsIAtom* aTag, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aFrameItems); nsresult ProcessChildren(nsIPresShell* aPresShell, @@ -657,7 +657,7 @@ protected: nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame*& aFrame, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); nsresult AddDummyFrameToSelect(nsIPresContext* aPresContext, nsIPresShell* aPresShell, @@ -697,28 +697,27 @@ protected: nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aScrolledFrame, nsIFrame* aParentFrame, nsIFrame*& aNewFrame, - nsIStyleContext*& aScrolledChildStyle, + nsStyleContext*& aScrolledChildStyle, nsIFrame* aScrollPort = nsnull); // Builds the initial ScrollFrame: // if Gfx scrollbasrs in ares, it creates a GfxScrollFrame, otherwise it creates a ScrollFrame // - nsresult + already_AddRefed BeginBuildingScrollFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsFrameConstructorState& aState, nsIContent* aContent, - nsIStyleContext* aContentStyle, + nsStyleContext* aContentStyle, nsIFrame* aParentFrame, nsIAtom* aScrolledPseudo, nsIDocument* aDocument, PRBool aIsRoot, nsIFrame*& aNewFrame, - nsCOMPtr& aScrolledChildStyle, nsIFrame*& aScrollableFrame, nsIFrame* aScrollPort = nsnull); @@ -731,7 +730,7 @@ protected: nsIContent* aContent, nsIFrame* aScrollFrame, nsIFrame* aScrolledFrame, - nsIStyleContext* scrolledPseudoStyle); + nsStyleContext* scrolledPseudoStyle); // Creates a new GfxScrollFrame, Initializes it, and creates a scroll port for it // @@ -742,7 +741,7 @@ protected: nsIContent* aContent, nsIDocument* aDocument, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsRoot, nsIFrame*& aNewFrame, nsFrameItems& aAnonymousFrames, @@ -757,7 +756,7 @@ protected: nsIFrame* scrolledFrame, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsAbsolutelyPositioned, PRBool aIsFixedPositioned, PRBool aCreateBlock); @@ -771,7 +770,7 @@ protected: nsIContent* aContent, PRBool aInlineStyle = PR_FALSE, nsIStyleRule* aRule = nsnull, - nsIStyleContext* aContext = nsnull); + nsStyleContext* aContext = nsnull); nsresult RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, nsIContent* aContent, @@ -782,7 +781,7 @@ protected: nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame); nsresult CreateContinuingTableFrame(nsIPresShell* aPresShell, @@ -790,32 +789,34 @@ protected: nsIFrame* aFrame, nsIFrame* aParentFrame, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame** aContinuingFrame); //---------------------------------------- // Methods support creating block frames and their children - static nsIStyleContext* GetFirstLetterStyle(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aStyleContext); + static already_AddRefed + GetFirstLetterStyle(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aStyleContext); - static nsIStyleContext* GetFirstLineStyle(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aStyleContext); + static already_AddRefed + GetFirstLineStyle(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aStyleContext); static PRBool HaveFirstLetterStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); static PRBool HaveFirstLineStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext); + nsStyleContext* aStyleContext); static void HaveSpecialBlockStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool* aHaveFirstLetterStyle, PRBool* aHaveFirstLineStyle); @@ -829,7 +830,7 @@ protected: const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aNewFrame, PRBool aRelPos); @@ -848,7 +849,7 @@ protected: const nsStyleDisplay* aDisplay, nsIContent* aContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aIsPositioned, nsIFrame* aNewFrame, nsIFrame** aNewBlockFrame, @@ -925,7 +926,7 @@ protected: nsIFrame* aTextFrame, nsIContent* aBlockContent, nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsFrameItems& aResult); nsresult CreateLetterFrame(nsIPresShell* aPresShell, diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 60d446d824e..cfb8d8bc5fd 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -43,7 +43,7 @@ #include "nsRect.h" #include "nsIViewManager.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIScrollableView.h" #include "nsLayoutAtoms.h" #include "nsIDrawingSurface.h" @@ -1562,8 +1562,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, // use this guy's color nsIFrame *pFrame = nsnull; if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) && pFrame) { - nsIStyleContext *pContext = nsnull; - pFrame->GetStyleContext(&pContext); + nsStyleContext *pContext = pFrame->GetStyleContext(); if (pContext) { const nsStyleBackground* color = (const nsStyleBackground*)pContext->GetStyleData(eStyleStruct_Background); NS_ASSERTION(color,"ColorStyleData should not be null"); @@ -1572,7 +1571,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, // set the reslt to TRUE to indicate we mapped the color result = PR_TRUE; } - NS_RELEASE(pContext); }// if context }// if frame }// if tag == html or body @@ -1672,7 +1670,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext, const nsRect& aDirtyRect, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap, nscoord aHardBorderSize, @@ -2070,7 +2068,7 @@ void nsCSSRendering::PaintOutline(nsIPresContext* aPresContext, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, const nsStyleOutline& aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap) { @@ -2233,7 +2231,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext* aPresContext, const nsRect& aDirtyRect, const nsRect& aBorderArea, nsBorderEdges * aBorderEdges, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap) { @@ -2527,11 +2525,11 @@ GetRootScrollableFrame(nsIPresContext* aPresContext, nsIFrame* aRootFrame) } const nsStyleBackground* -nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext, +nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext, PRBool aStartAtParent /*= PR_FALSE*/) { const nsStyleBackground* result = nsnull; - nsCOMPtr context; + nsStyleContext* context; if (aStartAtParent) { context = aContext->GetParent(); } else { @@ -2543,7 +2541,7 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext, // Have to .get() because some compilers won't match the template // otherwise (they don't look for implicit type conversions while doing // template matching?). - ::GetStyleData(context.get(), &result); + ::GetStyleData(context, &result); if (0 == (result->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) break; @@ -2609,7 +2607,7 @@ FindCanvasBackground(nsIPresContext* aPresContext, // for printing and print preview.. this should be a pageContentFrame nsCOMPtr frameType; - nsCOMPtr parentContext; + nsStyleContext* parentContext; firstChild->GetFrameType(getter_AddRefs(frameType)); if ( (frameType == nsLayoutAtoms::pageContentFrame) ){ @@ -2617,11 +2615,11 @@ FindCanvasBackground(nsIPresContext* aPresContext, // pageContentframe does not have content while(firstChild){ for (nsIFrame* kidFrame = firstChild; nsnull != kidFrame; ) { - kidFrame->GetStyleContext(getter_AddRefs(parentContext)); + parentContext = kidFrame->GetStyleContext(); // Need to .get() because some compilers will not do the // implicit .get() to match the template. // See also rev 3.188 of this file. - ::GetStyleData(parentContext.get(), &result); + ::GetStyleData(parentContext, &result); if (!result->IsTransparent()) { GetStyleData(kidFrame, aBackground); return PR_TRUE; @@ -3504,7 +3502,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, const nsRect& aBorderArea, const nsStyleBorder* aBorderStyle, const nsStyleOutline* aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, PRInt16 aBorderRadius[4], nsRect* aGap, @@ -3643,7 +3641,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext, */ void nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext, - const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext, + const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext, PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel, PRBool aIsOutline) { diff --git a/mozilla/layout/html/style/src/nsCSSRendering.h b/mozilla/layout/html/style/src/nsCSSRendering.h index a12f889f35e..ce3e138e10c 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.h +++ b/mozilla/layout/html/style/src/nsCSSRendering.h @@ -39,7 +39,7 @@ #include "nsIRenderingContext.h" struct nsPoint; -class nsIStyleContext; +class nsStyleContext; class nsIPresContext; class nsCSSRendering { @@ -58,7 +58,7 @@ public: const nsRect& aDirtyRect, const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0, nscoord aHardBorderSize = 0, @@ -79,7 +79,7 @@ public: const nsRect& aBorderArea, const nsStyleBorder& aBorderStyle, const nsStyleOutline& aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0); @@ -100,7 +100,7 @@ public: const nsRect& aDirtyRect, const nsRect& aBorderArea, nsBorderEdges * aBorderEdges, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, nsRect* aGap = 0); @@ -123,7 +123,7 @@ public: * you want. */ static const nsStyleBackground* - FindNonTransparentBackground(nsIStyleContext* aContext, + FindNonTransparentBackground(nsStyleContext* aContext, PRBool aStartAtParent = PR_FALSE); /** @@ -232,13 +232,13 @@ protected: const nsRect& aBorderArea, const nsStyleBorder* aBorderStyle, const nsStyleOutline* aOutlineStyle, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRIntn aSkipSides, PRInt16 aBorderRadius[4],nsRect* aGap = 0, PRBool aIsOutline=PR_FALSE); static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext, - const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext, + const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext, PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel, PRBool aIsOutline=PR_FALSE); diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 3d7d4b7f04e..7b3c7e1d7b9 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -41,7 +41,7 @@ #include "nsTableFrame.h" #include "nsTableRowGroupFrame.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -116,7 +116,7 @@ NS_IMETHODIMP nsTableCellFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h index 79c6abdb838..4db09980812 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.h +++ b/mozilla/layout/html/table/src/nsTableCellFrame.h @@ -41,7 +41,7 @@ #include "nscore.h" #include "nsHTMLContainerFrame.h" #include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPercentHeightObserver.h" #include "nsLayoutAtoms.h" @@ -85,7 +85,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); #ifdef ACCESSIBILITY diff --git a/mozilla/layout/html/table/src/nsTableColFrame.cpp b/mozilla/layout/html/table/src/nsTableColFrame.cpp index 3bf577d733b..4a12e9da353 100644 --- a/mozilla/layout/html/table/src/nsTableColFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColFrame.cpp @@ -37,7 +37,7 @@ #include "nsCOMPtr.h" #include "nsTableColFrame.h" #include "nsContainerFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsHTMLAtoms.h" @@ -116,8 +116,7 @@ nsStyleCoord nsTableColFrame::GetStyleWidth() const eStyleUnit_Inherit == styleWidth.GetUnit()) { nsIFrame* parent; GetParent(&parent); - nsCOMPtr styleContext; - parent->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = parent->GetStyleContext(); if (styleContext) { position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); styleWidth = position->mWidth; @@ -269,7 +268,7 @@ NS_IMETHODIMP nsTableColFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/table/src/nsTableColFrame.h b/mozilla/layout/html/table/src/nsTableColFrame.h index 505a84b3726..280efa9933b 100644 --- a/mozilla/layout/html/table/src/nsTableColFrame.h +++ b/mozilla/layout/html/table/src/nsTableColFrame.h @@ -107,7 +107,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Paint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp index ce3d2d53bb2..9221c4540ca 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp @@ -40,7 +40,7 @@ #include "nsIHTMLTableColElement.h" #include "nsIDOMHTMLTableColElement.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIHTMLContent.h" @@ -722,7 +722,7 @@ NS_IMETHODIMP nsTableColGroupFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.h b/mozilla/layout/html/table/src/nsTableColGroupFrame.h index ffcb9cf2dff..d0f0f556882 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.h +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.h @@ -73,7 +73,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index eb09677fa04..13d4ee48758 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -39,7 +39,7 @@ #include "nsVoidArray.h" #include "nsTableFrame.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsCellMap.h" @@ -76,7 +76,7 @@ #include "nsIFrameManager.h" #include "nsCSSRendering.h" #include "nsLayoutErrors.h" - +#include "nsAutoPtr.h" /******************************************************************************** @@ -247,7 +247,7 @@ NS_IMETHODIMP nsTableFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -377,8 +377,8 @@ PRBool nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, nsIFrame* aNextFrame) { - nsCOMPtr sourceContext; - aSourceFrame.GetStyleContext(getter_AddRefs(sourceContext)); NS_ENSURE_TRUE(sourceContext, PR_FALSE); + nsStyleContext* sourceContext = aSourceFrame.GetStyleContext(); + NS_ENSURE_TRUE(sourceContext, PR_FALSE); const nsStyleDisplay* display = (const nsStyleDisplay*) sourceContext->GetStyleData(eStyleStruct_Display); NS_ENSURE_TRUE(display, PR_FALSE); // don't allow a page break after a repeated header @@ -387,8 +387,8 @@ nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, } if (aNextFrame) { - nsCOMPtr nextContext; - aNextFrame->GetStyleContext(getter_AddRefs(nextContext)); NS_ENSURE_TRUE(nextContext, PR_FALSE); + nsStyleContext* nextContext = aNextFrame->GetStyleContext(); + NS_ENSURE_TRUE(nextContext, PR_FALSE); display = (const nsStyleDisplay*) nextContext->GetStyleData(eStyleStruct_Display); NS_ENSURE_TRUE(display, PR_FALSE); // don't allow a page break before a repeated footer @@ -860,11 +860,10 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, nsCOMPtr colGroupContent; GetContent(getter_AddRefs(colGroupContent)); - nsCOMPtr colGroupStyle; - aPresContext.ResolvePseudoStyleContextFor(colGroupContent, - nsCSSAnonBoxes::tableColGroup, - mStyleContext, - getter_AddRefs(colGroupStyle)); + nsRefPtr colGroupStyle; + colGroupStyle = aPresContext.ResolvePseudoStyleContextFor(colGroupContent, + nsCSSAnonBoxes::tableColGroup, + mStyleContext); // Create a col group frame nsIFrame* newFrame; nsCOMPtr presShell; @@ -967,21 +966,22 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, for (PRInt32 childX = startIndex; childX <= lastIndex; childX++) { nsCOMPtr iContent; - nsCOMPtr styleContext; - nsCOMPtr parentStyleContext; + nsRefPtr styleContext; + nsStyleContext* parentStyleContext; if ((aColType == eColAnonymousCol) && aPrevFrameIn) { // a col due to a span in a previous col uses the style context of the col - aPrevFrameIn->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aPrevFrameIn->GetStyleContext(); // fix for bugzilla bug 54454: get the content from the prevFrame aPrevFrameIn->GetContent(getter_AddRefs(iContent)); } else { // all other anonymous cols use a pseudo style context of the col group aColGroupFrame.GetContent(getter_AddRefs(iContent)); - aColGroupFrame.GetStyleContext(getter_AddRefs(parentStyleContext)); - aPresContext.ResolvePseudoStyleContextFor(iContent, nsCSSAnonBoxes::tableCol, - parentStyleContext, getter_AddRefs(styleContext)); + parentStyleContext = aColGroupFrame.GetStyleContext(); + styleContext = aPresContext.ResolvePseudoStyleContextFor(iContent, + nsCSSAnonBoxes::tableCol, + parentStyleContext); } // ASSERTION to check for bug 54454 sneaking back in... NS_ASSERTION(iContent, "null content in CreateAnonymousColFrames"); @@ -2867,7 +2867,7 @@ nsTableFrame::GetBCBorder(nsIPresContext& aPresContext, static void GetSeparateModelBorderPadding(nsIPresContext& aPresContext, const nsHTMLReflowState* aReflowState, - nsIStyleContext& aStyleContext, + nsStyleContext& aStyleContext, nsMargin& aBorderPadding) { const nsStyleBorder* border = @@ -3775,7 +3775,7 @@ UpdateCol(nsTableFrame& aTableFrame, } PRBool -nsTableFrame::IsPctHeight(nsIStyleContext* aStyleContext) +nsTableFrame::IsPctHeight(nsStyleContext* aStyleContext) { PRBool result = PR_FALSE; if (aStyleContext) { @@ -4164,10 +4164,8 @@ PRBool nsTableFrame::IsAutoHeight() { PRBool isAuto = PR_TRUE; // the default - nsCOMPtr styleContext; - GetStyleContext(getter_AddRefs(styleContext)); - nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); + nsStylePosition* position = (nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position); switch (position->mHeight.GetUnit()) { case eStyleUnit_Auto: // specified auto width @@ -5171,8 +5169,8 @@ GetStyleInfo(const nsIFrame& aFrame, PRBool transparent, foreground; styleData->GetBorderColor(aSide, aColor, transparent, foreground); if (foreground) { - nsCOMPtr styleContext; - aFrame.GetStyleContext(getter_AddRefs(styleContext)); if(!styleContext) ABORT0(); + nsStyleContext* styleContext = aFrame.GetStyleContext(); + if(!styleContext) ABORT0(); const nsStyleColor* colorStyle = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color); aColor = colorStyle->mColor; } diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index c355542df8c..fef8f6c3f41 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -42,7 +42,6 @@ #include "nsHTMLContainerFrame.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" #include "nsITableLayout.h" #include "nsTableColFrame.h" #include "nsTableColGroupFrame.h" @@ -56,6 +55,7 @@ class nsTableRowFrame; class nsTableColGroupFrame; class nsITableLayoutStrategy; class nsHTMLValue; +class nsStyleContext; struct nsTableReflowState; struct nsStylePosition; @@ -203,7 +203,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); @@ -293,7 +293,7 @@ public: nsIAtom* aChildType); PRBool IsAutoWidth(PRBool* aIsPctWidth = nsnull); PRBool IsAutoHeight(); - static PRBool IsPctHeight(nsIStyleContext* aStyleContext); + static PRBool IsPctHeight(nsStyleContext* aStyleContext); /** @return PR_TRUE if aDisplayType represents a rowgroup of any sort * (header, footer, or body) diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index ec74829dc95..355b0e716fb 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -38,7 +38,7 @@ #include "nsTableOuterFrame.h" #include "nsTableFrame.h" #include "nsHTMLReflowCommand.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -166,7 +166,7 @@ NS_IMETHODIMP nsTableOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -1231,8 +1231,7 @@ nsTableOuterFrame::IsAutoWidth(nsIFrame& aTableOrCaption, *aIsPctWidth = PR_FALSE; } - nsCOMPtr styleContext; - aTableOrCaption.GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aTableOrCaption.GetStyleContext(); nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); @@ -1877,8 +1876,7 @@ static PRBool IsPctHeight(nsIFrame* aFrame) { if (aFrame) { - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); if (eStyleUnit_Percent == position->mHeight.GetUnit()) { float percent = position->mHeight.GetPercentValue(); diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.h b/mozilla/layout/html/table/src/nsTableOuterFrame.h index ed72a539aa3..351bfe535ba 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.h +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.h @@ -91,7 +91,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 70d6baf0246..138bc5ca288 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -39,7 +39,7 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIHTMLContent.h" #include "nsHTMLAtoms.h" @@ -190,7 +190,7 @@ NS_IMETHODIMP nsTableRowFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.h b/mozilla/layout/html/table/src/nsTableRowFrame.h index bf08c32e7a4..aa46d78af04 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.h +++ b/mozilla/layout/html/table/src/nsTableRowFrame.h @@ -69,7 +69,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index 5a1b208c9bb..e03dc0f4371 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -41,7 +41,7 @@ #include "nsTableCellFrame.h" #include "nsIRenderingContext.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsIView.h" @@ -1874,7 +1874,7 @@ NS_IMETHODIMP nsTableRowGroupFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h index 6fc4bc81e64..1b82f15fdec 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h @@ -117,7 +117,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/tests/TestInlineFrame.cpp b/mozilla/layout/html/tests/TestInlineFrame.cpp index 8c81818fb17..affd69a2266 100644 --- a/mozilla/layout/html/tests/TestInlineFrame.cpp +++ b/mozilla/layout/html/tests/TestInlineFrame.cpp @@ -49,7 +49,7 @@ #include "nsIPresContext.h" #include "nsInlineFrame.h" #include "nsIAtom.h" - +#include "nsAutoPtr.h" /////////////////////////////////////////////////////////////////////////////// // @@ -291,7 +291,7 @@ TestReflowUnmapped(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -384,7 +384,7 @@ TestChildrenThatDontFit(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -556,7 +556,7 @@ TestOverflow(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -668,7 +668,7 @@ TestPushingPulling(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -1089,7 +1089,7 @@ TestSplittableChildren(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); @@ -1448,7 +1448,7 @@ TestMaxElementSize(nsIPresContext* presContext) // Create an inline frame for the HTML container and set its // style context InlineFrame* f = new InlineFrame(b, 0, nsnull); - nsIStyleContext* styleContext = presContext->ResolveStyleContextFor(b, nsnull); + nsRefPtr styleContext = presContext->ResolveStyleContextFor(b, nsnull); f->SetStyleContext(presContext,styleContext); diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp index d59e94a41c9..1a153ca04eb 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp @@ -24,7 +24,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsString.h" #include "nsUnicharUtils.h" @@ -1205,30 +1205,28 @@ InitGlobals(nsIPresContext* aPresContext) // ----------------------------------------------------------------------------------- // And now the implementation of nsMathMLChar -nsresult -nsMathMLChar::GetStyleContext(nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLChar::GetStyleContext() const { NS_ASSERTION(!mParent, "invalid call - not allowed for child chars"); - NS_PRECONDITION(aStyleContext, "null OUT ptr"); NS_ASSERTION(mStyleContext, "chars shoud always have style context"); - *aStyleContext = mStyleContext; - NS_IF_ADDREF(*aStyleContext); + return mStyleContext; return NS_OK; } -nsresult -nsMathMLChar::SetStyleContext(nsIStyleContext* aStyleContext) +void +nsMathMLChar::SetStyleContext(nsStyleContext* aStyleContext) { NS_ASSERTION(!mParent, "invalid call - not allowed for child chars"); NS_PRECONDITION(aStyleContext, "null ptr"); if (aStyleContext != mStyleContext) { - NS_IF_RELEASE(mStyleContext); + if (mStyleContext) + mStyleContext->Release(); if (aStyleContext) { mStyleContext = aStyleContext; - NS_ADDREF(aStyleContext); + aStyleContext->AddRef(); } } - return NS_OK; } void @@ -1468,7 +1466,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext, // mStyleContext is a leaf context used only when stretching happens. // For the base size, the default font should come from the parent context nsAutoString fontName; - nsCOMPtr parentContext(mStyleContext->GetParent()); + nsStyleContext* parentContext = mStyleContext->GetParent(); const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, parentContext->GetStyleData(eStyleStruct_Font)); nsFont theFont(font->mFont); @@ -1868,8 +1866,8 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext, const nsRect* aSelectedRect) { nsresult rv = NS_OK; - nsCOMPtr parentContext(mStyleContext->GetParent()); - nsIStyleContext* styleContext = mStyleContext; + nsStyleContext* parentContext = mStyleContext->GetParent(); + nsStyleContext* styleContext = mStyleContext; if (NS_STRETCH_DIRECTION_UNSUPPORTED == mDirection) { // normal drawing if there is nothing special about this char @@ -1906,7 +1904,7 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext, const nsStyleBackground *backg = NS_STATIC_CAST(const nsStyleBackground*, styleContext->GetStyleData(eStyleStruct_Background)); nsRect rect(mRect); //0, 0, mRect.width, mRect.height); - if (styleContext != parentContext.get() && + if (styleContext != parentContext && 0 == (backg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame, aDirtyRect, rect, *backg, *border, *padding, @@ -2007,7 +2005,7 @@ nsresult nsMathMLChar::PaintVertically(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, nsFont& aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsGlyphTable* aGlyphTable, nsMathMLChar* aChar, nsRect& aRect) @@ -2185,7 +2183,7 @@ nsresult nsMathMLChar::PaintHorizontally(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, nsFont& aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsGlyphTable* aGlyphTable, nsMathMLChar* aChar, nsRect& aRect) diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.h b/mozilla/layout/mathml/base/src/nsMathMLChar.h index ad611ba3700..c3115b668a7 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.h +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.h @@ -65,8 +65,8 @@ public: MOZ_COUNT_DTOR(nsMathMLChar); // there is only one style context owned by the "root" char // and it may be used by child chars as well - if (!mParent) { // only the "root" need to release it - NS_IF_RELEASE(mStyleContext); + if (!mParent && mStyleContext) { // only the "root" need to release it + mStyleContext->Release(); } if (mSibling) { delete mSibling; @@ -156,11 +156,9 @@ public: // They provide an interface to make them acessible to the Style System via // the Get/Set AdditionalStyleContext() APIs. Owners of MathMLChars // should honor these APIs. - nsresult - GetStyleContext(nsIStyleContext** aStyleContext) const; + nsStyleContext* GetStyleContext() const; - nsresult - SetStyleContext(nsIStyleContext* aStyleContext); + void SetStyleContext(nsStyleContext* aStyleContext); protected: friend class nsGlyphTable; @@ -175,7 +173,7 @@ private: PRInt32 mOperator; nsStretchDirection mDirection; nsBoundingMetrics mBoundingMetrics; - nsIStyleContext* mStyleContext; + nsStyleContext* mStyleContext; nsGlyphTable* mGlyphTable; nsGlyphCode mGlyph; @@ -192,7 +190,7 @@ private: PaintVertically(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, nsFont& aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsGlyphTable* aGlyphTable, nsMathMLChar* aChar, nsRect& aRect); @@ -201,7 +199,7 @@ private: PaintHorizontally(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, nsFont& aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsGlyphTable* aGlyphTable, nsMathMLChar* aChar, nsRect& aRect); diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 11e4d95cee3..2497b68a9c7 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -29,7 +29,7 @@ #include "nsIPresShell.h" #include "nsCSSAnonBoxes.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" @@ -45,6 +45,7 @@ #include "nsMathMLParts.h" #include "nsMathMLChar.h" #include "nsMathMLContainerFrame.h" +#include "nsAutoPtr.h" // // nsMathMLContainerFrame implementation @@ -592,9 +593,8 @@ nsMathMLContainerFrame::PropagateScriptStyleFor(nsIPresContext* aPresContext, // the one to use when we will propagate the recursion aParentScriptLevel = presentationData.scriptLevel; - nsCOMPtr oldStyleContext; - aFrame->GetStyleContext(getter_AddRefs(oldStyleContext)); - nsCOMPtr parentContext(oldStyleContext->GetParent()); + nsStyleContext* oldStyleContext = aFrame->GetStyleContext(); + nsStyleContext* parentContext = oldStyleContext->GetParent(); nsCOMPtr content; aFrame->GetContent(getter_AddRefs(content)); @@ -730,11 +730,10 @@ nsMathMLContainerFrame::WrapForeignFrames(nsIPresContext* aPresContext) nsIFrame* wrapper; nsresult rv = NS_NewMathMLForeignFrameWrapper(shell, &wrapper); if (NS_FAILED(rv)) return rv; - nsCOMPtr newStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, - nsCSSAnonBoxes::mozAnonymousBlock, - mStyleContext, - getter_AddRefs(newStyleContext)); + nsRefPtr newStyleContext; + newStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, + nsCSSAnonBoxes::mozAnonymousBlock, + mStyleContext); rv = wrapper->Init(aPresContext, mContent, this, newStyleContext, nsnull); if (NS_FAILED(rv)) { wrapper->Destroy(aPresContext); @@ -798,7 +797,7 @@ NS_IMETHODIMP nsMathMLContainerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { MapAttributesIntoCSS(aPresContext, aContent); @@ -1446,8 +1445,7 @@ GetInterFrameSpacingFor(nsIPresContext* aPresContext, prevFrameType, childFrameType, &fromFrameType, &carrySpace); if (aChildFrame == childFrame) { // get thinspace - nsCOMPtr parentContext; - aParentFrame->GetStyleContext(getter_AddRefs(parentContext)); + nsStyleContext* parentContext = aParentFrame->GetStyleContext(); const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, parentContext->GetStyleData(eStyleStruct_Font)); nscoord thinSpace = NSToCoordRound(float(font->mFont.size)*float(3) / float(18)); diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h index 30754fb25a2..d9f7e69b2b2 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -110,7 +110,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp index 8c3c6685393..808179161dd 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp @@ -33,7 +33,7 @@ #include "nsIPresContext.h" #include "nsHTMLAtoms.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -63,7 +63,7 @@ NS_IMETHODIMP nsMathMLForeignFrameWrapper::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { return nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h index 29fb4b8dda8..59dfc3d1572 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h +++ b/mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h @@ -66,7 +66,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); #ifdef NS_DEBUG diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index b6e492089d7..a7a10e91b2c 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -36,6 +36,7 @@ #include "nsNetUtil.h" #include "nsIURI.h" #include "nsContentCID.h" +#include "nsAutoPtr.h" static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); @@ -107,18 +108,17 @@ nsMathMLFrame::UpdatePresentationData(nsIPresContext* aPresContext, /* static */ void nsMathMLFrame::ResolveMathMLCharStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aParentStyleContext, + nsStyleContext* aParentStyleContext, nsMathMLChar* aMathMLChar, PRBool aIsMutableChar) { nsIAtom* fontAtom = (aIsMutableChar) ? nsMathMLAtoms::fontstyle_stretchy : nsMathMLAtoms::fontstyle_anonymous; // savings - nsCOMPtr newStyleContext; - nsresult rv = aPresContext->ResolvePseudoStyleContextFor(aContent, fontAtom, - aParentStyleContext, - getter_AddRefs(newStyleContext)); - if (NS_SUCCEEDED(rv) && newStyleContext) + nsRefPtr newStyleContext; + newStyleContext = aPresContext->ResolvePseudoStyleContextFor(aContent, fontAtom, + aParentStyleContext); + if (newStyleContext) aMathMLChar->SetStyleContext(newStyleContext); } @@ -403,7 +403,7 @@ nsMathMLFrame::ParseNumericValue(nsString& aString, /* static */ nscoord nsMathMLFrame::CalcLength(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsCSSValue& aCSSValue) { NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit"); diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.h b/mozilla/layout/mathml/base/src/nsMathMLFrame.h index 49504ebba48..9fcb4e6efe7 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.h @@ -26,7 +26,7 @@ #include "nsIPresContext.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsMathMLAtoms.h" #include "nsMathMLOperators.h" #include "nsIMathMLFrame.h" @@ -162,7 +162,7 @@ public: static void ResolveMathMLCharStyle(nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aParenStyleContext, + nsStyleContext* aParenStyleContext, nsMathMLChar* aMathMLChar, PRBool aIsMutableChar); @@ -216,7 +216,7 @@ public: static nscoord CalcLength(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, const nsCSSValue& aCSSValue); static PRBool diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp index fbea576a9b8..5e60a0befaf 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp @@ -23,7 +23,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -95,7 +95,7 @@ NS_IMETHODIMP nsMathMLTokenFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // leading and trailing whitespace doesn't count -- bug 15402 diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.h b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.h index cd90f2cfd7b..da0501f9dd3 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.h @@ -40,7 +40,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 55fb9cbb3bb..039c2521499 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -23,7 +23,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" @@ -44,6 +44,7 @@ #include "nsIDOMMouseListener.h" #include "nsMathMLmactionFrame.h" +#include "nsAutoPtr.h" // // -- bind actions to a subexpression - implementation @@ -90,7 +91,7 @@ NS_IMETHODIMP nsMathMLmactionFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsAutoString value, prefix; @@ -103,6 +104,7 @@ nsMathMLmactionFrame::Init(nsIPresContext* aPresContext, mChildCount = -1; // these will be updated in GetSelectedFrame() mSelection = 0; mSelectedFrame = nsnull; + nsRefPtr newStyleContext; mActionType = NS_MATHML_ACTION_TYPE_NONE; if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttr(kNameSpaceID_None, @@ -139,20 +141,16 @@ nsMathMLmactionFrame::Init(nsIPresContext* aPresContext, aContent->UnsetAttr(kNameSpaceID_None, nsMathMLAtoms::actiontype_, notify); // then, re-resolve our style - nsCOMPtr parentStyleContext; - aParent->GetStyleContext(getter_AddRefs(parentStyleContext)); - nsIStyleContext* newStyleContext; - aPresContext->ResolveStyleContextFor(aContent, parentStyleContext, - &newStyleContext); + nsStyleContext* parentStyleContext = aParent->GetStyleContext(); + newStyleContext = aPresContext->ResolveStyleContextFor(aContent, + parentStyleContext); if (!newStyleContext) mRestyle.Truncate(); else { if (newStyleContext != aContext) aContext = newStyleContext; - else { - NS_RELEASE(newStyleContext); + else mRestyle.Truncate(); - } } } } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.h index 81cc167cca5..70fade01e76 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.h @@ -48,7 +48,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp index 543b5de754d..64b7090e4f1 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -584,11 +584,9 @@ nsMathMLmfencedFrame::PlaceChar(nsMathMLChar* aMathMLChar, // ---------------------- // the Style System will use these to pass the proper style context to our MathMLChar -NS_IMETHODIMP -nsMathMLmfencedFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLmfencedFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(aStyleContext, "null OUT ptr"); PRInt32 openIndex = -1; PRInt32 closeIndex = -1; PRInt32 lastIndex = mSeparatorsCount-1; @@ -602,25 +600,24 @@ nsMathMLmfencedFrame::GetAdditionalStyleContext(PRInt32 aIndex, closeIndex = lastIndex; } if (aIndex < 0 || aIndex > lastIndex) { - return NS_ERROR_INVALID_ARG; + return nsnull; } - *aStyleContext = nsnull; if (aIndex < mSeparatorsCount) { - mSeparatorsChar[aIndex].GetStyleContext(aStyleContext); + return mSeparatorsChar[aIndex].GetStyleContext(); } else if (aIndex == openIndex) { - mOpenChar->GetStyleContext(aStyleContext); + return mOpenChar->GetStyleContext(); } else if (aIndex == closeIndex) { - mCloseChar->GetStyleContext(aStyleContext); + return mCloseChar->GetStyleContext(); } - return NS_OK; + return nsnull; } -NS_IMETHODIMP +void nsMathMLmfencedFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { PRInt32 openIndex = -1; PRInt32 closeIndex = -1; @@ -635,7 +632,7 @@ nsMathMLmfencedFrame::SetAdditionalStyleContext(PRInt32 aIndex, closeIndex = lastIndex; } if (aIndex < 0 || aIndex > lastIndex) { - return NS_ERROR_INVALID_ARG; + return; } if (aIndex < mSeparatorsCount) { @@ -647,5 +644,4 @@ nsMathMLmfencedFrame::SetAdditionalStyleContext(PRInt32 aIndex, else if (aIndex == closeIndex) { mCloseChar->SetStyleContext(aStyleContext); } - return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.h index 71b221ad5b3..27383263031 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.h @@ -34,12 +34,11 @@ class nsMathMLmfencedFrame : public nsMathMLContainerFrame { public: friend nsresult NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - NS_IMETHOD + virtual void SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); - NS_IMETHOD - GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; + nsStyleContext* aStyleContext); + virtual nsStyleContext* + GetAdditionalStyleContext(PRInt32 aIndex) const; NS_IMETHOD InheritAutomaticData(nsIPresContext* aPresContext, diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp index de132a3eb97..5e17881a191 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -99,7 +99,7 @@ NS_IMETHODIMP nsMathMLmfracFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -152,7 +152,7 @@ nsMathMLmfracFrame::TransmitAutomaticData(nsIPresContext* aPresContext) nscoord nsMathMLmfracFrame::CalcLineThickness(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsString& aThicknessAttribute, nscoord onePixel, nscoord aDefaultRuleThickness) @@ -548,36 +548,31 @@ nsMathMLmfracFrame::UpdatePresentationDataFromChildAt(nsIPresContext* aPresConte // ---------------------- // the Style System will use these to pass the proper style context to our MathMLChar -NS_IMETHODIMP -nsMathMLmfracFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLmfracFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(aStyleContext, "null OUT ptr"); - if (!mSlashChar || aIndex < 0) { - return NS_ERROR_INVALID_ARG; + if (!mSlashChar) { + return nsnull; } - *aStyleContext = nsnull; switch (aIndex) { case NS_SLASH_CHAR_STYLE_CONTEXT_INDEX: - mSlashChar->GetStyleContext(aStyleContext); + return mSlashChar->GetStyleContext(); break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -NS_IMETHODIMP +void nsMathMLmfracFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (!mSlashChar || aIndex < 0) { - return NS_ERROR_INVALID_ARG; + if (!mSlashChar) { + return; } switch (aIndex) { case NS_SLASH_CHAR_STYLE_CONTEXT_INDEX: mSlashChar->SetStyleContext(aStyleContext); break; } - return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h index 0eecfcfdc3e..ebfe0653bae 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h @@ -71,12 +71,11 @@ class nsMathMLmfracFrame : public nsMathMLContainerFrame { public: friend nsresult NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - NS_IMETHOD + virtual void SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); - NS_IMETHOD - GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; + nsStyleContext* aStyleContext); + virtual nsStyleContext* + GetAdditionalStyleContext(PRInt32 aIndex) const; NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, @@ -90,7 +89,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD @@ -132,7 +131,7 @@ public: // helper to translate the thickness attribute into a usable form static nscoord CalcLineThickness(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsString& aThicknessAttribute, nscoord onePixel, nscoord aDefaultRuleThickness); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp index 5927339b12f..75ea057abdb 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index 1812f9bafe8..c9bd3275792 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -1028,36 +1028,24 @@ nsMathMLmoFrame::AttributeChanged(nsIPresContext* aPresContext, // ---------------------- // No need to tract the style context given to our MathML char. // the Style System will use these to pass the proper style context to our MathMLChar -NS_IMETHODIMP -nsMathMLmoFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLmoFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(aStyleContext, "null OUT ptr"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX: - mMathMLChar.GetStyleContext(aStyleContext); - break; + return mMathMLChar.GetStyleContext(); default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -NS_IMETHODIMP +void nsMathMLmoFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX: mMathMLChar.SetStyleContext(aStyleContext); break; } - return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h index c1d7e4dd246..1ddbf1d70f8 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h @@ -38,12 +38,11 @@ public: NS_IMETHOD GetFrameType(nsIAtom** aType) const; - NS_IMETHOD + virtual void SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); - NS_IMETHOD - GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; + nsStyleContext* aStyleContext); + virtual nsStyleContext* + GetAdditionalStyleContext(PRInt32 aIndex) const; NS_IMETHOD Paint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp index 2b86d719b36..eb8d20a1503 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.cpp @@ -27,7 +27,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp index b9e8cc739ed..8e6ff575a1b 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp @@ -25,7 +25,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -293,7 +293,7 @@ nsMathMLmpaddedFrame::ParseAttribute(nsString& aString, void nsMathMLmpaddedFrame::UpdateValue(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRInt32 aSign, PRInt32 aPseudoUnit, nsCSSValue& aCSSValue, diff --git a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h index f61c554b633..8416202c7ae 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h @@ -78,7 +78,7 @@ private: static void UpdateValue(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRInt32 aSign, PRInt32 aPseudoUnit, nsCSSValue& aCSSValue, diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.cpp index 51469f4cacc..bbef79a6a59 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.cpp @@ -27,7 +27,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -81,7 +81,7 @@ NS_IMETHODIMP nsMathMLmrootFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -378,36 +378,25 @@ nsMathMLmrootFrame::Reflow(nsIPresContext* aPresContext, // ---------------------- // the Style System will use these to pass the proper style context to our MathMLChar -NS_IMETHODIMP -nsMathMLmrootFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLmrootFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(aStyleContext, "null OUT ptr"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_SQR_CHAR_STYLE_CONTEXT_INDEX: - mSqrChar.GetStyleContext(aStyleContext); + return mSqrChar.GetStyleContext(); break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -NS_IMETHODIMP +void nsMathMLmrootFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_SQR_CHAR_STYLE_CONTEXT_INDEX: mSqrChar.SetStyleContext(aStyleContext); break; } - return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.h index abd1241f790..45a6e3bd522 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmrootFrame.h @@ -35,18 +35,17 @@ class nsMathMLmrootFrame : public nsMathMLContainerFrame { public: friend nsresult NS_NewMathMLmrootFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - NS_IMETHOD + virtual void SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); - NS_IMETHOD - GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; + nsStyleContext* aStyleContext); + virtual nsStyleContext* + GetAdditionalStyleContext(PRInt32 aIndex) const; NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp index 58d44bae216..f8fc1801ad6 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp @@ -25,7 +25,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp index 8d1338a7d37..d99bafe18a1 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmspaceFrame.cpp @@ -24,7 +24,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp index c08307abe56..bddfa4ea8fe 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp @@ -27,7 +27,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" @@ -81,7 +81,7 @@ NS_IMETHODIMP nsMathMLmsqrtFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -297,36 +297,25 @@ nsMathMLmsqrtFrame::Reflow(nsIPresContext* aPresContext, // ---------------------- // the Style System will use these to pass the proper style context to our MathMLChar -NS_IMETHODIMP -nsMathMLmsqrtFrame::GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const +nsStyleContext* +nsMathMLmsqrtFrame::GetAdditionalStyleContext(PRInt32 aIndex) const { - NS_PRECONDITION(aStyleContext, "null OUT ptr"); - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } - *aStyleContext = nsnull; switch (aIndex) { case NS_SQR_CHAR_STYLE_CONTEXT_INDEX: - mSqrChar.GetStyleContext(aStyleContext); + return mSqrChar.GetStyleContext(); break; default: - return NS_ERROR_INVALID_ARG; + return nsnull; } - return NS_OK; } -NS_IMETHODIMP +void nsMathMLmsqrtFrame::SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { - if (aIndex < 0) { - return NS_ERROR_INVALID_ARG; - } switch (aIndex) { case NS_SQR_CHAR_STYLE_CONTEXT_INDEX: mSqrChar.SetStyleContext(aStyleContext); break; } - return NS_OK; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.h index 1592d0ce1ba..29f384f3979 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmsqrtFrame.h @@ -59,18 +59,17 @@ class nsMathMLmsqrtFrame : public nsMathMLContainerFrame { public: friend nsresult NS_NewMathMLmsqrtFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - NS_IMETHOD + virtual void SetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext* aStyleContext); - NS_IMETHOD - GetAdditionalStyleContext(PRInt32 aIndex, - nsIStyleContext** aStyleContext) const; + nsStyleContext* aStyleContext); + virtual nsStyleContext* + GetAdditionalStyleContext(PRInt32 aIndex) const; NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index 3f7d1321cf0..4054e2bd94d 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -25,7 +25,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp index ff80bc2e860..9fd242756d7 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp index 6acfeb5ecc4..6bd0bf4b102 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp @@ -26,7 +26,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp index c2dcf62faa6..6d65a95eaa8 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.cpp @@ -25,7 +25,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 8d5265fc723..9418c611d10 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -24,7 +24,7 @@ #include "nsAreaFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" @@ -420,7 +420,7 @@ NS_IMETHODIMP nsMathMLmtableOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { MapAttributesIntoCSS(aPresContext, aContent); @@ -691,7 +691,7 @@ NS_IMETHODIMP nsMathMLmtdInnerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h index d40cd31fd0f..7c7dea4f5b6 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h @@ -70,7 +70,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD @@ -147,7 +147,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp index 687a2cca9f7..03ee58625dd 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.cpp @@ -27,7 +27,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp index 1d8638a40ac..0ed60ed23f3 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp @@ -27,7 +27,7 @@ #include "nsFrame.h" #include "nsIPresContext.h" #include "nsUnitConversion.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsIRenderingContext.h" diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 39d8afbec3b..5655bfd8e0e 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -2585,13 +2585,10 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale, PRBool a nsIFrame * frame; aPO->mParent->mPresShell->GetPrimaryFrameFor(aPO->mContent, &frame); if (frame) { - nsCOMPtr sc; - frame->GetStyleContext(getter_AddRefs(sc)); - if (sc) { - const nsStyleVisibility* vis = (const nsStyleVisibility*)sc->GetStyleData(eStyleStruct_Visibility); - if (!vis->IsVisible()) { - aPO->mDontPrint = PR_TRUE; - } + const nsStyleVisibility* vis; + ::GetStyleData(frame, &vis); + if (!vis->IsVisible()) { + aPO->mDontPrint = PR_TRUE; } } } diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp index 88d21e667f1..3795eb52a37 100644 --- a/mozilla/layout/style/nsCSSStyleRule.cpp +++ b/mozilla/layout/style/nsCSSStyleRule.cpp @@ -73,6 +73,7 @@ #include "nsISizeOfHandler.h" #include "nsContentUtils.h" +#include "nsContentErrors.h" // #define DEBUG_REFS diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp index 9c5cf771a27..685367036d5 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.cpp +++ b/mozilla/layout/style/nsComputedDOMStyle.cpp @@ -44,7 +44,7 @@ #include "nsDOMError.h" #include "nsIDOMCSS2Properties.h" #include "nsIDOMElement.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIScrollableFrame.h" #include "nsContentUtils.h" #include "prprf.h" @@ -3034,18 +3034,16 @@ nsComputedDOMStyle::GetStyleData(nsStyleStructID aID, nsCOMPtr pctx; presShell->GetPresContext(getter_AddRefs(pctx)); if (pctx) { - nsCOMPtr sctx; + nsStyleContext* sctx; if (!mPseudo) { - pctx->ResolveStyleContextFor(mContent, nsnull, - getter_AddRefs(sctx)); + sctx = pctx->ResolveStyleContextFor(mContent, nsnull).get(); } else { - pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull, - getter_AddRefs(sctx)); + sctx = pctx->ResolvePseudoStyleContextFor(mContent, mPseudo, nsnull).get(); } if (sctx) { aStyleStruct = sctx->GetStyleData(aID); } - mStyleContextHolder = sctx; + mStyleContextHolder = dont_AddRef(sctx); // transfer ref from sctx } } NS_ASSERTION(aStyleStruct, "Failed to get a style struct"); diff --git a/mozilla/layout/style/nsComputedDOMStyle.h b/mozilla/layout/style/nsComputedDOMStyle.h index cdcd52b9dd3..e51d29ee2f4 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.h +++ b/mozilla/layout/style/nsComputedDOMStyle.h @@ -53,6 +53,7 @@ #include "nsIFrame.h" #include "nsCOMPtr.h" #include "nsWeakReference.h" +#include "nsAutoPtr.h" class nsComputedDOMStyle : public nsIComputedDOMStyle { @@ -302,7 +303,7 @@ private: * When a frame is unavailable, strong reference to the * style context while we're accessing the data from in. */ - nsCOMPtr mStyleContextHolder; + nsRefPtr mStyleContextHolder; nsCOMPtr mPseudo; float mT2P; /* For unit conversions */ diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 9400f2caa72..bd1ff22e153 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -42,7 +42,7 @@ #include "nsIStyleRuleProcessor.h" #include "nsIStyleRule.h" #include "nsIFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsHTMLAtoms.h" #include "nsIPresContext.h" #include "nsIEventStateManager.h" @@ -393,7 +393,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa { nsStyleText* text = (nsStyleText*)aStyleStruct; if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) { - nsCOMPtr parentContext = aRuleData->mStyleContext->GetParent(); + nsStyleContext* parentContext = aRuleData->mStyleContext->GetParent(); if (parentContext) { const nsStyleText* parentStyleText = @@ -426,7 +426,7 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct, { if (!aStyleStruct || !aRuleData || !aRuleData->mPresContext) return; - nsCOMPtr tableContext = aRuleData->mStyleContext->GetParent(); + nsStyleContext* tableContext = aRuleData->mStyleContext->GetParent(); if (!tableContext) return; if (!aGroup) { diff --git a/mozilla/layout/style/nsIStyleRuleProcessor.h b/mozilla/layout/style/nsIStyleRuleProcessor.h index 78f2f2ab24d..ac4a7517775 100644 --- a/mozilla/layout/style/nsIStyleRuleProcessor.h +++ b/mozilla/layout/style/nsIStyleRuleProcessor.h @@ -48,7 +48,6 @@ class nsISizeOfHandler; class nsIStyleSheet; -class nsIStyleContext; class nsIPresContext; class nsIContent; class nsIStyledContent; diff --git a/mozilla/layout/style/nsIStyleSheet.h b/mozilla/layout/style/nsIStyleSheet.h index a31423ebc5c..9e830d71dd3 100644 --- a/mozilla/layout/style/nsIStyleSheet.h +++ b/mozilla/layout/style/nsIStyleSheet.h @@ -51,7 +51,6 @@ class nsISupportsArray; class nsIPresContext; class nsIContent; class nsIDocument; -class nsIStyleContext; class nsIStyleRuleProcessor; // IID for the nsIStyleSheet interface {8c4a80a0-ad6a-11d1-8031-006008159b5a} diff --git a/mozilla/layout/style/nsInspectorCSSUtils.cpp b/mozilla/layout/style/nsInspectorCSSUtils.cpp index 9d073a32cd3..b327a0ab4b5 100644 --- a/mozilla/layout/style/nsInspectorCSSUtils.cpp +++ b/mozilla/layout/style/nsInspectorCSSUtils.cpp @@ -43,6 +43,8 @@ #include "nsLayoutAtoms.h" #include "nsIDocument.h" #include "nsIPresShell.h" +#include "nsAutoPtr.h" +#include "nsIFrame.h" nsInspectorCSSUtils::nsInspectorCSSUtils() { @@ -113,18 +115,12 @@ nsInspectorCSSUtils::AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect) return NS_OK; } -nsresult -nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame, - nsIStyleContext** aStyleContext) +nsStyleContext* +nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame) { - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); - if (!styleContext) { - // Caller returns rv on through, and this does not seem - // exception-worthy. - *aStyleContext = nsnull; - return NS_OK; - } + nsStyleContext* styleContext = aFrame->GetStyleContext(); + if (!styleContext) + return nsnull; /* For tables the primary frame is the "outer frame" but the style * rules are applied to the "inner frame". Luckily, the "outer @@ -133,45 +129,42 @@ nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame, */ nsCOMPtr frameType; aFrame->GetFrameType(getter_AddRefs(frameType)); - if (frameType == nsLayoutAtoms::tableOuterFrame) { - *aStyleContext = styleContext->GetParent().get(); - } else { - *aStyleContext = styleContext; - NS_ADDREF(*aStyleContext); - } - return NS_OK; + if (frameType == nsLayoutAtoms::tableOuterFrame) + return styleContext->GetParent(); + + return styleContext; } -nsresult +already_AddRefed nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, - nsIPresShell* aPresShell, - nsIStyleContext** aStyleContext) + nsIPresShell* aPresShell) { nsIFrame* frame = nsnull; aPresShell->GetPrimaryFrameFor(aContent, &frame); - if (frame) - return GetStyleContextForFrame(frame, aStyleContext); + if (frame) { + nsStyleContext* result = GetStyleContextForFrame(frame); + // this function returns an addrefed style context + if (result) + result->AddRef(); + return result; + } // No frame has been created, so resolve the style ourselves - nsCOMPtr parentContext; + nsRefPtr parentContext; nsCOMPtr parent; aContent->GetParent(*getter_AddRefs(parent)); - if (parent) { - nsresult rv = GetStyleContextForContent(parent, aPresShell, - getter_AddRefs(parentContext)); - NS_ENSURE_SUCCESS(rv, rv); - } + if (parent) + parentContext = GetStyleContextForContent(parent, aPresShell); nsCOMPtr presContext; aPresShell->GetPresContext(getter_AddRefs(presContext)); - NS_ENSURE_TRUE(presContext, NS_ERROR_UNEXPECTED); + if (!presContext) + return nsnull; if (aContent->IsContentOfType(nsIContent::eELEMENT)) - return presContext->ResolveStyleContextFor(aContent, parentContext, - aStyleContext); + return presContext->ResolveStyleContextFor(aContent, parentContext); - return presContext->ResolveStyleContextForNonElement(parentContext, - aStyleContext); + return presContext->ResolveStyleContextForNonElement(parentContext); } NS_IMETHODIMP @@ -188,10 +181,7 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent, doc->GetShellAt(0, getter_AddRefs(presShell)); NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED); - nsCOMPtr sContext; - nsresult rv = GetStyleContextForContent(aContent, presShell, - getter_AddRefs(sContext)); - NS_ENSURE_SUCCESS(rv, rv); - - return sContext->GetRuleNode(aRuleNode); + nsRefPtr sContext = GetStyleContextForContent(aContent, presShell); + sContext->GetRuleNode(aRuleNode); + return NS_OK; } diff --git a/mozilla/layout/style/nsInspectorCSSUtils.h b/mozilla/layout/style/nsInspectorCSSUtils.h index eef6a8176a3..65158b2b7a3 100644 --- a/mozilla/layout/style/nsInspectorCSSUtils.h +++ b/mozilla/layout/style/nsInspectorCSSUtils.h @@ -41,9 +41,10 @@ #define nsInspectorCSSUtils_h___ #include "nsIInspectorCSSUtils.h" +#include "nsStyleContext.h" +#include "nsAutoPtr.h" class nsIPresShell; -class nsIStyleContext; class nsInspectorCSSUtils : public nsIInspectorCSSUtils { @@ -64,11 +65,10 @@ public: nsRuleNode** aRuleNode); private: - nsresult GetStyleContextForContent(nsIContent* aContent, - nsIPresShell* aPresShell, - nsIStyleContext** aStyleContext); - nsresult GetStyleContextForFrame(nsIFrame* aFrame, - nsIStyleContext** aStyleContext); + already_AddRefed + GetStyleContextForContent(nsIContent* aContent, nsIPresShell* aPresShell); + + nsStyleContext* GetStyleContextForFrame(nsIFrame* aFrame); }; #endif /* nsInspectorCSSUtils_h___ */ diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 9d688900ec4..270f7bc6cef 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -52,6 +52,7 @@ #include "nsThemeConstants.h" #include "nsITheme.h" #include "pldhash.h" +#include "nsStyleContext.h" /* * For storage of an |nsRuleNode|'s children in a linked list. @@ -198,7 +199,7 @@ nsString& Unquote(nsString& aString) nscoord CalcLength(const nsCSSValue& aValue, const nsFont* aFont, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIPresContext* aPresContext, PRBool& aInherited) { @@ -269,7 +270,7 @@ nscoord CalcLength(const nsCSSValue& aValue, static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord, const nsStyleCoord& aParentCoord, - PRInt32 aMask, nsIStyleContext* aStyleContext, + PRInt32 aMask, nsStyleContext* aStyleContext, nsIPresContext* aPresContext, PRBool& aInherited) { PRBool result = PR_TRUE; @@ -1207,7 +1208,7 @@ nsRuleNode::CheckSpecifiedProperties(const nsStyleStructID aSID, } const nsStyleStruct* -nsRuleNode::GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetDisplayData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataDisplay displayData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Display, mPresContext, aContext); @@ -1221,7 +1222,7 @@ nsRuleNode::GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetVisibilityData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataDisplay displayData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Visibility, mPresContext, aContext); @@ -1231,7 +1232,7 @@ nsRuleNode::GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTextData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTextData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataText textData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Text, mPresContext, aContext); @@ -1241,7 +1242,7 @@ nsRuleNode::GetTextData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTextResetData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataText textData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_TextReset, mPresContext, aContext); @@ -1251,7 +1252,7 @@ nsRuleNode::GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetUserInterfaceData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataUserInterface uiData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_UserInterface, mPresContext, aContext); @@ -1263,7 +1264,7 @@ nsRuleNode::GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetUIResetData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataUserInterface uiData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_UIReset, mPresContext, aContext); @@ -1275,7 +1276,7 @@ nsRuleNode::GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetFontData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetFontData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataFont fontData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Font, mPresContext, aContext); @@ -1285,7 +1286,7 @@ nsRuleNode::GetFontData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetColorData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetColorData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataColor colorData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Color, mPresContext, aContext); @@ -1295,7 +1296,7 @@ nsRuleNode::GetColorData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetBackgroundData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataColor colorData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Background, mPresContext, aContext); @@ -1305,7 +1306,7 @@ nsRuleNode::GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetMarginData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetMarginData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Margin, mPresContext, aContext); @@ -1321,7 +1322,7 @@ nsRuleNode::GetMarginData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetBorderData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetBorderData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Border, mPresContext, aContext); @@ -1351,7 +1352,7 @@ nsRuleNode::GetBorderData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetPaddingData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Padding, mPresContext, aContext); @@ -1367,7 +1368,7 @@ nsRuleNode::GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetOutlineData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataMargin marginData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Outline, mPresContext, aContext); @@ -1383,7 +1384,7 @@ nsRuleNode::GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetListData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetListData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataList listData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_List, mPresContext, aContext); @@ -1398,7 +1399,7 @@ nsRuleNode::GetListData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetPositionData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetPositionData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataPosition posData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Position, mPresContext, aContext); @@ -1413,7 +1414,7 @@ nsRuleNode::GetPositionData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTableData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTableData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataTable tableData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Table, mPresContext, aContext); @@ -1423,7 +1424,7 @@ nsRuleNode::GetTableData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetTableBorderData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataTable tableData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_TableBorder, mPresContext, aContext); @@ -1433,7 +1434,7 @@ nsRuleNode::GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetContentData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetContentData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataContent contentData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Content, mPresContext, aContext); @@ -1446,7 +1447,7 @@ nsRuleNode::GetContentData(nsIStyleContext* aContext, PRBool aComputeData) } const nsStyleStruct* -nsRuleNode::GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetQuotesData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataContent contentData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Quotes, mPresContext, aContext); @@ -1459,7 +1460,7 @@ nsRuleNode::GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData) #ifdef INCLUDE_XUL const nsStyleStruct* -nsRuleNode::GetXULData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetXULData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataXUL xulData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_XUL, mPresContext, aContext); @@ -1471,7 +1472,7 @@ nsRuleNode::GetXULData(nsIStyleContext* aContext, PRBool aComputeData) #ifdef MOZ_SVG const nsStyleStruct* -nsRuleNode::GetSVGData(nsIStyleContext* aContext, PRBool aComputeData) +nsRuleNode::GetSVGData(nsStyleContext* aContext, PRBool aComputeData) { nsRuleDataSVG svgData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_SVG, mPresContext, aContext); @@ -1483,7 +1484,7 @@ nsRuleNode::GetSVGData(nsIStyleContext* aContext, PRBool aComputeData) const nsStyleStruct* nsRuleNode::WalkRuleTree(const nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData, PRBool aComputeData) @@ -1591,7 +1592,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID, // All information must necessarily be inherited from our parent style context. // In the absence of any computed data in the rule tree and with // no rules specified that didn't have values of 'inherit', we should check our parent. - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); if (parentContext) { // We have a parent, and so we should just inherit from the parent. // Set the inherit bits on our context. These bits tell the style context that @@ -1654,7 +1655,7 @@ IsChrome(nsIPresContext* aPresContext) } const nsStyleStruct* -nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext) +nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext) { switch (aSID) { case eStyleStruct_Font: @@ -1817,7 +1818,7 @@ nsRuleNode::gComputeStyleDataFn[] = { }; static void -SetFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, +SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aChromeOverride, PRBool aIsGeneric, const nsRuleDataFont& aFontData, const nsFont& aDefaultFont, const nsStyleFont* aParentFont, @@ -2106,14 +2107,14 @@ SetFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, // up to the root where default values come from the presentation context) // - re-apply cascading rules from there without caching intermediate values static void -SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, +SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext, const nsRuleDataFont& aFontData, PRUint8 aGenericFontID, nscoord aMinFontSize, PRBool aUseDocumentFonts, PRBool aChromeOverride, nsStyleFont* aFont) { // walk up the contexts until a context with the desired generic font nsAutoVoidArray contextPath; - nsCOMPtr higherContext = aContext->GetParent(); + nsStyleContext* higherContext = aContext->GetParent(); while (higherContext) { contextPath.AppendElement(higherContext); const nsStyleFont* higherFont = (const nsStyleFont*)higherContext->GetStyleData(eStyleStruct_Font); @@ -2135,7 +2136,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, PRInt32 i = contextPath.Count() - 1; PRBool zoom = PR_TRUE; if (higherContext) { - nsIStyleContext* context = (nsIStyleContext*)contextPath[i]; + nsStyleContext* context = (nsStyleContext*)contextPath[i]; nsStyleFont* tmpFont = (nsStyleFont*)context->GetStyleData(eStyleStruct_Font); parentFont.mFlags = tmpFont->mFlags; parentFont.mFont = tmpFont->mFont; @@ -2155,7 +2156,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, nsCOMPtr rule; for (; i >= 0; --i) { - nsIStyleContext* context = (nsIStyleContext*)contextPath[i]; + nsStyleContext* context = (nsStyleContext*)contextPath[i]; nsRuleDataFont fontData; // Declare a struct with null CSS values. nsRuleData ruleData(eStyleStruct_Font, aPresContext, context); ruleData.mFontData = &fontData; @@ -2203,11 +2204,11 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext, const nsStyleStruct* nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataFont& fontData = NS_STATIC_CAST(const nsRuleDataFont&, aData); nsStyleFont* font = nsnull; @@ -2333,11 +2334,11 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataText& textData = NS_STATIC_CAST(const nsRuleDataText&, aData); nsStyleText* text = nsnull; @@ -2454,11 +2455,11 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataText& textData = NS_STATIC_CAST(const nsRuleDataText&, aData); nsStyleTextReset* text; @@ -2537,12 +2538,12 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataUserInterface& uiData = NS_STATIC_CAST(const nsRuleDataUserInterface&, aData); nsStyleUserInterface* ui = nsnull; @@ -2649,11 +2650,11 @@ nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataUserInterface& uiData = NS_STATIC_CAST(const nsRuleDataUserInterface&, aData); nsStyleUIReset* ui; @@ -2739,11 +2740,11 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsStyleStruct* nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataDisplay& displayData = NS_STATIC_CAST(const nsRuleDataDisplay&, aData); nsStyleDisplay* display; @@ -2755,8 +2756,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, display = new (mPresContext) nsStyleDisplay(); const nsStyleDisplay* parentDisplay = display; - nsCOMPtr pseudoTag; - aContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsCOMPtr pseudoTag = aContext->GetPseudoType(); PRBool generatedContent = (pseudoTag == nsCSSPseudoElements::before || pseudoTag == nsCSSPseudoElements::after); @@ -2998,11 +2998,11 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataDisplay& displayData = NS_STATIC_CAST(const nsRuleDataDisplay&, aData); nsStyleVisibility* visibility = nsnull; @@ -3107,11 +3107,11 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataColor& colorData = NS_STATIC_CAST(const nsRuleDataColor&, aData); nsStyleColor* color = nsnull; @@ -3164,11 +3164,11 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataColor& colorData = NS_STATIC_CAST(const nsRuleDataColor&, aData); nsStyleBackground* bg; @@ -3354,11 +3354,11 @@ static const CSSRectSide gCSSSides[] = { const nsStyleStruct* nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleMargin* margin; @@ -3411,11 +3411,11 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleBorder* border; @@ -3517,7 +3517,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, // computed (unlike for the element where this will be used, for // which the color could be specified on a more specific rule). const nsStyleColor *parentColor; - ::GetStyleData(parentContext.get(), &parentColor); + ::GetStyleData(parentContext, &parentColor); border->SetBorderColor(side, parentColor->mColor); } else border->SetBorderColor(side, borderColor); @@ -3579,11 +3579,11 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStylePadding* padding; @@ -3636,11 +3636,11 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataMargin& marginData = NS_STATIC_CAST(const nsRuleDataMargin&, aData); nsStyleOutline* outline; @@ -3709,11 +3709,11 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataList& listData = NS_STATIC_CAST(const nsRuleDataList&, aData); nsStyleList* list = nsnull; @@ -3826,11 +3826,11 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataPosition& posData = NS_STATIC_CAST(const nsRuleDataPosition&, aData); nsStylePosition* pos; @@ -3935,11 +3935,11 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataTable& tableData = NS_STATIC_CAST(const nsRuleDataTable&, aData); nsStyleTable* table; @@ -4006,11 +4006,11 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataTable& tableData = NS_STATIC_CAST(const nsRuleDataTable&, aData); nsStyleTableBorder* table = nsnull; @@ -4105,11 +4105,11 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataContent& contentData = NS_STATIC_CAST(const nsRuleDataContent&, aData); nsStyleContent* content; @@ -4301,11 +4301,11 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataContent& contentData = NS_STATIC_CAST(const nsRuleDataContent&, aData); nsStyleQuotes* quotes = nsnull; @@ -4395,11 +4395,11 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsStyleStruct* nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); const nsRuleDataXUL& xulData = NS_STATIC_CAST(const nsRuleDataXUL&, aData); nsStyleXUL* xul = nsnull; @@ -4517,7 +4517,7 @@ SetSVGOpacity(const nsCSSValue& aValue, float parentOpacity, float& opacity, PRB static void SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length, - nsIStyleContext* aContext, nsIPresContext* aPresContext, PRBool& aInherited) + nsStyleContext* aContext, nsIPresContext* aPresContext, PRBool& aInherited) { nsStyleCoord coord; PRBool dummy; @@ -4545,11 +4545,11 @@ SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length, const nsStyleStruct* nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited) { - nsCOMPtr parentContext = aContext->GetParent(); + nsStyleContext* parentContext = aContext->GetParent(); nsStyleSVG* svg = nsnull; nsStyleSVG* parentSVG = svg; @@ -4692,7 +4692,7 @@ nsRuleNode::gGetStyleDataFn[] = { const nsStyleStruct* nsRuleNode::GetStyleData(nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, PRBool aComputeData) { const nsStyleStruct* cachedData = mStyleData.GetStyleData(aSID); diff --git a/mozilla/layout/style/nsRuleNode.h b/mozilla/layout/style/nsRuleNode.h index 746e6dd01df..fe978d1ab8c 100644 --- a/mozilla/layout/style/nsRuleNode.h +++ b/mozilla/layout/style/nsRuleNode.h @@ -42,13 +42,13 @@ #include "nsCOMPtr.h" #include "nsIStyleRule.h" -#include "nsIFrame.h" #include "nsFixedSizeAllocator.h" #include "nsIPresContext.h" #include "nsCSSDeclaration.h" #include "nsILanguageAtomService.h" +#include "nsStyleStruct.h" -class nsIStyleContext; +class nsStyleContext; struct nsRuleList; struct PLDHashTable; @@ -245,7 +245,7 @@ struct nsRuleData nsStyleStructID mSID; PRPackedBool mCanStoreInRuleTree; nsIPresContext* mPresContext; - nsIStyleContext* mStyleContext; + nsStyleContext* mStyleContext; nsPostResolveFunc mPostResolveCallback; nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! nsRuleDataDisplay* mDisplayData; @@ -266,7 +266,7 @@ struct nsRuleData nsRuleDataSVG* mSVGData; #endif - nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext) + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), @@ -409,89 +409,89 @@ protected: void PropagateDependentBit(PRUint32 aBit, nsRuleNode* aHighestNode); void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode); - const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext); + const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext); - const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsIStyleContext* aContext, + const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext, nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData, PRBool aComputeData); const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsRuleDataStruct& aDisplayData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsRuleDataStruct& aDisplayData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsRuleDataStruct& aFontData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsRuleDataStruct& aColorData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsRuleDataStruct& aColorData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsRuleDataStruct& aMarginData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsRuleDataStruct& aListData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsRuleDataStruct& aPositionData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData, - nsIStyleContext* aContext, nsRuleNode* aHighestNode, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeUserInterfaceData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #ifdef INCLUDE_XUL const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsRuleDataStruct& aXULData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #endif #ifdef MOZ_SVG const nsStyleStruct* ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); #endif @@ -499,7 +499,7 @@ protected: typedef const nsStyleStruct* (nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct, const nsRuleDataStruct& aStartData, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); @@ -509,33 +509,33 @@ protected: inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct); const nsStyleStruct* GetParentData(const nsStyleStructID aSID); - const nsStyleStruct* GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetFontData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetColorData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetMarginData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetBorderData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetListData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetPositionData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTableData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetContentData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTextData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetUserInterfaceData(nsIStyleContext* aContext, PRBool aComputeData); - const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetDisplayData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetVisibilityData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetFontData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetColorData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetBackgroundData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetMarginData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetBorderData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetPaddingData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetOutlineData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetListData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetPositionData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTableData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTableBorderData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetContentData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetQuotesData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTextData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetTextResetData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetUserInterfaceData(nsStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetUIResetData(nsStyleContext* aContext, PRBool aComputeData); #ifdef INCLUDE_XUL - const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetXULData(nsStyleContext* aContext, PRBool aComputeData); #endif #ifdef MOZ_SVG - const nsStyleStruct* GetSVGData(nsIStyleContext* aContext, PRBool aComputeData); + const nsStyleStruct* GetSVGData(nsStyleContext* aContext, PRBool aComputeData); #endif - typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*, PRBool); + typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsStyleContext*, PRBool); static GetStyleDataFn gGetStyleDataFn[]; public: @@ -568,7 +568,7 @@ public: nsresult GetPresContext(nsIPresContext** aResult); nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched); const nsStyleStruct* GetStyleData(nsStyleStructID aSID, - nsIStyleContext* aContext, + nsStyleContext* aContext, PRBool aComputeData); }; diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index 13428a4cd56..ed785cfac24 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -54,6 +54,7 @@ #include "nsRuleNode.h" #include "nsUnitConversion.h" +#include "nsStyleContext.h" #ifdef DEBUG // #define NOISY_DEBUG @@ -61,87 +62,8 @@ //---------------------------------------------------------------------- -class nsStyleContext : public nsIStyleContext -{ -public: - nsStyleContext(nsIStyleContext* aParent, nsIAtom* aPseudoTag, - nsRuleNode* aRuleNode, nsIPresContext* aPresContext); - virtual ~nsStyleContext(); - void* operator new(size_t sz, nsIPresContext* aPresContext) CPP_THROW_NEW; - void Destroy(); - - NS_DECL_ISUPPORTS - - virtual already_AddRefed GetParent(void) const; - NS_IMETHOD GetFirstChild(nsIStyleContext** aContext); - - NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const; - - NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules, - nsIStyleContext*& aResult); - - virtual PRBool Equals(const nsIStyleContext* aOther) const; - virtual PRBool HasTextDecorations() { return mBits & NS_STYLE_HAS_TEXT_DECORATIONS; }; - - NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding); - - NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct); - NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct); - - NS_IMETHOD GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; return NS_OK; }; - NS_IMETHOD AddStyleBit(const PRUint32& aBit) { mBits |= aBit; return NS_OK; }; - NS_IMETHOD GetStyleBits(PRUint32* aBits) { *aBits = mBits; return NS_OK; }; - - virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID); - const nsStyleStruct* PeekStyleData(nsStyleStructID aSID); - - virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID); - - virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule); - - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule); - - NS_IMETHOD CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint); - -#ifdef DEBUG - virtual void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); - - virtual void List(FILE* out, PRInt32 aIndent); - - virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize); -#endif - -protected: - void AppendChild(nsStyleContext* aChild); - void RemoveChild(nsStyleContext* aChild); - - void ApplyStyleFixups(nsIPresContext* aPresContext); - - nsStyleContext* mParent; - nsStyleContext* mChild; - nsStyleContext* mEmptyChild; - nsStyleContext* mPrevSibling; - nsStyleContext* mNextSibling; - - // If this style context is for a pseudo-element, the pseudo-element - // atom. Otherwise, null. - nsCOMPtr mPseudoTag; - - nsRuleNode* mRuleNode; - - // |mCachedStyleData| points to both structs that are owned by this - // style context and structs that are owned by one of this style - // context's ancestors (which are indirectly owned since this style - // context owns a reference to its parent). If the bit in |mBits| is - // set for a struct, that means that the pointer for that struct is - // owned by an ancestor rather than by this style context. - nsCachedStyleData mCachedStyleData; // Our cached style data. - PRUint32 mBits; // Which structs are inherited from the - // parent context. -}; - -nsStyleContext::nsStyleContext(nsIStyleContext* aParent, +nsStyleContext::nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag, nsRuleNode* aRuleNode, nsIPresContext* aPresContext) @@ -150,13 +72,13 @@ nsStyleContext::nsStyleContext(nsIStyleContext* aParent, mEmptyChild(nsnull), mPseudoTag(aPseudoTag), mRuleNode(aRuleNode), - mBits(0) + mBits(0), + mRefCnt(0) { - mNextSibling = this; mPrevSibling = this; if (mParent) { - NS_ADDREF(mParent); + mParent->AddRef(); mParent->AppendChild(this); } @@ -173,7 +95,7 @@ nsStyleContext::~nsStyleContext() if (mParent) { mParent->RemoveChild(this); - NS_RELEASE(mParent); + mParent->Release(); } // Free up our data structs. @@ -184,24 +106,6 @@ nsStyleContext::~nsStyleContext() } } -NS_IMPL_ADDREF(nsStyleContext) -NS_IMPL_RELEASE_WITH_DESTROY(nsStyleContext, Destroy()) -NS_IMPL_QUERY_INTERFACE1(nsStyleContext, nsIStyleContext) - -already_AddRefed nsStyleContext::GetParent(void) const -{ - NS_IF_ADDREF(mParent); - return mParent; -} - -NS_IMETHODIMP -nsStyleContext::GetFirstChild(nsIStyleContext** aContext) -{ - *aContext = mChild; - NS_IF_ADDREF(*aContext); - return NS_OK; -} - void nsStyleContext::AppendChild(nsStyleContext* aChild) { if (aChild->mRuleNode->IsRoot()) { @@ -263,23 +167,22 @@ void nsStyleContext::RemoveChild(nsStyleContext* aChild) aChild->mPrevSibling = aChild; } -NS_IMETHODIMP -nsStyleContext::GetPseudoType(nsIAtom*& aPseudoTag) const +already_AddRefed +nsStyleContext::GetPseudoType() const { - aPseudoTag = mPseudoTag; - NS_IF_ADDREF(aPseudoTag); - return NS_OK; + nsIAtom* pseudoTag = mPseudoTag; + NS_IF_ADDREF(pseudoTag); + return pseudoTag; } -NS_IMETHODIMP +already_AddRefed nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag, - nsRuleNode* aRuleNode, - nsIStyleContext*& aResult) + nsRuleNode* aRuleNode) { PRUint32 threshold = 10; // The # of siblings we're willing to examine // before just giving this whole thing up. - aResult = nsnull; + nsStyleContext* aResult = nsnull; if ((nsnull != mChild) || (nsnull != mEmptyChild)) { nsStyleContext* child; @@ -313,12 +216,15 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag, } while (child != mChild); } } - NS_IF_ADDREF(aResult); - return NS_OK; + + if (aResult) + aResult->AddRef(); + + return aResult; } -PRBool nsStyleContext::Equals(const nsIStyleContext* aOther) const +PRBool nsStyleContext::Equals(const nsStyleContext* aOther) const { PRBool result = PR_TRUE; const nsStyleContext* other = (nsStyleContext*)aOther; @@ -358,7 +264,7 @@ inline const nsStyleStruct* nsStyleContext::PeekStyleData(nsStyleStructID aSID) return mRuleNode->GetStyleData(aSID, this, PR_FALSE); // Our rule node will take care of it for us. } -NS_IMETHODIMP +void nsStyleContext::GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding) { nsMargin border, padding; @@ -370,8 +276,6 @@ nsStyleContext::GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding) aBorderPadding.SetBorderPadding(border); } } - - return NS_OK; } // This is an evil evil function, since it forces you to alloc your own separate copy of @@ -421,14 +325,7 @@ nsStyleContext::GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleSt return result; } -NS_IMETHODIMP -nsStyleContext::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) -{ - *aStruct = GetStyleData(aSID); - return NS_OK; -} - -NS_IMETHODIMP +void nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) { // This method should only be called from nsRuleNode! It is not a public @@ -461,8 +358,6 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) } char* dataSlot = resetOrInherit + info.mInheritResetOffset; *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot) = aStruct; - - return NS_OK; } void @@ -497,7 +392,7 @@ nsStyleContext::ApplyStyleFixups(nsIPresContext* aPresContext) } } -nsresult +void nsStyleContext::ClearCachedDataForRule(nsIStyleRule* aInlineStyleRule) { mRuleNode->ClearCachedData(aInlineStyleRule); // XXXdwh. If we're willing to *really* special case @@ -505,10 +400,9 @@ nsStyleContext::ClearCachedDataForRule(nsIStyleRule* aInlineStyleRule) // that actually changed. For example, if someone changes // style.left, we really only need to blow away cached // data in the position struct. - return NS_OK; } -nsresult +void nsStyleContext::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule) { PRBool matched = PR_TRUE; @@ -541,13 +435,12 @@ nsStyleContext::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule child = child->mNextSibling; } while (mEmptyChild != child); } - - return NS_OK; } -NS_IMETHODIMP -nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint) +nsChangeHint +nsStyleContext::CalcStyleDifference(nsStyleContext* aOther) { + nsChangeHint hint = NS_STYLE_HINT_NONE; if (aOther) { // If our rule nodes are the same, then we are looking at the same style // data. We know this because CalcStyleDifference is always called on two @@ -557,72 +450,70 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint nsRuleNode* ruleNode; aOther->GetRuleNode(&ruleNode); if (ruleNode == mRuleNode) - return NS_OK; + return hint; nsChangeHint maxHint = NS_STYLE_HINT_FRAMECHANGE; // We begin by examining those style structs that are capable of causing the maximal // difference, a FRAMECHANGE. // FRAMECHANGE Structs: Display, XUL, Content, UserInterface, Visibility, Quotes - if (!NS_IsHintSubset(maxHint, aHint)) { - const nsStyleDisplay* display = (const nsStyleDisplay*)PeekStyleData(eStyleStruct_Display); - if (display) { - const nsStyleDisplay* otherDisplay = (const nsStyleDisplay*)aOther->GetStyleData(eStyleStruct_Display); - if (display != otherDisplay) { - NS_UpdateHint(aHint, display->CalcDifference(*otherDisplay)); - } + const nsStyleDisplay* display = (const nsStyleDisplay*)PeekStyleData(eStyleStruct_Display); + if (display) { + const nsStyleDisplay* otherDisplay = (const nsStyleDisplay*)aOther->GetStyleData(eStyleStruct_Display); + if (display != otherDisplay) { + NS_UpdateHint(hint, display->CalcDifference(*otherDisplay)); } } #ifdef INCLUDE_XUL - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleXUL* xul = (const nsStyleXUL*)PeekStyleData(eStyleStruct_XUL); if (xul) { const nsStyleXUL* otherXUL = (const nsStyleXUL*)aOther->GetStyleData(eStyleStruct_XUL); if (xul != otherXUL) { - NS_UpdateHint(aHint, xul->CalcDifference(*otherXUL)); + NS_UpdateHint(hint, xul->CalcDifference(*otherXUL)); } } } #endif - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleContent* content = (const nsStyleContent*)PeekStyleData(eStyleStruct_Content); if (content) { const nsStyleContent* otherContent = (const nsStyleContent*)aOther->GetStyleData(eStyleStruct_Content); if (content != otherContent) { - NS_UpdateHint(aHint, content->CalcDifference(*otherContent)); + NS_UpdateHint(hint, content->CalcDifference(*otherContent)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleUserInterface* ui = (const nsStyleUserInterface*)PeekStyleData(eStyleStruct_UserInterface); if (ui) { const nsStyleUserInterface* otherUI = (const nsStyleUserInterface*)aOther->GetStyleData(eStyleStruct_UserInterface); if (ui != otherUI) { - NS_UpdateHint(aHint, ui->CalcDifference(*otherUI)); + NS_UpdateHint(hint, ui->CalcDifference(*otherUI)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleVisibility* vis = (const nsStyleVisibility*)PeekStyleData(eStyleStruct_Visibility); if (vis) { const nsStyleVisibility* otherVis = (const nsStyleVisibility*)aOther->GetStyleData(eStyleStruct_Visibility); if (vis != otherVis) { - NS_UpdateHint(aHint, vis->CalcDifference(*otherVis)); + NS_UpdateHint(hint, vis->CalcDifference(*otherVis)); } } } #ifdef MOZ_SVG - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleSVG* svg = (const nsStyleSVG*)PeekStyleData(eStyleStruct_SVG); if (svg) { const nsStyleSVG* otherSVG = (const nsStyleSVG*)aOther->GetStyleData(eStyleStruct_SVG); if (svg != otherSVG) { - NS_UpdateHint(aHint, svg->CalcDifference(*otherSVG)); + NS_UpdateHint(hint, svg->CalcDifference(*otherSVG)); } } } @@ -630,12 +521,12 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // If the quotes implementation is ever going to change we might not need // a framechange here and a reflow should be sufficient. See bug 35768. - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleQuotes* quotes = (const nsStyleQuotes*)PeekStyleData(eStyleStruct_Quotes); if (quotes) { const nsStyleQuotes* otherQuotes = (const nsStyleQuotes*)aOther->GetStyleData(eStyleStruct_Quotes); if (quotes != otherQuotes) { - NS_UpdateHint(aHint, quotes->CalcDifference(*otherQuotes)); + NS_UpdateHint(hint, quotes->CalcDifference(*otherQuotes)); } } } @@ -646,102 +537,102 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // The following structs cause (as their maximal difference) a reflow to occur. // REFLOW Structs: Font, Margin, Padding, Border, List, Position, Text, TextReset, // Table, TableBorder - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleFont* font = (const nsStyleFont*)PeekStyleData(eStyleStruct_Font); if (font) { const nsStyleFont* otherFont = (const nsStyleFont*)aOther->GetStyleData(eStyleStruct_Font); if (font != otherFont) { - NS_UpdateHint(aHint, font->CalcDifference(*otherFont)); + NS_UpdateHint(hint, font->CalcDifference(*otherFont)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleMargin* margin = (const nsStyleMargin*)PeekStyleData(eStyleStruct_Margin); if (margin) { const nsStyleMargin* otherMargin = (const nsStyleMargin*)aOther->GetStyleData(eStyleStruct_Margin); if (margin != otherMargin) { - NS_UpdateHint(aHint, margin->CalcDifference(*otherMargin)); + NS_UpdateHint(hint, margin->CalcDifference(*otherMargin)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStylePadding* padding = (const nsStylePadding*)PeekStyleData(eStyleStruct_Padding); if (padding) { const nsStylePadding* otherPadding = (const nsStylePadding*)aOther->GetStyleData(eStyleStruct_Padding); if (padding != otherPadding) { - NS_UpdateHint(aHint, padding->CalcDifference(*otherPadding)); + NS_UpdateHint(hint, padding->CalcDifference(*otherPadding)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleBorder* border = (const nsStyleBorder*)PeekStyleData(eStyleStruct_Border); if (border) { const nsStyleBorder* otherBorder = (const nsStyleBorder*)aOther->GetStyleData(eStyleStruct_Border); if (border != otherBorder) { - NS_UpdateHint(aHint, border->CalcDifference(*otherBorder)); + NS_UpdateHint(hint, border->CalcDifference(*otherBorder)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleList* list = (const nsStyleList*)PeekStyleData(eStyleStruct_List); if (list) { const nsStyleList* otherList = (const nsStyleList*)aOther->GetStyleData(eStyleStruct_List); if (list != otherList) { - NS_UpdateHint(aHint, list->CalcDifference(*otherList)); + NS_UpdateHint(hint, list->CalcDifference(*otherList)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStylePosition* pos = (const nsStylePosition*)PeekStyleData(eStyleStruct_Position); if (pos) { const nsStylePosition* otherPosition = (const nsStylePosition*)aOther->GetStyleData(eStyleStruct_Position); if (pos != otherPosition) { - NS_UpdateHint(aHint, pos->CalcDifference(*otherPosition)); + NS_UpdateHint(hint, pos->CalcDifference(*otherPosition)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleText* text = (const nsStyleText*)PeekStyleData(eStyleStruct_Text); if (text) { const nsStyleText* otherText = (const nsStyleText*)aOther->GetStyleData(eStyleStruct_Text); if (text != otherText) { - NS_UpdateHint(aHint, text->CalcDifference(*otherText)); + NS_UpdateHint(hint, text->CalcDifference(*otherText)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTextReset* text = (const nsStyleTextReset*)PeekStyleData(eStyleStruct_TextReset); if (text) { const nsStyleTextReset* otherText = (const nsStyleTextReset*)aOther->GetStyleData(eStyleStruct_TextReset); if (text != otherText) { - NS_UpdateHint(aHint, text->CalcDifference(*otherText)); + NS_UpdateHint(hint, text->CalcDifference(*otherText)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTable* table = (const nsStyleTable*)PeekStyleData(eStyleStruct_Table); if (table) { const nsStyleTable* otherTable = (const nsStyleTable*)aOther->GetStyleData(eStyleStruct_Table); if (table != otherTable) { - NS_UpdateHint(aHint, table->CalcDifference(*otherTable)); + NS_UpdateHint(hint, table->CalcDifference(*otherTable)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleTableBorder* table = (const nsStyleTableBorder*)PeekStyleData(eStyleStruct_TableBorder); if (table) { const nsStyleTableBorder* otherTable = (const nsStyleTableBorder*)aOther->GetStyleData(eStyleStruct_TableBorder); if (table != otherTable) { - NS_UpdateHint(aHint, table->CalcDifference(*otherTable)); + NS_UpdateHint(hint, table->CalcDifference(*otherTable)); } } } @@ -752,47 +643,47 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint // The following structs cause (as their maximal difference) a re-render to occur. // VISUAL Structs: Color, Background, Outline, UIReset - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleColor* color = (const nsStyleColor*)PeekStyleData(eStyleStruct_Color); if (color) { const nsStyleColor* otherColor = (const nsStyleColor*)aOther->GetStyleData(eStyleStruct_Color); if (color != otherColor) { - NS_UpdateHint(aHint, color->CalcDifference(*otherColor)); + NS_UpdateHint(hint, color->CalcDifference(*otherColor)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleBackground* background = (const nsStyleBackground*)PeekStyleData(eStyleStruct_Background); if (background) { const nsStyleBackground* otherBackground = (const nsStyleBackground*)aOther->GetStyleData(eStyleStruct_Background); if (background != otherBackground) { - NS_UpdateHint(aHint, background->CalcDifference(*otherBackground)); + NS_UpdateHint(hint, background->CalcDifference(*otherBackground)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleOutline* outline = (const nsStyleOutline*)PeekStyleData(eStyleStruct_Outline); if (outline) { const nsStyleOutline* otherOutline = (const nsStyleOutline*)aOther->GetStyleData(eStyleStruct_Outline); if (outline != otherOutline) { - NS_UpdateHint(aHint, outline->CalcDifference(*otherOutline)); + NS_UpdateHint(hint, outline->CalcDifference(*otherOutline)); } } } - if (!NS_IsHintSubset(maxHint, aHint)) { + if (!NS_IsHintSubset(maxHint, hint)) { const nsStyleUIReset* ui = (const nsStyleUIReset*)PeekStyleData(eStyleStruct_UIReset); if (ui) { const nsStyleUIReset* otherUI = (const nsStyleUIReset*)aOther->GetStyleData(eStyleStruct_UIReset); if (ui != otherUI) { - NS_UpdateHint(aHint, ui->CalcDifference(*otherUI)); + NS_UpdateHint(hint, ui->CalcDifference(*otherUI)); } } } } - return NS_OK; + return hint; } #ifdef DEBUG @@ -802,7 +693,7 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent) PRInt32 ix; for (ix = aIndent; --ix >= 0; ) fputs(" ", out); fprintf(out, "%p(%d) parent=%p ", - (void*)this, mRefCnt.get(), (void *)mParent); + (void*)this, mRefCnt, (void *)mParent); if (mPseudoTag) { nsAutoString buffer; mPseudoTag->ToString(buffer); @@ -1176,24 +1067,16 @@ nsStyleContext::Destroy() presContext->FreeToShell(sizeof(nsStyleContext), this); } -NS_EXPORT nsresult -NS_NewStyleContext(nsIStyleContext** aInstancePtrResult, - nsIStyleContext* aParentContext, +already_AddRefed +NS_NewStyleContext(nsStyleContext* aParentContext, nsIAtom* aPseudoTag, nsRuleNode* aRuleNode, nsIPresContext* aPresContext) { - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag, aRuleNode, aPresContext); - if (!context) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return CallQueryInterface(context, aInstancePtrResult); + if (context) + context->AddRef(); + return context; } diff --git a/mozilla/layout/style/nsStyleContext.h b/mozilla/layout/style/nsStyleContext.h new file mode 100644 index 00000000000..974f6bb87eb --- /dev/null +++ b/mozilla/layout/style/nsStyleContext.h @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Hyatt + * Pierre Phaneuf + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _nsStyleContext_h_ +#define _nsStyleContext_h_ + +#include "nsRuleNode.h" + +class nsIPresContext; +class nsIAtom; + +class nsStyleContext +{ +public: + nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag, + nsRuleNode* aRuleNode, nsIPresContext* aPresContext); + ~nsStyleContext(); + + void* operator new(size_t sz, nsIPresContext* aPresContext) CPP_THROW_NEW; + void Destroy(); + + void AddRef() { + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsStyleContext", sizeof(nsStyleContext)); + } + + void Release() { + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsStyleContext"); + if (mRefCnt == 0) { + mRefCnt = 1; + Destroy(); + } + } + + nsStyleContext* GetParent() const { return mParent; } + + nsStyleContext* GetFirstChild() const { return mChild; } + + already_AddRefed GetPseudoType() const; + + already_AddRefed + FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules); + + PRBool Equals(const nsStyleContext* aOther) const; + PRBool HasTextDecorations() { return mBits & NS_STYLE_HAS_TEXT_DECORATIONS; }; + + void GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding); + + void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct); + + void GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; } + void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; } + void GetStyleBits(PRUint32* aBits) { *aBits = mBits; } + + const nsStyleStruct* GetStyleData(nsStyleStructID aSID); + const nsStyleStruct* PeekStyleData(nsStyleStructID aSID); + + nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID); + + void ClearCachedDataForRule(nsIStyleRule* aRule); + + void ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule); + + nsChangeHint CalcStyleDifference(nsStyleContext* aOther); + +#ifdef DEBUG + void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); + + void List(FILE* out, PRInt32 aIndent); + + void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize); +#endif + +protected: + void AppendChild(nsStyleContext* aChild); + void RemoveChild(nsStyleContext* aChild); + + void ApplyStyleFixups(nsIPresContext* aPresContext); + + nsStyleContext* mParent; + nsStyleContext* mChild; + nsStyleContext* mEmptyChild; + nsStyleContext* mPrevSibling; + nsStyleContext* mNextSibling; + + // If this style context is for a pseudo-element, the pseudo-element + // atom. Otherwise, null. + nsCOMPtr mPseudoTag; + + nsRuleNode* mRuleNode; + + // |mCachedStyleData| points to both structs that are owned by this + // style context and structs that are owned by one of this style + // context's ancestors (which are indirectly owned since this style + // context owns a reference to its parent). If the bit in |mBits| is + // set for a struct, that means that the pointer for that struct is + // owned by an ancestor rather than by this style context. + nsCachedStyleData mCachedStyleData; // Our cached style data. + PRUint32 mBits; // Which structs are inherited from the + // parent context. + PRUint32 mRefCnt; +}; + +already_AddRefed +NS_NewStyleContext(nsStyleContext* aParentContext, + nsIAtom* aPseudoTag, + nsRuleNode* aRuleNode, + nsIPresContext* aPresContext); + + +// typesafe way to access style data. See nsStyleStruct.h and also +// overloaded function in nsIFrame.h. +template +inline void +GetStyleData(nsStyleContext* aStyleContext, const T** aStyleStruct) +{ + *aStyleStruct = NS_STATIC_CAST(const T*, + aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T))); +} + +#endif diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index cec07984b8f..9e4c35e439a 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -149,24 +149,27 @@ public: NS_IMETHOD NotifyStyleSheetStateChanged(PRBool aDisabled); - virtual nsIStyleContext* ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ResolveStyleFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aParentContext); - virtual nsIStyleContext* ResolveStyleForNonElement( - nsIPresContext* aPresContext, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ResolveStyleForNonElement(nsIPresContext* aPresContext, + nsStyleContext* aParentContext); - virtual nsIStyleContext* ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator = nsnull); + virtual already_AddRefed + ResolvePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator = nsnull); - virtual nsIStyleContext* ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext); + virtual already_AddRefed + ProbePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext); NS_IMETHOD Shutdown(); @@ -189,7 +192,7 @@ public: virtual nsresult AddRuleNodeMapping(nsRuleNode* aRuleNode); - virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext); + virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsStyleContext* aContext); virtual nsresult GetStyleFrameConstruction(nsIStyleFrameConstruction** aResult) { *aResult = mFrameConstructor; @@ -197,10 +200,10 @@ public: return NS_OK; } - NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, - nsIStyleContext* aNewParentContext, - nsIStyleContext** aNewStyleContext); + virtual already_AddRefed + ReParentStyleContext(nsIPresContext* aPresContext, + nsStyleContext* aStyleContext, + nsStyleContext* aNewParentContext); NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext, nsIContent* aContent, @@ -335,9 +338,9 @@ protected: void WalkRuleProcessors(nsISupportsArrayEnumFunc aFunc, RuleProcessorData* aData); - nsIStyleContext* GetContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - nsIAtom* aPseudoTag); + already_AddRefed GetContext(nsIPresContext* aPresContext, + nsStyleContext* aParentContext, + nsIAtom* aPseudoTag); #ifdef DEBUG void List(FILE* out, PRInt32 aIndent, nsISupportsArray* aSheets); @@ -999,15 +1002,16 @@ EnumRulesMatching(nsISupports* aProcessor, void* aData) * generation. (It works for cousins of the same generation since * |aParentContext| could itself be a shared context.) */ -nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - nsIAtom* aPseudoTag) +already_AddRefed +StyleSetImpl::GetContext(nsIPresContext* aPresContext, + nsStyleContext* aParentContext, + nsIAtom* aPseudoTag) { - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode(); if (aParentContext) - aParentContext->FindChildWithRules(aPseudoTag, ruleNode, result); + result = aParentContext->FindChildWithRules(aPseudoTag, ruleNode).get(); #ifdef NOISY_DEBUG if (result) @@ -1017,8 +1021,8 @@ nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext, #endif if (!result) - NS_NewStyleContext(&result, aParentContext, aPseudoTag, ruleNode, - aPresContext); + result = NS_NewStyleContext(aParentContext, aPseudoTag, ruleNode, + aPresContext).get(); return result; } @@ -1150,14 +1154,15 @@ void StyleSetImpl::EnsureRuleWalker(nsIPresContext* aPresContext) mRuleWalker = new nsRuleWalker(mRuleTree); } -nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolveStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aContent, "must have content"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1175,7 +1180,7 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, aPresContext->GetMedium(getter_AddRefs(medium)); RulesMatchingData data(aPresContext, medium, aContent, mRuleWalker); FileRules(EnumRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, nsnull); + result = GetContext(aPresContext, aParentContext, nsnull).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1187,14 +1192,14 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext, return result; } -nsIStyleContext* StyleSetImpl::ResolveStyleForNonElement( - nsIPresContext* aPresContext, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ResolveStyleForNonElement(nsIPresContext* aPresContext, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolveStyleForNonElement(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPresContext, "must have pres context"); @@ -1206,7 +1211,7 @@ nsIStyleContext* StyleSetImpl::ResolveStyleForNonElement( mOverrideRuleProcessors) { EnsureRuleWalker(aPresContext); result = GetContext(aPresContext, aParentContext, - nsCSSAnonBoxes::mozNonElement); + nsCSSAnonBoxes::mozNonElement).get(); NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root"); } } @@ -1242,16 +1247,17 @@ EnumPseudoRulesMatching(nsISupports* aProcessor, void* aData) return PR_TRUE; } -nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext, - nsICSSPseudoComparator* aComparator) +already_AddRefed +StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext, + nsICSSPseudoComparator* aComparator) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ResolvePseudoStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPseudoTag, "must have pseudo tag"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1272,7 +1278,7 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex aPseudoTag, aComparator, mRuleWalker); FileRules(EnumPseudoRulesMatching, &data); - result = GetContext(aPresContext, aParentContext, aPseudoTag); + result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1284,15 +1290,16 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex return result; } -nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, - nsIContent* aParentContent, - nsIAtom* aPseudoTag, - nsIStyleContext* aParentContext) +already_AddRefed +StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, + nsIContent* aParentContent, + nsIAtom* aPseudoTag, + nsStyleContext* aParentContext) { MOZ_TIMER_DEBUGLOG(("Start: StyleSetImpl::ProbePseudoStyleFor(), this=%p\n", this)); STYLESET_START_TIMER(NS_TIMER_STYLE_RESOLUTION); - nsIStyleContext* result = nsnull; + nsStyleContext* result = nsnull; NS_ASSERTION(aPseudoTag, "must have pseudo tag"); NS_ASSERTION(aPresContext, "must have pres context"); @@ -1314,7 +1321,7 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext, FileRules(EnumPseudoRulesMatching, &data); if (!mRuleWalker->AtRoot()) - result = GetContext(aPresContext, aParentContext, aPseudoTag); + result = GetContext(aPresContext, aParentContext, aPseudoTag).get(); // Now reset the walker back to the root of the tree. mRuleWalker->Reset(); @@ -1397,7 +1404,7 @@ StyleSetImpl::ClearCachedDataInRuleTree(nsIStyleRule* aInlineStyleRule) } nsresult -StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext) +StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsStyleContext* aContext) { // XXXdwh. If we're willing to *really* optimize this // invalidation, we could only invalidate the struct data @@ -1450,8 +1457,7 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIFrame* rootFrame; shell->GetRootFrame(&rootFrame); if (rootFrame) { - nsCOMPtr rootContext; - rootFrame->GetStyleContext(getter_AddRefs(rootContext)); + nsStyleContext* rootContext = rootFrame->GetStyleContext(); if (rootContext) rootContext->ClearStyleData(aPresContext, aRule); } @@ -1460,46 +1466,38 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, return NS_OK; } -NS_IMETHODIMP +already_AddRefed StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aStyleContext, - nsIStyleContext* aNewParentContext, - nsIStyleContext** aNewStyleContext) + nsStyleContext* aStyleContext, + nsStyleContext* aNewParentContext) { NS_ASSERTION(aPresContext, "must have pres context"); NS_ASSERTION(aStyleContext, "must have style context"); - NS_ASSERTION(aNewStyleContext, "must have new style context"); - nsresult result = NS_ERROR_NULL_POINTER; - - if (aPresContext && aStyleContext && aNewStyleContext) { - nsCOMPtr oldParent = aStyleContext->GetParent(); + if (aPresContext && aStyleContext) { + nsStyleContext* oldParent = aStyleContext->GetParent(); if (oldParent == aNewParentContext) { - result = NS_OK; - NS_ADDREF(aStyleContext); // for return - *aNewStyleContext = aStyleContext; + aStyleContext->AddRef(); + return aStyleContext; } else { // really a new parent - nsIStyleContext* newChild = nsnull; - nsCOMPtr pseudoTag; - aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + nsStyleContext* newChild = nsnull; + nsCOMPtr pseudoTag = aStyleContext->GetPseudoType(); nsRuleNode* ruleNode; aStyleContext->GetRuleNode(&ruleNode); - if (aNewParentContext) { - result = aNewParentContext->FindChildWithRules(pseudoTag, ruleNode, newChild); - } - if (newChild) { // new parent already has one - *aNewStyleContext = newChild; - } + if (aNewParentContext) + newChild = aNewParentContext->FindChildWithRules(pseudoTag, ruleNode).get(); + if (newChild) // new parent already has one + return newChild; else { // need to make one in the new parent - result = NS_NewStyleContext(aNewStyleContext, aNewParentContext, pseudoTag, - ruleNode, aPresContext); + return NS_NewStyleContext(aNewParentContext, pseudoTag, ruleNode, + aPresContext); } } } - return result; + return nsnull; } struct StatefulData : public StateRuleProcessorData { @@ -1764,8 +1762,7 @@ void StyleSetImpl::List(FILE* out, PRInt32 aIndent) void StyleSetImpl::ListContexts(nsIFrame* aRootFrame, FILE* out, PRInt32 aIndent) { - nsCOMPtr sc; - aRootFrame->GetStyleContext(getter_AddRefs(sc)); + nsStyleContext* sc = aRootFrame->GetStyleContext(); if (sc) sc->List(out, aIndent); } diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index 49e83428e16..2ab1fa3fc69 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -78,8 +78,7 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord, nsIFrame* parentFrame; aFrame->GetParent(&parentFrame); // XXX may not be direct parent... if (nsnull != parentFrame) { - nsIStyleContext* parentContext; - parentFrame->GetStyleContext(&parentContext); + nsStyleContext* parentContext = parentFrame->GetStyleContext(); if (nsnull != parentContext) { nsMargin parentSpacing; switch (aSpacing) { @@ -111,7 +110,6 @@ inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord, case NS_SIDE_RIGHT: result = parentSpacing.right; break; case NS_SIDE_BOTTOM: result = parentSpacing.bottom; break; } - NS_RELEASE(parentContext); } } break; diff --git a/mozilla/layout/style/nsStyleStruct.h b/mozilla/layout/style/nsStyleStruct.h index dd99d7931b8..92935245f44 100644 --- a/mozilla/layout/style/nsStyleStruct.h +++ b/mozilla/layout/style/nsStyleStruct.h @@ -1219,7 +1219,7 @@ inline nsBorderEdges::nsBorderEdges() // typesafe mechanisms for accessing style data, global function // templates |GetStyleData(nsIFrame*, const T**)| and -// |GetStyleData(nsIStyleContext*, const T**)|, where T is derived from -// nsStyleStruct, are located in nsIStyleContext.h and nsIFrame.h +// |GetStyleData(nsStyleContext*, const T**)|, where T is derived from +// nsStyleStruct, are located in nsStyleContext.h and nsIFrame.h #endif /* nsStyleStruct_h___ */ diff --git a/mozilla/layout/style/nsStyleUtil.h b/mozilla/layout/style/nsStyleUtil.h index 5a33ee77bdd..6393e157d98 100644 --- a/mozilla/layout/style/nsStyleUtil.h +++ b/mozilla/layout/style/nsStyleUtil.h @@ -42,7 +42,6 @@ #include "nsIPresContext.h" #include "nsILinkHandler.h" // for nsLinkState -class nsIStyleContext; struct nsStyleBackground; enum nsFontSizeType { diff --git a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp index 017883e315a..3f74f46dc52 100644 --- a/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGForeignObjectFrame.cpp @@ -79,7 +79,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -281,7 +281,7 @@ NS_IMETHODIMP nsSVGForeignObjectFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp index ee7dc71bb76..32573cae4fb 100644 --- a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp @@ -90,7 +90,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); @@ -183,7 +183,7 @@ NS_IMETHODIMP nsSVGGFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp index 9e875fea734..0b6f1cda99f 100644 --- a/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp @@ -89,7 +89,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, @@ -168,7 +168,7 @@ NS_IMETHODIMP nsSVGGenericContainerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/svg/base/src/nsSVGGraphicFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGraphicFrame.cpp index 4d9e329d7e4..d2b05984264 100644 --- a/mozilla/layout/svg/base/src/nsSVGGraphicFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGraphicFrame.cpp @@ -92,7 +92,7 @@ NS_IMETHODIMP nsSVGGraphicFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/svg/base/src/nsSVGGraphicFrame.h b/mozilla/layout/svg/base/src/nsSVGGraphicFrame.h index 4300eb18515..a940f97d391 100644 --- a/mozilla/layout/svg/base/src/nsSVGGraphicFrame.h +++ b/mozilla/layout/svg/base/src/nsSVGGraphicFrame.h @@ -77,7 +77,7 @@ public: Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, diff --git a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 65d5b568296..cbf5a49647b 100644 --- a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -79,7 +79,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, @@ -279,7 +279,7 @@ NS_IMETHODIMP nsSVGOuterSVGFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 3d7d4b7f04e..7b3c7e1d7b9 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -41,7 +41,7 @@ #include "nsTableFrame.h" #include "nsTableRowGroupFrame.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -116,7 +116,7 @@ NS_IMETHODIMP nsTableCellFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 79c6abdb838..4db09980812 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -41,7 +41,7 @@ #include "nscore.h" #include "nsHTMLContainerFrame.h" #include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPercentHeightObserver.h" #include "nsLayoutAtoms.h" @@ -85,7 +85,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); #ifdef ACCESSIBILITY diff --git a/mozilla/layout/tables/nsTableColFrame.cpp b/mozilla/layout/tables/nsTableColFrame.cpp index 3bf577d733b..4a12e9da353 100644 --- a/mozilla/layout/tables/nsTableColFrame.cpp +++ b/mozilla/layout/tables/nsTableColFrame.cpp @@ -37,7 +37,7 @@ #include "nsCOMPtr.h" #include "nsTableColFrame.h" #include "nsContainerFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsHTMLAtoms.h" @@ -116,8 +116,7 @@ nsStyleCoord nsTableColFrame::GetStyleWidth() const eStyleUnit_Inherit == styleWidth.GetUnit()) { nsIFrame* parent; GetParent(&parent); - nsCOMPtr styleContext; - parent->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = parent->GetStyleContext(); if (styleContext) { position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); styleWidth = position->mWidth; @@ -269,7 +268,7 @@ NS_IMETHODIMP nsTableColFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableColFrame.h b/mozilla/layout/tables/nsTableColFrame.h index 505a84b3726..280efa9933b 100644 --- a/mozilla/layout/tables/nsTableColFrame.h +++ b/mozilla/layout/tables/nsTableColFrame.h @@ -107,7 +107,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Paint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp index ce3d2d53bb2..9221c4540ca 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp @@ -40,7 +40,7 @@ #include "nsIHTMLTableColElement.h" #include "nsIDOMHTMLTableColElement.h" #include "nsReflowPath.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIHTMLContent.h" @@ -722,7 +722,7 @@ NS_IMETHODIMP nsTableColGroupFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableColGroupFrame.h b/mozilla/layout/tables/nsTableColGroupFrame.h index ffcb9cf2dff..d0f0f556882 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.h +++ b/mozilla/layout/tables/nsTableColGroupFrame.h @@ -73,7 +73,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index eb09677fa04..13d4ee48758 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -39,7 +39,7 @@ #include "nsVoidArray.h" #include "nsTableFrame.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsCellMap.h" @@ -76,7 +76,7 @@ #include "nsIFrameManager.h" #include "nsCSSRendering.h" #include "nsLayoutErrors.h" - +#include "nsAutoPtr.h" /******************************************************************************** @@ -247,7 +247,7 @@ NS_IMETHODIMP nsTableFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; @@ -377,8 +377,8 @@ PRBool nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, nsIFrame* aNextFrame) { - nsCOMPtr sourceContext; - aSourceFrame.GetStyleContext(getter_AddRefs(sourceContext)); NS_ENSURE_TRUE(sourceContext, PR_FALSE); + nsStyleContext* sourceContext = aSourceFrame.GetStyleContext(); + NS_ENSURE_TRUE(sourceContext, PR_FALSE); const nsStyleDisplay* display = (const nsStyleDisplay*) sourceContext->GetStyleData(eStyleStruct_Display); NS_ENSURE_TRUE(display, PR_FALSE); // don't allow a page break after a repeated header @@ -387,8 +387,8 @@ nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, } if (aNextFrame) { - nsCOMPtr nextContext; - aNextFrame->GetStyleContext(getter_AddRefs(nextContext)); NS_ENSURE_TRUE(nextContext, PR_FALSE); + nsStyleContext* nextContext = aNextFrame->GetStyleContext(); + NS_ENSURE_TRUE(nextContext, PR_FALSE); display = (const nsStyleDisplay*) nextContext->GetStyleData(eStyleStruct_Display); NS_ENSURE_TRUE(display, PR_FALSE); // don't allow a page break before a repeated footer @@ -860,11 +860,10 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, nsCOMPtr colGroupContent; GetContent(getter_AddRefs(colGroupContent)); - nsCOMPtr colGroupStyle; - aPresContext.ResolvePseudoStyleContextFor(colGroupContent, - nsCSSAnonBoxes::tableColGroup, - mStyleContext, - getter_AddRefs(colGroupStyle)); + nsRefPtr colGroupStyle; + colGroupStyle = aPresContext.ResolvePseudoStyleContextFor(colGroupContent, + nsCSSAnonBoxes::tableColGroup, + mStyleContext); // Create a col group frame nsIFrame* newFrame; nsCOMPtr presShell; @@ -967,21 +966,22 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, for (PRInt32 childX = startIndex; childX <= lastIndex; childX++) { nsCOMPtr iContent; - nsCOMPtr styleContext; - nsCOMPtr parentStyleContext; + nsRefPtr styleContext; + nsStyleContext* parentStyleContext; if ((aColType == eColAnonymousCol) && aPrevFrameIn) { // a col due to a span in a previous col uses the style context of the col - aPrevFrameIn->GetStyleContext(getter_AddRefs(styleContext)); + styleContext = aPrevFrameIn->GetStyleContext(); // fix for bugzilla bug 54454: get the content from the prevFrame aPrevFrameIn->GetContent(getter_AddRefs(iContent)); } else { // all other anonymous cols use a pseudo style context of the col group aColGroupFrame.GetContent(getter_AddRefs(iContent)); - aColGroupFrame.GetStyleContext(getter_AddRefs(parentStyleContext)); - aPresContext.ResolvePseudoStyleContextFor(iContent, nsCSSAnonBoxes::tableCol, - parentStyleContext, getter_AddRefs(styleContext)); + parentStyleContext = aColGroupFrame.GetStyleContext(); + styleContext = aPresContext.ResolvePseudoStyleContextFor(iContent, + nsCSSAnonBoxes::tableCol, + parentStyleContext); } // ASSERTION to check for bug 54454 sneaking back in... NS_ASSERTION(iContent, "null content in CreateAnonymousColFrames"); @@ -2867,7 +2867,7 @@ nsTableFrame::GetBCBorder(nsIPresContext& aPresContext, static void GetSeparateModelBorderPadding(nsIPresContext& aPresContext, const nsHTMLReflowState* aReflowState, - nsIStyleContext& aStyleContext, + nsStyleContext& aStyleContext, nsMargin& aBorderPadding) { const nsStyleBorder* border = @@ -3775,7 +3775,7 @@ UpdateCol(nsTableFrame& aTableFrame, } PRBool -nsTableFrame::IsPctHeight(nsIStyleContext* aStyleContext) +nsTableFrame::IsPctHeight(nsStyleContext* aStyleContext) { PRBool result = PR_FALSE; if (aStyleContext) { @@ -4164,10 +4164,8 @@ PRBool nsTableFrame::IsAutoHeight() { PRBool isAuto = PR_TRUE; // the default - nsCOMPtr styleContext; - GetStyleContext(getter_AddRefs(styleContext)); - nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); + nsStylePosition* position = (nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position); switch (position->mHeight.GetUnit()) { case eStyleUnit_Auto: // specified auto width @@ -5171,8 +5169,8 @@ GetStyleInfo(const nsIFrame& aFrame, PRBool transparent, foreground; styleData->GetBorderColor(aSide, aColor, transparent, foreground); if (foreground) { - nsCOMPtr styleContext; - aFrame.GetStyleContext(getter_AddRefs(styleContext)); if(!styleContext) ABORT0(); + nsStyleContext* styleContext = aFrame.GetStyleContext(); + if(!styleContext) ABORT0(); const nsStyleColor* colorStyle = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color); aColor = colorStyle->mColor; } diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index c355542df8c..fef8f6c3f41 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -42,7 +42,6 @@ #include "nsHTMLContainerFrame.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" -#include "nsIStyleContext.h" #include "nsITableLayout.h" #include "nsTableColFrame.h" #include "nsTableColGroupFrame.h" @@ -56,6 +55,7 @@ class nsTableRowFrame; class nsTableColGroupFrame; class nsITableLayoutStrategy; class nsHTMLValue; +class nsStyleContext; struct nsTableReflowState; struct nsStylePosition; @@ -203,7 +203,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); @@ -293,7 +293,7 @@ public: nsIAtom* aChildType); PRBool IsAutoWidth(PRBool* aIsPctWidth = nsnull); PRBool IsAutoHeight(); - static PRBool IsPctHeight(nsIStyleContext* aStyleContext); + static PRBool IsPctHeight(nsStyleContext* aStyleContext); /** @return PR_TRUE if aDisplayType represents a rowgroup of any sort * (header, footer, or body) diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index ec74829dc95..355b0e716fb 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -38,7 +38,7 @@ #include "nsTableOuterFrame.h" #include "nsTableFrame.h" #include "nsHTMLReflowCommand.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -166,7 +166,7 @@ NS_IMETHODIMP nsTableOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, @@ -1231,8 +1231,7 @@ nsTableOuterFrame::IsAutoWidth(nsIFrame& aTableOrCaption, *aIsPctWidth = PR_FALSE; } - nsCOMPtr styleContext; - aTableOrCaption.GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aTableOrCaption.GetStyleContext(); nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); @@ -1877,8 +1876,7 @@ static PRBool IsPctHeight(nsIFrame* aFrame) { if (aFrame) { - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position); if (eStyleUnit_Percent == position->mHeight.GetUnit()) { float percent = position->mHeight.GetPercentValue(); diff --git a/mozilla/layout/tables/nsTableOuterFrame.h b/mozilla/layout/tables/nsTableOuterFrame.h index ed72a539aa3..351bfe535ba 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.h +++ b/mozilla/layout/tables/nsTableOuterFrame.h @@ -91,7 +91,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 70d6baf0246..138bc5ca288 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -39,7 +39,7 @@ #include "nsIRenderingContext.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIHTMLContent.h" #include "nsHTMLAtoms.h" @@ -190,7 +190,7 @@ NS_IMETHODIMP nsTableRowFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableRowFrame.h b/mozilla/layout/tables/nsTableRowFrame.h index bf08c32e7a4..aa46d78af04 100644 --- a/mozilla/layout/tables/nsTableRowFrame.h +++ b/mozilla/layout/tables/nsTableRowFrame.h @@ -69,7 +69,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 5a1b208c9bb..e03dc0f4371 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -41,7 +41,7 @@ #include "nsTableCellFrame.h" #include "nsIRenderingContext.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsIView.h" @@ -1874,7 +1874,7 @@ NS_IMETHODIMP nsTableRowGroupFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv; diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.h b/mozilla/layout/tables/nsTableRowGroupFrame.h index 6fc4bc81e64..1b82f15fdec 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.h +++ b/mozilla/layout/tables/nsTableRowGroupFrame.h @@ -117,7 +117,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index 432c92822bb..608602dc885 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -40,7 +40,6 @@ #include "nsBoxLayoutState.h" #include "nsBox.h" #include "nsBoxFrame.h" -#include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsCOMPtr.h" #include "nsIContent.h" diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index b7e194286eb..e32e7b167dc 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -65,7 +65,7 @@ #include "nsBoxLayoutState.h" #include "nsBoxFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsCOMPtr.h" #include "nsUnitConversion.h" @@ -254,7 +254,7 @@ NS_IMETHODIMP nsBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { SetParent(aParent); @@ -2481,7 +2481,7 @@ nsBoxFrame::GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize) nsresult nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aForce) { nsIView* view; @@ -2514,14 +2514,12 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext, // See if the frame is a scrolled frame if (!aForce) { - nsIAtom* pseudoTag; - aStyleContext->GetPseudoType(pseudoTag); + nsCOMPtr pseudoTag = aStyleContext->GetPseudoType(); if (pseudoTag == nsCSSAnonBoxes::scrolledContent) { NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("nsBoxFrame::CreateViewForFrame: scrolled frame=%p", aFrame)); aForce = PR_TRUE; } - NS_IF_RELEASE(pseudoTag); } if (aForce) { diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.h b/mozilla/layout/xul/base/src/nsBoxFrame.h index 71cd172c5b9..c445d5bc5c2 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsBoxFrame.h @@ -135,7 +135,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); @@ -194,7 +194,7 @@ public: static nsresult CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aChild, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, PRBool aForce); NS_IMETHOD Paint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp index f87708af87d..2b432c6d7e5 100644 --- a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp +++ b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp @@ -44,7 +44,7 @@ #include "nsBoxLayoutState.h" #include "nsBoxFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsCOMPtr.h" #include "nsUnitConversion.h" @@ -180,10 +180,9 @@ nsBoxToBlockAdaptor::SetParentBox(nsIBox* aParent) mFrame->GetView(context, &view); if (!view) { - nsCOMPtr style; - mFrame->GetStyleContext(getter_AddRefs(style)); - nsHTMLContainerFrame::CreateViewForFrame(context,mFrame,style,nsnull,PR_TRUE); - mFrame->GetView(context, &view); + nsStyleContext* style = mFrame->GetStyleContext(); + nsHTMLContainerFrame::CreateViewForFrame(context,mFrame,style,nsnull,PR_TRUE); + mFrame->GetView(context, &view); } nsCOMPtr widget; diff --git a/mozilla/layout/xul/base/src/nsDeckFrame.cpp b/mozilla/layout/xul/base/src/nsDeckFrame.cpp index 03f745c96f8..65ca916dcf2 100644 --- a/mozilla/layout/xul/base/src/nsDeckFrame.cpp +++ b/mozilla/layout/xul/base/src/nsDeckFrame.cpp @@ -43,7 +43,7 @@ // #include "nsDeckFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsIContent.h" #include "nsCOMPtr.h" @@ -115,10 +115,9 @@ nsDeckFrame::CreateWidget(nsIPresContext* aPresContext, nsIBox* aBox) frame->GetView(aPresContext, &view); if (!view) { - nsCOMPtr context; - frame->GetStyleContext(getter_AddRefs(context)); - nsHTMLContainerFrame::CreateViewForFrame(aPresContext,frame,context,nsnull,PR_TRUE); - frame->GetView(aPresContext, &view); + nsStyleContext* context = frame->GetStyleContext(); + nsHTMLContainerFrame::CreateViewForFrame(aPresContext,frame,context,nsnull,PR_TRUE); + frame->GetView(aPresContext, &view); } nsCOMPtr widget; @@ -204,7 +203,7 @@ NS_IMETHODIMP nsDeckFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, diff --git a/mozilla/layout/xul/base/src/nsDeckFrame.h b/mozilla/layout/xul/base/src/nsDeckFrame.h index ac2503e4c7e..8e5d5cf85e0 100644 --- a/mozilla/layout/xul/base/src/nsDeckFrame.h +++ b/mozilla/layout/xul/base/src/nsDeckFrame.h @@ -95,7 +95,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust); diff --git a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp index bf1cb48d833..94140dd32ea 100644 --- a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp @@ -39,7 +39,7 @@ #include "nsBoxFrame.h" #include "nsCSSRendering.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" class nsGroupBoxFrame : public nsBoxFrame { public: diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index 732718bcc08..2e354051b5e 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -47,7 +47,7 @@ #include "nsIFontMetrics.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsCOMPtr.h" #include "nsIPresContext.h" @@ -66,7 +66,6 @@ #include "nsIHTMLContent.h" #include "nsIDocument.h" #include "nsIHTMLDocument.h" -#include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsImageMap.h" #include "nsILinkHandler.h" @@ -85,7 +84,6 @@ #include "nsTextFragment.h" #include "nsIDOMHTMLMapElement.h" #include "nsIStyleSet.h" -#include "nsIStyleContext.h" #include "nsBoxLayoutState.h" #include "nsIDOMDocument.h" #include "nsIEventQueueService.h" @@ -324,7 +322,7 @@ NS_IMETHODIMP nsImageBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { if (!mListener) { diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.h b/mozilla/layout/xul/base/src/nsImageBoxFrame.h index 70453082d1b..af342b66153 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.h @@ -80,7 +80,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp index 11420b648b6..60c6ee0a70e 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -51,7 +51,7 @@ #include "nsXULAtoms.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" @@ -103,7 +103,7 @@ NS_IMETHODIMP nsLeafBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.h b/mozilla/layout/xul/base/src/nsLeafBoxFrame.h index bf5482a270e..ab32fd81ab3 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.h @@ -74,7 +74,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index e8f5783da3f..06e329458a0 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -61,11 +61,12 @@ #include "nsIScrollableFrame.h" #include "nsIScrollbarFrame.h" #include "nsIScrollableView.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIRenderingContext.h" #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" #include "nsITimer.h" +#include "nsAutoPtr.h" /////////////// nsListScrollSmoother ////////////////// @@ -225,7 +226,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) NS_IMETHODIMP nsListBoxBodyFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -747,9 +748,9 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState) nsCOMPtr firstRowContent(do_QueryInterface(firstRowEl)); if (firstRowContent) { - nsCOMPtr styleContext; - aBoxLayoutState.GetPresContext()->ResolveStyleContextFor(firstRowContent, nsnull, - getter_AddRefs(styleContext)); + nsRefPtr styleContext; + styleContext = aBoxLayoutState.GetPresContext()->ResolveStyleContextFor(firstRowContent, + nsnull); nscoord width = 0; nsMargin margin(0,0,0,0); diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.h b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.h index b491e0ec927..de3d9e1182a 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.h +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.h @@ -75,7 +75,7 @@ public: // nsIFrame NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow); + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType, PRInt32 aHint) ; diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index b03ce63d7ce..a1ccd6cf3ba 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -46,7 +46,7 @@ #include "prtypes.h" #include "nsIAtom.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsIDocument.h" @@ -137,7 +137,7 @@ NS_IMETHODIMP nsMenuBarFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.h b/mozilla/layout/xul/base/src/nsMenuBarFrame.h index 348b5d9d0a9..cd2721b8572 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.h @@ -104,7 +104,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 1a9ac36aba2..358f3ff612e 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -49,7 +49,7 @@ #include "nsIAtom.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" @@ -183,7 +183,7 @@ NS_IMETHODIMP nsMenuFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; // Don't addref it. Our lifetime is shorter. diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.h b/mozilla/layout/xul/base/src/nsMenuFrame.h index 093cc09c11e..2d79d8ae11a 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuFrame.h @@ -88,7 +88,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 79935fc3266..51474b54ec5 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -47,7 +47,7 @@ #include "prtypes.h" #include "nsIAtom.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsIViewManager.h" @@ -168,7 +168,7 @@ NS_IMETHODIMP nsMenuPopupFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.h b/mozilla/layout/xul/base/src/nsMenuPopupFrame.h index 143131a74bc..f4db9dfc753 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.h @@ -119,7 +119,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp index fa42e74a676..a76caf1df8d 100644 --- a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp @@ -101,7 +101,7 @@ nsNativeScrollbarFrame::~nsNativeScrollbarFrame ( ) // NS_IMETHODIMP nsNativeScrollbarFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.h b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.h index 675327e9c0d..48bbbf51f12 100644 --- a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.h +++ b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.h @@ -54,7 +54,7 @@ class nsISupportsArray; class nsIPresShell; class nsIPresContext; class nsIContent; -class nsIStyleContext; +class nsStyleContext; nsresult NS_NewNativeScrollbarFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ; @@ -72,7 +72,7 @@ public: #endif NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow); + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow); // nsIFrame overrides NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index 3fa5f8ff79c..f7c9695440d 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -48,7 +48,7 @@ #include "prtypes.h" #include "nsIAtom.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" @@ -154,7 +154,7 @@ NS_IMETHODIMP nsPopupSetFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; // Don't addref it. Our lifetime is shorter. diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.h b/mozilla/layout/xul/base/src/nsPopupSetFrame.h index 2ffd7029574..5ed550ded8d 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.h +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.h @@ -75,7 +75,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); // nsIBox diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.cpp b/mozilla/layout/xul/base/src/nsResizerFrame.cpp index 66812dae9b1..9321d45669a 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.cpp +++ b/mozilla/layout/xul/base/src/nsResizerFrame.cpp @@ -87,7 +87,7 @@ nsResizerFrame::nsResizerFrame(nsIPresShell* aPresShell) NS_IMETHODIMP nsResizerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow) { nsresult rv = nsTitleBarFrame::Init(aPresContext, aContent, aParent, aContext, asPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.h b/mozilla/layout/xul/base/src/nsResizerFrame.h index 3f8d006c2f6..97f57c4f895 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.h +++ b/mozilla/layout/xul/base/src/nsResizerFrame.h @@ -69,7 +69,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp index f7e2fd2062e..299a367b1fc 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -101,7 +101,7 @@ NS_IMETHODIMP nsScrollBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aStyleContext, + nsStyleContext* aStyleContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, @@ -138,8 +138,7 @@ nsScrollBoxFrame::SetUpScrolledFrame(nsIPresContext* aPresContext) return; // create a view if we don't already have one. - nsCOMPtr context; - frame->GetStyleContext(getter_AddRefs(context)); + nsStyleContext* context = frame->GetStyleContext(); nsHTMLContainerFrame::CreateViewForFrame(aPresContext, frame, context, nsnull, PR_TRUE); @@ -827,7 +826,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_DECL_NSITIMERCALLBACK @@ -861,7 +860,7 @@ NS_IMETHODIMP nsAutoRepeatBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.h b/mozilla/layout/xul/base/src/nsScrollBoxFrame.h index 15022537996..d75d6f35d0b 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.h @@ -57,7 +57,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); // Called to set the one and only child frame. Returns NS_ERROR_INVALID_ARG diff --git a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp index 5b7a275580c..420225947e3 100644 --- a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp @@ -81,7 +81,7 @@ NS_IMETHODIMP nsScrollbarFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsScrollbarFrame.h b/mozilla/layout/xul/base/src/nsScrollbarFrame.h index 1970c0f8f8b..e9a05249677 100644 --- a/mozilla/layout/xul/base/src/nsScrollbarFrame.h +++ b/mozilla/layout/xul/base/src/nsScrollbarFrame.h @@ -93,7 +93,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD IsPercentageBase(PRBool& aBase) const; diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index f9e6ac4e4b5..6619563695b 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -44,7 +44,7 @@ // #include "nsSliderFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsIContent.h" #include "nsCOMPtr.h" @@ -113,7 +113,7 @@ NS_IMETHODIMP nsSliderFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.h b/mozilla/layout/xul/base/src/nsSliderFrame.h index 373a3ebba92..2225ba9eb78 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.h +++ b/mozilla/layout/xul/base/src/nsSliderFrame.h @@ -177,7 +177,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index 438e4300995..bb47b921ff6 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -66,7 +66,7 @@ #include "nsHTMLParts.h" #include "nsILookAndFeel.h" #include "nsIPresShell.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsWidgetsCID.h" #include "nsBoxLayoutState.h" #include "nsIXBLService.h" @@ -74,7 +74,7 @@ #include "nsHTMLContainerFrame.h" #include "nsINodeInfo.h" #include "nsGUIEvent.h" - +#include "nsAutoPtr.h" #include "nsContentCID.h" const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32 @@ -327,7 +327,7 @@ NS_IMETHODIMP nsSplitterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { /* make it real time drag for now due to problems @@ -345,7 +345,7 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext, if (aParent) CallQueryInterface(aParent, &boxParent); // |newContext| to Release the reference after the call to nsBoxFrame::Init - nsCOMPtr newContext; + nsRefPtr newContext; if (boxParent) { PRBool isHorizontal; boxParent->GetOrientation(isHorizontal); @@ -355,9 +355,8 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext, if (str.IsEmpty()) { aContent->SetAttr(kNameSpaceID_None, nsXULAtoms::orient, NS_LITERAL_STRING("vertical"), PR_FALSE); - nsCOMPtr parent = aContext->GetParent(); - aPresContext->ResolveStyleContextFor(aContent, parent, - getter_AddRefs(newContext)); + nsStyleContext* parent = aContext->GetParent(); + newContext = aPresContext->ResolveStyleContextFor(aContent, parent); aContext = newContext; } } diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.h b/mozilla/layout/xul/base/src/nsSplitterFrame.h index aa3fb1570a3..f457730bdb5 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.h +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.h @@ -74,7 +74,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD GetCursor(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsStackFrame.cpp b/mozilla/layout/xul/base/src/nsStackFrame.cpp index 3659d2a9156..b73398a345f 100644 --- a/mozilla/layout/xul/base/src/nsStackFrame.cpp +++ b/mozilla/layout/xul/base/src/nsStackFrame.cpp @@ -43,7 +43,7 @@ // #include "nsStackFrame.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIPresContext.h" #include "nsIContent.h" #include "nsCOMPtr.h" @@ -107,7 +107,9 @@ nsStackFrame::GetFrameForPoint(nsIPresContext* aPresContext, GetInset(im); nsMargin border(0,0,0,0); nsStyleBorderPadding bPad; - aFrame->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad); + nsStyleContext* styleContext; + aFrame->GetStyleContext(&styleContext); + styleContext->GetBorderPaddingFor(bPad); bPad.GetBorderPadding(borderPadding); r.Deflate(im); r.Deflate(border); diff --git a/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp b/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp index 02bf02faad4..61ab5be66bf 100644 --- a/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTextBoxFrame.cpp @@ -53,7 +53,7 @@ #include "nsXULAtoms.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIContent.h" #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" @@ -167,7 +167,7 @@ NS_IMETHODIMP nsTextBoxFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsTextBoxFrameSuper::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -352,7 +352,7 @@ nsTextBoxFrame::PaintTitle(nsIPresContext* aPresContext, nscolor overColor; nscolor underColor; nscolor strikeColor; - nsCOMPtr context = mStyleContext; + nsStyleContext* context = mStyleContext; PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE; // Begin with no decorations PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE | diff --git a/mozilla/layout/xul/base/src/nsTextBoxFrame.h b/mozilla/layout/xul/base/src/nsTextBoxFrame.h index 7279351a252..cbea0d2ad8f 100644 --- a/mozilla/layout/xul/base/src/nsTextBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsTextBoxFrame.h @@ -61,7 +61,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index f79e24bd988..c984e679b00 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -83,7 +83,7 @@ nsTitleBarFrame::nsTitleBarFrame(nsIPresShell* aPresShell) NS_IMETHODIMP nsTitleBarFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, asPrevInFlow); diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.h b/mozilla/layout/xul/base/src/nsTitleBarFrame.h index fc6032156a8..f89df084d82 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.h +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.h @@ -51,7 +51,7 @@ public: NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* asPrevInFlow); NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 6a5fbd00a87..e41aab5550c 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -57,7 +57,7 @@ #include "nsHTMLAtoms.h" #include "nsIContent.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsIBoxObject.h" #include "nsGUIEvent.h" #include "nsIDOMMouseEvent.h" @@ -108,15 +108,14 @@ static const PRUint32 kLazyScrollDelay = 150; static const PRUint32 kScrollDelay = 100; // The style context cache impl -nsresult +nsStyleContext* nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator, - nsIPresContext* aPresContext, nsIContent* aContent, - nsIStyleContext* aContext, nsIAtom* aPseudoElement, - nsISupportsArray* aInputWord, - nsIStyleContext** aResult) + nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aContext, + nsIAtom* aPseudoElement, + nsISupportsArray* aInputWord) { - *aResult = nsnull; - PRUint32 count; aInputWord->Count(&count); nsDFAState startState(0); @@ -156,20 +155,23 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator, // We're in a final state. // Look up our style context for this state. - if (mCache) - *aResult = NS_STATIC_CAST(nsIStyleContext*, mCache->Get(currState)); // Addref occurs on *aResult. - if (!*aResult) { + nsStyleContext* result; + if (mCache) + result = NS_STATIC_CAST(nsStyleContext*, mCache->Get(currState)); + if (!result) { // We missed the cache. Resolve this pseudo-style. - aPresContext->ResolvePseudoStyleWithComparator(aContent, aPseudoElement, - aContext, aComparator, - aResult); // Addref occurs on *aResult. - // Put it in our table. + result = aPresContext->ResolvePseudoStyleWithComparator(aContent, + aPseudoElement, + aContext, + aComparator).get(); + + // Put it in our table, transferring the owning reference to the table. if (!mCache) - mCache = new nsSupportsHashtable; - mCache->Put(currState, *aResult); + mCache = new nsObjectHashtable(nsnull, nsnull, ReleaseStyleContext, nsnull); + mCache->Put(currState, result); } - return NS_OK; + return result; } /* static */ PRBool PR_CALLBACK @@ -182,6 +184,16 @@ nsTreeStyleCache::DeleteDFAState(nsHashKey *aKey, return PR_TRUE; } +/* static */ PRBool PR_CALLBACK +nsTreeStyleCache::ReleaseStyleContext(nsHashKey *aKey, + void *aData, + void *closure) +{ + nsStyleContext* context = NS_STATIC_CAST(nsStyleContext*, aData); + context->Release(); + return PR_TRUE; +} + // Column class that caches all the info about our column. nsTreeColumn::nsTreeColumn(nsIContent* aColElement, nsIFrame* aFrame) :mNext(nsnull) @@ -197,8 +209,7 @@ nsTreeColumn::nsTreeColumn(nsIContent* aColElement, nsIFrame* aFrame) mIDAtom = getter_AddRefs(NS_NewAtom(mID)); } - nsCOMPtr styleContext; - aFrame->GetStyleContext(getter_AddRefs(styleContext)); + nsStyleContext* styleContext = aFrame->GetStyleContext(); const nsStyleVisibility* vis = (const nsStyleVisibility*)styleContext->GetStyleData(eStyleStruct_Visibility); @@ -365,7 +376,7 @@ static nsIFrame* InitScrollbarFrame(nsIPresContext* aPresContext, nsIFrame* aCur NS_IMETHODIMP nsTreeBodyFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow) { mPresContext = aPresContext; nsresult rv = nsLeafBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); @@ -436,8 +447,7 @@ nsTreeBodyFrame::CalcMaxRowWidth(nsBoxLayoutState& aState) if (!mView) return 0; - nsCOMPtr rowContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow, getter_AddRefs(rowContext)); + nsStyleContext* rowContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow); nsMargin rowMargin(0,0,0,0); nsStyleBorderPadding bPad; rowContext->GetBorderPaddingFor(bPad); @@ -653,7 +663,7 @@ nsTreeBodyFrame::ReflowFinished(nsIPresShell* aPresShell, PRBool* aFlushFlag) static void -AdjustForBorderPadding(nsIStyleContext* aContext, nsRect& aRect) +AdjustForBorderPadding(nsStyleContext* aContext, nsRect& aRect) { nsMargin m(0,0,0,0); nsStyleBorderPadding bPad; @@ -1257,16 +1267,14 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con PrefillPropertyArray(aRow, currCol); mView->GetCellProperties(aRow, currCol->GetID().get(), mScratchArray); - nsCOMPtr rowContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow, getter_AddRefs(rowContext)); + nsStyleContext* rowContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow); // We don't want to consider any of the decorations that may be present // on the current row, so we have to deflate the rect by the border and // padding and offset its left and top coordinates appropriately. AdjustForBorderPadding(rowContext, cellRect); - nsCOMPtr cellContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell, getter_AddRefs(cellContext)); + nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell); NS_NAMED_LITERAL_STRING(cell, "cell"); if (currCol->IsCycler() || cell.Equals(aCellItem)) { @@ -1314,8 +1322,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con } // Find the twisty rect by computing its size. - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); // |GetImageSize| returns the rect of the twisty image, including the // borders and padding. @@ -1339,8 +1346,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con } // Cell Image - nsCOMPtr imageContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage, getter_AddRefs(imageContext)); + nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage); nsRect imageSize = GetImageSize(aRow, currCol->GetID().get(), PR_FALSE, imageContext); if (NS_LITERAL_STRING("image").Equals(aCellItem)) { @@ -1367,8 +1373,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con // the remaining width available, then we just assume that the text has // been cropped and use the remaining rect as the text Rect. Otherwise, // we add in borders and padding to the text dimension and give that back. - nsCOMPtr textContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext, getter_AddRefs(textContext)); + nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); const nsStyleFont* fontStyle = (const nsStyleFont*) textContext->GetStyleData(eStyleStruct_Font); nsCOMPtr dc; @@ -1425,8 +1430,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(PRInt32 aX, const nsRect& aCellRect, mView->GetCellProperties(aRowIndex, aColumn->GetID().get(), mScratchArray); // Resolve style for the cell. - nsCOMPtr cellContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell, getter_AddRefs(cellContext)); + nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell); // Obtain the margins for the cell and then deflate our rect by that // amount. The cell is assumed to be contained within the deflated rect. @@ -1477,8 +1481,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(PRInt32 aX, const nsRect& aCellRect, } // Resolve style for the twisty. - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); // We will treat a click as hitting the twisty if it happens on the margins, borders, padding, // or content of the twisty object. By allowing a "slop" into the margin, we make it a little @@ -1509,8 +1512,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(PRInt32 aX, const nsRect& aCellRect, nsRect iconRect(currX, cellRect.y, remainingWidth, cellRect.height); // Resolve style for the image. - nsCOMPtr imageContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage, getter_AddRefs(imageContext)); + nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage); nsRect iconSize = GetImageSize(aRowIndex, aColumn->GetID().get(), PR_FALSE, imageContext); const nsStyleMargin* imageMarginData = (const nsStyleMargin*)imageContext->GetStyleData(eStyleStruct_Margin); @@ -1548,8 +1550,7 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, const nsAString& aColID, nsRect cellRect(0, 0, currCol->GetWidth(), mRowHeight); // Adjust borders and padding for the cell. - nsCOMPtr cellContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell, getter_AddRefs(cellContext)); + nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell); nsMargin m(0,0,0,0); nsStyleBorderPadding bPad; cellContext->GetBorderPaddingFor(bPad); @@ -1568,8 +1569,7 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, const nsAString& aColID, aDesiredSize += mIndentation * level; // Find the twisty rect by computing its size. - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); // |GetImageSize| returns the rect of the twisty image, including the // borders and padding. @@ -1584,8 +1584,7 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, const nsAString& aColID, aDesiredSize += twistyImageRect.width; } - nsCOMPtr imageContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage, getter_AddRefs(imageContext)); + nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage); // Account for the width of the cell image. nsRect imageSize = GetImageSize(aRow, currCol->GetID().get(), PR_FALSE, imageContext); @@ -1595,8 +1594,7 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, const nsAString& aColID, nsAutoString cellText; mView->GetCellText(aRow, currCol->GetID().get(), cellText); - nsCOMPtr textContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext, getter_AddRefs(textContext)); + nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); // Get the borders and padding for the text. nsStyleBorderPadding borderPadding; @@ -1800,7 +1798,7 @@ nsTreeBodyFrame::PrefillPropertyArray(PRInt32 aRowIndex, nsTreeColumn* aCol) nsresult nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUseContext, - nsIStyleContext* aStyleContext, PRBool& aAllowImageRegions, imgIContainer** aResult) + nsStyleContext* aStyleContext, PRBool& aAllowImageRegions, imgIContainer** aResult) { *aResult = nsnull; @@ -1901,7 +1899,7 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUs } nsRect nsTreeBodyFrame::GetImageSize(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUseContext, - nsIStyleContext* aStyleContext) + nsStyleContext* aStyleContext) { // XXX We should respond to visibility rules for collapsed vs. hidden. @@ -1983,9 +1981,8 @@ PRInt32 nsTreeBodyFrame::GetRowHeight() { // Look up the correct height. It is equal to the specified height // + the specified margins. - nsCOMPtr rowContext; mScratchArray->Clear(); - GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow, getter_AddRefs(rowContext)); + nsStyleContext* rowContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow); if (rowContext) { const nsStylePosition* myPosition = (const nsStylePosition*) rowContext->GetStyleData(eStyleStruct_Position); @@ -2030,9 +2027,8 @@ PRInt32 nsTreeBodyFrame::GetRowHeight() PRInt32 nsTreeBodyFrame::GetIndentation() { // Look up the correct indentation. It is equal to the specified indentation width. - nsCOMPtr indentContext; mScratchArray->Clear(); - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeindentation, getter_AddRefs(indentContext)); + nsStyleContext* indentContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeindentation); if (indentContext) { const nsStylePosition* myPosition = (const nsStylePosition*) indentContext->GetStyleData(eStyleStruct_Position); @@ -2194,8 +2190,7 @@ nsTreeBodyFrame::PaintColumn(nsTreeColumn* aColumn, // Resolve style for the column. It contains all the info we need to lay ourselves // out and to paint. - nsCOMPtr colContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecolumn, getter_AddRefs(colContext)); + nsStyleContext* colContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecolumn); // Obtain the margins for the cell and then deflate our rect by that // amount. The cell is assumed to be contained within the deflated rect. @@ -2232,8 +2227,7 @@ nsTreeBodyFrame::PaintRow(PRInt32 aRowIndex, // Resolve style for the row. It contains all the info we need to lay ourselves // out and to paint. - nsCOMPtr rowContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow, getter_AddRefs(rowContext)); + nsStyleContext* rowContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreerow); // Obtain the margins for the row and then deflate our rect by that // amount. The row is assumed to be contained within the deflated rect. @@ -2276,8 +2270,7 @@ nsTreeBodyFrame::PaintRow(PRInt32 aRowIndex, // The row is a separator. Paint only a double horizontal line. // Resolve style for the separator. - nsCOMPtr separatorContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeseparator, getter_AddRefs(separatorContext)); + nsStyleContext* separatorContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeseparator); PRBool useTheme = PR_FALSE; nsCOMPtr theme; const nsStyleDisplay* displayData = (const nsStyleDisplay*)separatorContext->GetStyleData(eStyleStruct_Display); @@ -2356,8 +2349,7 @@ nsTreeBodyFrame::PaintCell(PRInt32 aRowIndex, // Resolve style for the cell. It contains all the info we need to lay ourselves // out and to paint. - nsCOMPtr cellContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell, getter_AddRefs(cellContext)); + nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell); // Obtain the margins for the cell and then deflate our rect by that // amount. The cell is assumed to be contained within the deflated rect. @@ -2395,8 +2387,7 @@ nsTreeBodyFrame::PaintCell(PRInt32 aRowIndex, remainingWidth -= mIndentation * level; // Resolve the style to use for the connecting lines. - nsCOMPtr lineContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeline, getter_AddRefs(lineContext)); + nsStyleContext* lineContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeline); const nsStyleVisibility* vis = (const nsStyleVisibility*)lineContext->GetStyleData(eStyleStruct_Visibility); @@ -2406,8 +2397,7 @@ nsTreeBodyFrame::PaintCell(PRInt32 aRowIndex, // Get the size of the twisty. We don't want to paint the twisty // before painting of connecting lines since it would paint lines over // the twisty. But we need to leave a place for it. - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); nsRect twistySize = GetImageSize(aRowIndex, aColumn->GetID().get(), PR_TRUE, twistyContext); @@ -2546,8 +2536,7 @@ nsTreeBodyFrame::PaintTwisty(PRInt32 aRowIndex, } // Resolve style for the twisty. - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); PRBool useTheme = PR_FALSE; nsCOMPtr theme; @@ -2654,8 +2643,7 @@ nsTreeBodyFrame::PaintImage(PRInt32 aRowIndex, nscoord& aCurrX) { // Resolve style for the image. - nsCOMPtr imageContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage, getter_AddRefs(imageContext)); + nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeimage); // Obtain the margins for the twisty and then deflate our rect by that // amount. The twisty is assumed to be contained within the deflated rect. @@ -2743,8 +2731,7 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex, // Resolve style for the text. It contains all the info we need to lay ourselves // out and to paint. - nsCOMPtr textContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext, getter_AddRefs(textContext)); + nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); // Obtain the margins for the text and then deflate our rect by that // amount. The text is assumed to be contained within the deflated rect. @@ -2967,8 +2954,7 @@ nsTreeBodyFrame::PaintProgressMeter(PRInt32 aRowIndex, // Resolve style for the progress meter. It contains all the info we need // to lay ourselves out and to paint. - nsCOMPtr meterContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreeprogressmeter, getter_AddRefs(meterContext)); + nsStyleContext* meterContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreeprogressmeter); // Obtain the margins for the progress meter and then deflate our rect by that // amount. The progress meter is assumed to be contained within the deflated @@ -3061,8 +3047,7 @@ nsTreeBodyFrame::PaintDropFeedback(nsIPresContext* aPresContext, PrefillPropertyArray(mDropRow, currCol); // Resolve the style to use for the drop feedback. - nsCOMPtr feedbackContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreedropfeedback, getter_AddRefs(feedbackContext)); + nsStyleContext* feedbackContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreedropfeedback); const nsStyleVisibility* vis = (const nsStyleVisibility*)feedbackContext->GetStyleData(eStyleStruct_Visibility); @@ -3095,8 +3080,7 @@ nsTreeBodyFrame::PaintDropFeedback(nsIPresContext* aPresContext, currX += mIndentation * level; - nsCOMPtr twistyContext; - GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty, getter_AddRefs(twistyContext)); + nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty); nsRect twistySize = GetImageSize(mDropRow, currCol->GetID().get(), PR_TRUE, twistyContext); const nsStyleMargin* twistyMarginData = (const nsStyleMargin*)twistyContext->GetStyleData(eStyleStruct_Margin); nsMargin twistyMargin; @@ -3149,7 +3133,7 @@ nsTreeBodyFrame::PaintDropFeedback(nsIPresContext* aPresContext, } nsresult -nsTreeBodyFrame::PaintBackgroundLayer(nsIStyleContext* aStyleContext, +nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext* aStyleContext, nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aRect, @@ -3338,12 +3322,12 @@ nsTreeBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) } // The style cache. -nsresult -nsTreeBodyFrame::GetPseudoStyleContext(nsIAtom* aPseudoElement, - nsIStyleContext** aResult) +nsStyleContext* +nsTreeBodyFrame::GetPseudoStyleContext(nsIAtom* aPseudoElement) { - return mStyleCache.GetStyleContext(this, mPresContext, mContent, mStyleContext, aPseudoElement, - mScratchArray, aResult); + return mStyleCache.GetStyleContext(this, mPresContext, mContent, + mStyleContext, aPseudoElement, + mScratchArray); } // Our comparator for resolving our complex pseudos diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.h b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.h index a1de7de0790..c679e70a2b0 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.h +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.h @@ -112,14 +112,17 @@ public: void Clear() { delete mTransitionTable; mTransitionTable = nsnull; delete mCache; mCache = nsnull; mNextState = 0; }; - nsresult GetStyleContext(nsICSSPseudoComparator* aComparator, nsIPresContext* aPresContext, - nsIContent* aContent, - nsIStyleContext* aContext, nsIAtom* aPseudoElement, - nsISupportsArray* aInputWord, - nsIStyleContext** aResult); + nsStyleContext* GetStyleContext(nsICSSPseudoComparator* aComparator, + nsIPresContext* aPresContext, + nsIContent* aContent, + nsStyleContext* aContext, + nsIAtom* aPseudoElement, + nsISupportsArray* aInputWord); static PRBool PR_CALLBACK DeleteDFAState(nsHashKey *aKey, void *aData, void *closure); + static PRBool PR_CALLBACK ReleaseStyleContext(nsHashKey *aKey, void *aData, void *closure); + protected: // A transition table for a deterministic finite automaton. The DFA // takes as its input a single pseudoelement and an ordered set of properties. @@ -139,7 +142,7 @@ protected: // The cache of all active style contexts. This is a hash from // a final state in the DFA, Sf, to the resultant style context. - nsSupportsHashtable* mCache; + nsObjectHashtable* mCache; // An integer counter that is used when we need to make new states in the // DFA. @@ -259,7 +262,7 @@ public: // Overridden from nsIFrame to cache our pres context. NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, - nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow); + nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); // Painting methods. @@ -353,7 +356,7 @@ public: // This method is called with a specific style context and rect to // paint the background rect as if it were a full-blown frame. - nsresult PaintBackgroundLayer(nsIStyleContext* aStyleContext, + nsresult PaintBackgroundLayer(nsStyleContext* aStyleContext, nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aRect, @@ -381,11 +384,11 @@ protected: // Fetch an image from the image cache. nsresult GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUseContext, - nsIStyleContext* aStyleContext, PRBool& aAllowImageRegions, imgIContainer** aResult); + nsStyleContext* aStyleContext, PRBool& aAllowImageRegions, imgIContainer** aResult); // Returns the size of a given image. This size *includes* border and // padding. It does not include margins. - nsRect GetImageSize(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUseContext, nsIStyleContext* aStyleContext); + nsRect GetImageSize(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUseContext, nsStyleContext* aStyleContext); // Returns the height of rows in the tree. PRInt32 GetRowHeight(); @@ -398,7 +401,7 @@ protected: // Looks up a style context in the style cache. On a cache miss we resolve // the pseudo-styles passed in and place them into the cache. - nsresult GetPseudoStyleContext(nsIAtom* aPseudoElement, nsIStyleContext** aResult); + nsStyleContext* GetPseudoStyleContext(nsIAtom* aPseudoElement); // Builds our cache of column info. void EnsureColumns(); diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp index d52be3ef4f2..4d374870b0a 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp @@ -41,7 +41,7 @@ #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" #include "nsIContent.h" -#include "nsIStyleContext.h" +#include "nsStyleContext.h" #include "nsINameSpaceManager.h" #include "nsIDOMNSDocument.h" #include "nsIDocument.h" @@ -102,7 +102,7 @@ NS_IMETHODIMP nsTreeColFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h index 71ff53cdc36..dc78a6e2d02 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h @@ -60,7 +60,7 @@ public: NS_IMETHODIMP Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, - nsIStyleContext* aContext, + nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, diff --git a/mozilla/xpcom/base/MANIFEST b/mozilla/xpcom/base/MANIFEST index bae3468b9ab..db27fa7aec4 100644 --- a/mozilla/xpcom/base/MANIFEST +++ b/mozilla/xpcom/base/MANIFEST @@ -1,4 +1,5 @@ nsAgg.h +nsAutoPtr.h nsIAllocator.h nsCom.h nsComObsolete.h diff --git a/mozilla/xpcom/base/Makefile.in b/mozilla/xpcom/base/Makefile.in index f3b0f0e91b4..ff98ae816ef 100644 --- a/mozilla/xpcom/base/Makefile.in +++ b/mozilla/xpcom/base/Makefile.in @@ -54,6 +54,7 @@ endif EXPORTS = \ nsAgg.h \ + nsAutoPtr.h \ nsIAllocator.h \ nsCom.h \ nsComObsolete.h \ diff --git a/mozilla/xpcom/glue/nsCOMPtr.h b/mozilla/xpcom/glue/nsCOMPtr.h index 769636d8cf0..f1348d5f414 100644 --- a/mozilla/xpcom/glue/nsCOMPtr.h +++ b/mozilla/xpcom/glue/nsCOMPtr.h @@ -188,8 +188,8 @@ class nsDerivedSafe : public T using T::AddRef; using T::Release; #else - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + nsrefcnt AddRef(void); + nsrefcnt Release(void); #endif #if !defined(XP_OS2_VACPP) && !defined(AIX_XLC_364) diff --git a/mozilla/xpcom/tests/Makefile.in b/mozilla/xpcom/tests/Makefile.in index eca98de2ef9..5471742b946 100644 --- a/mozilla/xpcom/tests/Makefile.in +++ b/mozilla/xpcom/tests/Makefile.in @@ -55,6 +55,7 @@ CPPSRCS = \ TestThreads.cpp \ TestXPIDLString.cpp \ TestDeque.cpp \ + TestAutoPtr.cpp \ $(NULL) #CPPSRCS += TimerTest.cpp