1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_TEXT_FRAGMENT_PAINTER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_TEXT_FRAGMENT_PAINTER_H_
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
class ComputedStyle;
class DisplayItemClient;
class LayoutObject;
class NGPaintFragment;
class NGInlineCursor;
struct NGTextFragmentPaintInfo;
struct PaintInfo;
struct PhysicalOffset;
struct PhysicalRect;
struct PhysicalSize;
// The helper class for templatize |NGTextFragmentPainter|.
// TODO(yosin): Remove |NGTextPainterCursor| once the transition to
// |NGFragmentItem| is done. http://crbug.com/982194
class NGTextPainterCursor {
STACK_ALLOCATED();
public:
explicit NGTextPainterCursor(const NGPaintFragment& paint_fragment)
: paint_fragment_(paint_fragment),
text_fragment_(
To<NGPhysicalTextFragment>(paint_fragment.PhysicalFragment())) {}
const NGPaintFragment& PaintFragment() const { return paint_fragment_; }
const NGPhysicalTextFragment* CurrentItem() const { return &text_fragment_; }
StringView CurrentText() const;
const NGPaintFragment& RootPaintFragment() const;
private:
const NGPaintFragment& paint_fragment_;
const NGPhysicalTextFragment& text_fragment_;
mutable const NGPaintFragment* root_paint_fragment_ = nullptr;
};
// Text fragment painter for LayoutNG. Operates on NGPhysicalTextFragments and
// handles clipping, selection, etc. Delegates to NGTextPainter to paint the
// text itself.
// TODO(yosin): We should make |NGTextFragmentPainter| non-template class onnce
// we get rid of |NGPaintFragment|.
template <typename Cursor>
class NGTextFragmentPainter {
STACK_ALLOCATED();
public:
explicit NGTextFragmentPainter(const Cursor& cursor) : cursor_(cursor) {}
NGTextFragmentPainter(const Cursor& cursor,
const PhysicalOffset& parent_offset)
: cursor_(cursor), parent_offset_(parent_offset) {}
void Paint(const PaintInfo&, const PhysicalOffset& paint_offset);
private:
void Paint(const NGTextFragmentPaintInfo& fragment_paint_info,
const LayoutObject* layout_object,
const DisplayItemClient& display_item_client,
const ComputedStyle& style,
PhysicalRect box_rect,
const IntRect& visual_rect,
bool is_ellipsis,
bool is_symbol_marker,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset);
static void PaintSymbol(const LayoutObject* layout_object,
const ComputedStyle& style,
const PhysicalSize box_size,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset);
const Cursor& cursor_;
PhysicalOffset parent_offset_;
base::Optional<NGInlineCursor> inline_cursor_for_block_flow_;
};
extern template class NGTextFragmentPainter<NGTextPainterCursor>;
extern template class NGTextFragmentPainter<NGInlineCursor>;
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_TEXT_FRAGMENT_PAINTER_H_
|