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/editing/markers/TextMatchMarker.h" |
10 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
11 #include "core/layout/LayoutTextCombine.h" | 12 #include "core/layout/LayoutTextCombine.h" |
12 #include "core/layout/LayoutTheme.h" | 13 #include "core/layout/LayoutTheme.h" |
13 #include "core/layout/api/LineLayoutAPIShim.h" | 14 #include "core/layout/api/LineLayoutAPIShim.h" |
14 #include "core/layout/api/LineLayoutBox.h" | 15 #include "core/layout/api/LineLayoutBox.h" |
15 #include "core/layout/line/InlineTextBox.h" | 16 #include "core/layout/line/InlineTextBox.h" |
16 #include "core/paint/AppliedDecorationPainter.h" | 17 #include "core/paint/AppliedDecorationPainter.h" |
17 #include "core/paint/DecorationInfo.h" | 18 #include "core/paint/DecorationInfo.h" |
18 #include "core/paint/PaintInfo.h" | 19 #include "core/paint/PaintInfo.h" |
19 #include "core/paint/TextPainter.h" | 20 #include "core/paint/TextPainter.h" |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 switch (marker.GetType()) { | 671 switch (marker.GetType()) { |
671 case DocumentMarker::kSpelling: | 672 case DocumentMarker::kSpelling: |
672 inline_text_box_.PaintDocumentMarker(paint_info.context, box_origin, | 673 inline_text_box_.PaintDocumentMarker(paint_info.context, box_origin, |
673 marker, style, font, false); | 674 marker, style, font, false); |
674 break; | 675 break; |
675 case DocumentMarker::kGrammar: | 676 case DocumentMarker::kGrammar: |
676 inline_text_box_.PaintDocumentMarker(paint_info.context, box_origin, | 677 inline_text_box_.PaintDocumentMarker(paint_info.context, box_origin, |
677 marker, style, font, true); | 678 marker, style, font, true); |
678 break; | 679 break; |
679 case DocumentMarker::kTextMatch: | 680 case DocumentMarker::kTextMatch: |
680 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) | 681 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) { |
681 inline_text_box_.PaintTextMatchMarkerBackground( | 682 inline_text_box_.PaintTextMatchMarkerBackground( |
682 paint_info, box_origin, marker, style, font); | 683 paint_info, box_origin, ToTextMatchMarker(marker), style, font); |
683 else | 684 } else { |
684 inline_text_box_.PaintTextMatchMarkerForeground( | 685 inline_text_box_.PaintTextMatchMarkerForeground( |
685 paint_info, box_origin, marker, style, font); | 686 paint_info, box_origin, ToTextMatchMarker(marker), style, font); |
| 687 } |
686 break; | 688 break; |
687 case DocumentMarker::kComposition: { | 689 case DocumentMarker::kComposition: { |
688 CompositionUnderline underline(marker.StartOffset(), marker.EndOffset(), | 690 CompositionUnderline underline(marker.StartOffset(), marker.EndOffset(), |
689 marker.UnderlineColor(), marker.Thick(), | 691 marker.UnderlineColor(), marker.Thick(), |
690 marker.BackgroundColor()); | 692 marker.BackgroundColor()); |
691 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) | 693 if (marker_paint_phase == DocumentMarkerPaintPhase::kBackground) |
692 PaintSingleCompositionBackgroundRun( | 694 PaintSingleCompositionBackgroundRun( |
693 paint_info.context, box_origin, style, font, | 695 paint_info.context, box_origin, style, font, |
694 underline.BackgroundColor(), UnderlinePaintStart(underline), | 696 underline.BackgroundColor(), UnderlinePaintStart(underline), |
695 UnderlinePaintEnd(underline)); | 697 UnderlinePaintEnd(underline)); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 FloatPoint( | 1115 FloatPoint( |
1114 box_origin.X() + start, | 1116 box_origin.X() + start, |
1115 (box_origin.Y() + inline_text_box_.LogicalHeight() - line_thickness) | 1117 (box_origin.Y() + inline_text_box_.LogicalHeight() - line_thickness) |
1116 .ToFloat()), | 1118 .ToFloat()), |
1117 width); | 1119 width); |
1118 } | 1120 } |
1119 | 1121 |
1120 void InlineTextBoxPainter::PaintTextMatchMarkerForeground( | 1122 void InlineTextBoxPainter::PaintTextMatchMarkerForeground( |
1121 const PaintInfo& paint_info, | 1123 const PaintInfo& paint_info, |
1122 const LayoutPoint& box_origin, | 1124 const LayoutPoint& box_origin, |
1123 const DocumentMarker& marker, | 1125 const TextMatchMarker& marker, |
1124 const ComputedStyle& style, | 1126 const ComputedStyle& style, |
1125 const Font& font) { | 1127 const Font& font) { |
1126 if (!InlineLayoutObject() | 1128 if (!InlineLayoutObject() |
1127 .GetFrame() | 1129 .GetFrame() |
1128 ->GetEditor() | 1130 ->GetEditor() |
1129 .MarkedTextMatchesAreHighlighted()) | 1131 .MarkedTextMatchesAreHighlighted()) |
1130 return; | 1132 return; |
1131 | 1133 |
1132 const auto paint_offsets = GetMarkerPaintOffsets(marker, inline_text_box_); | 1134 const auto paint_offsets = GetMarkerPaintOffsets(marker, inline_text_box_); |
1133 TextRun run = inline_text_box_.ConstructTextRun(style); | 1135 TextRun run = inline_text_box_.ConstructTextRun(style); |
(...skipping 21 matching lines...) Expand all Loading... |
1155 TextPainter text_painter(paint_info.context, font, run, text_origin, box_rect, | 1157 TextPainter text_painter(paint_info.context, font, run, text_origin, box_rect, |
1156 inline_text_box_.IsHorizontal()); | 1158 inline_text_box_.IsHorizontal()); |
1157 | 1159 |
1158 text_painter.Paint(paint_offsets.first, paint_offsets.second, | 1160 text_painter.Paint(paint_offsets.first, paint_offsets.second, |
1159 inline_text_box_.Len(), text_style); | 1161 inline_text_box_.Len(), text_style); |
1160 } | 1162 } |
1161 | 1163 |
1162 void InlineTextBoxPainter::PaintTextMatchMarkerBackground( | 1164 void InlineTextBoxPainter::PaintTextMatchMarkerBackground( |
1163 const PaintInfo& paint_info, | 1165 const PaintInfo& paint_info, |
1164 const LayoutPoint& box_origin, | 1166 const LayoutPoint& box_origin, |
1165 const DocumentMarker& marker, | 1167 const TextMatchMarker& marker, |
1166 const ComputedStyle& style, | 1168 const ComputedStyle& style, |
1167 const Font& font) { | 1169 const Font& font) { |
1168 if (!LineLayoutAPIShim::LayoutObjectFrom(inline_text_box_.GetLineLayoutItem()) | 1170 if (!LineLayoutAPIShim::LayoutObjectFrom(inline_text_box_.GetLineLayoutItem()) |
1169 ->GetFrame() | 1171 ->GetFrame() |
1170 ->GetEditor() | 1172 ->GetEditor() |
1171 .MarkedTextMatchesAreHighlighted()) | 1173 .MarkedTextMatchesAreHighlighted()) |
1172 return; | 1174 return; |
1173 | 1175 |
1174 const auto paint_offsets = GetMarkerPaintOffsets(marker, inline_text_box_); | 1176 const auto paint_offsets = GetMarkerPaintOffsets(marker, inline_text_box_); |
1175 TextRun run = inline_text_box_.ConstructTextRun(style); | 1177 TextRun run = inline_text_box_.ConstructTextRun(style); |
1176 | 1178 |
1177 Color color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( | 1179 Color color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( |
1178 marker.IsActiveMatch()); | 1180 marker.IsActiveMatch()); |
1179 GraphicsContext& context = paint_info.context; | 1181 GraphicsContext& context = paint_info.context; |
1180 GraphicsContextStateSaver state_saver(context); | 1182 GraphicsContextStateSaver state_saver(context); |
1181 | 1183 |
1182 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), | 1184 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), |
1183 inline_text_box_.LogicalHeight())); | 1185 inline_text_box_.LogicalHeight())); |
1184 context.Clip(FloatRect(box_rect)); | 1186 context.Clip(FloatRect(box_rect)); |
1185 context.DrawHighlightForText(font, run, FloatPoint(box_origin), | 1187 context.DrawHighlightForText(font, run, FloatPoint(box_origin), |
1186 box_rect.Height().ToInt(), color, | 1188 box_rect.Height().ToInt(), color, |
1187 paint_offsets.first, paint_offsets.second); | 1189 paint_offsets.first, paint_offsets.second); |
1188 } | 1190 } |
1189 | 1191 |
1190 } // namespace blink | 1192 } // namespace blink |
OLD | NEW |