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/SVGInlineTextBoxPainter.h" | 5 #include "core/paint/SVGInlineTextBoxPainter.h" |
6 | 6 |
| 7 #include <memory> |
7 #include "core/editing/Editor.h" | 8 #include "core/editing/Editor.h" |
8 #include "core/editing/markers/DocumentMarkerController.h" | 9 #include "core/editing/markers/DocumentMarkerController.h" |
| 10 #include "core/editing/markers/TextMatchMarker.h" |
9 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
10 #include "core/layout/LayoutTheme.h" | 12 #include "core/layout/LayoutTheme.h" |
11 #include "core/layout/api/LineLayoutAPIShim.h" | 13 #include "core/layout/api/LineLayoutAPIShim.h" |
12 #include "core/layout/api/SelectionState.h" | 14 #include "core/layout/api/SelectionState.h" |
13 #include "core/layout/line/InlineFlowBox.h" | 15 #include "core/layout/line/InlineFlowBox.h" |
14 #include "core/layout/svg/LayoutSVGInlineText.h" | 16 #include "core/layout/svg/LayoutSVGInlineText.h" |
15 #include "core/layout/svg/SVGLayoutSupport.h" | 17 #include "core/layout/svg/SVGLayoutSupport.h" |
16 #include "core/layout/svg/SVGResourcesCache.h" | 18 #include "core/layout/svg/SVGResourcesCache.h" |
17 #include "core/layout/svg/line/SVGInlineTextBox.h" | 19 #include "core/layout/svg/line/SVGInlineTextBox.h" |
18 #include "core/paint/InlineTextBoxPainter.h" | 20 #include "core/paint/InlineTextBoxPainter.h" |
19 #include "core/paint/LayoutObjectDrawingRecorder.h" | 21 #include "core/paint/LayoutObjectDrawingRecorder.h" |
20 #include "core/paint/PaintInfo.h" | 22 #include "core/paint/PaintInfo.h" |
21 #include "core/paint/SVGPaintContext.h" | 23 #include "core/paint/SVGPaintContext.h" |
22 #include "core/style/AppliedTextDecoration.h" | 24 #include "core/style/AppliedTextDecoration.h" |
23 #include "core/style/ShadowList.h" | 25 #include "core/style/ShadowList.h" |
24 #include "platform/graphics/GraphicsContextStateSaver.h" | 26 #include "platform/graphics/GraphicsContextStateSaver.h" |
25 #include <memory> | |
26 | 27 |
27 namespace blink { | 28 namespace blink { |
28 | 29 |
29 static inline bool TextShouldBePainted( | 30 static inline bool TextShouldBePainted( |
30 const LayoutSVGInlineText& text_layout_object) { | 31 const LayoutSVGInlineText& text_layout_object) { |
31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which | 32 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which |
32 // returns "int(x + 0.5)". If the absolute font size on screen is below | 33 // returns "int(x + 0.5)". If the absolute font size on screen is below |
33 // x=0.5, don't render anything. | 34 // x=0.5, don't render anything. |
34 return text_layout_object.ScaledFont() | 35 return text_layout_object.ScaledFont() |
35 .GetFontDescription() | 36 .GetFontDescription() |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 586 |
586 fragment_info_list.push_back(SVGTextFragmentWithRange( | 587 fragment_info_list.push_back(SVGTextFragmentWithRange( |
587 fragment, fragment_start_position, fragment_end_position)); | 588 fragment, fragment_start_position, fragment_end_position)); |
588 } | 589 } |
589 return fragment_info_list; | 590 return fragment_info_list; |
590 } | 591 } |
591 | 592 |
592 void SVGInlineTextBoxPainter::PaintTextMatchMarkerForeground( | 593 void SVGInlineTextBoxPainter::PaintTextMatchMarkerForeground( |
593 const PaintInfo& paint_info, | 594 const PaintInfo& paint_info, |
594 const LayoutPoint& point, | 595 const LayoutPoint& point, |
595 const DocumentMarker& marker, | 596 const TextMatchMarker& marker, |
596 const ComputedStyle& style, | 597 const ComputedStyle& style, |
597 const Font& font) { | 598 const Font& font) { |
598 const Vector<SVGTextFragmentWithRange> text_match_info_list = | 599 const Vector<SVGTextFragmentWithRange> text_match_info_list = |
599 CollectTextMatches(marker); | 600 CollectTextMatches(marker); |
600 if (text_match_info_list.IsEmpty()) | 601 if (text_match_info_list.IsEmpty()) |
601 return; | 602 return; |
602 | 603 |
603 Color text_color = | 604 Color text_color = |
604 LayoutTheme::GetTheme().PlatformTextSearchColor(marker.IsActiveMatch()); | 605 LayoutTheme::GetTheme().PlatformTextSearchColor(marker.IsActiveMatch()); |
605 | 606 |
(...skipping 21 matching lines...) Expand all Loading... |
627 if (should_paint_stroke) { | 628 if (should_paint_stroke) { |
628 PaintText(paint_info, text_run, fragment, text_match_info.start_position, | 629 PaintText(paint_info, text_run, fragment, text_match_info.start_position, |
629 text_match_info.end_position, stroke_flags); | 630 text_match_info.end_position, stroke_flags); |
630 } | 631 } |
631 } | 632 } |
632 } | 633 } |
633 | 634 |
634 void SVGInlineTextBoxPainter::PaintTextMatchMarkerBackground( | 635 void SVGInlineTextBoxPainter::PaintTextMatchMarkerBackground( |
635 const PaintInfo& paint_info, | 636 const PaintInfo& paint_info, |
636 const LayoutPoint& point, | 637 const LayoutPoint& point, |
637 const DocumentMarker& marker, | 638 const TextMatchMarker& marker, |
638 const ComputedStyle& style, | 639 const ComputedStyle& style, |
639 const Font& font) { | 640 const Font& font) { |
640 const Vector<SVGTextFragmentWithRange> text_match_info_list = | 641 const Vector<SVGTextFragmentWithRange> text_match_info_list = |
641 CollectTextMatches(marker); | 642 CollectTextMatches(marker); |
642 if (text_match_info_list.IsEmpty()) | 643 if (text_match_info_list.IsEmpty()) |
643 return; | 644 return; |
644 | 645 |
645 Color color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( | 646 Color color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( |
646 marker.IsActiveMatch()); | 647 marker.IsActiveMatch()); |
647 for (const SVGTextFragmentWithRange& text_match_info : text_match_info_list) { | 648 for (const SVGTextFragmentWithRange& text_match_info : text_match_info_list) { |
648 const SVGTextFragment& fragment = text_match_info.fragment; | 649 const SVGTextFragment& fragment = text_match_info.fragment; |
649 | 650 |
650 GraphicsContextStateSaver state_saver(paint_info.context, false); | 651 GraphicsContextStateSaver state_saver(paint_info.context, false); |
651 if (fragment.IsTransformed()) { | 652 if (fragment.IsTransformed()) { |
652 state_saver.Save(); | 653 state_saver.Save(); |
653 paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); | 654 paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); |
654 } | 655 } |
655 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment( | 656 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment( |
656 fragment, text_match_info.start_position, text_match_info.end_position, | 657 fragment, text_match_info.start_position, text_match_info.end_position, |
657 style); | 658 style); |
658 paint_info.context.SetFillColor(color); | 659 paint_info.context.SetFillColor(color); |
659 paint_info.context.FillRect(fragment_rect); | 660 paint_info.context.FillRect(fragment_rect); |
660 } | 661 } |
661 } | 662 } |
662 | 663 |
663 } // namespace blink | 664 } // namespace blink |
OLD | NEW |