Make all nsBidiPresUtils methods static. Bug 624798, r=roc

This commit is contained in:
Simon Montagu 2011-04-13 12:23:49 +03:00
parent 4048863049
commit c5979d144a
17 changed files with 651 additions and 819 deletions

View File

@ -103,6 +103,7 @@
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
@ -2738,10 +2739,6 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nsIDocument* document = presShell->GetDocument();
nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
if (!bidiUtils)
return NS_ERROR_FAILURE;
// replace all the whitespace characters with U+0020 SPACE
nsAutoString textToDraw(aRawText);
TextReplaceWhitespaceCharacters(textToDraw);
@ -2787,15 +2784,17 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
// calls bidi algo twice since it needs the full text width and the
// bounding boxes before rendering anything
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord);
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@ -2894,15 +2893,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
processor.mThebes = ctx;
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@ -2931,15 +2931,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ApplyStyle(STYLE_FILL);
}
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
// this needs to be restored before function can return
if (doUseIntermediateSurface) {

View File

@ -100,6 +100,7 @@
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
@ -3196,11 +3197,6 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
nsIDocument* document = presShell->GetDocument();
nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
if (!bidiUtils) {
return NS_ERROR_FAILURE;
}
// replace all the whitespace characters with U+0020 SPACE
nsAutoString textToDraw(aRawText);
TextReplaceWhitespaceCharacters(textToDraw);
@ -3251,15 +3247,17 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
// calls bidi algo twice since it needs the full text width and the
// bounding boxes before rendering anything
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord);
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord,
&bidiEngine);
if (NS_FAILED(rv)) {
return rv;
}
@ -3350,15 +3348,16 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
// don't ever need to measure the bounding box twice
processor.mDoMeasureBoundingBox = PR_FALSE;
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
mTarget->SetTransform(oldTransform);

View File

