diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index fdb60e02151..e6b577c67bf 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -52,9 +52,6 @@ #include "nsIURL.h" #include "nsNetUtil.h" #include "prprf.h" -#ifdef IBMBIDI -#include "nsBidiPresUtils.h" -#endif // IBMBIDI #include "nsDisplayList.h" #include "imgILoader.h" @@ -242,13 +239,7 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt, nsCOMPtr fm; aRenderingContext.SetColor(myColor->mColor); -#ifdef IBMBIDI - nsCharType charType = eCharType_LeftToRight; - PRUint8 level = 0; - PRBool isBidiSystem = PR_FALSE; - const nsStyleVisibility* vis = GetStyleVisibility(); - PRUint32 hints = 0; -#endif // IBMBIDI + mTextIsRTL = PR_FALSE; nsAutoString text; switch (listStyleType) { @@ -277,38 +268,6 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt, case NS_STYLE_LIST_STYLE_DECIMAL: case NS_STYLE_LIST_STYLE_OLD_DECIMAL: case NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO: -#ifdef IBMBIDI - GetListItemText(*myList, text); - charType = eCharType_EuropeanNumber; - break; - - case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC: - if (GetListItemText(*myList, text)) - charType = eCharType_ArabicNumber; - else - charType = eCharType_EuropeanNumber; - break; - - case NS_STYLE_LIST_STYLE_HEBREW: - aRenderingContext.GetHints(hints); - isBidiSystem = !!(hints & NS_RENDERING_HINT_BIDI_REORDERING); - if (!isBidiSystem) { - if (GetListItemText(*myList, text)) { - charType = eCharType_RightToLeft; - level = 1; - } else { - charType = eCharType_EuropeanNumber; - } - - if (NS_STYLE_DIRECTION_RTL == vis->mDirection) { - text.Cut(0, 1); - text.AppendLiteral("."); - } - break; - } - // else fall through -#endif // IBMBIDI - case NS_STYLE_LIST_STYLE_LOWER_ROMAN: case NS_STYLE_LIST_STYLE_UPPER_ROMAN: case NS_STYLE_LIST_STYLE_LOWER_ALPHA: @@ -318,9 +277,7 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt, case NS_STYLE_LIST_STYLE_OLD_LOWER_ALPHA: case NS_STYLE_LIST_STYLE_OLD_UPPER_ALPHA: case NS_STYLE_LIST_STYLE_LOWER_GREEK: -#ifndef IBMBIDI case NS_STYLE_LIST_STYLE_HEBREW: -#endif case NS_STYLE_LIST_STYLE_ARMENIAN: case NS_STYLE_LIST_STYLE_GEORGIAN: case NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC: @@ -336,9 +293,7 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt, case NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL: case NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM: case NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH: -#ifndef IBMBIDI case NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC: -#endif case NS_STYLE_LIST_STYLE_MOZ_PERSIAN: case NS_STYLE_LIST_STYLE_MOZ_URDU: case NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI: @@ -362,57 +317,15 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt, case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER: case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET: nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); -#ifdef IBMBIDI - // If we can't render our numeral using the chars in the numbering - // system, we'll be using "decimal"... - PRBool usedChars = -#endif // IBMBIDI GetListItemText(*myList, text); -#ifdef IBMBIDI - if (!usedChars) - charType = eCharType_EuropeanNumber; -#endif aRenderingContext.SetFont(fm); nscoord ascent; fm->GetMaxAscent(ascent); - aRenderingContext.SetTextRunRTL(PR_FALSE); + aRenderingContext.SetTextRunRTL(mTextIsRTL); aRenderingContext.DrawString(text, mPadding.left + aPt.x, mPadding.top + aPt.y + ascent); break; } -#ifdef IBMBIDI - if (charType != eCharType_LeftToRight) { - nsPresContext* presContext = PresContext(); - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); - aRenderingContext.SetFont(fm); - nscoord ascent; - fm->GetMaxAscent(ascent); - - nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils(); - if (bidiUtils) { - const PRUnichar* buffer = text.get(); - PRInt32 textLength = text.Length(); - PRUint32 hints = 0; - aRenderingContext.GetHints(hints); - PRBool isNewTextRunSystem = (hints & NS_RENDERING_HINT_NEW_TEXT_RUNS) != 0; - if (eCharType_RightToLeft == charType) { - bidiUtils->FormatUnicodeText(presContext, (PRUnichar*)buffer, textLength, - charType, level, PR_FALSE, isNewTextRunSystem); - } - else { -//Mohamed - aRenderingContext.GetHints(hints); - isBidiSystem = !!(hints & NS_RENDERING_HINT_ARABIC_SHAPING); - bidiUtils->FormatUnicodeText(presContext, (PRUnichar*)buffer, textLength, - charType, level, isBidiSystem, isNewTextRunSystem);//Mohamed - } - } - // XXX is this right? - aRenderingContext.SetTextRunRTL(level); - aRenderingContext.DrawString(text, mPadding.left + aPt.x, - mPadding.top + aPt.y + ascent); - } -#endif // IBMBIDI } PRInt32 @@ -843,9 +756,7 @@ static const PRBool CJKIdeographicToText(PRInt32 ordinal, nsString& result, return PR_TRUE; } -#define HEBREW_THROSAND_SEP 0x0020 #define HEBREW_GERESH 0x05F3 -#define HEBREW_GERSHAYIM 0x05F4 static const PRUnichar gHebrewDigit[22] = { // 1 2 3 4 5 6 7 8 9 @@ -858,73 +769,22 @@ static const PRUnichar gHebrewDigit[22] = static PRBool HebrewToText(PRInt32 ordinal, nsString& result) { - if (ordinal < 0) { + if (ordinal < 1 || ordinal > 999999) { DecimalToText(ordinal, result); return PR_FALSE; } - if (ordinal == 0) { - // This one is treated specially -#ifdef IBMBIDI - static const PRUnichar hebrewZero[] = { 0x05D0, 0x05E4, 0x05E1 }; -#else - static const PRUnichar hebrewZero[] = { 0x05E1, 0x05E4, 0x05D0 }; -#endif // IBMBIDI - result.Append(hebrewZero); - return PR_TRUE; - } PRBool outputSep = PR_FALSE; - PRUnichar buf[NUM_BUF_SIZE]; -#ifdef IBMBIDI - // Changes: 1) don't reverse the text; 2) don't insert geresh/gershayim. - PRInt32 idx = 0; -#else - PRInt32 idx = NUM_BUF_SIZE; -#endif // IBMBIDI - PRUnichar digit; + nsAutoString allText, thousandsGroup; do { + thousandsGroup.Truncate(); PRInt32 n3 = ordinal % 1000; - if(outputSep) -#ifdef IBMBIDI - buf[idx++] = HEBREW_THROSAND_SEP; // output thousand separator -#else - buf[--idx] = HEBREW_THROSAND_SEP; // output thousand separator -#endif // IBMBIDI - outputSep = ( n3 > 0); // request to output thousand separator next time. - - PRInt32 d = 0; // we need to keep track of digit got output per 3 digits, - // so we can handle Gershayim and Gersh correctly - // Process digit for 100 - 900 for(PRInt32 n1 = 400; n1 > 0; ) { if( n3 >= n1) { n3 -= n1; - - digit = gHebrewDigit[(n1/100)-1+18]; - if( n3 > 0) - { -#ifdef IBMBIDI - buf[idx++] = digit; -#else - buf[--idx] = digit; -#endif // IBMBIDI - ++d; - } else { - // if this is the last digit -#ifdef IBMBIDI - buf[idx++] = digit; -#else - if (d > 0) - { - buf[--idx] = HEBREW_GERSHAYIM; - buf[--idx] = digit; - } else { - buf[--idx] = digit; - buf[--idx] = HEBREW_GERESH; - } // if -#endif // IBMBIDI - } // if + thousandsGroup.Append(gHebrewDigit[(n1/100)-1+18]); } else { n1 -= 100; } // if @@ -940,63 +800,28 @@ static PRBool HebrewToText(PRInt32 ordinal, nsString& result) // 15 is represented by 9 and 6, not 10 and 5 // 16 is represented by 9 and 7, not 10 and 6 n2 = 9; - digit = gHebrewDigit[ n2 - 1]; + thousandsGroup.Append(gHebrewDigit[ n2 - 1]); } else { n2 = n3 - (n3 % 10); - digit = gHebrewDigit[(n2/10)-1+9]; + thousandsGroup.Append(gHebrewDigit[(n2/10)-1+9]); } // if - n3 -= n2; - - if( n3 > 0) { -#ifdef IBMBIDI - buf[idx++] = digit; -#else - buf[--idx] = digit; -#endif // IBMBIDI - ++d; - } else { - // if this is the last digit -#ifdef IBMBIDI - buf[idx++] = digit; -#else - if (d > 0) - { - buf[--idx] = HEBREW_GERSHAYIM; - buf[--idx] = digit; - } else { - buf[--idx] = digit; - buf[--idx] = HEBREW_GERESH; - } // if -#endif // IBMBIDI - } // if } // if // Process digit for 1 - 9 if ( n3 > 0) - { - digit = gHebrewDigit[n3-1]; - // must be the last digit -#ifdef IBMBIDI - buf[idx++] = digit; -#else - if (d > 0) - { - buf[--idx] = HEBREW_GERSHAYIM; - buf[--idx] = digit; - } else { - buf[--idx] = digit; - buf[--idx] = HEBREW_GERESH; - } // if -#endif // IBMBIDI - } // if + thousandsGroup.Append(gHebrewDigit[n3-1]); + if (outputSep) + thousandsGroup.Append((PRUnichar)HEBREW_GERESH); + if (allText.IsEmpty()) + allText = thousandsGroup; + else + allText = thousandsGroup + allText; ordinal /= 1000; + outputSep = PR_TRUE; } while (ordinal >= 1); -#ifdef IBMBIDI - result.Append(buf, idx); -#else - result.Append(buf+idx,NUM_BUF_SIZE-idx); -#endif // IBMBIDI + + result.Append(allText); return PR_TRUE; } @@ -1384,16 +1209,8 @@ PRBool nsBulletFrame::GetListItemText(const nsStyleList& aListStyle, nsString& result) { -#ifdef IBMBIDI const nsStyleVisibility* vis = GetStyleVisibility(); - // XXX For some of these systems, "." is wrong! This should really be - // pushed down into the individual cases! - if (NS_STYLE_DIRECTION_RTL == vis->mDirection) { - result.AppendLiteral("."); - } -#endif // IBMBIDI - NS_ASSERTION(aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_NONE && aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_DISC && aListStyle.mListStyleType != NS_STYLE_LIST_STYLE_CIRCLE && @@ -1401,13 +1218,20 @@ nsBulletFrame::GetListItemText(const nsStyleList& aListStyle, "we should be using specialized code for these types"); PRBool success = AppendCounterText(aListStyle.mListStyleType, mOrdinal, result); + if (success && aListStyle.mListStyleType == NS_STYLE_LIST_STYLE_HEBREW) + mTextIsRTL = PR_TRUE; // XXX For some of these systems, "." is wrong! This should really be - // pushed up into the cases... -#ifdef IBMBIDI - if (NS_STYLE_DIRECTION_RTL != vis->mDirection) -#endif // IBMBIDI - result.AppendLiteral("."); + // pushed down into the individual cases! + nsString suffix = NS_LITERAL_STRING("."); + + // We're not going to do proper Bidi reordering on the list item marker, but + // just display the whole thing as RTL or LTR, so we fake reordering by + // appending the suffix to the end of the list item marker if the + // directionality of the characters is the same as the style direction or + // prepending it to the beginning if they are different. + result = (mTextIsRTL == (vis->mDirection == NS_STYLE_DIRECTION_RTL)) ? + result + suffix : suffix + result; return success; } diff --git a/layout/generic/nsBulletFrame.h b/layout/generic/nsBulletFrame.h index 947a8f89ff6..19f4dce1b8f 100644 --- a/layout/generic/nsBulletFrame.h +++ b/layout/generic/nsBulletFrame.h @@ -116,6 +116,7 @@ protected: nsSize mIntrinsicSize; nsSize mComputedSize; + PRBool mTextIsRTL; }; #endif /* nsBulletFrame_h___ */ diff --git a/layout/reftests/bidi/413928-1-ref.html b/layout/reftests/bidi/413928-1-ref.html new file mode 100644 index 00000000000..a814fcd16d8 --- /dev/null +++ b/layout/reftests/bidi/413928-1-ref.html @@ -0,0 +1,58 @@ + + + + + Bug 413928 + + + +
-3.
+
-2.
+
-1.
+
0.
+
+
+
+
+
+
.יד
+
.טו
+
.טז
+
.יז
+
.צז
+
.צח
+
.צט
+
+
.קא
+
.תתקמד
+
.תתקמה
+
.תתקמו
+
.תתקצט
+
.א׳
+
.א׳א
+
.א׳תתקצח
+
.א׳תתקצט
+
.ב׳
+
.ב׳א
+
.ב׳ג
+
.ב׳תשמח
+
.ב׳תשנ
+
1000000.
+
1500000.
+
2000000.
+
9999999.
+
10000212.
+
10000425.
+
10000851.
+
10001064.
+
10001277.
+ + \ No newline at end of file diff --git a/layout/reftests/bidi/413928-1.html b/layout/reftests/bidi/413928-1.html new file mode 100644 index 00000000000..e615659cb45 --- /dev/null +++ b/layout/reftests/bidi/413928-1.html @@ -0,0 +1,63 @@ + + + + + Bug 413928 + + + +
    +
  1. +
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
  10. +
  11. +
  12. +
  13. +
  14. +
  15. +
  16. +
  17. +
  18. +
  19. +
  20. +
  21. +
  22. +
  23. +
  24. +
  25. +
  26. +
  27. +
  28. +
  29. +
  30. +
  31. +
  32. +
  33. +
  34. +
  35. +
  36. +
  37. +
  38. +
  39. +
  40. +
