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