@ -773,7 +773,7 @@ public:
* The array does not need to be initialized.<p>
* The index map will result in <code>aIndexMap[aLogicalIndex]==aVisualIndex</code>.
*/
nsresult ReorderLogical(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
static nsresult ReorderLogical(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
#endif // FULL_BIDI_ENGINE
/**
* This is a convenience function that does not use a nsBidi object.
@ -794,7 +794,7 @@ public:
* The array does not need to be initialized.<p>
* The index map will result in <code>aIndexMap[aVisualIndex]==aLogicalIndex</code>.
*/
nsresult ReorderVisual(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
static nsresult ReorderVisual(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
#ifdef FULL_BIDI_ENGINE
/**
@ -917,7 +917,7 @@ private:
void ReorderLine(nsBidiLevel aMinLevel, nsBidiLevel aMaxLevel);
PRBool PrepareReorder(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap, nsBidiLevel *aMinLevel, nsBidiLevel *aMaxLevel);
static PRBool PrepareReorder(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap, nsBidiLevel *aMinLevel, nsBidiLevel *aMaxLevel);
PRInt32 doWriteReverse(const PRUnichar *src, PRInt32 srcLength,
PRUnichar *dest, PRUint16 options);

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,9 @@
#undef DrawText
#endif
struct BidiParagraphData;
struct BidiLineData;
/**
* A structure representing some continuation state for each frame on the line,
* used to determine the first and the last continuation frame for each
@ -118,7 +121,6 @@ class nsBidiPresUtils {
public:
nsBidiPresUtils();
~nsBidiPresUtils();
PRBool IsSuccessful(void) const;
/**
* Interface for the processor used by ProcessText. Used by process text to
@ -174,9 +176,11 @@ public:
*
* @lina 06/18/2000
*/
nsresult Resolve(nsBlockFrame* aBlockFrame);
void ResolveParagraph(nsBlockFrame* aBlockFrame);
void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame);
static nsresult Resolve(nsBlockFrame* aBlockFrame);
static nsresult ResolveParagraph(nsBlockFrame* aBlockFrame,
BidiParagraphData* aBpd);
static void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
BidiParagraphData* aBpd);
/**
* Reorder this line using Bidi engine.
@ -184,8 +188,8 @@ public:
*
* @lina 05/02/2000
*/
void ReorderFrames(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Format Unicode text, taking into account bidi capabilities
@ -194,11 +198,11 @@ public:
*
* @lina 06/18/2000
*/
nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel);
static nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel);
/**
* Reorder plain text using the Unicode Bidi algorithm and send it to
@ -217,26 +221,26 @@ public:
* @param[in,out] aPosResolve array of logical positions to resolve into visual positions; can be nsnull if this functionality is not required
* @param aPosResolveCount number of items in the aPosResolve array
*/
nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
nscoord aX,
nscoord aY,
nsBidiPositionResolve* aPosResolve = nsnull,
PRInt32 aPosResolveCount = 0)
static nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
nscoord aX,
nscoord aY,
nsBidiPositionResolve* aPosResolve = nsnull,
PRInt32 aPosResolveCount = 0)
{
return ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext, aRenderingContext,
aTextRunConstructionContext, MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nsnull);
}
nscoord MeasureTextWidth(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext)
static nscoord MeasureTextWidth(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext)
{
nscoord length;
nsresult rv = ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext,
@ -253,10 +257,10 @@ public:
* @param[out] aLeftMost : leftmost frame on this line
* @param[out] aRightMost : rightmost frame on this line
*/
PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine,
nsIFrame** aLeftmost,
nsIFrame** aRightmost);
static PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine,
nsIFrame** aLeftmost,
nsIFrame** aRightmost);
/**
* Get the frame to the right of the given frame, on the same line.
@ -265,9 +269,9 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Get the frame to the left of the given frame, on the same line.
@ -276,9 +280,9 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Get the bidi embedding level of the given (inline) frame.
@ -312,15 +316,16 @@ public:
* @param aPosResolveCount number of items in the aPosResolve array
* @param[out] aWidth Pointer to where the width will be stored (may be null)
*/
nsresult ProcessText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
BidiProcessor& aprocessor,
Mode aMode,
nsBidiPositionResolve* aPosResolve,
PRInt32 aPosResolveCount,
nscoord* aWidth);
static nsresult ProcessText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
BidiProcessor& aprocessor,
Mode aMode,
nsBidiPositionResolve* aPosResolve,
PRInt32 aPosResolveCount,
nscoord* aWidth,
nsBidi* aBidiEngine);
/**
* Make a copy of a string, converting from logical to visual order
@ -335,36 +340,25 @@ public:
* @param aOverride if TRUE, the text has a bidi override, according to
* the direction in aDir
*/
void CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
PRBool aOverride);
/**
* Guess at how much memory is being used by this nsBidiPresUtils instance,
* including memory used by nsBidi.
*/
PRUint32 EstimateMemoryUsed();
void Traverse(nsCycleCollectionTraversalCallback &cb) const;
void Unlink();
static void CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
PRBool aOverride);
private:
nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
Mode aMode,
nscoord aX, // DRAW only
nscoord aY, // DRAW only
nsBidiPositionResolve* aPosResolve, /* may be null */
PRInt32 aPosResolveCount,
nscoord* aWidth /* may be null */);
void AdvanceAndAppendFrame(nsIFrame** aFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame** aNextSibling);
static nsresult
ProcessTextForRenderingContext(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
Mode aMode,
nscoord aX, // DRAW only
nscoord aY, // DRAW only
nsBidiPositionResolve* aPosResolve, /* may be null */
PRInt32 aPosResolveCount,
nscoord* aWidth /* may be null */);
/**
* Traverse the child frames of the block element and:
@ -374,26 +368,10 @@ private:
* than one paragraph for bidi resolution, resolve the paragraph up to that
* point.
*/
void TraverseFrames(nsBlockFrame* aBlockFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame);
/**
* Initialize the logically-ordered array of frames
* using the top-level frames of a single line
*/
void InitLogicalArrayFromLine(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Reorder the frame array from logical to visual order
*
* @param aReordered TRUE on return if the visual order is different from
* the logical order
* @param aHasRTLFrames TRUE on return if at least one of the frames is RTL
* (and therefore might have reordered descendents)
*/
nsresult Reorder(PRBool& aReordered, PRBool& aHasRTLFrames);
static void TraverseFrames(nsBlockFrame* aBlockFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame,
BidiParagraphData* aBpd);
/*
* Position aFrame and it's descendants to their visual places. Also if aFrame
@ -408,10 +386,10 @@ private:
* adding its right margin)
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
void RepositionFrame(nsIFrame* aFrame,
PRBool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates) const;
static void RepositionFrame(nsIFrame* aFrame,
PRBool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates);
/*
* Initialize the continuation state(nsFrameContinuationState) to
@ -421,8 +399,8 @@ private:
* be initialized
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
void InitContinuationStates(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates) const;
static void InitContinuationStates(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates);
/*
* Determine if aFrame is leftmost or rightmost, and set aIsLeftMost and
@ -439,10 +417,10 @@ private:
* @param[out] aIsLeftMost TRUE means aFrame is leftmost frame or continuation
* @param[out] aIsRightMost TRUE means aFrame is rightmost frame or continuation
*/
void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
PRBool& aIsLeftMost /* out */,
PRBool& aIsRightMost /* out */) const;
static void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
PRBool& aIsLeftMost /* out */,
PRBool& aIsRightMost /* out */);
/**
* Adjust frame positions following their visual order
@ -451,7 +429,8 @@ private:
*
* @lina 04/11/2000
*/
void RepositionInlineFrames(nsIFrame* aFirstChild) const;
static void RepositionInlineFrames(BidiLineData* aBld,
nsIFrame* aFirstChild);
/**
* Helper method for Resolve()
@ -468,12 +447,12 @@ private:
* @see Resolve()
* @see RemoveBidiContinuation()
*/
inline
void EnsureBidiContinuation(nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex,
PRInt32 aStart,
PRInt32 aEnd);
static inline
nsresult EnsureBidiContinuation(nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex,
PRInt32 aStart,
PRInt32 aEnd);
/**
* Helper method for Resolve()
@ -491,20 +470,23 @@ private:
* @see Resolve()
* @see EnsureBidiContinuation()
*/
void RemoveBidiContinuation(nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset) const;
void CalculateCharType(PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType) const;
static void RemoveBidiContinuation(BidiParagraphData* aBpd,
nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset);
static void CalculateCharType(nsBidi* aBidiEngine,
const PRUnichar* aText,
PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType);
void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength) const;
static void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength);
static PRBool WriteLogicalToVisual(const PRUnichar* aSrc,
PRUint32 aSrcLength,
@ -512,26 +494,9 @@ private:
nsBidiLevel aBaseDirection,
nsBidi* aBidiEngine);
static void WriteReverse(const PRUnichar* aSrc,
PRUint32 aSrcLength,
PRUnichar* aDest);
nsString mBuffer;
nsTArray<PRUnichar> mEmbeddingStack;
nsTArray<nsIFrame*> mLogicalFrames;
nsTArray<nsLineBox*> mLinePerFrame;
nsTArray<nsIFrame*> mVisualFrames;
nsDataHashtable<nsISupportsHashKey, PRInt32> mContentToFrameIndex;
PRInt32 mArraySize;
PRInt32* mIndexMap;
PRUint8* mLevels;
nsresult mSuccess;
PRPackedBool mIsVisual;
nsBidiLevel mParaLevel;
nsIFrame* mPrevFrame;
nsIContent* mPrevContent;
nsBidi* mBidiEngine;
static void WriteReverse(const PRUnichar* aSrc,
PRUint32 aSrcLength,
PRUnichar* aDest);
};
#endif /* nsBidiPresUtils_h___ */

