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 #include "core/layout/ng/ng_length_utils.h" | 5 #include "core/layout/ng/ng_length_utils.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
8 #include "core/layout/ng/ng_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
10 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 case ExtendToZoom: | 169 case ExtendToZoom: |
170 NOTREACHED() << "These should only be used for viewport definitions"; | 170 NOTREACHED() << "These should only be used for viewport definitions"; |
171 case MaxSizeNone: | 171 case MaxSizeNone: |
172 default: | 172 default: |
173 NOTREACHED(); | 173 NOTREACHED(); |
174 return border_and_padding.BlockSum(); | 174 return border_and_padding.BlockSum(); |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 LayoutUnit ComputeInlineSizeForFragment( | 178 LayoutUnit ComputeInlineSizeForFragment( |
179 const NGConstraintSpace& constraint_space, | 179 const NGConstraintSpace& space, |
180 const ComputedStyle& style, | 180 const ComputedStyle& style, |
181 const WTF::Optional<MinAndMaxContentSizes>& min_and_max) { | 181 const WTF::Optional<MinAndMaxContentSizes>& min_and_max) { |
182 if (constraint_space.FixedInlineSize()) | 182 if (space.IsFixedSizeInline()) |
183 return constraint_space.AvailableSize().inline_size; | 183 return space.AvailableSize().inline_size; |
184 | 184 |
185 LayoutUnit extent = ResolveInlineLength(constraint_space, style, min_and_max, | 185 LayoutUnit extent = |
186 style.logicalWidth(), | 186 ResolveInlineLength(space, style, min_and_max, style.logicalWidth(), |
187 LengthResolveType::kContentSize); | 187 LengthResolveType::kContentSize); |
188 | 188 |
189 Length max_length = style.logicalMaxWidth(); | 189 Length max_length = style.logicalMaxWidth(); |
190 if (!max_length.isMaxSizeNone()) { | 190 if (!max_length.isMaxSizeNone()) { |
191 LayoutUnit max = | 191 LayoutUnit max = ResolveInlineLength(space, style, min_and_max, max_length, |
192 ResolveInlineLength(constraint_space, style, min_and_max, max_length, | 192 LengthResolveType::kMaxSize); |
193 LengthResolveType::kMaxSize); | |
194 extent = std::min(extent, max); | 193 extent = std::min(extent, max); |
195 } | 194 } |
196 | 195 |
197 LayoutUnit min = | 196 LayoutUnit min = |
198 ResolveInlineLength(constraint_space, style, min_and_max, | 197 ResolveInlineLength(space, style, min_and_max, style.logicalMinWidth(), |
199 style.logicalMinWidth(), LengthResolveType::kMinSize); | 198 LengthResolveType::kMinSize); |
200 extent = std::max(extent, min); | 199 extent = std::max(extent, min); |
201 return extent; | 200 return extent; |
202 } | 201 } |
203 | 202 |
204 LayoutUnit ComputeBlockSizeForFragment( | 203 LayoutUnit ComputeBlockSizeForFragment( |
205 const NGConstraintSpace& constraint_space, | 204 const NGConstraintSpace& constraint_space, |
206 const ComputedStyle& style, | 205 const ComputedStyle& style, |
207 LayoutUnit content_size) { | 206 LayoutUnit content_size) { |
208 if (constraint_space.FixedBlockSize()) | 207 if (constraint_space.IsFixedSizeBlock()) |
209 return constraint_space.AvailableSize().block_size; | 208 return constraint_space.AvailableSize().block_size; |
210 | 209 |
211 LayoutUnit extent = | 210 LayoutUnit extent = |
212 ResolveBlockLength(constraint_space, style, style.logicalHeight(), | 211 ResolveBlockLength(constraint_space, style, style.logicalHeight(), |
213 content_size, LengthResolveType::kContentSize); | 212 content_size, LengthResolveType::kContentSize); |
214 if (extent == NGSizeIndefinite) { | 213 if (extent == NGSizeIndefinite) { |
215 DCHECK_EQ(content_size, NGSizeIndefinite); | 214 DCHECK_EQ(content_size, NGSizeIndefinite); |
216 return extent; | 215 return extent; |
217 } | 216 } |
218 | 217 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 margins->inline_start = available_space / 2; | 346 margins->inline_start = available_space / 2; |
348 margins->inline_end = available_space - margins->inline_start; | 347 margins->inline_end = available_space - margins->inline_start; |
349 } else if (style.marginStart().isAuto()) { | 348 } else if (style.marginStart().isAuto()) { |
350 margins->inline_start = available_space; | 349 margins->inline_start = available_space; |
351 } else if (style.marginEnd().isAuto()) { | 350 } else if (style.marginEnd().isAuto()) { |
352 margins->inline_end = available_space; | 351 margins->inline_end = available_space; |
353 } | 352 } |
354 } | 353 } |
355 | 354 |
356 } // namespace blink | 355 } // namespace blink |
OLD | NEW |