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

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

Issue 2651393003: [layoutng] Propagate fixed descendants of abs. (Closed)
Patch Set: fixed1 is a reserved keyword on a mac Created 3 years, 10 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_out_of_flow_layout_part.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
(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 the oof fragments have been collected at NG->Legacy boundary.
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.
74 Element* fixed_1 = document().getElementById("fixed1");
75 Element* fixed_2 = document().getElementById("fixed2");
76 // fixed1 top is static: #abs.top + #pad.height
77 EXPECT_EQ(fixed_1->offsetTop(), LayoutUnit(99));
78 // fixed2 top is positioned: #fixed2.top
79 EXPECT_EQ(fixed_2->offsetTop(), LayoutUnit(9));
80 };
81 }
82 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698