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 b0d7a6f909
commit d03542b94f
16 changed files with 550 additions and 712 deletions

View File

@@ -105,6 +105,7 @@
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
@@ -2656,10 +2657,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);
@@ -2705,7 +2702,8 @@ 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(),
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
@@ -2713,7 +2711,8 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidth);
&totalWidth,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@@ -2811,7 +2810,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
processor.mThebes = ctx;
rv = bidiUtils->ProcessText(textToDraw.get(),
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
@@ -2819,7 +2818,8 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
nsnull,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@@ -2848,7 +2848,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ApplyStyle(STYLE_FILL);
}
rv = bidiUtils->ProcessText(textToDraw.get(),
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
@@ -2856,7 +2856,8 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
nsnull,
&bidiEngine);
// this needs to be restored before function can return
if (doUseIntermediateSurface) {

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
@@ -174,9 +177,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,7 +189,7 @@ public:
*
* @lina 05/02/2000
*/
void ReorderFrames(nsIFrame* aFirstFrameOnLine,
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
@@ -194,7 +199,7 @@ public:
*
* @lina 06/18/2000
*/
nsresult FormatUnicodeText(nsPresContext* aPresContext,
static nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
@@ -217,7 +222,7 @@ 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,
static nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
@@ -232,7 +237,7 @@ public:
aTextRunConstructionContext, MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nsnull);
}
nscoord MeasureTextWidth(const PRUnichar* aText,
static nscoord MeasureTextWidth(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
@@ -253,7 +258,7 @@ public:
* @param[out] aLeftMost : leftmost frame on this line
* @param[out] aRightMost : rightmost frame on this line
*/
PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
static PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine,
nsIFrame** aLeftmost,
nsIFrame** aRightmost);
@@ -265,7 +270,7 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
static nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
@@ -276,7 +281,7 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
static nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
@@ -312,7 +317,7 @@ 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,
static nsresult ProcessText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
@@ -320,7 +325,8 @@ public:
Mode aMode,
nsBidiPositionResolve* aPosResolve,
PRInt32 aPosResolveCount,
nscoord* aWidth);
nscoord* aWidth,
nsBidi* aBidiEngine);
/**
* Make a copy of a string, converting from logical to visual order
@@ -335,22 +341,13 @@ public:
* @param aOverride if TRUE, the text has a bidi override, according to
* the direction in aDir
*/
void CopyLogicalToVisual(const nsAString& aSource,
static 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();
private:
nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
static nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
@@ -371,24 +368,8 @@ private:
* than one paragraph for bidi resolution, resolve the paragraph up to that
* point.
*/
void TraverseFrames(nsBlockFrame* aBlockFrame, 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, nsIFrame* aCurrentFrame,
BidiParagraphData *aBpd);
/*
* Position aFrame and it's descendants to their visual places. Also if aFrame
@@ -403,10 +384,10 @@ private:
* adding its right margin)
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
void RepositionFrame(nsIFrame* aFrame,
static void RepositionFrame(nsIFrame* aFrame,
PRBool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates) const;
nsContinuationStates* aContinuationStates);
/*
* Initialize the continuation state(nsFrameContinuationState) to
@@ -416,8 +397,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
@@ -434,10 +415,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,
static void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
PRBool& aIsLeftMost /* out */,
PRBool& aIsRightMost /* out */) const;
PRBool& aIsRightMost /* out */);
/**
* Adjust frame positions following their visual order
@@ -446,7 +427,8 @@ private:
*
* @lina 04/11/2000
*/
void RepositionInlineFrames(nsIFrame* aFirstChild) const;
static void RepositionInlineFrames(BidiLineData *aBld,
nsIFrame* aFirstChild);
/**
* Helper method for Resolve()
@@ -463,8 +445,8 @@ private:
* @see Resolve()
* @see RemoveBidiContinuation()
*/
inline
void EnsureBidiContinuation(nsIFrame* aFrame,
static inline
nsresult EnsureBidiContinuation(nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex,
PRInt32 aStart,
@@ -486,20 +468,23 @@ private:
* @see Resolve()
* @see EnsureBidiContinuation()
*/
void RemoveBidiContinuation(nsIFrame* aFrame,
static void RemoveBidiContinuation(BidiParagraphData* aBpd,
nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset) const;
void CalculateCharType(PRInt32& aOffset,
PRInt32& aOffset);
static void CalculateCharType(nsBidi* aBidiEngine,
const PRUnichar* aText,
PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType) const;
PRUint8& aPrevCharType);
void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength) const;
static void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength);
static PRBool WriteLogicalToVisual(const PRUnichar* aSrc,
PRUint32 aSrcLength,
@@ -510,23 +495,6 @@ private:
static void WriteReverse(const PRUnichar* aSrc,
PRUint32 aSrcLength,
PRUnichar* aDest);
nsString mBuffer;
nsTArray<PRUnichar> mEmbeddingStack;
nsTArray<nsIFrame*> mLogicalFrames;
nsTArray<nsIFrame*> mVisualFrames;
nsDataHashtable<nsISupportsHashKey, PRInt32> mContentToFrameIndex;
PRInt32 mArraySize;
PRInt32* mIndexMap;
PRUint8* mLevels;
nsresult mSuccess;
PRPackedBool mIsVisual;
nsBidiLevel mParaLevel;
nsIFrame* mPrevFrame;
nsIContent* mPrevContent;
nsAutoPtr<nsBlockInFlowLineIterator> mLineIter;
nsBidi* mBidiEngine;
};
#endif /* nsBidiPresUtils_h___ */

