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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 textRunPaintInfo.cachedTextBlob = cachedTextBlob; | 245 textRunPaintInfo.cachedTextBlob = cachedTextBlob; |
246 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); | 246 paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); |
247 } else { | 247 } else { |
248 if (endOffset > 0) | 248 if (endOffset > 0) |
249 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); | 249 paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); |
250 if (startOffset < truncationPoint) | 250 if (startOffset < truncationPoint) |
251 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); | 251 paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 void TextPainter::clipDecorationsStripe(float upper, | |
256 float stripeWidth, | |
257 float dilation) { | |
258 TextRunPaintInfo textRunPaintInfo(m_run); | |
259 | |
260 if (!m_run.length()) | |
261 return; | |
262 | |
263 SkScalar lineBounds[] = {upper, upper + stripeWidth}; | |
264 const int numIntervals = m_graphicsContext.getTextIntercepts( | |
265 m_font, textRunPaintInfo, lineBounds, nullptr); | |
266 SkScalar intervals[numIntervals]; | |
267 m_graphicsContext.getTextIntercepts(m_font, textRunPaintInfo, lineBounds, | |
268 intervals); | |
269 | |
270 for (int i = 0; i < numIntervals; i += 2) { | |
eae
2016/10/13 18:18:54
Do we want to assert that the number of intervals
drott
2016/10/13 18:39:29
Makes sense, adding an assert.
| |
271 FloatPoint clipOrigin(m_textOrigin); | |
272 FloatRect clipRect(clipOrigin + FloatPoint(intervals[i], upper), | |
273 FloatSize(intervals[i + 1] - intervals[i], stripeWidth)); | |
274 clipRect.inflateX(dilation); | |
275 clipRect = enclosingIntRect(clipRect); | |
276 m_graphicsContext.setFillColor(Color(127, 0, 0, 127)); | |
eae
2016/10/13 18:18:54
Hard coded color? This is temporary, right?
drott
2016/10/13 18:39:29
Yep, the whole paintRect can go, and no color sett
| |
277 FloatRect paintClipRect(clipRect); | |
278 paintClipRect.inflateX(clipRect.width() * -0.25); | |
eae
2016/10/13 18:18:54
Please add a comment explaining the 0.25 value.
| |
279 // m_graphicsContext.fillRect(paintClipRect); | |
280 m_graphicsContext.clipOut(clipRect); | |
281 } | |
282 } | |
283 | |
255 void TextPainter::paintEmphasisMarkForCombinedText() { | 284 void TextPainter::paintEmphasisMarkForCombinedText() { |
256 ASSERT(m_combinedText); | 285 ASSERT(m_combinedText); |
257 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); | 286 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); |
258 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), | 287 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), |
259 m_textBounds.y().toFloat() + | 288 m_textBounds.y().toFloat() + |
260 m_font.getFontMetrics().ascent() + | 289 m_font.getFontMetrics().ascent() + |
261 m_emphasisMarkOffset); | 290 m_emphasisMarkOffset); |
262 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); | 291 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); |
263 textRunPaintInfo.bounds = FloatRect(m_textBounds); | 292 textRunPaintInfo.bounds = FloatRect(m_textBounds); |
264 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); | 293 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); |
265 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), | 294 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), |
266 textRunPaintInfo, m_emphasisMark, | 295 textRunPaintInfo, m_emphasisMark, |
267 emphasisMarkTextOrigin); | 296 emphasisMarkTextOrigin); |
268 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); | 297 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); |
269 } | 298 } |
270 | 299 |
271 } // namespace blink | 300 } // namespace blink |
OLD | NEW |