| 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 NGPhysicalConstraintSpace_h | 5 #ifndef NGPhysicalConstraintSpace_h |
| 6 #define NGPhysicalConstraintSpace_h | 6 #define NGPhysicalConstraintSpace_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/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 enum NGExclusionType { | 16 enum NGExclusionType { |
| 17 NGClearNone = 0, | 17 NGClearNone = 0, |
| 18 NGClearFloatLeft = 1, | 18 NGClearFloatLeft = 1, |
| 19 NGClearFloatRight = 2, | 19 NGClearFloatRight = 2, |
| 20 NGClearFragment = 4 | 20 NGClearFragment = 4 |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 enum NGFragmentationType { | 23 enum NGFragmentationType { |
| 24 FragmentNone, | 24 FragmentNone, |
| 25 FragmentPage, | 25 FragmentPage, |
| 26 FragmentColumn, | 26 FragmentColumn, |
| 27 FragmentRegion | 27 FragmentRegion |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 struct NGExclusion : public GarbageCollected<NGExclusion> { |
| 31 NGExclusion(LayoutUnit top, |
| 32 LayoutUnit right, |
| 33 LayoutUnit bottom, |
| 34 LayoutUnit left) { |
| 35 rect.offset.left = left; |
| 36 rect.offset.top = top; |
| 37 rect.size.width = right - left; |
| 38 rect.size.height = bottom - top; |
| 39 } |
| 40 LayoutUnit Top() const { return rect.offset.top; } |
| 41 LayoutUnit Right() const { return rect.size.width + rect.offset.left; } |
| 42 LayoutUnit Bottom() const { return rect.size.height + rect.offset.top; } |
| 43 LayoutUnit Left() const { return rect.offset.left; } |
| 44 |
| 45 String ToString() const { |
| 46 return String::format("%s,%s %sx%s", |
| 47 rect.offset.left.toString().ascii().data(), |
| 48 rect.offset.top.toString().ascii().data(), |
| 49 rect.size.width.toString().ascii().data(), |
| 50 rect.size.height.toString().ascii().data()); |
| 51 } |
| 52 NGPhysicalRect rect; |
| 53 |
| 54 DEFINE_INLINE_TRACE() {} |
| 55 }; |
| 56 |
| 30 // The NGPhysicalConstraintSpace contains the underlying data for the | 57 // The NGPhysicalConstraintSpace contains the underlying data for the |
| 31 // NGConstraintSpace. It is not meant to be used directly as all members are in | 58 // NGConstraintSpace. It is not meant to be used directly as all members are in |
| 32 // the physical coordinate space. Instead NGConstraintSpace should be used. | 59 // the physical coordinate space. Instead NGConstraintSpace should be used. |
| 33 class CORE_EXPORT NGPhysicalConstraintSpace final | 60 class CORE_EXPORT NGPhysicalConstraintSpace final |
| 34 : public GarbageCollectedFinalized<NGPhysicalConstraintSpace> { | 61 : public GarbageCollectedFinalized<NGPhysicalConstraintSpace> { |
| 35 public: | 62 public: |
| 36 NGPhysicalConstraintSpace( | 63 NGPhysicalConstraintSpace( |
| 37 NGPhysicalSize container_size, | 64 NGPhysicalSize container_size, |
| 38 bool fixed_width, | 65 bool fixed_width, |
| 39 bool fixed_height, | 66 bool fixed_height, |
| 40 bool width_direction_triggers_scrollbar, | 67 bool width_direction_triggers_scrollbar, |
| 41 bool height_direction_triggers_scrollbar, | 68 bool height_direction_triggers_scrollbar, |
| 42 NGFragmentationType width_direction_fragmentation_type, | 69 NGFragmentationType width_direction_fragmentation_type, |
| 43 NGFragmentationType height_direction_fragmentation_type, | 70 NGFragmentationType height_direction_fragmentation_type, |
| 44 bool is_new_fc); | 71 bool is_new_fc); |
| 45 | 72 |
| 46 NGPhysicalSize ContainerSize() const { return container_size_; } | 73 NGPhysicalSize ContainerSize() const { return container_size_; } |
| 47 | 74 |
| 48 void AddExclusion(const NGLogicalRect&, unsigned options = 0); | 75 void AddExclusion(const NGExclusion*, unsigned options = 0); |
| 49 const Vector<std::unique_ptr<const NGLogicalRect>>& Exclusions( | 76 const HeapVector<Member<const NGExclusion>>& Exclusions( |
| 50 unsigned options = 0) const; | 77 unsigned options = 0) const; |
| 51 | 78 |
| 52 DEFINE_INLINE_TRACE() {} | 79 DEFINE_INLINE_TRACE() { visitor->trace(exclusions_); } |
| 53 | 80 |
| 54 private: | 81 private: |
| 55 friend class NGConstraintSpace; | 82 friend class NGConstraintSpace; |
| 56 | 83 |
| 57 NGPhysicalSize container_size_; | 84 NGPhysicalSize container_size_; |
| 58 | 85 |
| 59 unsigned fixed_width_ : 1; | 86 unsigned fixed_width_ : 1; |
| 60 unsigned fixed_height_ : 1; | 87 unsigned fixed_height_ : 1; |
| 61 unsigned width_direction_triggers_scrollbar_ : 1; | 88 unsigned width_direction_triggers_scrollbar_ : 1; |
| 62 unsigned height_direction_triggers_scrollbar_ : 1; | 89 unsigned height_direction_triggers_scrollbar_ : 1; |
| 63 unsigned width_direction_fragmentation_type_ : 2; | 90 unsigned width_direction_fragmentation_type_ : 2; |
| 64 unsigned height_direction_fragmentation_type_ : 2; | 91 unsigned height_direction_fragmentation_type_ : 2; |
| 65 | 92 |
| 66 // Whether the current constraint space is for the newly established | 93 // Whether the current constraint space is for the newly established |
| 67 // formatting Context | 94 // formatting Context |
| 68 unsigned is_new_fc_ : 1; | 95 unsigned is_new_fc_ : 1; |
| 69 | 96 |
| 70 Vector<std::unique_ptr<const NGLogicalRect>> exclusions_; | 97 HeapVector<Member<const NGExclusion>> exclusions_; |
| 71 }; | 98 }; |
| 72 | 99 |
| 73 } // namespace blink | 100 } // namespace blink |
| 74 | 101 |
| 75 #endif // NGPhysicalConstraintSpace_h | 102 #endif // NGPhysicalConstraintSpace_h |
| OLD | NEW |