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

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

Issue 1043643002: Switch line layout to LayoutUnit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More TestExpectations tweaks 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/TextPainter.h ('k') | Source/modules/accessibility/AXInlineTextBox.cpp » ('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/TextPainter.h" 6 #include "core/paint/TextPainter.h"
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutObject.h" 10 #include "core/layout/LayoutObject.h"
11 #include "core/layout/LayoutTextCombine.h" 11 #include "core/layout/LayoutTextCombine.h"
12 #include "core/layout/line/InlineTextBox.h" 12 #include "core/layout/line/InlineTextBox.h"
13 #include "core/style/ComputedStyle.h" 13 #include "core/style/ComputedStyle.h"
14 #include "core/style/ShadowList.h" 14 #include "core/style/ShadowList.h"
15 #include "platform/fonts/Font.h" 15 #include "platform/fonts/Font.h"
16 #include "platform/graphics/GraphicsContext.h" 16 #include "platform/graphics/GraphicsContext.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h" 17 #include "platform/graphics/GraphicsContextStateSaver.h"
18 #include "platform/text/TextRun.h" 18 #include "platform/text/TextRun.h"
19 #include "wtf/Assertions.h" 19 #include "wtf/Assertions.h"
20 #include "wtf/unicode/CharacterNames.h" 20 #include "wtf/unicode/CharacterNames.h"
21 21
22 namespace blink { 22 namespace blink {
23 23
24 TextPainter::TextPainter(GraphicsContext* context, const Font& font, const TextR un& run, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizon tal) 24 TextPainter::TextPainter(GraphicsContext* context, const Font& font, const TextR un& run, const LayoutPoint& textOrigin, const LayoutRect& textBounds, bool horiz ontal)
25 : m_graphicsContext(context) 25 : m_graphicsContext(context)
26 , m_font(font) 26 , m_font(font)
27 , m_run(run) 27 , m_run(run)
28 , m_textOrigin(textOrigin) 28 , m_textOrigin(textOrigin)
29 , m_textBounds(textBounds) 29 , m_textBounds(textBounds)
30 , m_horizontal(horizontal) 30 , m_horizontal(horizontal)
31 , m_emphasisMarkOffset(0) 31 , m_emphasisMarkOffset(0)
32 , m_combinedText(0) 32 , m_combinedText(0)
33 { 33 {
34 } 34 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void TextPainter::paintInternalRun(TextRunPaintInfo& textRunPaintInfo, int from, int to) 184 void TextPainter::paintInternalRun(TextRunPaintInfo& textRunPaintInfo, int from, int to)
185 { 185 {
186 ASSERT(from <= textRunPaintInfo.run.length()); 186 ASSERT(from <= textRunPaintInfo.run.length());
187 ASSERT(to <= textRunPaintInfo.run.length()); 187 ASSERT(to <= textRunPaintInfo.run.length());
188 188
189 textRunPaintInfo.from = from; 189 textRunPaintInfo.from = from;
190 textRunPaintInfo.to = to; 190 textRunPaintInfo.to = to;
191 191
192 if (step == PaintEmphasisMark) { 192 if (step == PaintEmphasisMark) {
193 m_graphicsContext->drawEmphasisMarks(m_font, textRunPaintInfo, m_emphasi sMark, 193 m_graphicsContext->drawEmphasisMarks(m_font, textRunPaintInfo, m_emphasi sMark,
194 m_textOrigin + IntSize(0, m_emphasisMarkOffset)); 194 FloatPoint(m_textOrigin) + IntSize(0, m_emphasisMarkOffset));
195 } else { 195 } else {
196 ASSERT(step == PaintText); 196 ASSERT(step == PaintText);
197 m_graphicsContext->drawText(m_font, textRunPaintInfo, m_textOrigin); 197 m_graphicsContext->drawText(m_font, textRunPaintInfo, FloatPoint(m_textO rigin));
198 } 198 }
199 } 199 }
200 200
201 template <TextPainter::PaintInternalStep Step> 201 template <TextPainter::PaintInternalStep Step>
202 void TextPainter::paintInternal(int startOffset, int endOffset, int truncationPo int, TextBlobPtr* cachedTextBlob) 202 void TextPainter::paintInternal(int startOffset, int endOffset, int truncationPo int, TextBlobPtr* cachedTextBlob)
203 { 203 {
204 TextRunPaintInfo textRunPaintInfo(m_run); 204 TextRunPaintInfo textRunPaintInfo(m_run);
205 textRunPaintInfo.bounds = m_textBounds; 205 textRunPaintInfo.bounds = m_textBounds;
206 if (startOffset <= endOffset) { 206 if (startOffset <= endOffset) {
207 // FIXME: We should be able to use cachedTextBlob in more cases. 207 // FIXME: We should be able to use cachedTextBlob in more cases.
208 textRunPaintInfo.cachedTextBlob = cachedTextBlob; 208 textRunPaintInfo.cachedTextBlob = cachedTextBlob;
209 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); 209 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset);
210 } else { 210 } else {
211 if (endOffset > 0) 211 if (endOffset > 0)
212 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); 212 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset);
213 if (startOffset < truncationPoint) 213 if (startOffset < truncationPoint)
214 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoin t); 214 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoin t);
215 } 215 }
216 } 216 }
217 217
218 void TextPainter::paintEmphasisMarkForCombinedText() 218 void TextPainter::paintEmphasisMarkForCombinedText()
219 { 219 {
220 ASSERT(m_combinedText); 220 ASSERT(m_combinedText);
221 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStopCharac ter, 1)); 221 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStopCharac ter, 1));
222 FloatPoint emphasisMarkTextOrigin(m_textBounds.x(), m_textBounds.y() + m_fon t.fontMetrics().ascent() + m_emphasisMarkOffset); 222 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y ().toFloat() + m_font.fontMetrics().ascent() + m_emphasisMarkOffset);
223 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); 223 TextRunPaintInfo textRunPaintInfo(placeholderTextRun);
224 textRunPaintInfo.bounds = m_textBounds; 224 textRunPaintInfo.bounds = m_textBounds;
225 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise)); 225 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise));
226 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin); 226 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin);
227 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise)); 227 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise));
228 } 228 }
229 229
230 } // namespace blink 230 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/TextPainter.h ('k') | Source/modules/accessibility/AXInlineTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698