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_constraint_space.h" |
| 10 #include "platform/LayoutUnit.h" |
| 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/Vector.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 // The NGPhysicalFragmentBase contains the output information from layout. The |
| 17 // fragment stores all of its information in the physical coordinate system for |
| 18 // use by paint, hit-testing etc. |
| 19 // |
| 20 // Layout code should only access output layout information through the |
| 21 // NGFragmentBase classes which transforms infromation into the logical |
| 22 // coordinate system. |
| 23 class CORE_EXPORT NGPhysicalFragmentBase |
| 24 : public GarbageCollected<NGPhysicalFragmentBase> { |
| 25 public: |
| 26 enum NGFragmentType { FragmentBox = 0, FragmentText = 1 }; |
| 27 |
| 28 NGFragmentType Type() const { return static_cast<NGFragmentType>(type_); } |
| 29 |
| 30 // The accessors in this class shouldn't be used by layout code directly, |
| 31 // instead should be accessed by the NGFragmentBase classes. These accessors |
| 32 // exist for paint, hit-testing, etc. |
| 33 |
| 34 // Returns the border-box size. |
| 35 NGPhysicalSize Size() const { return size_; } |
| 36 LayoutUnit Width() const { return size_.width; } |
| 37 LayoutUnit Height() const { return size_.height; } |
| 38 |
| 39 // Returns the total size, including the contents outside of the border-box. |
| 40 LayoutUnit WidthOverflow() const { return overflow_.width; } |
| 41 LayoutUnit HeightOverflow() const { return overflow_.height; } |
| 42 |
| 43 // Returns the offset relative to the parent fragement's content-box. |
| 44 LayoutUnit LeftOffset() const { |
| 45 DCHECK(has_been_placed_); |
| 46 return offset_.left; |
| 47 } |
| 48 |
| 49 LayoutUnit TopOffset() const { |
| 50 DCHECK(has_been_placed_); |
| 51 return offset_.top; |
| 52 } |
| 53 |
| 54 // Should only be used by the parent fragement's layout. |
| 55 void SetOffset(NGPhysicalOffset offset) { |
| 56 DCHECK(!has_been_placed_); |
| 57 offset_ = offset; |
| 58 has_been_placed_ = true; |
| 59 } |
| 60 |
| 61 DEFINE_INLINE_TRACE_AFTER_DISPATCH() {} |
| 62 DECLARE_TRACE(); |
| 63 |
| 64 protected: |
| 65 NGPhysicalFragmentBase(NGPhysicalSize size, |
| 66 NGPhysicalSize overflow, |
| 67 NGFragmentType type) |
| 68 : size_(size), |
| 69 overflow_(overflow), |
| 70 type_(type), |
| 71 has_been_placed_(false) {} |
| 72 |
| 73 NGPhysicalSize size_; |
| 74 NGPhysicalSize overflow_; |
| 75 NGPhysicalOffset offset_; |
| 76 |
| 77 unsigned type_ : 1; |
| 78 unsigned has_been_placed_ : 1; |
| 79 }; |
| 80 |
| 81 } // namespace blink |
| 82 |
| 83 #endif // NGFragmentBase_h |
OLD | NEW |