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_box_strut.h" | 9 #include "core/layout/ng/geometry/ng_box_strut.h" |
10 #include "core/layout/ng/geometry/ng_physical_offset.h" | 10 #include "core/layout/ng/geometry/ng_physical_offset.h" |
11 #include "core/layout/ng/geometry/ng_physical_size.h" | 11 #include "core/layout/ng/geometry/ng_physical_size.h" |
12 #include "core/layout/ng/ng_break_token.h" | 12 #include "core/layout/ng/ng_break_token.h" |
13 #include "platform/LayoutUnit.h" | 13 #include "platform/LayoutUnit.h" |
| 14 #include "platform/graphics/paint/DisplayItemClient.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 { |
19 | 20 |
20 class ComputedStyle; | 21 class ComputedStyle; |
21 class LayoutObject; | 22 class LayoutObject; |
22 | 23 |
23 // The NGPhysicalFragment contains the output geometry from layout. The | 24 // The NGPhysicalFragment contains the output geometry from layout. The |
24 // fragment stores all of its information in the physical coordinate system for | 25 // fragment stores all of its information in the physical coordinate system for |
25 // use by paint, hit-testing etc. | 26 // use by paint, hit-testing etc. |
26 // | 27 // |
27 // The fragment keeps a pointer back to the LayoutObject which generated it. | 28 // The fragment keeps a pointer back to the LayoutObject which generated it. |
28 // Once we have transitioned fully to LayoutNG it should be a const pointer | 29 // Once we have transitioned fully to LayoutNG it should be a const pointer |
29 // such that paint/hit-testing/etc don't modify it. | 30 // such that paint/hit-testing/etc don't modify it. |
30 // | 31 // |
31 // Layout code should only access geometry information through the | 32 // Layout code should only access geometry information through the |
32 // NGFragment wrapper classes which transforms information into the logical | 33 // NGFragment wrapper classes which transforms information into the logical |
33 // coordinate system. | 34 // coordinate system. |
34 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> { | 35 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment>, |
| 36 public DisplayItemClient { |
35 public: | 37 public: |
36 enum NGFragmentType { | 38 enum NGFragmentType { |
37 kFragmentBox = 0, | 39 kFragmentBox = 0, |
38 kFragmentText = 1, | 40 kFragmentText = 1, |
39 kFragmentLineBox = 2 | 41 kFragmentLineBox = 2 |
40 // When adding new values, make sure the bit size of |type_| is large | 42 // When adding new values, make sure the bit size of |type_| is large |
41 // enough to store. | 43 // enough to store. |
42 }; | 44 }; |
43 | 45 |
44 // Which border edges should be painted. Due to fragmentation one or more may | 46 // Which border edges should be painted. Due to fragmentation one or more may |
(...skipping 12 matching lines...) Expand all Loading... |
57 | 59 |
58 // The accessors in this class shouldn't be used by layout code directly, | 60 // The accessors in this class shouldn't be used by layout code directly, |
59 // instead should be accessed by the NGFragmentBase classes. These accessors | 61 // instead should be accessed by the NGFragmentBase classes. These accessors |
60 // exist for paint, hit-testing, etc. | 62 // exist for paint, hit-testing, etc. |
61 | 63 |
62 // Returns the border-box size. | 64 // Returns the border-box size. |
63 NGPhysicalSize Size() const { return size_; } | 65 NGPhysicalSize Size() const { return size_; } |
64 | 66 |
65 // Bitmask for border edges, see NGPaintBorderEdge. | 67 // Bitmask for border edges, see NGPaintBorderEdge. |
66 unsigned BorderEdges() const { return paint_border_edge_; } | 68 unsigned BorderEdges() const { return paint_border_edge_; } |
| 69 |
67 NGPixelSnappedPhysicalBoxStrut BorderWidths() const; | 70 NGPixelSnappedPhysicalBoxStrut BorderWidths() const; |
68 | 71 |
69 // Returns the offset relative to the parent fragment's content-box. | 72 // Returns the offset relative to the parent fragment's content-box. |
70 NGPhysicalOffset Offset() const { | 73 NGPhysicalOffset Offset() const { |
71 DCHECK(is_placed_); | 74 DCHECK(is_placed_); |
72 return offset_; | 75 return offset_; |
73 } | 76 } |
74 | 77 |
75 NGBreakToken* BreakToken() const { return break_token_.Get(); } | 78 NGBreakToken* BreakToken() const { return break_token_.Get(); } |
76 const ComputedStyle& Style() const; | 79 const ComputedStyle& Style() const; |
77 | 80 |
78 // GetLayoutObject should only be used when necessary for compatibility | 81 // GetLayoutObject should only be used when necessary for compatibility |
79 // with LegacyLayout. | 82 // with LegacyLayout. |
80 LayoutObject* GetLayoutObject() const { return layout_object_; } | 83 LayoutObject* GetLayoutObject() const { return layout_object_; } |
81 | 84 |
| 85 // Legacy LayoutObject methods. Need to be reviewed. |
| 86 bool HasOverflowClip() const { return false; } |
| 87 |
| 88 // DisplayItemClient methods |
| 89 String DebugName() const override { return "NGPhysicalFragment"; } |
| 90 LayoutRect VisualRect() const { |
| 91 return LayoutRect(LayoutPoint(), LayoutSize(Size().width, Size().height)); |
| 92 } |
| 93 |
| 94 LayoutRect VisualOverflowRect() const { |
| 95 // TODO(layout-dev): Implement? |
| 96 return VisualRect(); |
| 97 } |
| 98 |
82 // Should only be used by the parent fragment's layout. | 99 // Should only be used by the parent fragment's layout. |
83 void SetOffset(NGPhysicalOffset offset) { | 100 void SetOffset(NGPhysicalOffset offset) { |
84 DCHECK(!is_placed_); | 101 DCHECK(!is_placed_); |
85 offset_ = offset; | 102 offset_ = offset; |
86 is_placed_ = true; | 103 is_placed_ = true; |
87 } | 104 } |
88 | 105 |
89 bool IsPlaced() const { return is_placed_; } | 106 bool IsPlaced() const { return is_placed_; } |
90 | |
91 String ToString() const; | 107 String ToString() const; |
92 | 108 |
93 // Override RefCounted's deref() to ensure operator delete is called on the | 109 // Override RefCounted's deref() to ensure operator delete is called on the |
94 // appropriate subclass type. | 110 // appropriate subclass type. |
95 void Deref() const { | 111 void Deref() const { |
96 if (DerefBase()) | 112 if (DerefBase()) |
97 Destroy(); | 113 Destroy(); |
98 } | 114 } |
99 | 115 |
100 protected: | 116 protected: |
(...skipping 11 matching lines...) Expand all Loading... |
112 unsigned is_placed_ : 1; | 128 unsigned is_placed_ : 1; |
113 unsigned paint_border_edge_ : 4; // NGPaintBorderEdge | 129 unsigned paint_border_edge_ : 4; // NGPaintBorderEdge |
114 | 130 |
115 private: | 131 private: |
116 void Destroy() const; | 132 void Destroy() const; |
117 }; | 133 }; |
118 | 134 |
119 } // namespace blink | 135 } // namespace blink |
120 | 136 |
121 #endif // NGPhysicalFragment_h | 137 #endif // NGPhysicalFragment_h |
OLD | NEW |