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

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

Issue 2400333003: Enforce comment formatting in core/layout as well. (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 reserv ed. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights
5 * reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) 7 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com)
7 * 8 *
8 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
12 * 13 *
13 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 if (num % 5 == 4) 63 if (num % 5 == 4)
63 letters[lettersSize - ++length] = digits[d]; 64 letters[lettersSize - ++length] = digits[d];
64 number /= 10; 65 number /= 10;
65 d += 2; 66 d += 2;
66 } while (number); 67 } while (number);
67 68
68 ASSERT(length <= lettersSize); 69 ASSERT(length <= lettersSize);
69 return String(&letters[lettersSize - length], length); 70 return String(&letters[lettersSize - length], length);
70 } 71 }
71 72
72 // The typedef is needed because taking sizeof(number) in the const expression b elow doesn't work with some compilers. 73 // The typedef is needed because taking sizeof(number) in the const expression
73 // This is likely the case because of the template. 74 // below doesn't work with some compilers. This is likely the case because of
75 // the template.
74 typedef int numberType; 76 typedef int numberType;
75 77
76 template <typename CharacterType> 78 template <typename CharacterType>
77 static inline String toAlphabeticOrNumeric(numberType number, 79 static inline String toAlphabeticOrNumeric(numberType number,
78 const CharacterType* sequence, 80 const CharacterType* sequence,
79 unsigned sequenceSize, 81 unsigned sequenceSize,
80 SequenceType type) { 82 SequenceType type) {
81 ASSERT(sequenceSize >= 2); 83 ASSERT(sequenceSize >= 2);
82 84
83 const int lettersSize = 85 // Binary is the worst case; requires one character per bit plus a minus sign.
84 sizeof(numberType) * 8 + 86 const int lettersSize = sizeof(numberType) * 8 + 1;
85 1; // Binary is the worst case; requires one character per bit plus a min us sign.
86 87
87 CharacterType letters[lettersSize]; 88 CharacterType letters[lettersSize];
88 89
89 bool isNegativeNumber = false; 90 bool isNegativeNumber = false;
90 unsigned numberShadow = number; 91 unsigned numberShadow = number;
91 if (type == AlphabeticSequence) { 92 if (type == AlphabeticSequence) {
92 ASSERT(number > 0); 93 ASSERT(number > 0);
93 --numberShadow; 94 --numberShadow;
94 } else if (number < 0) { 95 } else if (number < 0) {
95 numberShadow = -number; 96 numberShadow = -number;
(...skipping 20 matching lines...) Expand all
116 117
117 template <typename CharacterType> 118 template <typename CharacterType>
118 static String toSymbolic(int number, 119 static String toSymbolic(int number,
119 const CharacterType* symbols, 120 const CharacterType* symbols,
120 unsigned symbolsSize) { 121 unsigned symbolsSize) {
121 ASSERT(number > 0); 122 ASSERT(number > 0);
122 ASSERT(symbolsSize >= 1); 123 ASSERT(symbolsSize >= 1);
123 unsigned numberShadow = number; 124 unsigned numberShadow = number;
124 --numberShadow; 125 --numberShadow;
125 126
126 // The asterisks list-style-type is the worst case; we show |numberShadow| ast erisks. 127 // The asterisks list-style-type is the worst case; we show |numberShadow|
128 // asterisks.
127 StringBuilder letters; 129 StringBuilder letters;
128 letters.append(symbols[numberShadow % symbolsSize]); 130 letters.append(symbols[numberShadow % symbolsSize]);
129 unsigned numSymbols = numberShadow / symbolsSize; 131 unsigned numSymbols = numberShadow / symbolsSize;
130 while (numSymbols--) 132 while (numSymbols--)
131 letters.append(symbols[numberShadow % symbolsSize]); 133 letters.append(symbols[numberShadow % symbolsSize]);
132 return letters.toString(); 134 return letters.toString();
133 } 135 }
134 136
135 template <typename CharacterType> 137 template <typename CharacterType>
136 static String toAlphabetic(int number, 138 static String toAlphabetic(int number,
(...skipping 23 matching lines...) Expand all
160 } 162 }
161 163
162 template <typename CharacterType, size_t size> 164 template <typename CharacterType, size_t size>
163 static inline String toSymbolic(int number, 165 static inline String toSymbolic(int number,
164 const CharacterType (&alphabet)[size]) { 166 const CharacterType (&alphabet)[size]) {
165 return toSymbolic(number, alphabet, size); 167 return toSymbolic(number, alphabet, size);
166 } 168 }
167 169
168 static void toHebrewUnder1000(int number, Vector<UChar>& letters) { 170 static void toHebrewUnder1000(int number, Vector<UChar>& letters) {
169 // FIXME: CSS3 mentions various refinements not implemented here. 171 // FIXME: CSS3 mentions various refinements not implemented here.
170 // FIXME: Should take a look at Mozilla's HebrewToText function (in nsBulletFr ame). 172 // FIXME: Should take a look at Mozilla's HebrewToText function (in
173 // nsBulletFrame).
171 ASSERT(number >= 0 && number < 1000); 174 ASSERT(number >= 0 && number < 1000);
172 int fourHundreds = number / 400; 175 int fourHundreds = number / 400;
173 for (int i = 0; i < fourHundreds; i++) 176 for (int i = 0; i < fourHundreds; i++)
174 letters.prepend(1511 + 3); 177 letters.prepend(1511 + 3);
175 number %= 400; 178 number %= 400;
176 if (number / 100) 179 if (number / 100)
177 letters.prepend(1511 + (number / 100) - 1); 180 letters.prepend(1511 + (number / 100) - 1);
178 number %= 100; 181 number %= 100;
179 if (number == 15 || number == 16) { 182 if (number == 15 || number == 16) {
180 letters.prepend(1487 + 9); 183 letters.prepend(1487 + 9);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 305
303 ASSERT(length <= lettersSize); 306 ASSERT(length <= lettersSize);
304 return String(letters, length); 307 return String(letters, length);
305 } 308 }
306 309
307 enum CJKLang { Chinese = 1, Korean, Japanese }; 310 enum CJKLang { Chinese = 1, Korean, Japanese };
308 311
309 enum CJKStyle { Formal, Informal }; 312 enum CJKStyle { Formal, Informal };
310 313
311 // The table uses the order from the CSS3 specification: 314 // The table uses the order from the CSS3 specification:
312 // first 3 group markers, then 3 digit markers, then ten digits, then negative s ymbols. 315 // first 3 group markers, then 3 digit markers, then ten digits, then negative
316 // symbols.
313 static String toCJKIdeographic(int number, 317 static String toCJKIdeographic(int number,
314 const UChar table[26], 318 const UChar table[26],
315 CJKStyle cjkStyle) { 319 CJKStyle cjkStyle) {
316 enum AbstractCJKChar { 320 enum AbstractCJKChar {
317 NoChar = 0, 321 NoChar = 0,
318 Lang = 0, 322 Lang = 0,
319 // FourthGroupMarker for simplified chinese has two codepoints, to simplify 323 // FourthGroupMarker for simplified chinese has two codepoints, to simplify
320 // the main algorithm below use two codepoints for all group markers. 324 // the main algorithm below use two codepoints for all group markers.
321 SecondGroupMarker = 1, 325 SecondGroupMarker = 1,
322 ThirdGroupMarker = 3, 326 ThirdGroupMarker = 3,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 case UpperLatin: 525 case UpperLatin:
522 return (count < 1) ? DecimalListStyle : type; 526 return (count < 1) ? DecimalListStyle : type;
523 } 527 }
524 528
525 ASSERT_NOT_REACHED(); 529 ASSERT_NOT_REACHED();
526 return type; 530 return type;
527 } 531 }
528 532
529 UChar suffix(EListStyleType type, int count) { 533 UChar suffix(EListStyleType type, int count) {
530 // 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
531 // ordinal range then we fall back to some list style that can represent |coun t|. 535 // ordinal range then we fall back to some list style that can represent
536 // |count|.
532 EListStyleType effectiveType = effectiveListMarkerType(type, count); 537 EListStyleType effectiveType = effectiveListMarkerType(type, count);
533 538
534 // Note, the following switch statement has been explicitly 539 // Note, the following switch statement has been explicitly
535 // grouped by list-style-type suffix. 540 // grouped by list-style-type suffix.
536 switch (effectiveType) { 541 switch (effectiveType) {
537 case Circle: 542 case Circle:
538 case Disc: 543 case Disc:
539 case NoneListStyle: 544 case NoneListStyle:
540 case Square: 545 case Square:
541 return ' '; 546 return ' ';
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 case KoreanHanjaFormal: 599 case KoreanHanjaFormal:
595 case KoreanHanjaInformal: 600 case KoreanHanjaInformal:
596 return 0x3001; 601 return 0x3001;
597 } 602 }
598 603
599 ASSERT_NOT_REACHED(); 604 ASSERT_NOT_REACHED();
600 return '.'; 605 return '.';
601 } 606 }
602 607
603 String text(EListStyleType type, int count) { 608 String text(EListStyleType type, int count) {
604 // If the list-style-type, say hebrew, cannot represent |count| because it's o utside 609 // If the list-style-type, say hebrew, cannot represent |count| because it's
605 // its ordinal range then we fallback to some list style that can represent |c ount|. 610 // outside its ordinal range then we fallback to some list style that can
611 // represent |count|.
606 switch (effectiveListMarkerType(type, count)) { 612 switch (effectiveListMarkerType(type, count)) {
607 case NoneListStyle: 613 case NoneListStyle:
608 return ""; 614 return "";
609 615
610 // We use the same characters for text security. 616 // We use the same characters for text security.
611 // See LayoutText::setInternalString. 617 // See LayoutText::setInternalString.
612 case Circle: 618 case Circle:
613 return String(&whiteBulletCharacter, 1); 619 return String(&whiteBulletCharacter, 1);
614 case Disc: 620 case Disc:
615 return String(&bulletCharacter, 1); 621 return String(&bulletCharacter, 1);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 } 916 }
911 917
912 case LowerRoman: 918 case LowerRoman:
913 return toRoman(count, false); 919 return toRoman(count, false);
914 case UpperRoman: 920 case UpperRoman:
915 return toRoman(count, true); 921 return toRoman(count, true);
916 922
917 case Armenian: 923 case Armenian:
918 case UpperArmenian: 924 case UpperArmenian:
919 // CSS3 says "armenian" means "lower-armenian". 925 // CSS3 says "armenian" means "lower-armenian".
920 // But the CSS2.1 test suite contains uppercase test results for "armenian ", 926 // But the CSS2.1 test suite contains uppercase test results for
921 // so we'll match the test suite. 927 // "armenian", so we'll match the test suite.
922 return toArmenian(count, true); 928 return toArmenian(count, true);
923 case LowerArmenian: 929 case LowerArmenian:
924 return toArmenian(count, false); 930 return toArmenian(count, false);
925 case Georgian: 931 case Georgian:
926 return toGeorgian(count); 932 return toGeorgian(count);
927 case Hebrew: 933 case Hebrew:
928 return toHebrew(count); 934 return toHebrew(count);
929 } 935 }
930 936
931 ASSERT_NOT_REACHED(); 937 ASSERT_NOT_REACHED();
932 return ""; 938 return "";
933 } 939 }
934 940
935 } // namespace ListMarkerText 941 } // namespace ListMarkerText
936 942
937 } // namespace blink 943 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698