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 53713be8297314022d3c48a35bd918882ad225a7..4b3c696319ee6505683707017a771e542303fc13 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 |
@@ -21,6 +21,7 @@ LayoutUnit resolveInlineLength(const NGConstraintSpace& constraintSpace, |
LengthResolveType type) { |
// TODO(layout-ng): Handle min/max/fit-content |
DCHECK(!length.isMaxSizeNone()); |
+ DCHECK_NE(constraintSpace.ContainerSize().inlineSize, LayoutUnit(-1)); |
eae
2016/08/23 16:50:56
Can the length ever go negative? If not change thi
cbiesinger
2016/08/23 19:37:18
Done. I don't think size can ever go negative.
|
if (type == LengthResolveType::MinSize && length.isAuto()) |
return LayoutUnit(); |
@@ -47,6 +48,12 @@ LayoutUnit resolveBlockLength(const NGConstraintSpace& constraintSpace, |
if (length.isMinContent() || length.isMaxContent() || length.isFitContent()) |
return contentSize; |
+ // Make sure that indefinite percentages resolve to -1, not to a random |
+ // negative number. |
+ if (length.hasPercent() && |
+ constraintSpace.ContainerSize().blockSize == LayoutUnit(-1)) |
eae
2016/08/23 16:50:57
We might want to use a constant for infinite to im
cbiesinger
2016/08/23 19:37:18
OK. Adding NGSizeIndefinite. Using a #define to av
|
+ return contentSize; |
+ |
return valueForLength(length, constraintSpace.ContainerSize().blockSize); |
} |
@@ -86,8 +93,12 @@ LayoutUnit computeBlockSizeForFragment(const NGConstraintSpace& constraintSpace, |
LayoutUnit extent = |
resolveBlockLength(constraintSpace, style.logicalHeight(), contentSize, |
LengthResolveType::ContentSize); |
- Length maxLength = style.logicalMaxHeight(); |
+ if (extent == LayoutUnit(-1)) { |
+ DCHECK_EQ(contentSize, LayoutUnit(-1)); |
+ return extent; |
+ } |
+ Length maxLength = style.logicalMaxHeight(); |
if (!maxLength.isMaxSizeNone()) { |
LayoutUnit max = resolveBlockLength(constraintSpace, maxLength, contentSize, |
LengthResolveType::MaxSize); |