Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2332273003: Use updated interest rect when layer needs repainting. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compositing/CompositedLayerMapping.h" 5 #include "core/layout/compositing/CompositedLayerMapping.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/LayoutBoxModelObject.h" 8 #include "core/layout/LayoutBoxModelObject.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "core/layout/api/LayoutViewItem.h" 10 #include "core/layout/api/LayoutViewItem.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), recomputeInterestRect(rootScroll ingLayer)); 414 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), recomputeInterestRect(rootScroll ingLayer));
415 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli ngLayer)); 415 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli ngLayer));
416 416
417 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll); 417 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll);
418 // Use recomputed interest rect because it changed enough. 418 // Use recomputed interest rect because it changed enough.
419 document().view()->updateAllLifecyclePhases(); 419 document().view()->updateAllLifecyclePhases();
420 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), recomputeInterestRect(rootScrolling Layer)); 420 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), recomputeInterestRect(rootScrolling Layer));
421 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), previousInterestRect(rootScrollingL ayer)); 421 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), previousInterestRect(rootScrollingL ayer));
422 } 422 }
423 423
424 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnShrunkenViewport)
425 {
426 setBodyInnerHTML(
427 "<style>"
428 " ::-webkit-scrollbar { width: 0; height: 0; }"
429 " body { margin: 0; }"
430 "</style>"
431 "<div id='div' style='width: 100px; height: 10000px'>Text</div>");
432
433 document().view()->updateAllLifecyclePhases();
434 GraphicsLayer* rootScrollingLayer = document().layoutViewItem().layer()->gra phicsLayerBackingForScrolling();
435 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), previousInterestRect(rootScrollingL ayer));
436
437 document().view()->setFrameRect(IntRect(0, 0, 800, 60));
438 document().view()->updateAllLifecyclePhases();
439 // Repaint required, so interest rect should be updated to shrunken size.
440 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4060), recomputeInterestRect(rootScrolling Layer));
441 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4060), previousInterestRect(rootScrollingL ayer));
442 }
443
424 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnScroll) 444 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnScroll)
425 { 445 {
426 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 446 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
427 447
428 setBodyInnerHTML( 448 setBodyInnerHTML(
429 "<style>" 449 "<style>"
430 " ::-webkit-scrollbar { width: 0; height: 0; }" 450 " ::-webkit-scrollbar { width: 0; height: 0; }"
431 " body { margin: 0; }" 451 " body { margin: 0; }"
432 "</style>" 452 "</style>"
433 "<div id='scroller' style='width: 400px; height: 400px; overflow: scroll '>" 453 "<div id='scroller' style='width: 400px; height: 400px; overflow: scroll '>"
(...skipping 28 matching lines...) Expand all
462 EXPECT_RECT_EQ(IntRect(0, 5000, 400, 5000), recomputeInterestRect(scrollingL ayer)); 482 EXPECT_RECT_EQ(IntRect(0, 5000, 400, 5000), recomputeInterestRect(scrollingL ayer));
463 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), previousInterestRect(scrollingLa yer)); 483 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), previousInterestRect(scrollingLa yer));
464 484
465 scroller->setScrollTop(2000); 485 scroller->setScrollTop(2000);
466 // Use recomputed interest rect because it changed enough. 486 // Use recomputed interest rect because it changed enough.
467 document().view()->updateAllLifecyclePhases(); 487 document().view()->updateAllLifecyclePhases();
468 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600), recomputeInterestRect(scrollingLaye r)); 488 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600), recomputeInterestRect(scrollingLaye r));
469 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600), previousInterestRect(scrollingLayer )); 489 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600), previousInterestRect(scrollingLayer ));
470 } 490 }
471 491
472 TEST_F(CompositedLayerMappingTest, InterestRectShouldNotChangeOnPaintInvalidatio n) 492 TEST_F(CompositedLayerMappingTest, InterestRectShouldChangeOnPaintInvalidation)
473 { 493 {
474 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 494 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
475 495
476 setBodyInnerHTML( 496 setBodyInnerHTML(
477 "<style>" 497 "<style>"
478 " ::-webkit-scrollbar { width: 0; height: 0; }" 498 " ::-webkit-scrollbar { width: 0; height: 0; }"
479 " body { margin: 0; }" 499 " body { margin: 0; }"
480 "</style>" 500 "</style>"
481 "<div id='scroller' style='width: 400px; height: 400px; overflow: scroll '>" 501 "<div id='scroller' style='width: 400px; height: 400px; overflow: scroll '>"
482 " <div id='content' style='width: 100px; height: 10000px'>Text</div>" 502 " <div id='content' style='width: 100px; height: 10000px'>Text</div>"
483 "</div"); 503 "</div");
484 504
485 document().view()->updateAllLifecyclePhases(); 505 document().view()->updateAllLifecyclePhases();
486 Element* scroller = document().getElementById("scroller"); 506 Element* scroller = document().getElementById("scroller");
487 GraphicsLayer* scrollingLayer = scroller->layoutBox()->layer()->graphicsLaye rBackingForScrolling(); 507 GraphicsLayer* scrollingLayer = scroller->layoutBox()->layer()->graphicsLaye rBackingForScrolling();
488 508
489 scroller->setScrollTop(5400); 509 scroller->setScrollTop(5400);
490 document().view()->updateAllLifecyclePhases(); 510 document().view()->updateAllLifecyclePhases();
491 scroller->setScrollTop(9400); 511 scroller->setScrollTop(9400);
492 // The above code creates an interest rect bigger than the interest rect if recomputed now. 512 // The above code creates an interest rect bigger than the interest rect if recomputed now.
493 document().view()->updateAllLifecyclePhases(); 513 document().view()->updateAllLifecyclePhases();
494 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), recomputeInterestRect(scrollingL ayer)); 514 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), recomputeInterestRect(scrollingL ayer));
495 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), previousInterestRect(scrollingLa yer)); 515 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), previousInterestRect(scrollingLa yer));
496 516
497 // Paint invalidation and repaint should not change previous paint interest rect. 517 // Paint invalidation and repaint should change previous paint interest rect .
498 document().getElementById("content")->setTextContent("Change"); 518 document().getElementById("content")->setTextContent("Change");
499 document().view()->updateAllLifecyclePhases(); 519 document().view()->updateAllLifecyclePhases();
500 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), recomputeInterestRect(scrollingL ayer)); 520 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), recomputeInterestRect(scrollingL ayer));
501 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), previousInterestRect(scrollingLa yer)); 521 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), previousInterestRect(scrollingLa yer));
502 } 522 }
503 523
504 TEST_F(CompositedLayerMappingTest, InterestRectOfSquashingLayerWithNegativeOverf low) 524 TEST_F(CompositedLayerMappingTest, InterestRectOfSquashingLayerWithNegativeOverf low)
505 { 525 {
506 setBodyInnerHTML( 526 setBodyInnerHTML(
507 "<style>body { margin: 0; font-size: 16px; }</style>" 527 "<style>body { margin: 0; font-size: 16px; }</style>"
508 "<div style='position: absolute; top: -500px; width: 200px; height: 700p x; will-change: transform'></div>" 528 "<div style='position: absolute; top: -500px; width: 200px; height: 700p x; will-change: transform'></div>"
509 "<div id='squashed' style='position: absolute; top: 190px;'>" 529 "<div id='squashed' style='position: absolute; top: 190px;'>"
510 " <div id='inside' style='width: 100px; height: 100px; text-indent: -10 000px'>text</div>" 530 " <div id='inside' style='width: 100px; height: 100px; text-indent: -10 000px'>text</div>"
511 "</div>"); 531 "</div>");
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild); 640 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild);
621 document().view()->updateAllLifecyclePhases(); 641 document().view()->updateAllLifecyclePhases();
622 642
623 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c ompositedLayerMapping(); 643 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c ompositedLayerMapping();
624 ASSERT_TRUE(mapping->scrollingContentsLayer()); 644 ASSERT_TRUE(mapping->scrollingContentsLayer());
625 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m apping->scrollingContentsLayer()->paintingPhase()); 645 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m apping->scrollingContentsLayer()->paintingPhase());
626 EXPECT_FALSE(mapping->foregroundLayer()); 646 EXPECT_FALSE(mapping->foregroundLayer());
627 } 647 }
628 648
629 } // namespace blink 649 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698