OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/paint/NGTextPainter.h" | |
6 | |
7 #include "core/CSSPropertyNames.h" | |
8 #include "core/frame/Settings.h" | |
9 #include "core/layout/ng/inline/ng_physical_text_fragment.h" | |
10 #include "core/paint/BoxPainter.h" | |
11 #include "core/paint/PaintInfo.h" | |
12 #include "core/style/ComputedStyle.h" | |
13 #include "core/style/ShadowList.h" | |
14 #include "platform/fonts/Font.h" | |
15 #include "platform/graphics/GraphicsContext.h" | |
16 #include "platform/graphics/GraphicsContextStateSaver.h" | |
17 #include "platform/wtf/Assertions.h" | |
18 #include "platform/wtf/text/CharacterNames.h" | |
19 | |
20 namespace blink { | |
21 | |
22 void NGTextPainter::Paint(unsigned start_offset, | |
23 unsigned end_offset, | |
24 unsigned length, | |
25 const Style& text_style) { | |
26 GraphicsContextStateSaver state_saver(graphics_context_, false); | |
27 UpdateGraphicsContext(text_style, state_saver); | |
28 // if (combined_text_) { | |
29 // graphics_context_.Save(); | |
30 // combined_text_->TransformToInlineCoordinates(graphics_context_, | |
31 // text_bounds_); | |
32 // PaintInternal<kPaintText>(start_offset, end_offset, length); | |
33 // graphics_context_.Restore(); | |
34 //} else { | |
35 PaintInternal<kPaintText>(start_offset, end_offset, length); | |
36 //} | |
37 | |
38 // if (!emphasis_mark_.IsEmpty()) { | |
39 // if (text_style.emphasis_mark_color != text_style.fill_color) | |
40 // graphics_context_.SetFillColor(text_style.emphasis_mark_color); | |
41 // | |
42 // if (combined_text_) | |
43 // PaintEmphasisMarkForCombinedText(); | |
44 // else | |
45 // PaintInternal<kPaintEmphasisMark>(start_offset, end_offset, length); | |
46 //} | |
47 } | |
48 | |
49 template <NGTextPainter::PaintInternalStep step> | |
50 void NGTextPainter::PaintInternalFragment( | |
51 TextFragmentPaintInfo& fragment_paint_info, | |
52 unsigned from, | |
53 unsigned to) { | |
54 DCHECK(from <= fragment_paint_info.text.length()); | |
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_LE/
| |
55 DCHECK(to <= fragment_paint_info.text.length()); | |
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_LE/
It is better to write
D
| |
56 | |
57 fragment_paint_info.from = from; | |
58 fragment_paint_info.to = to; | |
59 | |
60 if (step == kPaintEmphasisMark) { | |
61 graphics_context_.DrawEmphasisMarks( | |
62 font_, fragment_paint_info, emphasis_mark_, | |
63 FloatPoint(text_origin_) + IntSize(0, emphasis_mark_offset_)); | |
64 } else { | |
65 DCHECK(step == kPaintText); | |
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_EQ/
| |
66 graphics_context_.DrawText(font_, fragment_paint_info, | |
67 FloatPoint(text_origin_)); | |
68 } | |
69 } | |
70 | |
71 template <NGTextPainter::PaintInternalStep Step> | |
72 void NGTextPainter::PaintInternal(unsigned start_offset, | |
73 unsigned end_offset, | |
74 unsigned truncation_point) { | |
75 unsigned offset = 0; | |
76 TextFragmentPaintInfo fragment_paint_info = { | |
77 text_fragment_->Text(), TextDirection::kLtr, offset, | |
78 text_fragment_->Text().length(), text_fragment_->TextShapeResult()}; | |
79 | |
80 // fragment_paint_info.bounds = FloatRect(text_bounds_); | |
81 if (start_offset <= end_offset) { | |
82 PaintInternalFragment<Step>(fragment_paint_info, start_offset, end_offset); | |
83 } else { | |
84 if (end_offset > 0) { | |
85 PaintInternalFragment<Step>(fragment_paint_info, ellipsis_offset_, | |
86 end_offset); | |
87 } | |
88 if (start_offset < truncation_point) { | |
89 PaintInternalFragment<Step>(fragment_paint_info, start_offset, | |
90 truncation_point); | |
91 } | |
92 } | |
93 } | |
94 | |
95 void NGTextPainter::ClipDecorationsStripe(float upper, | |
96 float stripe_width, | |
97 float dilation) {} | |
98 | |
99 void NGTextPainter::PaintEmphasisMarkForCombinedText() {} | |
100 | |
101 } // namespace blink | |
OLD | NEW |