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

Side by Side Diff: Source/core/paint/ListMarkerPainter.cpp

Issue 1152763006: Remove outdated list style types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix sorting Created 5 years, 6 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 | « Source/core/layout/LayoutListMarker.cpp ('k') | Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/ListMarkerPainter.h" 6 #include "core/paint/ListMarkerPainter.h"
7 7
8 #include "core/layout/LayoutListItem.h" 8 #include "core/layout/LayoutListItem.h"
9 #include "core/layout/LayoutListMarker.h" 9 #include "core/layout/LayoutListMarker.h"
10 #include "core/layout/TextRunConstructor.h" 10 #include "core/layout/TextRunConstructor.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 context->fillEllipse(marker); 72 context->fillEllipse(marker);
73 return; 73 return;
74 case Circle: 74 case Circle:
75 context->strokeEllipse(marker); 75 context->strokeEllipse(marker);
76 return; 76 return;
77 case Square: 77 case Square:
78 context->fillRect(marker); 78 context->fillRect(marker);
79 return; 79 return;
80 case NoneListStyle: 80 case NoneListStyle:
81 return; 81 return;
82 case Afar:
83 case Amharic:
84 case AmharicAbegede:
85 case ArabicIndic: 82 case ArabicIndic:
86 case Armenian: 83 case Armenian:
87 case BinaryListStyle:
88 case Bengali: 84 case Bengali:
89 case Cambodian: 85 case Cambodian:
90 case CJKIdeographic: 86 case CJKIdeographic:
91 case CjkEarthlyBranch: 87 case CjkEarthlyBranch:
92 case CjkHeavenlyStem: 88 case CjkHeavenlyStem:
93 case DecimalLeadingZero: 89 case DecimalLeadingZero:
94 case DecimalListStyle: 90 case DecimalListStyle:
95 case Devanagari: 91 case Devanagari:
96 case Ethiopic: 92 case EthiopicHalehame:
97 case EthiopicAbegede: 93 case EthiopicHalehameAm:
98 case EthiopicAbegedeAmEt:
99 case EthiopicAbegedeGez:
100 case EthiopicAbegedeTiEr:
101 case EthiopicAbegedeTiEt:
102 case EthiopicHalehameAaEr:
103 case EthiopicHalehameAaEt:
104 case EthiopicHalehameAmEt:
105 case EthiopicHalehameGez:
106 case EthiopicHalehameOmEt:
107 case EthiopicHalehameSidEt:
108 case EthiopicHalehameSoEt:
109 case EthiopicHalehameTiEr: 94 case EthiopicHalehameTiEr:
110 case EthiopicHalehameTiEt: 95 case EthiopicHalehameTiEt:
111 case EthiopicHalehameTig:
112 case Georgian: 96 case Georgian:
113 case Gujarati: 97 case Gujarati:
114 case Gurmukhi: 98 case Gurmukhi:
99 case Hebrew:
115 case Hangul: 100 case Hangul:
116 case HangulConsonant: 101 case HangulConsonant:
117 case Hebrew:
118 case Hiragana: 102 case Hiragana:
119 case HiraganaIroha: 103 case HiraganaIroha:
120 case Kannada: 104 case Kannada:
121 case Katakana: 105 case Katakana:
122 case KatakanaIroha: 106 case KatakanaIroha:
123 case Khmer: 107 case Khmer:
124 case Lao: 108 case Lao:
125 case LowerAlpha: 109 case LowerAlpha:
126 case LowerArmenian: 110 case LowerArmenian:
127 case LowerGreek: 111 case LowerGreek:
128 case LowerHexadecimal:
129 case LowerLatin: 112 case LowerLatin:
130 case LowerNorwegian:
131 case LowerRoman: 113 case LowerRoman:
132 case Malayalam: 114 case Malayalam:
133 case Mongolian: 115 case Mongolian:
134 case Myanmar: 116 case Myanmar:
135 case Octal:
136 case Oriya: 117 case Oriya:
137 case Oromo:
138 case Persian: 118 case Persian:
139 case Sidama:
140 case Somali:
141 case Telugu: 119 case Telugu:
142 case Thai: 120 case Thai:
143 case Tibetan: 121 case Tibetan:
144 case Tigre:
145 case TigrinyaEr:
146 case TigrinyaErAbegede:
147 case TigrinyaEt:
148 case TigrinyaEtAbegede:
149 case UpperAlpha: 122 case UpperAlpha:
150 case UpperArmenian: 123 case UpperArmenian:
151 case UpperGreek:
152 case UpperHexadecimal:
153 case UpperLatin: 124 case UpperLatin:
154 case UpperNorwegian:
155 case UpperRoman: 125 case UpperRoman:
156 case Urdu: 126 case Urdu:
157 case Asterisks:
158 case Footnotes:
159 break; 127 break;
160 } 128 }
161 if (m_layoutListMarker.text().isEmpty()) 129 if (m_layoutListMarker.text().isEmpty())
162 return; 130 return;
163 131
164 const Font& font = m_layoutListMarker.style()->font(); 132 const Font& font = m_layoutListMarker.style()->font();
165 TextRun textRun = constructTextRun(&m_layoutListMarker, font, m_layoutListMa rker.text(), m_layoutListMarker.styleRef()); 133 TextRun textRun = constructTextRun(&m_layoutListMarker, font, m_layoutListMa rker.text(), m_layoutListMarker.styleRef());
166 134
167 GraphicsContextStateSaver stateSaver(*context, false); 135 GraphicsContextStateSaver stateSaver(*context, false);
168 if (!m_layoutListMarker.style()->isHorizontalWritingMode()) { 136 if (!m_layoutListMarker.style()->isHorizontalWritingMode()) {
169 marker.moveBy(roundedIntPoint(-boxOrigin)); 137 marker.moveBy(roundedIntPoint(-boxOrigin));
170 marker = marker.transposedRect(); 138 marker = marker.transposedRect();
171 marker.moveBy(IntPoint(roundToInt(box.x()), roundToInt(box.y() - m_layou tListMarker.logicalHeight()))); 139 marker.moveBy(IntPoint(roundToInt(box.x()), roundToInt(box.y() - m_layou tListMarker.logicalHeight())));
172 stateSaver.save(); 140 stateSaver.save();
173 context->translate(marker.x(), marker.maxY()); 141 context->translate(marker.x(), marker.maxY());
174 context->rotate(static_cast<float>(deg2rad(90.))); 142 context->rotate(static_cast<float>(deg2rad(90.)));
175 context->translate(-marker.x(), -marker.maxY()); 143 context->translate(-marker.x(), -marker.maxY());
176 } 144 }
177 145
178 TextRunPaintInfo textRunPaintInfo(textRun); 146 TextRunPaintInfo textRunPaintInfo(textRun);
179 textRunPaintInfo.bounds = marker; 147 textRunPaintInfo.bounds = marker;
180 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + m_layoutListMarker.s tyle()->fontMetrics().ascent()); 148 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + m_layoutListMarker.s tyle()->fontMetrics().ascent());
181 149
182 if (type == Asterisks || type == Footnotes) { 150 // Text is not arbitrary. We can judge whether it's RTL from the first chara cter,
151 // and we only need to handle the direction RightToLeft for now.
152 bool textNeedsReversing = WTF::Unicode::direction(m_layoutListMarker.text()[ 0]) == WTF::Unicode::RightToLeft;
153 StringBuilder reversedText;
154 if (textNeedsReversing) {
155 unsigned length = m_layoutListMarker.text().length();
156 reversedText.reserveCapacity(length);
157 for (int i = length - 1; i >= 0; --i)
158 reversedText.append(m_layoutListMarker.text()[i]);
159 ASSERT(reversedText.length() == length);
160 textRun.setText(reversedText.toString());
161 }
162
163 const UChar suffix = m_layoutListMarker.listMarkerSuffix(type, m_layoutListM arker.listItem()->value());
164 UChar suffixStr[2] = {
165 m_layoutListMarker.style()->isLeftToRightDirection() ? suffix : static_c ast<UChar>(' '),
166 m_layoutListMarker.style()->isLeftToRightDirection() ? static_cast<UChar >(' ') : suffix
167 };
168 TextRun suffixRun = constructTextRun(&m_layoutListMarker, font, suffixStr, 2 , m_layoutListMarker.styleRef(), m_layoutListMarker.style()->direction());
169 TextRunPaintInfo suffixRunInfo(suffixRun);
170 suffixRunInfo.bounds = marker;
171
172 if (m_layoutListMarker.style()->isLeftToRightDirection()) {
183 context->drawText(font, textRunPaintInfo, textOrigin); 173 context->drawText(font, textRunPaintInfo, textOrigin);
174 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t extRun), 0));
184 } else { 175 } else {
185 // Text is not arbitrary. We can judge whether it's RTL from the first c haracter, 176 context->drawText(font, suffixRunInfo, textOrigin);
186 // and we only need to handle the direction RightToLeft for now. 177 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt h(suffixRun), 0));
187 bool textNeedsReversing = WTF::Unicode::direction(m_layoutListMarker.tex t()[0]) == WTF::Unicode::RightToLeft;
188 StringBuilder reversedText;
189 if (textNeedsReversing) {
190 unsigned length = m_layoutListMarker.text().length();
191 reversedText.reserveCapacity(length);
192 for (int i = length - 1; i >= 0; --i)
193 reversedText.append(m_layoutListMarker.text()[i]);
194 ASSERT(reversedText.length() == length);
195 textRun.setText(reversedText.toString());
196 }
197
198 const UChar suffix = m_layoutListMarker.listMarkerSuffix(type, m_layoutL istMarker.listItem()->value());
199 UChar suffixStr[2] = {
200 m_layoutListMarker.style()->isLeftToRightDirection() ? suffix : stat ic_cast<UChar>(' '),
201 m_layoutListMarker.style()->isLeftToRightDirection() ? static_cast<U Char>(' ') : suffix
202 };
203 TextRun suffixRun = constructTextRun(&m_layoutListMarker, font, suffixSt r, 2, m_layoutListMarker.styleRef(), m_layoutListMarker.style()->direction());
204 TextRunPaintInfo suffixRunInfo(suffixRun);
205 suffixRunInfo.bounds = marker;
206
207 if (m_layoutListMarker.style()->isLeftToRightDirection()) {
208 context->drawText(font, textRunPaintInfo, textOrigin);
209 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.wid th(textRun), 0));
210 } else {
211 context->drawText(font, suffixRunInfo, textOrigin);
212 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font. width(suffixRun), 0));
213 }
214 } 178 }
215 } 179 }
216 180
217 } // namespace blink 181 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutListMarker.cpp ('k') | Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698