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 df6908c960e3f8bb388714cdac375b56fb95c40f..b81d202351883059b1540517320b18858eaaf1fe 100644 |
| --- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| @@ -1039,7 +1039,7 @@ TEST_P(ScrollingCoordinatorTest, |
| } |
| } |
| -class StyleRelatedMainThreadScrollingReasonTest |
| +class NonCompositedMainThreadScrollingReasonTest |
| : public ScrollingCoordinatorTest { |
| static const uint32_t m_LCDTextRelatedReasons = |
| MainThreadScrollingReason::kHasOpacityAndLCDText | |
| @@ -1047,87 +1047,110 @@ class StyleRelatedMainThreadScrollingReasonTest |
| MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
| protected: |
| - StyleRelatedMainThreadScrollingReasonTest() { |
| + NonCompositedMainThreadScrollingReasonTest() { |
| registerMockedHttpURLLoad("two_scrollable_area.html"); |
| navigateTo(m_baseURL + "two_scrollable_area.html"); |
| } |
| - void testStyle(const std::string& target, const uint32_t reason) { |
| + void testNonCompositedReasons(const std::string& target, |
| + const uint32_t reason) { |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| Document* document = frame()->document(); |
| Element* container = document->getElementById("scroller1"); |
| - container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
| - container = document->getElementById("scroller2"); |
| + DCHECK(container); |
| container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
| forceFullCompositingUpdate(); |
| - FrameView* frameView = frame()->view(); |
| - ASSERT_TRUE(frameView); |
| - ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| + PaintLayerScrollableArea* scrollableArea = |
| + toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| + ASSERT_TRUE(scrollableArea); |
| + ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| - // Remove the target attribute from one of the scrollers. |
| - // Still need to scroll on main thread. |
| - container = document->getElementById("scroller1"); |
| - DCHECK(container); |
| + Element* container2 = document->getElementById("scroller2"); |
| + PaintLayerScrollableArea* scrollableArea2 = |
| + toLayoutBoxModelObject(container2->layoutObject())->getScrollableArea(); |
| + ASSERT_TRUE(scrollableArea2); |
| + // Different scrollable area should keep unaffected. |
|
bokan
2017/04/07 17:39:03
nit: keep -> remain
yigu
2017/04/07 19:26:27
Done.
|
| + ASSERT_FALSE(scrollableArea2->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| - container->removeAttribute("class"); |
| - forceFullCompositingUpdate(); |
| - |
| - ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| - |
| - // Remove attribute from the other scroller would lead to |
| - // scroll on impl. |
| - container = document->getElementById("scroller2"); |
| - DCHECK(container); |
| + FrameView* frameView = frame()->view(); |
| + ASSERT_TRUE(frameView); |
| + ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| + // Remove attribute from the scroller 1 would lead to scroll on impl. |
| container->removeAttribute("class"); |
| forceFullCompositingUpdate(); |
| + ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| // Add target attribute would again lead to scroll on main thread |
| container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
| forceFullCompositingUpdate(); |
| - ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| + ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| + ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| if ((reason & m_LCDTextRelatedReasons) && |
| !(reason & ~m_LCDTextRelatedReasons)) { |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| forceFullCompositingUpdate(); |
| + ASSERT_FALSE( |
| + scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
| + |
| + // With "will-change:transform" we composite elements with |
| + // LCDTextRelatedReasons only. For elements with other |
| + // NonCompositedReasons, we don't create scrollingLayer for their |
| + // CompositedLayerMapping therefore they don't get composited. |
| + webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| + forceFullCompositingUpdate(); |
| + ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| + container->setAttribute("style", "will-change:transform"); |
|
bokan
2017/04/07 17:39:03
Again, split this out into a separate test that ru
yigu
2017/04/07 19:26:27
Done.
|
| + forceFullCompositingUpdate(); |
| + ASSERT_FALSE( |
| + scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| } |
| } |
| }; |
| INSTANTIATE_TEST_CASE_P(All, |
| - StyleRelatedMainThreadScrollingReasonTest, |
| + NonCompositedMainThreadScrollingReasonTest, |
| ::testing::Bool()); |
| -// TODO(yigu): This test and all other style realted main thread scrolling |
| -// reason tests below have been disabled due to https://crbug.com/701355. |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransparentTest) { |
| - testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, TransparentTest) { |
| + testNonCompositedReasons("transparent", |
| + MainThreadScrollingReason::kHasOpacityAndLCDText); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransformTest) { |
| - testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { |
| + testNonCompositedReasons("transform", |
| + MainThreadScrollingReason::kHasTransformAndLCDText); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, |
| - DISABLED_BackgroundNotOpaqueTest) { |
| - testStyle("background-not-opaque", |
| - MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
| + testNonCompositedReasons( |
| + "background-not-opaque", |
| + MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BorderRadiusTest) { |
| - testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { |
| + testNonCompositedReasons("border-radius", |
| + MainThreadScrollingReason::kHasBorderRadius); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipTest) { |
| - testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
| + testNonCompositedReasons("clip", |
| + MainThreadScrollingReason::kHasClipRelatedProperty); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { |
| uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| Document* document = frame()->document(); |
| @@ -1136,16 +1159,26 @@ TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { |
| DCHECK(element); |
| element->setAttribute(HTMLNames::styleAttr, |
| "clip-path:circle(115px at 20px 20px);"); |
| + Element* container = document->getElementById("scroller1"); |
| + DCHECK(container); |
| forceFullCompositingUpdate(); |
| + PaintLayerScrollableArea* scrollableArea = |
| + toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| + ASSERT_TRUE(scrollableArea); |
| + ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| + |
| FrameView* frameView = frame()->view(); |
| ASSERT_TRUE(frameView); |
| - ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| + ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| // Remove clip path from ancestor. |
| element->removeAttribute(HTMLNames::styleAttr); |
| forceFullCompositingUpdate(); |
| + ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| // Test descendant with ClipPath |
| @@ -1154,23 +1187,27 @@ TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { |
| element->setAttribute(HTMLNames::styleAttr, |
| "clip-path:circle(115px at 20px 20px);"); |
| forceFullCompositingUpdate(); |
| - ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| + ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| + ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| // Remove clip path from descendant. |
| element->removeAttribute(HTMLNames::styleAttr); |
| forceFullCompositingUpdate(); |
| + ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| + reason); |
| ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_LCDTextEnabledTest) { |
| - testStyle("transparent border-radius", |
| - MainThreadScrollingReason::kHasOpacityAndLCDText | |
| - MainThreadScrollingReason::kHasBorderRadius); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
| + testNonCompositedReasons("transparent border-radius", |
| + MainThreadScrollingReason::kHasOpacityAndLCDText | |
| + MainThreadScrollingReason::kHasBorderRadius); |
| } |
| -TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BoxShadowTest) { |
| - testStyle("box-shadow", |
| - MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
| +TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
| + testNonCompositedReasons( |
| + "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
| } |
| } // namespace blink |