Chromium Code Reviews| 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/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. | |
|
ikilpatrick
2017/01/20 00:03:17
... this may occurs in situation X.
Gleb Lanbin
2017/01/20 00:45:27
Done.
| |
| 80 const HeapVector<Member<NGFloatingObject>>& UnpositionedFloats() const { | |
| 81 return unpositioned_floats_; | |
| 82 } | |
| 83 | |
| 84 // List of positioned float that need to be copied to the old layout tree. | |
|
ikilpatrick
2017/01/20 00:03:17
maybe... TODO remove this once we change painting
Gleb Lanbin
2017/01/20 00:45:27
Done.
| |
| 85 const HeapVector<Member<NGFloatingObject>>& PositionedFloats() const { | |
| 86 return positioned_floats_; | |
| 87 } | |
| 88 | |
| 75 DECLARE_TRACE_AFTER_DISPATCH(); | 89 DECLARE_TRACE_AFTER_DISPATCH(); |
| 76 DECLARE_TRACE(); | 90 DECLARE_TRACE(); |
| 77 | 91 |
| 78 void finalizeGarbageCollectedObject(); | 92 void finalizeGarbageCollectedObject(); |
| 79 | 93 |
| 80 protected: | 94 protected: |
| 81 NGPhysicalFragment( | 95 NGPhysicalFragment( |
| 82 NGPhysicalSize size, | 96 NGPhysicalSize size, |
| 83 NGPhysicalSize overflow, | 97 NGPhysicalSize overflow, |
| 84 NGFragmentType type, | 98 NGFragmentType type, |
| 85 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants, | 99 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants, |
| 86 Vector<NGStaticPosition> out_of_flow_positions, | 100 Vector<NGStaticPosition> out_of_flow_positions, |
| 101 HeapVector<Member<NGFloatingObject>>& unpositioned_floats, | |
| 102 HeapVector<Member<NGFloatingObject>>& positioned_floats, | |
| 87 NGBreakToken* break_token = nullptr); | 103 NGBreakToken* break_token = nullptr); |
| 88 | 104 |
| 89 NGPhysicalSize size_; | 105 NGPhysicalSize size_; |
| 90 NGPhysicalSize overflow_; | 106 NGPhysicalSize overflow_; |
| 91 NGPhysicalOffset offset_; | 107 NGPhysicalOffset offset_; |
| 92 Member<NGBreakToken> break_token_; | 108 Member<NGBreakToken> break_token_; |
| 93 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_; | 109 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_; |
| 94 Vector<NGStaticPosition> out_of_flow_positions_; | 110 Vector<NGStaticPosition> out_of_flow_positions_; |
| 111 HeapVector<Member<NGFloatingObject>> unpositioned_floats_; | |
| 112 HeapVector<Member<NGFloatingObject>> positioned_floats_; | |
| 95 | 113 |
| 96 unsigned type_ : 1; | 114 unsigned type_ : 1; |
| 97 unsigned has_been_placed_ : 1; | 115 unsigned is_placed_ : 1; |
| 98 }; | 116 }; |
| 99 | 117 |
| 100 } // namespace blink | 118 } // namespace blink |
| 101 | 119 |
| 102 #endif // NGPhysicalFragment_h | 120 #endif // NGPhysicalFragment_h |
| OLD | NEW |