OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef NGPhysicalFragment_h | 5 #ifndef NGPhysicalFragment_h |
6 #define NGPhysicalFragment_h | 6 #define NGPhysicalFragment_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/geometry/ng_border_edges.h" |
9 #include "core/layout/ng/geometry/ng_box_strut.h" | 10 #include "core/layout/ng/geometry/ng_box_strut.h" |
10 #include "core/layout/ng/geometry/ng_physical_offset.h" | 11 #include "core/layout/ng/geometry/ng_physical_offset.h" |
11 #include "core/layout/ng/geometry/ng_physical_size.h" | 12 #include "core/layout/ng/geometry/ng_physical_size.h" |
12 #include "core/layout/ng/ng_break_token.h" | 13 #include "core/layout/ng/ng_break_token.h" |
13 #include "platform/LayoutUnit.h" | 14 #include "platform/LayoutUnit.h" |
14 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
15 #include "platform/wtf/RefPtr.h" | 16 #include "platform/wtf/RefPtr.h" |
16 #include "platform/wtf/Vector.h" | 17 #include "platform/wtf/Vector.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
(...skipping 15 matching lines...) Expand all Loading... |
34 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> { | 35 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> { |
35 public: | 36 public: |
36 enum NGFragmentType { | 37 enum NGFragmentType { |
37 kFragmentBox = 0, | 38 kFragmentBox = 0, |
38 kFragmentText = 1, | 39 kFragmentText = 1, |
39 kFragmentLineBox = 2 | 40 kFragmentLineBox = 2 |
40 // When adding new values, make sure the bit size of |type_| is large | 41 // When adding new values, make sure the bit size of |type_| is large |
41 // enough to store. | 42 // enough to store. |
42 }; | 43 }; |
43 | 44 |
44 // Which border edges should be painted. Due to fragmentation one or more may | |
45 // be skipped. | |
46 enum NGPaintBorderEdge { | |
47 kTopBorder = 1, | |
48 kRightBorder = 2, | |
49 kBottomBorder = 4, | |
50 kLeftBorder = 8 | |
51 }; | |
52 | |
53 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } | 45 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } |
54 bool IsBox() const { return Type() == NGFragmentType::kFragmentBox; } | 46 bool IsBox() const { return Type() == NGFragmentType::kFragmentBox; } |
55 bool IsText() const { return Type() == NGFragmentType::kFragmentText; } | 47 bool IsText() const { return Type() == NGFragmentType::kFragmentText; } |
56 bool IsLineBox() const { return Type() == NGFragmentType::kFragmentLineBox; } | 48 bool IsLineBox() const { return Type() == NGFragmentType::kFragmentLineBox; } |
57 | 49 |
58 // The accessors in this class shouldn't be used by layout code directly, | 50 // The accessors in this class shouldn't be used by layout code directly, |
59 // instead should be accessed by the NGFragmentBase classes. These accessors | 51 // instead should be accessed by the NGFragmentBase classes. These accessors |
60 // exist for paint, hit-testing, etc. | 52 // exist for paint, hit-testing, etc. |
61 | 53 |
62 // Returns the border-box size. | 54 // Returns the border-box size. |
63 NGPhysicalSize Size() const { return size_; } | 55 NGPhysicalSize Size() const { return size_; } |
64 | 56 |
65 // Bitmask for border edges, see NGPaintBorderEdge. | 57 // Bitmask for border edges, see NGPaintBorderEdge. |
66 unsigned BorderEdges() const { return paint_border_edge_; } | 58 NGBorderEdges::Physical BorderEdges() const { |
| 59 return static_cast<NGBorderEdges::Physical>(border_edge_); |
| 60 } |
67 NGPixelSnappedPhysicalBoxStrut BorderWidths() const; | 61 NGPixelSnappedPhysicalBoxStrut BorderWidths() const; |
68 | 62 |
69 // Returns the offset relative to the parent fragment's content-box. | 63 // Returns the offset relative to the parent fragment's content-box. |
70 NGPhysicalOffset Offset() const { | 64 NGPhysicalOffset Offset() const { |
71 DCHECK(is_placed_); | 65 DCHECK(is_placed_); |
72 return offset_; | 66 return offset_; |
73 } | 67 } |
74 | 68 |
75 NGBreakToken* BreakToken() const { return break_token_.Get(); } | 69 NGBreakToken* BreakToken() const { return break_token_.Get(); } |
76 const ComputedStyle& Style() const; | 70 const ComputedStyle& Style() const; |
(...skipping 26 matching lines...) Expand all Loading... |
103 NGFragmentType type, | 97 NGFragmentType type, |
104 RefPtr<NGBreakToken> break_token = nullptr); | 98 RefPtr<NGBreakToken> break_token = nullptr); |
105 | 99 |
106 LayoutObject* layout_object_; | 100 LayoutObject* layout_object_; |
107 NGPhysicalSize size_; | 101 NGPhysicalSize size_; |
108 NGPhysicalOffset offset_; | 102 NGPhysicalOffset offset_; |
109 RefPtr<NGBreakToken> break_token_; | 103 RefPtr<NGBreakToken> break_token_; |
110 | 104 |
111 unsigned type_ : 2; // NGFragmentType | 105 unsigned type_ : 2; // NGFragmentType |
112 unsigned is_placed_ : 1; | 106 unsigned is_placed_ : 1; |
113 unsigned paint_border_edge_ : 4; // NGPaintBorderEdge | 107 unsigned border_edge_ : 4; // NGPhysicalBorderEdges |
114 | 108 |
115 private: | 109 private: |
116 void Destroy() const; | 110 void Destroy() const; |
117 }; | 111 }; |
118 | 112 |
119 } // namespace blink | 113 } // namespace blink |
120 | 114 |
121 #endif // NGPhysicalFragment_h | 115 #endif // NGPhysicalFragment_h |
OLD | NEW |