Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h

Issue 2702403003: [layoutng] Split NGLayoutResult out of NGPhysicalFragment (Closed)
Patch Set: rebased Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ng_units.h" 9 #include "core/layout/ng/ng_units.h"
10 #include "platform/LayoutUnit.h" 10 #include "platform/LayoutUnit.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/Vector.h" 12 #include "wtf/Vector.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LayoutObject; 16 class LayoutObject;
17 class NGBlockNode;
18 class NGBreakToken; 17 class NGBreakToken;
19 struct NGFloatingObject;
20 18
21 // The NGPhysicalFragment contains the output information from layout. The 19 // The NGPhysicalFragment contains the output geometry from layout. The
22 // fragment stores all of its information in the physical coordinate system for 20 // fragment stores all of its information in the physical coordinate system for
23 // use by paint, hit-testing etc. 21 // use by paint, hit-testing etc.
24 // 22 //
25 // The fragment keeps a pointer back to the LayoutObject which generated it. 23 // The fragment keeps a pointer back to the LayoutObject which generated it.
26 // Once we have transitioned fully to LayoutNG it should be a const pointer 24 // Once we have transitioned fully to LayoutNG it should be a const pointer
27 // such that paint/hit-testing/etc don't modify it. 25 // such that paint/hit-testing/etc don't modify it.
28 // 26 //
29 // Layout code should only access output layout information through the 27 // Layout code should only access geometry information through the
30 // NGFragmentBase classes which transforms information into the logical 28 // NGFragment wrapper classes which transforms information into the logical
31 // coordinate system. 29 // coordinate system.
32 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> { 30 class CORE_EXPORT NGPhysicalFragment : public RefCounted<NGPhysicalFragment> {
33 public: 31 public:
34 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 }; 32 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 };
35 33
36 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } 34 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
37 35
38 // Override RefCounted's deref() to ensure operator delete is called on the 36 // Override RefCounted's deref() to ensure operator delete is called on the
39 // appropriate subclass type. 37 // appropriate subclass type.
40 void deref() const { 38 void deref() const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void SetOffset(NGPhysicalOffset offset) { 73 void SetOffset(NGPhysicalOffset offset) {
76 DCHECK(!is_placed_); 74 DCHECK(!is_placed_);
77 offset_ = offset; 75 offset_ = offset;
78 is_placed_ = true; 76 is_placed_ = true;
79 } 77 }
80 78
81 NGBreakToken* BreakToken() const { return break_token_; } 79 NGBreakToken* BreakToken() const { return break_token_; }
82 80
83 LayoutObject* GetLayoutObject() const { return layout_object_; } 81 LayoutObject* GetLayoutObject() const { return layout_object_; }
84 82
85 const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants()
86 const {
87 return out_of_flow_descendants_;
88 }
89
90 const Vector<NGStaticPosition>& OutOfFlowPositions() const {
91 return out_of_flow_positions_;
92 }
93
94 bool IsPlaced() const { return is_placed_; } 83 bool IsPlaced() const { return is_placed_; }
95 84
96 // List of floats that need to be positioned by the next in-flow child that
97 // can determine its position in space.
98 // Use case example where it may be needed:
99 // <div><float></div>
100 // <div style="margin-top: 10px; height: 20px"></div>
101 // The float cannot be positioned right away inside of the 1st div because
102 // the vertical position is not known at that moment. It will be known only
103 // after the 2nd div collapses its margin with its parent.
104 const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const {
105 return unpositioned_floats_;
106 }
107
108 // List of positioned float that need to be copied to the old layout tree.
109 // TODO(layout-ng): remove this once we change painting code to handle floats
110 // differently.
111 const Vector<Persistent<NGFloatingObject>>& PositionedFloats() const {
112 return positioned_floats_;
113 }
114
115 protected: 85 protected:
116 NGPhysicalFragment(LayoutObject* layout_object, 86 NGPhysicalFragment(LayoutObject* layout_object,
117 NGPhysicalSize size, 87 NGPhysicalSize size,
118 NGPhysicalSize overflow, 88 NGPhysicalSize overflow,
119 NGFragmentType type, 89 NGFragmentType type,
120 PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>>&
121 out_of_flow_descendants,
122 Vector<NGStaticPosition> out_of_flow_positions,
123 Vector<Persistent<NGFloatingObject>>& unpositioned_floats,
124 Vector<Persistent<NGFloatingObject>>& positioned_floats,
125 NGBreakToken* break_token = nullptr); 90 NGBreakToken* break_token = nullptr);
126 91
127 LayoutObject* layout_object_; 92 LayoutObject* layout_object_;
128 NGPhysicalSize size_; 93 NGPhysicalSize size_;
129 NGPhysicalSize overflow_; 94 NGPhysicalSize overflow_;
130 NGPhysicalOffset offset_; 95 NGPhysicalOffset offset_;
131 Persistent<NGBreakToken> break_token_; 96 Persistent<NGBreakToken> break_token_;
132 PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
133 Vector<NGStaticPosition> out_of_flow_positions_;
134 Vector<Persistent<NGFloatingObject>> unpositioned_floats_;
135 Vector<Persistent<NGFloatingObject>> positioned_floats_;
136 97
137 unsigned type_ : 1; 98 unsigned type_ : 1;
138 unsigned is_placed_ : 1; 99 unsigned is_placed_ : 1;
139 100
140 private: 101 private:
141 void destroy() const; 102 void destroy() const;
142 }; 103 };
143 104
144 } // namespace blink 105 } // namespace blink
145 106
146 #endif // NGPhysicalFragment_h 107 #endif // NGPhysicalFragment_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698