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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc

Issue 2274593002: [layoutng] Correctly resolve indefinite percentages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NGSizeIndefinite 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_margin_strut.h" 8 #include "core/layout/ng/ng_margin_strut.h"
9 #include "core/style/ComputedStyle.h" 9 #include "core/style/ComputedStyle.h"
10 #include "platform/CalculationValue.h" 10 #include "platform/CalculationValue.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 style_->setMaxHeight(Length(80, Percent)); 152 style_->setMaxHeight(Length(80, Percent));
153 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); 153 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment());
154 154
155 style_->setLogicalHeight(Length(100, Fixed)); 155 style_->setLogicalHeight(Length(100, Fixed));
156 style_->setMinHeight(Length(80, Percent)); 156 style_->setMinHeight(Length(80, Percent));
157 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); 157 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment());
158 158
159 // TODO(layout-ng): test {min,max}-content on max-height. 159 // TODO(layout-ng): test {min,max}-content on max-height.
160 } 160 }
161 161
162 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) {
163 style_->setMinHeight(Length(20, Fixed));
164 style_->setHeight(Length(20, Percent));
165
166 EXPECT_EQ(NGSizeIndefinite,
167 computeBlockSizeForFragment(constructConstraintSpace(200, -1),
168 LayoutUnit(-1)));
169 EXPECT_EQ(LayoutUnit(20),
170 computeBlockSizeForFragment(constructConstraintSpace(200, -1),
171 LayoutUnit(10)));
172 EXPECT_EQ(LayoutUnit(120),
173 computeBlockSizeForFragment(constructConstraintSpace(200, -1),
174 LayoutUnit(120)));
175 }
176
162 TEST_F(NGLengthUtilsTest, testMargins) { 177 TEST_F(NGLengthUtilsTest, testMargins) {
163 style_->setMarginTop(Length(10, Percent)); 178 style_->setMarginTop(Length(10, Percent));
164 style_->setMarginRight(Length(52, Fixed)); 179 style_->setMarginRight(Length(52, Fixed));
165 style_->setMarginBottom(Length(Auto)); 180 style_->setMarginBottom(Length(Auto));
166 style_->setMarginLeft(Length(11, Percent)); 181 style_->setMarginLeft(Length(11, Percent));
167 182
168 NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300)); 183 NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300));
169 184
170 NGBoxMargins margins = computeMargins(constraintSpace, *style_); 185 NGBoxMargins margins = computeMargins(constraintSpace, *style_);
171 186
172 EXPECT_EQ(LayoutUnit(20), margins.blockStart); 187 EXPECT_EQ(LayoutUnit(20), margins.blockStart);
173 EXPECT_EQ(LayoutUnit(52), margins.inlineEnd); 188 EXPECT_EQ(LayoutUnit(52), margins.inlineEnd);
174 EXPECT_EQ(LayoutUnit(), margins.blockEnd); 189 EXPECT_EQ(LayoutUnit(), margins.blockEnd);
175 EXPECT_EQ(LayoutUnit(22), margins.inlineStart); 190 EXPECT_EQ(LayoutUnit(22), margins.inlineStart);
176 } 191 }
177 192
178 } // namespace 193 } // namespace
179 } // namespace blink 194 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698