OLD | NEW |
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 "core/paint/TextPainter.h" | 5 #include "core/paint/TextPainter.h" |
6 | 6 |
7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/layout/LayoutObject.h" | 9 #include "core/layout/LayoutObject.h" |
10 #include "core/layout/LayoutTextCombine.h" | 10 #include "core/layout/LayoutTextCombine.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const LayoutPoint& textOrigin, | 29 const LayoutPoint& textOrigin, |
30 const LayoutRect& textBounds, | 30 const LayoutRect& textBounds, |
31 bool horizontal) | 31 bool horizontal) |
32 : m_graphicsContext(context), | 32 : m_graphicsContext(context), |
33 m_font(font), | 33 m_font(font), |
34 m_run(run), | 34 m_run(run), |
35 m_textOrigin(textOrigin), | 35 m_textOrigin(textOrigin), |
36 m_textBounds(textBounds), | 36 m_textBounds(textBounds), |
37 m_horizontal(horizontal), | 37 m_horizontal(horizontal), |
38 m_emphasisMarkOffset(0), | 38 m_emphasisMarkOffset(0), |
39 m_combinedText(0), | 39 m_combinedText(0) {} |
40 m_ellipsisOffset(0) {} | |
41 | 40 |
42 TextPainter::~TextPainter() {} | 41 TextPainter::~TextPainter() {} |
43 | 42 |
44 void TextPainter::setEmphasisMark(const AtomicString& emphasisMark, | 43 void TextPainter::setEmphasisMark(const AtomicString& emphasisMark, |
45 TextEmphasisPosition position) { | 44 TextEmphasisPosition position) { |
46 m_emphasisMark = emphasisMark; | 45 m_emphasisMark = emphasisMark; |
47 const SimpleFontData* fontData = m_font.primaryFont(); | 46 const SimpleFontData* fontData = m_font.primaryFont(); |
48 DCHECK(fontData); | 47 DCHECK(fontData); |
49 | 48 |
50 if (!fontData || emphasisMark.isNull()) { | 49 if (!fontData || emphasisMark.isNull()) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 unsigned truncationPoint, | 240 unsigned truncationPoint, |
242 TextBlobPtr* cachedTextBlob) { | 241 TextBlobPtr* cachedTextBlob) { |
243 TextRunPaintInfo textRunPaintInfo(m_run); | 242 TextRunPaintInfo textRunPaintInfo(m_run); |
244 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 243 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
245 if (startOffset <= endOffset) { | 244 if (startOffset <= endOffset) { |
246 // FIXME: We should be able to use cachedTextBlob in more cases. | 245 // FIXME: We should be able to use cachedTextBlob in more cases. |
247 textRunPaintInfo.cachedTextBlob = cachedTextBlob; | 246 textRunPaintInfo.cachedTextBlob = cachedTextBlob; |
248 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); | 247 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); |
249 } else { | 248 } else { |
250 if (endOffset > 0) | 249 if (endOffset > 0) |
251 paintInternalRun<Step>(textRunPaintInfo, m_ellipsisOffset, endOffset); | 250 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); |
252 if (startOffset < truncationPoint) | 251 if (startOffset < truncationPoint) |
253 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); | 252 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); |
254 } | 253 } |
255 } | 254 } |
256 | 255 |
257 void TextPainter::clipDecorationsStripe(float upper, | 256 void TextPainter::clipDecorationsStripe(float upper, |
258 float stripeWidth, | 257 float stripeWidth, |
259 float dilation) { | 258 float dilation) { |
260 TextRunPaintInfo textRunPaintInfo(m_run); | 259 TextRunPaintInfo textRunPaintInfo(m_run); |
261 | 260 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); | 300 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); |
302 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 301 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
303 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); | 302 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); |
304 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), | 303 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), |
305 textRunPaintInfo, m_emphasisMark, | 304 textRunPaintInfo, m_emphasisMark, |
306 emphasisMarkTextOrigin); | 305 emphasisMarkTextOrigin); |
307 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); | 306 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); |
308 } | 307 } |
309 | 308 |
310 } // namespace blink | 309 } // namespace blink |
OLD | NEW |