| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 LengthResolveType::MarginBorderPaddingSize); | 280 LengthResolveType::MarginBorderPaddingSize); |
| 281 padding.block_end = | 281 padding.block_end = |
| 282 ResolveInlineLength(constraintSpace, style, style.paddingAfter(), | 282 ResolveInlineLength(constraintSpace, style, style.paddingAfter(), |
| 283 LengthResolveType::MarginBorderPaddingSize); | 283 LengthResolveType::MarginBorderPaddingSize); |
| 284 return padding; | 284 return padding; |
| 285 } | 285 } |
| 286 | 286 |
| 287 void ApplyAutoMargins(const NGConstraintSpace& constraint_space, | 287 void ApplyAutoMargins(const NGConstraintSpace& constraint_space, |
| 288 const ComputedStyle& style, | 288 const ComputedStyle& style, |
| 289 const NGFragment& fragment, | 289 const NGFragment& fragment, |
| 290 NGBoxStrut& margins) { | 290 NGBoxStrut* margins) { |
| 291 const LayoutUnit used_space = fragment.InlineSize() + margins.InlineSum(); | 291 DCHECK(margins) << "Margins cannot be NULL here"; |
| 292 const LayoutUnit used_space = fragment.InlineSize() + margins->InlineSum(); |
| 292 const LayoutUnit available_space = | 293 const LayoutUnit available_space = |
| 293 constraint_space.ContainerSize().inline_size - used_space; | 294 constraint_space.ContainerSize().inline_size - used_space; |
| 294 if (available_space < LayoutUnit()) | 295 if (available_space < LayoutUnit()) |
| 295 return; | 296 return; |
| 296 if (style.marginStart().isAuto() && style.marginEnd().isAuto()) { | 297 if (style.marginStart().isAuto() && style.marginEnd().isAuto()) { |
| 297 margins.inline_start = available_space / 2; | 298 margins->inline_start = available_space / 2; |
| 298 margins.inline_end = available_space - margins.inline_start; | 299 margins->inline_end = available_space - margins->inline_start; |
| 299 } else if (style.marginStart().isAuto()) { | 300 } else if (style.marginStart().isAuto()) { |
| 300 margins.inline_start = available_space; | 301 margins->inline_start = available_space; |
| 301 } else if (style.marginEnd().isAuto()) { | 302 } else if (style.marginEnd().isAuto()) { |
| 302 margins.inline_end = available_space; | 303 margins->inline_end = available_space; |
| 303 } | 304 } |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |