Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2925543003: [ActiveSuggestionMarker #3] Add painting for ActiveSuggestionMarker (Closed)
Patch Set: Add expected behavior for tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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& marker_with_formatting =
yosin_UTC9 2017/06/06 01:31:22 Is it better to use |stylable_marker| instead of |
681 ToStyleableMarker(marker);
682 CompositionUnderline underline( 682 CompositionUnderline underline(
683 composition_marker.StartOffset(), composition_marker.EndOffset(), 683 marker_with_formatting.StartOffset(),
684 composition_marker.UnderlineColor(), composition_marker.IsThick(), 684 marker_with_formatting.EndOffset(),
685 composition_marker.BackgroundColor()); 685 marker_with_formatting.UnderlineColor(),
686 marker_with_formatting.IsThick(),
687 marker_with_formatting.BackgroundColor());
686 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) 688 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground)
687 PaintSingleCompositionBackgroundRun( 689 PaintSingleCompositionBackgroundRun(
688 paint_info.context, box_origin, style, font, 690 paint_info.context, box_origin, style, font,
689 underline.BackgroundColor(), UnderlinePaintStart(underline), 691 underline.BackgroundColor(), UnderlinePaintStart(underline),
690 UnderlinePaintEnd(underline)); 692 UnderlinePaintEnd(underline));
691 else 693 else
692 PaintCompositionUnderline(paint_info.context, box_origin, underline); 694 PaintCompositionUnderline(paint_info.context, box_origin, underline);
693 } break; 695 } break;
694 default: 696 default:
695 NOTREACHED(); 697 NOTREACHED();
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1178
1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), 1179 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(),
1178 inline_text_box_.LogicalHeight())); 1180 inline_text_box_.LogicalHeight()));
1179 context.Clip(FloatRect(box_rect)); 1181 context.Clip(FloatRect(box_rect));
1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin), 1182 context.DrawHighlightForText(font, run, FloatPoint(box_origin),
1181 box_rect.Height().ToInt(), color, 1183 box_rect.Height().ToInt(), color,
1182 paint_offsets.first, paint_offsets.second); 1184 paint_offsets.first, paint_offsets.second);
1183 } 1185 }
1184 1186
1185 } // namespace blink 1187 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698