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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // Paint either the background markers or the foreground markers, but not | 634 // Paint either the background markers or the foreground markers, but not |
635 // both. | 635 // both. |
636 switch (marker.GetType()) { | 636 switch (marker.GetType()) { |
637 case DocumentMarker::kGrammar: | 637 case DocumentMarker::kGrammar: |
638 case DocumentMarker::kSpelling: | 638 case DocumentMarker::kSpelling: |
639 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) | 639 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) |
640 continue; | 640 continue; |
641 break; | 641 break; |
642 case DocumentMarker::kTextMatch: | 642 case DocumentMarker::kTextMatch: |
643 case DocumentMarker::kComposition: | 643 case DocumentMarker::kComposition: |
| 644 case DocumentMarker::kActiveSuggestion: |
644 break; | 645 break; |
645 default: | |
646 continue; | |
647 } | 646 } |
648 | 647 |
649 if (marker.EndOffset() <= inline_text_box_.Start()) { | 648 if (marker.EndOffset() <= inline_text_box_.Start()) { |
650 // marker is completely before this run. This might be a marker that sits | 649 // marker is completely before this run. This might be a marker that sits |
651 // before the first run we draw, or markers that were within runs we | 650 // before the first run we draw, or markers that were within runs we |
652 // skipped due to truncation. | 651 // skipped due to truncation. |
653 continue; | 652 continue; |
654 } | 653 } |
655 if (marker.StartOffset() > inline_text_box_.end()) { | 654 if (marker.StartOffset() > inline_text_box_.end()) { |
656 // marker is completely after this run, bail. A later run will paint it. | 655 // marker is completely after this run, bail. A later run will paint it. |
(...skipping 12 matching lines...) Expand all Loading... |
669 break; | 668 break; |
670 case DocumentMarker::kTextMatch: | 669 case DocumentMarker::kTextMatch: |
671 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) { | 670 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) { |
672 inline_text_box_.PaintTextMatchMarkerBackground( | 671 inline_text_box_.PaintTextMatchMarkerBackground( |
673 paint_info, box_origin, ToTextMatchMarker(marker), style, font); | 672 paint_info, box_origin, ToTextMatchMarker(marker), style, font); |
674 } else { | 673 } else { |
675 inline_text_box_.PaintTextMatchMarkerForeground( | 674 inline_text_box_.PaintTextMatchMarkerForeground( |
676 paint_info, box_origin, ToTextMatchMarker(marker), style, font); | 675 paint_info, box_origin, ToTextMatchMarker(marker), style, font); |
677 } | 676 } |
678 break; | 677 break; |
679 case DocumentMarker::kComposition: { | 678 case DocumentMarker::kComposition: |
680 const CompositionMarker& composition_marker = | 679 case DocumentMarker::kActiveSuggestion: { |
681 ToCompositionMarker(marker); | 680 const StyleableMarker& styleable_marker = ToStyleableMarker(marker); |
682 CompositionUnderline underline( | 681 CompositionUnderline underline( |
683 composition_marker.StartOffset(), composition_marker.EndOffset(), | 682 styleable_marker.StartOffset(), styleable_marker.EndOffset(), |
684 composition_marker.UnderlineColor(), composition_marker.IsThick(), | 683 styleable_marker.UnderlineColor(), styleable_marker.IsThick(), |
685 composition_marker.BackgroundColor()); | 684 styleable_marker.BackgroundColor()); |
686 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) | 685 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) |
687 PaintSingleCompositionBackgroundRun( | 686 PaintSingleCompositionBackgroundRun( |
688 paint_info.context, box_origin, style, font, | 687 paint_info.context, box_origin, style, font, |
689 underline.BackgroundColor(), UnderlinePaintStart(underline), | 688 underline.BackgroundColor(), UnderlinePaintStart(underline), |
690 UnderlinePaintEnd(underline)); | 689 UnderlinePaintEnd(underline)); |
691 else | 690 else |
692 PaintCompositionUnderline(paint_info.context, box_origin, underline); | 691 PaintCompositionUnderline(paint_info.context, box_origin, underline); |
693 } break; | 692 } break; |
694 default: | 693 default: |
695 NOTREACHED(); | 694 NOTREACHED(); |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 | 1175 |
1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), | 1176 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), |
1178 inline_text_box_.LogicalHeight())); | 1177 inline_text_box_.LogicalHeight())); |
1179 context.Clip(FloatRect(box_rect)); | 1178 context.Clip(FloatRect(box_rect)); |
1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin), | 1179 context.DrawHighlightForText(font, run, FloatPoint(box_origin), |
1181 box_rect.Height().ToInt(), color, | 1180 box_rect.Height().ToInt(), color, |
1182 paint_offsets.first, paint_offsets.second); | 1181 paint_offsets.first, paint_offsets.second); |
1183 } | 1182 } |
1184 | 1183 |
1185 } // namespace blink | 1184 } // namespace blink |
OLD | NEW |