OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/LayoutBox.h" | 5 #include "core/layout/LayoutBox.h" |
6 | 6 |
7 #include "core/html/HTMLElement.h" | 7 #include "core/html/HTMLElement.h" |
8 #include "core/layout/ImageQualityController.h" | 8 #include "core/layout/ImageQualityController.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 TEST_F(LayoutBoxTest, TopLeftLocationFlipped) { | 133 TEST_F(LayoutBoxTest, TopLeftLocationFlipped) { |
134 setBodyInnerHTML( | 134 setBodyInnerHTML( |
135 "<div style='width: 600px; height: 200px; writing-mode: vertical-rl'>" | 135 "<div style='width: 600px; height: 200px; writing-mode: vertical-rl'>" |
136 " <div id='box1' style='width: 100px'></div>" | 136 " <div id='box1' style='width: 100px'></div>" |
137 " <div id='box2' style='width: 200px'></div>" | 137 " <div id='box2' style='width: 200px'></div>" |
138 "</div>"); | 138 "</div>"); |
139 | 139 |
140 const LayoutBox* box1 = toLayoutBox(getLayoutObjectByElementId("box1")); | 140 const LayoutBox* box1 = toLayoutBox(getLayoutObjectByElementId("box1")); |
141 EXPECT_EQ(LayoutPoint(0, 0), box1->location()); | 141 EXPECT_EQ(LayoutPoint(0, 0), box1->location()); |
142 EXPECT_EQ(LayoutPoint(500, 0), box1->topLeftLocation()); | 142 EXPECT_EQ(LayoutPoint(500, 0), box1->physicalLocation()); |
143 | 143 |
144 const LayoutBox* box2 = toLayoutBox(getLayoutObjectByElementId("box2")); | 144 const LayoutBox* box2 = toLayoutBox(getLayoutObjectByElementId("box2")); |
145 EXPECT_EQ(LayoutPoint(100, 0), box2->location()); | 145 EXPECT_EQ(LayoutPoint(100, 0), box2->location()); |
146 EXPECT_EQ(LayoutPoint(300, 0), box2->topLeftLocation()); | 146 EXPECT_EQ(LayoutPoint(300, 0), box2->physicalLocation()); |
147 } | 147 } |
148 | 148 |
149 TEST_F(LayoutBoxTest, TableRowCellTopLeftLocationFlipped) { | 149 TEST_F(LayoutBoxTest, TableRowCellTopLeftLocationFlipped) { |
150 setBodyInnerHTML( | 150 setBodyInnerHTML( |
151 "<div style='writing-mode: vertical-rl'>" | 151 "<div style='writing-mode: vertical-rl'>" |
152 " <table style='border-spacing: 0'>" | 152 " <table style='border-spacing: 0'>" |
153 " <thead><tr><td style='width: 50px'></td></tr></thead>" | 153 " <thead><tr><td style='width: 50px'></td></tr></thead>" |
154 " <tbody>" | 154 " <tbody>" |
155 " <tr id='row1'>" | 155 " <tr id='row1'>" |
156 " <td id='cell1' style='width: 100px; height: 80px'></td>" | 156 " <td id='cell1' style='width: 100px; height: 80px'></td>" |
157 " </tr>" | 157 " </tr>" |
158 " <tr id='row2'>" | 158 " <tr id='row2'>" |
159 " <td id='cell2' style='width: 300px; height: 80px'></td>" | 159 " <td id='cell2' style='width: 300px; height: 80px'></td>" |
160 " </tr>" | 160 " </tr>" |
161 " </tbody>" | 161 " </tbody>" |
162 " </table>" | 162 " </table>" |
163 "</div>"); | 163 "</div>"); |
164 | 164 |
165 // location and topLeftLocation of a table row or a table cell should be | 165 // location and physicalLocation of a table row or a table cell should be |
166 // relative to the containing section. | 166 // relative to the containing section. |
167 | 167 |
168 const LayoutBox* row1 = toLayoutBox(getLayoutObjectByElementId("row1")); | 168 const LayoutBox* row1 = toLayoutBox(getLayoutObjectByElementId("row1")); |
169 EXPECT_EQ(LayoutPoint(0, 0), row1->location()); | 169 EXPECT_EQ(LayoutPoint(0, 0), row1->location()); |
170 EXPECT_EQ(LayoutPoint(300, 0), row1->topLeftLocation()); | 170 EXPECT_EQ(LayoutPoint(300, 0), row1->physicalLocation()); |
171 | 171 |
172 const LayoutBox* cell1 = toLayoutBox(getLayoutObjectByElementId("cell1")); | 172 const LayoutBox* cell1 = toLayoutBox(getLayoutObjectByElementId("cell1")); |
173 EXPECT_EQ(LayoutPoint(0, 0), cell1->location()); | 173 EXPECT_EQ(LayoutPoint(0, 0), cell1->location()); |
174 EXPECT_EQ(LayoutPoint(300, 0), cell1->topLeftLocation()); | 174 EXPECT_EQ(LayoutPoint(300, 0), cell1->physicalLocation()); |
175 | 175 |
176 const LayoutBox* row2 = toLayoutBox(getLayoutObjectByElementId("row2")); | 176 const LayoutBox* row2 = toLayoutBox(getLayoutObjectByElementId("row2")); |
177 EXPECT_EQ(LayoutPoint(100, 0), row2->location()); | 177 EXPECT_EQ(LayoutPoint(100, 0), row2->location()); |
178 EXPECT_EQ(LayoutPoint(0, 0), row2->topLeftLocation()); | 178 EXPECT_EQ(LayoutPoint(0, 0), row2->physicalLocation()); |
179 | 179 |
180 const LayoutBox* cell2 = toLayoutBox(getLayoutObjectByElementId("cell2")); | 180 const LayoutBox* cell2 = toLayoutBox(getLayoutObjectByElementId("cell2")); |
181 EXPECT_EQ(LayoutPoint(100, 0), cell2->location()); | 181 EXPECT_EQ(LayoutPoint(100, 0), cell2->location()); |
182 EXPECT_EQ(LayoutPoint(0, 0), cell2->topLeftLocation()); | 182 EXPECT_EQ(LayoutPoint(0, 0), cell2->physicalLocation()); |
183 } | 183 } |
184 | 184 |
185 TEST_F(LayoutBoxTest, LocationContainerOfSVG) { | 185 TEST_F(LayoutBoxTest, LocationContainerOfSVG) { |
186 setBodyInnerHTML( | 186 setBodyInnerHTML( |
187 "<svg id='svg' style='writing-mode:vertical-rl' width='500' height='500'>" | 187 "<svg id='svg' style='writing-mode:vertical-rl' width='500' height='500'>" |
188 " <foreignObject x='44' y='77' width='100' height='80' id='foreign'>" | 188 " <foreignObject x='44' y='77' width='100' height='80' id='foreign'>" |
189 " <div id='child' style='width: 33px; height: 55px'>" | 189 " <div id='child' style='width: 33px; height: 55px'>" |
190 " </div>" | 190 " </div>" |
191 " </foreignObject>" | 191 " </foreignObject>" |
192 "</svg>"); | 192 "</svg>"); |
193 const LayoutBox* svgRoot = toLayoutBox(getLayoutObjectByElementId("svg")); | 193 const LayoutBox* svgRoot = toLayoutBox(getLayoutObjectByElementId("svg")); |
194 const LayoutBox* foreign = toLayoutBox(getLayoutObjectByElementId("foreign")); | 194 const LayoutBox* foreign = toLayoutBox(getLayoutObjectByElementId("foreign")); |
195 const LayoutBox* child = toLayoutBox(getLayoutObjectByElementId("child")); | 195 const LayoutBox* child = toLayoutBox(getLayoutObjectByElementId("child")); |
196 | 196 |
197 EXPECT_EQ(document().body()->layoutObject(), svgRoot->locationContainer()); | 197 EXPECT_EQ(document().body()->layoutObject(), svgRoot->locationContainer()); |
198 | 198 |
199 // The foreign object's location is not affected by SVGRoot's writing-mode. | 199 // The foreign object's location is not affected by SVGRoot's writing-mode. |
200 EXPECT_FALSE(foreign->locationContainer()); | 200 EXPECT_FALSE(foreign->locationContainer()); |
201 EXPECT_EQ(LayoutRect(44, 77, 100, 80), foreign->frameRect()); | 201 EXPECT_EQ(LayoutRect(44, 77, 100, 80), foreign->frameRect()); |
202 EXPECT_EQ(LayoutPoint(44, 77), foreign->topLeftLocation()); | 202 EXPECT_EQ(LayoutPoint(44, 77), foreign->physicalLocation()); |
203 // The writing mode style should be still be inherited. | 203 // The writing mode style should be still be inherited. |
204 EXPECT_TRUE(foreign->hasFlippedBlocksWritingMode()); | 204 EXPECT_TRUE(foreign->hasFlippedBlocksWritingMode()); |
205 | 205 |
206 // The child of the foreign object is affected by writing-mode. | 206 // The child of the foreign object is affected by writing-mode. |
207 EXPECT_EQ(foreign, child->locationContainer()); | 207 EXPECT_EQ(foreign, child->locationContainer()); |
208 EXPECT_EQ(LayoutRect(0, 0, 33, 55), child->frameRect()); | 208 EXPECT_EQ(LayoutRect(0, 0, 33, 55), child->frameRect()); |
209 EXPECT_EQ(LayoutPoint(67, 0), child->topLeftLocation()); | 209 EXPECT_EQ(LayoutPoint(67, 0), child->physicalLocation()); |
210 EXPECT_TRUE(child->hasFlippedBlocksWritingMode()); | 210 EXPECT_TRUE(child->hasFlippedBlocksWritingMode()); |
211 } | 211 } |
212 | 212 |
213 } // namespace blink | 213 } // namespace blink |
OLD | NEW |