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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/InlineTextBoxPainter.h" | 6 #include "core/paint/InlineTextBoxPainter.h" |
7 | 7 |
8 #include "core/editing/CompositionUnderline.h" | 8 #include "core/editing/CompositionUnderline.h" |
9 #include "core/editing/CompositionUnderlineRangeFilter.h" | |
10 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
11 #include "core/editing/InputMethodController.h" | |
12 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
13 #include "core/editing/markers/RenderedDocumentMarker.h" | 11 #include "core/editing/markers/RenderedDocumentMarker.h" |
14 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
15 #include "core/layout/LayoutBlock.h" | 13 #include "core/layout/LayoutBlock.h" |
16 #include "core/layout/LayoutTextCombine.h" | 14 #include "core/layout/LayoutTextCombine.h" |
17 #include "core/layout/LayoutTheme.h" | 15 #include "core/layout/LayoutTheme.h" |
18 #include "core/layout/line/InlineTextBox.h" | 16 #include "core/layout/line/InlineTextBox.h" |
19 #include "core/paint/BoxPainter.h" | 17 #include "core/paint/BoxPainter.h" |
20 #include "core/paint/PaintInfo.h" | 18 #include "core/paint/PaintInfo.h" |
21 #include "core/paint/TextPainter.h" | 19 #include "core/paint/TextPainter.h" |
(...skipping 19 matching lines...) Expand all Loading... |
41 if (!gTextBlobCache) | 39 if (!gTextBlobCache) |
42 gTextBlobCache = new InlineTextBoxBlobCacheMap; | 40 gTextBlobCache = new InlineTextBoxBlobCacheMap; |
43 return &gTextBlobCache->add(&inlineTextBox, nullptr).storedValue->value; | 41 return &gTextBlobCache->add(&inlineTextBox, nullptr).storedValue->value; |
44 } | 42 } |
45 | 43 |
46 static bool paintsMarkerHighlights(const LayoutObject& layoutObject) | 44 static bool paintsMarkerHighlights(const LayoutObject& layoutObject) |
47 { | 45 { |
48 return layoutObject.node() && layoutObject.document().markers().hasMarkers(l
ayoutObject.node()); | 46 return layoutObject.node() && layoutObject.document().markers().hasMarkers(l
ayoutObject.node()); |
49 } | 47 } |
50 | 48 |
| 49 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) |
| 50 { |
| 51 return layoutObject.node() && layoutObject.document().markers().markersFor(l
ayoutObject.node(), DocumentMarker::Composition).size() > 0; |
| 52 } |
| 53 |
51 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 54 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
52 { | 55 { |
53 if (m_inlineTextBox.isLineBreak() || !paintInfo.shouldPaintWithinRoot(&m_inl
ineTextBox.layoutObject()) || m_inlineTextBox.layoutObject().style()->visibility
() != VISIBLE || m_inlineTextBox.truncation() == cFullTruncation || !m_inlineTex
tBox.len()) | 56 if (m_inlineTextBox.isLineBreak() || !paintInfo.shouldPaintWithinRoot(&m_inl
ineTextBox.layoutObject()) || m_inlineTextBox.layoutObject().style()->visibility
() != VISIBLE || m_inlineTextBox.truncation() == cFullTruncation || !m_inlineTex
tBox.len()) |
54 return; | 57 return; |
55 | 58 |
56 ASSERT(paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhase
SelfOutline && paintInfo.phase != PaintPhaseChildOutlines); | 59 ASSERT(paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhase
SelfOutline && paintInfo.phase != PaintPhaseChildOutlines); |
57 | 60 |
58 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect(); | 61 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect(); |
59 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor
izontal() ? paintOffset.x() : paintOffset.y()); | 62 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor
izontal() ? paintOffset.x() : paintOffset.y()); |
60 LayoutUnit logicalExtent = logicalVisualOverflow.width(); | 63 LayoutUnit logicalExtent = logicalVisualOverflow.width(); |
61 | 64 |
62 LayoutUnit paintEnd = m_inlineTextBox.isHorizontal() ? paintInfo.rect.maxX()
: paintInfo.rect.maxY(); | 65 LayoutUnit paintEnd = m_inlineTextBox.isHorizontal() ? paintInfo.rect.maxX()
: paintInfo.rect.maxY(); |
63 LayoutUnit paintStart = m_inlineTextBox.isHorizontal() ? paintInfo.rect.x()
: paintInfo.rect.y(); | 66 LayoutUnit paintStart = m_inlineTextBox.isHorizontal() ? paintInfo.rect.x()
: paintInfo.rect.y(); |
64 | 67 |
65 // We round the y-axis to ensure consistent line heights. | 68 // We round the y-axis to ensure consistent line heights. |
66 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), paintOffset.y
().round()); | 69 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), paintOffset.y
().round()); |
67 | 70 |
68 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) | 71 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) |
69 return; | 72 return; |
70 | 73 |
71 bool isPrinting = paintInfo.isPrinting(); | 74 bool isPrinting = paintInfo.isPrinting(); |
72 | 75 |
73 // Determine whether or not we're selected. | 76 // Determine whether or not we're selected. |
74 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != SelectionNone; | 77 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != SelectionNone; |
75 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { | 78 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { |
76 // When only painting the selection, don't bother to paint if there is n
one. | 79 // When only painting the selection, don't bother to paint if there is n
one. |
77 return; | 80 return; |
78 } | 81 } |
79 | 82 |
80 // Determine whether or not we have composition underlines to draw. | |
81 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline
TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i
nlineTextBox.layoutObject().node(); | |
82 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje
ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); | |
83 | |
84 // The text clip phase already has a DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already | 83 // The text clip phase already has a DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already |
85 // within a DrawingRecorder. | 84 // within a DrawingRecorder. |
86 Optional<DrawingRecorder> drawingRecorder; | 85 Optional<DrawingRecorder> drawingRecorder; |
87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { | 86 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { |
88 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) | 87 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) |
89 return; | 88 return; |
90 LayoutRect paintRect(logicalVisualOverflow); | 89 LayoutRect paintRect(logicalVisualOverflow); |
91 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); | 90 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); |
92 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains
Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) | 91 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa
rkerHighlights(m_inlineTextBox.layoutObject()))) |
93 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); | 92 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); |
94 paintRect.moveBy(adjustedPaintOffset); | 93 paintRect.moveBy(adjustedPaintOffset); |
95 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem
::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); | 94 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem
::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); |
96 } | 95 } |
97 | 96 |
98 if (m_inlineTextBox.truncation() != cNoTruncation) { | 97 if (m_inlineTextBox.truncation() != cNoTruncation) { |
99 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { | 98 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { |
100 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 99 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
101 // at which we start drawing text. | 100 // at which we start drawing text. |
102 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 101 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se
lectionStyle; | 143 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se
lectionStyle; |
145 | 144 |
146 // Set our font. | 145 // Set our font. |
147 const Font& font = styleToUse.font(); | 146 const Font& font = styleToUse.font(); |
148 | 147 |
149 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc
ent()); | 148 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc
ent()); |
150 | 149 |
151 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection | 150 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection |
152 // and composition highlights. | 151 // and composition highlights. |
153 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT
extClip && !isPrinting) { | 152 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT
extClip && !isPrinting) { |
154 if (containsComposition) { | |
155 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us
eCustomUnderlines); | |
156 } | |
157 | |
158 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); | 153 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); |
159 | 154 |
160 if (haveSelection && !useCustomUnderlines) { | 155 if (haveSelection && !paintsCompositionMarkers(m_inlineTextBox.layoutObj
ect())) { |
161 if (combinedText) | 156 if (combinedText) |
162 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText>
(context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); | 157 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText>
(context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); |
163 else | 158 else |
164 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte
xt, boxRect, styleToUse, font, selectionStyle.fillColor); | 159 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte
xt, boxRect, styleToUse, font, selectionStyle.fillColor); |
165 } | 160 } |
166 } | 161 } |
167 | 162 |
168 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). | 163 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). |
169 int length = m_inlineTextBox.len(); | 164 int length = m_inlineTextBox.len(); |
170 StringView string = m_inlineTextBox.layoutObject().text().createView(); | 165 StringView string = m_inlineTextBox.layoutObject().text().createView(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { | 229 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { |
235 GraphicsContextStateSaver stateSaver(*context, false); | 230 GraphicsContextStateSaver stateSaver(*context, false); |
236 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i
sHorizontal(), stateSaver); | 231 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i
sHorizontal(), stateSaver); |
237 if (combinedText) | 232 if (combinedText) |
238 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock
wise)); | 233 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock
wise)); |
239 paintDecoration(paintInfo, boxOrigin, textDecorations); | 234 paintDecoration(paintInfo, boxOrigin, textDecorations); |
240 if (combinedText) | 235 if (combinedText) |
241 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count
erclockwise)); | 236 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count
erclockwise)); |
242 } | 237 } |
243 | 238 |
244 if (paintInfo.phase == PaintPhaseForeground) { | 239 if (paintInfo.phase == PaintPhaseForeground) |
245 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); | 240 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); |
246 | 241 |
247 // Paint custom underlines for compositions. | |
248 if (useCustomUnderlines) { | |
249 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.lay
outObject().frame()->inputMethodController().customCompositionUnderlines(); | |
250 CompositionUnderlineRangeFilter filter(underlines, m_inlineTextBox.s
tart(), m_inlineTextBox.end()); | |
251 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begi
n(); it != filter.end(); ++it) { | |
252 if (it->color == Color::transparent) | |
253 continue; | |
254 paintCompositionUnderline(context, boxOrigin, *it); | |
255 } | |
256 } | |
257 } | |
258 | |
259 if (shouldRotate) | 242 if (shouldRotate) |
260 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Countercl
ockwise)); | 243 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Countercl
ockwise)); |
261 } | 244 } |
262 | 245 |
263 unsigned InlineTextBoxPainter::underlinePaintStart(const CompositionUnderline& u
nderline) | 246 unsigned InlineTextBoxPainter::underlinePaintStart(const CompositionUnderline& u
nderline) |
264 { | 247 { |
265 return std::max(static_cast<unsigned>(m_inlineTextBox.start()), underline.st
artOffset); | 248 return std::max(static_cast<unsigned>(m_inlineTextBox.start()), underline.st
artOffset); |
266 } | 249 } |
267 | 250 |
268 unsigned InlineTextBoxPainter::underlinePaintEnd(const CompositionUnderline& und
erline) | 251 unsigned InlineTextBoxPainter::underlinePaintEnd(const CompositionUnderline& und
erline) |
269 { | 252 { |
270 unsigned paintEnd = std::min(m_inlineTextBox.end() + 1, underline.endOffset)
; // end() points at the last char, not past it. | 253 unsigned paintEnd = std::min(m_inlineTextBox.end() + 1, underline.endOffset)
; // end() points at the last char, not past it. |
271 if (m_inlineTextBox.truncation() != cNoTruncation) | 254 if (m_inlineTextBox.truncation() != cNoTruncation) |
272 paintEnd = std::min(paintEnd, static_cast<unsigned>(m_inlineTextBox.star
t() + m_inlineTextBox.truncation())); | 255 paintEnd = std::min(paintEnd, static_cast<unsigned>(m_inlineTextBox.star
t() + m_inlineTextBox.truncation())); |
273 return paintEnd; | 256 return paintEnd; |
274 } | 257 } |
275 | 258 |
276 void InlineTextBoxPainter::paintCompositionBackgrounds(GraphicsContext* pt, cons
t LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool use
CustomUnderlines) | |
277 { | |
278 if (useCustomUnderlines) { | |
279 // Paint custom background highlights for compositions. | |
280 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.layoutO
bject().frame()->inputMethodController().customCompositionUnderlines(); | |
281 CompositionUnderlineRangeFilter filter(underlines, m_inlineTextBox.start
(), m_inlineTextBox.end()); | |
282 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begin();
it != filter.end(); ++it) { | |
283 if (it->backgroundColor == Color::transparent) | |
284 continue; | |
285 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, font, it->
backgroundColor, underlinePaintStart(*it), underlinePaintEnd(*it)); | |
286 } | |
287 | |
288 } else { | |
289 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, font, LayoutTh
eme::theme().platformDefaultCompositionBackgroundColor(), | |
290 m_inlineTextBox.layoutObject().frame()->inputMethodController().comp
ositionStart(), | |
291 m_inlineTextBox.layoutObject().frame()->inputMethodController().comp
ositionEnd()); | |
292 } | |
293 } | |
294 | |
295 void InlineTextBoxPainter::paintSingleCompositionBackgroundRun(GraphicsContext*
context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& f
ont, Color backgroundColor, int startPos, int endPos) | 259 void InlineTextBoxPainter::paintSingleCompositionBackgroundRun(GraphicsContext*
context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& f
ont, Color backgroundColor, int startPos, int endPos) |
296 { | 260 { |
| 261 if (backgroundColor == Color::transparent) |
| 262 return; |
| 263 |
297 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0)
; | 264 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0)
; |
298 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat
ic_cast<int>(m_inlineTextBox.len())); | 265 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat
ic_cast<int>(m_inlineTextBox.len())); |
299 if (sPos >= ePos) | 266 if (sPos >= ePos) |
300 return; | 267 return; |
301 | 268 |
302 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo
de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom(
) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); | 269 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo
de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom(
) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); |
303 int selHeight = m_inlineTextBox.root().selectionHeight(); | 270 int selHeight = m_inlineTextBox.root().selectionHeight(); |
304 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de
ltaY); | 271 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de
ltaY); |
305 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style,
font), localOrigin, selHeight, backgroundColor, sPos, ePos); | 272 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style,
font), localOrigin, selHeight, backgroundColor, sPos, ePos); |
306 } | 273 } |
(...skipping 15 matching lines...) Expand all Loading... |
322 switch (marker->type()) { | 289 switch (marker->type()) { |
323 case DocumentMarker::Grammar: | 290 case DocumentMarker::Grammar: |
324 case DocumentMarker::Spelling: | 291 case DocumentMarker::Spelling: |
325 if (background) | 292 if (background) |
326 continue; | 293 continue; |
327 break; | 294 break; |
328 case DocumentMarker::TextMatch: | 295 case DocumentMarker::TextMatch: |
329 if (!background) | 296 if (!background) |
330 continue; | 297 continue; |
331 break; | 298 break; |
| 299 case DocumentMarker::Composition: |
| 300 break; |
332 default: | 301 default: |
333 continue; | 302 continue; |
334 } | 303 } |
335 | 304 |
336 if (marker->endOffset() <= m_inlineTextBox.start()) { | 305 if (marker->endOffset() <= m_inlineTextBox.start()) { |
337 // marker is completely before this run. This might be a marker tha
t sits before the | 306 // marker is completely before this run. This might be a marker tha
t sits before the |
338 // first run we draw, or markers that were within runs we skipped du
e to truncation. | 307 // first run we draw, or markers that were within runs we skipped du
e to truncation. |
339 continue; | 308 continue; |
340 } | 309 } |
341 if (marker->startOffset() > m_inlineTextBox.end()) { | 310 if (marker->startOffset() > m_inlineTextBox.end()) { |
342 // marker is completely after this run, bail. A later run will pain
t it. | 311 // marker is completely after this run, bail. A later run will pain
t it. |
343 break; | 312 break; |
344 } | 313 } |
345 | 314 |
346 // marker intersects this run. Paint it. | 315 // marker intersects this run. Paint it. |
347 switch (marker->type()) { | 316 switch (marker->type()) { |
348 case DocumentMarker::Spelling: | 317 case DocumentMarker::Spelling: |
349 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo
nt, false); | 318 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo
nt, false); |
350 break; | 319 break; |
351 case DocumentMarker::Grammar: | 320 case DocumentMarker::Grammar: |
352 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo
nt, true); | 321 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo
nt, true); |
353 break; | 322 break; |
354 case DocumentMarker::TextMatch: | 323 case DocumentMarker::TextMatch: |
355 m_inlineTextBox.paintTextMatchMarker(pt, boxOrigin, marker, style, f
ont); | 324 m_inlineTextBox.paintTextMatchMarker(pt, boxOrigin, marker, style, f
ont); |
356 break; | 325 break; |
| 326 case DocumentMarker::Composition: |
| 327 { |
| 328 CompositionUnderline underline(marker->startOffset(), marker->en
dOffset(), marker->underlineColor(), marker->thick(), marker->backgroundColor())
; |
| 329 if (background) |
| 330 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, fo
nt, underline.backgroundColor, underlinePaintStart(underline), underlinePaintEnd
(underline)); |
| 331 else |
| 332 paintCompositionUnderline(pt, boxOrigin, underline); |
| 333 } |
| 334 break; |
357 default: | 335 default: |
358 ASSERT_NOT_REACHED(); | 336 ASSERT_NOT_REACHED(); |
359 } | 337 } |
360 } | 338 } |
361 } | 339 } |
362 | 340 |
363 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM
arker::MarkerType markerType) | 341 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM
arker::MarkerType markerType) |
364 { | 342 { |
365 switch (markerType) { | 343 switch (markerType) { |
366 case DocumentMarker::Spelling: | 344 case DocumentMarker::Spelling: |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 paintAppliedDecoration(context, FloatPoint(localOrigin), width.toFloat()
, -doubleOffset, 1, overline, textDecorationThickness, antialiasDecoration, isPr
inting); | 735 paintAppliedDecoration(context, FloatPoint(localOrigin), width.toFloat()
, -doubleOffset, 1, overline, textDecorationThickness, antialiasDecoration, isPr
inting); |
758 } | 736 } |
759 if (deco & TextDecorationLineThrough) { | 737 if (deco & TextDecorationLineThrough) { |
760 const float lineThroughOffset = 2 * baseline / 3; | 738 const float lineThroughOffset = 2 * baseline / 3; |
761 paintAppliedDecoration(context, FloatPoint(localOrigin) + FloatPoint(0,
lineThroughOffset), width.toFloat(), doubleOffset, 0, linethrough, textDecoratio
nThickness, antialiasDecoration, isPrinting); | 739 paintAppliedDecoration(context, FloatPoint(localOrigin) + FloatPoint(0,
lineThroughOffset), width.toFloat(), doubleOffset, 0, linethrough, textDecoratio
nThickness, antialiasDecoration, isPrinting); |
762 } | 740 } |
763 } | 741 } |
764 | 742 |
765 void InlineTextBoxPainter::paintCompositionUnderline(GraphicsContext* ctx, const
LayoutPoint& boxOrigin, const CompositionUnderline& underline) | 743 void InlineTextBoxPainter::paintCompositionUnderline(GraphicsContext* ctx, const
LayoutPoint& boxOrigin, const CompositionUnderline& underline) |
766 { | 744 { |
| 745 if (underline.color == Color::transparent) |
| 746 return; |
| 747 |
767 if (m_inlineTextBox.truncation() == cFullTruncation) | 748 if (m_inlineTextBox.truncation() == cFullTruncation) |
768 return; | 749 return; |
769 | 750 |
770 unsigned paintStart = underlinePaintStart(underline); | 751 unsigned paintStart = underlinePaintStart(underline); |
771 unsigned paintEnd = underlinePaintEnd(underline); | 752 unsigned paintEnd = underlinePaintEnd(underline); |
772 | 753 |
773 // start of line to draw, relative to paintOffset. | 754 // start of line to draw, relative to paintOffset. |
774 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ?
0 : | 755 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ?
0 : |
775 m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), paintStart
- m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR
ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); | 756 m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), paintStart
- m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR
ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); |
776 // how much line to draw | 757 // how much line to draw |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); | 809 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); |
829 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); | 810 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); |
830 | 811 |
831 textPainter.paint(sPos, ePos, length, textStyle, 0); | 812 textPainter.paint(sPos, ePos, length, textStyle, 0); |
832 } | 813 } |
833 } | 814 } |
834 } | 815 } |
835 | 816 |
836 | 817 |
837 } // namespace blink | 818 } // namespace blink |
OLD | NEW |