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

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

Issue 873453002: Fix ASSERT in ListMarkerPainter::paint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 | « LayoutTests/fast/lists/list-marker-text-reverse-expected.txt ('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 // 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/paint/BlockPainter.h" 8 #include "core/paint/BlockPainter.h"
9 #include "core/paint/GraphicsContextAnnotator.h" 9 #include "core/paint/GraphicsContextAnnotator.h"
10 #include "core/paint/RenderDrawingRecorder.h" 10 #include "core/paint/RenderDrawingRecorder.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + m_renderListMarker.s tyle()->fontMetrics().ascent()); 183 IntPoint textOrigin = IntPoint(marker.x(), marker.y() + m_renderListMarker.s tyle()->fontMetrics().ascent());
184 184
185 if (type == Asterisks || type == Footnotes) { 185 if (type == Asterisks || type == Footnotes) {
186 context->drawText(font, textRunPaintInfo, textOrigin); 186 context->drawText(font, textRunPaintInfo, textOrigin);
187 } else { 187 } else {
188 // Text is not arbitrary. We can judge whether it's RTL from the first c haracter, 188 // Text is not arbitrary. We can judge whether it's RTL from the first c haracter,
189 // and we only need to handle the direction RightToLeft for now. 189 // and we only need to handle the direction RightToLeft for now.
190 bool textNeedsReversing = WTF::Unicode::direction(m_renderListMarker.tex t()[0]) == WTF::Unicode::RightToLeft; 190 bool textNeedsReversing = WTF::Unicode::direction(m_renderListMarker.tex t()[0]) == WTF::Unicode::RightToLeft;
191 StringBuilder reversedText; 191 StringBuilder reversedText;
192 if (textNeedsReversing) { 192 if (textNeedsReversing) {
193 int length = m_renderListMarker.text().length(); 193 unsigned length = m_renderListMarker.text().length();
194 reversedText.reserveCapacity(length); 194 reversedText.reserveCapacity(length);
195 for (int i = length - 1; i >= 0; --i) 195 for (int i = length - 1; i >= 0; --i)
196 reversedText.append(m_renderListMarker.text()[i]); 196 reversedText.append(m_renderListMarker.text()[i]);
197 ASSERT(reversedText.length() == reversedText.capacity()); 197 ASSERT(reversedText.length() == length);
198 textRun.setText(reversedText.toString()); 198 textRun.setText(reversedText.toString());
199 } 199 }
200 200
201 const UChar suffix = m_renderListMarker.listMarkerSuffix(type, m_renderL istMarker.listItem()->value()); 201 const UChar suffix = m_renderListMarker.listMarkerSuffix(type, m_renderL istMarker.listItem()->value());
202 UChar suffixStr[2] = { 202 UChar suffixStr[2] = {
203 m_renderListMarker.style()->isLeftToRightDirection() ? suffix : ' ', 203 m_renderListMarker.style()->isLeftToRightDirection() ? suffix : ' ',
204 m_renderListMarker.style()->isLeftToRightDirection() ? ' ' : suffix 204 m_renderListMarker.style()->isLeftToRightDirection() ? ' ' : suffix
205 }; 205 };
206 TextRun suffixRun = constructTextRun(&m_renderListMarker, font, suffixSt r, 2, m_renderListMarker.style(), m_renderListMarker.style()->direction()); 206 TextRun suffixRun = constructTextRun(&m_renderListMarker, font, suffixSt r, 2, m_renderListMarker.style(), m_renderListMarker.style()->direction());
207 TextRunPaintInfo suffixRunInfo(suffixRun); 207 TextRunPaintInfo suffixRunInfo(suffixRun);
208 suffixRunInfo.bounds = marker; 208 suffixRunInfo.bounds = marker;
209 209
210 if (m_renderListMarker.style()->isLeftToRightDirection()) { 210 if (m_renderListMarker.style()->isLeftToRightDirection()) {
211 context->drawText(font, textRunPaintInfo, textOrigin); 211 context->drawText(font, textRunPaintInfo, textOrigin);
212 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.wid th(textRun), 0)); 212 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.wid th(textRun), 0));
213 } else { 213 } else {
214 context->drawText(font, suffixRunInfo, textOrigin); 214 context->drawText(font, suffixRunInfo, textOrigin);
215 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font. width(suffixRun), 0)); 215 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font. width(suffixRun), 0));
216 } 216 }
217 } 217 }
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/lists/list-marker-text-reverse-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698