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

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

Issue 2614883007: Change computed style enums to be prefixed with 'k'. (Closed)
Patch Set: Rebase on ToT. Created 3 years, 11 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
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_block_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_block_node.h" 7 #include "core/layout/ng/ng_block_node.h"
8 #include "core/layout/ng/ng_constraint_space.h" 8 #include "core/layout/ng/ng_constraint_space.h"
9 #include "core/layout/ng/ng_constraint_space_builder.h" 9 #include "core/layout/ng/ng_constraint_space_builder.h"
10 #include "core/layout/ng/ng_layout_coordinator.h" 10 #include "core/layout/ng/ng_layout_coordinator.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 while (!coordinator.Tick(&fragment)) 48 while (!coordinator.Tick(&fragment))
49 ; 49 ;
50 50
51 return toNGPhysicalBoxFragment(fragment); 51 return toNGPhysicalBoxFragment(fragment);
52 } 52 }
53 53
54 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* first_child) { 54 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* first_child) {
55 // The constraint space is not used for min/max computation, but we need 55 // The constraint space is not used for min/max computation, but we need
56 // it to create the algorithm. 56 // it to create the algorithm.
57 NGConstraintSpace* space = 57 NGConstraintSpace* space =
58 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::Ltr, 58 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr,
59 NGLogicalSize(LayoutUnit(), LayoutUnit())); 59 NGLogicalSize(LayoutUnit(), LayoutUnit()));
60 NGBlockLayoutAlgorithm algorithm(style_.get(), first_child, space); 60 NGBlockLayoutAlgorithm algorithm(style_.get(), first_child, space);
61 MinAndMaxContentSizes sizes; 61 MinAndMaxContentSizes sizes;
62 NGLayoutAlgorithm::MinAndMaxState state; 62 NGLayoutAlgorithm::MinAndMaxState state;
63 while ((state = algorithm.ComputeMinAndMaxContentSizes(&sizes)) != 63 while ((state = algorithm.ComputeMinAndMaxContentSizes(&sizes)) !=
64 NGLayoutAlgorithm::kSuccess) { 64 NGLayoutAlgorithm::kSuccess) {
65 EXPECT_NE(NGLayoutAlgorithm::kNotImplemented, state); 65 EXPECT_NE(NGLayoutAlgorithm::kNotImplemented, state);
66 // shouldn't happen but let's avoid an infinite loop 66 // shouldn't happen but let's avoid an infinite loop
67 if (state == NGLayoutAlgorithm::kNotImplemented) 67 if (state == NGLayoutAlgorithm::kNotImplemented)
68 break; 68 break;
69 } 69 }
70 return sizes; 70 return sizes;
71 } 71 }
72 72
73 RefPtr<ComputedStyle> style_; 73 RefPtr<ComputedStyle> style_;
74 }; 74 };
75 75
76 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { 76 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) {
77 style_->setWidth(Length(30, Fixed)); 77 style_->setWidth(Length(30, Fixed));
78 style_->setHeight(Length(40, Fixed)); 78 style_->setHeight(Length(40, Fixed));
79 79
80 auto* space = ConstructConstraintSpace( 80 auto* space = ConstructConstraintSpace(
81 kHorizontalTopBottom, TextDirection::Ltr, 81 kHorizontalTopBottom, TextDirection::kLtr,
82 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 82 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
83 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, nullptr); 83 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, nullptr);
84 84
85 EXPECT_EQ(LayoutUnit(30), frag->Width()); 85 EXPECT_EQ(LayoutUnit(30), frag->Width());
86 EXPECT_EQ(LayoutUnit(40), frag->Height()); 86 EXPECT_EQ(LayoutUnit(40), frag->Height());
87 } 87 }
88 88
89 // Verifies that two children are laid out with the correct size and position. 89 // Verifies that two children are laid out with the correct size and position.
90 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) { 90 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) {
91 const int kWidth = 30; 91 const int kWidth = 30;
92 const int kHeight1 = 20; 92 const int kHeight1 = 20;
93 const int kHeight2 = 30; 93 const int kHeight2 = 30;
94 const int kMarginTop = 5; 94 const int kMarginTop = 5;
95 const int kMarginBottom = 20; 95 const int kMarginBottom = 20;
96 style_->setWidth(Length(kWidth, Fixed)); 96 style_->setWidth(Length(kWidth, Fixed));
97 97
98 RefPtr<ComputedStyle> first_style = ComputedStyle::create(); 98 RefPtr<ComputedStyle> first_style = ComputedStyle::create();
99 first_style->setHeight(Length(kHeight1, Fixed)); 99 first_style->setHeight(Length(kHeight1, Fixed));
100 NGBlockNode* first_child = new NGBlockNode(first_style.get()); 100 NGBlockNode* first_child = new NGBlockNode(first_style.get());
101 101
102 RefPtr<ComputedStyle> second_style = ComputedStyle::create(); 102 RefPtr<ComputedStyle> second_style = ComputedStyle::create();
103 second_style->setHeight(Length(kHeight2, Fixed)); 103 second_style->setHeight(Length(kHeight2, Fixed));
104 second_style->setMarginTop(Length(kMarginTop, Fixed)); 104 second_style->setMarginTop(Length(kMarginTop, Fixed));
105 second_style->setMarginBottom(Length(kMarginBottom, Fixed)); 105 second_style->setMarginBottom(Length(kMarginBottom, Fixed));
106 NGBlockNode* second_child = new NGBlockNode(second_style.get()); 106 NGBlockNode* second_child = new NGBlockNode(second_style.get());
107 107
108 first_child->SetNextSibling(second_child); 108 first_child->SetNextSibling(second_child);
109 109
110 auto* space = ConstructConstraintSpace( 110 auto* space = ConstructConstraintSpace(
111 kHorizontalTopBottom, TextDirection::Ltr, 111 kHorizontalTopBottom, TextDirection::kLtr,
112 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 112 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
113 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child); 113 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
114 114
115 EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); 115 EXPECT_EQ(LayoutUnit(kWidth), frag->Width());
116 EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); 116 EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height());
117 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); 117 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type());
118 ASSERT_EQ(frag->Children().size(), 2UL); 118 ASSERT_EQ(frag->Children().size(), 2UL);
119 119
120 const NGPhysicalFragment* child = frag->Children()[0]; 120 const NGPhysicalFragment* child = frag->Children()[0];
121 EXPECT_EQ(kHeight1, child->Height()); 121 EXPECT_EQ(kHeight1, child->Height());
(...skipping 12 matching lines...) Expand all
134 // <div style="width:50px; 134 // <div style="width:50px;
135 // height: 50px; margin-left: 100px; 135 // height: 50px; margin-left: 100px;
136 // writing-mode: horizontal-tb;"></div> 136 // writing-mode: horizontal-tb;"></div>
137 // </div> 137 // </div>
138 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildrenWithWritingMode) { 138 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildrenWithWritingMode) {
139 const int kWidth = 50; 139 const int kWidth = 50;
140 const int kHeight = 50; 140 const int kHeight = 50;
141 const int kMarginLeft = 100; 141 const int kMarginLeft = 100;
142 142
143 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); 143 RefPtr<ComputedStyle> div1_style = ComputedStyle::create();
144 div1_style->setWritingMode(WritingMode::VerticalLr); 144 div1_style->setWritingMode(WritingMode::kVerticalLr);
145 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); 145 NGBlockNode* div1 = new NGBlockNode(div1_style.get());
146 146
147 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 147 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
148 div2_style->setHeight(Length(kHeight, Fixed)); 148 div2_style->setHeight(Length(kHeight, Fixed));
149 div2_style->setWidth(Length(kWidth, Fixed)); 149 div2_style->setWidth(Length(kWidth, Fixed));
150 div1_style->setWritingMode(WritingMode::HorizontalTb); 150 div1_style->setWritingMode(WritingMode::kHorizontalTb);
151 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); 151 div2_style->setMarginLeft(Length(kMarginLeft, Fixed));
152 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 152 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
153 153
154 div1->SetFirstChild(div2); 154 div1->SetFirstChild(div2);
155 155
156 auto* space = 156 auto* space =
157 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::Ltr, 157 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr,
158 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); 158 NGLogicalSize(LayoutUnit(500), LayoutUnit(500)));
159 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 159 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
160 160
161 const NGPhysicalFragment* child = frag->Children()[0]; 161 const NGPhysicalFragment* child = frag->Children()[0];
162 // DIV2 162 // DIV2
163 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0]; 163 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0];
164 164
165 EXPECT_EQ(kHeight, child->Height()); 165 EXPECT_EQ(kHeight, child->Height());
166 EXPECT_EQ(0, child->TopOffset()); 166 EXPECT_EQ(0, child->TopOffset());
167 EXPECT_EQ(kMarginLeft, child->LeftOffset()); 167 EXPECT_EQ(kMarginLeft, child->LeftOffset());
(...skipping 27 matching lines...) Expand all
195 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed)); 195 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed));
196 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 196 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
197 197
198 div1->SetFirstChild(div2); 198 div1->SetFirstChild(div2);
199 199
200 auto* space = 200 auto* space =
201 NGConstraintSpaceBuilder(kHorizontalTopBottom) 201 NGConstraintSpaceBuilder(kHorizontalTopBottom)
202 .SetAvailableSize(NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)) 202 .SetAvailableSize(NGLogicalSize(LayoutUnit(100), NGSizeIndefinite))
203 .SetPercentageResolutionSize( 203 .SetPercentageResolutionSize(
204 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)) 204 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite))
205 .SetTextDirection(TextDirection::Ltr) 205 .SetTextDirection(TextDirection::kLtr)
206 .SetIsNewFormattingContext(true) 206 .SetIsNewFormattingContext(true)
207 .ToConstraintSpace(); 207 .ToConstraintSpace();
208 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 208 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
209 209
210 EXPECT_TRUE(frag->MarginStrut().IsEmpty()); 210 EXPECT_TRUE(frag->MarginStrut().IsEmpty());
211 ASSERT_EQ(frag->Children().size(), 1UL); 211 ASSERT_EQ(frag->Children().size(), 1UL);
212 const NGPhysicalBoxFragment* div2_fragment = 212 const NGPhysicalBoxFragment* div2_fragment =
213 static_cast<const NGPhysicalBoxFragment*>(frag->Children()[0].get()); 213 static_cast<const NGPhysicalBoxFragment*>(frag->Children()[0].get());
214 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), 214 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}),
215 div2_fragment->MarginStrut()); 215 div2_fragment->MarginStrut());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 NGBlockNode* div7 = new NGBlockNode(div7_style.get()); 270 NGBlockNode* div7 = new NGBlockNode(div7_style.get());
271 271
272 div1->SetFirstChild(div2); 272 div1->SetFirstChild(div2);
273 div2->SetNextSibling(div3); 273 div2->SetNextSibling(div3);
274 div1->SetNextSibling(div4); 274 div1->SetNextSibling(div4);
275 div4->SetNextSibling(div5); 275 div4->SetNextSibling(div5);
276 div5->SetFirstChild(div6); 276 div5->SetFirstChild(div6);
277 div6->SetNextSibling(div7); 277 div6->SetNextSibling(div7);
278 278
279 auto* space = ConstructConstraintSpace( 279 auto* space = ConstructConstraintSpace(
280 kHorizontalTopBottom, TextDirection::Ltr, 280 kHorizontalTopBottom, TextDirection::kLtr,
281 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 281 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
282 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 282 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
283 283
284 ASSERT_EQ(frag->Children().size(), 3UL); 284 ASSERT_EQ(frag->Children().size(), 3UL);
285 285
286 // DIV1 286 // DIV1
287 const NGPhysicalFragment* child = frag->Children()[0]; 287 const NGPhysicalFragment* child = frag->Children()[0];
288 EXPECT_EQ(kHeight, child->Height()); 288 EXPECT_EQ(kHeight, child->Height());
289 EXPECT_EQ(0, child->TopOffset()); 289 EXPECT_EQ(0, child->TopOffset());
290 290
(...skipping 28 matching lines...) Expand all
319 319
320 // DIV2 320 // DIV2
321 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 321 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
322 div2_style->setHeight(Length(kHeight, Fixed)); 322 div2_style->setHeight(Length(kHeight, Fixed));
323 div2_style->setMarginBottom(Length(kDiv2MarginBottom, Fixed)); 323 div2_style->setMarginBottom(Length(kDiv2MarginBottom, Fixed));
324 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 324 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
325 325
326 div1->SetFirstChild(div2); 326 div1->SetFirstChild(div2);
327 327
328 auto* space = ConstructConstraintSpace( 328 auto* space = ConstructConstraintSpace(
329 kHorizontalTopBottom, TextDirection::Ltr, 329 kHorizontalTopBottom, TextDirection::kLtr,
330 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 330 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
331 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 331 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
332 332
333 // Verify that margins are collapsed. 333 // Verify that margins are collapsed.
334 EXPECT_EQ(NGMarginStrut({LayoutUnit(0), LayoutUnit(kDiv2MarginBottom)}), 334 EXPECT_EQ(NGMarginStrut({LayoutUnit(0), LayoutUnit(kDiv2MarginBottom)}),
335 frag->MarginStrut()); 335 frag->MarginStrut());
336 336
337 // Verify that margins are NOT collapsed. 337 // Verify that margins are NOT collapsed.
338 div1_style->setHeight(Length(kHeight, Fixed)); 338 div1_style->setHeight(Length(kHeight, Fixed));
339 frag = RunBlockLayoutAlgorithm(space, div1); 339 frag = RunBlockLayoutAlgorithm(space, div1);
(...skipping 28 matching lines...) Expand all
368 // DIV2 368 // DIV2
369 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 369 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
370 div2_style->setHeight(Length(kHeight, Fixed)); 370 div2_style->setHeight(Length(kHeight, Fixed));
371 div2_style->setMarginTop(Length(kDiv2Margin, Fixed)); 371 div2_style->setMarginTop(Length(kDiv2Margin, Fixed));
372 div2_style->setMarginBottom(Length(kDiv2Margin, Fixed)); 372 div2_style->setMarginBottom(Length(kDiv2Margin, Fixed));
373 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 373 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
374 374
375 div1->SetFirstChild(div2); 375 div1->SetFirstChild(div2);
376 376
377 auto* space = ConstructConstraintSpace( 377 auto* space = ConstructConstraintSpace(
378 kHorizontalTopBottom, TextDirection::Ltr, 378 kHorizontalTopBottom, TextDirection::kLtr,
379 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 379 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
380 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 380 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
381 381
382 // Verify that margins do NOT collapse. 382 // Verify that margins do NOT collapse.
383 frag = RunBlockLayoutAlgorithm(space, div1); 383 frag = RunBlockLayoutAlgorithm(space, div1);
384 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv1Margin), LayoutUnit(kDiv1Margin)}), 384 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv1Margin), LayoutUnit(kDiv1Margin)}),
385 frag->MarginStrut()); 385 frag->MarginStrut());
386 ASSERT_EQ(frag->Children().size(), 1UL); 386 ASSERT_EQ(frag->Children().size(), 1UL);
387 387
388 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2Margin), LayoutUnit(kDiv2Margin)}), 388 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2Margin), LayoutUnit(kDiv2Margin)}),
(...skipping 18 matching lines...) Expand all
407 // horizontal 407 // horizontal
408 // </div> 408 // </div>
409 // </div> 409 // </div>
410 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { 410 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) {
411 const int kVerticalDivMarginRight = 60; 411 const int kVerticalDivMarginRight = 60;
412 const int kVerticalDivWidth = 50; 412 const int kVerticalDivWidth = 50;
413 const int kHorizontalDivMarginLeft = 100; 413 const int kHorizontalDivMarginLeft = 100;
414 414
415 style_->setWidth(Length(500, Fixed)); 415 style_->setWidth(Length(500, Fixed));
416 style_->setHeight(Length(500, Fixed)); 416 style_->setHeight(Length(500, Fixed));
417 style_->setWritingMode(WritingMode::VerticalLr); 417 style_->setWritingMode(WritingMode::kVerticalLr);
418 418
419 // Vertical DIV 419 // Vertical DIV
420 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); 420 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create();
421 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed)); 421 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed));
422 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed)); 422 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed));
423 NGBlockNode* vertical_div = new NGBlockNode(vertical_style.get()); 423 NGBlockNode* vertical_div = new NGBlockNode(vertical_style.get());
424 424
425 // Horizontal DIV 425 // Horizontal DIV
426 RefPtr<ComputedStyle> horizontal_style = ComputedStyle::create(); 426 RefPtr<ComputedStyle> horizontal_style = ComputedStyle::create();
427 horizontal_style->setMarginLeft(Length(kHorizontalDivMarginLeft, Fixed)); 427 horizontal_style->setMarginLeft(Length(kHorizontalDivMarginLeft, Fixed));
428 horizontal_style->setWritingMode(WritingMode::HorizontalTb); 428 horizontal_style->setWritingMode(WritingMode::kHorizontalTb);
429 NGBlockNode* horizontal_div = new NGBlockNode(horizontal_style.get()); 429 NGBlockNode* horizontal_div = new NGBlockNode(horizontal_style.get());
430 430
431 vertical_div->SetNextSibling(horizontal_div); 431 vertical_div->SetNextSibling(horizontal_div);
432 432
433 auto* space = 433 auto* space =
434 ConstructConstraintSpace(kVerticalLeftRight, TextDirection::Ltr, 434 ConstructConstraintSpace(kVerticalLeftRight, TextDirection::kLtr,
435 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); 435 NGLogicalSize(LayoutUnit(500), LayoutUnit(500)));
436 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, vertical_div); 436 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, vertical_div);
437 437
438 ASSERT_EQ(frag->Children().size(), 2UL); 438 ASSERT_EQ(frag->Children().size(), 2UL);
439 const NGPhysicalFragment* child = frag->Children()[1]; 439 const NGPhysicalFragment* child = frag->Children()[1];
440 // Horizontal div 440 // Horizontal div
441 EXPECT_EQ(0, child->TopOffset()); 441 EXPECT_EQ(0, child->TopOffset());
442 EXPECT_EQ(kVerticalDivWidth + kHorizontalDivMarginLeft, child->LeftOffset()); 442 EXPECT_EQ(kVerticalDivWidth + kHorizontalDivMarginLeft, child->LeftOffset());
443 } 443 }
444 444
(...skipping 17 matching lines...) Expand all
462 const int kMarginLeft = -20; 462 const int kMarginLeft = -20;
463 const int kMarginTop = 40; 463 const int kMarginTop = 40;
464 464
465 style_->setWidth(Length(500, Fixed)); 465 style_->setWidth(Length(500, Fixed));
466 style_->setHeight(Length(500, Fixed)); 466 style_->setHeight(Length(500, Fixed));
467 467
468 // DIV1 468 // DIV1
469 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); 469 RefPtr<ComputedStyle> div1_style = ComputedStyle::create();
470 div1_style->setWidth(Length(kWidth, Fixed)); 470 div1_style->setWidth(Length(kWidth, Fixed));
471 div1_style->setHeight(Length(kHeight, Fixed)); 471 div1_style->setHeight(Length(kHeight, Fixed));
472 div1_style->setWritingMode(WritingMode::VerticalRl); 472 div1_style->setWritingMode(WritingMode::kVerticalRl);
473 div1_style->setMarginBottom(Length(kMarginBottom, Fixed)); 473 div1_style->setMarginBottom(Length(kMarginBottom, Fixed));
474 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); 474 NGBlockNode* div1 = new NGBlockNode(div1_style.get());
475 475
476 // DIV2 476 // DIV2
477 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 477 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
478 div2_style->setWidth(Length(kWidth, Fixed)); 478 div2_style->setWidth(Length(kWidth, Fixed));
479 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); 479 div2_style->setMarginLeft(Length(kMarginLeft, Fixed));
480 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 480 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
481 481
482 // DIV3 482 // DIV3
483 RefPtr<ComputedStyle> div3_style = ComputedStyle::create(); 483 RefPtr<ComputedStyle> div3_style = ComputedStyle::create();
484 div3_style->setHeight(Length(kHeight, Fixed)); 484 div3_style->setHeight(Length(kHeight, Fixed));
485 div3_style->setMarginTop(Length(kMarginTop, Fixed)); 485 div3_style->setMarginTop(Length(kMarginTop, Fixed));
486 NGBlockNode* div3 = new NGBlockNode(div3_style.get()); 486 NGBlockNode* div3 = new NGBlockNode(div3_style.get());
487 487
488 div1->SetFirstChild(div2); 488 div1->SetFirstChild(div2);
489 div1->SetNextSibling(div3); 489 div1->SetNextSibling(div3);
490 490
491 auto* space = 491 auto* space =
492 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::Ltr, 492 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr,
493 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); 493 NGLogicalSize(LayoutUnit(500), LayoutUnit(500)));
494 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 494 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
495 495
496 ASSERT_EQ(frag->Children().size(), 2UL); 496 ASSERT_EQ(frag->Children().size(), 2UL);
497 497
498 const NGPhysicalFragment* child1 = frag->Children()[0]; 498 const NGPhysicalFragment* child1 = frag->Children()[0];
499 EXPECT_EQ(0, child1->TopOffset()); 499 EXPECT_EQ(0, child1->TopOffset());
500 EXPECT_EQ(kHeight, child1->Height()); 500 EXPECT_EQ(kHeight, child1->Height());
501 501
502 const NGPhysicalFragment* child2 = frag->Children()[1]; 502 const NGPhysicalFragment* child2 = frag->Children()[1];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 div1_style->setPaddingBottom(Length(kPaddingBottom, Fixed)); 545 div1_style->setPaddingBottom(Length(kPaddingBottom, Fixed));
546 div1_style->setPaddingLeft(Length(kPaddingLeft, Fixed)); 546 div1_style->setPaddingLeft(Length(kPaddingLeft, Fixed));
547 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); 547 NGBlockNode* div1 = new NGBlockNode(div1_style.get());
548 548
549 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 549 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
550 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 550 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
551 551
552 div1->SetFirstChild(div2); 552 div1->SetFirstChild(div2);
553 553
554 auto* space = ConstructConstraintSpace( 554 auto* space = ConstructConstraintSpace(
555 kHorizontalTopBottom, TextDirection::Ltr, 555 kHorizontalTopBottom, TextDirection::kLtr,
556 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); 556 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite));
557 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 557 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
558 558
559 ASSERT_EQ(frag->Children().size(), 1UL); 559 ASSERT_EQ(frag->Children().size(), 1UL);
560 560
561 // div1 561 // div1
562 const NGPhysicalFragment* child = frag->Children()[0]; 562 const NGPhysicalFragment* child = frag->Children()[0];
563 EXPECT_EQ(kBorderLeft + kPaddingLeft + kWidth + kPaddingRight + kBorderRight, 563 EXPECT_EQ(kBorderLeft + kPaddingLeft + kWidth + kPaddingRight + kBorderRight,
564 child->Width()); 564 child->Width());
565 EXPECT_EQ(kBorderTop + kPaddingTop + kHeight + kPaddingBottom + kBorderBottom, 565 EXPECT_EQ(kBorderTop + kPaddingTop + kHeight + kPaddingBottom + kBorderBottom,
(...skipping 13 matching lines...) Expand all
579 const int kPaddingLeft = 10; 579 const int kPaddingLeft = 10;
580 const int kWidth = 30; 580 const int kWidth = 30;
581 style_->setWidth(Length(kWidth, Fixed)); 581 style_->setWidth(Length(kWidth, Fixed));
582 style_->setPaddingLeft(Length(kPaddingLeft, Fixed)); 582 style_->setPaddingLeft(Length(kPaddingLeft, Fixed));
583 583
584 RefPtr<ComputedStyle> first_style = ComputedStyle::create(); 584 RefPtr<ComputedStyle> first_style = ComputedStyle::create();
585 first_style->setWidth(Length(40, Percent)); 585 first_style->setWidth(Length(40, Percent));
586 NGBlockNode* first_child = new NGBlockNode(first_style.get()); 586 NGBlockNode* first_child = new NGBlockNode(first_style.get());
587 587
588 auto* space = ConstructConstraintSpace( 588 auto* space = ConstructConstraintSpace(
589 kHorizontalTopBottom, TextDirection::Ltr, 589 kHorizontalTopBottom, TextDirection::kLtr,
590 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 590 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
591 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child); 591 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
592 592
593 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); 593 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width());
594 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); 594 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type());
595 ASSERT_EQ(frag->Children().size(), 1UL); 595 ASSERT_EQ(frag->Children().size(), 1UL);
596 596
597 const NGPhysicalFragment* child = frag->Children()[0]; 597 const NGPhysicalFragment* child = frag->Children()[0];
598 EXPECT_EQ(LayoutUnit(12), child->Width()); 598 EXPECT_EQ(LayoutUnit(12), child->Width());
599 } 599 }
600 600
601 // A very simple auto margin case. We rely on the tests in ng_length_utils_test 601 // A very simple auto margin case. We rely on the tests in ng_length_utils_test
602 // for the more complex cases; just make sure we handle auto at all here. 602 // for the more complex cases; just make sure we handle auto at all here.
603 TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) { 603 TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) {
604 const int kPaddingLeft = 10; 604 const int kPaddingLeft = 10;
605 const int kWidth = 30; 605 const int kWidth = 30;
606 style_->setWidth(Length(kWidth, Fixed)); 606 style_->setWidth(Length(kWidth, Fixed));
607 style_->setPaddingLeft(Length(kPaddingLeft, Fixed)); 607 style_->setPaddingLeft(Length(kPaddingLeft, Fixed));
608 608
609 RefPtr<ComputedStyle> first_style = ComputedStyle::create(); 609 RefPtr<ComputedStyle> first_style = ComputedStyle::create();
610 const int kChildWidth = 10; 610 const int kChildWidth = 10;
611 first_style->setWidth(Length(kChildWidth, Fixed)); 611 first_style->setWidth(Length(kChildWidth, Fixed));
612 first_style->setMarginLeft(Length(Auto)); 612 first_style->setMarginLeft(Length(Auto));
613 first_style->setMarginRight(Length(Auto)); 613 first_style->setMarginRight(Length(Auto));
614 NGBlockNode* first_child = new NGBlockNode(first_style.get()); 614 NGBlockNode* first_child = new NGBlockNode(first_style.get());
615 615
616 auto* space = ConstructConstraintSpace( 616 auto* space = ConstructConstraintSpace(
617 kHorizontalTopBottom, TextDirection::Ltr, 617 kHorizontalTopBottom, TextDirection::kLtr,
618 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); 618 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
619 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child); 619 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
620 620
621 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); 621 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width());
622 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); 622 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type());
623 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->WidthOverflow()); 623 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->WidthOverflow());
624 ASSERT_EQ(1UL, frag->Children().size()); 624 ASSERT_EQ(1UL, frag->Children().size());
625 625
626 const NGPhysicalFragment* child = frag->Children()[0]; 626 const NGPhysicalFragment* child = frag->Children()[0];
627 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width()); 627 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width());
(...skipping 30 matching lines...) Expand all
658 const int kDiv4LeftMargin = kDiv1Size; 658 const int kDiv4LeftMargin = kDiv1Size;
659 659
660 style_->setHeight(Length(kParentSize, Fixed)); 660 style_->setHeight(Length(kParentSize, Fixed));
661 style_->setWidth(Length(kParentSize, Fixed)); 661 style_->setWidth(Length(kParentSize, Fixed));
662 style_->setPaddingLeft(Length(kParentLeftPadding, Fixed)); 662 style_->setPaddingLeft(Length(kParentLeftPadding, Fixed));
663 663
664 // DIV1 664 // DIV1
665 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); 665 RefPtr<ComputedStyle> div1_style = ComputedStyle::create();
666 div1_style->setWidth(Length(kDiv1Size, Fixed)); 666 div1_style->setWidth(Length(kDiv1Size, Fixed));
667 div1_style->setHeight(Length(kDiv1Size, Fixed)); 667 div1_style->setHeight(Length(kDiv1Size, Fixed));
668 div1_style->setFloating(EFloat::Left); 668 div1_style->setFloating(EFloat::kLeft);
669 div1_style->setMarginTop(Length(kDiv1TopMargin, Fixed)); 669 div1_style->setMarginTop(Length(kDiv1TopMargin, Fixed));
670 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); 670 NGBlockNode* div1 = new NGBlockNode(div1_style.get());
671 671
672 // DIV2 672 // DIV2
673 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 673 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
674 div2_style->setWidth(Length(kDiv2Size, Fixed)); 674 div2_style->setWidth(Length(kDiv2Size, Fixed));
675 div2_style->setHeight(Length(kDiv2Size, Fixed)); 675 div2_style->setHeight(Length(kDiv2Size, Fixed));
676 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 676 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
677 677
678 // DIV3 678 // DIV3
679 RefPtr<ComputedStyle> div3_style = ComputedStyle::create(); 679 RefPtr<ComputedStyle> div3_style = ComputedStyle::create();
680 div3_style->setWidth(Length(kDiv3Size, Fixed)); 680 div3_style->setWidth(Length(kDiv3Size, Fixed));
681 div3_style->setHeight(Length(kDiv3Size, Fixed)); 681 div3_style->setHeight(Length(kDiv3Size, Fixed));
682 div3_style->setFloating(EFloat::Right); 682 div3_style->setFloating(EFloat::kRight);
683 NGBlockNode* div3 = new NGBlockNode(div3_style.get()); 683 NGBlockNode* div3 = new NGBlockNode(div3_style.get());
684 684
685 // DIV4 685 // DIV4
686 RefPtr<ComputedStyle> div4_style = ComputedStyle::create(); 686 RefPtr<ComputedStyle> div4_style = ComputedStyle::create();
687 div4_style->setWidth(Length(kDiv4Size, Fixed)); 687 div4_style->setWidth(Length(kDiv4Size, Fixed));
688 div4_style->setHeight(Length(kDiv4Size, Fixed)); 688 div4_style->setHeight(Length(kDiv4Size, Fixed));
689 div4_style->setMarginLeft(Length(kDiv4LeftMargin, Fixed)); 689 div4_style->setMarginLeft(Length(kDiv4LeftMargin, Fixed));
690 div4_style->setFloating(EFloat::Left); 690 div4_style->setFloating(EFloat::kLeft);
691 NGBlockNode* div4 = new NGBlockNode(div4_style.get()); 691 NGBlockNode* div4 = new NGBlockNode(div4_style.get());
692 692
693 div1->SetNextSibling(div2); 693 div1->SetNextSibling(div2);
694 div2->SetNextSibling(div3); 694 div2->SetNextSibling(div3);
695 div3->SetNextSibling(div4); 695 div3->SetNextSibling(div4);
696 696
697 auto* space = ConstructConstraintSpace( 697 auto* space = ConstructConstraintSpace(
698 kHorizontalTopBottom, TextDirection::Ltr, 698 kHorizontalTopBottom, TextDirection::kLtr,
699 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 699 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
700 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 700 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
701 ASSERT_EQ(frag->Children().size(), 4UL); 701 ASSERT_EQ(frag->Children().size(), 4UL);
702 702
703 // DIV1 703 // DIV1
704 const NGPhysicalFragment* child1 = frag->Children()[0]; 704 const NGPhysicalFragment* child1 = frag->Children()[0];
705 EXPECT_EQ(kDiv1TopMargin, child1->TopOffset()); 705 EXPECT_EQ(kDiv1TopMargin, child1->TopOffset());
706 EXPECT_EQ(kParentLeftPadding, child1->LeftOffset()); 706 EXPECT_EQ(kParentLeftPadding, child1->LeftOffset());
707 707
708 // DIV2 708 // DIV2
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 const int kDiv2Size = 40; 742 const int kDiv2Size = 40;
743 const int kDiv3Size = 50; 743 const int kDiv3Size = 50;
744 744
745 style_->setHeight(Length(kParentSize, Fixed)); 745 style_->setHeight(Length(kParentSize, Fixed));
746 style_->setWidth(Length(kParentSize, Fixed)); 746 style_->setWidth(Length(kParentSize, Fixed));
747 747
748 // DIV1 748 // DIV1
749 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); 749 RefPtr<ComputedStyle> div1_style = ComputedStyle::create();
750 div1_style->setWidth(Length(kDiv1Size, Fixed)); 750 div1_style->setWidth(Length(kDiv1Size, Fixed));
751 div1_style->setHeight(Length(kDiv1Size, Fixed)); 751 div1_style->setHeight(Length(kDiv1Size, Fixed));
752 div1_style->setFloating(EFloat::Left); 752 div1_style->setFloating(EFloat::kLeft);
753 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); 753 NGBlockNode* div1 = new NGBlockNode(div1_style.get());
754 754
755 // DIV2 755 // DIV2
756 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); 756 RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
757 div2_style->setWidth(Length(kDiv2Size, Fixed)); 757 div2_style->setWidth(Length(kDiv2Size, Fixed));
758 div2_style->setHeight(Length(kDiv2Size, Fixed)); 758 div2_style->setHeight(Length(kDiv2Size, Fixed));
759 div2_style->setClear(EClear::ClearLeft); 759 div2_style->setClear(EClear::ClearLeft);
760 div2_style->setFloating(EFloat::Right); 760 div2_style->setFloating(EFloat::kRight);
761 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); 761 NGBlockNode* div2 = new NGBlockNode(div2_style.get());
762 762
763 // DIV3 763 // DIV3
764 RefPtr<ComputedStyle> div3_style = ComputedStyle::create(); 764 RefPtr<ComputedStyle> div3_style = ComputedStyle::create();
765 div3_style->setWidth(Length(kDiv3Size, Fixed)); 765 div3_style->setWidth(Length(kDiv3Size, Fixed));
766 div3_style->setHeight(Length(kDiv3Size, Fixed)); 766 div3_style->setHeight(Length(kDiv3Size, Fixed));
767 NGBlockNode* div3 = new NGBlockNode(div3_style.get()); 767 NGBlockNode* div3 = new NGBlockNode(div3_style.get());
768 768
769 div1->SetNextSibling(div2); 769 div1->SetNextSibling(div2);
770 div2->SetNextSibling(div3); 770 div2->SetNextSibling(div3);
771 771
772 // clear: left; 772 // clear: left;
773 div3_style->setClear(EClear::ClearLeft); 773 div3_style->setClear(EClear::ClearLeft);
774 auto* space = ConstructConstraintSpace( 774 auto* space = ConstructConstraintSpace(
775 kHorizontalTopBottom, TextDirection::Ltr, 775 kHorizontalTopBottom, TextDirection::kLtr,
776 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 776 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
777 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1); 777 NGPhysicalBoxFragment* frag = RunBlockLayoutAlgorithm(space, div1);
778 const NGPhysicalFragment* child3 = frag->Children()[2]; 778 const NGPhysicalFragment* child3 = frag->Children()[2];
779 EXPECT_EQ(kDiv1Size, child3->TopOffset()); 779 EXPECT_EQ(kDiv1Size, child3->TopOffset());
780 780
781 // clear: right; 781 // clear: right;
782 div3_style->setClear(EClear::ClearRight); 782 div3_style->setClear(EClear::ClearRight);
783 space = ConstructConstraintSpace( 783 space = ConstructConstraintSpace(
784 kHorizontalTopBottom, TextDirection::Ltr, 784 kHorizontalTopBottom, TextDirection::kLtr,
785 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 785 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
786 frag = RunBlockLayoutAlgorithm(space, div1); 786 frag = RunBlockLayoutAlgorithm(space, div1);
787 child3 = frag->Children()[2]; 787 child3 = frag->Children()[2];
788 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); 788 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset());
789 789
790 // clear: both; 790 // clear: both;
791 div3_style->setClear(EClear::ClearBoth); 791 div3_style->setClear(EClear::ClearBoth);
792 space = ConstructConstraintSpace( 792 space = ConstructConstraintSpace(
793 kHorizontalTopBottom, TextDirection::Ltr, 793 kHorizontalTopBottom, TextDirection::kLtr,
794 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 794 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
795 frag = RunBlockLayoutAlgorithm(space, div1); 795 frag = RunBlockLayoutAlgorithm(space, div1);
796 space = ConstructConstraintSpace( 796 space = ConstructConstraintSpace(
797 kHorizontalTopBottom, TextDirection::Ltr, 797 kHorizontalTopBottom, TextDirection::kLtr,
798 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 798 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
799 child3 = frag->Children()[2]; 799 child3 = frag->Children()[2];
800 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); 800 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset());
801 } 801 }
802 802
803 // Verifies that we compute the right min and max-content size. 803 // Verifies that we compute the right min and max-content size.
804 TEST_F(NGBlockLayoutAlgorithmTest, ComputeMinMaxContent) { 804 TEST_F(NGBlockLayoutAlgorithmTest, ComputeMinMaxContent) {
805 const int kWidth = 50; 805 const int kWidth = 50;
806 const int kWidthChild1 = 20; 806 const int kWidthChild1 = 20;
807 const int kWidthChild2 = 30; 807 const int kWidthChild2 = 30;
(...skipping 25 matching lines...) Expand all
833 first_style->setWidth(Length(kWidthChild1, Fixed)); 833 first_style->setWidth(Length(kWidthChild1, Fixed));
834 NGBlockNode* first_child = new NGBlockNode(first_style.get()); 834 NGBlockNode* first_child = new NGBlockNode(first_style.get());
835 835
836 RefPtr<ComputedStyle> second_style = ComputedStyle::create(); 836 RefPtr<ComputedStyle> second_style = ComputedStyle::create();
837 second_style->setWidth(Length(kWidthChild2, Fixed)); 837 second_style->setWidth(Length(kWidthChild2, Fixed));
838 NGBlockNode* second_child = new NGBlockNode(second_style.get()); 838 NGBlockNode* second_child = new NGBlockNode(second_style.get());
839 839
840 first_child->SetNextSibling(second_child); 840 first_child->SetNextSibling(second_child);
841 841
842 auto* space = ConstructConstraintSpace( 842 auto* space = ConstructConstraintSpace(
843 kHorizontalTopBottom, TextDirection::Ltr, 843 kHorizontalTopBottom, TextDirection::kLtr,
844 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite), true); 844 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite), true);
845 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child); 845 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
846 846
847 EXPECT_EQ(LayoutUnit(30), frag->Width()); 847 EXPECT_EQ(LayoutUnit(30), frag->Width());
848 } 848 }
849 849
850 } // namespace 850 } // namespace
851 } // namespace blink 851 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698