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

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

Issue 2453553002: Resolve ApplyAutoMargins's TODO in NGBlockLayoutAlgorithm. (Closed)
Patch Set: change ApplyAutoMargins to pass margins by pointer + DCHECK Created 4 years, 1 month 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_fragment.h" 8 #include "core/layout/ng/ng_fragment.h"
9 #include "core/layout/ng/ng_fragment_builder.h" 9 #include "core/layout/ng/ng_fragment_builder.h"
10 #include "core/layout/ng/ng_physical_fragment.h" 10 #include "core/layout/ng/ng_physical_fragment.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 NGFragmentBuilder builder(NGPhysicalFragmentBase::FragmentBox); 283 NGFragmentBuilder builder(NGPhysicalFragmentBase::FragmentBox);
284 builder.SetInlineSize(LayoutUnit(150)); 284 builder.SetInlineSize(LayoutUnit(150));
285 NGPhysicalFragment* physical_fragment = builder.ToFragment(); 285 NGPhysicalFragment* physical_fragment = builder.ToFragment();
286 NGFragment* fragment = 286 NGFragment* fragment =
287 new NGFragment(HorizontalTopBottom, LeftToRight, physical_fragment); 287 new NGFragment(HorizontalTopBottom, LeftToRight, physical_fragment);
288 288
289 NGConstraintSpace* constraint_space(ConstructConstraintSpace(200, 300)); 289 NGConstraintSpace* constraint_space(ConstructConstraintSpace(200, 300));
290 290
291 NGBoxStrut margins; 291 NGBoxStrut margins;
292 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); 292 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins);
293 293
294 EXPECT_EQ(LayoutUnit(), margins.block_start); 294 EXPECT_EQ(LayoutUnit(), margins.block_start);
295 EXPECT_EQ(LayoutUnit(), margins.block_end); 295 EXPECT_EQ(LayoutUnit(), margins.block_end);
296 EXPECT_EQ(LayoutUnit(25), margins.inline_start); 296 EXPECT_EQ(LayoutUnit(25), margins.inline_start);
297 EXPECT_EQ(LayoutUnit(25), margins.inline_end); 297 EXPECT_EQ(LayoutUnit(25), margins.inline_end);
298 298
299 style_->setMarginLeft(Length(0, Fixed)); 299 style_->setMarginLeft(Length(0, Fixed));
300 margins = NGBoxStrut(); 300 margins = NGBoxStrut();
301 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); 301 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins);
302 EXPECT_EQ(LayoutUnit(0), margins.inline_start); 302 EXPECT_EQ(LayoutUnit(0), margins.inline_start);
303 EXPECT_EQ(LayoutUnit(50), margins.inline_end); 303 EXPECT_EQ(LayoutUnit(50), margins.inline_end);
304 304
305 style_->setMarginLeft(Length(Auto)); 305 style_->setMarginLeft(Length(Auto));
306 style_->setMarginRight(Length(0, Fixed)); 306 style_->setMarginRight(Length(0, Fixed));
307 margins = NGBoxStrut(); 307 margins = NGBoxStrut();
308 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); 308 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins);
309 EXPECT_EQ(LayoutUnit(50), margins.inline_start); 309 EXPECT_EQ(LayoutUnit(50), margins.inline_start);
310 EXPECT_EQ(LayoutUnit(0), margins.inline_end); 310 EXPECT_EQ(LayoutUnit(0), margins.inline_end);
311 311
312 // Test that we don't end up with negative "auto" margins when the box is too 312 // Test that we don't end up with negative "auto" margins when the box is too
313 // big. 313 // big.
314 style_->setMarginLeft(Length(Auto)); 314 style_->setMarginLeft(Length(Auto));
315 style_->setMarginRight(Length(5000, Fixed)); 315 style_->setMarginRight(Length(5000, Fixed));
316 margins = NGBoxStrut(); 316 margins = NGBoxStrut();
317 margins.inline_end = LayoutUnit(5000); 317 margins.inline_end = LayoutUnit(5000);
318 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); 318 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins);
319 EXPECT_EQ(LayoutUnit(0), margins.inline_start); 319 EXPECT_EQ(LayoutUnit(0), margins.inline_start);
320 EXPECT_EQ(LayoutUnit(5000), margins.inline_end); 320 EXPECT_EQ(LayoutUnit(5000), margins.inline_end);
321 } 321 }
322 322
323 } // namespace 323 } // namespace
324 } // namespace blink 324 } // 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