View File

@ -2854,19 +2854,15 @@ nsLayoutUtils::DrawString(const nsIFrame* aFrame,
nsresult rv = NS_ERROR_FAILURE;
nsPresContext* presContext = aFrame->PresContext();
if (presContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
if (aDirection == NS_STYLE_DIRECTION_INHERIT) {
aDirection = aFrame->GetStyleVisibility()->mDirection;
}
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == aDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
rv = bidiUtils->RenderText(aString, aLength, direction,
presContext, *aContext, *aContext,
aPoint.x, aPoint.y);
if (aDirection == NS_STYLE_DIRECTION_INHERIT) {
aDirection = aFrame->GetStyleVisibility()->mDirection;
}
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == aDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
rv = nsBidiPresUtils::RenderText(aString, aLength, direction,
presContext, *aContext, *aContext,
aPoint.x, aPoint.y);
}
if (NS_FAILED(rv))
#endif // IBMBIDI
@ -2885,16 +2881,12 @@ nsLayoutUtils::GetStringWidth(const nsIFrame* aFrame,
#ifdef IBMBIDI
nsPresContext* presContext = aFrame->PresContext();
if (presContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
return bidiUtils->MeasureTextWidth(aString, aLength,
direction, presContext, *aContext);
}
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
return nsBidiPresUtils::MeasureTextWidth(aString, aLength,
direction, presContext, *aContext);
}
#endif // IBMBIDI
aContext->SetTextRunRTL(PR_FALSE);

View File

@ -369,8 +369,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPresContext)
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLangService); // a service
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrintSettings);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrefChangedTimer);
if (tmp->mBidiUtils)
tmp->mBidiUtils->Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
@ -395,8 +393,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
tmp->mPrefChangedTimer->Cancel();
tmp->mPrefChangedTimer = nsnull;
}
if (tmp->mBidiUtils)
tmp->mBidiUtils->Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -1461,15 +1457,6 @@ nsPresContext::SetBidiEnabled() const
}
}
nsBidiPresUtils*
nsPresContext::GetBidiUtils()
{
if (!mBidiUtils)
mBidiUtils = new nsBidiPresUtils;
return mBidiUtils;
}
void
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceRestyle)
{
@ -1512,15 +1499,6 @@ nsPresContext::GetBidi() const
return Document()->GetBidiOptions();
}
PRUint32
nsPresContext::GetBidiMemoryUsed()
{
if (!mBidiUtils)
return 0;
return mBidiUtils->EstimateMemoryUsed();
}
#endif //IBMBIDI
PRBool

