| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 inline_text_box_.GetLineLayoutItem()); | 144 inline_text_box_.GetLineLayoutItem()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool InlineTextBoxPainter::PaintsMarkerHighlights( | 147 bool InlineTextBoxPainter::PaintsMarkerHighlights( |
| 148 const LayoutObject& layout_object) { | 148 const LayoutObject& layout_object) { |
| 149 return layout_object.GetNode() && | 149 return layout_object.GetNode() && |
| 150 layout_object.GetDocument().Markers().HasMarkers( | 150 layout_object.GetDocument().Markers().HasMarkers( |
| 151 layout_object.GetNode()); | 151 layout_object.GetNode()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 static bool PaintsCompositionMarkers(const LayoutObject& layout_object) { | |
| 155 return layout_object.GetNode() && | |
| 156 layout_object.GetDocument() | |
| 157 .Markers() | |
| 158 .MarkersFor(layout_object.GetNode(), | |
| 159 DocumentMarker::kComposition) | |
| 160 .size() > 0; | |
| 161 } | |
| 162 | |
| 163 static void PrepareContextForDecoration( | 154 static void PrepareContextForDecoration( |
| 164 GraphicsContext& context, | 155 GraphicsContext& context, |
| 165 GraphicsContextStateSaver& state_saver, | 156 GraphicsContextStateSaver& state_saver, |
| 166 bool is_horizontal, | 157 bool is_horizontal, |
| 167 const TextPainterBase::Style& text_style, | 158 const TextPainterBase::Style& text_style, |
| 168 const LayoutTextCombine* combined_text, | 159 const LayoutTextCombine* combined_text, |
| 169 const LayoutRect& box_rect) { | 160 const LayoutRect& box_rect) { |
| 170 TextPainterBase::UpdateGraphicsContext(context, text_style, is_horizontal, | 161 TextPainterBase::UpdateGraphicsContext(context, text_style, is_horizontal, |
| 171 state_saver); | 162 state_saver); |
| 172 if (combined_text) { | 163 if (combined_text) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 383 |
| 393 int ascent = font_data ? font_data->GetFontMetrics().Ascent() : 0; | 384 int ascent = font_data ? font_data->GetFontMetrics().Ascent() : 0; |
| 394 LayoutPoint text_origin(box_origin.X(), box_origin.Y() + ascent); | 385 LayoutPoint text_origin(box_origin.X(), box_origin.Y() + ascent); |
| 395 | 386 |
| 396 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds | 387 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds |
| 397 // include selection and composition highlights. | 388 // include selection and composition highlights. |
| 398 if (paint_info.phase != kPaintPhaseSelection && | 389 if (paint_info.phase != kPaintPhaseSelection && |
| 399 paint_info.phase != kPaintPhaseTextClip && !is_printing) { | 390 paint_info.phase != kPaintPhaseTextClip && !is_printing) { |
| 400 PaintDocumentMarkers(paint_info, box_origin, style_to_use, font, | 391 PaintDocumentMarkers(paint_info, box_origin, style_to_use, font, |
| 401 DocumentMarkerPaintPhase::kBackground); | 392 DocumentMarkerPaintPhase::kBackground); |
| 402 | 393 if (have_selection) { |
| 403 const LayoutObject& text_box_layout_object = InlineLayoutObject(); | |
| 404 if (have_selection && !PaintsCompositionMarkers(text_box_layout_object)) { | |
| 405 if (combined_text) | 394 if (combined_text) |
| 406 PaintSelection<InlineTextBoxPainter::PaintOptions::kCombinedText>( | 395 PaintSelection<InlineTextBoxPainter::PaintOptions::kCombinedText>( |
| 407 context, box_rect, style_to_use, font, selection_style.fill_color, | 396 context, box_rect, style_to_use, font, selection_style.fill_color, |
| 408 combined_text); | 397 combined_text); |
| 409 else | 398 else |
| 410 PaintSelection<InlineTextBoxPainter::PaintOptions::kNormal>( | 399 PaintSelection<InlineTextBoxPainter::PaintOptions::kNormal>( |
| 411 context, box_rect, style_to_use, font, selection_style.fill_color); | 400 context, box_rect, style_to_use, font, selection_style.fill_color); |
| 412 } | 401 } |
| 413 } | 402 } |
| 414 | 403 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 | 1170 |
| 1182 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), | 1171 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), |
| 1183 inline_text_box_.LogicalHeight())); | 1172 inline_text_box_.LogicalHeight())); |
| 1184 context.Clip(FloatRect(box_rect)); | 1173 context.Clip(FloatRect(box_rect)); |
| 1185 context.DrawHighlightForText(font, run, FloatPoint(box_origin), | 1174 context.DrawHighlightForText(font, run, FloatPoint(box_origin), |
| 1186 box_rect.Height().ToInt(), color, | 1175 box_rect.Height().ToInt(), color, |
| 1187 paint_offsets.first, paint_offsets.second); | 1176 paint_offsets.first, paint_offsets.second); |
| 1188 } | 1177 } |
| 1189 | 1178 |
| 1190 } // namespace blink | 1179 } // namespace blink |
| OLD | NEW |