| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) | 6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10F1, 0x10
D7 | 311 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10F1, 0x10
D7 |
| 312 }; | 312 }; |
| 313 letters[length++] = georgianOnes[ones - 1]; | 313 letters[length++] = georgianOnes[ones - 1]; |
| 314 } | 314 } |
| 315 | 315 |
| 316 ASSERT(length <= lettersSize); | 316 ASSERT(length <= lettersSize); |
| 317 return String(letters, length); | 317 return String(letters, length); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // The table uses the order from the CSS3 specification: | 320 // The table uses the order from the CSS3 specification: |
| 321 // first 3 group markers, then 3 digit markers, then ten digits. | 321 // first 3 group markers, then 3 digit markers, then ten digits, then negative s
ymbols. |
| 322 static String toCJKIdeographic(int number, const UChar table[16]) | 322 static String toCJKIdeographic(int number, const UChar table[23]) |
| 323 { | 323 { |
| 324 ASSERT(number >= 0); | |
| 325 | |
| 326 enum AbstractCJKChar { | 324 enum AbstractCJKChar { |
| 327 NoChar, | 325 NoChar = 0, |
| 326 Lang = 0, |
| 328 SecondGroupMarker, ThirdGroupMarker, FourthGroupMarker, | 327 SecondGroupMarker, ThirdGroupMarker, FourthGroupMarker, |
| 329 SecondDigitMarker, ThirdDigitMarker, FourthDigitMarker, | 328 SecondDigitMarker, ThirdDigitMarker, FourthDigitMarker, |
| 330 Digit0, Digit1, Digit2, Digit3, Digit4, | 329 Digit0, Digit1, Digit2, Digit3, Digit4, |
| 331 Digit5, Digit6, Digit7, Digit8, Digit9 | 330 Digit5, Digit6, Digit7, Digit8, Digit9, |
| 331 Neg1, Neg2, Neg3, Neg4, Neg5 |
| 332 }; |
| 333 |
| 334 enum CJKLang { |
| 335 Chinese = 1, |
| 336 Korean, |
| 337 Japanese |
| 332 }; | 338 }; |
| 333 | 339 |
| 334 if (number == 0) | 340 if (number == 0) |
| 335 return String(&table[Digit0 - 1], 1); | 341 return String(&table[Digit0], 1); |
| 342 |
| 343 const bool negative = number < 0; |
| 344 if (negative) |
| 345 number = -number; |
| 336 | 346 |
| 337 const int groupLength = 8; // 4 digits, 3 digit markers, and a group marker | 347 const int groupLength = 8; // 4 digits, 3 digit markers, and a group marker |
| 338 const int bufferLength = 4 * groupLength; | 348 const int bufferLength = 4 * groupLength; |
| 339 AbstractCJKChar buffer[bufferLength] = { NoChar }; | 349 AbstractCJKChar buffer[bufferLength] = { NoChar }; |
| 340 | 350 |
| 341 for (int i = 0; i < 4; ++i) { | 351 for (int i = 0; i < 4; ++i) { |
| 342 int groupValue = number % 10000; | 352 int groupValue = number % 10000; |
| 343 number /= 10000; | 353 number /= 10000; |
| 344 | 354 |
| 345 // Process least-significant group first, but put it in the buffer last. | 355 // Process least-significant group first, but put it in the buffer last. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 364 } | 374 } |
| 365 if (number != 0 || groupValue > 999) { | 375 if (number != 0 || groupValue > 999) { |
| 366 int digitValue = groupValue / 1000; | 376 int digitValue = groupValue / 1000; |
| 367 group[0] = static_cast<AbstractCJKChar>(Digit0 + digitValue); | 377 group[0] = static_cast<AbstractCJKChar>(Digit0 + digitValue); |
| 368 if (digitValue) | 378 if (digitValue) |
| 369 group[1] = FourthDigitMarker; | 379 group[1] = FourthDigitMarker; |
| 370 } | 380 } |
| 371 | 381 |
| 372 // Remove the tens digit, but leave the marker, for any group that has | 382 // Remove the tens digit, but leave the marker, for any group that has |
| 373 // a value of less than 20. | 383 // a value of less than 20. |
| 374 if (groupValue < 20) { | 384 if (table[Lang] == Chinese && groupValue < 20) { |
| 375 ASSERT(group[4] == NoChar || group[4] == Digit0 || group[4] == Digit
1); | 385 ASSERT(group[4] == NoChar || group[4] == Digit0 || group[4] == Digit
1); |
| 376 group[4] = NoChar; | 386 group[4] = NoChar; |
| 377 } | 387 } |
| 378 | 388 |
| 379 if (number == 0) | 389 if (number == 0) |
| 380 break; | 390 break; |
| 381 } | 391 } |
| 382 | 392 |
| 383 // Convert into characters, omitting consecutive runs of Digit0 and | 393 // Convert into characters, omitting consecutive runs of Digit0 and |
| 384 // any trailing Digit0. | 394 // any trailing Digit0. |
| 385 int length = 0; | 395 int length = 0; |
| 386 UChar characters[bufferLength]; | 396 const int maxLengthForNegativeSymbols = 5; |
| 397 UChar characters[bufferLength + maxLengthForNegativeSymbols]; |
| 387 AbstractCJKChar last = NoChar; | 398 AbstractCJKChar last = NoChar; |
| 399 if (negative) { |
| 400 while (UChar a = table[Neg1 + length]) |
| 401 characters[length++] = a; |
| 402 } |
| 388 for (int i = 0; i < bufferLength; ++i) { | 403 for (int i = 0; i < bufferLength; ++i) { |
| 389 AbstractCJKChar a = buffer[i]; | 404 AbstractCJKChar a = buffer[i]; |
| 390 if (a != NoChar) { | 405 if (a != NoChar) { |
| 391 if (a != Digit0 || last != Digit0) | 406 if (a != Digit0 || (table[Lang] == Chinese && last != Digit0)) { |
| 392 characters[length++] = table[a - 1]; | 407 characters[length++] = table[a]; |
| 408 if (table[Lang] == Korean && a >= SecondGroupMarker && a <= Four
thGroupMarker) |
| 409 characters[length++] = ' '; |
| 410 } |
| 393 last = a; | 411 last = a; |
| 394 } | 412 } |
| 395 } | 413 } |
| 396 if (last == Digit0) | 414 if ((table[Lang] == Chinese && last == Digit0) || characters[length - 1] ==
' ') |
| 397 --length; | 415 --length; |
| 398 | 416 |
| 399 return String(characters, length); | 417 return String(characters, length); |
| 400 } | 418 } |
| 401 | 419 |
| 402 static EListStyleType effectiveListMarkerType(EListStyleType type, int value) | 420 static EListStyleType effectiveListMarkerType(EListStyleType type, int value) |
| 403 { | 421 { |
| 404 // Note, the following switch statement has been explicitly grouped | 422 // Note, the following switch statement has been explicitly grouped |
| 405 // by list-style-type ordinal range. | 423 // by list-style-type ordinal range. |
| 406 switch (type) { | 424 switch (type) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 421 case Mongolian: | 439 case Mongolian: |
| 422 case Myanmar: | 440 case Myanmar: |
| 423 case NoneListStyle: | 441 case NoneListStyle: |
| 424 case Oriya: | 442 case Oriya: |
| 425 case Persian: | 443 case Persian: |
| 426 case Square: | 444 case Square: |
| 427 case Telugu: | 445 case Telugu: |
| 428 case Thai: | 446 case Thai: |
| 429 case Tibetan: | 447 case Tibetan: |
| 430 case Urdu: | 448 case Urdu: |
| 449 case KoreanHangulFormal: |
| 431 return type; // Can represent all ordinals. | 450 return type; // Can represent all ordinals. |
| 432 case Armenian: | 451 case Armenian: |
| 433 return (value < 1 || value > 99999999) ? DecimalListStyle : type; | 452 return (value < 1 || value > 99999999) ? DecimalListStyle : type; |
| 434 case CJKIdeographic: | 453 case CJKIdeographic: |
| 435 return (value < 0) ? DecimalListStyle : type; | 454 return (value < 0) ? DecimalListStyle : type; |
| 436 case Georgian: | 455 case Georgian: |
| 437 return (value < 1 || value > 19999) ? DecimalListStyle : type; | 456 return (value < 1 || value > 19999) ? DecimalListStyle : type; |
| 438 case Hebrew: | 457 case Hebrew: |
| 439 return (value < 0 || value > 999999) ? DecimalListStyle : type; | 458 return (value < 0 || value > 999999) ? DecimalListStyle : type; |
| 440 case LowerRoman: | 459 case LowerRoman: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 case Persian: | 539 case Persian: |
| 521 case Telugu: | 540 case Telugu: |
| 522 case Thai: | 541 case Thai: |
| 523 case Tibetan: | 542 case Tibetan: |
| 524 case UpperAlpha: | 543 case UpperAlpha: |
| 525 case UpperArmenian: | 544 case UpperArmenian: |
| 526 case UpperLatin: | 545 case UpperLatin: |
| 527 case UpperRoman: | 546 case UpperRoman: |
| 528 case Urdu: | 547 case Urdu: |
| 529 return '.'; | 548 return '.'; |
| 549 case KoreanHangulFormal: |
| 550 return ','; |
| 530 } | 551 } |
| 531 | 552 |
| 532 ASSERT_NOT_REACHED(); | 553 ASSERT_NOT_REACHED(); |
| 533 return '.'; | 554 return '.'; |
| 534 } | 555 } |
| 535 | 556 |
| 536 String listMarkerText(EListStyleType type, int value) | 557 String listMarkerText(EListStyleType type, int value) |
| 537 { | 558 { |
| 538 // If the list-style-type, say hebrew, cannot represent |value| because it's
outside | 559 // If the list-style-type, say hebrew, cannot represent |value| because it's
outside |
| 539 // its ordinal range then we fallback to some list style that can represent
|value|. | 560 // its ordinal range then we fallback to some list style that can represent
|value|. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 } | 815 } |
| 795 case EthiopicHalehameTiEt: { | 816 case EthiopicHalehameTiEt: { |
| 796 static const UChar ethiopicHalehameTiEtAlphabet[34] = { | 817 static const UChar ethiopicHalehameTiEtAlphabet[34] = { |
| 797 0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228, 0x1230, 0x1238, 0x12
40, | 818 0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228, 0x1230, 0x1238, 0x12
40, |
| 798 0x1250, 0x1260, 0x1270, 0x1278, 0x1280, 0x1290, 0x1298, 0x12A0, 0x12
A8, | 819 0x1250, 0x1260, 0x1270, 0x1278, 0x1280, 0x1290, 0x1298, 0x12A0, 0x12
A8, |
| 799 0x12B8, 0x12C8, 0x12D0, 0x12D8, 0x12E0, 0x12E8, 0x12F0, 0x1300, 0x13
08, | 820 0x12B8, 0x12C8, 0x12D0, 0x12D8, 0x12E0, 0x12E8, 0x12F0, 0x1300, 0x13
08, |
| 800 0x1320, 0x1328, 0x1330, 0x1338, 0x1340, 0x1348, 0x1350 | 821 0x1320, 0x1328, 0x1330, 0x1338, 0x1340, 0x1348, 0x1350 |
| 801 }; | 822 }; |
| 802 return toAlphabetic(value, ethiopicHalehameTiEtAlphabet); | 823 return toAlphabetic(value, ethiopicHalehameTiEtAlphabet); |
| 803 } | 824 } |
| 825 case KoreanHangulFormal: { |
| 826 static const UChar koreanHangulFormalTable[23] = { |
| 827 0x2, |
| 828 0xB9CC, 0xC5B5, 0xC870, |
| 829 0xC2ED, 0xBC31, 0xCC9C, |
| 830 0xC601, 0xC77C, 0xC774, 0xC0BC, 0xC0AC, |
| 831 0xC624, 0xC721, 0xCE60, 0xD314, 0xAD6C, |
| 832 0xB9C8, 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000 |
| 833 }; |
| 834 return toCJKIdeographic(value, koreanHangulFormalTable); |
| 835 } |
| 804 case CJKIdeographic: { | 836 case CJKIdeographic: { |
| 805 static const UChar traditionalChineseInformalTable[16] = { | 837 static const UChar traditionalChineseInformalTable[19] = { |
| 838 0x1, |
| 806 0x842C, 0x5104, 0x5146, | 839 0x842C, 0x5104, 0x5146, |
| 807 0x5341, 0x767E, 0x5343, | 840 0x5341, 0x767E, 0x5343, |
| 808 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, | 841 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, |
| 809 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D | 842 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, |
| 843 0x8CA0, 0x0000 |
| 810 }; | 844 }; |
| 811 return toCJKIdeographic(value, traditionalChineseInformalTable); | 845 return toCJKIdeographic(value, traditionalChineseInformalTable); |
| 812 } | 846 } |
| 813 | 847 |
| 814 case LowerRoman: | 848 case LowerRoman: |
| 815 return toRoman(value, false); | 849 return toRoman(value, false); |
| 816 case UpperRoman: | 850 case UpperRoman: |
| 817 return toRoman(value, true); | 851 return toRoman(value, true); |
| 818 | 852 |
| 819 case Armenian: | 853 case Armenian: |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 case Devanagari: | 1031 case Devanagari: |
| 998 case EthiopicHalehame: | 1032 case EthiopicHalehame: |
| 999 case EthiopicHalehameAm: | 1033 case EthiopicHalehameAm: |
| 1000 case EthiopicHalehameTiEr: | 1034 case EthiopicHalehameTiEr: |
| 1001 case EthiopicHalehameTiEt: | 1035 case EthiopicHalehameTiEt: |
| 1002 case Georgian: | 1036 case Georgian: |
| 1003 case Gujarati: | 1037 case Gujarati: |
| 1004 case Gurmukhi: | 1038 case Gurmukhi: |
| 1005 case Hangul: | 1039 case Hangul: |
| 1006 case HangulConsonant: | 1040 case HangulConsonant: |
| 1041 case KoreanHangulFormal: |
| 1007 case Hebrew: | 1042 case Hebrew: |
| 1008 case Hiragana: | 1043 case Hiragana: |
| 1009 case HiraganaIroha: | 1044 case HiraganaIroha: |
| 1010 case Kannada: | 1045 case Kannada: |
| 1011 case Katakana: | 1046 case Katakana: |
| 1012 case KatakanaIroha: | 1047 case KatakanaIroha: |
| 1013 case Khmer: | 1048 case Khmer: |
| 1014 case Lao: | 1049 case Lao: |
| 1015 case LowerAlpha: | 1050 case LowerAlpha: |
| 1016 case LowerArmenian: | 1051 case LowerArmenian: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 case Devanagari: | 1107 case Devanagari: |
| 1073 case EthiopicHalehame: | 1108 case EthiopicHalehame: |
| 1074 case EthiopicHalehameAm: | 1109 case EthiopicHalehameAm: |
| 1075 case EthiopicHalehameTiEr: | 1110 case EthiopicHalehameTiEr: |
| 1076 case EthiopicHalehameTiEt: | 1111 case EthiopicHalehameTiEt: |
| 1077 case Georgian: | 1112 case Georgian: |
| 1078 case Gujarati: | 1113 case Gujarati: |
| 1079 case Gurmukhi: | 1114 case Gurmukhi: |
| 1080 case Hangul: | 1115 case Hangul: |
| 1081 case HangulConsonant: | 1116 case HangulConsonant: |
| 1117 case KoreanHangulFormal: |
| 1082 case Hebrew: | 1118 case Hebrew: |
| 1083 case Hiragana: | 1119 case Hiragana: |
| 1084 case HiraganaIroha: | 1120 case HiraganaIroha: |
| 1085 case Kannada: | 1121 case Kannada: |
| 1086 case Katakana: | 1122 case Katakana: |
| 1087 case KatakanaIroha: | 1123 case KatakanaIroha: |
| 1088 case Khmer: | 1124 case Khmer: |
| 1089 case Lao: | 1125 case Lao: |
| 1090 case LowerAlpha: | 1126 case LowerAlpha: |
| 1091 case LowerArmenian: | 1127 case LowerArmenian: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 case DecimalListStyle: | 1278 case DecimalListStyle: |
| 1243 case Devanagari: | 1279 case Devanagari: |
| 1244 case EthiopicHalehame: | 1280 case EthiopicHalehame: |
| 1245 case EthiopicHalehameAm: | 1281 case EthiopicHalehameAm: |
| 1246 case EthiopicHalehameTiEr: | 1282 case EthiopicHalehameTiEr: |
| 1247 case EthiopicHalehameTiEt: | 1283 case EthiopicHalehameTiEt: |
| 1248 case Georgian: | 1284 case Georgian: |
| 1249 case Gujarati: | 1285 case Gujarati: |
| 1250 case Gurmukhi: | 1286 case Gurmukhi: |
| 1251 case Hangul: | 1287 case Hangul: |
| 1288 case KoreanHangulFormal: |
| 1252 case HangulConsonant: | 1289 case HangulConsonant: |
| 1253 case Hebrew: | 1290 case Hebrew: |
| 1254 case Hiragana: | 1291 case Hiragana: |
| 1255 case HiraganaIroha: | 1292 case HiraganaIroha: |
| 1256 case Kannada: | 1293 case Kannada: |
| 1257 case Katakana: | 1294 case Katakana: |
| 1258 case KatakanaIroha: | 1295 case KatakanaIroha: |
| 1259 case Khmer: | 1296 case Khmer: |
| 1260 case Lao: | 1297 case Lao: |
| 1261 case LowerAlpha: | 1298 case LowerAlpha: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 if (style()) { | 1364 if (style()) { |
| 1328 // Reuse the current margins. Otherwise resetting the margins to initial
values | 1365 // Reuse the current margins. Otherwise resetting the margins to initial
values |
| 1329 // would trigger unnecessary layout. | 1366 // would trigger unnecessary layout. |
| 1330 newStyle->setMarginStart(style()->marginStart()); | 1367 newStyle->setMarginStart(style()->marginStart()); |
| 1331 newStyle->setMarginEnd(style()->marginRight()); | 1368 newStyle->setMarginEnd(style()->marginRight()); |
| 1332 } | 1369 } |
| 1333 setStyle(newStyle.release()); | 1370 setStyle(newStyle.release()); |
| 1334 } | 1371 } |
| 1335 | 1372 |
| 1336 } // namespace blink | 1373 } // namespace blink |
| OLD | NEW |