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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 " width: 100px; height: 100px; background: blue'>" | 256 " width: 100px; height: 100px; background: blue'>" |
257 " <div style='width: 300px; height: 10px; background: green'></div>" | 257 " <div style='width: 300px; height: 10px; background: green'></div>" |
258 "</div>"); | 258 "</div>"); |
259 | 259 |
260 LayoutBox* target = ToLayoutBox(GetLayoutObjectByElementId("target")); | 260 LayoutBox* target = ToLayoutBox(GetLayoutObjectByElementId("target")); |
261 EXPECT_TRUE(target->HasMask()); | 261 EXPECT_TRUE(target->HasMask()); |
262 EXPECT_TRUE(target->HasOverflowClip()); | 262 EXPECT_TRUE(target->HasOverflowClip()); |
263 EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->LocalVisualRect()); | 263 EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->LocalVisualRect()); |
264 } | 264 } |
265 | 265 |
| 266 TEST_F(LayoutBoxTest, ContentsVisualOverflowPropagation) { |
| 267 SetBodyInnerHTML( |
| 268 "<style>" |
| 269 " div { width: 100px; height: 100px }" |
| 270 "</style>" |
| 271 "<div id='a'>" |
| 272 " <div style='height: 50px'></div>" |
| 273 " <div id='b' style='writing-mode: vertical-rl; margin-left: 60px'>" |
| 274 " <div style='width: 30px'></div>" |
| 275 " <div id='c' style='margin-top: 40px'>" |
| 276 " <div style='width: 10px'></div>" |
| 277 " <div style='margin-top: 20px; margin-left: 10px'></div>" |
| 278 " </div>" |
| 279 " <div id='d' style='writing-mode: vertical-lr; margin-top: 40px'>" |
| 280 " <div style='width: 10px'></div>" |
| 281 " <div style='margin-top: 20px'></div>" |
| 282 " </div>" |
| 283 " </div>" |
| 284 "</div>"); |
| 285 |
| 286 auto* c = ToLayoutBox(GetLayoutObjectByElementId("c")); |
| 287 EXPECT_EQ(LayoutRect(0, 0, 100, 100), c->SelfVisualOverflowRect()); |
| 288 EXPECT_EQ(LayoutRect(10, 20, 100, 100), c->ContentsVisualOverflowRect()); |
| 289 EXPECT_EQ(LayoutRect(0, 0, 110, 120), c->VisualOverflowRect()); |
| 290 // C and its parent b have the same blocks direction. |
| 291 EXPECT_EQ(LayoutRect(0, 0, 110, 120), c->VisualOverflowRectForPropagation()); |
| 292 |
| 293 auto* d = ToLayoutBox(GetLayoutObjectByElementId("d")); |
| 294 EXPECT_EQ(LayoutRect(0, 0, 100, 100), d->SelfVisualOverflowRect()); |
| 295 EXPECT_EQ(LayoutRect(10, 20, 100, 100), d->ContentsVisualOverflowRect()); |
| 296 EXPECT_EQ(LayoutRect(0, 0, 110, 120), d->VisualOverflowRect()); |
| 297 // D and its parent b have different blocks direction. |
| 298 EXPECT_EQ(LayoutRect(-10, 0, 110, 120), |
| 299 d->VisualOverflowRectForPropagation()); |
| 300 |
| 301 auto* b = ToLayoutBox(GetLayoutObjectByElementId("b")); |
| 302 EXPECT_EQ(LayoutRect(0, 0, 100, 100), b->SelfVisualOverflowRect()); |
| 303 // Union of VisualOverflowRectForPropagations offset by locations of c and d. |
| 304 EXPECT_EQ(LayoutRect(30, 40, 200, 120), b->ContentsVisualOverflowRect()); |
| 305 EXPECT_EQ(LayoutRect(0, 0, 230, 160), b->VisualOverflowRect()); |
| 306 // B and its parent A have different blocks direction. |
| 307 EXPECT_EQ(LayoutRect(-130, 0, 230, 160), |
| 308 b->VisualOverflowRectForPropagation()); |
| 309 |
| 310 auto* a = ToLayoutBox(GetLayoutObjectByElementId("a")); |
| 311 EXPECT_EQ(LayoutRect(0, 0, 100, 100), a->SelfVisualOverflowRect()); |
| 312 EXPECT_EQ(LayoutRect(-70, 50, 230, 160), a->ContentsVisualOverflowRect()); |
| 313 EXPECT_EQ(LayoutRect(-70, 0, 230, 210), a->VisualOverflowRect()); |
| 314 } |
| 315 |
266 } // namespace blink | 316 } // namespace blink |
OLD | NEW |