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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 textRunPaintInfo.cachedTextBlob = cachedTextBlob; | 246 textRunPaintInfo.cachedTextBlob = cachedTextBlob; |
247 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); | 247 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); |
248 } else { | 248 } else { |
249 if (endOffset > 0) | 249 if (endOffset > 0) |
250 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); | 250 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); |
251 if (startOffset < truncationPoint) | 251 if (startOffset < truncationPoint) |
252 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); | 252 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
| 256 void TextPainter::clipDecorationsStripe(float upper, |
| 257 float stripeWidth, |
| 258 float dilation) { |
| 259 TextRunPaintInfo textRunPaintInfo(m_run); |
| 260 |
| 261 if (!m_run.length()) |
| 262 return; |
| 263 |
| 264 Vector<Font::TextIntercept> textIntercepts; |
| 265 m_font.getTextIntercepts( |
| 266 textRunPaintInfo, m_graphicsContext.deviceScaleFactor(), |
| 267 m_graphicsContext.fillPaint(), |
| 268 std::make_tuple(upper, upper + stripeWidth), textIntercepts); |
| 269 |
| 270 for (auto intercept : textIntercepts) { |
| 271 FloatPoint clipOrigin(m_textOrigin); |
| 272 FloatRect clipRect( |
| 273 clipOrigin + FloatPoint(intercept.m_begin, upper), |
| 274 FloatSize(intercept.m_end - intercept.m_begin, stripeWidth)); |
| 275 clipRect.inflateX(dilation); |
| 276 // We need to ensure the clip rectangle is covering the full underline |
| 277 // extent. For horizontal drawing, using enclosingIntRect would be |
| 278 // sufficient, since we can clamp to full device pixels that way. However, |
| 279 // for vertical drawing, we have a transformation applied, which breaks the |
| 280 // integers-equal-device pixels assumption, so vertically inflating by 1 |
| 281 // pixel makes sure we're always covering. This should only be done on the |
| 282 // clipping rectangle, not when computing the glyph intersects. |
| 283 clipRect.inflateY(1.0); |
| 284 m_graphicsContext.clipOut(clipRect); |
| 285 } |
| 286 } |
| 287 |
256 void TextPainter::paintEmphasisMarkForCombinedText() { | 288 void TextPainter::paintEmphasisMarkForCombinedText() { |
257 const SimpleFontData* fontData = m_font.primaryFont(); | 289 const SimpleFontData* fontData = m_font.primaryFont(); |
258 DCHECK(fontData); | 290 DCHECK(fontData); |
259 if (!fontData) | 291 if (!fontData) |
260 return; | 292 return; |
261 | 293 |
262 DCHECK(m_combinedText); | 294 DCHECK(m_combinedText); |
263 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); | 295 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); |
264 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), | 296 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), |
265 m_textBounds.y().toFloat() + | 297 m_textBounds.y().toFloat() + |
266 fontData->getFontMetrics().ascent() + | 298 fontData->getFontMetrics().ascent() + |
267 m_emphasisMarkOffset); | 299 m_emphasisMarkOffset); |
268 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); | 300 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); |
269 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 301 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
270 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); | 302 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); |
271 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), | 303 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), |
272 textRunPaintInfo, m_emphasisMark, | 304 textRunPaintInfo, m_emphasisMark, |
273 emphasisMarkTextOrigin); | 305 emphasisMarkTextOrigin); |
274 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); | 306 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); |
275 } | 307 } |
276 | 308 |
277 } // namespace blink | 309 } // namespace blink |
OLD | NEW |