+ + \ No newline at end of file diff --git a/layout/reftests/bidi/413928-2-ref.html b/layout/reftests/bidi/413928-2-ref.html new file mode 100644 index 00000000000..41efd95a17a --- /dev/null +++ b/layout/reftests/bidi/413928-2-ref.html @@ -0,0 +1,58 @@ + + + + + Bug 413928 + + + +
‎-3.
+
‎-2.
+
‎-1.
+
0.
+
א.
+
ב.
+
ג.
+
ד.
+
ה.
+
יד.
+
טו.
+
טז.
+
יז.
+
צז.
+
צח.
+
צט.
+
ק.
+
קא.
+
תתקמד.
+
תתקמה.
+
תתקמו.
+
תתקצט.
+
א׳.
+
א׳א.
+
א׳תתקצח.
+
א׳תתקצט.
+
ב׳.
+
ב׳א.
+
ב׳ג.
+
ב׳תשמח.
+
ב׳תשנ.
+
1000000.
+
1500000.
+
2000000.
+
9999999.
+
10000212.
+
10000425.
+
10000851.
+
10001064.
+
10001277.
+ + \ No newline at end of file diff --git a/layout/reftests/bidi/413928-2.html b/layout/reftests/bidi/413928-2.html new file mode 100644 index 00000000000..3b09bb9f74c --- /dev/null +++ b/layout/reftests/bidi/413928-2.html @@ -0,0 +1,63 @@ + + + + + Bug 413928 + + + +
    +
  1. +
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
  10. +
  11. +
  12. +
  13. +
  14. +
  15. +
  16. +
  17. +
  18. +
  19. +
  20. +
  21. +
  22. +
  23. +
  24. +
  25. +
  26. +
  27. +
  28. +
  29. +
  30. +
  31. +
  32. +
  33. +
  34. +
  35. +
  36. +
  37. +
  38. +
  39. +
  40. +
+ + \ No newline at end of file diff --git a/layout/reftests/bidi/reftest.list b/layout/reftests/bidi/reftest.list index 59217788bc1..51dd4b3ed0f 100644 --- a/layout/reftests/bidi/reftest.list +++ b/layout/reftests/bidi/reftest.list @@ -21,3 +21,5 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == mixedChartype-03-j.html mixedChartype-0 == 409375.html 409375-ref.html == 413542-1.html 413542-1-ref.html == 413542-2.html 413542-2-ref.html +== 413928-1.html 413928-1-ref.html +== 413928-2.html 413928-2-ref.html diff --git a/layout/reftests/counters/counter-hebrew-reference.html b/layout/reftests/counters/counter-hebrew-reference.html new file mode 100644 index 00000000000..0d08f6d49b9 --- /dev/null +++ b/layout/reftests/counters/counter-hebrew-reference.html @@ -0,0 +1,62 @@ + + + + CSS 2.1 Test Suite: content: counter() error cases + + + + + + + +
+ א + ב + ג + ד + ה + ו + ז + ח + ט + י + יא + יב + יג + יד + טו + טז + יז + כ + ל + מ + נ + ס + ע + פ + צ + ק + ר + ש + ת + תק + תר + תש + תת + תתק + א׳ + ב׳ + ג׳ + ד׳ + ה׳ + ו׳ + ז׳ + ח׳ + ט׳ + ט׳תתקצט + תתקצט׳תתקצט + 1000000 +
+ + + diff --git a/layout/reftests/counters/counter-hebrew-test.html b/layout/reftests/counters/counter-hebrew-test.html new file mode 100644 index 00000000000..8c636342d16 --- /dev/null +++ b/layout/reftests/counters/counter-hebrew-test.html @@ -0,0 +1,68 @@ + + + + CSS 2.1 Test Suite: content: counter() error cases + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/layout/reftests/counters/counters-hebrew-reference.html b/layout/reftests/counters/counters-hebrew-reference.html new file mode 100644 index 00000000000..9ae6b5e011d --- /dev/null +++ b/layout/reftests/counters/counters-hebrew-reference.html @@ -0,0 +1,63 @@ + + + + CSS 2.1 Test Suite: content: counters(c, ".", hebrew) + + + + + + + +

