From b4581d93cf556127353c114c7618e89f9ea9b2e5 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sat, 31 Jan 2004 22:41:40 +0000 Subject: [PATCH] Continuing nsIPresContext deCOMtamination (bug 229371). Remove ReParentStyleContext - callers can call frame manager directly. Removed several unused setters. Inlined getters for default colors, font scaler, and focus ring width. Changed GetDefaultFont to return a const nsFont*. r+sr=dbaron. git-svn-id: svn://10.0.0.236/trunk@152127 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 4 +- mozilla/content/base/src/nsRuleNode.cpp | 33 ++- .../html/content/src/nsHTMLBodyElement.cpp | 2 +- .../html/style/src/nsComputedDOMStyle.cpp | 6 +- mozilla/content/shared/src/nsStyleStruct.cpp | 10 +- .../xmlterm/base/mozXMLTerminal.cpp | 8 +- mozilla/layout/base/nsCSSFrameConstructor.cpp | 9 +- mozilla/layout/base/nsCSSRendering.cpp | 2 +- mozilla/layout/base/nsDocumentViewer.cpp | 4 +- mozilla/layout/base/nsPresContext.cpp | 209 ++---------------- mozilla/layout/base/nsPresContext.h | 59 +++-- mozilla/layout/base/nsPresShell.cpp | 89 ++++---- mozilla/layout/base/public/nsIPresContext.h | 59 +++-- mozilla/layout/base/public/nsPresContext.h | 59 +++-- mozilla/layout/base/src/nsPresContext.cpp | 209 ++---------------- mozilla/layout/base/src/nsPresContext.h | 32 +-- mozilla/layout/generic/nsFirstLetterFrame.cpp | 5 +- mozilla/layout/generic/nsInlineFrame.cpp | 8 +- .../html/base/src/nsFirstLetterFrame.cpp | 5 +- .../layout/html/base/src/nsInlineFrame.cpp | 8 +- mozilla/layout/html/base/src/nsPresShell.cpp | 89 ++++---- .../html/style/src/nsCSSFrameConstructor.cpp | 9 +- .../layout/html/style/src/nsCSSRendering.cpp | 2 +- .../base/src/nsMathMLContainerFrame.cpp | 4 +- mozilla/layout/style/nsComputedDOMStyle.cpp | 6 +- mozilla/layout/style/nsRuleNode.cpp | 33 ++- mozilla/layout/style/nsStyleStruct.cpp | 10 +- 27 files changed, 285 insertions(+), 688 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 4f308a7fd64..f9627725b2f 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -687,9 +687,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) // This may be overridden by the docshell with the background color // for the last document loaded into the docshell - nscolor bgcolor = NS_RGB(0, 0, 0); - mPresContext->GetDefaultBackgroundColor(&bgcolor); - mViewManager->SetDefaultBackgroundColor(bgcolor); + mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor()); if (aDoInitialReflow) { nsCOMPtr sc = do_QueryInterface(mContainer); diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index c26daf94c1f..71258427a68 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -339,19 +339,13 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor, else { switch (intValue) { case NS_COLOR_MOZ_HYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultLinkColor(); break; case NS_COLOR_MOZ_VISITEDHYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultVisitedLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultVisitedLinkColor(); break; case NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultActiveLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultActiveLinkColor(); break; default: NS_NOTREACHED("Should never have an unknown negative colorID."); @@ -1518,10 +1512,11 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, const nsFont& aDefaultFont, const nsStyleFont* aParentFont, nsStyleFont* aFont, PRBool& aInherited) { - const nsFont* defaultVariableFont; - const nsFont* defaultFixedFont; - aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, &defaultVariableFont); - aPresContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID, &defaultFixedFont); + const nsFont* defaultVariableFont = + aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + + const nsFont* defaultFixedFont = + aPresContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID); // font-family: string list, enum, inherit if (eCSSUnit_String == aFontData.mFamily.GetUnit()) { @@ -1680,8 +1675,7 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, PRBool zoom = PR_FALSE; if (eCSSUnit_Enumerated == aFontData.mSize.GetUnit()) { PRInt32 value = aFontData.mSize.GetIntValue(); - PRInt32 scaler; - aPresContext->GetFontScaler(&scaler); + PRInt32 scaler = aPresContext->FontScaler(); float scaleFactor = nsStyleUtil::GetScalingFactor(scaler); zoom = PR_TRUE; @@ -1790,8 +1784,7 @@ nsRuleNode::SetGenericFont(nsIPresContext* aPresContext, // If we stopped earlier because we reached the root of the style tree, // we will start with the default generic font from the presentation // context. Otherwise we start with the higher context. - const nsFont* defaultFont; - aPresContext->GetDefaultFont(aGenericFontID, &defaultFont); + const nsFont* defaultFont = aPresContext->GetDefaultFont(aGenericFontID); nsStyleFont parentFont(*defaultFont); parentFont.mSize = parentFont.mFont.size = nsStyleFont::ZoomText(aPresContext, parentFont.mSize); @@ -1944,9 +1937,9 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, if (generic == kGenericFont_NONE) { // continue the normal processing // our default font is the most recent generic font - const nsFont* defaultFont; - mPresContext->GetDefaultFont(parentFont->mFlags & NS_STYLE_FONT_FACE_MASK, - &defaultFont); + const nsFont* defaultFont = + mPresContext->GetDefaultFont(parentFont->mFlags & NS_STYLE_FONT_FACE_MASK); + nsRuleNode::SetFont(mPresContext, aContext, minimumFontSize, useDocumentFonts, PR_FALSE, fontData, *defaultFont, parentFont, font, inherited); diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 44fa5827a84..52a2e4f3cd9 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -390,7 +390,7 @@ nsHTMLBodyElement::Get##func_(nsAString& aColor) \ GetPresContext(this, getter_AddRefs(presContext)); \ \ if (presContext) { \ - presContext->GetDefault##default_(&attrColor); \ + attrColor = presContext->Default##default_(); \ nsHTMLValue(attrColor).ToString(aColor); \ } \ } else if (NS_ColorNameToRGB(color, &attrColor)) { \ diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp index 5f95a27fc0e..2fda5ddd6e9 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp @@ -511,9 +511,9 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame, const nsString& fontName = font->mFont.name; PRUint8 generic = font->mFlags & NS_STYLE_FONT_FACE_MASK; if (generic == kGenericFont_NONE) { - const nsFont* defaultFont; - presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, - &defaultFont); + const nsFont* defaultFont = + presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + PRInt32 lendiff = fontName.Length() - defaultFont->name.Length(); if (lendiff > 0) { val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index a209a1fb363..4157878cafc 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -190,9 +190,9 @@ nsStyleFont::nsStyleFont(const nsStyleFont& aSrc) nsStyleFont::nsStyleFont(nsIPresContext* aPresContext) : mFlags(NS_STYLE_FONT_DEFAULT) { - const nsFont* defaultFont; - aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, - &defaultFont); + const nsFont* defaultFont = + aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + mFont = *defaultFont; mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size); } @@ -943,7 +943,7 @@ nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther nsStyleColor::nsStyleColor(nsIPresContext* aPresContext) { - aPresContext->GetDefaultColor(&mColor); + mColor = aPresContext->DefaultColor(); } nsStyleColor::nsStyleColor(const nsStyleColor& aSource) @@ -970,7 +970,7 @@ nsStyleBackground::nsStyleBackground(nsIPresContext* aPresContext) mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING), mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY) { - aPresContext->GetDefaultBackgroundColor(&mBackgroundColor); + mBackgroundColor = aPresContext->DefaultBackgroundColor(); } nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource) diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index f51f06c7a24..b930d9034f5 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -589,14 +589,12 @@ NS_IMETHODIMP mozXMLTerminal::ScreenSize(PRInt32* rows, PRInt32* cols, return result; // Get the default fixed pitch font - const nsFont* defaultFixedFont; - result = presContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID, &defaultFixedFont); - if (NS_FAILED(result)) - return result; + const nsFont* defaultFixedFont = + presContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID); // Get metrics for fixed font nsCOMPtr fontMetrics; - result = presContext->GetMetricsFor(*defaultFixedFont, + result = presContext->GetMetricsFor(defaultFixedFont, getter_AddRefs(fontMetrics)); if (NS_FAILED(result) || !fontMetrics) return result; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index eca6ddb2510..e23f63e43ca 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -1032,7 +1032,8 @@ MoveChildrenTo(nsIPresContext* aPresContext, // anonymous block frame, but oddly they aren't -- need to // investigate that...) if (aNewParentSC) - aPresContext->ReParentStyleContext(aFrameList, aNewParentSC); + aPresContext->GetFrameManager()->ReParentStyleContext(aFrameList, + aNewParentSC); #endif aFrameList = aFrameList->GetNextSibling(); @@ -2763,7 +2764,8 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context if (aIsPseudoParent) { - aPresContext->ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); + aPresContext->GetFrameManager()-> + ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); } // construct additional col frames if the col frame has a span > 1 @@ -11489,7 +11491,8 @@ ReparentFrame(nsIPresContext* aPresContext, nsIFrame* aFrame) { aFrame->SetParent(aNewParentFrame); - aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); + aPresContext->GetFrameManager()->ReParentStyleContext(aFrame, + aParentStyleContext); } // Special routine to handle placing a list of frames into a block diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 13448530d75..c64f202fb11 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -2825,7 +2825,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext, // Ensure that we always paint a color for the root (in case there's // no background at all or a partly transparent image). canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT; - aPresContext->GetDefaultBackgroundColor(&canvasColor.mBackgroundColor); + canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor(); } } } diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 4f308a7fd64..f9627725b2f 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -687,9 +687,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) // This may be overridden by the docshell with the background color // for the last document loaded into the docshell - nscolor bgcolor = NS_RGB(0, 0, 0); - mPresContext->GetDefaultBackgroundColor(&bgcolor); - mViewManager->SetDefaultBackgroundColor(bgcolor); + mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor()); if (aDoInitialReflow) { nsCOMPtr sc = do_QueryInterface(mContainer); diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index c4417843fba..44ebc12a012 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -169,7 +169,7 @@ nsPresContext::nsPresContext() mDefaultColor = NS_RGB(0x00, 0x00, 0x00); - mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); + mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); mUseDocumentColors = PR_TRUE; mUseDocumentFonts = PR_TRUE; @@ -184,7 +184,7 @@ nsPresContext::nsPresContext() mUseFocusColors = PR_FALSE; mFocusTextColor = mDefaultColor; - mFocusBackgroundColor = mDefaultBackgroundColor; + mFocusBackgroundColor = mBackgroundColor; mFocusRingWidth = 1; mFocusRingOnAnything = PR_FALSE; @@ -425,16 +425,16 @@ nsPresContext::GetDocumentColorPreferences() mDefaultColor = MakeColorPref(colorStr); } if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.background_color", getter_Copies(colorStr)))) { - mDefaultBackgroundColor = MakeColorPref(colorStr); + mBackgroundColor = MakeColorPref(colorStr); } } else { mDefaultColor = NS_RGB(0x00, 0x00, 0x00); - mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); + mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor); mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground, - mDefaultBackgroundColor); + mBackgroundColor); } if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) { @@ -474,7 +474,7 @@ nsPresContext::GetUserPreferences() if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_focus_colors", &boolPref))) { mUseFocusColors = boolPref; mFocusTextColor = mDefaultColor; - mFocusBackgroundColor = mDefaultBackgroundColor; + mFocusBackgroundColor = mBackgroundColor; if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_text_color", getter_Copies(colorStr)))) { mFocusTextColor = MakeColorPref(colorStr); } @@ -849,23 +849,6 @@ nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext) -{ - NS_PRECONDITION(aFrame, "null ptr"); - if (! aFrame) { - return NS_ERROR_NULL_POINTER; - } - - nsCOMPtr manager; - nsresult rv = mShell->GetFrameManager(getter_AddRefs(manager)); - if (NS_SUCCEEDED(rv) && manager) { - rv = manager->ReParentStyleContext(aFrame, aNewParentContext); - } - return rv; -} - NS_IMETHODIMP nsPresContext::AllocateFromShell(size_t aSize, void** aResult) { @@ -899,137 +882,42 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetDefaultFont(PRUint8 aFontID, const nsFont** aResult) +const nsFont* +nsPresContext::GetDefaultFont(PRUint8 aFontID) const { - nsresult rv = NS_OK; + const nsFont *font; switch (aFontID) { // Special (our default variable width font and fixed width font) case kPresContext_DefaultVariableFont_ID: - *aResult = &mDefaultVariableFont; + font = &mDefaultVariableFont; break; case kPresContext_DefaultFixedFont_ID: - *aResult = &mDefaultFixedFont; + font = &mDefaultFixedFont; break; // CSS case kGenericFont_serif: - *aResult = &mDefaultSerifFont; + font = &mDefaultSerifFont; break; case kGenericFont_sans_serif: - *aResult = &mDefaultSansSerifFont; + font = &mDefaultSansSerifFont; break; case kGenericFont_monospace: - *aResult = &mDefaultMonospaceFont; + font = &mDefaultMonospaceFont; break; case kGenericFont_cursive: - *aResult = &mDefaultCursiveFont; + font = &mDefaultCursiveFont; break; case kGenericFont_fantasy: - *aResult = &mDefaultFantasyFont; + font = &mDefaultFantasyFont; break; default: - rv = NS_ERROR_INVALID_ARG; + font = nsnull; NS_ERROR("invalid arg"); break; } - return rv; + return font; } -NS_IMETHODIMP -nsPresContext::SetDefaultFont(PRUint8 aFontID, const nsFont& aFont) -{ - nsresult rv = NS_OK; - switch (aFontID) { - // Special (our default variable width font and fixed width font) - case kPresContext_DefaultVariableFont_ID: - mDefaultVariableFont = aFont; - break; - case kPresContext_DefaultFixedFont_ID: - mDefaultFixedFont = aFont; - break; - // CSS - case kGenericFont_serif: - mDefaultSerifFont = aFont; - break; - case kGenericFont_sans_serif: - mDefaultSansSerifFont = aFont; - break; - case kGenericFont_monospace: - mDefaultMonospaceFont = aFont; - break; - case kGenericFont_cursive: - mDefaultCursiveFont = aFont; - break; - case kGenericFont_fantasy: - mDefaultFantasyFont = aFont; - break; - default: - rv = NS_ERROR_INVALID_ARG; - NS_ERROR("invalid arg"); - break; - } - return rv; -} - -NS_IMETHODIMP -nsPresContext::GetFontScaler(PRInt32* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mFontScaler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetFontScaler(PRInt32 aScaler) -{ - mFontScaler = aScaler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultColor(nscolor* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mDefaultColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultBackgroundColor(nscolor* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mDefaultBackgroundColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mLinkColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultActiveLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mActiveLinkColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultVisitedLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mVisitedLinkColor; - return NS_OK; -} - - NS_IMETHODIMP nsPresContext::GetFocusRingOnAnything(PRBool& aFocusRingOnAnything) { @@ -1046,67 +934,6 @@ nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) } -NS_IMETHODIMP -nsPresContext::GetFocusTextColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mFocusTextColor; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::GetFocusBackgroundColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mFocusBackgroundColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetFocusRingWidth(PRUint8 *aFocusRingWidth) -{ - NS_PRECONDITION(aFocusRingWidth, "null out param"); - *aFocusRingWidth = mFocusRingWidth; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::SetDefaultColor(nscolor aColor) -{ - mDefaultColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultBackgroundColor(nscolor aColor) -{ - mDefaultBackgroundColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultLinkColor(nscolor aColor) -{ - mLinkColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultActiveLinkColor(nscolor aColor) -{ - mActiveLinkColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultVisitedLinkColor(nscolor aColor) -{ - mVisitedLinkColor = aColor; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetVisibleArea(nsRect& aResult) { diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index c241897f714..5f80bce28f5 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -185,16 +185,6 @@ public: virtual nsresult GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; - /** - * For a given frame tree, get a new style context that is the equivalent - * but within a new parent. The StyleContextParent of aFrame should be - * changed _before_ this method is called, so that style tree verification - * can take place correctly. - */ - NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext) = 0; - - NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; NS_IMETHOD FreeToShell(size_t aSize, void* aFreeChunk) = 0; @@ -203,10 +193,11 @@ public: */ NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0; - /** Get the default font correponding to the given ID */ - NS_IMETHOD GetDefaultFont(PRUint8 aFontID, const nsFont** aResult) = 0; - /** Set the default font correponding to the given ID */ - NS_IMETHOD SetDefaultFont(PRUint8 aFontID, const nsFont& aFont) = 0; + /** + * Get the default font correponding to the given ID. This object is + * read-only, you must copy the font to modify it. + */ + virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0; /** Get a cached boolean pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -225,30 +216,24 @@ public: /** * Access Nav's magic font scaler value */ - NS_IMETHOD GetFontScaler(PRInt32* aResult) = 0; - NS_IMETHOD SetFontScaler(PRInt32 aScaler) = 0; + PRInt32 FontScaler() const { return mFontScaler; } /** * Get the default colors */ - NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; + const nscolor DefaultColor() const { return mDefaultColor; } + const nscolor DefaultBackgroundColor() const { return mBackgroundColor; } + const nscolor DefaultLinkColor() const { return mLinkColor; } + const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; } + const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; } + const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } + const nscolor FocusTextColor() const { return mFocusTextColor; } + NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; - NS_IMETHOD GetFocusRingWidth(PRUint8 *focusRingWidth) = 0; + PRUint8 FocusRingWidth() const { return mFocusRingWidth; } NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; - NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; - /** * Load an image for the target frame. This call can be made * repeated with only a single image ever being loaded. When the @@ -511,6 +496,20 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + PRInt32 mFontScaler; + + nscolor mDefaultColor; + nscolor mBackgroundColor; + + nscolor mLinkColor; + nscolor mActiveLinkColor; + nscolor mVisitedLinkColor; + + nscolor mFocusBackgroundColor; + nscolor mFocusTextColor; + + PRUint8 mFocusRingWidth; + nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; }; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 70b6a15ddb5..8c1b3858094 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2310,45 +2310,40 @@ nsresult PresShell::SetPrefColorRules(void) if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); - nscolor bgColor; - nscolor textColor; - result = mPresContext->GetDefaultColor(&textColor); + nscolor bgColor = mPresContext->DefaultBackgroundColor(); + nscolor textColor = mPresContext->DefaultColor(); + + // get the DOM interface to the stylesheet + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); if (NS_SUCCEEDED(result)) { - result = mPresContext->GetDefaultBackgroundColor(&bgColor); - } - if (NS_SUCCEEDED(result)) { - // get the DOM interface to the stylesheet - nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); - if (NS_SUCCEEDED(result)) { - PRUint32 index = 0; - nsAutoString strColor, strBackgroundColor; + PRUint32 index = 0; + nsAutoString strColor, strBackgroundColor; - // create a rule for background and foreground color and - // add it to the style sheet - // - the rule is !important so it overrides all but author - // important rules (when put into an agent stylesheet) and - // all (even author important) when put into an override stylesheet + // create a rule for background and foreground color and + // add it to the style sheet + // - the rule is !important so it overrides all but author + // important rules (when put into an agent stylesheet) and + // all (even author important) when put into an override stylesheet - /////////////////////////////////////////////////////////////// - // - default colors: ':root {color:#RRGGBB !important; - // background: #RRGGBB !important;}' - ColorToString(textColor,strColor); - ColorToString(bgColor,strBackgroundColor); - result = sheet->InsertRule(NS_LITERAL_STRING(":root {color:") + - strColor + - NS_LITERAL_STRING(" !important; ") + - NS_LITERAL_STRING("border-color: -moz-use-text-color !important; ") + - NS_LITERAL_STRING("background:") + - strBackgroundColor + - NS_LITERAL_STRING(" !important; }"), - sInsertPrefSheetRulesAt, &index); - NS_ENSURE_SUCCESS(result, result); + /////////////////////////////////////////////////////////////// + // - default colors: ':root {color:#RRGGBB !important; + // background: #RRGGBB !important;}' + ColorToString(textColor,strColor); + ColorToString(bgColor,strBackgroundColor); + result = sheet->InsertRule(NS_LITERAL_STRING(":root {color:") + + strColor + + NS_LITERAL_STRING(" !important; ") + + NS_LITERAL_STRING("border-color: -moz-use-text-color !important; ") + + NS_LITERAL_STRING("background:") + + strBackgroundColor + + NS_LITERAL_STRING(" !important; }"), + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(result, result); - /////////////////////////////////////////////////////////////// - // - everything else inherits the color, and has transparent background - result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), - sInsertPrefSheetRulesAt, &index); - } + /////////////////////////////////////////////////////////////// + // - everything else inherits the color, and has transparent background + result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), + sInsertPrefSheetRulesAt, &index); } } } @@ -2405,17 +2400,10 @@ nsresult PresShell::SetPrefLinkRules(void) // though if using an override sheet this will cause authors grief still // In the agent stylesheet, they are !important when we are ignoring document colors - nscolor linkColor, activeColor, visitedColor; + nscolor linkColor(mPresContext->DefaultLinkColor()); + nscolor activeColor(mPresContext->DefaultActiveLinkColor()); + nscolor visitedColor(mPresContext->DefaultVisitedLinkColor()); - rv = mPresContext->GetDefaultLinkColor(&linkColor); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mPresContext->GetDefaultActiveLinkColor(&activeColor); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); - NS_ENSURE_SUCCESS(rv, rv); - PRBool useDocColors = PR_TRUE; mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); @@ -2484,10 +2472,10 @@ nsresult PresShell::SetPrefFocusRules(void) if (NS_SUCCEEDED(result)) { PRBool useFocusColors; mPresContext->GetUseFocusColors(useFocusColors); - nscolor focusBackground, focusText; - result = mPresContext->GetFocusBackgroundColor(&focusBackground); - nsresult result2 = mPresContext->GetFocusTextColor(&focusText); - if (useFocusColors && NS_SUCCEEDED(result) && NS_SUCCEEDED(result2)) { + if (useFocusColors) { + nscolor focusBackground(mPresContext->FocusBackgroundColor()); + nscolor focusText(mPresContext->FocusTextColor()); + // insert a rule to make focus the preferred color PRUint32 index = 0; nsAutoString strRule, strColor; @@ -2504,8 +2492,7 @@ nsresult PresShell::SetPrefFocusRules(void) // insert the rules result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } - PRUint8 focusRingWidth = 1; - result = mPresContext->GetFocusRingWidth(&focusRingWidth); + PRUint8 focusRingWidth = mPresContext->FocusRingWidth(); PRBool focusRingOnAnything; mPresContext->GetFocusRingOnAnything(focusRingOnAnything); diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index c241897f714..5f80bce28f5 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -185,16 +185,6 @@ public: virtual nsresult GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; - /** - * For a given frame tree, get a new style context that is the equivalent - * but within a new parent. The StyleContextParent of aFrame should be - * changed _before_ this method is called, so that style tree verification - * can take place correctly. - */ - NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext) = 0; - - NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; NS_IMETHOD FreeToShell(size_t aSize, void* aFreeChunk) = 0; @@ -203,10 +193,11 @@ public: */ NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0; - /** Get the default font correponding to the given ID */ - NS_IMETHOD GetDefaultFont(PRUint8 aFontID, const nsFont** aResult) = 0; - /** Set the default font correponding to the given ID */ - NS_IMETHOD SetDefaultFont(PRUint8 aFontID, const nsFont& aFont) = 0; + /** + * Get the default font correponding to the given ID. This object is + * read-only, you must copy the font to modify it. + */ + virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0; /** Get a cached boolean pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -225,30 +216,24 @@ public: /** * Access Nav's magic font scaler value */ - NS_IMETHOD GetFontScaler(PRInt32* aResult) = 0; - NS_IMETHOD SetFontScaler(PRInt32 aScaler) = 0; + PRInt32 FontScaler() const { return mFontScaler; } /** * Get the default colors */ - NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; + const nscolor DefaultColor() const { return mDefaultColor; } + const nscolor DefaultBackgroundColor() const { return mBackgroundColor; } + const nscolor DefaultLinkColor() const { return mLinkColor; } + const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; } + const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; } + const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } + const nscolor FocusTextColor() const { return mFocusTextColor; } + NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; - NS_IMETHOD GetFocusRingWidth(PRUint8 *focusRingWidth) = 0; + PRUint8 FocusRingWidth() const { return mFocusRingWidth; } NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; - NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; - /** * Load an image for the target frame. This call can be made * repeated with only a single image ever being loaded. When the @@ -511,6 +496,20 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + PRInt32 mFontScaler; + + nscolor mDefaultColor; + nscolor mBackgroundColor; + + nscolor mLinkColor; + nscolor mActiveLinkColor; + nscolor mVisitedLinkColor; + + nscolor mFocusBackgroundColor; + nscolor mFocusTextColor; + + PRUint8 mFocusRingWidth; + nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; }; diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index c241897f714..5f80bce28f5 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -185,16 +185,6 @@ public: virtual nsresult GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) = 0; - /** - * For a given frame tree, get a new style context that is the equivalent - * but within a new parent. The StyleContextParent of aFrame should be - * changed _before_ this method is called, so that style tree verification - * can take place correctly. - */ - NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext) = 0; - - NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult) = 0; NS_IMETHOD FreeToShell(size_t aSize, void* aFreeChunk) = 0; @@ -203,10 +193,11 @@ public: */ NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0; - /** Get the default font correponding to the given ID */ - NS_IMETHOD GetDefaultFont(PRUint8 aFontID, const nsFont** aResult) = 0; - /** Set the default font correponding to the given ID */ - NS_IMETHOD SetDefaultFont(PRUint8 aFontID, const nsFont& aFont) = 0; + /** + * Get the default font correponding to the given ID. This object is + * read-only, you must copy the font to modify it. + */ + virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0; /** Get a cached boolean pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -225,30 +216,24 @@ public: /** * Access Nav's magic font scaler value */ - NS_IMETHOD GetFontScaler(PRInt32* aResult) = 0; - NS_IMETHOD SetFontScaler(PRInt32 aScaler) = 0; + PRInt32 FontScaler() const { return mFontScaler; } /** * Get the default colors */ - NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; - NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; + const nscolor DefaultColor() const { return mDefaultColor; } + const nscolor DefaultBackgroundColor() const { return mBackgroundColor; } + const nscolor DefaultLinkColor() const { return mLinkColor; } + const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; } + const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; } + const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } + const nscolor FocusTextColor() const { return mFocusTextColor; } + NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; - NS_IMETHOD GetFocusRingWidth(PRUint8 *focusRingWidth) = 0; + PRUint8 FocusRingWidth() const { return mFocusRingWidth; } NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; - NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; - NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; - /** * Load an image for the target frame. This call can be made * repeated with only a single image ever being loaded. When the @@ -511,6 +496,20 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + PRInt32 mFontScaler; + + nscolor mDefaultColor; + nscolor mBackgroundColor; + + nscolor mLinkColor; + nscolor mActiveLinkColor; + nscolor mVisitedLinkColor; + + nscolor mFocusBackgroundColor; + nscolor mFocusTextColor; + + PRUint8 mFocusRingWidth; + nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; }; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index c4417843fba..44ebc12a012 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -169,7 +169,7 @@ nsPresContext::nsPresContext() mDefaultColor = NS_RGB(0x00, 0x00, 0x00); - mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); + mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); mUseDocumentColors = PR_TRUE; mUseDocumentFonts = PR_TRUE; @@ -184,7 +184,7 @@ nsPresContext::nsPresContext() mUseFocusColors = PR_FALSE; mFocusTextColor = mDefaultColor; - mFocusBackgroundColor = mDefaultBackgroundColor; + mFocusBackgroundColor = mBackgroundColor; mFocusRingWidth = 1; mFocusRingOnAnything = PR_FALSE; @@ -425,16 +425,16 @@ nsPresContext::GetDocumentColorPreferences() mDefaultColor = MakeColorPref(colorStr); } if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.background_color", getter_Copies(colorStr)))) { - mDefaultBackgroundColor = MakeColorPref(colorStr); + mBackgroundColor = MakeColorPref(colorStr); } } else { mDefaultColor = NS_RGB(0x00, 0x00, 0x00); - mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); + mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF); mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor); mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground, - mDefaultBackgroundColor); + mBackgroundColor); } if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) { @@ -474,7 +474,7 @@ nsPresContext::GetUserPreferences() if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_focus_colors", &boolPref))) { mUseFocusColors = boolPref; mFocusTextColor = mDefaultColor; - mFocusBackgroundColor = mDefaultBackgroundColor; + mFocusBackgroundColor = mBackgroundColor; if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.display.focus_text_color", getter_Copies(colorStr)))) { mFocusTextColor = MakeColorPref(colorStr); } @@ -849,23 +849,6 @@ nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::ReParentStyleContext(nsIFrame* aFrame, - nsStyleContext* aNewParentContext) -{ - NS_PRECONDITION(aFrame, "null ptr"); - if (! aFrame) { - return NS_ERROR_NULL_POINTER; - } - - nsCOMPtr manager; - nsresult rv = mShell->GetFrameManager(getter_AddRefs(manager)); - if (NS_SUCCEEDED(rv) && manager) { - rv = manager->ReParentStyleContext(aFrame, aNewParentContext); - } - return rv; -} - NS_IMETHODIMP nsPresContext::AllocateFromShell(size_t aSize, void** aResult) { @@ -899,137 +882,42 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetDefaultFont(PRUint8 aFontID, const nsFont** aResult) +const nsFont* +nsPresContext::GetDefaultFont(PRUint8 aFontID) const { - nsresult rv = NS_OK; + const nsFont *font; switch (aFontID) { // Special (our default variable width font and fixed width font) case kPresContext_DefaultVariableFont_ID: - *aResult = &mDefaultVariableFont; + font = &mDefaultVariableFont; break; case kPresContext_DefaultFixedFont_ID: - *aResult = &mDefaultFixedFont; + font = &mDefaultFixedFont; break; // CSS case kGenericFont_serif: - *aResult = &mDefaultSerifFont; + font = &mDefaultSerifFont; break; case kGenericFont_sans_serif: - *aResult = &mDefaultSansSerifFont; + font = &mDefaultSansSerifFont; break; case kGenericFont_monospace: - *aResult = &mDefaultMonospaceFont; + font = &mDefaultMonospaceFont; break; case kGenericFont_cursive: - *aResult = &mDefaultCursiveFont; + font = &mDefaultCursiveFont; break; case kGenericFont_fantasy: - *aResult = &mDefaultFantasyFont; + font = &mDefaultFantasyFont; break; default: - rv = NS_ERROR_INVALID_ARG; + font = nsnull; NS_ERROR("invalid arg"); break; } - return rv; + return font; } -NS_IMETHODIMP -nsPresContext::SetDefaultFont(PRUint8 aFontID, const nsFont& aFont) -{ - nsresult rv = NS_OK; - switch (aFontID) { - // Special (our default variable width font and fixed width font) - case kPresContext_DefaultVariableFont_ID: - mDefaultVariableFont = aFont; - break; - case kPresContext_DefaultFixedFont_ID: - mDefaultFixedFont = aFont; - break; - // CSS - case kGenericFont_serif: - mDefaultSerifFont = aFont; - break; - case kGenericFont_sans_serif: - mDefaultSansSerifFont = aFont; - break; - case kGenericFont_monospace: - mDefaultMonospaceFont = aFont; - break; - case kGenericFont_cursive: - mDefaultCursiveFont = aFont; - break; - case kGenericFont_fantasy: - mDefaultFantasyFont = aFont; - break; - default: - rv = NS_ERROR_INVALID_ARG; - NS_ERROR("invalid arg"); - break; - } - return rv; -} - -NS_IMETHODIMP -nsPresContext::GetFontScaler(PRInt32* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mFontScaler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetFontScaler(PRInt32 aScaler) -{ - mFontScaler = aScaler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultColor(nscolor* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mDefaultColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultBackgroundColor(nscolor* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - - *aResult = mDefaultBackgroundColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mLinkColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultActiveLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mActiveLinkColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetDefaultVisitedLinkColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mVisitedLinkColor; - return NS_OK; -} - - NS_IMETHODIMP nsPresContext::GetFocusRingOnAnything(PRBool& aFocusRingOnAnything) { @@ -1046,67 +934,6 @@ nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) } -NS_IMETHODIMP -nsPresContext::GetFocusTextColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mFocusTextColor; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::GetFocusBackgroundColor(nscolor* aColor) -{ - NS_PRECONDITION(aColor, "null out param"); - *aColor = mFocusBackgroundColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetFocusRingWidth(PRUint8 *aFocusRingWidth) -{ - NS_PRECONDITION(aFocusRingWidth, "null out param"); - *aFocusRingWidth = mFocusRingWidth; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::SetDefaultColor(nscolor aColor) -{ - mDefaultColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultBackgroundColor(nscolor aColor) -{ - mDefaultBackgroundColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultLinkColor(nscolor aColor) -{ - mLinkColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultActiveLinkColor(nscolor aColor) -{ - mActiveLinkColor = aColor; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetDefaultVisitedLinkColor(nscolor aColor) -{ - mVisitedLinkColor = aColor; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetVisibleArea(nsRect& aResult) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 203ebca75e8..7ccd8d9d31e 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -74,34 +74,15 @@ public: virtual void ClearStyleDataAndReflow(); virtual nsresult GetXBLBindingURL(nsIContent* aContent, nsIURI** aResult); - NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, - 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); - NS_IMETHOD GetDefaultFont(PRUint8 aFontID, const nsFont** aResult); - NS_IMETHOD SetDefaultFont(PRUint8 aFontID, const nsFont& aFont); + virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const; NS_IMETHOD GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue); NS_IMETHOD GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue); - NS_IMETHOD GetFontScaler(PRInt32* aResult); - NS_IMETHOD SetFontScaler(PRInt32 aScaler); - NS_IMETHOD GetDefaultColor(nscolor* aColor); - NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor); - NS_IMETHOD GetDefaultLinkColor(nscolor* aColor); - NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor); - NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor); - - NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor); - NS_IMETHOD GetFocusTextColor(nscolor* aColor); NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors); - NS_IMETHOD GetFocusRingWidth(PRUint8 *focusRingWidth); NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything); - NS_IMETHOD SetDefaultColor(nscolor aColor); - NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor); - NS_IMETHOD SetDefaultLinkColor(nscolor aColor); - NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor); - NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor); NS_IMETHOD LoadImage(nsIURI* aURL, nsIFrame* aTargetFrame, @@ -198,22 +179,11 @@ protected: nsFont mDefaultFantasyFont; nscoord mMinimumFontSize; - PRInt32 mFontScaler; - PRPackedBool mUseDocumentFonts; // set in GetUserPrefs PRPackedBool mUseDocumentColors; // set in GetUserPrefs PRPackedBool mUnderlineLinks; // set in GetUserPrefs PRPackedBool mUseFocusColors; // set in GetUserPrefs - nscolor mDefaultColor; // set in GetUserPrefs - nscolor mDefaultBackgroundColor; // set in GetUserPrefs - nscolor mLinkColor; // set in GetUserPrefs - nscolor mActiveLinkColor; // set in GetUserPrefs - nscolor mVisitedLinkColor; // set in GetUserPrefs - nscolor mFocusTextColor; // set in GetUserPrefs - nscolor mFocusBackgroundColor; // set in GetUserPrefs - - PRUint8 mFocusRingWidth; // set in GetUserPrefs PRPackedBool mFocusRingOnAnything; // set in GetUserPrefs PRPackedBool mDrawImageBackground; diff --git a/mozilla/layout/generic/nsFirstLetterFrame.cpp b/mozilla/layout/generic/nsFirstLetterFrame.cpp index 41f58980d40..0b3926f265e 100644 --- a/mozilla/layout/generic/nsFirstLetterFrame.cpp +++ b/mozilla/layout/generic/nsFirstLetterFrame.cpp @@ -44,6 +44,7 @@ #include "nsLayoutAtoms.h" #include "nsAutoPtr.h" #include "nsStyleSet.h" +#include "nsIFrameManager.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -160,8 +161,10 @@ nsFirstLetterFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame* aChildList) { mFrames.SetFrames(aChildList); + nsIFrameManager *frameManager = aPresContext->GetFrameManager(); + for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) { - aPresContext->ReParentStyleContext(frame, mStyleContext); + frameManager->ReParentStyleContext(frame, mStyleContext); } return NS_OK; } diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index e0d954e88cf..9e39ab4864b 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -49,6 +49,7 @@ #include "nsCSSAnonBoxes.h" #include "nsReflowPath.h" #include "nsAutoPtr.h" +#include "nsIFrameManager.h" #ifdef ACCESSIBILITY #include "nsIServiceManager.h" #include "nsIAccessibilityService.h" @@ -909,9 +910,11 @@ ReParentChildListStyle(nsIPresContext* aPresContext, nsStyleContext* aParentStyleContext, nsFrameList& aFrameList) { + nsIFrameManager *frameManager = aPresContext->GetFrameManager(); + for (nsIFrame* kid = aFrameList.FirstChild(); kid; kid = kid->GetNextSibling()) { - aPresContext->ReParentStyleContext(kid, aParentStyleContext); + frameManager->ReParentStyleContext(kid, aParentStyleContext); } } @@ -967,7 +970,8 @@ nsFirstLineFrame::PullOneFrame(nsIPresContext* aPresContext, InlineReflowState& if (frame && !mPrevInFlow) { // We are a first-line frame. Fixup the child frames // style-context that we just pulled. - aPresContext->ReParentStyleContext(frame, mStyleContext); + aPresContext->GetFrameManager()->ReParentStyleContext(frame, + mStyleContext); } return frame; } diff --git a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp index 41f58980d40..0b3926f265e 100644 --- a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp @@ -44,6 +44,7 @@ #include "nsLayoutAtoms.h" #include "nsAutoPtr.h" #include "nsStyleSet.h" +#include "nsIFrameManager.h" #define nsFirstLetterFrameSuper nsHTMLContainerFrame @@ -160,8 +161,10 @@ nsFirstLetterFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame* aChildList) { mFrames.SetFrames(aChildList); + nsIFrameManager *frameManager = aPresContext->GetFrameManager(); + for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) { - aPresContext->ReParentStyleContext(frame, mStyleContext); + frameManager->ReParentStyleContext(frame, mStyleContext); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index e0d954e88cf..9e39ab4864b 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -49,6 +49,7 @@ #include "nsCSSAnonBoxes.h" #include "nsReflowPath.h" #include "nsAutoPtr.h" +#include "nsIFrameManager.h" #ifdef ACCESSIBILITY #include "nsIServiceManager.h" #include "nsIAccessibilityService.h" @@ -909,9 +910,11 @@ ReParentChildListStyle(nsIPresContext* aPresContext, nsStyleContext* aParentStyleContext, nsFrameList& aFrameList) { + nsIFrameManager *frameManager = aPresContext->GetFrameManager(); + for (nsIFrame* kid = aFrameList.FirstChild(); kid; kid = kid->GetNextSibling()) { - aPresContext->ReParentStyleContext(kid, aParentStyleContext); + frameManager->ReParentStyleContext(kid, aParentStyleContext); } } @@ -967,7 +970,8 @@ nsFirstLineFrame::PullOneFrame(nsIPresContext* aPresContext, InlineReflowState& if (frame && !mPrevInFlow) { // We are a first-line frame. Fixup the child frames // style-context that we just pulled. - aPresContext->ReParentStyleContext(frame, mStyleContext); + aPresContext->GetFrameManager()->ReParentStyleContext(frame, + mStyleContext); } return frame; } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 70b6a15ddb5..8c1b3858094 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -2310,45 +2310,40 @@ nsresult PresShell::SetPrefColorRules(void) if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); - nscolor bgColor; - nscolor textColor; - result = mPresContext->GetDefaultColor(&textColor); + nscolor bgColor = mPresContext->DefaultBackgroundColor(); + nscolor textColor = mPresContext->DefaultColor(); + + // get the DOM interface to the stylesheet + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); if (NS_SUCCEEDED(result)) { - result = mPresContext->GetDefaultBackgroundColor(&bgColor); - } - if (NS_SUCCEEDED(result)) { - // get the DOM interface to the stylesheet - nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); - if (NS_SUCCEEDED(result)) { - PRUint32 index = 0; - nsAutoString strColor, strBackgroundColor; + PRUint32 index = 0; + nsAutoString strColor, strBackgroundColor; - // create a rule for background and foreground color and - // add it to the style sheet - // - the rule is !important so it overrides all but author - // important rules (when put into an agent stylesheet) and - // all (even author important) when put into an override stylesheet + // create a rule for background and foreground color and + // add it to the style sheet + // - the rule is !important so it overrides all but author + // important rules (when put into an agent stylesheet) and + // all (even author important) when put into an override stylesheet - /////////////////////////////////////////////////////////////// - // - default colors: ':root {color:#RRGGBB !important; - // background: #RRGGBB !important;}' - ColorToString(textColor,strColor); - ColorToString(bgColor,strBackgroundColor); - result = sheet->InsertRule(NS_LITERAL_STRING(":root {color:") + - strColor + - NS_LITERAL_STRING(" !important; ") + - NS_LITERAL_STRING("border-color: -moz-use-text-color !important; ") + - NS_LITERAL_STRING("background:") + - strBackgroundColor + - NS_LITERAL_STRING(" !important; }"), - sInsertPrefSheetRulesAt, &index); - NS_ENSURE_SUCCESS(result, result); + /////////////////////////////////////////////////////////////// + // - default colors: ':root {color:#RRGGBB !important; + // background: #RRGGBB !important;}' + ColorToString(textColor,strColor); + ColorToString(bgColor,strBackgroundColor); + result = sheet->InsertRule(NS_LITERAL_STRING(":root {color:") + + strColor + + NS_LITERAL_STRING(" !important; ") + + NS_LITERAL_STRING("border-color: -moz-use-text-color !important; ") + + NS_LITERAL_STRING("background:") + + strBackgroundColor + + NS_LITERAL_STRING(" !important; }"), + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(result, result); - /////////////////////////////////////////////////////////////// - // - everything else inherits the color, and has transparent background - result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), - sInsertPrefSheetRulesAt, &index); - } + /////////////////////////////////////////////////////////////// + // - everything else inherits the color, and has transparent background + result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), + sInsertPrefSheetRulesAt, &index); } } } @@ -2405,17 +2400,10 @@ nsresult PresShell::SetPrefLinkRules(void) // though if using an override sheet this will cause authors grief still // In the agent stylesheet, they are !important when we are ignoring document colors - nscolor linkColor, activeColor, visitedColor; + nscolor linkColor(mPresContext->DefaultLinkColor()); + nscolor activeColor(mPresContext->DefaultActiveLinkColor()); + nscolor visitedColor(mPresContext->DefaultVisitedLinkColor()); - rv = mPresContext->GetDefaultLinkColor(&linkColor); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mPresContext->GetDefaultActiveLinkColor(&activeColor); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); - NS_ENSURE_SUCCESS(rv, rv); - PRBool useDocColors = PR_TRUE; mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); @@ -2484,10 +2472,10 @@ nsresult PresShell::SetPrefFocusRules(void) if (NS_SUCCEEDED(result)) { PRBool useFocusColors; mPresContext->GetUseFocusColors(useFocusColors); - nscolor focusBackground, focusText; - result = mPresContext->GetFocusBackgroundColor(&focusBackground); - nsresult result2 = mPresContext->GetFocusTextColor(&focusText); - if (useFocusColors && NS_SUCCEEDED(result) && NS_SUCCEEDED(result2)) { + if (useFocusColors) { + nscolor focusBackground(mPresContext->FocusBackgroundColor()); + nscolor focusText(mPresContext->FocusTextColor()); + // insert a rule to make focus the preferred color PRUint32 index = 0; nsAutoString strRule, strColor; @@ -2504,8 +2492,7 @@ nsresult PresShell::SetPrefFocusRules(void) // insert the rules result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } - PRUint8 focusRingWidth = 1; - result = mPresContext->GetFocusRingWidth(&focusRingWidth); + PRUint8 focusRingWidth = mPresContext->FocusRingWidth(); PRBool focusRingOnAnything; mPresContext->GetFocusRingOnAnything(focusRingOnAnything); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index eca6ddb2510..e23f63e43ca 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1032,7 +1032,8 @@ MoveChildrenTo(nsIPresContext* aPresContext, // anonymous block frame, but oddly they aren't -- need to // investigate that...) if (aNewParentSC) - aPresContext->ReParentStyleContext(aFrameList, aNewParentSC); + aPresContext->GetFrameManager()->ReParentStyleContext(aFrameList, + aNewParentSC); #endif aFrameList = aFrameList->GetNextSibling(); @@ -2763,7 +2764,8 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context if (aIsPseudoParent) { - aPresContext->ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); + aPresContext->GetFrameManager()-> + ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); } // construct additional col frames if the col frame has a span > 1 @@ -11489,7 +11491,8 @@ ReparentFrame(nsIPresContext* aPresContext, nsIFrame* aFrame) { aFrame->SetParent(aNewParentFrame); - aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); + aPresContext->GetFrameManager()->ReParentStyleContext(aFrame, + aParentStyleContext); } // Special routine to handle placing a list of frames into a block diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 13448530d75..c64f202fb11 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -2825,7 +2825,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext, // Ensure that we always paint a color for the root (in case there's // no background at all or a partly transparent image). canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT; - aPresContext->GetDefaultBackgroundColor(&canvasColor.mBackgroundColor); + canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor(); } } } diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index db66575508e..0b4e4a9a75b 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -701,6 +701,8 @@ nsresult nsMathMLContainerFrame::WrapForeignFrames(nsIPresContext* aPresContext) { nsIFrame* next = mFrames.FirstChild(); + nsIFrameManager *frameManager = aPresContext->GetFrameManager(); + while (next) { nsIFrame* child = next; next = next->GetNextSibling(); @@ -725,7 +727,7 @@ nsMathMLContainerFrame::WrapForeignFrames(nsIPresContext* aPresContext) mFrames.ReplaceFrame(aPresContext, this, child, wrapper, PR_FALSE); child->SetParent(wrapper); child->SetNextSibling(nsnull); - aPresContext->ReParentStyleContext(child, newStyleContext); + frameManager->ReParentStyleContext(child, newStyleContext); wrapper->SetInitialChildList(aPresContext, nsnull, child); } } diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp index 5f95a27fc0e..2fda5ddd6e9 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.cpp +++ b/mozilla/layout/style/nsComputedDOMStyle.cpp @@ -511,9 +511,9 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame, const nsString& fontName = font->mFont.name; PRUint8 generic = font->mFlags & NS_STYLE_FONT_FACE_MASK; if (generic == kGenericFont_NONE) { - const nsFont* defaultFont; - presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, - &defaultFont); + const nsFont* defaultFont = + presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + PRInt32 lendiff = fontName.Length() - defaultFont->name.Length(); if (lendiff > 0) { val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index c26daf94c1f..71258427a68 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -339,19 +339,13 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor, else { switch (intValue) { case NS_COLOR_MOZ_HYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultLinkColor(); break; case NS_COLOR_MOZ_VISITEDHYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultVisitedLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultVisitedLinkColor(); break; case NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT: - if (NS_SUCCEEDED(aPresContext->GetDefaultActiveLinkColor(&aResult))) { - result = PR_TRUE; - } + aResult = aPresContext->DefaultActiveLinkColor(); break; default: NS_NOTREACHED("Should never have an unknown negative colorID."); @@ -1518,10 +1512,11 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, const nsFont& aDefaultFont, const nsStyleFont* aParentFont, nsStyleFont* aFont, PRBool& aInherited) { - const nsFont* defaultVariableFont; - const nsFont* defaultFixedFont; - aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, &defaultVariableFont); - aPresContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID, &defaultFixedFont); + const nsFont* defaultVariableFont = + aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + + const nsFont* defaultFixedFont = + aPresContext->GetDefaultFont(kPresContext_DefaultFixedFont_ID); // font-family: string list, enum, inherit if (eCSSUnit_String == aFontData.mFamily.GetUnit()) { @@ -1680,8 +1675,7 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext, PRBool zoom = PR_FALSE; if (eCSSUnit_Enumerated == aFontData.mSize.GetUnit()) { PRInt32 value = aFontData.mSize.GetIntValue(); - PRInt32 scaler; - aPresContext->GetFontScaler(&scaler); + PRInt32 scaler = aPresContext->FontScaler(); float scaleFactor = nsStyleUtil::GetScalingFactor(scaler); zoom = PR_TRUE; @@ -1790,8 +1784,7 @@ nsRuleNode::SetGenericFont(nsIPresContext* aPresContext, // If we stopped earlier because we reached the root of the style tree, // we will start with the default generic font from the presentation // context. Otherwise we start with the higher context. - const nsFont* defaultFont; - aPresContext->GetDefaultFont(aGenericFontID, &defaultFont); + const nsFont* defaultFont = aPresContext->GetDefaultFont(aGenericFontID); nsStyleFont parentFont(*defaultFont); parentFont.mSize = parentFont.mFont.size = nsStyleFont::ZoomText(aPresContext, parentFont.mSize); @@ -1944,9 +1937,9 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, if (generic == kGenericFont_NONE) { // continue the normal processing // our default font is the most recent generic font - const nsFont* defaultFont; - mPresContext->GetDefaultFont(parentFont->mFlags & NS_STYLE_FONT_FACE_MASK, - &defaultFont); + const nsFont* defaultFont = + mPresContext->GetDefaultFont(parentFont->mFlags & NS_STYLE_FONT_FACE_MASK); + nsRuleNode::SetFont(mPresContext, aContext, minimumFontSize, useDocumentFonts, PR_FALSE, fontData, *defaultFont, parentFont, font, inherited); diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index a209a1fb363..4157878cafc 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -190,9 +190,9 @@ nsStyleFont::nsStyleFont(const nsStyleFont& aSrc) nsStyleFont::nsStyleFont(nsIPresContext* aPresContext) : mFlags(NS_STYLE_FONT_DEFAULT) { - const nsFont* defaultFont; - aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, - &defaultFont); + const nsFont* defaultFont = + aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID); + mFont = *defaultFont; mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size); } @@ -943,7 +943,7 @@ nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther nsStyleColor::nsStyleColor(nsIPresContext* aPresContext) { - aPresContext->GetDefaultColor(&mColor); + mColor = aPresContext->DefaultColor(); } nsStyleColor::nsStyleColor(const nsStyleColor& aSource) @@ -970,7 +970,7 @@ nsStyleBackground::nsStyleBackground(nsIPresContext* aPresContext) mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING), mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY) { - aPresContext->GetDefaultBackgroundColor(&mBackgroundColor); + mBackgroundColor = aPresContext->DefaultBackgroundColor(); } nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)