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