зеркало из https://github.com/mozilla/gecko-dev.git
Bug 370589. Put the prescontext into bidi mode when XUL trees detect a bidi string. r=smontagu,sr=dbaron
This commit is contained in:
Родитель
5ea42c0e18
Коммит
52e27c8271
|
@ -1172,6 +1172,9 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
|
|||
// Cell Text
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, currCol, cellText);
|
||||
// We're going to measure this text so we need to ensure bidi is enabled if
|
||||
// necessary
|
||||
CheckTextForBidi(cellText);
|
||||
|
||||
// Create a scratch rect to represent the text rectangle, with the current
|
||||
// X and Y coords, and a guess at the width and height. The width is the
|
||||
|
@ -1241,6 +1244,32 @@ nsTreeBodyFrame::GetRowAt(PRInt32 aX, PRInt32 aY)
|
|||
return row;
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::CheckTextForBidi(nsAutoString& aText)
|
||||
{
|
||||
// We could check to see whether the prescontext already has bidi enabled,
|
||||
// but usually it won't, so it's probably faster to avoid the call to
|
||||
// GetPresContext() when it's not needed.
|
||||
const PRUnichar* text = aText.get();
|
||||
PRUint32 length = aText.Length();
|
||||
PRUint32 i;
|
||||
PRBool maybeRTL = PR_FALSE;
|
||||
for (i = 0; i < length; ++i) {
|
||||
PRUnichar ch = text[i];
|
||||
// To simplify things, anything that could be a surrogate or RTL
|
||||
// presentation form is covered just by testing >= 0xD800). It's fine to
|
||||
// enable bidi in rare cases where it actually isn't needed.
|
||||
if (ch >= 0xD800 || IS_IN_BMP_RTL_BLOCK(ch)) {
|
||||
maybeRTL = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!maybeRTL)
|
||||
return;
|
||||
|
||||
GetPresContext()->SetBidiEnabled(PR_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
|
||||
PRInt32 aRowIndex, nsTreeColumn* aColumn,
|
||||
|
@ -1271,6 +1300,8 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
|
|||
if (nextColumn) {
|
||||
nsAutoString nextText;
|
||||
mView->GetCellText(aRowIndex, nextColumn, nextText);
|
||||
// We don't measure or draw this text so no need to check it for
|
||||
// bidi-ness
|
||||
|
||||
if (nextText.Length() == 0) {
|
||||
nscoord width;
|
||||
|
@ -1508,6 +1539,9 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
|||
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRowIndex, aColumn, cellText);
|
||||
// We're going to measure this text so we need to ensure bidi is enabled if
|
||||
// necessary
|
||||
CheckTextForBidi(cellText);
|
||||
|
||||
nsRect textRect(currX, cellRect.y, remainingWidth, cellRect.height);
|
||||
|
||||
|
@ -1645,6 +1679,9 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, nsTreeColumn* aCol,
|
|||
// Get the cell text.
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, aCol, cellText);
|
||||
// We're going to measure this text so we need to ensure bidi is enabled if
|
||||
// necessary
|
||||
CheckTextForBidi(cellText);
|
||||
|
||||
nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext);
|
||||
|
||||
|
@ -3337,6 +3374,9 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex,
|
|||
// Now obtain the text for our cell.
|
||||
nsAutoString text;
|
||||
mView->GetCellText(aRowIndex, aColumn, text);
|
||||
// We're going to paint this text so we need to ensure bidi is enabled if
|
||||
// necessary
|
||||
CheckTextForBidi(text);
|
||||
|
||||
if (text.Length() == 0)
|
||||
return; // Don't paint an empty string. XXX What about background/borders? Still paint?
|
||||
|
|
|
@ -232,6 +232,10 @@ protected:
|
|||
// coordinate system of this frame.
|
||||
PRInt32 GetRowAt(nscoord aX, nscoord aY);
|
||||
|
||||
// Check for bidi characters in the text, and if there are any, ensure
|
||||
// that the prescontext is in bidi mode.
|
||||
void CheckTextForBidi(nsAutoString& aText);
|
||||
|
||||
void AdjustForCellText(nsAutoString& aText,
|
||||
PRInt32 aRowIndex, nsTreeColumn* aColumn,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
|
|
Загрузка…
Ссылка в новой задаче