From c17fab67825736897f42e588f6ee9f9fa72fedfe Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Wed, 1 Aug 2001 03:09:59 +0000 Subject: [PATCH] Clean up if-else cascade by condensing into one big logical expression. Based on patch by Ulrich Drepper . r=jag sr=waterson b=89791 git-svn-id: svn://10.0.0.236/trunk@100080 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsTextFrame.cpp | 25 +++++++++----------- mozilla/layout/html/base/src/nsTextFrame.cpp | 25 +++++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index e9296312237..679c42e4e62 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -1384,24 +1384,21 @@ nsTextFrame::Paint(nsIPresContext* aPresContext, #ifdef IBMBIDI PRBool bidiEnabled; aPresContext->GetBidiEnabled(&bidiEnabled); - if (bidiEnabled) { - PaintUnicodeText(aPresContext, aRenderingContext, sc, ts, 0, 0); - } else +#else + const PRBool bidiEnabled = PR_FALSE; #endif // IBMBIDI - // If we have ascii text that doesn't contain multi-byte characters - // and the text doesn't need transforming then always render as ascii - if ((0 == (mState & TEXT_WAS_TRANSFORMED)) && !frag->Is2b() && !hasMultiByteChars) { - PaintAsciiText(aPresContext, aRenderingContext, sc, ts, 0, 0); - - } else if (hasMultiByteChars || (0 == (hints & NS_RENDERING_HINT_FAST_8BIT_TEXT))) { - // If it has multi-byte characters then we have to render it as Unicode - // regardless of whether the text fragment is 1-byte or 2-byte characters. - // Or if the text fragment requires transforming then leave it up to the - // rendering context's preference + // * BiDi text or text with multi-byte characters must always be + // rendered as Unicode. + // * Non-transformed, 1-byte text should always be rendered as + // ASCII. + // * Other transformed or 2-byte text should be rendered according + // to the preference of the hint from the rendering context. + if (bidiEnabled || hasMultiByteChars || + ((0 == (hints & NS_RENDERING_HINT_FAST_8BIT_TEXT)) && + (frag->Is2b() || (0 != (mState & TEXT_WAS_TRANSFORMED))))) { PaintUnicodeText(aPresContext, aRenderingContext, sc, ts, 0, 0); } else { - // Use char rendering routine PaintAsciiText(aPresContext, aRenderingContext, sc, ts, 0, 0); } diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index e9296312237..679c42e4e62 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -1384,24 +1384,21 @@ nsTextFrame::Paint(nsIPresContext* aPresContext, #ifdef IBMBIDI PRBool bidiEnabled; aPresContext->GetBidiEnabled(&bidiEnabled); - if (bidiEnabled) { - PaintUnicodeText(aPresContext, aRenderingContext, sc, ts, 0, 0); - } else +#else + const PRBool bidiEnabled = PR_FALSE; #endif // IBMBIDI - // If we have ascii text that doesn't contain multi-byte characters - // and the text doesn't need transforming then always render as ascii - if ((0 == (mState & TEXT_WAS_TRANSFORMED)) && !frag->Is2b() && !hasMultiByteChars) { - PaintAsciiText(aPresContext, aRenderingContext, sc, ts, 0, 0); - - } else if (hasMultiByteChars || (0 == (hints & NS_RENDERING_HINT_FAST_8BIT_TEXT))) { - // If it has multi-byte characters then we have to render it as Unicode - // regardless of whether the text fragment is 1-byte or 2-byte characters. - // Or if the text fragment requires transforming then leave it up to the - // rendering context's preference + // * BiDi text or text with multi-byte characters must always be + // rendered as Unicode. + // * Non-transformed, 1-byte text should always be rendered as + // ASCII. + // * Other transformed or 2-byte text should be rendered according + // to the preference of the hint from the rendering context. + if (bidiEnabled || hasMultiByteChars || + ((0 == (hints & NS_RENDERING_HINT_FAST_8BIT_TEXT)) && + (frag->Is2b() || (0 != (mState & TEXT_WAS_TRANSFORMED))))) { PaintUnicodeText(aPresContext, aRenderingContext, sc, ts, 0, 0); } else { - // Use char rendering routine PaintAsciiText(aPresContext, aRenderingContext, sc, ts, 0, 0); }