зеркало из https://github.com/mozilla/gecko-dev.git
Enable bidi processing if there are right-to-left characters in print headers or footers. Bug 421690, r+sr=roc, blocking1.9=damon
This commit is contained in:
Родитель
85e49a64d5
Коммит
d1d47d9bdb
|
@ -42,6 +42,7 @@
|
|||
#include "nsBidiUtils.h"
|
||||
#include "symmtable.h"
|
||||
#include "bidicattable.h"
|
||||
#include "nsCharTraits.h"
|
||||
|
||||
#define FE_TO_06_OFFSET 0xfe70
|
||||
|
||||
|
@ -613,6 +614,22 @@ PRBool IsBidiControl(PRUint32 aChar)
|
|||
return (eBidiCat_CC == GetBidiCat(aChar) || ((aChar)&0xfffffe)==LRM_CHAR);
|
||||
}
|
||||
|
||||
PRBool HasRTLChars(nsAString& aString)
|
||||
{
|
||||
PRInt32 length = aString.Length();
|
||||
for (PRInt32 i = 0; i < length; i++) {
|
||||
if ((UCS2_CHAR_IS_BIDI(aString.CharAt(i)) ) ||
|
||||
((NS_IS_HIGH_SURROGATE(aString.CharAt(i))) &&
|
||||
(++i < length) &&
|
||||
(NS_IS_LOW_SURROGATE(aString.CharAt(i))) &&
|
||||
(UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(aString.CharAt(i-1),
|
||||
aString.CharAt(i)))))) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCharType GetCharType(PRUint32 aChar)
|
||||
{
|
||||
nsCharType oResult;
|
||||
|
|
|
@ -203,6 +203,12 @@ typedef enum nsCharType nsCharType;
|
|||
*/
|
||||
PRBool IsBidiControl(PRUint32 aChar);
|
||||
|
||||
/**
|
||||
* Give an nsString.
|
||||
* @return PR_TRUE if the string contains right-to-left characters
|
||||
*/
|
||||
PRBool HasRTLChars(nsAString& aString);
|
||||
|
||||
// --------------------------------------------------
|
||||
// IBMBIDI
|
||||
// --------------------------------------------------
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "nsTextFormatter.h" // for page number localization formatting
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiUtils.h"
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
|
@ -369,6 +368,8 @@ nsPageFrame::DrawHeaderFooter(nsIRenderingContext& aRenderingContext,
|
|||
} else {
|
||||
return; // bail if couldn't find the correct length
|
||||
}
|
||||
|
||||
PresContext()->SetBidiEnabled(HasRTLChars(str));
|
||||
|
||||
// cacl the x and y positions of the text
|
||||
nscoord x = GetXPosition(aRenderingContext, aRect, aJust, str);
|
||||
|
|
|
@ -609,17 +609,8 @@ nsTextBoxFrame::CalculateTitleForWidth(nsPresContext* aPresContext,
|
|||
if (mTitleWidth <= aWidth) {
|
||||
mCroppedTitle = mTitle;
|
||||
#ifdef IBMBIDI
|
||||
PRInt32 length = mTitle.Length();
|
||||
for (PRInt32 i = 0; i < length; i++) {
|
||||
if ((UCS2_CHAR_IS_BIDI(mTitle.CharAt(i)) ) ||
|
||||
((NS_IS_HIGH_SURROGATE(mTitle.CharAt(i))) &&
|
||||
(++i < length) &&
|
||||
(NS_IS_LOW_SURROGATE(mTitle.CharAt(i))) &&
|
||||
(UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(mTitle.CharAt(i-1),
|
||||
mTitle.CharAt(i)))))) {
|
||||
if (HasRTLChars(mTitle)) {
|
||||
mState |= NS_FRAME_IS_BIDI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
return; // fits, done.
|
||||
|
|
Загрузка…
Ссылка в новой задаче