| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutView.h" | 6 #include "core/layout/LayoutView.h" |
| 7 #include "core/layout/PaintInvalidationState.h" | 7 #include "core/layout/PaintInvalidationState.h" |
| 8 #include "core/paint/PaintLayer.h" | 8 #include "core/paint/PaintLayer.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) { | 228 TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) { |
| 229 setBodyInnerHTML( | 229 setBodyInnerHTML( |
| 230 "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px " | 230 "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px " |
| 231 "20px black;" | 231 "20px black;" |
| 232 " width: 100px; height: 50px; position: absolute; top: 111px; left: " | 232 " width: 100px; height: 50px; position: absolute; top: 111px; left: " |
| 233 "222px'>" | 233 "222px'>" |
| 234 "</div>"); | 234 "</div>"); |
| 235 | 235 |
| 236 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 236 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 237 LayoutRect overflowRect = target->localOverflowRectForPaintInvalidation(); | 237 LayoutRect visualRect = target->localVisualRect(); |
| 238 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the | 238 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| 239 // origin) | 239 // origin) |
| 240 // 140 = width(100) + box_shadow_offset_x(40) | 240 // 140 = width(100) + box_shadow_offset_x(40) |
| 241 // 70 = height(50) + box_shadow_offset_y(20) | 241 // 70 = height(50) + box_shadow_offset_y(20) |
| 242 EXPECT_EQ(LayoutRect(-40, 0, 140, 70), overflowRect); | 242 EXPECT_EQ(LayoutRect(-40, 0, 140, 70), visualRect); |
| 243 | 243 |
| 244 LayoutRect rect = overflowRect; | 244 LayoutRect rect = visualRect; |
| 245 // TODO(wkorman): The calls to flipForWritingMode() here and in other test | 245 // TODO(wkorman): The calls to flipForWritingMode() here and in other test |
| 246 // cases below are necessary because mapToVisualRectInAncestorSpace() | 246 // cases below are necessary because mapToVisualRectInAncestorSpace() |
| 247 // currently expects the input rect to be in "physical coordinates" (*not* | 247 // currently expects the input rect to be in "physical coordinates" (*not* |
| 248 // "physical coordinates with flipped block-flow direction"), see | 248 // "physical coordinates with flipped block-flow direction"), see |
| 249 // LayoutBoxModelObject.h. | 249 // LayoutBoxModelObject.h. |
| 250 target->flipForWritingMode(rect); | 250 target->flipForWritingMode(rect); |
| 251 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 251 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 252 // This rect is in physical coordinates of target. | 252 // This rect is in physical coordinates of target. |
| 253 EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect); | 253 EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect); |
| 254 | 254 |
| 255 rect = overflowRect; | 255 rect = visualRect; |
| 256 target->flipForWritingMode(rect); | 256 target->flipForWritingMode(rect); |
| 257 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 257 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 258 EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect); | 258 EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect); |
| 259 checkPaintInvalidationStateRectMapping(rect, overflowRect, *target, | 259 checkPaintInvalidationStateRectMapping(rect, visualRect, *target, |
| 260 layoutView(), layoutView()); | 260 layoutView(), layoutView()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) { | 263 TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) { |
| 264 setBodyInnerHTML( | 264 setBodyInnerHTML( |
| 265 "<div id='container' style='writing-mode: vertical-rl; position: " | 265 "<div id='container' style='writing-mode: vertical-rl; position: " |
| 266 "absolute; top: 111px; left: 222px'>" | 266 "absolute; top: 111px; left: 222px'>" |
| 267 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " | 267 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| 268 "height: 90px'></div>" | 268 "height: 90px'></div>" |
| 269 " <div style='width: 100px; height: 100px'></div>" | 269 " <div style='width: 100px; height: 100px'></div>" |
| 270 "</div>"); | 270 "</div>"); |
| 271 | 271 |
| 272 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 272 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 273 LayoutRect targetOverflowRect = | 273 LayoutRect targetVisualRect = target->localVisualRect(); |
| 274 target->localOverflowRectForPaintInvalidation(); | |
| 275 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the | 274 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| 276 // origin) | 275 // origin) |
| 277 // 140 = width(100) + box_shadow_offset_x(40) | 276 // 140 = width(100) + box_shadow_offset_x(40) |
| 278 // 110 = height(90) + box_shadow_offset_y(20) | 277 // 110 = height(90) + box_shadow_offset_y(20) |
| 279 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); | 278 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| 280 | 279 |
| 281 LayoutRect rect = targetOverflowRect; | 280 LayoutRect rect = targetVisualRect; |
| 282 target->flipForWritingMode(rect); | 281 target->flipForWritingMode(rect); |
| 283 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 282 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 284 // This rect is in physical coordinates of target. | 283 // This rect is in physical coordinates of target. |
| 285 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 284 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 286 | 285 |
| 287 LayoutBlock* container = | 286 LayoutBlock* container = |
| 288 toLayoutBlock(getLayoutObjectByElementId("container")); | 287 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 289 rect = targetOverflowRect; | 288 rect = targetVisualRect; |
| 290 target->flipForWritingMode(rect); | 289 target->flipForWritingMode(rect); |
| 291 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 290 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 292 // 100 is the physical x location of target in container. | 291 // 100 is the physical x location of target in container. |
| 293 EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect); | 292 EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect); |
| 294 rect = targetOverflowRect; | 293 rect = targetVisualRect; |
| 295 target->flipForWritingMode(rect); | 294 target->flipForWritingMode(rect); |
| 296 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 295 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 297 EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); | 296 EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); |
| 298 checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, | 297 checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| 299 layoutView(), layoutView()); | 298 layoutView(), layoutView()); |
| 300 | 299 |
| 301 LayoutRect containerOverflowRect = | 300 LayoutRect containerVisualRect = container->localVisualRect(); |
| 302 container->localOverflowRectForPaintInvalidation(); | 301 EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerVisualRect); |
| 303 EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerOverflowRect); | 302 rect = containerVisualRect; |
| 304 rect = containerOverflowRect; | |
| 305 container->flipForWritingMode(rect); | 303 container->flipForWritingMode(rect); |
| 306 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); | 304 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| 307 EXPECT_EQ(LayoutRect(0, 0, 200, 100), rect); | 305 EXPECT_EQ(LayoutRect(0, 0, 200, 100), rect); |
| 308 rect = containerOverflowRect; | 306 rect = containerVisualRect; |
| 309 container->flipForWritingMode(rect); | 307 container->flipForWritingMode(rect); |
| 310 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 308 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 311 EXPECT_EQ(LayoutRect(222, 111, 200, 100), rect); | 309 EXPECT_EQ(LayoutRect(222, 111, 200, 100), rect); |
| 312 checkPaintInvalidationStateRectMapping( | 310 checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| 313 rect, containerOverflowRect, *container, layoutView(), layoutView()); | 311 layoutView(), layoutView()); |
| 314 } | 312 } |
| 315 | 313 |
| 316 TEST_F(VisualRectMappingTest, ContainerOverflowScroll) { | 314 TEST_F(VisualRectMappingTest, ContainerOverflowScroll) { |
| 317 setBodyInnerHTML( | 315 setBodyInnerHTML( |
| 318 "<div id='container' style='position: absolute; top: 111px; left: 222px;" | 316 "<div id='container' style='position: absolute; top: 111px; left: 222px;" |
| 319 " border: 10px solid red; overflow: scroll; width: 50px; height: " | 317 " border: 10px solid red; overflow: scroll; width: 50px; height: " |
| 320 "80px;'>" | 318 "80px;'>" |
| 321 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " | 319 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| 322 "height: 90px'></div>" | 320 "height: 90px'></div>" |
| 323 "</div>"); | 321 "</div>"); |
| 324 | 322 |
| 325 LayoutBlock* container = | 323 LayoutBlock* container = |
| 326 toLayoutBlock(getLayoutObjectByElementId("container")); | 324 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 327 EXPECT_EQ(LayoutUnit(), container->scrollTop()); | 325 EXPECT_EQ(LayoutUnit(), container->scrollTop()); |
| 328 EXPECT_EQ(LayoutUnit(), container->scrollLeft()); | 326 EXPECT_EQ(LayoutUnit(), container->scrollLeft()); |
| 329 container->setScrollTop(LayoutUnit(7)); | 327 container->setScrollTop(LayoutUnit(7)); |
| 330 container->setScrollLeft(LayoutUnit(8)); | 328 container->setScrollLeft(LayoutUnit(8)); |
| 331 document().view()->updateAllLifecyclePhases(); | 329 document().view()->updateAllLifecyclePhases(); |
| 332 | 330 |
| 333 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 331 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 334 LayoutRect targetOverflowRect = | 332 LayoutRect targetVisualRect = target->localVisualRect(); |
| 335 target->localOverflowRectForPaintInvalidation(); | |
| 336 // 140 = width(100) + box_shadow_offset_x(40) | 333 // 140 = width(100) + box_shadow_offset_x(40) |
| 337 // 110 = height(90) + box_shadow_offset_y(20) | 334 // 110 = height(90) + box_shadow_offset_y(20) |
| 338 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect); | 335 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| 339 LayoutRect rect = targetOverflowRect; | 336 LayoutRect rect = targetVisualRect; |
| 340 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 337 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 341 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 338 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 342 | 339 |
| 343 rect = targetOverflowRect; | 340 rect = targetVisualRect; |
| 344 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 341 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 345 rect.move(-container->scrolledContentOffset()); | 342 rect.move(-container->scrolledContentOffset()); |
| 346 // 2 = target_x(0) + container_border_left(10) - scroll_left(8) | 343 // 2 = target_x(0) + container_border_left(10) - scroll_left(8) |
| 347 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) | 344 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) |
| 348 // Rect is not clipped by container's overflow clip because of | 345 // Rect is not clipped by container's overflow clip because of |
| 349 // overflow:scroll. | 346 // overflow:scroll. |
| 350 EXPECT_EQ(LayoutRect(2, 3, 140, 110), rect); | 347 EXPECT_EQ(LayoutRect(2, 3, 140, 110), rect); |
| 351 | 348 |
| 352 rect = targetOverflowRect; | 349 rect = targetVisualRect; |
| 353 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 350 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 354 // (2, 3, 140, 100) is first clipped by container's overflow clip, to | 351 // (2, 3, 140, 100) is first clipped by container's overflow clip, to |
| 355 // (10, 10, 50, 80), then is by added container's offset in LayoutView | 352 // (10, 10, 50, 80), then is by added container's offset in LayoutView |
| 356 // (111, 222). | 353 // (111, 222). |
| 357 EXPECT_EQ(LayoutRect(232, 121, 50, 80), rect); | 354 EXPECT_EQ(LayoutRect(232, 121, 50, 80), rect); |
| 358 checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, | 355 checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| 359 layoutView(), layoutView()); | 356 layoutView(), layoutView()); |
| 360 | 357 |
| 361 LayoutRect containerOverflowRect = | 358 LayoutRect containerVisualRect = container->localVisualRect(); |
| 362 container->localOverflowRectForPaintInvalidation(); | |
| 363 // Because container has overflow clip, its visual overflow doesn't include | 359 // Because container has overflow clip, its visual overflow doesn't include |
| 364 // overflow from children. | 360 // overflow from children. |
| 365 // 70 = width(50) + border_left_width(10) + border_right_width(10) | 361 // 70 = width(50) + border_left_width(10) + border_right_width(10) |
| 366 // 100 = height(80) + border_top_width(10) + border_bottom_width(10) | 362 // 100 = height(80) + border_top_width(10) + border_bottom_width(10) |
| 367 EXPECT_EQ(LayoutRect(0, 0, 70, 100), containerOverflowRect); | 363 EXPECT_EQ(LayoutRect(0, 0, 70, 100), containerVisualRect); |
| 368 rect = containerOverflowRect; | 364 rect = containerVisualRect; |
| 369 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); | 365 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| 370 // Container should not apply overflow clip on its own overflow rect. | 366 // Container should not apply overflow clip on its own overflow rect. |
| 371 EXPECT_EQ(LayoutRect(0, 0, 70, 100), rect); | 367 EXPECT_EQ(LayoutRect(0, 0, 70, 100), rect); |
| 372 | 368 |
| 373 rect = containerOverflowRect; | 369 rect = containerVisualRect; |
| 374 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 370 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 375 EXPECT_EQ(LayoutRect(222, 111, 70, 100), rect); | 371 EXPECT_EQ(LayoutRect(222, 111, 70, 100), rect); |
| 376 checkPaintInvalidationStateRectMapping( | 372 checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| 377 rect, containerOverflowRect, *container, layoutView(), layoutView()); | 373 layoutView(), layoutView()); |
| 378 } | 374 } |
| 379 | 375 |
| 380 TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { | 376 TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { |
| 381 setBodyInnerHTML( | 377 setBodyInnerHTML( |
| 382 "<div id='container' style='writing-mode: vertical-rl; position: " | 378 "<div id='container' style='writing-mode: vertical-rl; position: " |
| 383 "absolute; top: 111px; left: 222px;" | 379 "absolute; top: 111px; left: 222px;" |
| 384 " border: solid red; border-width: 10px 20px 30px 40px;" | 380 " border: solid red; border-width: 10px 20px 30px 40px;" |
| 385 " overflow: scroll; width: 50px; height: 80px'>" | 381 " overflow: scroll; width: 50px; height: 80px'>" |
| 386 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " | 382 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| 387 "height: 90px'></div>" | 383 "height: 90px'></div>" |
| 388 " <div style='width: 100px; height: 100px'></div>" | 384 " <div style='width: 100px; height: 100px'></div>" |
| 389 "</div>"); | 385 "</div>"); |
| 390 | 386 |
| 391 LayoutBlock* container = | 387 LayoutBlock* container = |
| 392 toLayoutBlock(getLayoutObjectByElementId("container")); | 388 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 393 EXPECT_EQ(LayoutUnit(), container->scrollTop()); | 389 EXPECT_EQ(LayoutUnit(), container->scrollTop()); |
| 394 // The initial scroll offset is to the left-most because of flipped blocks | 390 // The initial scroll offset is to the left-most because of flipped blocks |
| 395 // writing mode. | 391 // writing mode. |
| 396 // 150 = total_layout_overflow(100 + 100) - width(50) | 392 // 150 = total_layout_overflow(100 + 100) - width(50) |
| 397 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); | 393 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); |
| 398 container->setScrollTop(LayoutUnit(7)); | 394 container->setScrollTop(LayoutUnit(7)); |
| 399 container->setScrollLeft( | 395 container->setScrollLeft( |
| 400 LayoutUnit(142)); // Scroll to the right by 8 pixels. | 396 LayoutUnit(142)); // Scroll to the right by 8 pixels. |
| 401 document().view()->updateAllLifecyclePhases(); | 397 document().view()->updateAllLifecyclePhases(); |
| 402 | 398 |
| 403 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 399 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 404 LayoutRect targetOverflowRect = | 400 LayoutRect targetVisualRect = target->localVisualRect(); |
| 405 target->localOverflowRectForPaintInvalidation(); | |
| 406 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the | 401 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| 407 // origin) | 402 // origin) |
| 408 // 140 = width(100) + box_shadow_offset_x(40) | 403 // 140 = width(100) + box_shadow_offset_x(40) |
| 409 // 110 = height(90) + box_shadow_offset_y(20) | 404 // 110 = height(90) + box_shadow_offset_y(20) |
| 410 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); | 405 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| 411 | 406 |
| 412 LayoutRect rect = targetOverflowRect; | 407 LayoutRect rect = targetVisualRect; |
| 413 target->flipForWritingMode(rect); | 408 target->flipForWritingMode(rect); |
| 414 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 409 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 415 // This rect is in physical coordinates of target. | 410 // This rect is in physical coordinates of target. |
| 416 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 411 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 417 | 412 |
| 418 rect = targetOverflowRect; | 413 rect = targetVisualRect; |
| 419 target->flipForWritingMode(rect); | 414 target->flipForWritingMode(rect); |
| 420 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 415 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 421 rect.move(-container->scrolledContentOffset()); | 416 rect.move(-container->scrolledContentOffset()); |
| 422 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) | 417 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) |
| 423 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) | 418 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) |
| 424 // Rect is clipped by container's overflow clip because of overflow:scroll. | 419 // Rect is clipped by container's overflow clip because of overflow:scroll. |
| 425 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); | 420 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); |
| 426 | 421 |
| 427 rect = targetOverflowRect; | 422 rect = targetVisualRect; |
| 428 target->flipForWritingMode(rect); | 423 target->flipForWritingMode(rect); |
| 429 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 424 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 430 // (-2, 3, 140, 100) is first clipped by container's overflow clip, to | 425 // (-2, 3, 140, 100) is first clipped by container's overflow clip, to |
| 431 // (40, 10, 50, 80), then is added by container's offset in LayoutView | 426 // (40, 10, 50, 80), then is added by container's offset in LayoutView |
| 432 // (111, 222). | 427 // (111, 222). |
| 433 // TODO(crbug.com/600039): rect.x() should be 262 (left + border-left), but is | 428 // TODO(crbug.com/600039): rect.x() should be 262 (left + border-left), but is |
| 434 // offset | 429 // offset |
| 435 // by extra horizontal border-widths because of layout error. | 430 // by extra horizontal border-widths because of layout error. |
| 436 EXPECT_EQ(LayoutRect(322, 121, 50, 80), rect); | 431 EXPECT_EQ(LayoutRect(322, 121, 50, 80), rect); |
| 437 checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, | 432 checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| 438 layoutView(), layoutView()); | 433 layoutView(), layoutView()); |
| 439 | 434 |
| 440 LayoutRect containerOverflowRect = | 435 LayoutRect containerVisualRect = container->localVisualRect(); |
| 441 container->localOverflowRectForPaintInvalidation(); | |
| 442 // Because container has overflow clip, its visual overflow doesn't include | 436 // Because container has overflow clip, its visual overflow doesn't include |
| 443 // overflow from children. | 437 // overflow from children. |
| 444 // 110 = width(50) + border_left_width(40) + border_right_width(20) | 438 // 110 = width(50) + border_left_width(40) + border_right_width(20) |
| 445 // 120 = height(80) + border_top_width(10) + border_bottom_width(30) | 439 // 120 = height(80) + border_top_width(10) + border_bottom_width(30) |
| 446 EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerOverflowRect); | 440 EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerVisualRect); |
| 447 | 441 |
| 448 rect = containerOverflowRect; | 442 rect = containerVisualRect; |
| 449 container->flipForWritingMode(rect); | 443 container->flipForWritingMode(rect); |
| 450 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); | 444 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| 451 EXPECT_EQ(LayoutRect(0, 0, 110, 120), rect); | 445 EXPECT_EQ(LayoutRect(0, 0, 110, 120), rect); |
| 452 | 446 |
| 453 rect = containerOverflowRect; | 447 rect = containerVisualRect; |
| 454 container->flipForWritingMode(rect); | 448 container->flipForWritingMode(rect); |
| 455 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 449 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 456 // TODO(crbug.com/600039): rect.x() should be 222 (left), but is offset by | 450 // TODO(crbug.com/600039): rect.x() should be 222 (left), but is offset by |
| 457 // extra horizontal | 451 // extra horizontal |
| 458 // border-widths because of layout error. | 452 // border-widths because of layout error. |
| 459 EXPECT_EQ(LayoutRect(282, 111, 110, 120), rect); | 453 EXPECT_EQ(LayoutRect(282, 111, 110, 120), rect); |
| 460 checkPaintInvalidationStateRectMapping( | 454 checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| 461 rect, containerOverflowRect, *container, layoutView(), layoutView()); | 455 layoutView(), layoutView()); |
| 462 } | 456 } |
| 463 | 457 |
| 464 TEST_F(VisualRectMappingTest, ContainerOverflowHidden) { | 458 TEST_F(VisualRectMappingTest, ContainerOverflowHidden) { |
| 465 setBodyInnerHTML( | 459 setBodyInnerHTML( |
| 466 "<div id='container' style='position: absolute; top: 111px; left: 222px;" | 460 "<div id='container' style='position: absolute; top: 111px; left: 222px;" |
| 467 " border: 10px solid red; overflow: hidden; width: 50px; height: " | 461 " border: 10px solid red; overflow: hidden; width: 50px; height: " |
| 468 "80px;'>" | 462 "80px;'>" |
| 469 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " | 463 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| 470 "height: 90px'></div>" | 464 "height: 90px'></div>" |
| 471 "</div>"); | 465 "</div>"); |
| 472 | 466 |
| 473 LayoutBlock* container = | 467 LayoutBlock* container = |
| 474 toLayoutBlock(getLayoutObjectByElementId("container")); | 468 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 475 EXPECT_EQ(LayoutUnit(), container->scrollTop()); | 469 EXPECT_EQ(LayoutUnit(), container->scrollTop()); |
| 476 EXPECT_EQ(LayoutUnit(), container->scrollLeft()); | 470 EXPECT_EQ(LayoutUnit(), container->scrollLeft()); |
| 477 container->setScrollTop(LayoutUnit(27)); | 471 container->setScrollTop(LayoutUnit(27)); |
| 478 container->setScrollLeft(LayoutUnit(28)); | 472 container->setScrollLeft(LayoutUnit(28)); |
| 479 document().view()->updateAllLifecyclePhases(); | 473 document().view()->updateAllLifecyclePhases(); |
| 480 | 474 |
| 481 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 475 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 482 LayoutRect targetOverflowRect = | 476 LayoutRect targetVisualRect = target->localVisualRect(); |
| 483 target->localOverflowRectForPaintInvalidation(); | |
| 484 // 140 = width(100) + box_shadow_offset_x(40) | 477 // 140 = width(100) + box_shadow_offset_x(40) |
| 485 // 110 = height(90) + box_shadow_offset_y(20) | 478 // 110 = height(90) + box_shadow_offset_y(20) |
| 486 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect); | 479 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| 487 LayoutRect rect = targetOverflowRect; | 480 LayoutRect rect = targetVisualRect; |
| 488 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 481 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 489 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 482 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 490 | 483 |
| 491 rect = targetOverflowRect; | 484 rect = targetVisualRect; |
| 492 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 485 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 493 // Rect is not clipped by container's overflow clip. | 486 // Rect is not clipped by container's overflow clip. |
| 494 EXPECT_EQ(LayoutRect(10, 10, 140, 110), rect); | 487 EXPECT_EQ(LayoutRect(10, 10, 140, 110), rect); |
| 495 } | 488 } |
| 496 | 489 |
| 497 TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) { | 490 TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) { |
| 498 setBodyInnerHTML( | 491 setBodyInnerHTML( |
| 499 "<div id='container' style='writing-mode: vertical-rl; position: " | 492 "<div id='container' style='writing-mode: vertical-rl; position: " |
| 500 "absolute; top: 111px; left: 222px;" | 493 "absolute; top: 111px; left: 222px;" |
| 501 " border: solid red; border-width: 10px 20px 30px 40px;" | 494 " border: solid red; border-width: 10px 20px 30px 40px;" |
| 502 " overflow: hidden; width: 50px; height: 80px'>" | 495 " overflow: hidden; width: 50px; height: 80px'>" |
| 503 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " | 496 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| 504 "height: 90px'></div>" | 497 "height: 90px'></div>" |
| 505 " <div style='width: 100px; height: 100px'></div>" | 498 " <div style='width: 100px; height: 100px'></div>" |
| 506 "</div>"); | 499 "</div>"); |
| 507 | 500 |
| 508 LayoutBlock* container = | 501 LayoutBlock* container = |
| 509 toLayoutBlock(getLayoutObjectByElementId("container")); | 502 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 510 EXPECT_EQ(LayoutUnit(), container->scrollTop()); | 503 EXPECT_EQ(LayoutUnit(), container->scrollTop()); |
| 511 // The initial scroll offset is to the left-most because of flipped blocks | 504 // The initial scroll offset is to the left-most because of flipped blocks |
| 512 // writing mode. | 505 // writing mode. |
| 513 // 150 = total_layout_overflow(100 + 100) - width(50) | 506 // 150 = total_layout_overflow(100 + 100) - width(50) |
| 514 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); | 507 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); |
| 515 container->setScrollTop(LayoutUnit(7)); | 508 container->setScrollTop(LayoutUnit(7)); |
| 516 container->setScrollLeft(LayoutUnit(82)); // Scroll to the right by 8 pixels. | 509 container->setScrollLeft(LayoutUnit(82)); // Scroll to the right by 8 pixels. |
| 517 document().view()->updateAllLifecyclePhases(); | 510 document().view()->updateAllLifecyclePhases(); |
| 518 | 511 |
| 519 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 512 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 520 LayoutRect targetOverflowRect = | 513 LayoutRect targetVisualRect = target->localVisualRect(); |
| 521 target->localOverflowRectForPaintInvalidation(); | |
| 522 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the | 514 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| 523 // origin) | 515 // origin) |
| 524 // 140 = width(100) + box_shadow_offset_x(40) | 516 // 140 = width(100) + box_shadow_offset_x(40) |
| 525 // 110 = height(90) + box_shadow_offset_y(20) | 517 // 110 = height(90) + box_shadow_offset_y(20) |
| 526 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); | 518 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| 527 | 519 |
| 528 LayoutRect rect = targetOverflowRect; | 520 LayoutRect rect = targetVisualRect; |
| 529 target->flipForWritingMode(rect); | 521 target->flipForWritingMode(rect); |
| 530 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 522 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 531 // This rect is in physical coordinates of target. | 523 // This rect is in physical coordinates of target. |
| 532 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 524 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 533 | 525 |
| 534 rect = targetOverflowRect; | 526 rect = targetVisualRect; |
| 535 target->flipForWritingMode(rect); | 527 target->flipForWritingMode(rect); |
| 536 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 528 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 537 // 58 = target_physical_x(100) + container_border_left(40) - scroll_left(58) | 529 // 58 = target_physical_x(100) + container_border_left(40) - scroll_left(58) |
| 538 EXPECT_EQ(LayoutRect(-10, 10, 140, 110), rect); | 530 EXPECT_EQ(LayoutRect(-10, 10, 140, 110), rect); |
| 539 } | 531 } |
| 540 | 532 |
| 541 TEST_F(VisualRectMappingTest, ContainerAndTargetDifferentFlippedWritingMode) { | 533 TEST_F(VisualRectMappingTest, ContainerAndTargetDifferentFlippedWritingMode) { |
| 542 setBodyInnerHTML( | 534 setBodyInnerHTML( |
| 543 "<div id='container' style='writing-mode: vertical-rl; position: " | 535 "<div id='container' style='writing-mode: vertical-rl; position: " |
| 544 "absolute; top: 111px; left: 222px;" | 536 "absolute; top: 111px; left: 222px;" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 555 // The initial scroll offset is to the left-most because of flipped blocks | 547 // The initial scroll offset is to the left-most because of flipped blocks |
| 556 // writing mode. | 548 // writing mode. |
| 557 // 150 = total_layout_overflow(100 + 100) - width(50) | 549 // 150 = total_layout_overflow(100 + 100) - width(50) |
| 558 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); | 550 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); |
| 559 container->setScrollTop(LayoutUnit(7)); | 551 container->setScrollTop(LayoutUnit(7)); |
| 560 container->setScrollLeft( | 552 container->setScrollLeft( |
| 561 LayoutUnit(142)); // Scroll to the right by 8 pixels. | 553 LayoutUnit(142)); // Scroll to the right by 8 pixels. |
| 562 document().view()->updateAllLifecyclePhases(); | 554 document().view()->updateAllLifecyclePhases(); |
| 563 | 555 |
| 564 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | 556 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| 565 LayoutRect targetOverflowRect = | 557 LayoutRect targetVisualRect = target->localVisualRect(); |
| 566 target->localOverflowRectForPaintInvalidation(); | |
| 567 // 140 = width(100) + box_shadow_offset_x(40) | 558 // 140 = width(100) + box_shadow_offset_x(40) |
| 568 // 110 = height(90) + box_shadow_offset_y(20) | 559 // 110 = height(90) + box_shadow_offset_y(20) |
| 569 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect); | 560 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| 570 | 561 |
| 571 LayoutRect rect = targetOverflowRect; | 562 LayoutRect rect = targetVisualRect; |
| 572 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | 563 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| 573 // This rect is in physical coordinates of target. | 564 // This rect is in physical coordinates of target. |
| 574 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | 565 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| 575 | 566 |
| 576 rect = targetOverflowRect; | 567 rect = targetVisualRect; |
| 577 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 568 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 578 rect.move(-container->scrolledContentOffset()); | 569 rect.move(-container->scrolledContentOffset()); |
| 579 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) | 570 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) |
| 580 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) | 571 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) |
| 581 // Rect is not clipped by container's overflow clip. | 572 // Rect is not clipped by container's overflow clip. |
| 582 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); | 573 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); |
| 583 } | 574 } |
| 584 | 575 |
| 585 TEST_F(VisualRectMappingTest, | 576 TEST_F(VisualRectMappingTest, |
| 586 DifferentPaintInvalidaitionContainerForAbsolutePosition) { | 577 DifferentPaintInvalidaitionContainerForAbsolutePosition) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 601 | 592 |
| 602 LayoutBlock* scroller = toLayoutBlock(getLayoutObjectByElementId("scroller")); | 593 LayoutBlock* scroller = toLayoutBlock(getLayoutObjectByElementId("scroller")); |
| 603 scroller->setScrollTop(LayoutUnit(77)); | 594 scroller->setScrollTop(LayoutUnit(77)); |
| 604 scroller->setScrollLeft(LayoutUnit(88)); | 595 scroller->setScrollLeft(LayoutUnit(88)); |
| 605 document().view()->updateAllLifecyclePhases(); | 596 document().view()->updateAllLifecyclePhases(); |
| 606 | 597 |
| 607 LayoutBlock* normalFlow = | 598 LayoutBlock* normalFlow = |
| 608 toLayoutBlock(getLayoutObjectByElementId("normal-flow")); | 599 toLayoutBlock(getLayoutObjectByElementId("normal-flow")); |
| 609 EXPECT_EQ(scroller, &normalFlow->containerForPaintInvalidation()); | 600 EXPECT_EQ(scroller, &normalFlow->containerForPaintInvalidation()); |
| 610 | 601 |
| 611 LayoutRect normalFlowOverflowRect = | 602 LayoutRect normalFlowVisualRect = normalFlow->localVisualRect(); |
| 612 normalFlow->localOverflowRectForPaintInvalidation(); | 603 EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), normalFlowVisualRect); |
| 613 EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), normalFlowOverflowRect); | 604 LayoutRect rect = normalFlowVisualRect; |
| 614 LayoutRect rect = normalFlowOverflowRect; | |
| 615 EXPECT_TRUE(normalFlow->mapToVisualRectInAncestorSpace(scroller, rect)); | 605 EXPECT_TRUE(normalFlow->mapToVisualRectInAncestorSpace(scroller, rect)); |
| 616 EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect); | 606 EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect); |
| 617 checkPaintInvalidationStateRectMapping(rect, normalFlowOverflowRect, | 607 checkPaintInvalidationStateRectMapping(rect, normalFlowVisualRect, |
| 618 *normalFlow, layoutView(), *scroller); | 608 *normalFlow, layoutView(), *scroller); |
| 619 | 609 |
| 620 LayoutBlock* stackingContext = | 610 LayoutBlock* stackingContext = |
| 621 toLayoutBlock(getLayoutObjectByElementId("stacking-context")); | 611 toLayoutBlock(getLayoutObjectByElementId("stacking-context")); |
| 622 LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute")); | 612 LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute")); |
| 623 EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation()); | 613 EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation()); |
| 624 EXPECT_EQ(stackingContext, absolute->container()); | 614 EXPECT_EQ(stackingContext, absolute->container()); |
| 625 | 615 |
| 626 LayoutRect absoluteOverflowRect = | 616 LayoutRect absoluteVisualRect = absolute->localVisualRect(); |
| 627 absolute->localOverflowRectForPaintInvalidation(); | 617 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteVisualRect); |
| 628 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); | 618 rect = absoluteVisualRect; |
| 629 rect = absoluteOverflowRect; | |
| 630 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); | 619 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); |
| 631 EXPECT_EQ(LayoutRect(222, 111, 50, 50), rect); | 620 EXPECT_EQ(LayoutRect(222, 111, 50, 50), rect); |
| 632 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute, | 621 checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute, |
| 633 layoutView(), *stackingContext); | 622 layoutView(), *stackingContext); |
| 634 } | 623 } |
| 635 | 624 |
| 636 TEST_F(VisualRectMappingTest, | 625 TEST_F(VisualRectMappingTest, |
| 637 ContainerOfAbsoluteAbovePaintInvalidationContainer) { | 626 ContainerOfAbsoluteAbovePaintInvalidationContainer) { |
| 638 enableCompositing(); | 627 enableCompositing(); |
| 639 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 628 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 640 | 629 |
| 641 setBodyInnerHTML( | 630 setBodyInnerHTML( |
| 642 "<div id='container' style='position: absolute; top: 88px; left: 99px'>" | 631 "<div id='container' style='position: absolute; top: 88px; left: 99px'>" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 653 "</div>"); | 642 "</div>"); |
| 654 | 643 |
| 655 LayoutBlock* stackingContext = | 644 LayoutBlock* stackingContext = |
| 656 toLayoutBlock(getLayoutObjectByElementId("stacking-context")); | 645 toLayoutBlock(getLayoutObjectByElementId("stacking-context")); |
| 657 LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute")); | 646 LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute")); |
| 658 LayoutBlock* container = | 647 LayoutBlock* container = |
| 659 toLayoutBlock(getLayoutObjectByElementId("container")); | 648 toLayoutBlock(getLayoutObjectByElementId("container")); |
| 660 EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation()); | 649 EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation()); |
| 661 EXPECT_EQ(container, absolute->container()); | 650 EXPECT_EQ(container, absolute->container()); |
| 662 | 651 |
| 663 LayoutRect absoluteOverflowRect = | 652 LayoutRect absoluteVisualRect = absolute->localVisualRect(); |
| 664 absolute->localOverflowRectForPaintInvalidation(); | 653 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteVisualRect); |
| 665 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); | 654 LayoutRect rect = absoluteVisualRect; |
| 666 LayoutRect rect = absoluteOverflowRect; | |
| 667 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); | 655 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); |
| 668 // -172 = top(50) - y_offset_of_stacking_context(222) | 656 // -172 = top(50) - y_offset_of_stacking_context(222) |
| 669 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); | 657 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); |
| 670 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute, | 658 checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute, |
| 671 layoutView(), *stackingContext); | 659 layoutView(), *stackingContext); |
| 672 } | 660 } |
| 673 | 661 |
| 674 TEST_F(VisualRectMappingTest, CSSClip) { | 662 TEST_F(VisualRectMappingTest, CSSClip) { |
| 675 setBodyInnerHTML( | 663 setBodyInnerHTML( |
| 676 "<div id='container' style='position: absolute; top: 0px; left: 0px; " | 664 "<div id='container' style='position: absolute; top: 0px; left: 0px; " |
| 677 "clip: rect(0px, 200px, 200px, 0px)'>" | 665 "clip: rect(0px, 200px, 200px, 0px)'>" |
| 678 " <div id='target' style='width: 400px; height: 400px'></div>" | 666 " <div id='target' style='width: 400px; height: 400px'></div>" |
| 679 " </div>" | 667 " </div>" |
| 680 "</div>"); | 668 "</div>"); |
| 681 | 669 |
| 682 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); | 670 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| 683 | 671 |
| 684 LayoutRect targetOverflowRect = | 672 LayoutRect targetVisualRect = target->localVisualRect(); |
| 685 target->localOverflowRectForPaintInvalidation(); | 673 EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetVisualRect); |
| 686 EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetOverflowRect); | 674 LayoutRect rect = targetVisualRect; |
| 687 LayoutRect rect = targetOverflowRect; | |
| 688 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 675 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 689 EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); | 676 EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); |
| 690 checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, | 677 checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| 691 layoutView(), layoutView()); | 678 layoutView(), layoutView()); |
| 692 } | 679 } |
| 693 | 680 |
| 694 TEST_F(VisualRectMappingTest, ContainPaint) { | 681 TEST_F(VisualRectMappingTest, ContainPaint) { |
| 695 setBodyInnerHTML( | 682 setBodyInnerHTML( |
| 696 "<div id='container' style='position: absolute; top: 0px; left: 0px; " | 683 "<div id='container' style='position: absolute; top: 0px; left: 0px; " |
| 697 "width: 200px; height: 200px; contain: paint'>" | 684 "width: 200px; height: 200px; contain: paint'>" |
| 698 " <div id='target' style='width: 400px; height: 400px'></div>" | 685 " <div id='target' style='width: 400px; height: 400px'></div>" |
| 699 " </div>" | 686 " </div>" |
| 700 "</div>"); | 687 "</div>"); |
| 701 | 688 |
| 702 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); | 689 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| 703 | 690 |
| 704 LayoutRect targetOverflowRect = | 691 LayoutRect targetVisualRect = target->localVisualRect(); |
| 705 target->localOverflowRectForPaintInvalidation(); | 692 EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetVisualRect); |
| 706 EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetOverflowRect); | 693 LayoutRect rect = targetVisualRect; |
| 707 LayoutRect rect = targetOverflowRect; | |
| 708 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 694 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 709 EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); | 695 EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); |
| 710 checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, | 696 checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| 711 layoutView(), layoutView()); | 697 layoutView(), layoutView()); |
| 712 } | 698 } |
| 713 | 699 |
| 714 } // namespace blink | 700 } // namespace blink |
| OLD | NEW |