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 30fb60ad79621718f22be82b5eaa164432c10414..fe85f17bba60b032b3ceaec949461c0fcc4496ec 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_margin_strut.h" |
#include "core/style/ComputedStyle.h" |
#include "platform/LayoutUnit.h" |
#include "platform/Length.h" |
@@ -24,6 +25,9 @@ LayoutUnit resolveInlineLength(const NGConstraintSpace& constraintSpace, |
if (type == LengthResolveType::MinSize && length.isAuto()) |
return LayoutUnit(); |
+ if (type == LengthResolveType::MarginSize && length.isAuto()) |
+ return LayoutUnit(); |
+ |
return valueForLength(length, constraintSpace.ContainerSize().inlineSize); |
} |
@@ -36,7 +40,7 @@ LayoutUnit resolveBlockLength(const NGConstraintSpace& constraintSpace, |
if (type == LengthResolveType::MinSize && length.isAuto()) |
return LayoutUnit(); |
- if (length.isAuto()) |
+ if (type != LengthResolveType::MarginSize && length.isAuto()) |
ikilpatrick
2016/08/18 22:54:33
is this needed? should there just be a DCHECK(type
|
return contentSize; |
if (length.isMinContent() || length.isMaxContent() || length.isFitContent()) |
@@ -100,4 +104,20 @@ LayoutUnit computeBlockSizeForFragment(const NGConstraintSpace& constraintSpace, |
return extent; |
} |
+NGBoxMargins computeMargins(const NGConstraintSpace& constraintSpace, |
+ const ComputedStyle& style) { |
+ // Margins always get computed relative to the inline size: |
+ // https://www.w3.org/TR/CSS2/box.html#value-def-margin-width |
+ NGBoxMargins margins; |
+ margins.inlineStart = resolveInlineLength( |
+ constraintSpace, style.marginStart(), LengthResolveType::MarginSize); |
+ margins.inlineEnd = resolveInlineLength(constraintSpace, style.marginEnd(), |
+ LengthResolveType::MarginSize); |
+ margins.blockStart = resolveInlineLength( |
+ constraintSpace, style.marginBefore(), LengthResolveType::MarginSize); |
+ margins.blockEnd = resolveInlineLength(constraintSpace, style.marginAfter(), |
+ LengthResolveType::MarginSize); |
+ return margins; |
+} |
+ |
} // namespace blink |