| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/page/scrolling/ScrollingCoordinator.h" | 25 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 26 | 26 |
| 27 #include "core/css/CSSStyleSheet.h" | 27 #include "core/css/CSSStyleSheet.h" |
| 28 #include "core/css/StyleSheetList.h" | 28 #include "core/css/StyleSheetList.h" |
| 29 #include "core/frame/FrameHost.h" | 29 #include "core/frame/FrameHost.h" |
| 30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
| 31 #include "core/frame/VisualViewport.h" | 31 #include "core/frame/VisualViewport.h" |
| 32 #include "core/layout/LayoutPart.h" | 32 #include "core/layout/LayoutPart.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 namespace blink { | 52 namespace blink { |
| 53 | 53 |
| 54 class ScrollingCoordinatorTest : public testing::Test { | 54 class ScrollingCoordinatorTest : public testing::Test { |
| 55 public: | 55 public: |
| 56 ScrollingCoordinatorTest() : m_baseURL("http://www.test.com/") { | 56 ScrollingCoordinatorTest() : m_baseURL("http://www.test.com/") { |
| 57 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, | 57 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, |
| 58 &configureSettings); | 58 &configureSettings); |
| 59 webViewImpl()->resize(IntSize(320, 240)); | 59 webViewImpl()->resize(IntSize(320, 240)); |
| 60 | 60 |
| 61 // OSX attaches main frame scrollbars to the VisualViewport so the VisualVie
wport layers need | 61 // macOS attaches main frame scrollbars to the VisualViewport so the |
| 62 // to be initialized. | 62 // VisualViewport layers need to be initialized. |
| 63 webViewImpl()->updateAllLifecyclePhases(); | 63 webViewImpl()->updateAllLifecyclePhases(); |
| 64 WebFrameWidgetBase* mainFrameWidget = | 64 WebFrameWidgetBase* mainFrameWidget = |
| 65 webViewImpl()->mainFrameImpl()->frameWidget(); | 65 webViewImpl()->mainFrameImpl()->frameWidget(); |
| 66 mainFrameWidget->setRootGraphicsLayer(webViewImpl() | 66 mainFrameWidget->setRootGraphicsLayer(webViewImpl() |
| 67 ->mainFrameImpl() | 67 ->mainFrameImpl() |
| 68 ->frame() | 68 ->frame() |
| 69 ->view() | 69 ->view() |
| 70 ->layoutViewItem() | 70 ->layoutViewItem() |
| 71 .compositor() | 71 .compositor() |
| 72 ->rootGraphicsLayer()); | 72 ->rootGraphicsLayer()); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 WebLayer* rootScrollLayer = getRootScrollLayer(); | 414 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 415 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); | 415 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 TEST_F(ScrollingCoordinatorTest, overflowScrolling) { | 418 TEST_F(ScrollingCoordinatorTest, overflowScrolling) { |
| 419 registerMockedHttpURLLoad("overflow-scrolling.html"); | 419 registerMockedHttpURLLoad("overflow-scrolling.html"); |
| 420 navigateTo(m_baseURL + "overflow-scrolling.html"); | 420 navigateTo(m_baseURL + "overflow-scrolling.html"); |
| 421 forceFullCompositingUpdate(); | 421 forceFullCompositingUpdate(); |
| 422 | 422 |
| 423 // Verify the properties of the accelerated scrolling element starting from th
e LayoutObject | 423 // Verify the properties of the accelerated scrolling element starting from |
| 424 // all the way to the WebLayer. | 424 // the LayoutObject all the way to the WebLayer. |
| 425 Element* scrollableElement = | 425 Element* scrollableElement = |
| 426 frame()->document()->getElementById("scrollable"); | 426 frame()->document()->getElementById("scrollable"); |
| 427 DCHECK(scrollableElement); | 427 DCHECK(scrollableElement); |
| 428 | 428 |
| 429 LayoutObject* layoutObject = scrollableElement->layoutObject(); | 429 LayoutObject* layoutObject = scrollableElement->layoutObject(); |
| 430 ASSERT_TRUE(layoutObject->isBox()); | 430 ASSERT_TRUE(layoutObject->isBox()); |
| 431 ASSERT_TRUE(layoutObject->hasLayer()); | 431 ASSERT_TRUE(layoutObject->hasLayer()); |
| 432 | 432 |
| 433 LayoutBox* box = toLayoutBox(layoutObject); | 433 LayoutBox* box = toLayoutBox(layoutObject); |
| 434 ASSERT_TRUE(box->usesCompositedScrolling()); | 434 ASSERT_TRUE(box->usesCompositedScrolling()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 459 ASSERT_TRUE( | 459 ASSERT_TRUE( |
| 460 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); | 460 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); |
| 461 #endif | 461 #endif |
| 462 } | 462 } |
| 463 | 463 |
| 464 TEST_F(ScrollingCoordinatorTest, overflowHidden) { | 464 TEST_F(ScrollingCoordinatorTest, overflowHidden) { |
| 465 registerMockedHttpURLLoad("overflow-hidden.html"); | 465 registerMockedHttpURLLoad("overflow-hidden.html"); |
| 466 navigateTo(m_baseURL + "overflow-hidden.html"); | 466 navigateTo(m_baseURL + "overflow-hidden.html"); |
| 467 forceFullCompositingUpdate(); | 467 forceFullCompositingUpdate(); |
| 468 | 468 |
| 469 // Verify the properties of the accelerated scrolling element starting from th
e LayoutObject | 469 // Verify the properties of the accelerated scrolling element starting from |
| 470 // all the way to the WebLayer. | 470 // the LayoutObject all the way to the WebLayer. |
| 471 Element* overflowElement = | 471 Element* overflowElement = |
| 472 frame()->document()->getElementById("unscrollable-y"); | 472 frame()->document()->getElementById("unscrollable-y"); |
| 473 DCHECK(overflowElement); | 473 DCHECK(overflowElement); |
| 474 | 474 |
| 475 LayoutObject* layoutObject = overflowElement->layoutObject(); | 475 LayoutObject* layoutObject = overflowElement->layoutObject(); |
| 476 ASSERT_TRUE(layoutObject->isBox()); | 476 ASSERT_TRUE(layoutObject->isBox()); |
| 477 ASSERT_TRUE(layoutObject->hasLayer()); | 477 ASSERT_TRUE(layoutObject->hasLayer()); |
| 478 | 478 |
| 479 LayoutBox* box = toLayoutBox(layoutObject); | 479 LayoutBox* box = toLayoutBox(layoutObject); |
| 480 ASSERT_TRUE(box->usesCompositedScrolling()); | 480 ASSERT_TRUE(box->usesCompositedScrolling()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 521 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| 522 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 522 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| 523 } | 523 } |
| 524 | 524 |
| 525 TEST_F(ScrollingCoordinatorTest, iframeScrolling) { | 525 TEST_F(ScrollingCoordinatorTest, iframeScrolling) { |
| 526 registerMockedHttpURLLoad("iframe-scrolling.html"); | 526 registerMockedHttpURLLoad("iframe-scrolling.html"); |
| 527 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); | 527 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
| 528 navigateTo(m_baseURL + "iframe-scrolling.html"); | 528 navigateTo(m_baseURL + "iframe-scrolling.html"); |
| 529 forceFullCompositingUpdate(); | 529 forceFullCompositingUpdate(); |
| 530 | 530 |
| 531 // Verify the properties of the accelerated scrolling element starting from th
e LayoutObject | 531 // Verify the properties of the accelerated scrolling element starting from |
| 532 // all the way to the WebLayer. | 532 // the LayoutObject all the way to the WebLayer. |
| 533 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); | 533 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); |
| 534 ASSERT_TRUE(scrollableFrame); | 534 ASSERT_TRUE(scrollableFrame); |
| 535 | 535 |
| 536 LayoutObject* layoutObject = scrollableFrame->layoutObject(); | 536 LayoutObject* layoutObject = scrollableFrame->layoutObject(); |
| 537 ASSERT_TRUE(layoutObject); | 537 ASSERT_TRUE(layoutObject); |
| 538 ASSERT_TRUE(layoutObject->isLayoutPart()); | 538 ASSERT_TRUE(layoutObject->isLayoutPart()); |
| 539 | 539 |
| 540 LayoutPart* layoutPart = toLayoutPart(layoutObject); | 540 LayoutPart* layoutPart = toLayoutPart(layoutObject); |
| 541 ASSERT_TRUE(layoutPart); | 541 ASSERT_TRUE(layoutPart); |
| 542 ASSERT_TRUE(layoutPart->widget()); | 542 ASSERT_TRUE(layoutPart->widget()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 565 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); | 565 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); |
| 566 #endif | 566 #endif |
| 567 } | 567 } |
| 568 | 568 |
| 569 TEST_F(ScrollingCoordinatorTest, rtlIframe) { | 569 TEST_F(ScrollingCoordinatorTest, rtlIframe) { |
| 570 registerMockedHttpURLLoad("rtl-iframe.html"); | 570 registerMockedHttpURLLoad("rtl-iframe.html"); |
| 571 registerMockedHttpURLLoad("rtl-iframe-inner.html"); | 571 registerMockedHttpURLLoad("rtl-iframe-inner.html"); |
| 572 navigateTo(m_baseURL + "rtl-iframe.html"); | 572 navigateTo(m_baseURL + "rtl-iframe.html"); |
| 573 forceFullCompositingUpdate(); | 573 forceFullCompositingUpdate(); |
| 574 | 574 |
| 575 // Verify the properties of the accelerated scrolling element starting from th
e LayoutObject | 575 // Verify the properties of the accelerated scrolling element starting from |
| 576 // all the way to the WebLayer. | 576 // the LayoutObject all the way to the WebLayer. |
| 577 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); | 577 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); |
| 578 ASSERT_TRUE(scrollableFrame); | 578 ASSERT_TRUE(scrollableFrame); |
| 579 | 579 |
| 580 LayoutObject* layoutObject = scrollableFrame->layoutObject(); | 580 LayoutObject* layoutObject = scrollableFrame->layoutObject(); |
| 581 ASSERT_TRUE(layoutObject); | 581 ASSERT_TRUE(layoutObject); |
| 582 ASSERT_TRUE(layoutObject->isLayoutPart()); | 582 ASSERT_TRUE(layoutObject->isLayoutPart()); |
| 583 | 583 |
| 584 LayoutPart* layoutPart = toLayoutPart(layoutObject); | 584 LayoutPart* layoutPart = toLayoutPart(layoutObject); |
| 585 ASSERT_TRUE(layoutPart); | 585 ASSERT_TRUE(layoutPart); |
| 586 ASSERT_TRUE(layoutPart->widget()); | 586 ASSERT_TRUE(layoutPart->widget()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 forceFullCompositingUpdate(); | 735 forceFullCompositingUpdate(); |
| 736 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); | 736 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); |
| 737 ASSERT_FALSE( | 737 ASSERT_FALSE( |
| 738 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); | 738 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); |
| 739 ASSERT_FALSE( | 739 ASSERT_FALSE( |
| 740 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & | 740 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & |
| 741 MainThreadScrollingReason::kCustomScrollbarScrolling); | 741 MainThreadScrollingReason::kCustomScrollbarScrolling); |
| 742 } | 742 } |
| 743 | 743 |
| 744 } // namespace blink | 744 } // namespace blink |
| OLD | NEW |