From 3191a1feaadc4662dcc453040d33ef58352999e0 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Fri, 20 Feb 2004 17:49:01 +0000 Subject: [PATCH] Inline boolean getters and setters on nsIPresContext, and change the storage to a bitfield. Bug 229371, r+sr=roc. git-svn-id: svn://10.0.0.236/trunk@153018 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsCopySupport.cpp | 6 +- mozilla/content/base/src/nsRuleNode.cpp | 19 ++-- mozilla/layout/base/nsBidiPresUtils.cpp | 2 +- mozilla/layout/base/nsCSSRendering.cpp | 4 +- mozilla/layout/base/nsPresContext.cpp | 81 +-------------- mozilla/layout/base/nsPresContext.h | 81 ++++++++++++--- mozilla/layout/base/nsPresShell.cpp | 99 +++++++++---------- mozilla/layout/base/public/nsIPresContext.h | 81 ++++++++++++--- mozilla/layout/base/public/nsPresContext.h | 81 ++++++++++++--- mozilla/layout/base/src/nsBidiPresUtils.cpp | 2 +- mozilla/layout/base/src/nsCopySupport.cpp | 6 +- mozilla/layout/base/src/nsPresContext.cpp | 81 +-------------- mozilla/layout/base/src/nsPresContext.h | 38 ------- mozilla/layout/forms/nsListControlFrame.cpp | 4 +- mozilla/layout/generic/nsBlockFrame.cpp | 4 +- mozilla/layout/generic/nsFrame.cpp | 4 +- mozilla/layout/generic/nsHTMLReflowState.cpp | 4 +- mozilla/layout/generic/nsLineLayout.cpp | 2 +- mozilla/layout/generic/nsTextFrame.cpp | 26 ++--- mozilla/layout/generic/nsTextTransformer.cpp | 7 +- mozilla/layout/html/base/src/nsBlockFrame.cpp | 4 +- mozilla/layout/html/base/src/nsFrame.cpp | 4 +- .../html/base/src/nsHTMLReflowState.cpp | 4 +- mozilla/layout/html/base/src/nsLineLayout.cpp | 2 +- mozilla/layout/html/base/src/nsPresShell.cpp | 99 +++++++++---------- mozilla/layout/html/base/src/nsTextFrame.cpp | 26 ++--- .../html/base/src/nsTextTransformer.cpp | 7 +- .../html/forms/src/nsListControlFrame.cpp | 4 +- .../layout/html/style/src/nsCSSRendering.cpp | 4 +- .../layout/mathml/base/src/nsMathMLChar.cpp | 5 +- mozilla/layout/style/nsRuleNode.cpp | 19 ++-- 31 files changed, 362 insertions(+), 448 deletions(-) diff --git a/mozilla/content/base/src/nsCopySupport.cpp b/mozilla/content/base/src/nsCopySupport.cpp index 7eed6dc6b70..8220d7dc532 100644 --- a/mozilla/content/base/src/nsCopySupport.cpp +++ b/mozilla/content/base/src/nsCopySupport.cpp @@ -152,12 +152,10 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 context->IsArabicEncoding(arabicCharset); if (arabicCharset) { PRUint32 bidiOptions; - PRBool isVisual; - PRBool isBidiSystem; + PRBool isBidiSystem = context->IsBidiSystem(); + PRBool isVisual = context->IsVisualMode(); context->GetBidi(&bidiOptions); - context->IsVisualMode(isVisual); - context->GetIsBidiSystem(isBidiSystem); if ( (GET_BIDI_OPTION_CLIPBOARDTEXTMODE(bidiOptions) == IBMBIDI_CLIPBOARDTEXTMODE_LOGICAL)&&(isVisual) ) { nsAutoString newBuffer; diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index d82a2474ceb..31238272341 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -1990,7 +1990,8 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // MJA: bug 31816 // if we are not using document fonts, but this is a XUL document, // then we use the document fonts anyway - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts, useDocumentFonts); + useDocumentFonts = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts); if (!useDocumentFonts) { // check if the prefs have been disabled for this shell // - if prefs are disabled then we use the document fonts anyway (yet another override) @@ -2224,15 +2225,13 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, PRInt32 td = textData.mDecoration.GetIntValue(); text->mTextDecoration = td; if (td & NS_STYLE_TEXT_DECORATION_PREF_ANCHORS) { - PRBool underlineLinks = PR_TRUE; - nsresult res = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); - if (NS_SUCCEEDED(res)) { - if (underlineLinks) { - text->mTextDecoration |= NS_STYLE_TEXT_DECORATION_UNDERLINE; - } - else { - text->mTextDecoration &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE; - } + PRBool underlineLinks = + mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks); + if (underlineLinks) { + text->mTextDecoration |= NS_STYLE_TEXT_DECORATION_UNDERLINE; + } + else { + text->mTextDecoration &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE; } } } diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index 105315cf71a..f4248039168 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -236,7 +236,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, if (aIsVisualFormControl) { isVisual = PR_FALSE; } else { - aPresContext->IsVisualMode(isVisual); + isVisual = aPresContext->IsVisualMode(); } mSuccess = mBidiEngine->CountRuns(&runCount); if (NS_FAILED(mSuccess) ) { diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index ad157fb78a6..029f9faaf5d 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -2822,8 +2822,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, PRBool canDrawBackgroundColor = PR_TRUE; if (aUsePrintSettings) { - aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage); - aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor); + canDrawBackgroundImage = aPresContext->GetBackgroundImageDraw(); + canDrawBackgroundColor = aPresContext->GetBackgroundColorDraw(); } // Check to see if we have an appearance defined. If so, we let the theme diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index c5f69f99936..417980e7510 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -150,8 +150,7 @@ nsPresContext::nsPresContext() mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)), mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)), - mNoTheme(PR_FALSE) + NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)) { mCompatibilityMode = eCompatibility_FullStandards; mImageAnimationMode = imgIContainer::kNormalAnimMode; @@ -160,9 +159,6 @@ nsPresContext::nsPresContext() SetBackgroundImageDraw(PR_TRUE); // always draw the background SetBackgroundColorDraw(PR_TRUE); - mStopped = PR_FALSE; - mStopChrome = PR_TRUE; - mShell = nsnull; mLinkHandler = nsnull; mContainer = nsnull; @@ -537,28 +533,6 @@ nsPresContext::GetUserPreferences() #endif } -NS_IMETHODIMP -nsPresContext::GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue) -{ - nsresult rv = NS_OK; - - switch (aPrefType) { - case kPresContext_UseDocumentFonts : - aValue = mUseDocumentFonts; - break; - case kPresContext_UseDocumentColors: - aValue = mUseDocumentColors; - break; - case kPresContext_UnderlineLinks: - aValue = mUnderlineLinks; - break; - default : - rv = NS_ERROR_INVALID_ARG; - NS_ERROR("invalid arg"); - } - return rv; -} - NS_IMETHODIMP nsPresContext::GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue) { @@ -914,22 +888,6 @@ nsPresContext::GetDefaultFont(PRUint8 aFontID) const return font; } -NS_IMETHODIMP -nsPresContext::GetFocusRingOnAnything(PRBool& aFocusRingOnAnything) -{ - aFocusRingOnAnything = mFocusRingOnAnything; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) -{ - aUseFocusColors = mUseFocusColors; - return NS_OK; -} - - NS_IMETHODIMP nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const { @@ -1144,20 +1102,6 @@ nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const return NS_OK; } -NS_IMETHODIMP -nsPresContext::SetVisualMode(PRBool aIsVisual) -{ - mIsVisual = aIsVisual; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::IsVisualMode(PRBool& aIsVisual) const -{ - aIsVisual = mIsVisual; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils) { @@ -1202,20 +1146,6 @@ NS_IMETHODIMP nsPresContext::GetBidi(PRUint32* aDest) const } //Mohamed 17-1-01 -NS_IMETHODIMP -nsPresContext::SetIsBidiSystem(PRBool aIsBidi) -{ - mIsBidiSystem = aIsBidi; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetIsBidiSystem(PRBool& aResult) const -{ - aResult = mIsBidiSystem; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetBidiCharset(nsACString &aCharSet) const { @@ -1236,15 +1166,6 @@ nsPresContext::GetLanguageSpecificTransformType( return NS_OK; } -NS_IMETHODIMP -nsPresContext::IsRenderingOnlySelection(PRBool* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mIsRenderingOnlySelection; - - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetTheme(nsITheme** aResult) { diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 59e3359735e..d256f2025fd 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -206,7 +206,23 @@ public: and the aValue argument is undefined, otherwise aValue is set to the value of the boolean pref */ // * - initially created for bugs 31816, 20760, 22963 - NS_IMETHOD GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue) = 0; + PRBool GetCachedBoolPref(PRUint32 aPrefType) const + { + // If called with a constant parameter, the compiler should optimize + // this switch statement away. + switch (aPrefType) { + case kPresContext_UseDocumentFonts: + return mUseDocumentFonts; + case kPresContext_UseDocumentColors: + return mUseDocumentColors; + case kPresContext_UnderlineLinks: + return mUnderlineLinks; + default: + NS_ERROR("Invalid arg passed to GetCachedBoolPref"); + } + + return PR_FALSE; + } /** Get a cached integer pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -231,9 +247,9 @@ public: const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } const nscolor FocusTextColor() const { return mFocusTextColor; } - NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; + PRBool GetUseFocusColors() const { return mUseFocusColors; } PRUint8 FocusRingWidth() const { return mFocusRingWidth; } - NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; + PRBool GetFocusRingOnAnything() const { return mFocusRingOnAnything; } /** @@ -347,10 +363,19 @@ public: /** * Set and get methods for controling the background drawing */ - NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0; - NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0; + PRBool GetBackgroundImageDraw() const { return mDrawImageBackground; } + void SetBackgroundImageDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawImageBackground = aCanDraw; + } + + PRBool GetBackgroundColorDraw() const { return mDrawColorBackground; } + void SetBackgroundColorDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawColorBackground = aCanDraw; + } #ifdef IBMBIDI /** @@ -383,14 +408,18 @@ public: * * @lina 05/02/2000 */ - NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0; + void SetVisualMode(PRBool aIsVisual) + { + NS_ASSERTION(!(aIsVisual & ~1), "Value must be true or false"); + mIsVisual = aIsVisual; + } /** * Check whether the content should be treated as visual. * * @lina 05/02/2000 */ - NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0; + PRBool IsVisualMode() const { return mIsVisual; } //Mohamed @@ -426,13 +455,17 @@ public: * Set the Bidi capabilities of the system * @param aIsBidi == TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0; + void SetIsBidiSystem(PRBool aIsBidi) + { + NS_ASSERTION(!(aIsBidi & ~1), "Value must be true or false"); + mIsBidiSystem = aIsBidi; + } /** * Get the Bidi capabilities of the system - * @return aResult == TRUE if the system has the capability of reordering Bidi text + * @return TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0; + PRBool IsBidiSystem() const { return mIsBidiSystem; } /** * Get the document charset @@ -445,8 +478,13 @@ public: /** * Render only Selection */ - NS_IMETHOD SetIsRenderingOnlySelection(PRBool aResult) = 0; - NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; + void SetIsRenderingOnlySelection(PRBool aResult) + { + NS_ASSERTION(!(aResult & ~1), "Value must be true or false"); + mIsRenderingOnlySelection = aResult; + } + + PRBool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; } /* * Obtain a native them for rendering our widgets (both form controls and html) @@ -518,6 +556,21 @@ protected: nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; + + unsigned mUseDocumentFonts : 1; + unsigned mUseDocumentColors : 1; + unsigned mUnderlineLinks : 1; + unsigned mUseFocusColors : 1; + unsigned mFocusRingOnAnything : 1; + unsigned mDrawImageBackground : 1; + unsigned mDrawColorBackground : 1; + unsigned mNeverAnimate : 1; + unsigned mIsRenderingOnlySelection : 1; + unsigned mNoTheme : 1; +#ifdef IBMBIDI + unsigned mIsVisual : 1; + unsigned mIsBidiSystem : 1; +#endif }; // Bit values for StartLoadImage's aImageStatus diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index b7824182755..9b2ee4b8383 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2292,58 +2292,57 @@ nsresult PresShell::SetPrefColorRules(void) NS_ASSERTION(mPresContext,"null prescontext not allowed"); if (mPresContext) { nsresult result = NS_OK; - PRBool useDocColors = PR_TRUE; // see if we need to create the rules first - if (NS_SUCCEEDED(mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors))) { - if (!useDocColors) { + PRBool useDocColors = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors); + if (!useDocColors) { #ifdef DEBUG_attinasi - printf(" - Creating rules for document colors\n"); + printf(" - Creating rules for document colors\n"); #endif - // OK, not using document colors, so we have to force the user's colors via style rules - if (!mPrefStyleSheet) { - result = CreatePreferenceStyleSheet(); - } + // OK, not using document colors, so we have to force the user's colors via style rules + if (!mPrefStyleSheet) { + result = CreatePreferenceStyleSheet(); + } + if (NS_SUCCEEDED(result)) { + NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + + 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)) { - NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + PRUint32 index = 0; + nsAutoString strColor, strBackgroundColor; - 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)) { - 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); } } } @@ -2403,8 +2402,8 @@ nsresult PresShell::SetPrefLinkRules(void) nscolor activeColor(mPresContext->DefaultActiveLinkColor()); nscolor visitedColor(mPresContext->DefaultVisitedLinkColor()); - PRBool useDocColors = PR_TRUE; - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); + PRBool useDocColors = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); NS_NAMED_LITERAL_STRING(importantStr, "!important}"); const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; @@ -2432,9 +2431,8 @@ nsresult PresShell::SetPrefLinkRules(void) sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(rv, rv); - PRBool underlineLinks = PR_TRUE; - rv = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); - NS_ENSURE_SUCCESS(rv, rv); + PRBool underlineLinks = + mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks); if (underlineLinks) { // create a rule to make underlining happen @@ -2469,9 +2467,7 @@ nsresult PresShell::SetPrefFocusRules(void) // get the DOM interface to the stylesheet nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); if (NS_SUCCEEDED(result)) { - PRBool useFocusColors; - mPresContext->GetUseFocusColors(useFocusColors); - if (useFocusColors) { + if (mPresContext->GetUseFocusColors()) { nscolor focusBackground(mPresContext->FocusBackgroundColor()); nscolor focusText(mPresContext->FocusTextColor()); @@ -2492,8 +2488,7 @@ nsresult PresShell::SetPrefFocusRules(void) result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } PRUint8 focusRingWidth = mPresContext->FocusRingWidth(); - PRBool focusRingOnAnything; - mPresContext->GetFocusRingOnAnything(focusRingOnAnything); + PRBool focusRingOnAnything = mPresContext->GetFocusRingOnAnything(); if ((NS_SUCCEEDED(result) && focusRingWidth != 1 && focusRingWidth <= 4 ) || focusRingOnAnything) { PRUint32 index = 0; diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 59e3359735e..d256f2025fd 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -206,7 +206,23 @@ public: and the aValue argument is undefined, otherwise aValue is set to the value of the boolean pref */ // * - initially created for bugs 31816, 20760, 22963 - NS_IMETHOD GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue) = 0; + PRBool GetCachedBoolPref(PRUint32 aPrefType) const + { + // If called with a constant parameter, the compiler should optimize + // this switch statement away. + switch (aPrefType) { + case kPresContext_UseDocumentFonts: + return mUseDocumentFonts; + case kPresContext_UseDocumentColors: + return mUseDocumentColors; + case kPresContext_UnderlineLinks: + return mUnderlineLinks; + default: + NS_ERROR("Invalid arg passed to GetCachedBoolPref"); + } + + return PR_FALSE; + } /** Get a cached integer pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -231,9 +247,9 @@ public: const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } const nscolor FocusTextColor() const { return mFocusTextColor; } - NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; + PRBool GetUseFocusColors() const { return mUseFocusColors; } PRUint8 FocusRingWidth() const { return mFocusRingWidth; } - NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; + PRBool GetFocusRingOnAnything() const { return mFocusRingOnAnything; } /** @@ -347,10 +363,19 @@ public: /** * Set and get methods for controling the background drawing */ - NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0; - NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0; + PRBool GetBackgroundImageDraw() const { return mDrawImageBackground; } + void SetBackgroundImageDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawImageBackground = aCanDraw; + } + + PRBool GetBackgroundColorDraw() const { return mDrawColorBackground; } + void SetBackgroundColorDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawColorBackground = aCanDraw; + } #ifdef IBMBIDI /** @@ -383,14 +408,18 @@ public: * * @lina 05/02/2000 */ - NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0; + void SetVisualMode(PRBool aIsVisual) + { + NS_ASSERTION(!(aIsVisual & ~1), "Value must be true or false"); + mIsVisual = aIsVisual; + } /** * Check whether the content should be treated as visual. * * @lina 05/02/2000 */ - NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0; + PRBool IsVisualMode() const { return mIsVisual; } //Mohamed @@ -426,13 +455,17 @@ public: * Set the Bidi capabilities of the system * @param aIsBidi == TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0; + void SetIsBidiSystem(PRBool aIsBidi) + { + NS_ASSERTION(!(aIsBidi & ~1), "Value must be true or false"); + mIsBidiSystem = aIsBidi; + } /** * Get the Bidi capabilities of the system - * @return aResult == TRUE if the system has the capability of reordering Bidi text + * @return TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0; + PRBool IsBidiSystem() const { return mIsBidiSystem; } /** * Get the document charset @@ -445,8 +478,13 @@ public: /** * Render only Selection */ - NS_IMETHOD SetIsRenderingOnlySelection(PRBool aResult) = 0; - NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; + void SetIsRenderingOnlySelection(PRBool aResult) + { + NS_ASSERTION(!(aResult & ~1), "Value must be true or false"); + mIsRenderingOnlySelection = aResult; + } + + PRBool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; } /* * Obtain a native them for rendering our widgets (both form controls and html) @@ -518,6 +556,21 @@ protected: nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; + + unsigned mUseDocumentFonts : 1; + unsigned mUseDocumentColors : 1; + unsigned mUnderlineLinks : 1; + unsigned mUseFocusColors : 1; + unsigned mFocusRingOnAnything : 1; + unsigned mDrawImageBackground : 1; + unsigned mDrawColorBackground : 1; + unsigned mNeverAnimate : 1; + unsigned mIsRenderingOnlySelection : 1; + unsigned mNoTheme : 1; +#ifdef IBMBIDI + unsigned mIsVisual : 1; + unsigned mIsBidiSystem : 1; +#endif }; // Bit values for StartLoadImage's aImageStatus diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 59e3359735e..d256f2025fd 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -206,7 +206,23 @@ public: and the aValue argument is undefined, otherwise aValue is set to the value of the boolean pref */ // * - initially created for bugs 31816, 20760, 22963 - NS_IMETHOD GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue) = 0; + PRBool GetCachedBoolPref(PRUint32 aPrefType) const + { + // If called with a constant parameter, the compiler should optimize + // this switch statement away. + switch (aPrefType) { + case kPresContext_UseDocumentFonts: + return mUseDocumentFonts; + case kPresContext_UseDocumentColors: + return mUseDocumentColors; + case kPresContext_UnderlineLinks: + return mUnderlineLinks; + default: + NS_ERROR("Invalid arg passed to GetCachedBoolPref"); + } + + return PR_FALSE; + } /** Get a cached integer pref, by its type if the type is not supported, then NS_ERROR_INVALID_ARG is returned @@ -231,9 +247,9 @@ public: const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } const nscolor FocusTextColor() const { return mFocusTextColor; } - NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors) = 0; + PRBool GetUseFocusColors() const { return mUseFocusColors; } PRUint8 FocusRingWidth() const { return mFocusRingWidth; } - NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything) = 0; + PRBool GetFocusRingOnAnything() const { return mFocusRingOnAnything; } /** @@ -347,10 +363,19 @@ public: /** * Set and get methods for controling the background drawing */ - NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0; - NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0; - NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0; + PRBool GetBackgroundImageDraw() const { return mDrawImageBackground; } + void SetBackgroundImageDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawImageBackground = aCanDraw; + } + + PRBool GetBackgroundColorDraw() const { return mDrawColorBackground; } + void SetBackgroundColorDraw(PRBool aCanDraw) + { + NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false"); + mDrawColorBackground = aCanDraw; + } #ifdef IBMBIDI /** @@ -383,14 +408,18 @@ public: * * @lina 05/02/2000 */ - NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0; + void SetVisualMode(PRBool aIsVisual) + { + NS_ASSERTION(!(aIsVisual & ~1), "Value must be true or false"); + mIsVisual = aIsVisual; + } /** * Check whether the content should be treated as visual. * * @lina 05/02/2000 */ - NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0; + PRBool IsVisualMode() const { return mIsVisual; } //Mohamed @@ -426,13 +455,17 @@ public: * Set the Bidi capabilities of the system * @param aIsBidi == TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0; + void SetIsBidiSystem(PRBool aIsBidi) + { + NS_ASSERTION(!(aIsBidi & ~1), "Value must be true or false"); + mIsBidiSystem = aIsBidi; + } /** * Get the Bidi capabilities of the system - * @return aResult == TRUE if the system has the capability of reordering Bidi text + * @return TRUE if the system has the capability of reordering Bidi text */ - NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0; + PRBool IsBidiSystem() const { return mIsBidiSystem; } /** * Get the document charset @@ -445,8 +478,13 @@ public: /** * Render only Selection */ - NS_IMETHOD SetIsRenderingOnlySelection(PRBool aResult) = 0; - NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; + void SetIsRenderingOnlySelection(PRBool aResult) + { + NS_ASSERTION(!(aResult & ~1), "Value must be true or false"); + mIsRenderingOnlySelection = aResult; + } + + PRBool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; } /* * Obtain a native them for rendering our widgets (both form controls and html) @@ -518,6 +556,21 @@ protected: nsCompatibility mCompatibilityMode; PRUint16 mImageAnimationMode; + + unsigned mUseDocumentFonts : 1; + unsigned mUseDocumentColors : 1; + unsigned mUnderlineLinks : 1; + unsigned mUseFocusColors : 1; + unsigned mFocusRingOnAnything : 1; + unsigned mDrawImageBackground : 1; + unsigned mDrawColorBackground : 1; + unsigned mNeverAnimate : 1; + unsigned mIsRenderingOnlySelection : 1; + unsigned mNoTheme : 1; +#ifdef IBMBIDI + unsigned mIsVisual : 1; + unsigned mIsBidiSystem : 1; +#endif }; // Bit values for StartLoadImage's aImageStatus diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index 105315cf71a..f4248039168 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -236,7 +236,7 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, if (aIsVisualFormControl) { isVisual = PR_FALSE; } else { - aPresContext->IsVisualMode(isVisual); + isVisual = aPresContext->IsVisualMode(); } mSuccess = mBidiEngine->CountRuns(&runCount); if (NS_FAILED(mSuccess) ) { diff --git a/mozilla/layout/base/src/nsCopySupport.cpp b/mozilla/layout/base/src/nsCopySupport.cpp index 7eed6dc6b70..8220d7dc532 100644 --- a/mozilla/layout/base/src/nsCopySupport.cpp +++ b/mozilla/layout/base/src/nsCopySupport.cpp @@ -152,12 +152,10 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 context->IsArabicEncoding(arabicCharset); if (arabicCharset) { PRUint32 bidiOptions; - PRBool isVisual; - PRBool isBidiSystem; + PRBool isBidiSystem = context->IsBidiSystem(); + PRBool isVisual = context->IsVisualMode(); context->GetBidi(&bidiOptions); - context->IsVisualMode(isVisual); - context->GetIsBidiSystem(isBidiSystem); if ( (GET_BIDI_OPTION_CLIPBOARDTEXTMODE(bidiOptions) == IBMBIDI_CLIPBOARDTEXTMODE_LOGICAL)&&(isVisual) ) { nsAutoString newBuffer; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index c5f69f99936..417980e7510 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -150,8 +150,7 @@ nsPresContext::nsPresContext() mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)), mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)), - mNoTheme(PR_FALSE) + NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)) { mCompatibilityMode = eCompatibility_FullStandards; mImageAnimationMode = imgIContainer::kNormalAnimMode; @@ -160,9 +159,6 @@ nsPresContext::nsPresContext() SetBackgroundImageDraw(PR_TRUE); // always draw the background SetBackgroundColorDraw(PR_TRUE); - mStopped = PR_FALSE; - mStopChrome = PR_TRUE; - mShell = nsnull; mLinkHandler = nsnull; mContainer = nsnull; @@ -537,28 +533,6 @@ nsPresContext::GetUserPreferences() #endif } -NS_IMETHODIMP -nsPresContext::GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue) -{ - nsresult rv = NS_OK; - - switch (aPrefType) { - case kPresContext_UseDocumentFonts : - aValue = mUseDocumentFonts; - break; - case kPresContext_UseDocumentColors: - aValue = mUseDocumentColors; - break; - case kPresContext_UnderlineLinks: - aValue = mUnderlineLinks; - break; - default : - rv = NS_ERROR_INVALID_ARG; - NS_ERROR("invalid arg"); - } - return rv; -} - NS_IMETHODIMP nsPresContext::GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue) { @@ -914,22 +888,6 @@ nsPresContext::GetDefaultFont(PRUint8 aFontID) const return font; } -NS_IMETHODIMP -nsPresContext::GetFocusRingOnAnything(PRBool& aFocusRingOnAnything) -{ - aFocusRingOnAnything = mFocusRingOnAnything; - return NS_OK; -} - - -NS_IMETHODIMP -nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) -{ - aUseFocusColors = mUseFocusColors; - return NS_OK; -} - - NS_IMETHODIMP nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const { @@ -1144,20 +1102,6 @@ nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const return NS_OK; } -NS_IMETHODIMP -nsPresContext::SetVisualMode(PRBool aIsVisual) -{ - mIsVisual = aIsVisual; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::IsVisualMode(PRBool& aIsVisual) const -{ - aIsVisual = mIsVisual; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils) { @@ -1202,20 +1146,6 @@ NS_IMETHODIMP nsPresContext::GetBidi(PRUint32* aDest) const } //Mohamed 17-1-01 -NS_IMETHODIMP -nsPresContext::SetIsBidiSystem(PRBool aIsBidi) -{ - mIsBidiSystem = aIsBidi; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetIsBidiSystem(PRBool& aResult) const -{ - aResult = mIsBidiSystem; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetBidiCharset(nsACString &aCharSet) const { @@ -1236,15 +1166,6 @@ nsPresContext::GetLanguageSpecificTransformType( return NS_OK; } -NS_IMETHODIMP -nsPresContext::IsRenderingOnlySelection(PRBool* aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mIsRenderingOnlySelection; - - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetTheme(nsITheme** aResult) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index fb2210692bc..27fc0fcb731 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -78,12 +78,8 @@ public: NS_IMETHOD AllocateFromShell(size_t aSize, void** aResult); NS_IMETHOD FreeToShell(size_t aSize, void* aFreeChunk); virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const; - NS_IMETHOD GetCachedBoolPref(PRUint32 aPrefType, PRBool& aValue); NS_IMETHOD GetCachedIntPref(PRUint32 aPrefType, PRInt32& aValue); - NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors); - NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything); - virtual nsresult LoadImage(nsIURI* aURL, nsIFrame* aTargetFrame, imgIRequest **aRequest); @@ -105,14 +101,6 @@ public: NS_IMETHOD GetLanguageSpecificTransformType( nsLanguageSpecificTransformType* aType); - NS_IMETHOD SetIsRenderingOnlySelection(PRBool aVal) { mIsRenderingOnlySelection = aVal; return NS_OK; } - NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult); - - NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw) { aCanDraw = mDrawImageBackground; return NS_OK; } - NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw) { mDrawImageBackground = aCanDraw; return NS_OK; } - NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw) { aCanDraw = mDrawColorBackground; return NS_OK; } - NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw) { mDrawColorBackground = aCanDraw; return NS_OK; } - #ifdef MOZ_REFLOW_PERF NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame); NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor); @@ -126,8 +114,6 @@ public: #ifdef IBMBIDI NS_IMETHOD GetBidiEnabled(PRBool* aBidiEnabled) const; NS_IMETHOD SetBidiEnabled(PRBool aBidiEnabled) const; - NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const; - NS_IMETHOD SetVisualMode(PRBool aIsVisual); NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils); NS_IMETHOD SetBidi(PRUint32 aSource, PRBool aForceReflow = PR_FALSE); NS_IMETHOD GetBidi(PRUint32* aDest) const; @@ -136,8 +122,6 @@ public: NS_IMETHOD IsArabicEncoding(PRBool &aResult) const; //Mohamed 17-1-01 - NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi); - NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const; NS_IMETHOD GetBidiCharset(nsACString &aCharSet) const; //Mohamed End #endif // IBMBIDI @@ -168,29 +152,8 @@ protected: nsFont mDefaultFantasyFont; nscoord mMinimumFontSize; - PRPackedBool mUseDocumentFonts; // set in GetUserPrefs - PRPackedBool mUseDocumentColors; // set in GetUserPrefs - PRPackedBool mUnderlineLinks; // set in GetUserPrefs - PRPackedBool mUseFocusColors; // set in GetUserPrefs - - PRPackedBool mFocusRingOnAnything; // set in GetUserPrefs - - PRPackedBool mDrawImageBackground; - PRPackedBool mDrawColorBackground; - nsSupportsHashtable mImageLoaders; - PRPackedBool mImageAnimationStopped; // image animation stopped - PRPackedBool mNeverAnimate; // never animate images - - PRPackedBool mStopped; // loading stopped - PRPackedBool mStopChrome; // should we stop chrome? -#ifdef IBMBIDI - PRPackedBool mIsVisual; // is the Bidi text mode visual - PRPackedBool mIsBidiSystem; // is the system capable of doing Bidi reordering -#endif // IBMBIDI - PRPackedBool mIsRenderingOnlySelection; - #ifdef IBMBIDI nsBidiPresUtils* mBidiUtils; PRUint32 mBidi; @@ -204,7 +167,6 @@ protected: PRUint16 mImageAnimationModePref; nsCOMPtr mTheme; - PRBool mNoTheme; protected: void GetUserPreferences(); diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index e483fc96475..059a63683ce 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -530,9 +530,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, PRBool isPaginated; aPresContext->IsPaginated(&isPaginated); if (isPaginated) { - PRBool isRendingSelection;; - aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; // if we aren't selected in the mState we could be a container diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 8094ea5f6a5..aba3073adb2 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -3969,9 +3969,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, aState.mPresContext->GetBidiEnabled(&bidiEnabled); if (bidiEnabled) { - PRBool isVisual; - aState.mPresContext->IsVisualMode(isVisual); - if (!isVisual) { + if (!aState.mPresContext->IsVisualMode()) { nsBidiPresUtils* bidiUtils; aState.mPresContext->GetBidiUtils(&bidiUtils); diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 02011be9419..c69c210a2ee 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -2814,9 +2814,7 @@ nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** a nsresult rv = aPresContext->IsPaginated(&isPaginated); if (NS_SUCCEEDED(rv) && isPaginated) { // now see if we are rendering selection only - PRBool isRendingSelection; - rv = aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (NS_SUCCEEDED(rv) && isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first (typically only leaf nodes) PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; // if we aren't selected in the mState, diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 6e4b807a7c1..917489a2780 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -2522,9 +2522,7 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext) return PR_FALSE; } - PRBool isVisual; - aPresContext->IsVisualMode(isVisual); - if (!isVisual) { + if (!aPresContext->IsVisualMode()) { return PR_FALSE; } diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 25b26ec9eac..7c56b9a8b77 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -2921,7 +2921,7 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, if (aShrinkWrapWidth) { return PR_FALSE; } - mPresContext->IsVisualMode(visualRTL); + visualRTL = mPresContext->IsVisualMode(); if (bulletPfd) { bulletPfd->mBounds.x += maxX; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 75926cb1984..740429b1b04 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -130,19 +130,17 @@ // text is darkend inline PRBool CanDarken(nsIPresContext* aPresContext) { -PRBool darken,haveBackground; + PRBool darken; - aPresContext->GetBackgroundColorDraw(haveBackground); - if(PR_TRUE == haveBackground){ + if (aPresContext->GetBackgroundColorDraw()) { + darken = PR_FALSE; + } else { + if (aPresContext->GetBackgroundImageDraw()) { darken = PR_FALSE; } else { - aPresContext->GetBackgroundImageDraw(haveBackground); - if(PR_TRUE == haveBackground){ - darken = PR_FALSE; - } else { - darken = PR_TRUE; - } + darken = PR_TRUE; } + } return darken; } @@ -2021,13 +2019,11 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte return NS_ERROR_FAILURE; aPresContext->IsPaginated(&aIsPaginated); - PRBool isRenderingOnlySelection; - aPresContext->IsRenderingOnlySelection(&isRenderingOnlySelection); (*aSelectionController)->GetDisplaySelection(&aSelectionValue); if(aIsPaginated){ - aDisplayingSelection = isRenderingOnlySelection; + aDisplayingSelection = aPresContext->IsRenderingOnlySelection(); } else { //if greater than hidden then we display some kind of selection aDisplayingSelection = (aSelectionValue > nsISelectionController::SELECTION_HIDDEN); @@ -2170,9 +2166,7 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, PRBool isPaginated; aPresContext->IsPaginated(&isPaginated); if (isPaginated) { - PRBool isRendingSelection; - aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { @@ -2257,7 +2251,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; aPresContext->GetBidiEnabled(&bidiEnabled); if (bidiEnabled) { - aPresContext->GetIsBidiSystem(isBidiSystem); + isBidiSystem = aPresContext->IsBidiSystem(); GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**) &level,sizeof(level)); GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**) &charType,sizeof(charType)); diff --git a/mozilla/layout/generic/nsTextTransformer.cpp b/mozilla/layout/generic/nsTextTransformer.cpp index 3bdf4ea4a10..138646d430b 100644 --- a/mozilla/layout/generic/nsTextTransformer.cpp +++ b/mozilla/layout/generic/nsTextTransformer.cpp @@ -247,9 +247,7 @@ nsTextTransformer::Init(nsIFrame* aFrame, SetNeedsArabicShaping(PR_TRUE); } else { - PRBool isBidiSystem; - mPresContext->GetIsBidiSystem(isBidiSystem); - if (!isBidiSystem) { + if (!mPresContext->IsBidiSystem()) { SetNeedsArabicShaping(PR_TRUE); } } @@ -1497,8 +1495,7 @@ nsTextTransformer::DoArabicShaping(PRUnichar* aText, return; PRInt32 newLen; - PRBool isVisual; - mPresContext->IsVisualMode(isVisual); + PRBool isVisual = mPresContext->IsVisualMode(); nsAutoString buf; buf.SetLength(aTextLength); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 8094ea5f6a5..aba3073adb2 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -3969,9 +3969,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, aState.mPresContext->GetBidiEnabled(&bidiEnabled); if (bidiEnabled) { - PRBool isVisual; - aState.mPresContext->IsVisualMode(isVisual); - if (!isVisual) { + if (!aState.mPresContext->IsVisualMode()) { nsBidiPresUtils* bidiUtils; aState.mPresContext->GetBidiUtils(&bidiUtils); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 02011be9419..c69c210a2ee 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -2814,9 +2814,7 @@ nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** a nsresult rv = aPresContext->IsPaginated(&isPaginated); if (NS_SUCCEEDED(rv) && isPaginated) { // now see if we are rendering selection only - PRBool isRendingSelection; - rv = aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (NS_SUCCEEDED(rv) && isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first (typically only leaf nodes) PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; // if we aren't selected in the mState, diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index 6e4b807a7c1..917489a2780 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -2522,9 +2522,7 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext) return PR_FALSE; } - PRBool isVisual; - aPresContext->IsVisualMode(isVisual); - if (!isVisual) { + if (!aPresContext->IsVisualMode()) { return PR_FALSE; } diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 25b26ec9eac..7c56b9a8b77 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -2921,7 +2921,7 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds, if (aShrinkWrapWidth) { return PR_FALSE; } - mPresContext->IsVisualMode(visualRTL); + visualRTL = mPresContext->IsVisualMode(); if (bulletPfd) { bulletPfd->mBounds.x += maxX; diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index b7824182755..9b2ee4b8383 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -2292,58 +2292,57 @@ nsresult PresShell::SetPrefColorRules(void) NS_ASSERTION(mPresContext,"null prescontext not allowed"); if (mPresContext) { nsresult result = NS_OK; - PRBool useDocColors = PR_TRUE; // see if we need to create the rules first - if (NS_SUCCEEDED(mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors))) { - if (!useDocColors) { + PRBool useDocColors = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors); + if (!useDocColors) { #ifdef DEBUG_attinasi - printf(" - Creating rules for document colors\n"); + printf(" - Creating rules for document colors\n"); #endif - // OK, not using document colors, so we have to force the user's colors via style rules - if (!mPrefStyleSheet) { - result = CreatePreferenceStyleSheet(); - } + // OK, not using document colors, so we have to force the user's colors via style rules + if (!mPrefStyleSheet) { + result = CreatePreferenceStyleSheet(); + } + if (NS_SUCCEEDED(result)) { + NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + + 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)) { - NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + PRUint32 index = 0; + nsAutoString strColor, strBackgroundColor; - 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)) { - 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); } } } @@ -2403,8 +2402,8 @@ nsresult PresShell::SetPrefLinkRules(void) nscolor activeColor(mPresContext->DefaultActiveLinkColor()); nscolor visitedColor(mPresContext->DefaultVisitedLinkColor()); - PRBool useDocColors = PR_TRUE; - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); + PRBool useDocColors = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); NS_NAMED_LITERAL_STRING(importantStr, "!important}"); const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; @@ -2432,9 +2431,8 @@ nsresult PresShell::SetPrefLinkRules(void) sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(rv, rv); - PRBool underlineLinks = PR_TRUE; - rv = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); - NS_ENSURE_SUCCESS(rv, rv); + PRBool underlineLinks = + mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks); if (underlineLinks) { // create a rule to make underlining happen @@ -2469,9 +2467,7 @@ nsresult PresShell::SetPrefFocusRules(void) // get the DOM interface to the stylesheet nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); if (NS_SUCCEEDED(result)) { - PRBool useFocusColors; - mPresContext->GetUseFocusColors(useFocusColors); - if (useFocusColors) { + if (mPresContext->GetUseFocusColors()) { nscolor focusBackground(mPresContext->FocusBackgroundColor()); nscolor focusText(mPresContext->FocusTextColor()); @@ -2492,8 +2488,7 @@ nsresult PresShell::SetPrefFocusRules(void) result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } PRUint8 focusRingWidth = mPresContext->FocusRingWidth(); - PRBool focusRingOnAnything; - mPresContext->GetFocusRingOnAnything(focusRingOnAnything); + PRBool focusRingOnAnything = mPresContext->GetFocusRingOnAnything(); if ((NS_SUCCEEDED(result) && focusRingWidth != 1 && focusRingWidth <= 4 ) || focusRingOnAnything) { PRUint32 index = 0; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 75926cb1984..740429b1b04 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -130,19 +130,17 @@ // text is darkend inline PRBool CanDarken(nsIPresContext* aPresContext) { -PRBool darken,haveBackground; + PRBool darken; - aPresContext->GetBackgroundColorDraw(haveBackground); - if(PR_TRUE == haveBackground){ + if (aPresContext->GetBackgroundColorDraw()) { + darken = PR_FALSE; + } else { + if (aPresContext->GetBackgroundImageDraw()) { darken = PR_FALSE; } else { - aPresContext->GetBackgroundImageDraw(haveBackground); - if(PR_TRUE == haveBackground){ - darken = PR_FALSE; - } else { - darken = PR_TRUE; - } + darken = PR_TRUE; } + } return darken; } @@ -2021,13 +2019,11 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte return NS_ERROR_FAILURE; aPresContext->IsPaginated(&aIsPaginated); - PRBool isRenderingOnlySelection; - aPresContext->IsRenderingOnlySelection(&isRenderingOnlySelection); (*aSelectionController)->GetDisplaySelection(&aSelectionValue); if(aIsPaginated){ - aDisplayingSelection = isRenderingOnlySelection; + aDisplayingSelection = aPresContext->IsRenderingOnlySelection(); } else { //if greater than hidden then we display some kind of selection aDisplayingSelection = (aSelectionValue > nsISelectionController::SELECTION_HIDDEN); @@ -2170,9 +2166,7 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, PRBool isPaginated; aPresContext->IsPaginated(&isPaginated); if (isPaginated) { - PRBool isRendingSelection; - aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { @@ -2257,7 +2251,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; aPresContext->GetBidiEnabled(&bidiEnabled); if (bidiEnabled) { - aPresContext->GetIsBidiSystem(isBidiSystem); + isBidiSystem = aPresContext->IsBidiSystem(); GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**) &level,sizeof(level)); GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**) &charType,sizeof(charType)); diff --git a/mozilla/layout/html/base/src/nsTextTransformer.cpp b/mozilla/layout/html/base/src/nsTextTransformer.cpp index 3bdf4ea4a10..138646d430b 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.cpp +++ b/mozilla/layout/html/base/src/nsTextTransformer.cpp @@ -247,9 +247,7 @@ nsTextTransformer::Init(nsIFrame* aFrame, SetNeedsArabicShaping(PR_TRUE); } else { - PRBool isBidiSystem; - mPresContext->GetIsBidiSystem(isBidiSystem); - if (!isBidiSystem) { + if (!mPresContext->IsBidiSystem()) { SetNeedsArabicShaping(PR_TRUE); } } @@ -1497,8 +1495,7 @@ nsTextTransformer::DoArabicShaping(PRUnichar* aText, return; PRInt32 newLen; - PRBool isVisual; - mPresContext->IsVisualMode(isVisual); + PRBool isVisual = mPresContext->IsVisualMode(); nsAutoString buf; buf.SetLength(aTextLength); diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index e483fc96475..059a63683ce 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -530,9 +530,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, PRBool isPaginated; aPresContext->IsPaginated(&isPaginated); if (isPaginated) { - PRBool isRendingSelection;; - aPresContext->IsRenderingOnlySelection(&isRendingSelection); - if (isRendingSelection) { + if (aPresContext->IsRenderingOnlySelection()) { // Check the quick way first PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; // if we aren't selected in the mState we could be a container diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index ad157fb78a6..029f9faaf5d 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -2822,8 +2822,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, PRBool canDrawBackgroundColor = PR_TRUE; if (aUsePrintSettings) { - aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage); - aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor); + canDrawBackgroundImage = aPresContext->GetBackgroundImageDraw(); + canDrawBackgroundColor = aPresContext->GetBackgroundColorDraw(); } // Check to see if we have an appearance defined. If so, we let the theme diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp index 6d8a1227259..79d235bd756 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp @@ -899,8 +899,9 @@ nsGlyphTableList::GetListFor(nsIPresContext* aPresContext, // @see the documentation of -moz-math-stretchy in mathml.css // for how this work aGlyphTableList->Clear(); - PRBool useDocumentFonts = PR_TRUE; - aPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts, useDocumentFonts); + PRBool useDocumentFonts = + aPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts); + // Check to honor the pref("browser.display.use_document_fonts", 0) // Only include fonts from CSS if the pref to disallow authors' fonts isn't set if (useDocumentFonts) { diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index d82a2474ceb..31238272341 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -1990,7 +1990,8 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // MJA: bug 31816 // if we are not using document fonts, but this is a XUL document, // then we use the document fonts anyway - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts, useDocumentFonts); + useDocumentFonts = + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts); if (!useDocumentFonts) { // check if the prefs have been disabled for this shell // - if prefs are disabled then we use the document fonts anyway (yet another override) @@ -2224,15 +2225,13 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, PRInt32 td = textData.mDecoration.GetIntValue(); text->mTextDecoration = td; if (td & NS_STYLE_TEXT_DECORATION_PREF_ANCHORS) { - PRBool underlineLinks = PR_TRUE; - nsresult res = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); - if (NS_SUCCEEDED(res)) { - if (underlineLinks) { - text->mTextDecoration |= NS_STYLE_TEXT_DECORATION_UNDERLINE; - } - else { - text->mTextDecoration &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE; - } + PRBool underlineLinks = + mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks); + if (underlineLinks) { + text->mTextDecoration |= NS_STYLE_TEXT_DECORATION_UNDERLINE; + } + else { + text->mTextDecoration &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE; } } }