| Index: third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc b/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
|
| index 87894828d679bff724a9b0adefe525186176be38..54d4172ea63a45e1d55d251fb2db70f6d9dcf977 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
|
| @@ -5,6 +5,7 @@
|
| #include "core/layout/ng/ng_length_utils.h"
|
|
|
| #include "core/layout/ng/ng_constraint_space.h"
|
| +#include "core/layout/ng/ng_fragment.h"
|
| #include "core/style/ComputedStyle.h"
|
| #include "platform/LayoutUnit.h"
|
| #include "platform/Length.h"
|
| @@ -283,4 +284,23 @@ NGBoxStrut computePadding(const NGConstraintSpace& constraintSpace,
|
| return padding;
|
| }
|
|
|
| +void ApplyAutoMargins(const NGConstraintSpace& constraint_space,
|
| + const ComputedStyle& style,
|
| + const NGFragment& fragment,
|
| + NGBoxStrut& margins) {
|
| + const LayoutUnit used_space = fragment.InlineSize() + margins.InlineSum();
|
| + const LayoutUnit available_space =
|
| + constraint_space.ContainerSize().inline_size - used_space;
|
| + if (available_space < LayoutUnit())
|
| + return;
|
| + if (style.marginStart().isAuto() && style.marginEnd().isAuto()) {
|
| + margins.inline_start = available_space / 2;
|
| + margins.inline_end = available_space - margins.inline_start;
|
| + } else if (style.marginStart().isAuto()) {
|
| + margins.inline_start = available_space;
|
| + } else if (style.marginEnd().isAuto()) {
|
| + margins.inline_end = available_space;
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|