Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/layout/ng/ng_out_of_flow_layout_part.h" | |
| 6 | |
| 7 #include "core/layout/LayoutTestHelper.h" | |
| 8 #include "core/layout/ng/layout_ng_block_flow.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 namespace { | |
| 12 | |
| 13 class NGOutOfFlowLayoutPartTest : public RenderingTest { | |
| 14 public: | |
| 15 NGOutOfFlowLayoutPartTest() { | |
| 16 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | |
| 17 }; | |
| 18 ~NGOutOfFlowLayoutPartTest() { | |
| 19 RuntimeEnabledFeatures::setLayoutNGEnabled(false); | |
| 20 }; | |
| 21 }; | |
| 22 | |
| 23 // Fixed blocks inside absolute blocks trigger otherwise unused while loop | |
| 24 // inside NGOutOfFlowLayoutPart::Run. | |
| 25 // This test exercises this loop by placing two fixed elements inside abs. | |
| 26 TEST_F(NGOutOfFlowLayoutPartTest, FixedInsideAbs) { | |
| 27 setBodyInnerHTML( | |
| 28 R"HTML( | |
| 29 <style> | |
| 30 body{ padding:0px; margin:0px} | |
| 31 #rel { position:relative } | |
| 32 #abs { | |
| 33 position: absolute; | |
| 34 top:49px; | |
| 35 left:0px; | |
| 36 } | |
| 37 #pad { | |
| 38 width:100px; | |
| 39 height:50px; | |
| 40 } | |
| 41 #fixed1 { | |
| 42 position:fixed; | |
| 43 width:50px; | |
| 44 } | |
| 45 #fixed2 { | |
| 46 position:fixed; | |
| 47 top:9px; | |
| 48 left:7px; | |
| 49 } | |
| 50 </style> | |
| 51 <div id='rel'> | |
| 52 <div id='abs'> | |
| 53 <div id='pad'></div> | |
| 54 <div id='fixed1'> | |
| 55 <p>fixed static</p> | |
| 56 </div> | |
| 57 <div id='fixed2'> | |
| 58 <p>fixed plain</p> | |
| 59 </div> | |
| 60 </div> | |
| 61 </div> | |
| 62 )HTML"); | |
| 63 | |
| 64 // Test whether oof fragments have been collected at NG->Legacy boundary | |
|
ikilpatrick
2017/02/06 19:46:03
.nit
// Test whether the oof fragments have been
| |
| 65 Element* rel = document().getElementById("rel"); | |
| 66 LayoutNGBlockFlow* block_flow = toLayoutNGBlockFlow(rel->layoutObject()); | |
| 67 NGConstraintSpace* space = | |
| 68 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | |
| 69 NGBlockNode node(block_flow); | |
| 70 RefPtr<NGPhysicalFragment> fragment = node.Layout(space); | |
| 71 EXPECT_EQ(fragment->OutOfFlowDescendants().size(), (size_t)2); | |
| 72 | |
| 73 // Test the final result | |
|
ikilpatrick
2017/02/06 19:46:03
.nit period.
| |
| 74 Element* fixed1 = document().getElementById("fixed1"); | |
| 75 Element* fixed2 = document().getElementById("fixed2"); | |
| 76 // fixed1 top is static: #abs.top + #pad.height | |
| 77 EXPECT_EQ(fixed1->offsetTop(), LayoutUnit(99)); | |
| 78 // fixed2 top is positioned: #fixed2.top | |
| 79 EXPECT_EQ(fixed2->offsetTop(), LayoutUnit(9)); | |
| 80 }; | |
| 81 } | |
| 82 } | |
| OLD | NEW |