OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_out_of_flow_layout_part.h" | 5 #include "core/layout/ng/ng_out_of_flow_layout_part.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/ng/layout_ng_block_flow.h" | 8 #include "core/layout/ng/layout_ng_block_flow.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 EXPECT_EQ(result->OutOfFlowDescendants().size(), (size_t)2); | 71 EXPECT_EQ(result->OutOfFlowDescendants().size(), (size_t)2); |
72 | 72 |
73 // Test the final result. | 73 // Test the final result. |
74 Element* fixed_1 = document().getElementById("fixed1"); | 74 Element* fixed_1 = document().getElementById("fixed1"); |
75 Element* fixed_2 = document().getElementById("fixed2"); | 75 Element* fixed_2 = document().getElementById("fixed2"); |
76 // fixed1 top is static: #abs.top + #pad.height | 76 // fixed1 top is static: #abs.top + #pad.height |
77 EXPECT_EQ(fixed_1->offsetTop(), LayoutUnit(99)); | 77 EXPECT_EQ(fixed_1->offsetTop(), LayoutUnit(99)); |
78 // fixed2 top is positioned: #fixed2.top | 78 // fixed2 top is positioned: #fixed2.top |
79 EXPECT_EQ(fixed_2->offsetTop(), LayoutUnit(9)); | 79 EXPECT_EQ(fixed_2->offsetTop(), LayoutUnit(9)); |
80 }; | 80 }; |
81 } | 81 |
82 } | 82 TEST_F(NGOutOfFlowLayoutPartTest, OrthogonalWritingMode1) { |
| 83 setBodyInnerHTML( |
| 84 R"HTML( |
| 85 <style> |
| 86 #container { |
| 87 position: relative; |
| 88 writing-mode: horizontal-tb; |
| 89 width: 200px; |
| 90 height: 400px; |
| 91 } |
| 92 #abs-child { |
| 93 position: absolute; |
| 94 top: 10px; |
| 95 writing-mode: vertical-rl; |
| 96 width: auto; |
| 97 height: 30px; |
| 98 } |
| 99 </style> |
| 100 <div id="container"> |
| 101 <div id="abs-child"></div> |
| 102 </div> |
| 103 )HTML"); |
| 104 |
| 105 LayoutNGBlockFlow* block_flow = |
| 106 toLayoutNGBlockFlow(getLayoutObjectByElementId("container")); |
| 107 auto* node = new NGBlockNode(block_flow); |
| 108 RefPtr<NGConstraintSpace> space = |
| 109 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
| 110 |
| 111 RefPtr<const NGPhysicalFragment> fragment = |
| 112 node->Layout(space.get())->PhysicalFragment(); |
| 113 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); |
| 114 |
| 115 fragment = toNGPhysicalBoxFragment(fragment.get())->Children()[0]; |
| 116 EXPECT_EQ(NGPhysicalSize(LayoutUnit(0), LayoutUnit(30)), fragment->Size()); |
| 117 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), |
| 118 fragment->Offset()); |
| 119 }; |
| 120 |
| 121 TEST_F(NGOutOfFlowLayoutPartTest, OrthogonalWritingMode2) { |
| 122 setBodyInnerHTML( |
| 123 R"HTML( |
| 124 <style> |
| 125 #container { |
| 126 position: relative; |
| 127 writing-mode: horizontal-tb; |
| 128 width: 200px; |
| 129 height: 400px; |
| 130 } |
| 131 #abs-child { |
| 132 position: absolute; |
| 133 top: 10px; |
| 134 writing-mode: vertical-rl; |
| 135 width: 20%; |
| 136 height: 30px; |
| 137 } |
| 138 </style> |
| 139 <div id="container"> |
| 140 <div id="abs-child"></div> |
| 141 </div> |
| 142 )HTML"); |
| 143 |
| 144 LayoutNGBlockFlow* block_flow = |
| 145 toLayoutNGBlockFlow(getLayoutObjectByElementId("container")); |
| 146 auto* node = new NGBlockNode(block_flow); |
| 147 RefPtr<NGConstraintSpace> space = |
| 148 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
| 149 |
| 150 RefPtr<const NGPhysicalFragment> fragment = |
| 151 node->Layout(space.get())->PhysicalFragment(); |
| 152 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); |
| 153 |
| 154 fragment = toNGPhysicalBoxFragment(fragment.get())->Children()[0]; |
| 155 EXPECT_EQ(NGPhysicalSize(LayoutUnit(40), LayoutUnit(30)), fragment->Size()); |
| 156 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), |
| 157 fragment->Offset()); |
| 158 }; |
| 159 |
| 160 } // namespace |
| 161 } // namespace blink |
OLD | NEW |