Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| index a2194782061ed57c8b036b8c1d5418d3dfd5a2c3..55aa67f6b36fd2029e1c2e90e037e97d757e86fd 100644 |
| --- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| @@ -29,6 +29,7 @@ |
| #include "core/frame/FrameHost.h" |
| #include "core/frame/FrameView.h" |
| #include "core/frame/VisualViewport.h" |
| +#include "core/html/HTMLIFrameElement.h" |
| #include "core/layout/LayoutPart.h" |
| #include "core/layout/api/LayoutViewItem.h" |
| #include "core/layout/compositing/CompositedLayerMapping.h" |
| @@ -849,4 +850,81 @@ TEST_F(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
| MainThreadScrollingReason::kCustomScrollbarScrolling); |
| } |
| +TEST_F(ScrollingCoordinatorTest, |
| + BackgroundAttachmentFixedShouldTriggerMainThreadScroll) { |
| + registerMockedHttpURLLoad("iframe-background-attachment-fixed.html"); |
| + registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html"); |
| + registerMockedHttpURLLoad("white-1x1.png"); |
| + navigateTo(m_baseURL + "iframe-background-attachment-fixed.html"); |
| + forceFullCompositingUpdate(); |
| + |
| + Element* iframe = frame()->document()->getElementById("iframe"); |
| + ASSERT_TRUE(iframe); |
| + |
| + LayoutObject* layoutObject = iframe->layoutObject(); |
| + ASSERT_TRUE(layoutObject); |
| + ASSERT_TRUE(layoutObject->isLayoutPart()); |
| + |
| + LayoutPart* layoutPart = toLayoutPart(layoutObject); |
| + ASSERT_TRUE(layoutPart); |
| + ASSERT_TRUE(layoutPart->widget()); |
| + ASSERT_TRUE(layoutPart->widget()->isFrameView()); |
| + |
| + FrameView* innerFrameView = toFrameView(layoutPart->widget()); |
| + LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); |
| + ASSERT_FALSE(innerLayoutViewItem.isNull()); |
| + |
| + PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
| + ASSERT_TRUE(innerCompositor->inCompositingMode()); |
| + ASSERT_TRUE(innerCompositor->scrollLayer()); |
| + |
| + GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); |
| + ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); |
| + |
| + WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| + ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & |
| + MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| + |
| + // Remove fixed background-attachment should make the iframe |
| + // scroll on cc. |
| + auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument(); |
| + iframe = iframeDoc->getElementById("scrollable"); |
| + ASSERT_TRUE(iframe); |
| + |
| + iframe->removeAttribute("class"); |
| + forceFullCompositingUpdate(); |
| + |
| + layoutObject = iframe->layoutObject(); |
| + ASSERT_TRUE(layoutObject); |
| + |
| + scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| + ASSERT_TRUE(scrollLayer); |
| + |
| + webScrollLayer = scrollLayer->platformLayer(); |
| + ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() & |
| + MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| + |
| + // Force main frame to scroll on main thread. All its descendants |
| + // should scroll on main thread as well. |
| + Element* element = frame()->document()->getElementById("scrollable"); |
| + element->setAttribute( |
| + "style", |
| + "background-image: url('white-1x1.png'); background-attachment: fixed;;", |
|
pdr.
2016/12/19 04:04:28
Nit: extra semicolon
yigu
2016/12/20 00:48:34
Done.
|
| + ASSERT_NO_EXCEPTION); |
| + |
| + forceFullCompositingUpdate(); |
| + |
| + layoutObject = iframe->layoutObject(); |
| + ASSERT_TRUE(layoutObject); |
| + |
| + scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| + ASSERT_TRUE(scrollLayer); |
| + |
| + webScrollLayer = scrollLayer->platformLayer(); |
| + ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & |
| + MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| +} |
| } // namespace blink |