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

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

Issue 2642823008: Introduce NGFloatingObject (Closed)
Patch Set: Update TestExpectations Created 3 years, 11 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 NGBlockNode; 16 class NGBlockNode;
17 class NGBreakToken; 17 class NGBreakToken;
18 struct NGFloatingObject;
18 19
19 // The NGPhysicalFragmentBase contains the output information from layout. The 20 // The NGPhysicalFragment contains the output information from layout. The
20 // fragment stores all of its information in the physical coordinate system for 21 // fragment stores all of its information in the physical coordinate system for
21 // use by paint, hit-testing etc. 22 // use by paint, hit-testing etc.
22 // 23 //
23 // Layout code should only access output layout information through the 24 // Layout code should only access output layout information through the
24 // NGFragmentBase classes which transforms information into the logical 25 // NGFragmentBase classes which transforms information into the logical
25 // coordinate system. 26 // coordinate system.
26 class CORE_EXPORT NGPhysicalFragment 27 class CORE_EXPORT NGPhysicalFragment
27 : public GarbageCollectedFinalized<NGPhysicalFragment> { 28 : public GarbageCollectedFinalized<NGPhysicalFragment> {
28 public: 29 public:
29 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 }; 30 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 };
30 31
31 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } 32 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); }
32 33
33 // The accessors in this class shouldn't be used by layout code directly, 34 // The accessors in this class shouldn't be used by layout code directly,
34 // instead should be accessed by the NGFragmentBase classes. These accessors 35 // instead should be accessed by the NGFragmentBase classes. These accessors
35 // exist for paint, hit-testing, etc. 36 // exist for paint, hit-testing, etc.
36 37
37 // Returns the border-box size. 38 // Returns the border-box size.
38 NGPhysicalSize Size() const { return size_; } 39 NGPhysicalSize Size() const { return size_; }
39 LayoutUnit Width() const { return size_.width; } 40 LayoutUnit Width() const { return size_.width; }
40 LayoutUnit Height() const { return size_.height; } 41 LayoutUnit Height() const { return size_.height; }
41 42
42 // Returns the total size, including the contents outside of the border-box. 43 // Returns the total size, including the contents outside of the border-box.
43 LayoutUnit WidthOverflow() const { return overflow_.width; } 44 LayoutUnit WidthOverflow() const { return overflow_.width; }
44 LayoutUnit HeightOverflow() const { return overflow_.height; } 45 LayoutUnit HeightOverflow() const { return overflow_.height; }
45 46
46 // Returns the offset relative to the parent fragement's content-box. 47 // Returns the offset relative to the parent fragement's content-box.
47 LayoutUnit LeftOffset() const { 48 LayoutUnit LeftOffset() const {
48 DCHECK(has_been_placed_); 49 DCHECK(is_placed_);
49 return offset_.left; 50 return offset_.left;
50 } 51 }
51 52
52 LayoutUnit TopOffset() const { 53 LayoutUnit TopOffset() const {
53 DCHECK(has_been_placed_); 54 DCHECK(is_placed_);
54 return offset_.top; 55 return offset_.top;
55 } 56 }
56 57
57 // Should only be used by the parent fragement's layout. 58 // Should only be used by the parent fragement's layout.
58 void SetOffset(NGPhysicalOffset offset) { 59 void SetOffset(NGPhysicalOffset offset) {
59 DCHECK(!has_been_placed_); 60 DCHECK(!is_placed_);
60 offset_ = offset; 61 offset_ = offset;
61 has_been_placed_ = true; 62 is_placed_ = true;
62 } 63 }
63 64
64 NGBreakToken* BreakToken() const { return break_token_; } 65 NGBreakToken* BreakToken() const { return break_token_; }
65 66
66 const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants() 67 const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants()
67 const { 68 const {
68 return out_of_flow_descendants_; 69 return out_of_flow_descendants_;
69 } 70 }
70 71
71 const Vector<NGStaticPosition>& OutOfFlowPositions() const { 72 const Vector<NGStaticPosition>& OutOfFlowPositions() const {
72 return out_of_flow_positions_; 73 return out_of_flow_positions_;
73 } 74 }
74 75
76 bool IsPlaced() const { return is_placed_; }
77
78 // List of floats that need to be positioned by the next in-flow child that
79 // can determine its position in space.
80 // Use case example where it may be needed:
81 // <div><float></div>
82 // <div style="margin-top: 10px; height: 20px"></div>
83 // The float cannot be positioned right away inside of the 1st div because
84 // the vertical position is not known at that moment. It will be known only
85 // after the 2nd div collapses its margin with its parent.
86 const HeapVector<Member<NGFloatingObject>>& UnpositionedFloats() const {
87 return unpositioned_floats_;
88 }
89
90 // List of positioned float that need to be copied to the old layout tree.
91 // TODO(layout-ng): remove this once we change painting code to handle floats
92 // differently.
93 const HeapVector<Member<NGFloatingObject>>& PositionedFloats() const {
94 return positioned_floats_;
95 }
96
75 DECLARE_TRACE_AFTER_DISPATCH(); 97 DECLARE_TRACE_AFTER_DISPATCH();
76 DECLARE_TRACE(); 98 DECLARE_TRACE();
77 99
78 void finalizeGarbageCollectedObject(); 100 void finalizeGarbageCollectedObject();
79 101
80 protected: 102 protected:
81 NGPhysicalFragment( 103 NGPhysicalFragment(
82 NGPhysicalSize size, 104 NGPhysicalSize size,
83 NGPhysicalSize overflow, 105 NGPhysicalSize overflow,
84 NGFragmentType type, 106 NGFragmentType type,
85 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants, 107 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants,
86 Vector<NGStaticPosition> out_of_flow_positions, 108 Vector<NGStaticPosition> out_of_flow_positions,
109 HeapVector<Member<NGFloatingObject>>& unpositioned_floats,
110 HeapVector<Member<NGFloatingObject>>& positioned_floats,
87 NGBreakToken* break_token = nullptr); 111 NGBreakToken* break_token = nullptr);
88 112
89 NGPhysicalSize size_; 113 NGPhysicalSize size_;
90 NGPhysicalSize overflow_; 114 NGPhysicalSize overflow_;
91 NGPhysicalOffset offset_; 115 NGPhysicalOffset offset_;
92 Member<NGBreakToken> break_token_; 116 Member<NGBreakToken> break_token_;
93 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_; 117 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_;
94 Vector<NGStaticPosition> out_of_flow_positions_; 118 Vector<NGStaticPosition> out_of_flow_positions_;
119 HeapVector<Member<NGFloatingObject>> unpositioned_floats_;
120 HeapVector<Member<NGFloatingObject>> positioned_floats_;
95 121
96 unsigned type_ : 1; 122 unsigned type_ : 1;
97 unsigned has_been_placed_ : 1; 123 unsigned is_placed_ : 1;
98 }; 124 };
99 125
100 } // namespace blink 126 } // namespace blink
101 127
102 #endif // NGPhysicalFragment_h 128 #endif // NGPhysicalFragment_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698