+
+ א.א + א.ב + א.ג + א.ד + א.ה + א.ו + א.ז + א.ח + א.ט + א.י + א.יא + א.יב + א.יג + א.יד + א.טו + א.טז + א.יז + א.כ + א.ל + א.מ + א.נ + א.ס + א.ע + א.פ + א.צ + א.ק + א.ר + א.ש + א.ת + א.תק + א.תר + א.תש + א.תת + א.תתק + א.א׳ + א.ב׳ + א.ג׳ + א.ד׳ + א.ה׳ + א.ו׳ + א.ז׳ + א.ח׳ + א.ט׳ + א.ט׳תתקצט + א.תתקצט׳תתקצט + א.1000000 +
+ + + diff --git a/layout/reftests/counters/counters-hebrew-test.html b/layout/reftests/counters/counters-hebrew-test.html new file mode 100644 index 00000000000..ca18ae5ffbb --- /dev/null +++ b/layout/reftests/counters/counters-hebrew-test.html @@ -0,0 +1,72 @@ + + + + CSS 2.1 Test Suite: content: counters(c, ".", hebrew) + + + + + + + + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/layout/reftests/counters/reftest.list b/layout/reftests/counters/reftest.list index ac7228c8df8..16f14715f79 100644 --- a/layout/reftests/counters/reftest.list +++ b/layout/reftests/counters/reftest.list @@ -58,3 +58,5 @@ fails == t1202-counters-10-b-test.html t1202-counters-10-b-reference.html # need == t120403-display-none-00-c-test.html t120403-display-none-00-c-reference.html == t120403-visibility-00-c-test.html t120403-visibility-00-c-reference.html == text-boundaries-subpixel.html text-boundaries-subpixel-ref.html +== counter-hebrew-test.html counter-hebrew-reference.html +== counters-hebrew-test.html counters-hebrew-reference.html