Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/layout/ListMarkerText.cpp

Issue 2597083002: Moved list-style-type to be generated in ComputedStyleBase (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights
5 * reserved. 5 * reserved.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) 7 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 static EListStyleType effectiveListMarkerType(EListStyleType type, int count) { 461 static EListStyleType effectiveListMarkerType(EListStyleType type, int count) {
462 // Note, the following switch statement has been explicitly grouped 462 // Note, the following switch statement has been explicitly grouped
463 // by list-style-type ordinal range. 463 // by list-style-type ordinal range.
464 switch (type) { 464 switch (type) {
465 case EListStyleType::ArabicIndic: 465 case EListStyleType::ArabicIndic:
466 case EListStyleType::Bengali: 466 case EListStyleType::Bengali:
467 case EListStyleType::Cambodian: 467 case EListStyleType::Cambodian:
468 case EListStyleType::Circle: 468 case EListStyleType::Circle:
469 case EListStyleType::DecimalLeadingZero: 469 case EListStyleType::DecimalLeadingZero:
470 case EListStyleType::DecimalListStyle: 470 case EListStyleType::Decimal:
471 case EListStyleType::Devanagari: 471 case EListStyleType::Devanagari:
472 case EListStyleType::Disc: 472 case EListStyleType::Disc:
473 case EListStyleType::Gujarati: 473 case EListStyleType::Gujarati:
474 case EListStyleType::Gurmukhi: 474 case EListStyleType::Gurmukhi:
475 case EListStyleType::Kannada: 475 case EListStyleType::Kannada:
476 case EListStyleType::Khmer: 476 case EListStyleType::Khmer:
477 case EListStyleType::Lao: 477 case EListStyleType::Lao:
478 case EListStyleType::Malayalam: 478 case EListStyleType::Malayalam:
479 case EListStyleType::Mongolian: 479 case EListStyleType::Mongolian:
480 case EListStyleType::Myanmar: 480 case EListStyleType::Myanmar:
481 case EListStyleType::NoneListStyle: 481 case EListStyleType::None:
482 case EListStyleType::Oriya: 482 case EListStyleType::Oriya:
483 case EListStyleType::Persian: 483 case EListStyleType::Persian:
484 case EListStyleType::Square: 484 case EListStyleType::Square:
485 case EListStyleType::Telugu: 485 case EListStyleType::Telugu:
486 case EListStyleType::Thai: 486 case EListStyleType::Thai:
487 case EListStyleType::Tibetan: 487 case EListStyleType::Tibetan:
488 case EListStyleType::Urdu: 488 case EListStyleType::Urdu:
489 case EListStyleType::KoreanHangulFormal: 489 case EListStyleType::KoreanHangulFormal:
490 case EListStyleType::KoreanHanjaFormal: 490 case EListStyleType::KoreanHanjaFormal:
491 case EListStyleType::KoreanHanjaInformal: 491 case EListStyleType::KoreanHanjaInformal:
492 case EListStyleType::CJKIdeographic: 492 case EListStyleType::CjkIdeographic:
493 case EListStyleType::SimpChineseFormal: 493 case EListStyleType::SimpChineseFormal:
494 case EListStyleType::SimpChineseInformal: 494 case EListStyleType::SimpChineseInformal:
495 case EListStyleType::TradChineseFormal: 495 case EListStyleType::TradChineseFormal:
496 case EListStyleType::TradChineseInformal: 496 case EListStyleType::TradChineseInformal:
497 return type; // Can represent all ordinals. 497 return type; // Can represent all ordinals.
498 case EListStyleType::Armenian: 498 case EListStyleType::Armenian:
499 case EListStyleType::LowerArmenian: 499 case EListStyleType::LowerArmenian:
500 case EListStyleType::UpperArmenian: 500 case EListStyleType::UpperArmenian:
501 return (count < 1 || count > 99999999) ? EListStyleType::DecimalListStyle 501 return (count < 1 || count > 99999999) ? EListStyleType::Decimal : type;
502 : type;
503 case EListStyleType::Georgian: 502 case EListStyleType::Georgian:
504 return (count < 1 || count > 19999) ? EListStyleType::DecimalListStyle 503 return (count < 1 || count > 19999) ? EListStyleType::Decimal : type;
505 : type;
506 case EListStyleType::Hebrew: 504 case EListStyleType::Hebrew:
507 return (count < 0 || count > 999999) ? EListStyleType::DecimalListStyle 505 return (count < 0 || count > 999999) ? EListStyleType::Decimal : type;
508 : type;
509 case EListStyleType::LowerRoman: 506 case EListStyleType::LowerRoman:
510 case EListStyleType::UpperRoman: 507 case EListStyleType::UpperRoman:
511 return (count < 1 || count > 3999) ? EListStyleType::DecimalListStyle 508 return (count < 1 || count > 3999) ? EListStyleType::Decimal : type;
512 : type;
513 case EListStyleType::CjkEarthlyBranch: 509 case EListStyleType::CjkEarthlyBranch:
514 case EListStyleType::CjkHeavenlyStem: 510 case EListStyleType::CjkHeavenlyStem:
515 case EListStyleType::EthiopicHalehameAm: 511 case EListStyleType::EthiopicHalehameAm:
516 case EListStyleType::EthiopicHalehame: 512 case EListStyleType::EthiopicHalehame:
517 case EListStyleType::EthiopicHalehameTiEr: 513 case EListStyleType::EthiopicHalehameTiEr:
518 case EListStyleType::EthiopicHalehameTiEt: 514 case EListStyleType::EthiopicHalehameTiEt:
519 case EListStyleType::Hangul: 515 case EListStyleType::Hangul:
520 case EListStyleType::HangulConsonant: 516 case EListStyleType::HangulConsonant:
521 case EListStyleType::Hiragana: 517 case EListStyleType::Hiragana:
522 case EListStyleType::HiraganaIroha: 518 case EListStyleType::HiraganaIroha:
523 case EListStyleType::Katakana: 519 case EListStyleType::Katakana:
524 case EListStyleType::KatakanaIroha: 520 case EListStyleType::KatakanaIroha:
525 case EListStyleType::LowerAlpha: 521 case EListStyleType::LowerAlpha:
526 case EListStyleType::LowerGreek: 522 case EListStyleType::LowerGreek:
527 case EListStyleType::LowerLatin: 523 case EListStyleType::LowerLatin:
528 case EListStyleType::UpperAlpha: 524 case EListStyleType::UpperAlpha:
529 case EListStyleType::UpperLatin: 525 case EListStyleType::UpperLatin:
530 return (count < 1) ? EListStyleType::DecimalListStyle : type; 526 return (count < 1) ? EListStyleType::Decimal : type;
531 } 527 }
532 528
533 ASSERT_NOT_REACHED(); 529 ASSERT_NOT_REACHED();
534 return type; 530 return type;
535 } 531 }
536 532
537 UChar suffix(EListStyleType type, int count) { 533 UChar suffix(EListStyleType type, int count) {
538 // If the list-style-type cannot represent |count| because it's outside its 534 // If the list-style-type cannot represent |count| because it's outside its
539 // ordinal range then we fall back to some list style that can represent 535 // ordinal range then we fall back to some list style that can represent
540 // |count|. 536 // |count|.
541 EListStyleType effectiveType = effectiveListMarkerType(type, count); 537 EListStyleType effectiveType = effectiveListMarkerType(type, count);
542 538
543 // Note, the following switch statement has been explicitly 539 // Note, the following switch statement has been explicitly
544 // grouped by list-style-type suffix. 540 // grouped by list-style-type suffix.
545 switch (effectiveType) { 541 switch (effectiveType) {
546 case EListStyleType::Circle: 542 case EListStyleType::Circle:
547 case EListStyleType::Disc: 543 case EListStyleType::Disc:
548 case EListStyleType::NoneListStyle: 544 case EListStyleType::None:
549 case EListStyleType::Square: 545 case EListStyleType::Square:
550 return ' '; 546 return ' ';
551 case EListStyleType::EthiopicHalehame: 547 case EListStyleType::EthiopicHalehame:
552 case EListStyleType::EthiopicHalehameAm: 548 case EListStyleType::EthiopicHalehameAm:
553 case EListStyleType::EthiopicHalehameTiEr: 549 case EListStyleType::EthiopicHalehameTiEr:
554 case EListStyleType::EthiopicHalehameTiEt: 550 case EListStyleType::EthiopicHalehameTiEt:
555 return ethiopicPrefaceColonCharacter; 551 return ethiopicPrefaceColonCharacter;
556 case EListStyleType::Armenian: 552 case EListStyleType::Armenian:
557 case EListStyleType::ArabicIndic: 553 case EListStyleType::ArabicIndic:
558 case EListStyleType::Bengali: 554 case EListStyleType::Bengali:
559 case EListStyleType::Cambodian: 555 case EListStyleType::Cambodian:
560 case EListStyleType::CJKIdeographic: 556 case EListStyleType::CjkIdeographic:
561 case EListStyleType::CjkEarthlyBranch: 557 case EListStyleType::CjkEarthlyBranch:
562 case EListStyleType::CjkHeavenlyStem: 558 case EListStyleType::CjkHeavenlyStem:
563 case EListStyleType::DecimalLeadingZero: 559 case EListStyleType::DecimalLeadingZero:
564 case EListStyleType::DecimalListStyle: 560 case EListStyleType::Decimal:
565 case EListStyleType::Devanagari: 561 case EListStyleType::Devanagari:
566 case EListStyleType::Georgian: 562 case EListStyleType::Georgian:
567 case EListStyleType::Gujarati: 563 case EListStyleType::Gujarati:
568 case EListStyleType::Gurmukhi: 564 case EListStyleType::Gurmukhi:
569 case EListStyleType::Hangul: 565 case EListStyleType::Hangul:
570 case EListStyleType::HangulConsonant: 566 case EListStyleType::HangulConsonant:
571 case EListStyleType::Hebrew: 567 case EListStyleType::Hebrew:
572 case EListStyleType::Hiragana: 568 case EListStyleType::Hiragana:
573 case EListStyleType::HiraganaIroha: 569 case EListStyleType::HiraganaIroha:
574 case EListStyleType::Kannada: 570 case EListStyleType::Kannada:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 603
608 ASSERT_NOT_REACHED(); 604 ASSERT_NOT_REACHED();
609 return '.'; 605 return '.';
610 } 606 }
611 607
612 String text(EListStyleType type, int count) { 608 String text(EListStyleType type, int count) {
613 // If the list-style-type, say hebrew, cannot represent |count| because it's 609 // If the list-style-type, say hebrew, cannot represent |count| because it's
614 // outside its ordinal range then we fallback to some list style that can 610 // outside its ordinal range then we fallback to some list style that can
615 // represent |count|. 611 // represent |count|.
616 switch (effectiveListMarkerType(type, count)) { 612 switch (effectiveListMarkerType(type, count)) {
617 case EListStyleType::NoneListStyle: 613 case EListStyleType::None:
618 return ""; 614 return "";
619 615
620 // We use the same characters for text security. 616 // We use the same characters for text security.
621 // See LayoutText::setInternalString. 617 // See LayoutText::setInternalString.
622 case EListStyleType::Circle: 618 case EListStyleType::Circle:
623 return String(&whiteBulletCharacter, 1); 619 return String(&whiteBulletCharacter, 1);
624 case EListStyleType::Disc: 620 case EListStyleType::Disc:
625 return String(&bulletCharacter, 1); 621 return String(&bulletCharacter, 1);
626 case EListStyleType::Square: 622 case EListStyleType::Square:
627 // The CSS 2.1 test suite uses U+25EE BLACK MEDIUM SMALL SQUARE 623 // The CSS 2.1 test suite uses U+25EE BLACK MEDIUM SMALL SQUARE
628 // instead, but I think this looks better. 624 // instead, but I think this looks better.
629 return String(&blackSquareCharacter, 1); 625 return String(&blackSquareCharacter, 1);
630 626
631 case EListStyleType::DecimalListStyle: 627 case EListStyleType::Decimal:
632 return String::number(count); 628 return String::number(count);
633 case EListStyleType::DecimalLeadingZero: 629 case EListStyleType::DecimalLeadingZero:
634 if (count < -9 || count > 9) 630 if (count < -9 || count > 9)
635 return String::number(count); 631 return String::number(count);
636 if (count < 0) 632 if (count < 0)
637 return "-0" + String::number(-count); // -01 to -09 633 return "-0" + String::number(-count); // -01 to -09
638 return "0" + String::number(count); // 00 to 09 634 return "0" + String::number(count); // 00 to 09
639 635
640 case EListStyleType::ArabicIndic: { 636 case EListStyleType::ArabicIndic: {
641 static const UChar arabicIndicNumerals[10] = { 637 static const UChar arabicIndicNumerals[10] = {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 return toCJKIdeographic(count, koreanHanjaFormalTable, Formal); 878 return toCJKIdeographic(count, koreanHanjaFormalTable, Formal);
883 } 879 }
884 case EListStyleType::KoreanHanjaInformal: { 880 case EListStyleType::KoreanHanjaInformal: {
885 static const UChar koreanHanjaInformalTable[26] = { 881 static const UChar koreanHanjaInformalTable[26] = {
886 Korean, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 882 Korean, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000,
887 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 883 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09,
888 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0xB9C8, 884 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0xB9C8,
889 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000}; 885 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000};
890 return toCJKIdeographic(count, koreanHanjaInformalTable, Informal); 886 return toCJKIdeographic(count, koreanHanjaInformalTable, Informal);
891 } 887 }
892 case EListStyleType::CJKIdeographic: 888 case EListStyleType::CjkIdeographic:
893 case EListStyleType::TradChineseInformal: { 889 case EListStyleType::TradChineseInformal: {
894 static const UChar traditionalChineseInformalTable[22] = { 890 static const UChar traditionalChineseInformalTable[22] = {
895 Chinese, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x5341, 891 Chinese, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x5341,
896 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 892 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94,
897 0x516D, 0x4E03, 0x516B, 0x4E5D, 0x8CA0, 0x0000}; 893 0x516D, 0x4E03, 0x516B, 0x4E5D, 0x8CA0, 0x0000};
898 return toCJKIdeographic(count, traditionalChineseInformalTable, Informal); 894 return toCJKIdeographic(count, traditionalChineseInformalTable, Informal);
899 } 895 }
900 case EListStyleType::SimpChineseInformal: { 896 case EListStyleType::SimpChineseInformal: {
901 static const UChar simpleChineseInformalTable[22] = { 897 static const UChar simpleChineseInformalTable[22] = {
902 Chinese, 0x4E07, 0x0000, 0x4EBF, 0x0000, 0x4E07, 0x4EBF, 0x5341, 898 Chinese, 0x4E07, 0x0000, 0x4EBF, 0x0000, 0x4E07, 0x4EBF, 0x5341,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return toHebrew(count); 934 return toHebrew(count);
939 } 935 }
940 936
941 ASSERT_NOT_REACHED(); 937 ASSERT_NOT_REACHED();
942 return ""; 938 return "";
943 } 939 }
944 940
945 } // namespace ListMarkerText 941 } // namespace ListMarkerText
946 942
947 } // namespace blink 943 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListMarker.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698