| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } else { | 55 } else { |
| 56 DCHECK(position == TextEmphasisPositionUnder); | 56 DCHECK(position == TextEmphasisPositionUnder); |
| 57 m_emphasisMarkOffset = fontData->getFontMetrics().descent() + | 57 m_emphasisMarkOffset = fontData->getFontMetrics().descent() + |
| 58 m_font.emphasisMarkAscent(emphasisMark); | 58 m_font.emphasisMarkAscent(emphasisMark); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 void TextPainter::paint(unsigned startOffset, | 62 void TextPainter::paint(unsigned startOffset, |
| 63 unsigned endOffset, | 63 unsigned endOffset, |
| 64 unsigned length, | 64 unsigned length, |
| 65 const Style& textStyle, | 65 const Style& textStyle) { |
| 66 TextBlobPtr* cachedTextBlob) { | |
| 67 GraphicsContextStateSaver stateSaver(m_graphicsContext, false); | 66 GraphicsContextStateSaver stateSaver(m_graphicsContext, false); |
| 68 updateGraphicsContext(textStyle, stateSaver); | 67 updateGraphicsContext(textStyle, stateSaver); |
| 69 if (m_combinedText) { | 68 if (m_combinedText) { |
| 70 m_graphicsContext.save(); | 69 m_graphicsContext.save(); |
| 71 m_combinedText->transformToInlineCoordinates(m_graphicsContext, | 70 m_combinedText->transformToInlineCoordinates(m_graphicsContext, |
| 72 m_textBounds); | 71 m_textBounds); |
| 73 paintInternal<PaintText>(startOffset, endOffset, length, cachedTextBlob); | 72 paintInternal<PaintText>(startOffset, endOffset, length); |
| 74 m_graphicsContext.restore(); | 73 m_graphicsContext.restore(); |
| 75 } else { | 74 } else { |
| 76 paintInternal<PaintText>(startOffset, endOffset, length, cachedTextBlob); | 75 paintInternal<PaintText>(startOffset, endOffset, length); |
| 77 } | 76 } |
| 78 | 77 |
| 79 if (!m_emphasisMark.isEmpty()) { | 78 if (!m_emphasisMark.isEmpty()) { |
| 80 if (textStyle.emphasisMarkColor != textStyle.fillColor) | 79 if (textStyle.emphasisMarkColor != textStyle.fillColor) |
| 81 m_graphicsContext.setFillColor(textStyle.emphasisMarkColor); | 80 m_graphicsContext.setFillColor(textStyle.emphasisMarkColor); |
| 82 | 81 |
| 83 if (m_combinedText) | 82 if (m_combinedText) |
| 84 paintEmphasisMarkForCombinedText(); | 83 paintEmphasisMarkForCombinedText(); |
| 85 else | 84 else |
| 86 paintInternal<PaintEmphasisMark>(startOffset, endOffset, length); | 85 paintInternal<PaintEmphasisMark>(startOffset, endOffset, length); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } else { | 230 } else { |
| 232 DCHECK(step == PaintText); | 231 DCHECK(step == PaintText); |
| 233 m_graphicsContext.drawText(m_font, textRunPaintInfo, | 232 m_graphicsContext.drawText(m_font, textRunPaintInfo, |
| 234 FloatPoint(m_textOrigin)); | 233 FloatPoint(m_textOrigin)); |
| 235 } | 234 } |
| 236 } | 235 } |
| 237 | 236 |
| 238 template <TextPainter::PaintInternalStep Step> | 237 template <TextPainter::PaintInternalStep Step> |
| 239 void TextPainter::paintInternal(unsigned startOffset, | 238 void TextPainter::paintInternal(unsigned startOffset, |
| 240 unsigned endOffset, | 239 unsigned endOffset, |
| 241 unsigned truncationPoint, | 240 unsigned truncationPoint) { |
| 242 TextBlobPtr* cachedTextBlob) { | |
| 243 TextRunPaintInfo textRunPaintInfo(m_run); | 241 TextRunPaintInfo textRunPaintInfo(m_run); |
| 244 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 242 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
| 245 if (startOffset <= endOffset) { | 243 if (startOffset <= endOffset) { |
| 246 // FIXME: We should be able to use cachedTextBlob in more cases. | |
| 247 textRunPaintInfo.cachedTextBlob = cachedTextBlob; | |
| 248 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); | 244 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); |
| 249 } else { | 245 } else { |
| 250 if (endOffset > 0) | 246 if (endOffset > 0) |
| 251 paintInternalRun<Step>(textRunPaintInfo, m_ellipsisOffset, endOffset); | 247 paintInternalRun<Step>(textRunPaintInfo, m_ellipsisOffset, endOffset); |
| 252 if (startOffset < truncationPoint) | 248 if (startOffset < truncationPoint) |
| 253 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); | 249 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); |
| 254 } | 250 } |
| 255 } | 251 } |
| 256 | 252 |
| 257 void TextPainter::clipDecorationsStripe(float upper, | 253 void TextPainter::clipDecorationsStripe(float upper, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); | 297 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); |
| 302 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 298 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
| 303 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); | 299 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); |
| 304 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), | 300 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), |
| 305 textRunPaintInfo, m_emphasisMark, | 301 textRunPaintInfo, m_emphasisMark, |
| 306 emphasisMarkTextOrigin); | 302 emphasisMarkTextOrigin); |
| 307 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); | 303 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); |
| 308 } | 304 } |
| 309 | 305 |
| 310 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |