| 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/InlineTextBoxPainter.h" | 5 #include "core/paint/InlineTextBoxPainter.h" |
| 6 | 6 |
| 7 #include "core/editing/CompositionUnderline.h" | 7 #include "core/editing/CompositionUnderline.h" |
| 8 #include "core/editing/Editor.h" | 8 #include "core/editing/Editor.h" |
| 9 #include "core/editing/markers/DocumentMarkerController.h" | 9 #include "core/editing/markers/DocumentMarkerController.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 bool InlineTextBoxPainter::paintsMarkerHighlights( | 383 bool InlineTextBoxPainter::paintsMarkerHighlights( |
| 384 const LayoutObject& layoutObject) { | 384 const LayoutObject& layoutObject) { |
| 385 return layoutObject.node() && | 385 return layoutObject.node() && |
| 386 layoutObject.document().markers().hasMarkers(layoutObject.node()); | 386 layoutObject.document().markers().hasMarkers(layoutObject.node()); |
| 387 } | 387 } |
| 388 | 388 |
| 389 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { | 389 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { |
| 390 return layoutObject.node() && | 390 return layoutObject.node() && |
| 391 layoutObject.document() | 391 layoutObject.document() |
| 392 .markers() | 392 .markers() |
| 393 .markersFor(layoutObject.node(), DocumentMarker::Composition) | 393 .markersFor(layoutObject.node(), |
| 394 DocumentMarker::Composition | |
| 395 DocumentMarker::PersistingComposition) |
| 394 .size() > 0; | 396 .size() > 0; |
| 395 } | 397 } |
| 396 | 398 |
| 397 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, | 399 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, |
| 398 const LayoutPoint& paintOffset) { | 400 const LayoutPoint& paintOffset) { |
| 399 if (!shouldPaintTextBox(paintInfo)) | 401 if (!shouldPaintTextBox(paintInfo)) |
| 400 return; | 402 return; |
| 401 | 403 |
| 402 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && | 404 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && |
| 403 !shouldPaintDescendantOutlines(paintInfo.phase)); | 405 !shouldPaintDescendantOutlines(paintInfo.phase)); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // Paint either the background markers or the foreground markers, but not | 758 // Paint either the background markers or the foreground markers, but not |
| 757 // both. | 759 // both. |
| 758 switch (marker.type()) { | 760 switch (marker.type()) { |
| 759 case DocumentMarker::Grammar: | 761 case DocumentMarker::Grammar: |
| 760 case DocumentMarker::Spelling: | 762 case DocumentMarker::Spelling: |
| 761 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 763 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 762 continue; | 764 continue; |
| 763 break; | 765 break; |
| 764 case DocumentMarker::TextMatch: | 766 case DocumentMarker::TextMatch: |
| 765 case DocumentMarker::Composition: | 767 case DocumentMarker::Composition: |
| 768 case DocumentMarker::PersistingComposition: |
| 766 break; | 769 break; |
| 767 default: | 770 default: |
| 768 continue; | 771 continue; |
| 769 } | 772 } |
| 770 | 773 |
| 771 if (marker.endOffset() <= m_inlineTextBox.start()) { | 774 if (marker.endOffset() <= m_inlineTextBox.start()) { |
| 772 // marker is completely before this run. This might be a marker that sits | 775 // marker is completely before this run. This might be a marker that sits |
| 773 // before the first run we draw, or markers that were within runs we | 776 // before the first run we draw, or markers that were within runs we |
| 774 // skipped due to truncation. | 777 // skipped due to truncation. |
| 775 continue; | 778 continue; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 790 marker, style, font, true); | 793 marker, style, font, true); |
| 791 break; | 794 break; |
| 792 case DocumentMarker::TextMatch: | 795 case DocumentMarker::TextMatch: |
| 793 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 796 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 794 m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, | 797 m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, |
| 795 marker, style, font); | 798 marker, style, font); |
| 796 else | 799 else |
| 797 m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, | 800 m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, |
| 798 marker, style, font); | 801 marker, style, font); |
| 799 break; | 802 break; |
| 800 case DocumentMarker::Composition: { | 803 case DocumentMarker::Composition: |
| 801 CompositionUnderline underline(marker.startOffset(), marker.endOffset(), | 804 case DocumentMarker::PersistingComposition: { |
| 802 marker.underlineColor(), marker.thick(), | 805 CompositionUnderline underline( |
| 803 marker.backgroundColor()); | 806 marker.startOffset(), marker.endOffset(), marker.underlineColor(), |
| 807 marker.thick(), marker.backgroundColor(), |
| 808 (marker.type() == DocumentMarker::PersistingComposition)); |
| 804 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 809 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 805 paintSingleCompositionBackgroundRun( | 810 paintSingleCompositionBackgroundRun( |
| 806 paintInfo.context, boxOrigin, style, font, | 811 paintInfo.context, boxOrigin, style, font, |
| 807 underline.backgroundColor(), underlinePaintStart(underline), | 812 underline.backgroundColor(), underlinePaintStart(underline), |
| 808 underlinePaintEnd(underline)); | 813 underlinePaintEnd(underline)); |
| 809 else | 814 else |
| 810 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); | 815 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); |
| 811 } break; | 816 } break; |
| 812 default: | 817 default: |
| 813 ASSERT_NOT_REACHED(); | 818 ASSERT_NOT_REACHED(); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1281 |
| 1277 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), | 1282 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), |
| 1278 m_inlineTextBox.logicalHeight())); | 1283 m_inlineTextBox.logicalHeight())); |
| 1279 context.clip(FloatRect(boxRect)); | 1284 context.clip(FloatRect(boxRect)); |
| 1280 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), | 1285 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), |
| 1281 boxRect.height().toInt(), color, | 1286 boxRect.height().toInt(), color, |
| 1282 paintOffsets.first, paintOffsets.second); | 1287 paintOffsets.first, paintOffsets.second); |
| 1283 } | 1288 } |
| 1284 | 1289 |
| 1285 } // namespace blink | 1290 } // namespace blink |
| OLD | NEW |