OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/frame/FrameHost.h" | 5 #include "core/frame/FrameHost.h" |
6 #include "core/frame/FrameView.h" | 6 #include "core/frame/FrameView.h" |
7 #include "core/frame/TopControls.h" | 7 #include "core/frame/TopControls.h" |
8 #include "core/html/HTMLFrameOwnerElement.h" | 8 #include "core/html/HTMLFrameOwnerElement.h" |
9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
10 #include "core/page/scrolling/RootScrollerController.h" | 10 #include "core/page/scrolling/RootScrollerController.h" |
11 #include "core/page/scrolling/TopDocumentRootScrollerController.h" | |
11 #include "core/paint/PaintLayerScrollableArea.h" | 12 #include "core/paint/PaintLayerScrollableArea.h" |
12 #include "platform/testing/URLTestHelpers.h" | 13 #include "platform/testing/URLTestHelpers.h" |
13 #include "platform/testing/UnitTestHelpers.h" | 14 #include "platform/testing/UnitTestHelpers.h" |
14 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
15 #include "public/platform/WebURLLoaderMockFactory.h" | 16 #include "public/platform/WebURLLoaderMockFactory.h" |
16 #include "public/web/WebCache.h" | 17 #include "public/web/WebCache.h" |
17 #include "public/web/WebConsoleMessage.h" | 18 #include "public/web/WebConsoleMessage.h" |
18 #include "public/web/WebScriptSource.h" | 19 #include "public/web/WebScriptSource.h" |
19 #include "public/web/WebSettings.h" | 20 #include "public/web/WebSettings.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 TEST_F(RootScrollerTest, SetRootScrollerIframeUsesCorrectLayerAndCallback) | 504 TEST_F(RootScrollerTest, SetRootScrollerIframeUsesCorrectLayerAndCallback) |
504 { | 505 { |
505 initialize("root-scroller-iframe.html"); | 506 initialize("root-scroller-iframe.html"); |
506 ASSERT_EQ(nullptr, mainFrame()->document()->rootScroller()); | 507 ASSERT_EQ(nullptr, mainFrame()->document()->rootScroller()); |
507 | 508 |
508 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( | 509 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( |
509 mainFrame()->document()->getElementById("iframe")); | 510 mainFrame()->document()->getElementById("iframe")); |
510 Element* container = | 511 Element* container = |
511 iframe->contentDocument()->getElementById("container"); | 512 iframe->contentDocument()->getElementById("container"); |
512 | 513 |
513 RootScrollerController* mainController = | 514 TopDocumentRootScrollerController& mainController = |
tdresser
2016/08/30 15:05:30
Can this be const?
bokan
2016/08/30 16:13:39
Done.
| |
514 mainFrame()->document()->rootScrollerController(); | 515 mainFrame()->document()->frameHost()->globalRootScrollerController(); |
515 | 516 |
516 NonThrowableExceptionState nonThrow; | 517 NonThrowableExceptionState nonThrow; |
517 | 518 |
518 // No root scroller set, the documentElement should be the effective root | 519 // No root scroller set, the documentElement should be the effective root |
519 // and the main FrameView's scroll layer should be the layer to use. | 520 // and the main FrameView's scroll layer should be the layer to use. |
520 { | 521 { |
521 EXPECT_EQ( | 522 EXPECT_EQ( |
522 mainController->rootScrollerLayer(), | 523 mainController.rootScrollerLayer(), |
523 mainFrameView()->layerForScrolling()); | 524 mainFrameView()->layerForScrolling()); |
524 EXPECT_TRUE(mainController->isViewportScrollCallback( | 525 EXPECT_TRUE(mainController.isViewportScrollCallback( |
525 mainFrame()->document()->documentElement()->getApplyScroll())); | 526 mainFrame()->document()->documentElement()->getApplyScroll())); |
526 } | 527 } |
527 | 528 |
528 // Set a root scroller in the iframe. Since the main document didn't set a | 529 // Set a root scroller in the iframe. Since the main document didn't set a |
529 // root scroller, the global root scroller shouldn't change. | 530 // root scroller, the global root scroller shouldn't change. |
530 { | 531 { |
531 | 532 |
532 iframe->contentDocument()->setRootScroller(container, nonThrow); | 533 iframe->contentDocument()->setRootScroller(container, nonThrow); |
533 | 534 |
534 EXPECT_EQ( | 535 EXPECT_EQ( |
535 mainController->rootScrollerLayer(), | 536 mainController.rootScrollerLayer(), |
536 mainFrameView()->layerForScrolling()); | 537 mainFrameView()->layerForScrolling()); |
537 EXPECT_TRUE(mainController->isViewportScrollCallback( | 538 EXPECT_TRUE(mainController.isViewportScrollCallback( |
538 mainFrame()->document()->documentElement()->getApplyScroll())); | 539 mainFrame()->document()->documentElement()->getApplyScroll())); |
539 } | 540 } |
540 | 541 |
541 // Setting the iframe as the root scroller in the main frame should now | 542 // Setting the iframe as the root scroller in the main frame should now |
542 // link the root scrollers so the container should now be the global root | 543 // link the root scrollers so the container should now be the global root |
543 // scroller. | 544 // scroller. |
544 { | 545 { |
545 mainFrame()->document()->setRootScroller(iframe, nonThrow); | 546 mainFrame()->document()->setRootScroller(iframe, nonThrow); |
546 | 547 |
547 ScrollableArea* containerScroller = | 548 ScrollableArea* containerScroller = |
548 static_cast<PaintInvalidationCapableScrollableArea*>( | 549 static_cast<PaintInvalidationCapableScrollableArea*>( |
549 toLayoutBox(container->layoutObject())->getScrollableArea()); | 550 toLayoutBox(container->layoutObject())->getScrollableArea()); |
550 | 551 |
551 EXPECT_EQ( | 552 EXPECT_EQ( |
552 mainController->rootScrollerLayer(), | 553 mainController.rootScrollerLayer(), |
553 containerScroller->layerForScrolling()); | 554 containerScroller->layerForScrolling()); |
554 EXPECT_FALSE(mainController->isViewportScrollCallback( | 555 EXPECT_FALSE(mainController.isViewportScrollCallback( |
555 mainFrame()->document()->documentElement()->getApplyScroll())); | 556 mainFrame()->document()->documentElement()->getApplyScroll())); |
556 EXPECT_TRUE(mainController->isViewportScrollCallback( | 557 EXPECT_TRUE(mainController.isViewportScrollCallback( |
557 container->getApplyScroll())); | 558 container->getApplyScroll())); |
558 } | 559 } |
559 | 560 |
560 // Unsetting the root scroller in the iframe should reset its effective | 561 // Unsetting the root scroller in the iframe should reset its effective |
561 // root scroller to the iframe's documentElement and thus the iframe's | 562 // root scroller to the iframe's documentElement and thus the iframe's |
562 // documentElement becomes the global root scroller. | 563 // documentElement becomes the global root scroller. |
563 { | 564 { |
564 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); | 565 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); |
565 EXPECT_EQ( | 566 EXPECT_EQ( |
566 mainController->rootScrollerLayer(), | 567 mainController.rootScrollerLayer(), |
567 iframe->contentDocument()->view()->layerForScrolling()); | 568 iframe->contentDocument()->view()->layerForScrolling()); |
568 EXPECT_FALSE(mainController->isViewportScrollCallback( | 569 EXPECT_FALSE(mainController.isViewportScrollCallback( |
569 container->getApplyScroll())); | 570 container->getApplyScroll())); |
570 EXPECT_FALSE(mainController->isViewportScrollCallback( | 571 EXPECT_FALSE(mainController.isViewportScrollCallback( |
571 mainFrame()->document()->documentElement()->getApplyScroll())); | 572 mainFrame()->document()->documentElement()->getApplyScroll())); |
572 EXPECT_TRUE(mainController->isViewportScrollCallback( | 573 EXPECT_TRUE(mainController.isViewportScrollCallback( |
573 iframe->contentDocument()->documentElement()->getApplyScroll())); | 574 iframe->contentDocument()->documentElement()->getApplyScroll())); |
574 } | 575 } |
575 | 576 |
576 // Finally, unsetting the main frame's root scroller should reset it to the | 577 // Finally, unsetting the main frame's root scroller should reset it to the |
577 // documentElement and corresponding layer. | 578 // documentElement and corresponding layer. |
578 { | 579 { |
579 mainFrame()->document()->setRootScroller(nullptr, nonThrow); | 580 mainFrame()->document()->setRootScroller(nullptr, nonThrow); |
580 EXPECT_EQ( | 581 EXPECT_EQ( |
581 mainController->rootScrollerLayer(), | 582 mainController.rootScrollerLayer(), |
582 mainFrameView()->layerForScrolling()); | 583 mainFrameView()->layerForScrolling()); |
583 EXPECT_TRUE(mainController->isViewportScrollCallback( | 584 EXPECT_TRUE(mainController.isViewportScrollCallback( |
584 mainFrame()->document()->documentElement()->getApplyScroll())); | 585 mainFrame()->document()->documentElement()->getApplyScroll())); |
585 EXPECT_FALSE(mainController->isViewportScrollCallback( | 586 EXPECT_FALSE(mainController.isViewportScrollCallback( |
586 container->getApplyScroll())); | 587 container->getApplyScroll())); |
587 EXPECT_FALSE(mainController->isViewportScrollCallback( | 588 EXPECT_FALSE(mainController.isViewportScrollCallback( |
588 iframe->contentDocument()->documentElement()->getApplyScroll())); | 589 iframe->contentDocument()->documentElement()->getApplyScroll())); |
589 } | 590 } |
590 } | 591 } |
591 | 592 |
592 TEST_F(RootScrollerTest, TestSetRootScrollerCausesViewportLayerChange) | 593 TEST_F(RootScrollerTest, TestSetRootScrollerCausesViewportLayerChange) |
593 { | 594 { |
594 // TODO(bokan): Need a test that changing root scrollers actually sets the | 595 // TODO(bokan): Need a test that changing root scrollers actually sets the |
595 // outer viewport layer on the compositor, even in the absence of other | 596 // outer viewport layer on the compositor, even in the absence of other |
596 // compositing changes. crbug.com/505516 | 597 // compositing changes. crbug.com/505516 |
597 } | 598 } |
(...skipping 30 matching lines...) Expand all Loading... | |
628 body, | 629 body, |
629 exceptionState); | 630 exceptionState); |
630 | 631 |
631 EXPECT_EQ(body, iframe->contentDocument()->rootScroller()); | 632 EXPECT_EQ(body, iframe->contentDocument()->rootScroller()); |
632 } | 633 } |
633 } | 634 } |
634 | 635 |
635 } // namespace | 636 } // namespace |
636 | 637 |
637 } // namespace blink | 638 } // namespace blink |
OLD | NEW |