| 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/CompositionMarker.h" | 9 #include "core/editing/markers/CompositionMarker.h" |
| 10 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 bool InlineTextBoxPainter::paintsMarkerHighlights( | 454 bool InlineTextBoxPainter::paintsMarkerHighlights( |
| 455 const LayoutObject& layoutObject) { | 455 const LayoutObject& layoutObject) { |
| 456 return layoutObject.node() && | 456 return layoutObject.node() && |
| 457 layoutObject.document().markers().hasMarkers(layoutObject.node()); | 457 layoutObject.document().markers().hasMarkers(layoutObject.node()); |
| 458 } | 458 } |
| 459 | 459 |
| 460 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { | 460 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { |
| 461 return layoutObject.node() && | 461 return layoutObject.node() && |
| 462 layoutObject.document() | 462 layoutObject.document() |
| 463 .markers() | 463 .markers() |
| 464 .markersFor(layoutObject.node(), DocumentMarker::Composition) | 464 .markersFor(layoutObject.node(), |
| 465 DocumentMarker::Composition | |
| 466 DocumentMarker::Suggestion | |
| 467 DocumentMarker::SuggestionHighlight) |
| 465 .size() > 0; | 468 .size() > 0; |
| 466 } | 469 } |
| 467 | 470 |
| 468 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, | 471 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, |
| 469 const LayoutPoint& paintOffset) { | 472 const LayoutPoint& paintOffset) { |
| 470 if (!shouldPaintTextBox(paintInfo)) | 473 if (!shouldPaintTextBox(paintInfo)) |
| 471 return; | 474 return; |
| 472 | 475 |
| 473 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && | 476 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && |
| 474 !shouldPaintDescendantOutlines(paintInfo.phase)); | 477 !shouldPaintDescendantOutlines(paintInfo.phase)); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 // Paint either the background markers or the foreground markers, but not | 827 // Paint either the background markers or the foreground markers, but not |
| 825 // both. | 828 // both. |
| 826 switch (marker.type()) { | 829 switch (marker.type()) { |
| 827 case DocumentMarker::Grammar: | 830 case DocumentMarker::Grammar: |
| 828 case DocumentMarker::Spelling: | 831 case DocumentMarker::Spelling: |
| 829 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 832 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 830 continue; | 833 continue; |
| 831 break; | 834 break; |
| 832 case DocumentMarker::TextMatch: | 835 case DocumentMarker::TextMatch: |
| 833 case DocumentMarker::Composition: | 836 case DocumentMarker::Composition: |
| 837 case DocumentMarker::Suggestion: |
| 838 case DocumentMarker::SuggestionHighlight: |
| 834 break; | 839 break; |
| 835 default: | 840 default: |
| 836 continue; | 841 continue; |
| 837 } | 842 } |
| 838 | 843 |
| 839 if (marker.endOffset() <= m_inlineTextBox.start()) { | 844 if (marker.endOffset() <= m_inlineTextBox.start()) { |
| 840 // marker is completely before this run. This might be a marker that sits | 845 // marker is completely before this run. This might be a marker that sits |
| 841 // before the first run we draw, or markers that were within runs we | 846 // before the first run we draw, or markers that were within runs we |
| 842 // skipped due to truncation. | 847 // skipped due to truncation. |
| 843 continue; | 848 continue; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 859 break; | 864 break; |
| 860 case DocumentMarker::TextMatch: | 865 case DocumentMarker::TextMatch: |
| 861 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) { | 866 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) { |
| 862 m_inlineTextBox.paintTextMatchMarkerBackground( | 867 m_inlineTextBox.paintTextMatchMarkerBackground( |
| 863 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font); | 868 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font); |
| 864 } else { | 869 } else { |
| 865 m_inlineTextBox.paintTextMatchMarkerForeground( | 870 m_inlineTextBox.paintTextMatchMarkerForeground( |
| 866 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font); | 871 paintInfo, boxOrigin, toTextMatchMarker(marker), style, font); |
| 867 } | 872 } |
| 868 break; | 873 break; |
| 869 case DocumentMarker::Composition: { | 874 case DocumentMarker::Composition: |
| 870 const CompositionMarker& compositionMarker = | 875 case DocumentMarker::Suggestion: |
| 871 toCompositionMarker(marker); | 876 case DocumentMarker::SuggestionHighlight: { |
| 872 CompositionUnderline underline( | 877 const MarkerWithFormatting& markerWithFormatting = toMarkerWithFormattin
g(marker); |
| 873 compositionMarker.startOffset(), compositionMarker.endOffset(), | 878 CompositionUnderline underline(markerWithFormatting.startOffset(), marke
rWithFormatting.endOffset(), |
| 874 compositionMarker.underlineColor(), compositionMarker.thick(), | 879 markerWithFormatting.underlineColor(), ma
rkerWithFormatting.thick(), |
| 875 compositionMarker.backgroundColor()); | 880 markerWithFormatting.backgroundColor()); |
| 876 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 881 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 877 paintSingleCompositionBackgroundRun( | 882 paintSingleCompositionBackgroundRun( |
| 878 paintInfo.context, boxOrigin, style, font, | 883 paintInfo.context, boxOrigin, style, font, |
| 879 underline.backgroundColor(), underlinePaintStart(underline), | 884 underline.backgroundColor(), underlinePaintStart(underline), |
| 880 underlinePaintEnd(underline)); | 885 underlinePaintEnd(underline)); |
| 881 else | 886 else |
| 882 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); | 887 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); |
| 883 } break; | 888 } break; |
| 884 default: | 889 default: |
| 885 ASSERT_NOT_REACHED(); | 890 ASSERT_NOT_REACHED(); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 | 1372 |
| 1368 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), | 1373 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), |
| 1369 m_inlineTextBox.logicalHeight())); | 1374 m_inlineTextBox.logicalHeight())); |
| 1370 context.clip(FloatRect(boxRect)); | 1375 context.clip(FloatRect(boxRect)); |
| 1371 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), | 1376 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), |
| 1372 boxRect.height().toInt(), color, | 1377 boxRect.height().toInt(), color, |
| 1373 paintOffsets.first, paintOffsets.second); | 1378 paintOffsets.first, paintOffsets.second); |
| 1374 } | 1379 } |
| 1375 | 1380 |
| 1376 } // namespace blink | 1381 } // namespace blink |
| OLD | NEW |