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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 12090014: Add a bit to not bubble scrolls to parent scrolling layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); 364 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
365 } 365 }
366 366
367 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) 367 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
368 { 368 {
369 setupScrollAndContentsLayers(gfx::Size(100, 100)); 369 setupScrollAndContentsLayers(gfx::Size(100, 100));
370 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 370 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
371 initializeRendererAndDrawFrame(); 371 initializeRendererAndDrawFrame();
372 372
373 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 373 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
374 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 374 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
375 m_hostImpl->scrollEnd(); 375 m_hostImpl->scrollEnd();
376 EXPECT_TRUE(m_didRequestRedraw); 376 EXPECT_TRUE(m_didRequestRedraw);
377 EXPECT_TRUE(m_didRequestCommit); 377 EXPECT_TRUE(m_didRequestCommit);
378 } 378 }
379 379
380 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) 380 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer)
381 { 381 {
382 // We should not crash when trying to scroll an empty layer tree. 382 // We should not crash when trying to scroll an empty layer tree.
383 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 383 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
384 } 384 }
(...skipping 22 matching lines...) Expand all
407 initializeRendererAndDrawFrame(); 407 initializeRendererAndDrawFrame();
408 408
409 // We should not crash if the tree is replaced while we are scrolling. 409 // We should not crash if the tree is replaced while we are scrolling.
410 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 410 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
411 m_hostImpl->activeTree()->DetachLayerTree(); 411 m_hostImpl->activeTree()->DetachLayerTree();
412 412
413 setupScrollAndContentsLayers(gfx::Size(100, 100)); 413 setupScrollAndContentsLayers(gfx::Size(100, 100));
414 414
415 // We should still be scrolling, because the scrolled layer also exists in t he new tree. 415 // We should still be scrolling, because the scrolled layer also exists in t he new tree.
416 gfx::Vector2d scrollDelta(0, 10); 416 gfx::Vector2d scrollDelta(0, 10);
417 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 417 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
418 m_hostImpl->scrollEnd(); 418 m_hostImpl->scrollEnd();
419 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 419 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
420 expectContains(*scrollInfo, scrollLayerId, scrollDelta); 420 expectContains(*scrollInfo, scrollLayerId, scrollDelta);
421 } 421 }
422 422
423 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) 423 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
424 { 424 {
425 setupScrollAndContentsLayers(gfx::Size(100, 100)); 425 setupScrollAndContentsLayers(gfx::Size(100, 100));
426 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 426 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
427 initializeRendererAndDrawFrame(); 427 initializeRendererAndDrawFrame();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 473 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
474 474
475 initializeRendererAndDrawFrame(); 475 initializeRendererAndDrawFrame();
476 476
477 // All scroll types inside the non-fast scrollable region should fail. 477 // All scroll types inside the non-fast scrollable region should fail.
478 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread); 478 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread);
479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge sture), InputHandlerClient::ScrollOnMainThread); 479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge sture), InputHandlerClient::ScrollOnMainThread);
480 480
481 // All scroll types outside this region should succeed. 481 // All scroll types outside this region should succeed.
482 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted); 482 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted);
483 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 483 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
484 m_hostImpl->scrollEnd(); 484 m_hostImpl->scrollEnd();
485 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted); 485 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted);
486 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 486 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
487 m_hostImpl->scrollEnd(); 487 m_hostImpl->scrollEnd();
488 } 488 }
489 489
490 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) 490 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
491 { 491 {
492 setupScrollAndContentsLayers(gfx::Size(200, 200)); 492 setupScrollAndContentsLayers(gfx::Size(200, 200));
493 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 493 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
494 494
495 LayerImpl* root = m_hostImpl->rootLayer(); 495 LayerImpl* root = m_hostImpl->rootLayer();
496 root->setContentsScale(2, 2); 496 root->setContentsScale(2, 2);
497 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 497 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
498 root->setPosition(gfx::PointF(-25, 0)); 498 root->setPosition(gfx::PointF(-25, 0));
499 499
500 initializeRendererAndDrawFrame(); 500 initializeRendererAndDrawFrame();
501 501
502 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels. 502 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels.
503 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted); 503 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted);
504 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); 504 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1), true);
505 m_hostImpl->scrollEnd(); 505 m_hostImpl->scrollEnd();
506 506
507 // This point is still inside the non-fast region. 507 // This point is still inside the non-fast region.
508 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread); 508 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread);
509 } 509 }
510 510
511 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue) 511 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue)
512 { 512 {
513 setupScrollAndContentsLayers(gfx::Size(200, 200)); 513 setupScrollAndContentsLayers(gfx::Size(200, 200));
514 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 514 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
515 515
516 initializeRendererAndDrawFrame(); 516 initializeRendererAndDrawFrame();
517 517
518 EXPECT_EQ(InputHandlerClient::ScrollStarted, 518 EXPECT_EQ(InputHandlerClient::ScrollStarted,
519 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); 519 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
520 520
521 // Trying to scroll to the left/top will not succeed. 521 // Trying to scroll to the left/top will not succeed.
522 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 522 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0), true) );
523 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); 523 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10), true) );
524 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); 524 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10), tru e));
525 525
526 // Scrolling to the right/bottom will succeed. 526 // Scrolling to the right/bottom will succeed.
527 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 0))); 527 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 0), true));
528 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10))); 528 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true));
529 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 10))); 529 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 10), true)) ;
530 530
531 // Scrolling to left/top will now succeed. 531 // Scrolling to left/top will now succeed.
532 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 532 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0), true)) ;
533 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); 533 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10), true)) ;
534 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); 534 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10), true ));
535 535
536 // Scrolling diagonally against an edge will succeed. 536 // Scrolling diagonally against an edge will succeed.
537 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, -10))); 537 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, -10), true) );
538 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 538 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0), true)) ;
539 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 10))); 539 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 10), true) );
540 540
541 // Trying to scroll more than the available space will also succeed. 541 // Trying to scroll more than the available space will also succeed.
542 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); 542 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(5000, 5000), tr ue));
543 } 543 }
544 544
545 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion ) 545 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion )
546 { 546 {
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); 547 setupScrollAndContentsLayers(gfx::Size(100, 100));
548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
549 initializeRendererAndDrawFrame(); 549 initializeRendererAndDrawFrame();
550 550
551 // We should be able to hit test for touch event handlers even if the root l ayer loses 551 // We should be able to hit test for touch event handlers even if the root l ayer loses
552 // its render surface after the most recent render. 552 // its render surface after the most recent render.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 scrollLayer->setImplTransform(identityScaleTransform); 598 scrollLayer->setImplTransform(identityScaleTransform);
599 scrollLayer->setScrollDelta(gfx::Vector2d()); 599 scrollLayer->setScrollDelta(gfx::Vector2d());
600 600
601 float pageScaleDelta = 2; 601 float pageScaleDelta = 2;
602 m_hostImpl->pinchGestureBegin(); 602 m_hostImpl->pinchGestureBegin();
603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); 603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
604 m_hostImpl->pinchGestureEnd(); 604 m_hostImpl->pinchGestureEnd();
605 605
606 gfx::Vector2d scrollDelta(0, 10); 606 gfx::Vector2d scrollDelta(0, 10);
607 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 607 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
608 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 608 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
609 m_hostImpl->scrollEnd(); 609 m_hostImpl->scrollEnd();
610 610
611 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 611 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
612 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 612 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
613 } 613 }
614 } 614 }
615 615
616 TEST_P(LayerTreeHostImplTest, pinchGesture) 616 TEST_P(LayerTreeHostImplTest, pinchGesture)
617 { 617 {
618 setupScrollAndContentsLayers(gfx::Size(100, 100)); 618 setupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 { 703 {
704 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 704 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
705 scrollLayer->setImplTransform(identityScaleTransform); 705 scrollLayer->setImplTransform(identityScaleTransform);
706 scrollLayer->setScrollDelta(gfx::Vector2d()); 706 scrollLayer->setScrollDelta(gfx::Vector2d());
707 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); 707 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20));
708 708
709 float pageScaleDelta = 1; 709 float pageScaleDelta = 1;
710 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); 710 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel);
711 m_hostImpl->pinchGestureBegin(); 711 m_hostImpl->pinchGestureBegin();
712 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); 712 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10));
713 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); 713 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10), true);
714 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); 714 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20));
715 m_hostImpl->pinchGestureEnd(); 715 m_hostImpl->pinchGestureEnd();
716 m_hostImpl->scrollEnd(); 716 m_hostImpl->scrollEnd();
717 717
718 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 718 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
719 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 719 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
720 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); 720 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10));
721 } 721 }
722 } 722 }
723 723
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // We should immediately get the final zoom and scroll values for the 870 // We should immediately get the final zoom and scroll values for the
871 // animation. 871 // animation.
872 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); 872 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
873 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 873 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
874 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 874 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
875 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); 875 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
876 876
877 // Scrolling during the animation is ignored. 877 // Scrolling during the animation is ignored.
878 const gfx::Vector2d scrollDelta(0, 10); 878 const gfx::Vector2d scrollDelta(0, 10);
879 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH andlerClient::Wheel), InputHandlerClient::ScrollStarted); 879 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH andlerClient::Wheel), InputHandlerClient::ScrollStarted);
880 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 880 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
881 m_hostImpl->scrollEnd(); 881 m_hostImpl->scrollEnd();
882 882
883 // The final page scale and scroll deltas should match what we got 883 // The final page scale and scroll deltas should match what we got
884 // earlier. 884 // earlier.
885 m_hostImpl->animate(endTime, base::Time()); 885 m_hostImpl->animate(endTime, base::Time());
886 scrollInfo = m_hostImpl->processScrollDeltas(); 886 scrollInfo = m_hostImpl->processScrollDeltas();
887 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 887 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
888 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); 888 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
889 } 889 }
890 890
891 TEST_P(LayerTreeHostImplTest, compositorFrameMetadata) 891 TEST_P(LayerTreeHostImplTest, compositorFrameMetadata)
892 { 892 {
893 setupScrollAndContentsLayers(gfx::Size(100, 100)); 893 setupScrollAndContentsLayers(gfx::Size(100, 100));
894 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 894 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
895 m_hostImpl->setPageScaleFactorAndLimits(1.0f, 0.5f, 4.0f); 895 m_hostImpl->setPageScaleFactorAndLimits(1.0f, 0.5f, 4.0f);
896 initializeRendererAndDrawFrame(); 896 initializeRendererAndDrawFrame();
897 897
898 { 898 {
899 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); 899 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta();
900 EXPECT_EQ(gfx::Vector2dF(0.0f, 0.0f), metadata.root_scroll_offset); 900 EXPECT_EQ(gfx::Vector2dF(0.0f, 0.0f), metadata.root_scroll_offset);
901 EXPECT_EQ(1.0f, metadata.page_scale_factor); 901 EXPECT_EQ(1.0f, metadata.page_scale_factor);
902 EXPECT_EQ(gfx::SizeF(50.0f, 50.0f), metadata.viewport_size); 902 EXPECT_EQ(gfx::SizeF(50.0f, 50.0f), metadata.viewport_size);
903 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); 903 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size);
904 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 904 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
905 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); 905 EXPECT_EQ(4.0f, metadata.max_page_scale_factor);
906 } 906 }
907 907
908 // Scrolling should update metadata immediately. 908 // Scrolling should update metadata immediately.
909 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 909 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
910 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 910 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
911 { 911 {
912 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); 912 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta();
913 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); 913 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset);
914 } 914 }
915 m_hostImpl->scrollEnd(); 915 m_hostImpl->scrollEnd();
916 916
917 { 917 {
918 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); 918 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta();
919 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); 919 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset);
920 } 920 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 scrollLayer->setContentBounds(surfaceSize); 1205 scrollLayer->setContentBounds(surfaceSize);
1206 scrollLayer->setPosition(gfx::PointF(0, 0)); 1206 scrollLayer->setPosition(gfx::PointF(0, 0));
1207 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); 1207 scrollLayer->setAnchorPoint(gfx::PointF(0, 0));
1208 scrollLayer->addChild(contentLayer.Pass()); 1208 scrollLayer->addChild(contentLayer.Pass());
1209 1209
1210 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); 1210 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass());
1211 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1211 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1212 initializeRendererAndDrawFrame(); 1212 initializeRendererAndDrawFrame();
1213 1213
1214 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1214 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1215 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1215 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
1216 m_hostImpl->scrollEnd(); 1216 m_hostImpl->scrollEnd();
1217 EXPECT_TRUE(m_didRequestRedraw); 1217 EXPECT_TRUE(m_didRequestRedraw);
1218 EXPECT_TRUE(m_didRequestCommit); 1218 EXPECT_TRUE(m_didRequestCommit);
1219 } 1219 }
1220 1220
1221 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) 1221 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
1222 { 1222 {
1223 gfx::Size surfaceSize(10, 10); 1223 gfx::Size surfaceSize(10, 10);
1224 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1224 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1225 root->setBounds(surfaceSize); 1225 root->setBounds(surfaceSize);
1226 root->setContentBounds(surfaceSize); 1226 root->setContentBounds(surfaceSize);
1227 root->addChild(createScrollableLayer(2, surfaceSize)); 1227 root->addChild(createScrollableLayer(2, surfaceSize));
1228 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1228 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1229 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1229 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1230 initializeRendererAndDrawFrame(); 1230 initializeRendererAndDrawFrame();
1231 1231
1232 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1232 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1233 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1233 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10), true);
1234 m_hostImpl->scrollEnd(); 1234 m_hostImpl->scrollEnd();
1235 EXPECT_TRUE(m_didRequestRedraw); 1235 EXPECT_TRUE(m_didRequestRedraw);
1236 EXPECT_TRUE(m_didRequestCommit); 1236 EXPECT_TRUE(m_didRequestCommit);
1237 } 1237 }
1238 1238
1239 TEST_P(LayerTreeHostImplTest, scrollMissesChild) 1239 TEST_P(LayerTreeHostImplTest, scrollMissesChild)
1240 { 1240 {
1241 gfx::Size surfaceSize(10, 10); 1241 gfx::Size surfaceSize(10, 10);
1242 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1242 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1243 root->addChild(createScrollableLayer(2, surfaceSize)); 1243 root->addChild(createScrollableLayer(2, surfaceSize));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1299 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1300 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1300 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1301 m_hostImpl->activeTree()->DidBecomeActive(); 1301 m_hostImpl->activeTree()->DidBecomeActive();
1302 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1302 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1303 initializeRendererAndDrawFrame(); 1303 initializeRendererAndDrawFrame();
1304 1304
1305 gfx::Vector2d scrollDelta(0, 10); 1305 gfx::Vector2d scrollDelta(0, 10);
1306 gfx::Vector2d expectedScrollDelta(scrollDelta); 1306 gfx::Vector2d expectedScrollDelta(scrollDelta);
1307 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1307 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1308 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1308 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1309 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1309 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1310 m_hostImpl->scrollEnd(); 1310 m_hostImpl->scrollEnd();
1311 1311
1312 // Set new page scale from main thread. 1312 // Set new page scale from main thread.
1313 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); 1313 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale);
1314 1314
1315 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1315 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1316 // The scale should apply to the scroll delta. 1316 // The scale should apply to the scroll delta.
1317 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1317 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1318 } 1318 }
1319 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1319 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1353 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1354 m_hostImpl->activeTree()->DidBecomeActive(); 1354 m_hostImpl->activeTree()->DidBecomeActive();
1355 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1355 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1356 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1356 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1357 initializeRendererAndDrawFrame(); 1357 initializeRendererAndDrawFrame();
1358 1358
1359 gfx::Vector2d scrollDelta(0, 10); 1359 gfx::Vector2d scrollDelta(0, 10);
1360 gfx::Vector2d expectedScrollDelta(scrollDelta); 1360 gfx::Vector2d expectedScrollDelta(scrollDelta);
1361 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1361 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1362 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1362 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1363 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1363 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1364 m_hostImpl->scrollEnd(); 1364 m_hostImpl->scrollEnd();
1365 1365
1366 // Set new page scale on impl thread by pinching. 1366 // Set new page scale on impl thread by pinching.
1367 m_hostImpl->pinchGestureBegin(); 1367 m_hostImpl->pinchGestureBegin();
1368 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 1368 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
1369 m_hostImpl->pinchGestureEnd(); 1369 m_hostImpl->pinchGestureEnd();
1370 drawOneFrame(); 1370 drawOneFrame();
1371 1371
1372 // The scroll delta is not scaled because the main thread did not scale. 1372 // The scroll delta is not scaled because the main thread did not scale.
1373 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1373 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 m_hostImpl->activeTree()->DidBecomeActive(); 1441 m_hostImpl->activeTree()->DidBecomeActive();
1442 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1442 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1443 initializeRendererAndDrawFrame(); 1443 initializeRendererAndDrawFrame();
1444 1444
1445 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1445 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1446 1446
1447 gfx::Vector2d scrollDelta(0, 10); 1447 gfx::Vector2d scrollDelta(0, 10);
1448 gfx::Vector2d expectedScrollDelta(scrollDelta); 1448 gfx::Vector2d expectedScrollDelta(scrollDelta);
1449 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1449 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1450 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1450 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1451 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1451 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1452 m_hostImpl->scrollEnd(); 1452 m_hostImpl->scrollEnd();
1453 1453
1454 float pageScale = 2; 1454 float pageScale = 2;
1455 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1455 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1456 1456
1457 drawOneFrame(); 1457 drawOneFrame();
1458 1458
1459 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1459 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1460 // The scale should apply to the scroll delta. 1460 // The scale should apply to the scroll delta.
1461 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1461 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
(...skipping 25 matching lines...) Expand all
1487 child->addChild(grandChild.Pass()); 1487 child->addChild(grandChild.Pass());
1488 1488
1489 root->addChild(child.Pass()); 1489 root->addChild(child.Pass());
1490 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1490 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1491 m_hostImpl->activeTree()->DidBecomeActive(); 1491 m_hostImpl->activeTree()->DidBecomeActive();
1492 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1492 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1493 initializeRendererAndDrawFrame(); 1493 initializeRendererAndDrawFrame();
1494 { 1494 {
1495 gfx::Vector2d scrollDelta(-8, -7); 1495 gfx::Vector2d scrollDelta(-8, -7);
1496 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1496 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1497 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1497 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1498 m_hostImpl->scrollEnd(); 1498 m_hostImpl->scrollEnd();
1499 1499
1500 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1500 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1501 1501
1502 // The grand child should have scrolled up to its limit. 1502 // The grand child should have scrolled up to its limit.
1503 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1503 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1504 LayerImpl* grandChild = child->children()[0]; 1504 LayerImpl* grandChild = child->children()[0];
1505 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) ); 1505 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) );
1506 1506
1507 // The child should have only scrolled on the other axis. 1507 // The child should have only scrolled on the other axis.
(...skipping 13 matching lines...) Expand all
1521 child->setScrollable(false); 1521 child->setScrollable(false);
1522 root->addChild(child.Pass()); 1522 root->addChild(child.Pass());
1523 1523
1524 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1524 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1525 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1525 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1526 m_hostImpl->activeTree()->DidBecomeActive(); 1526 m_hostImpl->activeTree()->DidBecomeActive();
1527 initializeRendererAndDrawFrame(); 1527 initializeRendererAndDrawFrame();
1528 { 1528 {
1529 gfx::Vector2d scrollDelta(0, 4); 1529 gfx::Vector2d scrollDelta(0, 4);
1530 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1530 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1531 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1531 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1532 m_hostImpl->scrollEnd(); 1532 m_hostImpl->scrollEnd();
1533 1533
1534 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1534 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1535 1535
1536 // Only the root should have scrolled. 1536 // Only the root should have scrolled.
1537 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1537 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1538 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1538 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1539 } 1539 }
1540 } 1540 }
1541 1541
(...skipping 23 matching lines...) Expand all
1565 rotateTransform.Rotate(-90); 1565 rotateTransform.Rotate(-90);
1566 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1566 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1567 1567
1568 gfx::Size surfaceSize(50, 50); 1568 gfx::Size surfaceSize(50, 50);
1569 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1569 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1570 initializeRendererAndDrawFrame(); 1570 initializeRendererAndDrawFrame();
1571 1571
1572 // Scroll to the right in screen coordinates with a gesture. 1572 // Scroll to the right in screen coordinates with a gesture.
1573 gfx::Vector2d gestureScrollDelta(10, 0); 1573 gfx::Vector2d gestureScrollDelta(10, 0);
1574 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1574 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1575 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1575 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta, true);
1576 m_hostImpl->scrollEnd(); 1576 m_hostImpl->scrollEnd();
1577 1577
1578 // The layer should have scrolled down in its local coordinates. 1578 // The layer should have scrolled down in its local coordinates.
1579 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1579 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1580 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, gestureScrollDelta.x())); 1580 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, gestureScrollDelta.x()));
1581 1581
1582 // Reset and scroll down with the wheel. 1582 // Reset and scroll down with the wheel.
1583 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); 1583 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
1584 gfx::Vector2d wheelScrollDelta(0, 10); 1584 gfx::Vector2d wheelScrollDelta(0, 10);
1585 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1585 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1586 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); 1586 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta, true);
1587 m_hostImpl->scrollEnd(); 1587 m_hostImpl->scrollEnd();
1588 1588
1589 // The layer should have scrolled down in its local coordinates. 1589 // The layer should have scrolled down in its local coordinates.
1590 scrollInfo = m_hostImpl->processScrollDeltas(); 1590 scrollInfo = m_hostImpl->processScrollDeltas();
1591 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1591 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1592 } 1592 }
1593 1593
1594 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1594 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1595 { 1595 {
1596 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1596 setupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 13 matching lines...) Expand all
1610 m_hostImpl->rootLayer()->addChild(child.Pass()); 1610 m_hostImpl->rootLayer()->addChild(child.Pass());
1611 1611
1612 gfx::Size surfaceSize(50, 50); 1612 gfx::Size surfaceSize(50, 50);
1613 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1613 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1614 initializeRendererAndDrawFrame(); 1614 initializeRendererAndDrawFrame();
1615 1615
1616 { 1616 {
1617 // Scroll down in screen coordinates with a gesture. 1617 // Scroll down in screen coordinates with a gesture.
1618 gfx::Vector2d gestureScrollDelta(0, 10); 1618 gfx::Vector2d gestureScrollDelta(0, 10);
1619 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted); 1619 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted);
1620 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1620 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta, true);
1621 m_hostImpl->scrollEnd(); 1621 m_hostImpl->scrollEnd();
1622 1622
1623 // The child layer should have scrolled down in its local coordinates an amount proportional to 1623 // The child layer should have scrolled down in its local coordinates an amount proportional to
1624 // the angle between it and the input scroll delta. 1624 // the angle between it and the input scroll delta.
1625 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M athUtil::Deg2Rad(childLayerAngle))); 1625 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M athUtil::Deg2Rad(childLayerAngle)));
1626 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1626 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1627 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1627 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1628 1628
1629 // The root layer should not have scrolled, because the input delta was close to the layer's 1629 // The root layer should not have scrolled, because the input delta was close to the layer's
1630 // axis of movement. 1630 // axis of movement.
1631 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); 1631 EXPECT_EQ(scrollInfo->scrolls.size(), 1u);
1632 } 1632 }
1633 1633
1634 { 1634 {
1635 // Now reset and scroll the same amount horizontally. 1635 // Now reset and scroll the same amount horizontally.
1636 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF()) ; 1636 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF()) ;
1637 gfx::Vector2d gestureScrollDelta(10, 0); 1637 gfx::Vector2d gestureScrollDelta(10, 0);
1638 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted); 1638 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted);
1639 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1639 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta, true);
1640 m_hostImpl->scrollEnd(); 1640 m_hostImpl->scrollEnd();
1641 1641
1642 // The child layer should have scrolled down in its local coordinates an amount proportional to 1642 // The child layer should have scrolled down in its local coordinates an amount proportional to
1643 // the angle between it and the input scroll delta. 1643 // the angle between it and the input scroll delta.
1644 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin( MathUtil::Deg2Rad(childLayerAngle))); 1644 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin( MathUtil::Deg2Rad(childLayerAngle)));
1645 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1645 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1646 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1646 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1647 1647
1648 // The root layer should have scrolled more, since the input scroll delt a was mostly 1648 // The root layer should have scrolled more, since the input scroll delt a was mostly
1649 // orthogonal to the child layer's vertical scroll axis. 1649 // orthogonal to the child layer's vertical scroll axis.
(...skipping 12 matching lines...) Expand all
1662 scaleTransform.Scale(scale, scale); 1662 scaleTransform.Scale(scale, scale);
1663 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1663 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1664 1664
1665 gfx::Size surfaceSize(50, 50); 1665 gfx::Size surfaceSize(50, 50);
1666 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1666 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1667 initializeRendererAndDrawFrame(); 1667 initializeRendererAndDrawFrame();
1668 1668
1669 // Scroll down in screen coordinates with a gesture. 1669 // Scroll down in screen coordinates with a gesture.
1670 gfx::Vector2d scrollDelta(0, 10); 1670 gfx::Vector2d scrollDelta(0, 10);
1671 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1671 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1672 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1672 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
1673 m_hostImpl->scrollEnd(); 1673 m_hostImpl->scrollEnd();
1674 1674
1675 // The layer should have scrolled down in its local coordinates, but half he amount. 1675 // The layer should have scrolled down in its local coordinates, but half he amount.
1676 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1676 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1677 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, scrollDelta.y() / scale)); 1677 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, scrollDelta.y() / scale));
1678 1678
1679 // Reset and scroll down with the wheel. 1679 // Reset and scroll down with the wheel.
1680 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); 1680 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
1681 gfx::Vector2d wheelScrollDelta(0, 10); 1681 gfx::Vector2d wheelScrollDelta(0, 10);
1682 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1682 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1683 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); 1683 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta, true);
1684 m_hostImpl->scrollEnd(); 1684 m_hostImpl->scrollEnd();
1685 1685
1686 // The scale should not have been applied to the scroll delta. 1686 // The scale should not have been applied to the scroll delta.
1687 scrollInfo = m_hostImpl->processScrollDeltas(); 1687 scrollInfo = m_hostImpl->processScrollDeltas();
1688 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1688 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1689 } 1689 }
1690 1690
1691 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { 1691 class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
1692 public: 1692 public:
1693 BlendStateTrackerContext() : m_blend(false) { } 1693 BlendStateTrackerContext() : m_blend(false) { }
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 // so no point in continuing without it. 4045 // so no point in continuing without it.
4046 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4046 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4047 return; 4047 return;
4048 4048
4049 m_didRequestCommit = false; 4049 m_didRequestCommit = false;
4050 m_didRequestRedraw = false; 4050 m_didRequestRedraw = false;
4051 4051
4052 // This scroll will force the viewport to pan horizontally. 4052 // This scroll will force the viewport to pan horizontally.
4053 gfx::Vector2d scrollDelta(5, 0); 4053 gfx::Vector2d scrollDelta(5, 0);
4054 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4054 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4055 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4055 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
4056 m_hostImpl->scrollEnd(); 4056 m_hostImpl->scrollEnd();
4057 4057
4058 EXPECT_EQ(true, m_didRequestCommit); 4058 EXPECT_EQ(true, m_didRequestCommit);
4059 EXPECT_EQ(true, m_didRequestRedraw); 4059 EXPECT_EQ(true, m_didRequestRedraw);
4060 4060
4061 m_didRequestCommit = false; 4061 m_didRequestCommit = false;
4062 m_didRequestRedraw = false; 4062 m_didRequestRedraw = false;
4063 4063
4064 // This scroll will force the viewport to pan vertically. 4064 // This scroll will force the viewport to pan vertically.
4065 scrollDelta = gfx::Vector2d(0, 5); 4065 scrollDelta = gfx::Vector2d(0, 5);
4066 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4066 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4067 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4067 m_hostImpl->scrollBy(gfx::Point(), scrollDelta, true);
4068 m_hostImpl->scrollEnd(); 4068 m_hostImpl->scrollEnd();
4069 4069
4070 EXPECT_EQ(true, m_didRequestCommit); 4070 EXPECT_EQ(true, m_didRequestCommit);
4071 EXPECT_EQ(true, m_didRequestRedraw); 4071 EXPECT_EQ(true, m_didRequestRedraw);
4072 } 4072 }
4073 4073
4074 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1 ) 4074 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1 )
4075 { 4075 {
4076 pinchZoomPanViewportForcesCommitRedraw(1); 4076 pinchZoomPanViewportForcesCommitRedraw(1);
4077 } 4077 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4117 // so no point in continuing without it. 4117 // so no point in continuing without it.
4118 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4118 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4119 return; 4119 return;
4120 4120
4121 gfx::Vector2d scrollDelta(5, 0); 4121 gfx::Vector2d scrollDelta(5, 0);
4122 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is 4122 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is
4123 // scaled instead of the scroll input. 4123 // scaled instead of the scroll input.
4124 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4124 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4125 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4125 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4126 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4126 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4127 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4127 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4128 m_hostImpl->scrollEnd(); 4128 m_hostImpl->scrollEnd();
4129 drawOneFrame(); 4129 drawOneFrame();
4130 4130
4131 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); 4131 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor());
4132 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4132 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4133 4133
4134 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4134 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4135 // No change expected. 4135 // No change expected.
4136 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4136 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4137 // None of the scroll delta should have been used for document scroll. 4137 // None of the scroll delta should have been used for document scroll.
4138 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4138 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4139 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4139 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4140 4140
4141 // Test scroll in y-direction also. 4141 // Test scroll in y-direction also.
4142 scrollDelta = gfx::Vector2d(0, 5); 4142 scrollDelta = gfx::Vector2d(0, 5);
4143 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4143 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4144 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4144 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4145 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4145 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4146 m_hostImpl->scrollEnd(); 4146 m_hostImpl->scrollEnd();
4147 drawOneFrame(); 4147 drawOneFrame();
4148 4148
4149 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); 4149 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor());
4150 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4150 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4151 4151
4152 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4152 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4153 // No change expected. 4153 // No change expected.
4154 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4154 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4155 // None of the scroll delta should have been used for document scroll. 4155 // None of the scroll delta should have been used for document scroll.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4203 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4204 return; 4204 return;
4205 4205
4206 // Scroll document only: scrollDelta chosen to move document horizontally 4206 // Scroll document only: scrollDelta chosen to move document horizontally
4207 // to its max scroll offset. 4207 // to its max scroll offset.
4208 gfx::Vector2d scrollDelta(3, 0); 4208 gfx::Vector2d scrollDelta(3, 0);
4209 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4209 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4210 gfx::Vector2d expectedScrollDelta(scrollDelta); 4210 gfx::Vector2d expectedScrollDelta(scrollDelta);
4211 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4211 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4212 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4212 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4213 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4213 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4214 m_hostImpl->scrollEnd(); 4214 m_hostImpl->scrollEnd();
4215 drawOneFrame(); 4215 drawOneFrame();
4216 4216
4217 // The scroll delta is not scaled because the main thread did not scale. 4217 // The scroll delta is not scaled because the main thread did not scale.
4218 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4218 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4219 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4219 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4220 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4220 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4221 4221
4222 // Verify we did not change the implTransform this time. 4222 // Verify we did not change the implTransform this time.
4223 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4223 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4224 4224
4225 // Further scrolling should move the pinchZoomViewport only. 4225 // Further scrolling should move the pinchZoomViewport only.
4226 scrollDelta = gfx::Vector2d(2, 0); 4226 scrollDelta = gfx::Vector2d(2, 0);
4227 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4227 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4228 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4228 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4229 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4229 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4230 m_hostImpl->scrollEnd(); 4230 m_hostImpl->scrollEnd();
4231 drawOneFrame(); 4231 drawOneFrame();
4232 4232
4233 gfx::Vector2d expectedPanDelta(scrollDelta); 4233 gfx::Vector2d expectedPanDelta(scrollDelta);
4234 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4234 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4235 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4235 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4236 4236
4237 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4237 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4238 4238
4239 // The scroll delta on the main thread should not have been affected by this . 4239 // The scroll delta on the main thread should not have been affected by this .
4240 scrollInfo = m_hostImpl->processScrollDeltas(); 4240 scrollInfo = m_hostImpl->processScrollDeltas();
4241 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4241 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4242 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4242 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4243 4243
4244 // Perform same test sequence in y-direction also. 4244 // Perform same test sequence in y-direction also.
4245 // Document only scroll. 4245 // Document only scroll.
4246 scrollDelta = gfx::Vector2d(0, 4); 4246 scrollDelta = gfx::Vector2d(0, 4);
4247 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4247 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4248 expectedScrollDelta += scrollDelta; 4248 expectedScrollDelta += scrollDelta;
4249 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4249 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4250 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4250 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4251 m_hostImpl->scrollEnd(); 4251 m_hostImpl->scrollEnd();
4252 drawOneFrame(); 4252 drawOneFrame();
4253 4253
4254 // The scroll delta is not scaled because the main thread did not scale. 4254 // The scroll delta is not scaled because the main thread did not scale.
4255 scrollInfo = m_hostImpl->processScrollDeltas(); 4255 scrollInfo = m_hostImpl->processScrollDeltas();
4256 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4256 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4257 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4257 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4258 4258
4259 // Verify we did not change the implTransform this time. 4259 // Verify we did not change the implTransform this time.
4260 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4260 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4261 4261
4262 // pinchZoomViewport scroll only. 4262 // pinchZoomViewport scroll only.
4263 scrollDelta = gfx::Vector2d(0, 1); 4263 scrollDelta = gfx::Vector2d(0, 1);
4264 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4264 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4265 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4265 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4266 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4266 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4267 m_hostImpl->scrollEnd(); 4267 m_hostImpl->scrollEnd();
4268 drawOneFrame(); 4268 drawOneFrame();
4269 4269
4270 expectedPanDelta = scrollDelta; 4270 expectedPanDelta = scrollDelta;
4271 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4271 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4272 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4272 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4273 4273
4274 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4274 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4275 4275
4276 // The scroll delta on the main thread should not have been affected by this . 4276 // The scroll delta on the main thread should not have been affected by this .
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4327 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4328 return; 4328 return;
4329 4329
4330 // Scroll document and pann zoomViewport in one scroll-delta. 4330 // Scroll document and pann zoomViewport in one scroll-delta.
4331 gfx::Vector2d scrollDelta(5, 0); 4331 gfx::Vector2d scrollDelta(5, 0);
4332 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4332 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4333 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. 4333 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll.
4334 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4334 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4335 4335
4336 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4336 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4337 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4337 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4338 m_hostImpl->scrollEnd(); 4338 m_hostImpl->scrollEnd();
4339 drawOneFrame(); 4339 drawOneFrame();
4340 4340
4341 // The scroll delta is not scaled because the main thread did not scale. 4341 // The scroll delta is not scaled because the main thread did not scale.
4342 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4342 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4343 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4343 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4344 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4344 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4345 4345
4346 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. 4346 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan.
4347 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4347 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4348 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4348 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4349 4349
4350 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4350 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4351 4351
4352 // Perform same test sequence in y-direction also. 4352 // Perform same test sequence in y-direction also.
4353 scrollDelta = gfx::Vector2d(0, 5); 4353 scrollDelta = gfx::Vector2d(0, 5);
4354 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4354 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4355 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. 4355 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll.
4356 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4356 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4357 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4357 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport, true);
4358 m_hostImpl->scrollEnd(); 4358 m_hostImpl->scrollEnd();
4359 drawOneFrame(); 4359 drawOneFrame();
4360 4360
4361 // The scroll delta is not scaled because the main thread did not scale. 4361 // The scroll delta is not scaled because the main thread did not scale.
4362 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. 4362 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan.
4363 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4363 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4364 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4364 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4365 4365
4366 expectedPanDelta = gfx::Vector2d(0, 1); 4366 expectedPanDelta = gfx::Vector2d(0, 1);
4367 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4367 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 m_hostImpl->didDrawAllLayers(frame); 4676 m_hostImpl->didDrawAllLayers(frame);
4677 } 4677 }
4678 } 4678 }
4679 4679
4680 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4680 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4681 LayerTreeHostImplTest, 4681 LayerTreeHostImplTest,
4682 ::testing::Values(false, true)); 4682 ::testing::Values(false, true));
4683 4683
4684 } // namespace 4684 } // namespace
4685 } // namespace cc 4685 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698