| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 bool InlineTextBoxPainter::paintsMarkerHighlights( | 422 bool InlineTextBoxPainter::paintsMarkerHighlights( |
| 423 const LayoutObject& layoutObject) { | 423 const LayoutObject& layoutObject) { |
| 424 return layoutObject.node() && | 424 return layoutObject.node() && |
| 425 layoutObject.document().markers().hasMarkers(layoutObject.node()); | 425 layoutObject.document().markers().hasMarkers(layoutObject.node()); |
| 426 } | 426 } |
| 427 | 427 |
| 428 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { | 428 static bool paintsCompositionMarkers(const LayoutObject& layoutObject) { |
| 429 return layoutObject.node() && | 429 return layoutObject.node() && |
| 430 layoutObject.document() | 430 layoutObject.document() |
| 431 .markers() | 431 .markers() |
| 432 .markersFor(layoutObject.node(), DocumentMarker::Composition) | 432 .markersFor(layoutObject.node(), |
| 433 DocumentMarker::Composition | |
| 434 DocumentMarker::Suggestion | |
| 435 DocumentMarker::SuggestionBackgroundHighlight) |
| 433 .size() > 0; | 436 .size() > 0; |
| 434 } | 437 } |
| 435 | 438 |
| 436 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, | 439 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, |
| 437 const LayoutPoint& paintOffset) { | 440 const LayoutPoint& paintOffset) { |
| 438 if (!shouldPaintTextBox(paintInfo)) | 441 if (!shouldPaintTextBox(paintInfo)) |
| 439 return; | 442 return; |
| 440 | 443 |
| 441 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && | 444 DCHECK(!shouldPaintSelfOutline(paintInfo.phase) && |
| 442 !shouldPaintDescendantOutlines(paintInfo.phase)); | 445 !shouldPaintDescendantOutlines(paintInfo.phase)); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 // Paint either the background markers or the foreground markers, but not | 806 // Paint either the background markers or the foreground markers, but not |
| 804 // both. | 807 // both. |
| 805 switch (marker.type()) { | 808 switch (marker.type()) { |
| 806 case DocumentMarker::Grammar: | 809 case DocumentMarker::Grammar: |
| 807 case DocumentMarker::Spelling: | 810 case DocumentMarker::Spelling: |
| 808 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 811 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 809 continue; | 812 continue; |
| 810 break; | 813 break; |
| 811 case DocumentMarker::TextMatch: | 814 case DocumentMarker::TextMatch: |
| 812 case DocumentMarker::Composition: | 815 case DocumentMarker::Composition: |
| 816 case DocumentMarker::Suggestion: |
| 817 case DocumentMarker::SuggestionBackgroundHighlight: |
| 813 break; | 818 break; |
| 814 default: | 819 default: |
| 815 continue; | 820 continue; |
| 816 } | 821 } |
| 817 | 822 |
| 818 if (marker.endOffset() <= m_inlineTextBox.start()) { | 823 if (marker.endOffset() <= m_inlineTextBox.start()) { |
| 819 // marker is completely before this run. This might be a marker that sits | 824 // marker is completely before this run. This might be a marker that sits |
| 820 // before the first run we draw, or markers that were within runs we | 825 // before the first run we draw, or markers that were within runs we |
| 821 // skipped due to truncation. | 826 // skipped due to truncation. |
| 822 continue; | 827 continue; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 837 marker, style, font, true); | 842 marker, style, font, true); |
| 838 break; | 843 break; |
| 839 case DocumentMarker::TextMatch: | 844 case DocumentMarker::TextMatch: |
| 840 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 845 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 841 m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, | 846 m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, |
| 842 marker, style, font); | 847 marker, style, font); |
| 843 else | 848 else |
| 844 m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, | 849 m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, |
| 845 marker, style, font); | 850 marker, style, font); |
| 846 break; | 851 break; |
| 847 case DocumentMarker::Composition: { | 852 case DocumentMarker::Composition: |
| 853 case DocumentMarker::Suggestion: |
| 854 case DocumentMarker::SuggestionBackgroundHighlight: { |
| 848 CompositionUnderline underline(marker.startOffset(), marker.endOffset(), | 855 CompositionUnderline underline(marker.startOffset(), marker.endOffset(), |
| 849 marker.underlineColor(), marker.thick(), | 856 marker.underlineColor(), marker.thick(), |
| 850 marker.backgroundColor()); | 857 marker.backgroundColor()); |
| 851 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) | 858 if (markerPaintPhase == DocumentMarkerPaintPhase::Background) |
| 852 paintSingleCompositionBackgroundRun( | 859 paintSingleCompositionBackgroundRun( |
| 853 paintInfo.context, boxOrigin, style, font, | 860 paintInfo.context, boxOrigin, style, font, |
| 854 underline.backgroundColor(), underlinePaintStart(underline), | 861 underline.backgroundColor(), underlinePaintStart(underline), |
| 855 underlinePaintEnd(underline)); | 862 underlinePaintEnd(underline)); |
| 856 else | 863 else |
| 857 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); | 864 paintCompositionUnderline(paintInfo.context, boxOrigin, underline); |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 | 1330 |
| 1324 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), | 1331 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), |
| 1325 m_inlineTextBox.logicalHeight())); | 1332 m_inlineTextBox.logicalHeight())); |
| 1326 context.clip(FloatRect(boxRect)); | 1333 context.clip(FloatRect(boxRect)); |
| 1327 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), | 1334 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), |
| 1328 boxRect.height().toInt(), color, | 1335 boxRect.height().toInt(), color, |
| 1329 paintOffsets.first, paintOffsets.second); | 1336 paintOffsets.first, paintOffsets.second); |
| 1330 } | 1337 } |
| 1331 | 1338 |
| 1332 } // namespace blink | 1339 } // namespace blink |
| OLD | NEW |