| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NGPhysicalFragmentBase_h | |
| 6 #define NGPhysicalFragmentBase_h | |
| 7 | |
| 8 #include "core/CoreExport.h" | |
| 9 #include "core/layout/ng/ng_units.h" | |
| 10 #include "platform/LayoutUnit.h" | |
| 11 #include "platform/heap/Handle.h" | |
| 12 #include "wtf/Vector.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class NGBlockNode; | |
| 17 class NGBreakToken; | |
| 18 | |
| 19 // The NGPhysicalFragmentBase contains the output information from layout. The | |
| 20 // fragment stores all of its information in the physical coordinate system for | |
| 21 // use by paint, hit-testing etc. | |
| 22 // | |
| 23 // Layout code should only access output layout information through the | |
| 24 // NGFragmentBase classes which transforms information into the logical | |
| 25 // coordinate system. | |
| 26 class CORE_EXPORT NGPhysicalFragmentBase | |
| 27 : public GarbageCollectedFinalized<NGPhysicalFragmentBase> { | |
| 28 public: | |
| 29 enum NGFragmentType { kFragmentBox = 0, kFragmentText = 1 }; | |
| 30 | |
| 31 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } | |
| 32 | |
| 33 // 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 // exist for paint, hit-testing, etc. | |
| 36 | |
| 37 // Returns the border-box size. | |
| 38 NGPhysicalSize Size() const { return size_; } | |
| 39 LayoutUnit Width() const { return size_.width; } | |
| 40 LayoutUnit Height() const { return size_.height; } | |
| 41 | |
| 42 // Returns the total size, including the contents outside of the border-box. | |
| 43 LayoutUnit WidthOverflow() const { return overflow_.width; } | |
| 44 LayoutUnit HeightOverflow() const { return overflow_.height; } | |
| 45 | |
| 46 // Returns the offset relative to the parent fragement's content-box. | |
| 47 LayoutUnit LeftOffset() const { | |
| 48 DCHECK(has_been_placed_); | |
| 49 return offset_.left; | |
| 50 } | |
| 51 | |
| 52 LayoutUnit TopOffset() const { | |
| 53 DCHECK(has_been_placed_); | |
| 54 return offset_.top; | |
| 55 } | |
| 56 | |
| 57 // Should only be used by the parent fragement's layout. | |
| 58 void SetOffset(NGPhysicalOffset offset) { | |
| 59 DCHECK(!has_been_placed_); | |
| 60 offset_ = offset; | |
| 61 has_been_placed_ = true; | |
| 62 } | |
| 63 | |
| 64 const HeapLinkedHashSet<WeakMember<NGBlockNode>>& OutOfFlowDescendants() | |
| 65 const { | |
| 66 return out_of_flow_descendants_; | |
| 67 } | |
| 68 | |
| 69 const Vector<NGStaticPosition>& OutOfFlowPositions() const { | |
| 70 return out_of_flow_positions_; | |
| 71 } | |
| 72 | |
| 73 DECLARE_TRACE_AFTER_DISPATCH(); | |
| 74 DECLARE_TRACE(); | |
| 75 | |
| 76 void finalizeGarbageCollectedObject(); | |
| 77 | |
| 78 protected: | |
| 79 NGPhysicalFragmentBase( | |
| 80 NGPhysicalSize size, | |
| 81 NGPhysicalSize overflow, | |
| 82 NGFragmentType type, | |
| 83 HeapLinkedHashSet<WeakMember<NGBlockNode>>& out_of_flow_descendants, | |
| 84 Vector<NGStaticPosition> out_of_flow_positions, | |
| 85 NGBreakToken* break_token = nullptr); | |
| 86 | |
| 87 NGPhysicalSize size_; | |
| 88 NGPhysicalSize overflow_; | |
| 89 NGPhysicalOffset offset_; | |
| 90 Member<NGBreakToken> break_token_; | |
| 91 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_descendants_; | |
| 92 Vector<NGStaticPosition> out_of_flow_positions_; | |
| 93 | |
| 94 unsigned type_ : 1; | |
| 95 unsigned has_been_placed_ : 1; | |
| 96 }; | |
| 97 | |
| 98 } // namespace blink | |
| 99 | |
| 100 #endif // NGFragmentBase_h | |
| OLD | NEW |