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 | |
57 // The NGPhysicalConstraintSpace contains the underlying data for the | 30 // The NGPhysicalConstraintSpace contains the underlying data for the |
58 // NGConstraintSpace. It is not meant to be used directly as all members are in | 31 // NGConstraintSpace. It is not meant to be used directly as all members are in |
59 // the physical coordinate space. Instead NGConstraintSpace should be used. | 32 // the physical coordinate space. Instead NGConstraintSpace should be used. |
60 class CORE_EXPORT NGPhysicalConstraintSpace final | 33 class CORE_EXPORT NGPhysicalConstraintSpace final |
61 : public GarbageCollectedFinalized<NGPhysicalConstraintSpace> { | 34 : public GarbageCollectedFinalized<NGPhysicalConstraintSpace> { |
62 public: | 35 public: |
63 NGPhysicalConstraintSpace( | 36 NGPhysicalConstraintSpace( |
64 NGPhysicalSize container_size, | 37 NGPhysicalSize container_size, |
65 bool fixed_width, | 38 bool fixed_width, |
66 bool fixed_height, | 39 bool fixed_height, |
67 bool width_direction_triggers_scrollbar, | 40 bool width_direction_triggers_scrollbar, |
68 bool height_direction_triggers_scrollbar, | 41 bool height_direction_triggers_scrollbar, |
69 NGFragmentationType width_direction_fragmentation_type, | 42 NGFragmentationType width_direction_fragmentation_type, |
70 NGFragmentationType height_direction_fragmentation_type, | 43 NGFragmentationType height_direction_fragmentation_type, |
71 bool is_new_fc); | 44 bool is_new_fc); |
72 | 45 |
73 NGPhysicalSize ContainerSize() const { return container_size_; } | 46 NGPhysicalSize ContainerSize() const { return container_size_; } |
74 | 47 |
75 void AddExclusion(const NGExclusion*, unsigned options = 0); | 48 void AddExclusion(const NGLogicalRect&, unsigned options = 0); |
76 const HeapVector<Member<const NGExclusion>>& Exclusions( | 49 const Vector<std::unique_ptr<const NGLogicalRect>>& Exclusions( |
77 unsigned options = 0) const; | 50 unsigned options = 0) const; |
78 | 51 |
79 DEFINE_INLINE_TRACE() { visitor->trace(exclusions_); } | 52 DEFINE_INLINE_TRACE() {} |
80 | 53 |
81 private: | 54 private: |
82 friend class NGConstraintSpace; | 55 friend class NGConstraintSpace; |
83 | 56 |
84 NGPhysicalSize container_size_; | 57 NGPhysicalSize container_size_; |
85 | 58 |
86 unsigned fixed_width_ : 1; | 59 unsigned fixed_width_ : 1; |
87 unsigned fixed_height_ : 1; | 60 unsigned fixed_height_ : 1; |
88 unsigned width_direction_triggers_scrollbar_ : 1; | 61 unsigned width_direction_triggers_scrollbar_ : 1; |
89 unsigned height_direction_triggers_scrollbar_ : 1; | 62 unsigned height_direction_triggers_scrollbar_ : 1; |
90 unsigned width_direction_fragmentation_type_ : 2; | 63 unsigned width_direction_fragmentation_type_ : 2; |
91 unsigned height_direction_fragmentation_type_ : 2; | 64 unsigned height_direction_fragmentation_type_ : 2; |
92 | 65 |
93 // Whether the current constraint space is for the newly established | 66 // Whether the current constraint space is for the newly established |
94 // formatting Context | 67 // formatting Context |
95 unsigned is_new_fc_ : 1; | 68 unsigned is_new_fc_ : 1; |
96 | 69 |
97 HeapVector<Member<const NGExclusion>> exclusions_; | 70 Vector<std::unique_ptr<const NGLogicalRect>> exclusions_; |
98 }; | 71 }; |
99 | 72 |
100 } // namespace blink | 73 } // namespace blink |
101 | 74 |
102 #endif // NGPhysicalConstraintSpace_h | 75 #endif // NGPhysicalConstraintSpace_h |
OLD | NEW |