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

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

Issue 2632523002: [LayoutNG] Initial support for multicol, introducing NGBlockBreakToken. (Closed)
Patch Set: Add TODO. Created 3 years, 11 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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // The available space size. 64 // The available space size.
65 // See: https://drafts.csswg.org/css-sizing/#available 65 // See: https://drafts.csswg.org/css-sizing/#available
66 NGLogicalSize AvailableSize() const { return available_size_; } 66 NGLogicalSize AvailableSize() const { return available_size_; }
67 67
68 // Offset relative to the root constraint space. 68 // Offset relative to the root constraint space.
69 NGLogicalOffset Offset() const { return offset_; } 69 NGLogicalOffset Offset() const { return offset_; }
70 // TODO(layout-ng): Set offset via NGConstraintSpacebuilder. 70 // TODO(layout-ng): Set offset via NGConstraintSpacebuilder.
71 void SetOffset(const NGLogicalOffset& offset) { offset_ = offset; } 71 void SetOffset(const NGLogicalOffset& offset) { offset_ = offset; }
72 72
73 // Return the block-direction space available in the current fragmentainer.
74 LayoutUnit FragmentainerSpaceAvailable() const {
75 DCHECK(HasBlockFragmentation());
76 return fragmentainer_space_available_;
77 }
78
73 // Whether the current constraint space is for the newly established 79 // Whether the current constraint space is for the newly established
74 // Formatting Context. 80 // Formatting Context.
75 bool IsNewFormattingContext() const { return is_new_fc_; } 81 bool IsNewFormattingContext() const { return is_new_fc_; }
76 82
77 // Whether exceeding the AvailableSize() triggers the presence of a scrollbar 83 // Whether exceeding the AvailableSize() triggers the presence of a scrollbar
78 // for the indicated direction. 84 // for the indicated direction.
79 // If exceeded the current layout should be aborted and invoked again with a 85 // If exceeded the current layout should be aborted and invoked again with a
80 // constraint space modified to reserve space for a scrollbar. 86 // constraint space modified to reserve space for a scrollbar.
81 bool IsInlineDirectionTriggersScrollbar() const { 87 bool IsInlineDirectionTriggersScrollbar() const {
82 return is_inline_direction_triggers_scrollbar_; 88 return is_inline_direction_triggers_scrollbar_;
(...skipping 14 matching lines...) Expand all
97 bool IsFixedSizeBlock() const { return is_fixed_size_block_; } 103 bool IsFixedSizeBlock() const { return is_fixed_size_block_; }
98 104
99 // Whether an auto inline-size should be interpreted as shrink-to-fit 105 // Whether an auto inline-size should be interpreted as shrink-to-fit
100 // (ie. fit-content). This is used for inline-block, floats, etc. 106 // (ie. fit-content). This is used for inline-block, floats, etc.
101 bool IsShrinkToFit() const { return is_shrink_to_fit_; } 107 bool IsShrinkToFit() const { return is_shrink_to_fit_; }
102 108
103 // If specified a layout should produce a Fragment which fragments at the 109 // If specified a layout should produce a Fragment which fragments at the
104 // blockSize if possible. 110 // blockSize if possible.
105 NGFragmentationType BlockFragmentationType() const; 111 NGFragmentationType BlockFragmentationType() const;
106 112
113 // Return true if this contraint space participates in a fragmentation
114 // context.
115 bool HasBlockFragmentation() const {
116 return BlockFragmentationType() != kFragmentNone;
117 }
118
107 // Modifies constraint space to account for a placed fragment. Depending on 119 // Modifies constraint space to account for a placed fragment. Depending on
108 // the shape of the fragment this will either modify the inline or block 120 // the shape of the fragment this will either modify the inline or block
109 // size, or add an exclusion. 121 // size, or add an exclusion.
110 void Subtract(const NGBoxFragment*); 122 void Subtract(const NGBoxFragment*);
111 123
112 NGLayoutOpportunityIterator* LayoutOpportunities( 124 NGLayoutOpportunityIterator* LayoutOpportunities(
113 unsigned clear = kNGClearNone, 125 unsigned clear = kNGClearNone,
114 bool for_inline_or_bfc = false); 126 bool for_inline_or_bfc = false);
115 127
116 DEFINE_INLINE_VIRTUAL_TRACE() {} 128 DEFINE_INLINE_VIRTUAL_TRACE() {}
117 129
118 String ToString() const; 130 String ToString() const;
119 131
120 private: 132 private:
121 friend class NGConstraintSpaceBuilder; 133 friend class NGConstraintSpaceBuilder;
122 // Default constructor. 134 // Default constructor.
123 NGConstraintSpace(NGWritingMode, 135 NGConstraintSpace(NGWritingMode,
124 TextDirection, 136 TextDirection,
125 NGLogicalSize available_size, 137 NGLogicalSize available_size,
126 NGLogicalSize percentage_resolution_size, 138 NGLogicalSize percentage_resolution_size,
139 LayoutUnit fragmentainer_space_available,
127 bool is_fixed_size_inline, 140 bool is_fixed_size_inline,
128 bool is_fixed_size_block, 141 bool is_fixed_size_block,
129 bool is_shrink_to_fit, 142 bool is_shrink_to_fit,
130 bool is_inline_direction_triggers_scrollbar, 143 bool is_inline_direction_triggers_scrollbar,
131 bool is_block_direction_triggers_scrollbar, 144 bool is_block_direction_triggers_scrollbar,
132 NGFragmentationType block_direction_fragmentation_type, 145 NGFragmentationType block_direction_fragmentation_type,
133 bool is_new_fc, 146 bool is_new_fc,
134 const std::shared_ptr<NGExclusions>& exclusions_); 147 const std::shared_ptr<NGExclusions>& exclusions_);
135 148
136 NGLogicalSize available_size_; 149 NGLogicalSize available_size_;
137 NGLogicalSize percentage_resolution_size_; 150 NGLogicalSize percentage_resolution_size_;
138 151
152 LayoutUnit fragmentainer_space_available_;
153
139 unsigned is_fixed_size_inline_ : 1; 154 unsigned is_fixed_size_inline_ : 1;
140 unsigned is_fixed_size_block_ : 1; 155 unsigned is_fixed_size_block_ : 1;
141 156
142 unsigned is_shrink_to_fit_ : 1; 157 unsigned is_shrink_to_fit_ : 1;
143 158
144 unsigned is_inline_direction_triggers_scrollbar_ : 1; 159 unsigned is_inline_direction_triggers_scrollbar_ : 1;
145 unsigned is_block_direction_triggers_scrollbar_ : 1; 160 unsigned is_block_direction_triggers_scrollbar_ : 1;
146 161
147 unsigned block_direction_fragmentation_type_ : 2; 162 unsigned block_direction_fragmentation_type_ : 2;
148 163
149 // Whether the current constraint space is for the newly established 164 // Whether the current constraint space is for the newly established
150 // formatting Context 165 // formatting Context
151 unsigned is_new_fc_ : 1; 166 unsigned is_new_fc_ : 1;
152 167
153 NGLogicalOffset offset_; 168 NGLogicalOffset offset_;
154 unsigned writing_mode_ : 3; 169 unsigned writing_mode_ : 3;
155 unsigned direction_ : 1; 170 unsigned direction_ : 1;
156 171
157 const std::shared_ptr<NGExclusions> exclusions_; 172 const std::shared_ptr<NGExclusions> exclusions_;
158 }; 173 };
159 174
160 inline std::ostream& operator<<(std::ostream& stream, 175 inline std::ostream& operator<<(std::ostream& stream,
161 const NGConstraintSpace& value) { 176 const NGConstraintSpace& value) {
162 return stream << value.ToString(); 177 return stream << value.ToString();
163 } 178 }
164 179
165 } // namespace blink 180 } // namespace blink
166 181
167 #endif // NGConstraintSpace_h 182 #endif // NGConstraintSpace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698