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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 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
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 4 200px in non-RTL mode. Expanding 136 // A scroll by -5000px is equivalent to a scroll by (10000 - 5000 - 800)px = 4 200px in non-RTL mode. Expanding
137 // the resulting rect by 4000px in each direction yields this result. 137 // the resulting rect by 4000px in each direction yields this result.
138 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600), 138 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600),
139 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 139 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
140 } 140 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 " body { margin: 0; }" 449 " body { margin: 0; }"
450 "</style>" 450 "</style>"
451 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); 451 "<div id='div' style='width: 100px; height: 10000px'>Text</div>");
452 452
453 document().view()->updateAllLifecyclePhases(); 453 document().view()->updateAllLifecyclePhases();
454 GraphicsLayer* rootScrollingLayer = 454 GraphicsLayer* rootScrollingLayer =
455 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling(); 455 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling();
456 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), 456 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600),
457 previousInterestRect(rootScrollingLayer)); 457 previousInterestRect(rootScrollingLayer));
458 458
459 document().view()->setScrollPosition(IntPoint(0, 300), ProgrammaticScroll); 459 document().view()->setScrollOffset(ScrollOffset(0, 300), ProgrammaticScroll);
460 document().view()->updateAllLifecyclePhases(); 460 document().view()->updateAllLifecyclePhases();
461 // Still use the previous interest rect because the recomputed rect hasn't cha nged enough. 461 // Still use the previous interest rect because the recomputed rect hasn't cha nged enough.
462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900), 462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900),
463 recomputeInterestRect(rootScrollingLayer)); 463 recomputeInterestRect(rootScrollingLayer));
464 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), 464 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600),
465 previousInterestRect(rootScrollingLayer)); 465 previousInterestRect(rootScrollingLayer));
466 466
467 document().view()->setScrollPosition(IntPoint(0, 600), ProgrammaticScroll); 467 document().view()->setScrollOffset(ScrollOffset(0, 600), ProgrammaticScroll);
468 document().view()->updateAllLifecyclePhases(); 468 document().view()->updateAllLifecyclePhases();
469 // Use recomputed interest rect because it changed enough. 469 // Use recomputed interest rect because it changed enough.
470 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), 470 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200),
471 recomputeInterestRect(rootScrollingLayer)); 471 recomputeInterestRect(rootScrollingLayer));
472 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), 472 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200),
473 previousInterestRect(rootScrollingLayer)); 473 previousInterestRect(rootScrollingLayer));
474 474
475 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll); 475 document().view()->setScrollOffset(ScrollOffset(0, 5400), ProgrammaticScroll);
476 document().view()->updateAllLifecyclePhases(); 476 document().view()->updateAllLifecyclePhases();
477 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 477 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
478 recomputeInterestRect(rootScrollingLayer)); 478 recomputeInterestRect(rootScrollingLayer));
479 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 479 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
480 previousInterestRect(rootScrollingLayer)); 480 previousInterestRect(rootScrollingLayer));
481 481
482 document().view()->setScrollPosition(IntPoint(0, 9000), ProgrammaticScroll); 482 document().view()->setScrollOffset(ScrollOffset(0, 9000), ProgrammaticScroll);
483 document().view()->updateAllLifecyclePhases(); 483 document().view()->updateAllLifecyclePhases();
484 // Still use the previous interest rect because it contains the recomputed int erest rect. 484 // Still use the previous interest rect because it contains the recomputed int erest rect.
485 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), 485 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000),
486 recomputeInterestRect(rootScrollingLayer)); 486 recomputeInterestRect(rootScrollingLayer));
487 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 487 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
488 previousInterestRect(rootScrollingLayer)); 488 previousInterestRect(rootScrollingLayer));
489 489
490 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll); 490 document().view()->setScrollOffset(ScrollOffset(0, 2000), ProgrammaticScroll);
491 // Use recomputed interest rect because it changed enough. 491 // Use recomputed interest rect because it changed enough.
492 document().view()->updateAllLifecyclePhases(); 492 document().view()->updateAllLifecyclePhases();
493 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), 493 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600),
494 recomputeInterestRect(rootScrollingLayer)); 494 recomputeInterestRect(rootScrollingLayer));
495 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), 495 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600),
496 previousInterestRect(rootScrollingLayer)); 496 previousInterestRect(rootScrollingLayer));
497 } 497 }
498 498
499 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnShrunkenViewport) { 499 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnShrunkenViewport) {
500 setBodyInnerHTML( 500 setBodyInnerHTML(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 "<iframe id=frame src='http://test.com' width='500' height='500' " 682 "<iframe id=frame src='http://test.com' width='500' height='500' "
683 "frameBorder='0'>" 683 "frameBorder='0'>"
684 "</iframe>"); 684 "</iframe>");
685 685
686 Document& frameDocument = setupChildIframe( 686 Document& frameDocument = setupChildIframe(
687 "frame", 687 "frame",
688 "<style>body { margin: 0; } #target { width: 200px; height: 200px; " 688 "<style>body { margin: 0; } #target { width: 200px; height: 200px; "
689 "will-change: transform}</style><div id=target></div>"); 689 "will-change: transform}</style><div id=target></div>");
690 690
691 // Scroll 8000 pixels down to move the iframe into view. 691 // Scroll 8000 pixels down to move the iframe into view.
692 document().view()->setScrollPosition(DoublePoint(0.0, 8000.0), 692 document().view()->setScrollOffset(ScrollOffset(0.0, 8000.0),
693 ProgrammaticScroll); 693 ProgrammaticScroll);
694 document().view()->updateAllLifecyclePhases(); 694 document().view()->updateAllLifecyclePhases();
695 695
696 Element* target = frameDocument.getElementById("target"); 696 Element* target = frameDocument.getElementById("target");
697 ASSERT_TRUE(target); 697 ASSERT_TRUE(target);
698 698
699 EXPECT_RECT_EQ( 699 EXPECT_RECT_EQ(
700 IntRect(0, 0, 200, 200), 700 IntRect(0, 0, 200, 200),
701 recomputeInterestRect( 701 recomputeInterestRect(
702 target->layoutObject()->enclosingLayer()->graphicsLayerBacking())); 702 target->layoutObject()->enclosingLayer()->graphicsLayerBacking()));
703 } 703 }
704 704
705 TEST_F(CompositedLayerMappingTest, InterestRectOfScrolledIframe) { 705 TEST_F(CompositedLayerMappingTest, InterestRectOfScrolledIframe) {
706 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); 706 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
707 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 707 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
708 setBodyInnerHTML( 708 setBodyInnerHTML(
709 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; " 709 "<style>body { margin: 0; } ::-webkit-scrollbar { display: none; "
710 "}</style>" 710 "}</style>"
711 "<iframe id=frame src='http://test.com' width='500' height='500' " 711 "<iframe id=frame src='http://test.com' width='500' height='500' "
712 "frameBorder='0'>" 712 "frameBorder='0'>"
713 "</iframe>"); 713 "</iframe>");
714 714
715 Document& frameDocument = 715 Document& frameDocument =
716 setupChildIframe("frame", 716 setupChildIframe("frame",
717 "<style>body { margin: 0; } #target { width: 200px; " 717 "<style>body { margin: 0; } #target { width: 200px; "
718 "height: 8000px;}</style><div id=target></div>"); 718 "height: 8000px;}</style><div id=target></div>");
719 719
720 document().view()->updateAllLifecyclePhases(); 720 document().view()->updateAllLifecyclePhases();
721 721
722 // Scroll 7500 pixels down to bring the scrollable area to the bottom. 722 // Scroll 7500 pixels down to bring the scrollable area to the bottom.
723 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 7500.0), 723 frameDocument.view()->setScrollOffset(ScrollOffset(0.0, 7500.0),
724 ProgrammaticScroll); 724 ProgrammaticScroll);
725 document().view()->updateAllLifecyclePhases(); 725 document().view()->updateAllLifecyclePhases();
726 726
727 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); 727 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer());
728 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500), 728 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500),
729 recomputeInterestRect(frameDocument.view() 729 recomputeInterestRect(frameDocument.view()
730 ->layoutViewItem() 730 ->layoutViewItem()
731 .enclosingLayer() 731 .enclosingLayer()
732 ->graphicsLayerBacking())); 732 ->graphicsLayerBacking()));
733 } 733 }
734 734
735 TEST_F(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) { 735 TEST_F(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) {
736 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); 736 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
737 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 737 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
738 // Set a 10px border in order to have a contentBoxOffset for the iframe elemen t. 738 // Set a 10px border in order to have a contentBoxOffset for the iframe elemen t.
739 setBodyInnerHTML( 739 setBodyInnerHTML(
740 "<style>body { margin: 0; } #frame { border: 10px solid black; } " 740 "<style>body { margin: 0; } #frame { border: 10px solid black; } "
741 "::-webkit-scrollbar { display: none; }</style>" 741 "::-webkit-scrollbar { display: none; }</style>"
742 "<iframe id=frame src='http://test.com' width='500' height='500' " 742 "<iframe id=frame src='http://test.com' width='500' height='500' "
743 "frameBorder='0'>" 743 "frameBorder='0'>"
744 "</iframe>"); 744 "</iframe>");
745 745
746 Document& frameDocument = 746 Document& frameDocument =
747 setupChildIframe("frame", 747 setupChildIframe("frame",
748 "<style>body { margin: 0; } #target { width: 200px; " 748 "<style>body { margin: 0; } #target { width: 200px; "
749 "height: 8000px;}</style> <div id=target></div>"); 749 "height: 8000px;}</style> <div id=target></div>");
750 750
751 document().view()->updateAllLifecyclePhases(); 751 document().view()->updateAllLifecyclePhases();
752 752
753 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the mi ddle. 753 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the mi ddle.
754 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), 754 frameDocument.view()->setScrollOffset(ScrollOffset(0.0, 3000.0),
755 ProgrammaticScroll); 755 ProgrammaticScroll);
756 document().view()->updateAllLifecyclePhases(); 756 document().view()->updateAllLifecyclePhases();
757 757
758 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); 758 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer());
759 // The width is 485 pixels due to the size of the scrollbar. 759 // The width is 485 pixels due to the size of the scrollbar.
760 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), 760 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500),
761 recomputeInterestRect(frameDocument.view() 761 recomputeInterestRect(frameDocument.view()
762 ->layoutViewItem() 762 ->layoutViewItem()
763 .enclosingLayer() 763 .enclosingLayer()
764 ->graphicsLayerBacking())); 764 ->graphicsLayerBacking()));
765 } 765 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 document().view()->updateAllLifecyclePhases(); 1014 document().view()->updateAllLifecyclePhases();
1015 ASSERT_EQ(document().documentElement(), 1015 ASSERT_EQ(document().documentElement(),
1016 rootScrollerController.globalRootScroller()); 1016 rootScrollerController.globalRootScroller());
1017 1017
1018 EXPECT_TRUE(mapping3->clippingLayer()); 1018 EXPECT_TRUE(mapping3->clippingLayer());
1019 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); 1019 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds());
1020 } 1020 }
1021 } 1021 }
1022 1022
1023 } // namespace blink 1023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698