Make all nsBidiPresUtils methods static. Bug 624798, r=roc
This commit is contained in:
@@ -105,6 +105,7 @@
|
|||||||
|
|
||||||
#include "nsFrameManager.h"
|
#include "nsFrameManager.h"
|
||||||
#include "nsFrameLoader.h"
|
#include "nsFrameLoader.h"
|
||||||
|
#include "nsBidi.h"
|
||||||
#include "nsBidiPresUtils.h"
|
#include "nsBidiPresUtils.h"
|
||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
#include "CanvasUtils.h"
|
#include "CanvasUtils.h"
|
||||||
@@ -2656,10 +2657,6 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||||||
|
|
||||||
nsIDocument* document = presShell->GetDocument();
|
nsIDocument* document = presShell->GetDocument();
|
||||||
|
|
||||||
nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
|
|
||||||
if (!bidiUtils)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
// replace all the whitespace characters with U+0020 SPACE
|
// replace all the whitespace characters with U+0020 SPACE
|
||||||
nsAutoString textToDraw(aRawText);
|
nsAutoString textToDraw(aRawText);
|
||||||
TextReplaceWhitespaceCharacters(textToDraw);
|
TextReplaceWhitespaceCharacters(textToDraw);
|
||||||
@@ -2705,15 +2702,17 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||||||
|
|
||||||
// calls bidi algo twice since it needs the full text width and the
|
// calls bidi algo twice since it needs the full text width and the
|
||||||
// bounding boxes before rendering anything
|
// bounding boxes before rendering anything
|
||||||
rv = bidiUtils->ProcessText(textToDraw.get(),
|
nsBidi bidiEngine;
|
||||||
textToDraw.Length(),
|
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
|
||||||
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
textToDraw.Length(),
|
||||||
presShell->GetPresContext(),
|
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
||||||
processor,
|
presShell->GetPresContext(),
|
||||||
nsBidiPresUtils::MODE_MEASURE,
|
processor,
|
||||||
nsnull,
|
nsBidiPresUtils::MODE_MEASURE,
|
||||||
0,
|
nsnull,
|
||||||
&totalWidth);
|
0,
|
||||||
|
&totalWidth,
|
||||||
|
&bidiEngine);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@@ -2811,15 +2810,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||||
processor.mThebes = ctx;
|
processor.mThebes = ctx;
|
||||||
|
|
||||||
rv = bidiUtils->ProcessText(textToDraw.get(),
|
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
|
||||||
textToDraw.Length(),
|
textToDraw.Length(),
|
||||||
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
||||||
presShell->GetPresContext(),
|
presShell->GetPresContext(),
|
||||||
processor,
|
processor,
|
||||||
nsBidiPresUtils::MODE_DRAW,
|
nsBidiPresUtils::MODE_DRAW,
|
||||||
nsnull,
|
nsnull,
|
||||||
0,
|
0,
|
||||||
nsnull);
|
nsnull,
|
||||||
|
&bidiEngine);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@@ -2848,15 +2848,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||||||
ApplyStyle(STYLE_FILL);
|
ApplyStyle(STYLE_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = bidiUtils->ProcessText(textToDraw.get(),
|
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
|
||||||
textToDraw.Length(),
|
textToDraw.Length(),
|
||||||
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
|
||||||
presShell->GetPresContext(),
|
presShell->GetPresContext(),
|
||||||
processor,
|
processor,
|
||||||
nsBidiPresUtils::MODE_DRAW,
|
nsBidiPresUtils::MODE_DRAW,
|
||||||
nsnull,
|
nsnull,
|
||||||
0,
|
0,
|
||||||
nsnull);
|
nsnull,
|
||||||
|
&bidiEngine);
|
||||||
|
|
||||||
// this needs to be restored before function can return
|
// this needs to be restored before function can return
|
||||||
if (doUseIntermediateSurface) {
|
if (doUseIntermediateSurface) {
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ public:
|
|||||||
* The array does not need to be initialized.<p>
|
* The array does not need to be initialized.<p>
|
||||||
* The index map will result in <code>aIndexMap[aLogicalIndex]==aVisualIndex</code>.
|
* 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
|
#endif // FULL_BIDI_ENGINE
|
||||||
/**
|
/**
|
||||||
* This is a convenience function that does not use a nsBidi object.
|
* 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 array does not need to be initialized.<p>
|
||||||
* The index map will result in <code>aIndexMap[aVisualIndex]==aLogicalIndex</code>.
|
* 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
|
#ifdef FULL_BIDI_ENGINE
|
||||||
/**
|
/**
|
||||||
@@ -917,7 +917,7 @@ private:
|
|||||||
|
|
||||||
void ReorderLine(nsBidiLevel aMinLevel, nsBidiLevel aMaxLevel);
|
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,
|
PRInt32 doWriteReverse(const PRUnichar *src, PRInt32 srcLength,
|
||||||
PRUnichar *dest, PRUint16 options);
|
PRUnichar *dest, PRUint16 options);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,9 @@
|
|||||||
#undef DrawText
|
#undef DrawText
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct BidiParagraphData;
|
||||||
|
struct BidiLineData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structure representing some continuation state for each frame on the line,
|
* A structure representing some continuation state for each frame on the line,
|
||||||
* used to determine the first and the last continuation frame for each
|
* used to determine the first and the last continuation frame for each
|
||||||
@@ -174,9 +177,11 @@ public:
|
|||||||
*
|
*
|
||||||
* @lina 06/18/2000
|
* @lina 06/18/2000
|
||||||
*/
|
*/
|
||||||
nsresult Resolve(nsBlockFrame* aBlockFrame);
|
static nsresult Resolve(nsBlockFrame* aBlockFrame);
|
||||||
void ResolveParagraph(nsBlockFrame* aBlockFrame);
|
static nsresult ResolveParagraph(nsBlockFrame* aBlockFrame,
|
||||||
void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame);
|
BidiParagraphData* aBpd);
|
||||||
|
static void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
|
||||||
|
BidiParagraphData* aBpd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorder this line using Bidi engine.
|
* Reorder this line using Bidi engine.
|
||||||
@@ -184,8 +189,8 @@ public:
|
|||||||
*
|
*
|
||||||
* @lina 05/02/2000
|
* @lina 05/02/2000
|
||||||
*/
|
*/
|
||||||
void ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
||||||
PRInt32 aNumFramesOnLine);
|
PRInt32 aNumFramesOnLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format Unicode text, taking into account bidi capabilities
|
* Format Unicode text, taking into account bidi capabilities
|
||||||
@@ -194,11 +199,11 @@ public:
|
|||||||
*
|
*
|
||||||
* @lina 06/18/2000
|
* @lina 06/18/2000
|
||||||
*/
|
*/
|
||||||
nsresult FormatUnicodeText(nsPresContext* aPresContext,
|
static nsresult FormatUnicodeText(nsPresContext* aPresContext,
|
||||||
PRUnichar* aText,
|
PRUnichar* aText,
|
||||||
PRInt32& aTextLength,
|
PRInt32& aTextLength,
|
||||||
nsCharType aCharType,
|
nsCharType aCharType,
|
||||||
PRBool aIsOddLevel);
|
PRBool aIsOddLevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorder plain text using the Unicode Bidi algorithm and send it to
|
* Reorder plain text using the Unicode Bidi algorithm and send it to
|
||||||
@@ -217,26 +222,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[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
|
* @param aPosResolveCount number of items in the aPosResolve array
|
||||||
*/
|
*/
|
||||||
nsresult RenderText(const PRUnichar* aText,
|
static nsresult RenderText(const PRUnichar* aText,
|
||||||
PRInt32 aLength,
|
PRInt32 aLength,
|
||||||
nsBidiDirection aBaseDirection,
|
nsBidiDirection aBaseDirection,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext,
|
nsIRenderingContext& aRenderingContext,
|
||||||
nsIRenderingContext& aTextRunConstructionContext,
|
nsIRenderingContext& aTextRunConstructionContext,
|
||||||
nscoord aX,
|
nscoord aX,
|
||||||
nscoord aY,
|
nscoord aY,
|
||||||
nsBidiPositionResolve* aPosResolve = nsnull,
|
nsBidiPositionResolve* aPosResolve = nsnull,
|
||||||
PRInt32 aPosResolveCount = 0)
|
PRInt32 aPosResolveCount = 0)
|
||||||
{
|
{
|
||||||
return ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext, aRenderingContext,
|
return ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext, aRenderingContext,
|
||||||
aTextRunConstructionContext, MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nsnull);
|
aTextRunConstructionContext, MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord MeasureTextWidth(const PRUnichar* aText,
|
static nscoord MeasureTextWidth(const PRUnichar* aText,
|
||||||
PRInt32 aLength,
|
PRInt32 aLength,
|
||||||
nsBidiDirection aBaseDirection,
|
nsBidiDirection aBaseDirection,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext)
|
nsIRenderingContext& aRenderingContext)
|
||||||
{
|
{
|
||||||
nscoord length;
|
nscoord length;
|
||||||
nsresult rv = ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext,
|
nsresult rv = ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext,
|
||||||
@@ -253,10 +258,10 @@ public:
|
|||||||
* @param[out] aLeftMost : leftmost frame on this line
|
* @param[out] aLeftMost : leftmost frame on this line
|
||||||
* @param[out] aRightMost : rightmost frame on this line
|
* @param[out] aRightMost : rightmost frame on this line
|
||||||
*/
|
*/
|
||||||
PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
|
static PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
|
||||||
PRInt32 aNumFramesOnLine,
|
PRInt32 aNumFramesOnLine,
|
||||||
nsIFrame** aLeftmost,
|
nsIFrame** aLeftmost,
|
||||||
nsIFrame** aRightmost);
|
nsIFrame** aRightmost);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the frame to the right of the given frame, on the same line.
|
* Get the frame to the right of the given frame, on the same line.
|
||||||
@@ -265,9 +270,9 @@ public:
|
|||||||
* @param aFirstFrameOnLine : first frame of the line to be tested
|
* @param aFirstFrameOnLine : first frame of the line to be tested
|
||||||
* @param aNumFramesOnLine : number of frames on this line
|
* @param aNumFramesOnLine : number of frames on this line
|
||||||
*/
|
*/
|
||||||
nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
|
static nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
|
||||||
nsIFrame* aFirstFrameOnLine,
|
nsIFrame* aFirstFrameOnLine,
|
||||||
PRInt32 aNumFramesOnLine);
|
PRInt32 aNumFramesOnLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the frame to the left of the given frame, on the same line.
|
* Get the frame to the left of the given frame, on the same line.
|
||||||
@@ -276,9 +281,9 @@ public:
|
|||||||
* @param aFirstFrameOnLine : first frame of the line to be tested
|
* @param aFirstFrameOnLine : first frame of the line to be tested
|
||||||
* @param aNumFramesOnLine : number of frames on this line
|
* @param aNumFramesOnLine : number of frames on this line
|
||||||
*/
|
*/
|
||||||
nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
|
static nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
|
||||||
nsIFrame* aFirstFrameOnLine,
|
nsIFrame* aFirstFrameOnLine,
|
||||||
PRInt32 aNumFramesOnLine);
|
PRInt32 aNumFramesOnLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the bidi embedding level of the given (inline) frame.
|
* Get the bidi embedding level of the given (inline) frame.
|
||||||
@@ -312,15 +317,16 @@ public:
|
|||||||
* @param aPosResolveCount number of items in the aPosResolve array
|
* @param aPosResolveCount number of items in the aPosResolve array
|
||||||
* @param[out] aWidth Pointer to where the width will be stored (may be null)
|
* @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,
|
PRInt32 aLength,
|
||||||
nsBidiDirection aBaseDirection,
|
nsBidiDirection aBaseDirection,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
BidiProcessor& aprocessor,
|
BidiProcessor& aprocessor,
|
||||||
Mode aMode,
|
Mode aMode,
|
||||||
nsBidiPositionResolve* aPosResolve,
|
nsBidiPositionResolve* aPosResolve,
|
||||||
PRInt32 aPosResolveCount,
|
PRInt32 aPosResolveCount,
|
||||||
nscoord* aWidth);
|
nscoord* aWidth,
|
||||||
|
nsBidi* aBidiEngine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a copy of a string, converting from logical to visual order
|
* Make a copy of a string, converting from logical to visual order
|
||||||
@@ -335,33 +341,24 @@ public:
|
|||||||
* @param aOverride if TRUE, the text has a bidi override, according to
|
* @param aOverride if TRUE, the text has a bidi override, according to
|
||||||
* the direction in aDir
|
* the direction in aDir
|
||||||
*/
|
*/
|
||||||
void CopyLogicalToVisual(const nsAString& aSource,
|
static void CopyLogicalToVisual(const nsAString& aSource,
|
||||||
nsAString& aDest,
|
nsAString& aDest,
|
||||||
nsBidiLevel aBaseDirection,
|
nsBidiLevel aBaseDirection,
|
||||||
PRBool aOverride);
|
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:
|
private:
|
||||||
nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
|
static nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
|
||||||
PRInt32 aLength,
|
PRInt32 aLength,
|
||||||
nsBidiDirection aBaseDirection,
|
nsBidiDirection aBaseDirection,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext,
|
nsIRenderingContext& aRenderingContext,
|
||||||
nsIRenderingContext& aTextRunConstructionContext,
|
nsIRenderingContext& aTextRunConstructionContext,
|
||||||
Mode aMode,
|
Mode aMode,
|
||||||
nscoord aX, // DRAW only
|
nscoord aX, // DRAW only
|
||||||
nscoord aY, // DRAW only
|
nscoord aY, // DRAW only
|
||||||
nsBidiPositionResolve* aPosResolve, /* may be null */
|
nsBidiPositionResolve* aPosResolve, /* may be null */
|
||||||
PRInt32 aPosResolveCount,
|
PRInt32 aPosResolveCount,
|
||||||
nscoord* aWidth /* may be null */);
|
nscoord* aWidth /* may be null */);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverse the child frames of the block element and:
|
* Traverse the child frames of the block element and:
|
||||||
@@ -371,24 +368,8 @@ private:
|
|||||||
* than one paragraph for bidi resolution, resolve the paragraph up to that
|
* than one paragraph for bidi resolution, resolve the paragraph up to that
|
||||||
* point.
|
* point.
|
||||||
*/
|
*/
|
||||||
void TraverseFrames(nsBlockFrame* aBlockFrame, nsIFrame* aCurrentFrame);
|
static void TraverseFrames(nsBlockFrame* aBlockFrame, nsIFrame* aCurrentFrame,
|
||||||
|
BidiParagraphData *aBpd);
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Position aFrame and it's descendants to their visual places. Also if aFrame
|
* Position aFrame and it's descendants to their visual places. Also if aFrame
|
||||||
@@ -403,10 +384,10 @@ private:
|
|||||||
* adding its right margin)
|
* adding its right margin)
|
||||||
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
|
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
|
||||||
*/
|
*/
|
||||||
void RepositionFrame(nsIFrame* aFrame,
|
static void RepositionFrame(nsIFrame* aFrame,
|
||||||
PRBool aIsOddLevel,
|
PRBool aIsOddLevel,
|
||||||
nscoord& aLeft,
|
nscoord& aLeft,
|
||||||
nsContinuationStates* aContinuationStates) const;
|
nsContinuationStates* aContinuationStates);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the continuation state(nsFrameContinuationState) to
|
* Initialize the continuation state(nsFrameContinuationState) to
|
||||||
@@ -416,8 +397,8 @@ private:
|
|||||||
* be initialized
|
* be initialized
|
||||||
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
|
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
|
||||||
*/
|
*/
|
||||||
void InitContinuationStates(nsIFrame* aFrame,
|
static void InitContinuationStates(nsIFrame* aFrame,
|
||||||
nsContinuationStates* aContinuationStates) const;
|
nsContinuationStates* aContinuationStates);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine if aFrame is leftmost or rightmost, and set aIsLeftMost and
|
* 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] aIsLeftMost TRUE means aFrame is leftmost frame or continuation
|
||||||
* @param[out] aIsRightMost TRUE means aFrame is rightmost 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,
|
nsContinuationStates* aContinuationStates,
|
||||||
PRBool& aIsLeftMost /* out */,
|
PRBool& aIsLeftMost /* out */,
|
||||||
PRBool& aIsRightMost /* out */) const;
|
PRBool& aIsRightMost /* out */);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust frame positions following their visual order
|
* Adjust frame positions following their visual order
|
||||||
@@ -446,7 +427,8 @@ private:
|
|||||||
*
|
*
|
||||||
* @lina 04/11/2000
|
* @lina 04/11/2000
|
||||||
*/
|
*/
|
||||||
void RepositionInlineFrames(nsIFrame* aFirstChild) const;
|
static void RepositionInlineFrames(BidiLineData *aBld,
|
||||||
|
nsIFrame* aFirstChild);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for Resolve()
|
* Helper method for Resolve()
|
||||||
@@ -463,12 +445,12 @@ private:
|
|||||||
* @see Resolve()
|
* @see Resolve()
|
||||||
* @see RemoveBidiContinuation()
|
* @see RemoveBidiContinuation()
|
||||||
*/
|
*/
|
||||||
inline
|
static inline
|
||||||
void EnsureBidiContinuation(nsIFrame* aFrame,
|
nsresult EnsureBidiContinuation(nsIFrame* aFrame,
|
||||||
nsIFrame** aNewFrame,
|
nsIFrame** aNewFrame,
|
||||||
PRInt32& aFrameIndex,
|
PRInt32& aFrameIndex,
|
||||||
PRInt32 aStart,
|
PRInt32 aStart,
|
||||||
PRInt32 aEnd);
|
PRInt32 aEnd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for Resolve()
|
* Helper method for Resolve()
|
||||||
@@ -486,20 +468,23 @@ private:
|
|||||||
* @see Resolve()
|
* @see Resolve()
|
||||||
* @see EnsureBidiContinuation()
|
* @see EnsureBidiContinuation()
|
||||||
*/
|
*/
|
||||||
void RemoveBidiContinuation(nsIFrame* aFrame,
|
static void RemoveBidiContinuation(BidiParagraphData* aBpd,
|
||||||
PRInt32 aFirstIndex,
|
nsIFrame* aFrame,
|
||||||
PRInt32 aLastIndex,
|
PRInt32 aFirstIndex,
|
||||||
PRInt32& aOffset) const;
|
PRInt32 aLastIndex,
|
||||||
void CalculateCharType(PRInt32& aOffset,
|
PRInt32& aOffset);
|
||||||
PRInt32 aCharTypeLimit,
|
static void CalculateCharType(nsBidi* aBidiEngine,
|
||||||
PRInt32& aRunLimit,
|
const PRUnichar* aText,
|
||||||
PRInt32& aRunLength,
|
PRInt32& aOffset,
|
||||||
PRInt32& aRunCount,
|
PRInt32 aCharTypeLimit,
|
||||||
PRUint8& aCharType,
|
PRInt32& aRunLimit,
|
||||||
PRUint8& aPrevCharType) const;
|
PRInt32& aRunLength,
|
||||||
|
PRInt32& aRunCount,
|
||||||
|
PRUint8& aCharType,
|
||||||
|
PRUint8& aPrevCharType);
|
||||||
|
|
||||||
void StripBidiControlCharacters(PRUnichar* aText,
|
static void StripBidiControlCharacters(PRUnichar* aText,
|
||||||
PRInt32& aTextLength) const;
|
PRInt32& aTextLength);
|
||||||
|
|
||||||
static PRBool WriteLogicalToVisual(const PRUnichar* aSrc,
|
static PRBool WriteLogicalToVisual(const PRUnichar* aSrc,
|
||||||
PRUint32 aSrcLength,
|
PRUint32 aSrcLength,
|
||||||
@@ -507,26 +492,9 @@ private:
|
|||||||
nsBidiLevel aBaseDirection,
|
nsBidiLevel aBaseDirection,
|
||||||
nsBidi* aBidiEngine);
|
nsBidi* aBidiEngine);
|
||||||
|
|
||||||
static void WriteReverse(const PRUnichar* aSrc,
|
static void WriteReverse(const PRUnichar* aSrc,
|
||||||
PRUint32 aSrcLength,
|
PRUint32 aSrcLength,
|
||||||
PRUnichar* aDest);
|
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___ */
|
#endif /* nsBidiPresUtils_h___ */
|
||||||
|
|||||||
@@ -2804,19 +2804,15 @@ nsLayoutUtils::DrawString(const nsIFrame* aFrame,
|
|||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
nsPresContext* presContext = aFrame->PresContext();
|
nsPresContext* presContext = aFrame->PresContext();
|
||||||
if (presContext->BidiEnabled()) {
|
if (presContext->BidiEnabled()) {
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
if (aDirection == NS_STYLE_DIRECTION_INHERIT) {
|
||||||
|
aDirection = aFrame->GetStyleVisibility()->mDirection;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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))
|
if (NS_FAILED(rv))
|
||||||
#endif // IBMBIDI
|
#endif // IBMBIDI
|
||||||
@@ -2835,16 +2831,12 @@ nsLayoutUtils::GetStringWidth(const nsIFrame* aFrame,
|
|||||||
#ifdef IBMBIDI
|
#ifdef IBMBIDI
|
||||||
nsPresContext* presContext = aFrame->PresContext();
|
nsPresContext* presContext = aFrame->PresContext();
|
||||||
if (presContext->BidiEnabled()) {
|
if (presContext->BidiEnabled()) {
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
|
||||||
|
nsBidiDirection direction =
|
||||||
if (bidiUtils) {
|
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
|
||||||
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
|
NSBIDI_RTL : NSBIDI_LTR;
|
||||||
nsBidiDirection direction =
|
return nsBidiPresUtils::MeasureTextWidth(aString, aLength,
|
||||||
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
|
direction, presContext, *aContext);
|
||||||
NSBIDI_RTL : NSBIDI_LTR;
|
|
||||||
return bidiUtils->MeasureTextWidth(aString, aLength,
|
|
||||||
direction, presContext, *aContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif // IBMBIDI
|
#endif // IBMBIDI
|
||||||
aContext->SetTextRunRTL(PR_FALSE);
|
aContext->SetTextRunRTL(PR_FALSE);
|
||||||
|
|||||||
@@ -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(mLangService); // a service
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrintSettings);
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrintSettings);
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrefChangedTimer);
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrefChangedTimer);
|
||||||
if (tmp->mBidiUtils)
|
|
||||||
tmp->mBidiUtils->Traverse(cb);
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
|
||||||
@@ -387,8 +385,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
|
|||||||
tmp->mPrefChangedTimer->Cancel();
|
tmp->mPrefChangedTimer->Cancel();
|
||||||
tmp->mPrefChangedTimer = nsnull;
|
tmp->mPrefChangedTimer = nsnull;
|
||||||
}
|
}
|
||||||
if (tmp->mBidiUtils)
|
|
||||||
tmp->mBidiUtils->Unlink();
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
|
|
||||||
@@ -1464,15 +1460,6 @@ nsPresContext::SetBidiEnabled() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsBidiPresUtils*
|
|
||||||
nsPresContext::GetBidiUtils()
|
|
||||||
{
|
|
||||||
if (!mBidiUtils)
|
|
||||||
mBidiUtils = new nsBidiPresUtils;
|
|
||||||
|
|
||||||
return mBidiUtils;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceRestyle)
|
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceRestyle)
|
||||||
{
|
{
|
||||||
@@ -1515,15 +1502,6 @@ nsPresContext::GetBidi() const
|
|||||||
return Document()->GetBidiOptions();
|
return Document()->GetBidiOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32
|
|
||||||
nsPresContext::GetBidiMemoryUsed()
|
|
||||||
{
|
|
||||||
if (!mBidiUtils)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return mBidiUtils->EstimateMemoryUsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //IBMBIDI
|
#endif //IBMBIDI
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
|
|||||||
@@ -752,11 +752,6 @@ public:
|
|||||||
|
|
||||||
//Mohamed
|
//Mohamed
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a Bidi presentation utilities object
|
|
||||||
*/
|
|
||||||
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Bidi options for the presentation context
|
* Set the Bidi options for the presentation context
|
||||||
*/
|
*/
|
||||||
@@ -769,10 +764,6 @@ public:
|
|||||||
* include nsIDocument.
|
* include nsIDocument.
|
||||||
*/
|
*/
|
||||||
NS_HIDDEN_(PRUint32) GetBidi() const;
|
NS_HIDDEN_(PRUint32) GetBidi() const;
|
||||||
|
|
||||||
PRUint32 GetBidiMemoryUsed();
|
|
||||||
#else
|
|
||||||
PRUint32 GetBidiMemoryUsed() { return 0; }
|
|
||||||
#endif // IBMBIDI
|
#endif // IBMBIDI
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1005,7 +996,6 @@ public:
|
|||||||
PRUint32 result = 0;
|
PRUint32 result = 0;
|
||||||
|
|
||||||
result += sizeof(nsPresContext);
|
result += sizeof(nsPresContext);
|
||||||
result += GetBidiMemoryUsed();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1094,10 +1084,6 @@ protected:
|
|||||||
PRInt32 mCurAppUnitsPerDevPixel;
|
PRInt32 mCurAppUnitsPerDevPixel;
|
||||||
PRInt32 mAutoQualityMinFontSizePixelsPref;
|
PRInt32 mAutoQualityMinFontSizePixelsPref;
|
||||||
|
|
||||||
#ifdef IBMBIDI
|
|
||||||
nsAutoPtr<nsBidiPresUtils> mBidiUtils;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nsCOMPtr<nsITheme> mTheme;
|
nsCOMPtr<nsITheme> mTheme;
|
||||||
nsCOMPtr<nsILanguageAtomService> mLangService;
|
nsCOMPtr<nsILanguageAtomService> mLangService;
|
||||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||||
|
|||||||
@@ -1408,15 +1408,6 @@ public:
|
|||||||
return PL_DHASH_NEXT;
|
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
|
static PRUint32
|
||||||
EstimateShellsMemory(nsTHashtable<PresShellPtrKey>::Enumerator aEnumerator)
|
EstimateShellsMemory(nsTHashtable<PresShellPtrKey>::Enumerator aEnumerator)
|
||||||
{
|
{
|
||||||
@@ -1430,10 +1421,6 @@ public:
|
|||||||
return EstimateShellsMemory(LiveShellSizeEnumerator);
|
return EstimateShellsMemory(LiveShellSizeEnumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRInt64 SizeOfBidiMemoryReporter(void *) {
|
|
||||||
return EstimateShellsMemory(LiveShellBidiSizeEnumerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void QueryIsActive();
|
void QueryIsActive();
|
||||||
nsresult UpdateImageLockingState();
|
nsresult UpdateImageLockingState();
|
||||||
@@ -1649,12 +1636,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(LayoutPresShell,
|
|||||||
PresShell::SizeOfLayoutMemoryReporter,
|
PresShell::SizeOfLayoutMemoryReporter,
|
||||||
nsnull)
|
nsnull)
|
||||||
|
|
||||||
NS_MEMORY_REPORTER_IMPLEMENT(LayoutBidi,
|
|
||||||
"layout/bidi",
|
|
||||||
"Memory in use by layout Bidi processor.",
|
|
||||||
PresShell::SizeOfBidiMemoryReporter,
|
|
||||||
nsnull)
|
|
||||||
|
|
||||||
PresShell::PresShell()
|
PresShell::PresShell()
|
||||||
{
|
{
|
||||||
mSelection = nsnull;
|
mSelection = nsnull;
|
||||||
@@ -1682,7 +1663,6 @@ PresShell::PresShell()
|
|||||||
static bool registeredReporter = false;
|
static bool registeredReporter = false;
|
||||||
if (!registeredReporter) {
|
if (!registeredReporter) {
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutPresShell));
|
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutPresShell));
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutBidi));
|
|
||||||
registeredReporter = true;
|
registeredReporter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4239,11 +4239,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||||||
if (aState.mPresContext->BidiEnabled()) {
|
if (aState.mPresContext->BidiEnabled()) {
|
||||||
if (!aState.mPresContext->IsVisualMode() ||
|
if (!aState.mPresContext->IsVisualMode() ||
|
||||||
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
||||||
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
|
nsBidiPresUtils::ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
|
||||||
|
|
||||||
if (bidiUtils && bidiUtils->IsSuccessful() ) {
|
|
||||||
bidiUtils->ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
|
|
||||||
} // bidiUtils
|
|
||||||
} // not visual mode
|
} // not visual mode
|
||||||
} // bidi enabled
|
} // bidi enabled
|
||||||
#endif // IBMBIDI
|
#endif // IBMBIDI
|
||||||
@@ -7179,11 +7175,7 @@ nsBlockFrame::ResolveBidi()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
return nsBidiPresUtils::Resolve(this);
|
||||||
if (!bidiUtils)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
return bidiUtils->Resolve(this);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,6 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
|
|||||||
return aFrame ? aFrame->GetPrevSibling() : LastChild();
|
return aFrame ? aFrame->GetPrevSibling() : LastChild();
|
||||||
|
|
||||||
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
|
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
|
||||||
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
|
|
||||||
|
|
||||||
nsAutoLineIterator iter = parent->GetLineIterator();
|
nsAutoLineIterator iter = parent->GetLineIterator();
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
@@ -460,9 +459,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
|
|||||||
if (parent->GetType() == nsGkAtoms::lineFrame) {
|
if (parent->GetType() == nsGkAtoms::lineFrame) {
|
||||||
// Line frames are not bidi-splittable, so need to consider bidi reordering
|
// Line frames are not bidi-splittable, so need to consider bidi reordering
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
|
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
|
||||||
} else { // RTL
|
} else { // RTL
|
||||||
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
|
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Just get the next or prev sibling, depending on block and frame direction.
|
// 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);
|
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
|
||||||
|
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
frame = bidiUtils->GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
|
||||||
} else { // RTL
|
} 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);
|
iter->GetLine(thisLine - 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
|
||||||
|
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
||||||
} else { // RTL
|
} else { // RTL
|
||||||
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frame;
|
return frame;
|
||||||
@@ -527,7 +526,6 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
|
|||||||
return aFrame ? aFrame->GetPrevSibling() : mFirstChild;
|
return aFrame ? aFrame->GetPrevSibling() : mFirstChild;
|
||||||
|
|
||||||
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
|
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
|
||||||
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
|
|
||||||
|
|
||||||
nsAutoLineIterator iter = parent->GetLineIterator();
|
nsAutoLineIterator iter = parent->GetLineIterator();
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
@@ -535,9 +533,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
|
|||||||
if (parent->GetType() == nsGkAtoms::lineFrame) {
|
if (parent->GetType() == nsGkAtoms::lineFrame) {
|
||||||
// Line frames are not bidi-splittable, so need to consider bidi reordering
|
// Line frames are not bidi-splittable, so need to consider bidi reordering
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
|
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
|
||||||
} else { // RTL
|
} else { // RTL
|
||||||
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
|
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Just get the next or prev sibling, depending on block and frame direction.
|
// 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);
|
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
|
||||||
|
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
frame = bidiUtils->GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
|
||||||
} else { // RTL
|
} 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);
|
iter->GetLine(thisLine + 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
|
||||||
|
|
||||||
if (baseLevel == NSBIDI_LTR) {
|
if (baseLevel == NSBIDI_LTR) {
|
||||||
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
||||||
} else { // RTL
|
} else { // RTL
|
||||||
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frame;
|
return frame;
|
||||||
|
|||||||
@@ -1007,21 +1007,17 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
|
|||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if (aPresContext->BidiEnabled()) {
|
if (aPresContext->BidiEnabled()) {
|
||||||
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
||||||
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
|
||||||
if (bidiUtils) {
|
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_RTL,
|
||||||
const nsStyleVisibility* vis = GetStyleVisibility();
|
aPresContext, aRenderingContext,
|
||||||
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
|
aRenderingContext,
|
||||||
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_RTL,
|
aRect.XMost() - strWidth, y + maxAscent);
|
||||||
aPresContext, aRenderingContext,
|
else
|
||||||
aRenderingContext,
|
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_LTR,
|
||||||
aRect.XMost() - strWidth, y + maxAscent);
|
aPresContext, aRenderingContext,
|
||||||
else
|
aRenderingContext,
|
||||||
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_LTR,
|
aRect.x, y + maxAscent);
|
||||||
aPresContext, aRenderingContext,
|
|
||||||
aRenderingContext,
|
|
||||||
aRect.x, y + maxAscent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);
|
aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);
|
||||||
|
|||||||
@@ -663,11 +663,9 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
|
|||||||
|
|
||||||
nsPresContext* presContext = line->mFirstChild->PresContext();
|
nsPresContext* presContext = line->mFirstChild->PresContext();
|
||||||
|
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
|
||||||
|
|
||||||
nsIFrame* leftmostFrame;
|
nsIFrame* leftmostFrame;
|
||||||
nsIFrame* rightmostFrame;
|
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
|
// map leftmost/rightmost to first/last according to paragraph direction
|
||||||
*aFirstVisual = mRightToLeft ? rightmostFrame : leftmostFrame;
|
*aFirstVisual = mRightToLeft ? rightmostFrame : leftmostFrame;
|
||||||
|
|||||||
@@ -108,7 +108,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
|
|
||||||
#include "nsBidiPresUtils.h"
|
|
||||||
#include "nsBidiUtils.h"
|
#include "nsBidiUtils.h"
|
||||||
|
|
||||||
#include "nsIThebesFontMetrics.h"
|
#include "nsIThebesFontMetrics.h"
|
||||||
|
|||||||
@@ -1530,48 +1530,45 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
|
|||||||
if (!GetCharacterData(text))
|
if (!GetCharacterData(text))
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
nsAutoString visualText;
|
||||||
if (bidiUtils) {
|
|
||||||
nsAutoString visualText;
|
/*
|
||||||
|
* XXXsmontagu: The SVG spec says:
|
||||||
/*
|
*
|
||||||
* 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'
|
||||||
* http://www.w3.org/TR/SVG11/text.html#DirectionProperty
|
* property's value must be embed or bidi-override."
|
||||||
* "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
|
||||||
*
|
*
|
||||||
* 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
|
||||||
* http://www.w3.org/TR/SVGTiny12/text.html#DirectionProperty
|
* does not by itself establish a new text chunk (such as the 'tspan'
|
||||||
* "For the 'direction' property to have any effect on an element that
|
* element in SVG 1.2 Tiny), the 'unicode-bidi' property's value must
|
||||||
* does not by itself establish a new text chunk (such as the 'tspan'
|
* be embed or bidi-override."
|
||||||
* 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
|
||||||
* 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
|
||||||
* Our current implementation of bidi in SVG does not distinguish between
|
* new text chunk, so we always set the base direction according to the
|
||||||
* different text elements, but treats every text container frame as a
|
* direction property
|
||||||
* new text chunk, so we always set the base direction according to the
|
*
|
||||||
* direction property
|
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
|
||||||
*
|
*/
|
||||||
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
|
|
||||||
*/
|
// Get the unicodeBidi property from the parent, because it doesn't
|
||||||
|
// inherit
|
||||||
// Get the unicodeBidi property from the parent, because it doesn't
|
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
|
||||||
// inherit
|
NS_STYLE_UNICODE_BIDI_OVERRIDE);
|
||||||
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
|
nsBidiLevel baseDirection =
|
||||||
NS_STYLE_UNICODE_BIDI_OVERRIDE);
|
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
|
||||||
nsBidiLevel baseDirection =
|
NSBIDI_RTL : NSBIDI_LTR;
|
||||||
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
|
nsBidiPresUtils::CopyLogicalToVisual(text, visualText,
|
||||||
NSBIDI_RTL : NSBIDI_LTR;
|
baseDirection, bidiOverride);
|
||||||
bidiUtils->CopyLogicalToVisual(text, visualText,
|
if (!visualText.IsEmpty()) {
|
||||||
baseDirection, bidiOverride);
|
text = visualText;
|
||||||
if (!visualText.IsEmpty()) {
|
|
||||||
text = visualText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxMatrix m;
|
gfxMatrix m;
|
||||||
|
|||||||
@@ -533,32 +533,28 @@ nsTextBoxFrame::DrawText(nsIRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
if (mState & NS_FRAME_IS_BIDI) {
|
if (mState & NS_FRAME_IS_BIDI) {
|
||||||
presContext->SetBidiEnabled();
|
presContext->SetBidiEnabled();
|
||||||
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
||||||
|
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
|
||||||
if (bidiUtils) {
|
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
|
||||||
const nsStyleVisibility* vis = GetStyleVisibility();
|
// We let the RenderText function calculate the mnemonic's
|
||||||
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
|
// underline position for us.
|
||||||
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
|
nsBidiPositionResolve posResolve;
|
||||||
// We let the RenderText function calculate the mnemonic's
|
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
|
||||||
// underline position for us.
|
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
|
||||||
nsBidiPositionResolve posResolve;
|
presContext, aRenderingContext,
|
||||||
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
|
*refContext,
|
||||||
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
|
aTextRect.x, baseline,
|
||||||
presContext, aRenderingContext,
|
&posResolve,
|
||||||
*refContext,
|
1);
|
||||||
aTextRect.x, baseline,
|
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
|
||||||
&posResolve,
|
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
|
||||||
1);
|
}
|
||||||
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
|
else
|
||||||
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
|
{
|
||||||
}
|
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
|
||||||
else
|
presContext, aRenderingContext,
|
||||||
{
|
*refContext,
|
||||||
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
|
aTextRect.x, baseline);
|
||||||
presContext, aRenderingContext,
|
|
||||||
*refContext,
|
|
||||||
aTextRect.x, baseline);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv) )
|
if (NS_FAILED(rv) )
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
#include "nsTreeBoxObject.h"
|
#include "nsTreeBoxObject.h"
|
||||||
|
|
||||||
#ifdef IBMBIDI
|
#ifdef IBMBIDI
|
||||||
#include "nsBidiPresUtils.h"
|
#include "nsBidiUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enumeration function that cancels all the image requests in our cache
|
// Enumeration function that cancels all the image requests in our cache
|
||||||
|
|||||||
Reference in New Issue
Block a user