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_constraint_space_builder.h" | 8 #include "core/layout/ng/ng_constraint_space_builder.h" |
9 #include "core/layout/ng/ng_fragment.h" | 9 #include "core/layout/ng/ng_fragment.h" |
10 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 LengthResolveType::kMarginBorderPaddingSize); | 389 LengthResolveType::kMarginBorderPaddingSize); |
390 padding.block_start = ResolveInlineLength( | 390 padding.block_start = ResolveInlineLength( |
391 constraint_space, style, empty_sizes, style.PaddingBefore(), | 391 constraint_space, style, empty_sizes, style.PaddingBefore(), |
392 LengthResolveType::kMarginBorderPaddingSize); | 392 LengthResolveType::kMarginBorderPaddingSize); |
393 padding.block_end = ResolveInlineLength( | 393 padding.block_end = ResolveInlineLength( |
394 constraint_space, style, empty_sizes, style.PaddingAfter(), | 394 constraint_space, style, empty_sizes, style.PaddingAfter(), |
395 LengthResolveType::kMarginBorderPaddingSize); | 395 LengthResolveType::kMarginBorderPaddingSize); |
396 return padding; | 396 return padding; |
397 } | 397 } |
398 | 398 |
399 LayoutUnit ComputeMarginBorderPaddingInlineStart( | |
cbiesinger
2017/05/22 19:02:58
I'd rather not add functions like these; why not u
kojii
2017/05/22 19:22:42
It computes 4 values and discard 3 out of that. I'
kojii
2017/05/22 19:26:31
BTW, you might know but in case, the legacy has Ma
| |
400 const NGConstraintSpace& constraint_space, | |
401 const ComputedStyle& style) { | |
402 MinMaxContentSize empty_sizes; | |
403 return ResolveInlineLength(constraint_space, style, empty_sizes, | |
404 style.MarginStart(), | |
405 LengthResolveType::kMarginBorderPaddingSize) + | |
406 LayoutUnit(style.BorderStartWidth()) + | |
407 ResolveInlineLength(constraint_space, style, empty_sizes, | |
408 style.PaddingStart(), | |
409 LengthResolveType::kMarginBorderPaddingSize); | |
410 } | |
411 | |
412 LayoutUnit ComputeMarginBorderPaddingInlineEnd( | |
413 const NGConstraintSpace& constraint_space, | |
414 const ComputedStyle& style) { | |
415 MinMaxContentSize empty_sizes; | |
416 return ResolveInlineLength(constraint_space, style, empty_sizes, | |
417 style.MarginEnd(), | |
418 LengthResolveType::kMarginBorderPaddingSize) + | |
419 LayoutUnit(style.BorderEndWidth()) + | |
420 ResolveInlineLength(constraint_space, style, empty_sizes, | |
421 style.PaddingEnd(), | |
422 LengthResolveType::kMarginBorderPaddingSize); | |
423 } | |
424 | |
399 void ApplyAutoMargins(const NGConstraintSpace& constraint_space, | 425 void ApplyAutoMargins(const NGConstraintSpace& constraint_space, |
400 const ComputedStyle& style, | 426 const ComputedStyle& style, |
401 const LayoutUnit& inline_size, | 427 const LayoutUnit& inline_size, |
402 NGBoxStrut* margins) { | 428 NGBoxStrut* margins) { |
403 DCHECK(margins) << "Margins cannot be NULL here"; | 429 DCHECK(margins) << "Margins cannot be NULL here"; |
404 const LayoutUnit used_space = inline_size + margins->InlineSum(); | 430 const LayoutUnit used_space = inline_size + margins->InlineSum(); |
405 const LayoutUnit available_space = | 431 const LayoutUnit available_space = |
406 constraint_space.AvailableSize().inline_size - used_space; | 432 constraint_space.AvailableSize().inline_size - used_space; |
407 if (available_space < LayoutUnit()) | 433 if (available_space < LayoutUnit()) |
408 return; | 434 return; |
(...skipping 11 matching lines...) Expand all Loading... | |
420 Optional<LayoutUnit> min, | 446 Optional<LayoutUnit> min, |
421 Optional<LayoutUnit> max) { | 447 Optional<LayoutUnit> max) { |
422 if (max && length > max.value()) | 448 if (max && length > max.value()) |
423 length = max.value(); | 449 length = max.value(); |
424 if (min && length < min.value()) | 450 if (min && length < min.value()) |
425 length = min.value(); | 451 length = min.value(); |
426 return length; | 452 return length; |
427 } | 453 } |
428 | 454 |
429 } // namespace blink | 455 } // namespace blink |
OLD | NEW |