| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 ->layer() | 691 ->layer() |
| 692 ->groupedMapping(); | 692 ->groupedMapping(); |
| 693 // The squashing layer is at (-9600, 0, 10000, 1000) in viewport coordinates. | 693 // The squashing layer is at (-9600, 0, 10000, 1000) in viewport coordinates. |
| 694 // The following rect is at (-4000, 0, 4400, 1000) in viewport coordinates. | 694 // The following rect is at (-4000, 0, 4400, 1000) in viewport coordinates. |
| 695 EXPECT_RECT_EQ(IntRect(5600, 0, 4400, 1000), | 695 EXPECT_RECT_EQ(IntRect(5600, 0, 4400, 1000), |
| 696 groupedMapping->computeInterestRect( | 696 groupedMapping->computeInterestRect( |
| 697 groupedMapping->squashingLayer(), IntRect())); | 697 groupedMapping->squashingLayer(), IntRect())); |
| 698 } | 698 } |
| 699 | 699 |
| 700 TEST_P(CompositedLayerMappingTest, InterestRectOfIframeInScrolledDiv) { | 700 TEST_P(CompositedLayerMappingTest, InterestRectOfIframeInScrolledDiv) { |
| 701 setChildFrameHTML( |
| 702 "<style>body { margin: 0; } #target { width: 200px; height: 200px; " |
| 703 "will-change: transform}</style><div id=target></div>"); |
| 704 |
| 701 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 705 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
| 702 setBodyInnerHTML( | 706 setBodyInnerHTML( |
| 703 "<style>body { margin: 0; }</style>" | 707 "<style>body { margin: 0; }</style>" |
| 704 "<div style='width: 200; height: 8000px'></div>" | 708 "<div style='width: 200; height: 8000px'></div>" |
| 705 "<iframe id=frame src='http://test.com' width='500' height='500' " | 709 "<iframe src='http://test.com' width='500' height='500' " |
| 706 "frameBorder='0'>" | 710 "frameBorder='0'>" |
| 707 "</iframe>"); | 711 "</iframe>"); |
| 708 | 712 |
| 709 Document& frameDocument = setupChildIframe( | |
| 710 "frame", | |
| 711 "<style>body { margin: 0; } #target { width: 200px; height: 200px; " | |
| 712 "will-change: transform}</style><div id=target></div>"); | |
| 713 | |
| 714 // Scroll 8000 pixels down to move the iframe into view. | 713 // Scroll 8000 pixels down to move the iframe into view. |
| 715 document().view()->layoutViewportScrollableArea()->setScrollOffset( | 714 document().view()->layoutViewportScrollableArea()->setScrollOffset( |
| 716 ScrollOffset(0.0, 8000.0), ProgrammaticScroll); | 715 ScrollOffset(0.0, 8000.0), ProgrammaticScroll); |
| 717 document().view()->updateAllLifecyclePhases(); | 716 document().view()->updateAllLifecyclePhases(); |
| 718 | 717 |
| 719 Element* target = frameDocument.getElementById("target"); | 718 Element* target = childDocument().getElementById("target"); |
| 720 ASSERT_TRUE(target); | 719 ASSERT_TRUE(target); |
| 721 | 720 |
| 722 EXPECT_RECT_EQ( | 721 EXPECT_RECT_EQ( |
| 723 IntRect(0, 0, 200, 200), | 722 IntRect(0, 0, 200, 200), |
| 724 recomputeInterestRect( | 723 recomputeInterestRect( |
| 725 target->layoutObject()->enclosingLayer()->graphicsLayerBacking())); | 724 target->layoutObject()->enclosingLayer()->graphicsLayerBacking())); |
| 726 } | 725 } |
| 727 | 726 |
| 728 TEST_P(CompositedLayerMappingTest, InterestRectOfScrolledIframe) { | 727 TEST_P(CompositedLayerMappingTest, InterestRectOfScrolledIframe) { |
| 728 setChildFrameHTML( |
| 729 "<style>body { margin: 0; } #target { width: 200px; " |
| 730 "height: 8000px;}</style><div id=target></div>"); |
| 731 |
| 729 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 732 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
| 730 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 733 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 731 setBodyInnerHTML( | 734 setBodyInnerHTML( |
| 732 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; " | 735 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; " |
| 733 "}</style>" | 736 "}</style>" |
| 734 "<iframe id=frame src='http://test.com' width='500' height='500' " | 737 "<iframe src='http://test.com' width='500' height='500' " |
| 735 "frameBorder='0'>" | 738 "frameBorder='0'>" |
| 736 "</iframe>"); | 739 "</iframe>"); |
| 737 | 740 |
| 738 Document& frameDocument = | |
| 739 setupChildIframe("frame", | |
| 740 "<style>body { margin: 0; } #target { width: 200px; " | |
| 741 "height: 8000px;}</style><div id=target></div>"); | |
| 742 | |
| 743 document().view()->updateAllLifecyclePhases(); | 741 document().view()->updateAllLifecyclePhases(); |
| 744 | 742 |
| 745 // Scroll 7500 pixels down to bring the scrollable area to the bottom. | 743 // Scroll 7500 pixels down to bring the scrollable area to the bottom. |
| 746 frameDocument.view()->layoutViewportScrollableArea()->setScrollOffset( | 744 childDocument().view()->layoutViewportScrollableArea()->setScrollOffset( |
| 747 ScrollOffset(0.0, 7500.0), ProgrammaticScroll); | 745 ScrollOffset(0.0, 7500.0), ProgrammaticScroll); |
| 748 document().view()->updateAllLifecyclePhases(); | 746 document().view()->updateAllLifecyclePhases(); |
| 749 | 747 |
| 750 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); | 748 ASSERT_TRUE(childDocument().view()->layoutViewItem().hasLayer()); |
| 751 EXPECT_RECT_EQ( | 749 EXPECT_RECT_EQ( |
| 752 IntRect(0, 3500, 500, 4500), | 750 IntRect(0, 3500, 500, 4500), |
| 753 recomputeInterestRect(frameDocument.view() | 751 recomputeInterestRect(childDocument() |
| 752 .view() |
| 754 ->layoutViewItem() | 753 ->layoutViewItem() |
| 755 .enclosingLayer() | 754 .enclosingLayer() |
| 756 ->graphicsLayerBackingForScrolling())); | 755 ->graphicsLayerBackingForScrolling())); |
| 757 } | 756 } |
| 758 | 757 |
| 759 TEST_P(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) { | 758 TEST_P(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) { |
| 759 setChildFrameHTML( |
| 760 "<style>body { margin: 0; } #target { width: 200px; " |
| 761 "height: 8000px;}</style> <div id=target></div>"); |
| 762 |
| 760 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 763 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
| 761 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 764 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 762 // Set a 10px border in order to have a contentBoxOffset for the iframe | 765 // Set a 10px border in order to have a contentBoxOffset for the iframe |
| 763 // element. | 766 // element. |
| 764 setBodyInnerHTML( | 767 setBodyInnerHTML( |
| 765 "<style>body { margin: 0; } #frame { border: 10px solid black; } " | 768 "<style>body { margin: 0; } #frame { border: 10px solid black; } " |
| 766 "::-webkit-scrollbar { display: none; }</style>" | 769 "::-webkit-scrollbar { display: none; }</style>" |
| 767 "<iframe id=frame src='http://test.com' width='500' height='500' " | 770 "<iframe src='http://test.com' width='500' height='500' " |
| 768 "frameBorder='0'>" | 771 "frameBorder='0'>" |
| 769 "</iframe>"); | 772 "</iframe>"); |
| 770 | 773 |
| 771 Document& frameDocument = | |
| 772 setupChildIframe("frame", | |
| 773 "<style>body { margin: 0; } #target { width: 200px; " | |
| 774 "height: 8000px;}</style> <div id=target></div>"); | |
| 775 | |
| 776 document().view()->updateAllLifecyclePhases(); | 774 document().view()->updateAllLifecyclePhases(); |
| 777 | 775 |
| 778 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the | 776 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the |
| 779 // middle. | 777 // middle. |
| 780 frameDocument.view()->layoutViewportScrollableArea()->setScrollOffset( | 778 childDocument().view()->layoutViewportScrollableArea()->setScrollOffset( |
| 781 ScrollOffset(0.0, 3000.0), ProgrammaticScroll); | 779 ScrollOffset(0.0, 3000.0), ProgrammaticScroll); |
| 782 document().view()->updateAllLifecyclePhases(); | 780 document().view()->updateAllLifecyclePhases(); |
| 783 | 781 |
| 784 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); | 782 ASSERT_TRUE(childDocument().view()->layoutViewItem().hasLayer()); |
| 785 // The width is 485 pixels due to the size of the scrollbar. | 783 // The width is 485 pixels due to the size of the scrollbar. |
| 786 EXPECT_RECT_EQ( | 784 EXPECT_RECT_EQ( |
| 787 IntRect(0, 0, 500, 7500), | 785 IntRect(0, 0, 500, 7500), |
| 788 recomputeInterestRect(frameDocument.view() | 786 recomputeInterestRect(childDocument() |
| 787 .view() |
| 789 ->layoutViewItem() | 788 ->layoutViewItem() |
| 790 .enclosingLayer() | 789 .enclosingLayer() |
| 791 ->graphicsLayerBackingForScrolling())); | 790 ->graphicsLayerBackingForScrolling())); |
| 792 } | 791 } |
| 793 | 792 |
| 794 TEST_P(CompositedLayerMappingTest, | 793 TEST_P(CompositedLayerMappingTest, |
| 795 ScrollingContentsAndForegroundLayerPaintingPhase) { | 794 ScrollingContentsAndForegroundLayerPaintingPhase) { |
| 796 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 795 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 797 setBodyInnerHTML( | 796 setBodyInnerHTML( |
| 798 "<div id='container' style='position: relative; z-index: 1; overflow: " | 797 "<div id='container' style='position: relative; z-index: 1; overflow: " |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 document().view()->updateAllLifecyclePhases(); | 1000 document().view()->updateAllLifecyclePhases(); |
| 1002 ASSERT_EQ(document().documentElement(), | 1001 ASSERT_EQ(document().documentElement(), |
| 1003 rootScrollerController.globalRootScroller()); | 1002 rootScrollerController.globalRootScroller()); |
| 1004 | 1003 |
| 1005 EXPECT_TRUE(mapping3->clippingLayer()); | 1004 EXPECT_TRUE(mapping3->clippingLayer()); |
| 1006 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); | 1005 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); |
| 1007 } | 1006 } |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 } // namespace blink | 1009 } // namespace blink |
| OLD | NEW |