Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h

Issue 2655783006: Top down version of algorithm to position margins and floats in LayoutNG (Closed)
Patch Set: git rebase-update Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 NGConstraintSpace_h 5 #ifndef NGConstraintSpace_h
6 #define NGConstraintSpace_h 6 #define NGConstraintSpace_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 "core/layout/ng/ng_writing_mode.h" 10 #include "core/layout/ng/ng_writing_mode.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/Optional.h"
12 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class LayoutBox; 17 class LayoutBox;
17 class NGBoxFragment; 18 class NGBoxFragment;
18 class NGLayoutOpportunityIterator; 19 class NGLayoutOpportunityIterator;
19 20
20 // TODO(glebl@): unused, delete.
21 enum NGExclusionType {
22 kNGClearNone = 0,
23 kNGClearFloatLeft = 1,
24 kNGClearFloatRight = 2,
25 kNGClearFragment = 4
26 };
27
28 enum NGFragmentationType { 21 enum NGFragmentationType {
29 kFragmentNone, 22 kFragmentNone,
30 kFragmentPage, 23 kFragmentPage,
31 kFragmentColumn, 24 kFragmentColumn,
32 kFragmentRegion 25 kFragmentRegion
33 }; 26 };
34 27
35 // The NGConstraintSpace represents a set of constraints and available space 28 // The NGConstraintSpace represents a set of constraints and available space
36 // which a layout algorithm may produce a NGFragment within. 29 // which a layout algorithm may produce a NGFragment within.
37 class CORE_EXPORT NGConstraintSpace final 30 class CORE_EXPORT NGConstraintSpace final
(...skipping 20 matching lines...) Expand all
58 // The size to use for percentage resolution. 51 // The size to use for percentage resolution.
59 // See: https://drafts.csswg.org/css-sizing/#percentage-sizing 52 // See: https://drafts.csswg.org/css-sizing/#percentage-sizing
60 NGLogicalSize PercentageResolutionSize() const { 53 NGLogicalSize PercentageResolutionSize() const {
61 return percentage_resolution_size_; 54 return percentage_resolution_size_;
62 } 55 }
63 56
64 // The available space size. 57 // The available space size.
65 // See: https://drafts.csswg.org/css-sizing/#available 58 // See: https://drafts.csswg.org/css-sizing/#available
66 NGLogicalSize AvailableSize() const { return available_size_; } 59 NGLogicalSize AvailableSize() const { return available_size_; }
67 60
68 // Offset relative to the root constraint space.
69 NGLogicalOffset Offset() const { return offset_; }
70 // TODO(layout-ng): Set offset via NGConstraintSpacebuilder.
71 void SetOffset(const NGLogicalOffset& offset) { offset_ = offset; }
72
73 // Return the block-direction space available in the current fragmentainer. 61 // Return the block-direction space available in the current fragmentainer.
74 LayoutUnit FragmentainerSpaceAvailable() const { 62 LayoutUnit FragmentainerSpaceAvailable() const {
75 DCHECK(HasBlockFragmentation()); 63 DCHECK(HasBlockFragmentation());
76 return fragmentainer_space_available_; 64 return fragmentainer_space_available_;
77 } 65 }
78 66
79 // Whether the current constraint space is for the newly established 67 // Whether the current constraint space is for the newly established
80 // Formatting Context. 68 // Formatting Context.
81 bool IsNewFormattingContext() const { return is_new_fc_; } 69 bool IsNewFormattingContext() const { return is_new_fc_; }
82 70
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool HasBlockFragmentation() const { 103 bool HasBlockFragmentation() const {
116 return BlockFragmentationType() != kFragmentNone; 104 return BlockFragmentationType() != kFragmentNone;
117 } 105 }
118 106
119 // Modifies constraint space to account for a placed fragment. Depending on 107 // Modifies constraint space to account for a placed fragment. Depending on
120 // the shape of the fragment this will either modify the inline or block 108 // the shape of the fragment this will either modify the inline or block
121 // size, or add an exclusion. 109 // size, or add an exclusion.
122 void Subtract(const NGBoxFragment*); 110 void Subtract(const NGBoxFragment*);
123 111
124 NGLayoutOpportunityIterator* LayoutOpportunities( 112 NGLayoutOpportunityIterator* LayoutOpportunities(
125 unsigned clear = kNGClearNone, 113 const WTF::Optional<NGLogicalOffset>& opt_origin_point = WTF::nullopt);
126 bool for_inline_or_bfc = false); 114
115 NGMarginStrut MarginStrut() const { return margin_strut_; }
116
117 NGLogicalOffset BfcOffset() const { return bfc_offset_; }
127 118
128 DEFINE_INLINE_VIRTUAL_TRACE() {} 119 DEFINE_INLINE_VIRTUAL_TRACE() {}
129 120
130 String ToString() const; 121 String ToString() const;
131 122
132 private: 123 private:
133 friend class NGConstraintSpaceBuilder; 124 friend class NGConstraintSpaceBuilder;
134 // Default constructor. 125 // Default constructor.
135 NGConstraintSpace(NGWritingMode, 126 NGConstraintSpace(NGWritingMode,
136 TextDirection, 127 TextDirection,
137 NGLogicalSize available_size, 128 NGLogicalSize available_size,
138 NGLogicalSize percentage_resolution_size, 129 NGLogicalSize percentage_resolution_size,
139 LayoutUnit fragmentainer_space_available, 130 LayoutUnit fragmentainer_space_available,
140 bool is_fixed_size_inline, 131 bool is_fixed_size_inline,
141 bool is_fixed_size_block, 132 bool is_fixed_size_block,
142 bool is_shrink_to_fit, 133 bool is_shrink_to_fit,
143 bool is_inline_direction_triggers_scrollbar, 134 bool is_inline_direction_triggers_scrollbar,
144 bool is_block_direction_triggers_scrollbar, 135 bool is_block_direction_triggers_scrollbar,
145 NGFragmentationType block_direction_fragmentation_type, 136 NGFragmentationType block_direction_fragmentation_type,
146 bool is_new_fc, 137 bool is_new_fc,
138 const NGMarginStrut& margin_strut,
139 const NGLogicalOffset& bfc_offset,
147 const std::shared_ptr<NGExclusions>& exclusions); 140 const std::shared_ptr<NGExclusions>& exclusions);
148 141
149 NGLogicalSize available_size_; 142 NGLogicalSize available_size_;
150 NGLogicalSize percentage_resolution_size_; 143 NGLogicalSize percentage_resolution_size_;
151 144
152 LayoutUnit fragmentainer_space_available_; 145 LayoutUnit fragmentainer_space_available_;
153 146
154 unsigned is_fixed_size_inline_ : 1; 147 unsigned is_fixed_size_inline_ : 1;
155 unsigned is_fixed_size_block_ : 1; 148 unsigned is_fixed_size_block_ : 1;
156 149
157 unsigned is_shrink_to_fit_ : 1; 150 unsigned is_shrink_to_fit_ : 1;
158 151
159 unsigned is_inline_direction_triggers_scrollbar_ : 1; 152 unsigned is_inline_direction_triggers_scrollbar_ : 1;
160 unsigned is_block_direction_triggers_scrollbar_ : 1; 153 unsigned is_block_direction_triggers_scrollbar_ : 1;
161 154
162 unsigned block_direction_fragmentation_type_ : 2; 155 unsigned block_direction_fragmentation_type_ : 2;
163 156
164 // Whether the current constraint space is for the newly established 157 // Whether the current constraint space is for the newly established
165 // formatting Context 158 // formatting Context
166 unsigned is_new_fc_ : 1; 159 unsigned is_new_fc_ : 1;
167 160
168 NGLogicalOffset offset_;
169 unsigned writing_mode_ : 3; 161 unsigned writing_mode_ : 3;
170 unsigned direction_ : 1; 162 unsigned direction_ : 1;
171 163
164 NGMarginStrut margin_strut_;
165 NGLogicalOffset bfc_offset_;
172 const std::shared_ptr<NGExclusions> exclusions_; 166 const std::shared_ptr<NGExclusions> exclusions_;
173 }; 167 };
174 168
175 inline std::ostream& operator<<(std::ostream& stream, 169 inline std::ostream& operator<<(std::ostream& stream,
176 const NGConstraintSpace& value) { 170 const NGConstraintSpace& value) {
177 return stream << value.ToString(); 171 return stream << value.ToString();
178 } 172 }
179 173
180 } // namespace blink 174 } // namespace blink
181 175
182 #endif // NGConstraintSpace_h 176 #endif // NGConstraintSpace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698