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/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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 paintLayer->graphicsLayerBacking(), IntRect())); | 119 paintLayer->graphicsLayerBacking(), IntRect())); |
120 } | 120 } |
121 | 121 |
122 TEST_F(CompositedLayerMappingTest, VerticalRightLeftWritingModeDocument) { | 122 TEST_F(CompositedLayerMappingTest, VerticalRightLeftWritingModeDocument) { |
123 setBodyInnerHTML( | 123 setBodyInnerHTML( |
124 "<style>html,body { margin: 0px } html { -webkit-writing-mode: " | 124 "<style>html,body { margin: 0px } html { -webkit-writing-mode: " |
125 "vertical-rl}</style> <div id='target' style='width: 10000px; height: " | 125 "vertical-rl}</style> <div id='target' style='width: 10000px; height: " |
126 "200px;'></div>"); | 126 "200px;'></div>"); |
127 | 127 |
128 document().view()->updateAllLifecyclePhases(); | 128 document().view()->updateAllLifecyclePhases(); |
129 document().view()->setScrollPosition(DoublePoint(-5000, 0), | 129 document().view()->setScrollOffset(ScrollOffset(-5000, 0), |
130 ProgrammaticScroll); | 130 ProgrammaticScroll); |
131 document().view()->updateAllLifecyclePhases(); | 131 document().view()->updateAllLifecyclePhases(); |
132 | 132 |
133 PaintLayer* paintLayer = document().layoutViewItem().layer(); | 133 PaintLayer* paintLayer = document().layoutViewItem().layer(); |
134 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); | 134 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); |
135 ASSERT_TRUE(paintLayer->compositedLayerMapping()); | 135 ASSERT_TRUE(paintLayer->compositedLayerMapping()); |
136 // A scroll by -5000px is equivalent to a scroll by (10000 - 5000 - 800)px = | 136 // A scroll by -5000px is equivalent to a scroll by (10000 - 5000 - 800)px = |
137 // 4200px in non-RTL mode. Expanding the resulting rect by 4000px in each | 137 // 4200px in non-RTL mode. Expanding the resulting rect by 4000px in each |
138 // direction yields this result. | 138 // direction yields this result. |
139 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600), | 139 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600), |
140 recomputeInterestRect(paintLayer->graphicsLayerBacking())); | 140 recomputeInterestRect(paintLayer->graphicsLayerBacking())); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 " body { margin: 0; }" | 455 " body { margin: 0; }" |
456 "</style>" | 456 "</style>" |
457 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); | 457 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); |
458 | 458 |
459 document().view()->updateAllLifecyclePhases(); | 459 document().view()->updateAllLifecyclePhases(); |
460 GraphicsLayer* rootScrollingLayer = | 460 GraphicsLayer* rootScrollingLayer = |
461 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling(); | 461 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling(); |
462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), | 462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), |
463 previousInterestRect(rootScrollingLayer)); | 463 previousInterestRect(rootScrollingLayer)); |
464 | 464 |
465 document().view()->setScrollPosition(IntPoint(0, 300), ProgrammaticScroll); | 465 document().view()->setScrollOffset(ScrollOffset(0, 300), ProgrammaticScroll); |
466 document().view()->updateAllLifecyclePhases(); | 466 document().view()->updateAllLifecyclePhases(); |
467 // Still use the previous interest rect because the recomputed rect hasn't | 467 // Still use the previous interest rect because the recomputed rect hasn't |
468 // changed enough. | 468 // changed enough. |
469 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900), | 469 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900), |
470 recomputeInterestRect(rootScrollingLayer)); | 470 recomputeInterestRect(rootScrollingLayer)); |
471 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), | 471 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), |
472 previousInterestRect(rootScrollingLayer)); | 472 previousInterestRect(rootScrollingLayer)); |
473 | 473 |
474 document().view()->setScrollPosition(IntPoint(0, 600), ProgrammaticScroll); | 474 document().view()->setScrollOffset(ScrollOffset(0, 600), ProgrammaticScroll); |
475 document().view()->updateAllLifecyclePhases(); | 475 document().view()->updateAllLifecyclePhases(); |
476 // Use recomputed interest rect because it changed enough. | 476 // Use recomputed interest rect because it changed enough. |
477 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), | 477 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), |
478 recomputeInterestRect(rootScrollingLayer)); | 478 recomputeInterestRect(rootScrollingLayer)); |
479 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), | 479 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), |
480 previousInterestRect(rootScrollingLayer)); | 480 previousInterestRect(rootScrollingLayer)); |
481 | 481 |
482 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll); | 482 document().view()->setScrollOffset(ScrollOffset(0, 5400), ProgrammaticScroll); |
483 document().view()->updateAllLifecyclePhases(); | 483 document().view()->updateAllLifecyclePhases(); |
484 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), | 484 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), |
485 recomputeInterestRect(rootScrollingLayer)); | 485 recomputeInterestRect(rootScrollingLayer)); |
486 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), | 486 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), |
487 previousInterestRect(rootScrollingLayer)); | 487 previousInterestRect(rootScrollingLayer)); |
488 | 488 |
489 document().view()->setScrollPosition(IntPoint(0, 9000), ProgrammaticScroll); | 489 document().view()->setScrollOffset(ScrollOffset(0, 9000), ProgrammaticScroll); |
490 document().view()->updateAllLifecyclePhases(); | 490 document().view()->updateAllLifecyclePhases(); |
491 // Still use the previous interest rect because it contains the recomputed | 491 // Still use the previous interest rect because it contains the recomputed |
492 // interest rect. | 492 // interest rect. |
493 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), | 493 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), |
494 recomputeInterestRect(rootScrollingLayer)); | 494 recomputeInterestRect(rootScrollingLayer)); |
495 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), | 495 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), |
496 previousInterestRect(rootScrollingLayer)); | 496 previousInterestRect(rootScrollingLayer)); |
497 | 497 |
498 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll); | 498 document().view()->setScrollOffset(ScrollOffset(0, 2000), ProgrammaticScroll); |
499 // Use recomputed interest rect because it changed enough. | 499 // Use recomputed interest rect because it changed enough. |
500 document().view()->updateAllLifecyclePhases(); | 500 document().view()->updateAllLifecyclePhases(); |
501 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), | 501 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), |
502 recomputeInterestRect(rootScrollingLayer)); | 502 recomputeInterestRect(rootScrollingLayer)); |
503 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), | 503 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), |
504 previousInterestRect(rootScrollingLayer)); | 504 previousInterestRect(rootScrollingLayer)); |
505 } | 505 } |
506 | 506 |
507 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnShrunkenViewport) { | 507 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnShrunkenViewport) { |
508 setBodyInnerHTML( | 508 setBodyInnerHTML( |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 "<iframe id=frame src='http://test.com' width='500' height='500' " | 695 "<iframe id=frame src='http://test.com' width='500' height='500' " |
696 "frameBorder='0'>" | 696 "frameBorder='0'>" |
697 "</iframe>"); | 697 "</iframe>"); |
698 | 698 |
699 Document& frameDocument = setupChildIframe( | 699 Document& frameDocument = setupChildIframe( |
700 "frame", | 700 "frame", |
701 "<style>body { margin: 0; } #target { width: 200px; height: 200px; " | 701 "<style>body { margin: 0; } #target { width: 200px; height: 200px; " |
702 "will-change: transform}</style><div id=target></div>"); | 702 "will-change: transform}</style><div id=target></div>"); |
703 | 703 |
704 // Scroll 8000 pixels down to move the iframe into view. | 704 // Scroll 8000 pixels down to move the iframe into view. |
705 document().view()->setScrollPosition(DoublePoint(0.0, 8000.0), | 705 document().view()->setScrollOffset(ScrollOffset(0.0, 8000.0), |
706 ProgrammaticScroll); | 706 ProgrammaticScroll); |
707 document().view()->updateAllLifecyclePhases(); | 707 document().view()->updateAllLifecyclePhases(); |
708 | 708 |
709 Element* target = frameDocument.getElementById("target"); | 709 Element* target = frameDocument.getElementById("target"); |
710 ASSERT_TRUE(target); | 710 ASSERT_TRUE(target); |
711 | 711 |
712 EXPECT_RECT_EQ( | 712 EXPECT_RECT_EQ( |
713 IntRect(0, 0, 200, 200), | 713 IntRect(0, 0, 200, 200), |
714 recomputeInterestRect( | 714 recomputeInterestRect( |
715 target->layoutObject()->enclosingLayer()->graphicsLayerBacking())); | 715 target->layoutObject()->enclosingLayer()->graphicsLayerBacking())); |
716 } | 716 } |
717 | 717 |
718 TEST_F(CompositedLayerMappingTest, InterestRectOfScrolledIframe) { | 718 TEST_F(CompositedLayerMappingTest, InterestRectOfScrolledIframe) { |
719 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 719 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
720 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 720 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
721 setBodyInnerHTML( | 721 setBodyInnerHTML( |
722 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; " | 722 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; " |
723 "}</style>" | 723 "}</style>" |
724 "<iframe id=frame src='http://test.com' width='500' height='500' " | 724 "<iframe id=frame src='http://test.com' width='500' height='500' " |
725 "frameBorder='0'>" | 725 "frameBorder='0'>" |
726 "</iframe>"); | 726 "</iframe>"); |
727 | 727 |
728 Document& frameDocument = | 728 Document& frameDocument = |
729 setupChildIframe("frame", | 729 setupChildIframe("frame", |
730 "<style>body { margin: 0; } #target { width: 200px; " | 730 "<style>body { margin: 0; } #target { width: 200px; " |
731 "height: 8000px;}</style><div id=target></div>"); | 731 "height: 8000px;}</style><div id=target></div>"); |
732 | 732 |
733 document().view()->updateAllLifecyclePhases(); | 733 document().view()->updateAllLifecyclePhases(); |
734 | 734 |
735 // Scroll 7500 pixels down to bring the scrollable area to the bottom. | 735 // Scroll 7500 pixels down to bring the scrollable area to the bottom. |
736 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 7500.0), | 736 frameDocument.view()->setScrollOffset(ScrollOffset(0.0, 7500.0), |
737 ProgrammaticScroll); | 737 ProgrammaticScroll); |
738 document().view()->updateAllLifecyclePhases(); | 738 document().view()->updateAllLifecyclePhases(); |
739 | 739 |
740 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); | 740 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); |
741 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500), | 741 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500), |
742 recomputeInterestRect(frameDocument.view() | 742 recomputeInterestRect(frameDocument.view() |
743 ->layoutViewItem() | 743 ->layoutViewItem() |
744 .enclosingLayer() | 744 .enclosingLayer() |
745 ->graphicsLayerBacking())); | 745 ->graphicsLayerBacking())); |
746 } | 746 } |
747 | 747 |
(...skipping 11 matching lines...) Expand all Loading... |
759 | 759 |
760 Document& frameDocument = | 760 Document& frameDocument = |
761 setupChildIframe("frame", | 761 setupChildIframe("frame", |
762 "<style>body { margin: 0; } #target { width: 200px; " | 762 "<style>body { margin: 0; } #target { width: 200px; " |
763 "height: 8000px;}</style> <div id=target></div>"); | 763 "height: 8000px;}</style> <div id=target></div>"); |
764 | 764 |
765 document().view()->updateAllLifecyclePhases(); | 765 document().view()->updateAllLifecyclePhases(); |
766 | 766 |
767 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the | 767 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the |
768 // middle. | 768 // middle. |
769 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), | 769 frameDocument.view()->setScrollOffset(ScrollOffset(0.0, 3000.0), |
770 ProgrammaticScroll); | 770 ProgrammaticScroll); |
771 document().view()->updateAllLifecyclePhases(); | 771 document().view()->updateAllLifecyclePhases(); |
772 | 772 |
773 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); | 773 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); |
774 // The width is 485 pixels due to the size of the scrollbar. | 774 // The width is 485 pixels due to the size of the scrollbar. |
775 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), | 775 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), |
776 recomputeInterestRect(frameDocument.view() | 776 recomputeInterestRect(frameDocument.view() |
777 ->layoutViewItem() | 777 ->layoutViewItem() |
778 .enclosingLayer() | 778 .enclosingLayer() |
779 ->graphicsLayerBacking())); | 779 ->graphicsLayerBacking())); |
780 } | 780 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 document().view()->updateAllLifecyclePhases(); | 1030 document().view()->updateAllLifecyclePhases(); |
1031 ASSERT_EQ(document().documentElement(), | 1031 ASSERT_EQ(document().documentElement(), |
1032 rootScrollerController.globalRootScroller()); | 1032 rootScrollerController.globalRootScroller()); |
1033 | 1033 |
1034 EXPECT_TRUE(mapping3->clippingLayer()); | 1034 EXPECT_TRUE(mapping3->clippingLayer()); |
1035 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); | 1035 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); |
1036 } | 1036 } |
1037 } | 1037 } |
1038 | 1038 |
1039 } // namespace blink | 1039 } // namespace blink |
OLD | NEW |