View File

@@ -2804,20 +2804,16 @@ 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,
rv = nsBidiPresUtils::RenderText(aString, aLength, direction,
presContext, *aContext, *aContext,
aPoint.x, aPoint.y);
}
}
if (NS_FAILED(rv))
#endif // IBMBIDI
{
@@ -2835,17 +2831,13 @@ 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,
return nsBidiPresUtils::MeasureTextWidth(aString, aLength,
direction, presContext, *aContext);
}
}
#endif // IBMBIDI
aContext->SetTextRunRTL(PR_FALSE);
nscoord width;

View File

@@ -361,8 +361,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)
@@ -387,8 +385,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
@@ -1464,15 +1460,6 @@ nsPresContext::SetBidiEnabled() const
}
}
nsBidiPresUtils*
nsPresContext::GetBidiUtils()
{
if (!mBidiUtils)
mBidiUtils = new nsBidiPresUtils;
return mBidiUtils;
}
void
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceRestyle)
{
@@ -1515,15 +1502,6 @@ nsPresContext::GetBidi() const
return Document()->GetBidiOptions();
}
PRUint32
nsPresContext::GetBidiMemoryUsed()
{
if (!mBidiUtils)
return 0;
return mBidiUtils->EstimateMemoryUsed();
}
#endif //IBMBIDI
PRBool

View File

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

View File

@@ -1408,15 +1408,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)
{
@@ -1430,10 +1421,6 @@ public:
return EstimateShellsMemory(LiveShellSizeEnumerator);
}
static PRInt64 SizeOfBidiMemoryReporter(void *) {
return EstimateShellsMemory(LiveShellBidiSizeEnumerator);
}
protected:
void QueryIsActive();
nsresult UpdateImageLockingState();
@@ -1649,12 +1636,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(LayoutPresShell,
PresShell::SizeOfLayoutMemoryReporter,
nsnull)
NS_MEMORY_REPORTER_IMPLEMENT(LayoutBidi,
"layout/bidi",
"Memory in use by layout Bidi processor.",
PresShell::SizeOfBidiMemoryReporter,
nsnull)
PresShell::PresShell()
{
mSelection = nsnull;
@@ -1682,7 +1663,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));
registeredReporter = true;
}

View File

@@ -4239,11 +4239,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
@@ -7179,11 +7175,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

@@ -452,7 +452,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) {
@@ -460,9 +459,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.
@@ -497,9 +496,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);
}
}
@@ -508,9 +507,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;
@@ -527,7 +526,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) {
@@ -535,9 +533,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.
@@ -572,9 +570,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);
}
}
@@ -584,9 +582,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

@@ -1007,22 +1007,18 @@ 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,
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_RTL,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.XMost() - strWidth, y + maxAscent);
else
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_LTR,
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

@@ -663,11 +663,9 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
nsPresContext* presContext = line->mFirstChild->PresContext();
nsBidiPresUtils* bidiUtils = 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

@@ -108,7 +108,6 @@
#endif
#include "nsAutoPtr.h"
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#include "nsIThebesFontMetrics.h"

View File

@@ -1530,8 +1530,6 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
if (!GetCharacterData(text))
return PR_FALSE;
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
nsAutoString visualText;
/*
@@ -1567,12 +1565,11 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
nsBidiLevel baseDirection =
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
NSBIDI_RTL : NSBIDI_LTR;
bidiUtils->CopyLogicalToVisual(text, visualText,
nsBidiPresUtils::CopyLogicalToVisual(text, visualText,
baseDirection, bidiOverride);
if (!visualText.IsEmpty()) {
text = visualText;
}
}
gfxMatrix m;
if (aForceGlobalTransform ||

View File

@@ -533,9 +533,6 @@ nsTextBoxFrame::DrawText(nsIRenderingContext& 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) {
@@ -543,7 +540,7 @@ nsTextBoxFrame::DrawText(nsIRenderingContext& aRenderingContext,
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline,
@@ -554,13 +551,12 @@ nsTextBoxFrame::DrawText(nsIRenderingContext& aRenderingContext,
}
else
{
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline);
}
}
}
if (NS_FAILED(rv) )
#endif // IBMBIDI
{

View File

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