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 29 matching lines...) Expand all Loading... |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 void TextPainter::setEmphasisMark(const AtomicString& emphasisMark, TextEmphasis
Position position) | 43 void TextPainter::setEmphasisMark(const AtomicString& emphasisMark, TextEmphasis
Position position) |
44 { | 44 { |
45 m_emphasisMark = emphasisMark; | 45 m_emphasisMark = emphasisMark; |
46 | 46 |
47 if (emphasisMark.isNull()) { | 47 if (emphasisMark.isNull()) { |
48 m_emphasisMarkOffset = 0; | 48 m_emphasisMarkOffset = 0; |
49 } else if (position == TextEmphasisPositionOver) { | 49 } else if (position == TextEmphasisPositionOver) { |
50 m_emphasisMarkOffset = -m_font.fontMetrics().ascent() - m_font.emphasisM
arkDescent(emphasisMark); | 50 m_emphasisMarkOffset = -m_font.getFontMetrics().ascent() - m_font.emphas
isMarkDescent(emphasisMark); |
51 } else { | 51 } else { |
52 ASSERT(position == TextEmphasisPositionUnder); | 52 ASSERT(position == TextEmphasisPositionUnder); |
53 m_emphasisMarkOffset = m_font.fontMetrics().descent() + m_font.emphasisM
arkAscent(emphasisMark); | 53 m_emphasisMarkOffset = m_font.getFontMetrics().descent() + m_font.emphas
isMarkAscent(emphasisMark); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 void TextPainter::paint(int startOffset, int endOffset, int length, const Style&
textStyle, TextBlobPtr* cachedTextBlob) | 57 void TextPainter::paint(int startOffset, int endOffset, int length, const Style&
textStyle, TextBlobPtr* cachedTextBlob) |
58 { | 58 { |
59 GraphicsContextStateSaver stateSaver(m_graphicsContext, false); | 59 GraphicsContextStateSaver stateSaver(m_graphicsContext, false); |
60 updateGraphicsContext(textStyle, stateSaver); | 60 updateGraphicsContext(textStyle, stateSaver); |
61 if (m_combinedText) { | 61 if (m_combinedText) { |
62 m_graphicsContext.save(); | 62 m_graphicsContext.save(); |
63 m_combinedText->transformToInlineCoordinates(m_graphicsContext, m_textBo
unds); | 63 m_combinedText->transformToInlineCoordinates(m_graphicsContext, m_textBo
unds); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); | 214 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); |
215 if (startOffset < truncationPoint) | 215 if (startOffset < truncationPoint) |
216 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoin
t); | 216 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoin
t); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 void TextPainter::paintEmphasisMarkForCombinedText() | 220 void TextPainter::paintEmphasisMarkForCombinedText() |
221 { | 221 { |
222 ASSERT(m_combinedText); | 222 ASSERT(m_combinedText); |
223 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); | 223 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); |
224 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y
().toFloat() + m_font.fontMetrics().ascent() + m_emphasisMarkOffset); | 224 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y
().toFloat() + m_font.getFontMetrics().ascent() + m_emphasisMarkOffset); |
225 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); | 225 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); |
226 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 226 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
227 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); | 227 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); |
228 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), textRunP
aintInfo, m_emphasisMark, emphasisMarkTextOrigin); | 228 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), textRunP
aintInfo, m_emphasisMark, emphasisMarkTextOrigin); |
229 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); | 229 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); |
230 } | 230 } |
231 | 231 |
232 } // namespace blink | 232 } // namespace blink |
OLD | NEW |