View File

@ -757,11 +757,6 @@ public:
//Mohamed
/**
* Get a Bidi presentation utilities object
*/
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
@ -774,10 +769,6 @@ public:
* include nsIDocument.
*/
NS_HIDDEN_(PRUint32) GetBidi() const;
PRUint32 GetBidiMemoryUsed();
#else
PRUint32 GetBidiMemoryUsed() { return 0; }
#endif // IBMBIDI
/**
@ -1010,7 +1001,6 @@ public:
PRUint32 result = 0;
result += sizeof(nsPresContext);
result += GetBidiMemoryUsed();
return result;
}
@ -1100,10 +1090,6 @@ protected:
PRInt32 mCurAppUnitsPerDevPixel;
PRInt32 mAutoQualityMinFontSizePixelsPref;
#ifdef IBMBIDI
nsAutoPtr<nsBidiPresUtils> mBidiUtils;
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;

View File

@ -1434,15 +1434,6 @@ public:
return PL_DHASH_NEXT;
}
static PLDHashOperator LiveShellBidiSizeEnumerator(PresShellPtrKey *aEntry,
void *userArg)
{
PresShell *aShell = static_cast<PresShell*>(aEntry->GetKey());
PRUint32 *val = (PRUint32*)userArg;
*val += aShell->mPresContext->GetBidiMemoryUsed();
return PL_DHASH_NEXT;
}
static PRUint32
EstimateShellsMemory(nsTHashtable<PresShellPtrKey>::Enumerator aEnumerator)
{
@ -1456,10 +1447,6 @@ public:
return EstimateShellsMemory(LiveShellSizeEnumerator);
}
static PRInt64 SizeOfBidiMemoryReporter() {
return EstimateShellsMemory(LiveShellBidiSizeEnumerator);
}
protected:
void QueryIsActive();
nsresult UpdateImageLockingState();
@ -1675,13 +1662,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(LayoutPresShell,
PresShell::SizeOfLayoutMemoryReporter,
"Memory used by layout PresShell, PresContext, and other related areas.")
NS_MEMORY_REPORTER_IMPLEMENT(LayoutBidi,
"explicit/layout/bidi",
KIND_HEAP,
UNITS_BYTES,
PresShell::SizeOfBidiMemoryReporter,
"Memory used by layout Bidi processor.")
PresShell::PresShell()
: mMouseLocation(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)
{
@ -1710,7 +1690,6 @@ PresShell::PresShell()
static bool registeredReporter = false;
if (!registeredReporter) {
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutPresShell));
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutBidi));
Preferences::AddBoolVarCache(&sSynthMouseMove,
"layout.reflow.synthMouseMove", PR_TRUE);
registeredReporter = true;

View File

@ -4257,11 +4257,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
if (aState.mPresContext->BidiEnabled()) {
if (!aState.mPresContext->IsVisualMode() ||
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
if (bidiUtils && bidiUtils->IsSuccessful() ) {
bidiUtils->ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
} // bidiUtils
nsBidiPresUtils::ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
} // not visual mode
} // bidi enabled
#endif // IBMBIDI
@ -7220,11 +7216,7 @@ nsBlockFrame::ResolveBidi()
return NS_OK;
}
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (!bidiUtils)
return NS_ERROR_NULL_POINTER;
return bidiUtils->Resolve(this);
return nsBidiPresUtils::Resolve(this);
}
#endif

View File

@ -448,7 +448,6 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
return aFrame ? aFrame->GetPrevSibling() : LastChild();
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
nsAutoLineIterator iter = parent->GetLineIterator();
if (!iter) {
@ -456,9 +455,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
if (parent->GetType() == nsGkAtoms::lineFrame) {
// Line frames are not bidi-splittable, so need to consider bidi reordering
if (baseLevel == NSBIDI_LTR) {
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
} else { // RTL
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
}
} else {
// Just get the next or prev sibling, depending on block and frame direction.
@ -493,9 +492,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
}
}
@ -504,9 +503,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine - 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
}
}
return frame;
@ -523,7 +522,6 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
return aFrame ? aFrame->GetPrevSibling() : mFirstChild;
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
nsAutoLineIterator iter = parent->GetLineIterator();
if (!iter) {
@ -531,9 +529,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
if (parent->GetType() == nsGkAtoms::lineFrame) {
// Line frames are not bidi-splittable, so need to consider bidi reordering
if (baseLevel == NSBIDI_LTR) {
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
} else { // RTL
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
}
} else {
// Just get the next or prev sibling, depending on block and frame direction.
@ -568,9 +566,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
}
}
@ -580,9 +578,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine + 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
}
}
return frame;

View File

@ -1003,21 +1003,17 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
nsresult rv = NS_ERROR_FAILURE;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = GetStyleVisibility();
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_RTL,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.XMost() - strWidth, y + maxAscent);
else
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_LTR,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.x, y + maxAscent);
}
const nsStyleVisibility* vis = GetStyleVisibility();
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_RTL,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.XMost() - strWidth, y + maxAscent);
else
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_LTR,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.x, y + maxAscent);
}
if (NS_FAILED(rv))
aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);

View File

@ -656,11 +656,9 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
return NS_OK;
}
nsBidiPresUtils* bidiUtils = line->mFirstChild->PresContext()->GetBidiUtils();
nsIFrame* leftmostFrame;
nsIFrame* rightmostFrame;
*aIsReordered = bidiUtils->CheckLineOrder(line->mFirstChild, line->GetChildCount(), &leftmostFrame, &rightmostFrame);
*aIsReordered = nsBidiPresUtils::CheckLineOrder(line->mFirstChild, line->GetChildCount(), &leftmostFrame, &rightmostFrame);
// map leftmost/rightmost to first/last according to paragraph direction
*aFirstVisual = mRightToLeft ? rightmostFrame : leftmostFrame;

View File

@ -106,7 +106,6 @@
#endif
#include "nsAutoPtr.h"
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#include "gfxFont.h"

View File

@ -1521,48 +1521,45 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
if (!GetCharacterData(text))
return PR_FALSE;
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
nsAutoString visualText;
/*
* XXXsmontagu: The SVG spec says:
*
* http://www.w3.org/TR/SVG11/text.html#DirectionProperty
* "For the 'direction' property to have any effect, the 'unicode-bidi'
* property's value must be embed or bidi-override."
*
* The SVGTiny spec, on the other hand, says
*
* http://www.w3.org/TR/SVGTiny12/text.html#DirectionProperty
* "For the 'direction' property to have any effect on an element that
* does not by itself establish a new text chunk (such as the 'tspan'
* element in SVG 1.2 Tiny), the 'unicode-bidi' property's value must
* be embed or bidi-override."
*
* Note that this is different from HTML/CSS, where setting the 'dir'
* attribute on an inline element automatically sets unicode-bidi: embed
*
* Our current implementation of bidi in SVG does not distinguish between
* different text elements, but treats every text container frame as a
* new text chunk, so we always set the base direction according to the
* direction property
*
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
*/
// Get the unicodeBidi property from the parent, because it doesn't
// inherit
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
NS_STYLE_UNICODE_BIDI_OVERRIDE);
nsBidiLevel baseDirection =
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
NSBIDI_RTL : NSBIDI_LTR;
bidiUtils->CopyLogicalToVisual(text, visualText,
baseDirection, bidiOverride);
if (!visualText.IsEmpty()) {
text = visualText;
}
nsAutoString visualText;
/*
* XXXsmontagu: The SVG spec says:
*
* http://www.w3.org/TR/SVG11/text.html#DirectionProperty
* "For the 'direction' property to have any effect, the 'unicode-bidi'
* property's value must be embed or bidi-override."
*
* The SVGTiny spec, on the other hand, says
*
* http://www.w3.org/TR/SVGTiny12/text.html#DirectionProperty
* "For the 'direction' property to have any effect on an element that
* does not by itself establish a new text chunk (such as the 'tspan'
* element in SVG 1.2 Tiny), the 'unicode-bidi' property's value must
* be embed or bidi-override."
*
* Note that this is different from HTML/CSS, where setting the 'dir'
* attribute on an inline element automatically sets unicode-bidi: embed
*
* Our current implementation of bidi in SVG does not distinguish between
* different text elements, but treats every text container frame as a
* new text chunk, so we always set the base direction according to the
* direction property
*
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
*/
// Get the unicodeBidi property from the parent, because it doesn't
// inherit
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
NS_STYLE_UNICODE_BIDI_OVERRIDE);
nsBidiLevel baseDirection =
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
NSBIDI_RTL : NSBIDI_LTR;
nsBidiPresUtils::CopyLogicalToVisual(text, visualText,
baseDirection, bidiOverride);
if (!visualText.IsEmpty()) {
text = visualText;
}
gfxMatrix m;

View File

@ -555,32 +555,28 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
if (mState & NS_FRAME_IS_BIDI) {
presContext->SetBidiEnabled();
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = GetStyleVisibility();
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// We let the RenderText function calculate the mnemonic's
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
}
else
{
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline);
}
const nsStyleVisibility* vis = GetStyleVisibility();
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// We let the RenderText function calculate the mnemonic's
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
}
else
{
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline);
}
}
if (NS_FAILED(rv) )

View File

@ -105,7 +105,7 @@
#include "nsRenderingContext.h"
#ifdef IBMBIDI
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#endif
// Enumeration function that cancels all the image requests in our cache