| 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 #include "core/layout/ng/ng_layout_result.h" | 9 #include "core/layout/ng/ng_layout_result.h" |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 </div> | 60 </div> |
| 61 </div> | 61 </div> |
| 62 </div> | 62 </div> |
| 63 )HTML"); | 63 )HTML"); |
| 64 | 64 |
| 65 // Test whether the oof fragments have been collected at NG->Legacy boundary. | 65 // Test whether the oof fragments have been collected at NG->Legacy boundary. |
| 66 Element* rel = GetDocument().getElementById("rel"); | 66 Element* rel = GetDocument().getElementById("rel"); |
| 67 LayoutNGBlockFlow* block_flow = ToLayoutNGBlockFlow(rel->GetLayoutObject()); | 67 LayoutNGBlockFlow* block_flow = ToLayoutNGBlockFlow(rel->GetLayoutObject()); |
| 68 RefPtr<NGConstraintSpace> space = | 68 RefPtr<NGConstraintSpace> space = |
| 69 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 69 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
| 70 NGBlockNode* node = new NGBlockNode(block_flow); | 70 NGBlockNode node(block_flow); |
| 71 RefPtr<NGLayoutResult> result = node->Layout(space.Get()); | 71 RefPtr<NGLayoutResult> result = node.Layout(space.Get()); |
| 72 EXPECT_EQ(result->OutOfFlowDescendants().size(), (size_t)2); | 72 EXPECT_EQ(result->OutOfFlowDescendants().size(), (size_t)2); |
| 73 | 73 |
| 74 // Test the final result. | 74 // Test the final result. |
| 75 Element* fixed_1 = GetDocument().getElementById("fixed1"); | 75 Element* fixed_1 = GetDocument().getElementById("fixed1"); |
| 76 Element* fixed_2 = GetDocument().getElementById("fixed2"); | 76 Element* fixed_2 = GetDocument().getElementById("fixed2"); |
| 77 // fixed1 top is static: #abs.top + #pad.height | 77 // fixed1 top is static: #abs.top + #pad.height |
| 78 EXPECT_EQ(fixed_1->OffsetTop(), LayoutUnit(99)); | 78 EXPECT_EQ(fixed_1->OffsetTop(), LayoutUnit(99)); |
| 79 // fixed2 top is positioned: #fixed2.top | 79 // fixed2 top is positioned: #fixed2.top |
| 80 EXPECT_EQ(fixed_2->OffsetTop(), LayoutUnit(9)); | 80 EXPECT_EQ(fixed_2->OffsetTop(), LayoutUnit(9)); |
| 81 }; | 81 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 98 height: 30px; | 98 height: 30px; |
| 99 } | 99 } |
| 100 </style> | 100 </style> |
| 101 <div id="container"> | 101 <div id="container"> |
| 102 <div id="abs-child"></div> | 102 <div id="abs-child"></div> |
| 103 </div> | 103 </div> |
| 104 )HTML"); | 104 )HTML"); |
| 105 | 105 |
| 106 LayoutNGBlockFlow* block_flow = | 106 LayoutNGBlockFlow* block_flow = |
| 107 ToLayoutNGBlockFlow(GetLayoutObjectByElementId("container")); | 107 ToLayoutNGBlockFlow(GetLayoutObjectByElementId("container")); |
| 108 auto* node = new NGBlockNode(block_flow); | 108 NGBlockNode node(block_flow); |
| 109 RefPtr<NGConstraintSpace> space = | 109 RefPtr<NGConstraintSpace> space = |
| 110 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 110 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
| 111 | 111 |
| 112 RefPtr<const NGPhysicalFragment> fragment = | 112 RefPtr<const NGPhysicalFragment> fragment = |
| 113 node->Layout(space.Get())->PhysicalFragment(); | 113 node.Layout(space.Get())->PhysicalFragment(); |
| 114 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); | 114 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); |
| 115 | 115 |
| 116 fragment = ToNGPhysicalBoxFragment(fragment.Get())->Children()[0]; | 116 fragment = ToNGPhysicalBoxFragment(fragment.Get())->Children()[0]; |
| 117 EXPECT_EQ(NGPhysicalSize(LayoutUnit(0), LayoutUnit(30)), fragment->Size()); | 117 EXPECT_EQ(NGPhysicalSize(LayoutUnit(0), LayoutUnit(30)), fragment->Size()); |
| 118 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), | 118 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), |
| 119 fragment->Offset()); | 119 fragment->Offset()); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 TEST_F(NGOutOfFlowLayoutPartTest, OrthogonalWritingMode2) { | 122 TEST_F(NGOutOfFlowLayoutPartTest, OrthogonalWritingMode2) { |
| 123 SetBodyInnerHTML( | 123 SetBodyInnerHTML( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 137 height: 30px; | 137 height: 30px; |
| 138 } | 138 } |
| 139 </style> | 139 </style> |
| 140 <div id="container"> | 140 <div id="container"> |
| 141 <div id="abs-child"></div> | 141 <div id="abs-child"></div> |
| 142 </div> | 142 </div> |
| 143 )HTML"); | 143 )HTML"); |
| 144 | 144 |
| 145 LayoutNGBlockFlow* block_flow = | 145 LayoutNGBlockFlow* block_flow = |
| 146 ToLayoutNGBlockFlow(GetLayoutObjectByElementId("container")); | 146 ToLayoutNGBlockFlow(GetLayoutObjectByElementId("container")); |
| 147 auto* node = new NGBlockNode(block_flow); | 147 NGBlockNode node(block_flow); |
| 148 RefPtr<NGConstraintSpace> space = | 148 RefPtr<NGConstraintSpace> space = |
| 149 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 149 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
| 150 | 150 |
| 151 RefPtr<const NGPhysicalFragment> fragment = | 151 RefPtr<const NGPhysicalFragment> fragment = |
| 152 node->Layout(space.Get())->PhysicalFragment(); | 152 node.Layout(space.Get())->PhysicalFragment(); |
| 153 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); | 153 EXPECT_EQ(NGPhysicalSize(LayoutUnit(200), LayoutUnit(400)), fragment->Size()); |
| 154 | 154 |
| 155 fragment = ToNGPhysicalBoxFragment(fragment.Get())->Children()[0]; | 155 fragment = ToNGPhysicalBoxFragment(fragment.Get())->Children()[0]; |
| 156 EXPECT_EQ(NGPhysicalSize(LayoutUnit(40), LayoutUnit(30)), fragment->Size()); | 156 EXPECT_EQ(NGPhysicalSize(LayoutUnit(40), LayoutUnit(30)), fragment->Size()); |
| 157 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), | 157 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(10)), |
| 158 fragment->Offset()); | 158 fragment->Offset()); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |