Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc

Issue 2274593002: [layoutng] Correctly resolve indefinite percentages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error... Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698