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/DoublyLinkedList.h" | 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/WTFString.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 enum NGExclusionType { | 16 enum NGExclusionType { |
16 NGClearNone = 0, | 17 NGClearNone = 0, |
17 NGClearFloatLeft = 1, | 18 NGClearFloatLeft = 1, |
18 NGClearFloatRight = 2, | 19 NGClearFloatRight = 2, |
19 NGClearFragment = 4 | 20 NGClearFragment = 4 |
20 }; | 21 }; |
21 | 22 |
22 enum NGFragmentationType { | 23 enum NGFragmentationType { |
23 FragmentNone, | 24 FragmentNone, |
24 FragmentPage, | 25 FragmentPage, |
25 FragmentColumn, | 26 FragmentColumn, |
26 FragmentRegion | 27 FragmentRegion |
27 }; | 28 }; |
28 | 29 |
29 class NGExclusion { | 30 struct NGExclusion { |
30 public: | 31 NGExclusion(LayoutUnit top, |
31 NGExclusion(); | 32 LayoutUnit right, |
32 ~NGExclusion() {} | 33 LayoutUnit bottom, |
| 34 LayoutUnit left) { |
| 35 rect.location.left = left; |
| 36 rect.location.top = top; |
| 37 rect.size.width = right - left; |
| 38 rect.size.height = bottom - top; |
| 39 } |
| 40 LayoutUnit Top() const { return rect.location.top; } |
| 41 LayoutUnit Right() const { return rect.size.width + rect.location.left; } |
| 42 LayoutUnit Bottom() const { return rect.size.height + rect.location.top; } |
| 43 LayoutUnit Left() const { return rect.location.left; } |
| 44 String toString() const { |
| 45 return String::format( |
| 46 "Exclusion: %0.2f, %0.2f, size: %0.2f, %0.2f (right %0.2f)", |
| 47 rect.location.left.toFloat(), rect.location.top.toFloat(), |
| 48 rect.size.width.toFloat(), rect.size.height.toFloat(), |
| 49 Right().toFloat()); |
| 50 } |
| 51 NGPhysicalRect rect; |
33 }; | 52 }; |
34 | 53 |
35 // The NGPhysicalConstraintSpace contains the underlying data for the | 54 // The NGPhysicalConstraintSpace contains the underlying data for the |
36 // NGConstraintSpace. It is not meant to be used directly as all members are in | 55 // NGConstraintSpace. It is not meant to be used directly as all members are in |
37 // the physical coordinate space. Instead NGConstraintSpace should be used. | 56 // the physical coordinate space. Instead NGConstraintSpace should be used. |
38 class CORE_EXPORT NGPhysicalConstraintSpace final | 57 class CORE_EXPORT NGPhysicalConstraintSpace final |
39 : public GarbageCollected<NGPhysicalConstraintSpace> { | 58 : public GarbageCollectedFinalized<NGPhysicalConstraintSpace> { |
40 public: | 59 public: |
41 NGPhysicalConstraintSpace(); | 60 NGPhysicalConstraintSpace(); |
42 NGPhysicalConstraintSpace(NGPhysicalSize); | 61 NGPhysicalConstraintSpace(NGPhysicalSize); |
43 NGPhysicalConstraintSpace(const NGPhysicalConstraintSpace&); | 62 NGPhysicalConstraintSpace(const NGPhysicalConstraintSpace&); |
44 | 63 |
45 NGPhysicalSize ContainerSize() const { return container_size_; } | 64 NGPhysicalSize ContainerSize() const { return container_size_; } |
46 | 65 |
47 void AddExclusion(const NGExclusion, unsigned options = 0); | 66 void AddExclusion(const NGExclusion, unsigned options = 0); |
48 const DoublyLinkedList<const NGExclusion>* Exclusions( | 67 const Vector<NGExclusion>& Exclusions(unsigned options = 0) const; |
49 unsigned options = 0) const; | |
50 | 68 |
51 DEFINE_INLINE_TRACE() {} | 69 DEFINE_INLINE_TRACE() {} |
52 | 70 |
53 private: | 71 private: |
54 friend class NGConstraintSpace; | 72 friend class NGConstraintSpace; |
55 | 73 |
56 NGPhysicalSize container_size_; | 74 NGPhysicalSize container_size_; |
57 | 75 |
58 unsigned fixed_width_ : 1; | 76 unsigned fixed_width_ : 1; |
59 unsigned fixed_height_ : 1; | 77 unsigned fixed_height_ : 1; |
60 unsigned width_direction_triggers_scrollbar_ : 1; | 78 unsigned width_direction_triggers_scrollbar_ : 1; |
61 unsigned height_direction_triggers_scrollbar_ : 1; | 79 unsigned height_direction_triggers_scrollbar_ : 1; |
62 unsigned width_direction_fragmentation_type_ : 2; | 80 unsigned width_direction_fragmentation_type_ : 2; |
63 unsigned height_direction_fragmentation_type_ : 2; | 81 unsigned height_direction_fragmentation_type_ : 2; |
64 | 82 |
65 DoublyLinkedList<const NGExclusion> exclusions_; | 83 Vector<NGExclusion> exclusions_; |
66 }; | 84 }; |
67 | 85 |
68 } // namespace blink | 86 } // namespace blink |
69 | 87 |
70 #endif // NGPhysicalConstraintSpace_h | 88 #endif // NGPhysicalConstraintSpace_h |
OLD | NEW |