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

Side by Side Diff: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp

Issue 2672473002: Revert of [RootLayerScrolls] Fix ScrollingCoordinatorTest (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 20 matching lines...) Expand all
31 #include "core/frame/VisualViewport.h" 31 #include "core/frame/VisualViewport.h"
32 #include "core/html/HTMLIFrameElement.h" 32 #include "core/html/HTMLIFrameElement.h"
33 #include "core/layout/LayoutPart.h" 33 #include "core/layout/LayoutPart.h"
34 #include "core/layout/api/LayoutViewItem.h" 34 #include "core/layout/api/LayoutViewItem.h"
35 #include "core/layout/compositing/CompositedLayerMapping.h" 35 #include "core/layout/compositing/CompositedLayerMapping.h"
36 #include "core/layout/compositing/PaintLayerCompositor.h" 36 #include "core/layout/compositing/PaintLayerCompositor.h"
37 #include "core/page/Page.h" 37 #include "core/page/Page.h"
38 #include "platform/geometry/IntPoint.h" 38 #include "platform/geometry/IntPoint.h"
39 #include "platform/geometry/IntRect.h" 39 #include "platform/geometry/IntRect.h"
40 #include "platform/graphics/GraphicsLayer.h" 40 #include "platform/graphics/GraphicsLayer.h"
41 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
42 #include "platform/testing/URLTestHelpers.h" 41 #include "platform/testing/URLTestHelpers.h"
43 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
44 #include "public/platform/WebLayer.h" 43 #include "public/platform/WebLayer.h"
45 #include "public/platform/WebLayerPositionConstraint.h" 44 #include "public/platform/WebLayerPositionConstraint.h"
46 #include "public/platform/WebLayerTreeView.h" 45 #include "public/platform/WebLayerTreeView.h"
47 #include "public/platform/WebURLLoaderMockFactory.h" 46 #include "public/platform/WebURLLoaderMockFactory.h"
48 #include "public/web/WebCache.h" 47 #include "public/web/WebCache.h"
49 #include "public/web/WebSettings.h" 48 #include "public/web/WebSettings.h"
50 #include "public/web/WebViewClient.h" 49 #include "public/web/WebViewClient.h"
51 #include "testing/gtest/include/gtest/gtest.h" 50 #include "testing/gtest/include/gtest/gtest.h"
52 #include "web/WebLocalFrameImpl.h" 51 #include "web/WebLocalFrameImpl.h"
53 #include "web/WebViewImpl.h" 52 #include "web/WebViewImpl.h"
54 #include "web/tests/FrameTestHelpers.h" 53 #include "web/tests/FrameTestHelpers.h"
55 54
56 namespace blink { 55 namespace blink {
57 56
58 class ScrollingCoordinatorTest : public testing::Test, 57 class ScrollingCoordinatorTest : public testing::Test {
59 public testing::WithParamInterface<bool>,
60 private ScopedRootLayerScrollingForTest {
61 public: 58 public:
62 ScrollingCoordinatorTest() 59 ScrollingCoordinatorTest() : m_baseURL("http://www.test.com/") {
63 : ScopedRootLayerScrollingForTest(GetParam()),
64 m_baseURL("http://www.test.com/") {
65 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, 60 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr,
66 &configureSettings); 61 &configureSettings);
67 webViewImpl()->resize(IntSize(320, 240)); 62 webViewImpl()->resize(IntSize(320, 240));
68 63
69 // macOS attaches main frame scrollbars to the VisualViewport so the 64 // macOS attaches main frame scrollbars to the VisualViewport so the
70 // VisualViewport layers need to be initialized. 65 // VisualViewport layers need to be initialized.
71 webViewImpl()->updateAllLifecyclePhases(); 66 webViewImpl()->updateAllLifecyclePhases();
72 WebFrameWidgetBase* mainFrameWidget = 67 WebFrameWidgetBase* mainFrameWidget =
73 webViewImpl()->mainFrameImpl()->frameWidget(); 68 webViewImpl()->mainFrameImpl()->frameWidget();
74 mainFrameWidget->setRootGraphicsLayer(webViewImpl() 69 mainFrameWidget->setRootGraphicsLayer(webViewImpl()
75 ->mainFrameImpl() 70 ->mainFrameImpl()
76 ->frame() 71 ->frame()
77 ->view() 72 ->view()
78 ->layoutViewItem() 73 ->layoutViewItem()
79 .compositor() 74 .compositor()
80 ->rootGraphicsLayer()); 75 ->rootGraphicsLayer());
81 } 76 }
82 77
83 ~ScrollingCoordinatorTest() override { 78 ~ScrollingCoordinatorTest() override {
84 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 79 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
85 WebCache::clear(); 80 WebCache::clear();
86 } 81 }
87 82
88 void navigateTo(const std::string& url) { 83 void navigateTo(const std::string& url) {
89 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); 84 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url);
90 } 85 }
91 86
92 void loadHTML(const std::string& html) {
93 FrameTestHelpers::loadHTMLString(webViewImpl()->mainFrame(), html,
94 URLTestHelpers::toKURL("about:blank"));
95 }
96
97 void forceFullCompositingUpdate() { 87 void forceFullCompositingUpdate() {
98 webViewImpl()->updateAllLifecyclePhases(); 88 webViewImpl()->updateAllLifecyclePhases();
99 } 89 }
100 90
101 void registerMockedHttpURLLoad(const std::string& fileName) { 91 void registerMockedHttpURLLoad(const std::string& fileName) {
102 URLTestHelpers::registerMockedURLFromBaseURL( 92 URLTestHelpers::registerMockedURLFromBaseURL(
103 WebString::fromUTF8(m_baseURL.c_str()), 93 WebString::fromUTF8(m_baseURL.c_str()),
104 WebString::fromUTF8(fileName.c_str())); 94 WebString::fromUTF8(fileName.c_str()));
105 } 95 }
106 96
107 WebLayer* getRootScrollLayer() { 97 WebLayer* getRootScrollLayer() {
108 GraphicsLayer* layer = 98 PaintLayerCompositor* compositor =
109 frame()->view()->layoutViewportScrollableArea()->layerForScrolling(); 99 frame()->contentLayoutItem().compositor();
110 return layer ? layer->platformLayer() : nullptr; 100 DCHECK(compositor);
101 DCHECK(compositor->scrollLayer());
102
103 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
104 return webScrollLayer;
111 } 105 }
112 106
113 WebViewImpl* webViewImpl() const { return m_helper.webView(); } 107 WebViewImpl* webViewImpl() const { return m_helper.webView(); }
114 LocalFrame* frame() const { 108 LocalFrame* frame() const {
115 return m_helper.webView()->mainFrameImpl()->frame(); 109 return m_helper.webView()->mainFrameImpl()->frame();
116 } 110 }
117 111
118 WebLayerTreeView* webLayerTreeView() const { 112 WebLayerTreeView* webLayerTreeView() const {
119 return webViewImpl()->layerTreeView(); 113 return webViewImpl()->layerTreeView();
120 } 114 }
121 115
116 void styleRelatedMainThreadScrollingReasonTest(const std::string&,
117 const uint32_t);
118
122 protected: 119 protected:
123 std::string m_baseURL; 120 std::string m_baseURL;
124 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; 121 FrameTestHelpers::TestWebViewClient m_mockWebViewClient;
125 122
126 private: 123 private:
127 static void configureSettings(WebSettings* settings) { 124 static void configureSettings(WebSettings* settings) {
128 settings->setJavaScriptEnabled(true); 125 settings->setJavaScriptEnabled(true);
129 settings->setAcceleratedCompositingEnabled(true); 126 settings->setAcceleratedCompositingEnabled(true);
130 settings->setPreferCompositingToLCDTextEnabled(true); 127 settings->setPreferCompositingToLCDTextEnabled(true);
131 } 128 }
132 129
133 FrameTestHelpers::WebViewHelper m_helper; 130 FrameTestHelpers::WebViewHelper m_helper;
134 }; 131 };
135 132
136 INSTANTIATE_TEST_CASE_P(All, ScrollingCoordinatorTest, ::testing::Bool()); 133 TEST_F(ScrollingCoordinatorTest, fastScrollingByDefault) {
137 134 navigateTo("about:blank");
138 TEST_P(ScrollingCoordinatorTest, fastScrollingByDefault) {
139 webViewImpl()->resize(WebSize(800, 600));
140 loadHTML("<div id='spacer' style='height: 1000px'></div>");
141 forceFullCompositingUpdate(); 135 forceFullCompositingUpdate();
142 136
143 // Make sure the scrolling coordinator is active. 137 // Make sure the scrolling coordinator is active.
144 FrameView* frameView = frame()->view(); 138 FrameView* frameView = frame()->view();
145 Page* page = frame()->page(); 139 Page* page = frame()->page();
146 ASSERT_TRUE(page->scrollingCoordinator()); 140 ASSERT_TRUE(page->scrollingCoordinator());
147 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( 141 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(
148 frameView)); 142 frameView));
149 143
150 // Fast scrolling should be enabled by default. 144 // Fast scrolling should be enabled by default.
151 WebLayer* rootScrollLayer = getRootScrollLayer(); 145 WebLayer* rootScrollLayer = getRootScrollLayer();
152 ASSERT_TRUE(rootScrollLayer);
153 ASSERT_TRUE(rootScrollLayer->scrollable()); 146 ASSERT_TRUE(rootScrollLayer->scrollable());
154 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); 147 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
155 ASSERT_EQ(WebEventListenerProperties::Nothing, 148 ASSERT_EQ(WebEventListenerProperties::Nothing,
156 webLayerTreeView()->eventListenerProperties( 149 webLayerTreeView()->eventListenerProperties(
157 WebEventListenerClass::TouchStartOrMove)); 150 WebEventListenerClass::TouchStartOrMove));
158 ASSERT_EQ(WebEventListenerProperties::Nothing, 151 ASSERT_EQ(WebEventListenerProperties::Nothing,
159 webLayerTreeView()->eventListenerProperties( 152 webLayerTreeView()->eventListenerProperties(
160 WebEventListenerClass::MouseWheel)); 153 WebEventListenerClass::MouseWheel));
161 154
162 WebLayer* innerViewportScrollLayer = 155 WebLayer* innerViewportScrollLayer =
163 page->frameHost().visualViewport().scrollLayer()->platformLayer(); 156 page->frameHost().visualViewport().scrollLayer()->platformLayer();
164 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); 157 ASSERT_TRUE(innerViewportScrollLayer->scrollable());
165 ASSERT_FALSE(innerViewportScrollLayer->shouldScrollOnMainThread()); 158 ASSERT_FALSE(innerViewportScrollLayer->shouldScrollOnMainThread());
166 } 159 }
167 160
168 TEST_P(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { 161 TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) {
169 webViewImpl()->resize(WebSize(800, 600)); 162 navigateTo("about:blank");
170 loadHTML("<div id='spacer' style='height: 1000px'></div>");
171 webViewImpl()->settings()->setThreadedScrollingEnabled(false); 163 webViewImpl()->settings()->setThreadedScrollingEnabled(false);
172 forceFullCompositingUpdate(); 164 forceFullCompositingUpdate();
173 165
174 // Make sure the scrolling coordinator is active. 166 // Make sure the scrolling coordinator is active.
175 FrameView* frameView = frame()->view(); 167 FrameView* frameView = frame()->view();
176 Page* page = frame()->page(); 168 Page* page = frame()->page();
177 ASSERT_TRUE(page->scrollingCoordinator()); 169 ASSERT_TRUE(page->scrollingCoordinator());
178 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( 170 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(
179 frameView)); 171 frameView));
180 172
181 // Main scrolling should be enabled with the setting override. 173 // Main scrolling should be enabled with the setting override.
182 WebLayer* rootScrollLayer = getRootScrollLayer(); 174 WebLayer* rootScrollLayer = getRootScrollLayer();
183 ASSERT_TRUE(rootScrollLayer);
184 ASSERT_TRUE(rootScrollLayer->scrollable()); 175 ASSERT_TRUE(rootScrollLayer->scrollable());
185 ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); 176 ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread());
186 177
187 // Main scrolling should also propagate to inner viewport layer. 178 // Main scrolling should also propagate to inner viewport layer.
188 WebLayer* innerViewportScrollLayer = 179 WebLayer* innerViewportScrollLayer =
189 page->frameHost().visualViewport().scrollLayer()->platformLayer(); 180 page->frameHost().visualViewport().scrollLayer()->platformLayer();
190 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); 181 ASSERT_TRUE(innerViewportScrollLayer->scrollable());
191 ASSERT_TRUE(innerViewportScrollLayer->shouldScrollOnMainThread()); 182 ASSERT_TRUE(innerViewportScrollLayer->shouldScrollOnMainThread());
192 } 183 }
193 184
194 TEST_P(ScrollingCoordinatorTest, fastFractionalScrollingDiv) { 185 TEST_F(ScrollingCoordinatorTest, fastFractionalScrollingDiv) {
195 bool origFractionalOffsetsEnabled = 186 bool origFractionalOffsetsEnabled =
196 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); 187 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled();
197 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); 188 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true);
198 189
199 registerMockedHttpURLLoad("fractional-scroll-div.html"); 190 registerMockedHttpURLLoad("fractional-scroll-div.html");
200 navigateTo(m_baseURL + "fractional-scroll-div.html"); 191 navigateTo(m_baseURL + "fractional-scroll-div.html");
201 forceFullCompositingUpdate(); 192 forceFullCompositingUpdate();
202 193
203 Document* document = frame()->document(); 194 Document* document = frame()->document();
204 Element* scrollableElement = document->getElementById("scroller"); 195 Element* scrollableElement = document->getElementById("scroller");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (!layer->hasCompositedLayerMapping()) 235 if (!layer->hasCompositedLayerMapping())
245 return 0; 236 return 0;
246 CompositedLayerMapping* compositedLayerMapping = 237 CompositedLayerMapping* compositedLayerMapping =
247 layer->compositedLayerMapping(); 238 layer->compositedLayerMapping();
248 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); 239 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
249 if (!graphicsLayer) 240 if (!graphicsLayer)
250 return 0; 241 return 0;
251 return graphicsLayer->platformLayer(); 242 return graphicsLayer->platformLayer();
252 } 243 }
253 244
254 TEST_P(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { 245 TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition) {
255 registerMockedHttpURLLoad("fixed-position.html"); 246 registerMockedHttpURLLoad("fixed-position.html");
256 navigateTo(m_baseURL + "fixed-position.html"); 247 navigateTo(m_baseURL + "fixed-position.html");
257 forceFullCompositingUpdate(); 248 forceFullCompositingUpdate();
258 249
259 // Fixed position should not fall back to main thread scrolling. 250 // Fixed position should not fall back to main thread scrolling.
260 WebLayer* rootScrollLayer = getRootScrollLayer(); 251 WebLayer* rootScrollLayer = getRootScrollLayer();
261 ASSERT_TRUE(rootScrollLayer);
262 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); 252 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
263 253
264 Document* document = frame()->document(); 254 Document* document = frame()->document();
265 { 255 {
266 Element* element = document->getElementById("div-tl"); 256 Element* element = document->getElementById("div-tl");
267 ASSERT_TRUE(element); 257 ASSERT_TRUE(element);
268 WebLayer* layer = webLayerFromElement(element); 258 WebLayer* layer = webLayerFromElement(element);
269 ASSERT_TRUE(layer); 259 ASSERT_TRUE(layer);
270 WebLayerPositionConstraint constraint = layer->positionConstraint(); 260 WebLayerPositionConstraint constraint = layer->positionConstraint();
271 ASSERT_TRUE(constraint.isFixedPosition); 261 ASSERT_TRUE(constraint.isFixedPosition);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 ASSERT_TRUE(element); 327 ASSERT_TRUE(element);
338 WebLayer* layer = webLayerFromElement(element); 328 WebLayer* layer = webLayerFromElement(element);
339 ASSERT_TRUE(layer); 329 ASSERT_TRUE(layer);
340 WebLayerPositionConstraint constraint = layer->positionConstraint(); 330 WebLayerPositionConstraint constraint = layer->positionConstraint();
341 ASSERT_TRUE(constraint.isFixedPosition); 331 ASSERT_TRUE(constraint.isFixedPosition);
342 ASSERT_TRUE(constraint.isFixedToRightEdge && 332 ASSERT_TRUE(constraint.isFixedToRightEdge &&
343 constraint.isFixedToBottomEdge); 333 constraint.isFixedToBottomEdge);
344 } 334 }
345 } 335 }
346 336
347 TEST_P(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { 337 TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) {
348 registerMockedHttpURLLoad("sticky-position.html"); 338 registerMockedHttpURLLoad("sticky-position.html");
349 navigateTo(m_baseURL + "sticky-position.html"); 339 navigateTo(m_baseURL + "sticky-position.html");
350 forceFullCompositingUpdate(); 340 forceFullCompositingUpdate();
351 341
352 // Sticky position should not fall back to main thread scrolling. 342 // Sticky position should not fall back to main thread scrolling.
353 WebLayer* rootScrollLayer = getRootScrollLayer(); 343 WebLayer* rootScrollLayer = getRootScrollLayer();
354 ASSERT_TRUE(rootScrollLayer);
355 EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); 344 EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
356 345
357 Document* document = frame()->document(); 346 Document* document = frame()->document();
358 { 347 {
359 Element* element = document->getElementById("div-tl"); 348 Element* element = document->getElementById("div-tl");
360 ASSERT_TRUE(element); 349 ASSERT_TRUE(element);
361 WebLayer* layer = webLayerFromElement(element); 350 WebLayer* layer = webLayerFromElement(element);
362 ASSERT_TRUE(layer); 351 ASSERT_TRUE(layer);
363 WebLayerStickyPositionConstraint constraint = 352 WebLayerStickyPositionConstraint constraint =
364 layer->stickyPositionConstraint(); 353 layer->stickyPositionConstraint();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 EXPECT_TRUE(constraint.isAnchoredTop); 433 EXPECT_TRUE(constraint.isAnchoredTop);
445 EXPECT_EQ(IntRect(100, 110, 10, 10), 434 EXPECT_EQ(IntRect(100, 110, 10, 10),
446 IntRect(constraint.scrollContainerRelativeStickyBoxRect)); 435 IntRect(constraint.scrollContainerRelativeStickyBoxRect));
447 EXPECT_EQ(IntRect(100, 100, 200, 200), 436 EXPECT_EQ(IntRect(100, 100, 200, 200),
448 IntRect(constraint.scrollContainerRelativeContainingBlockRect)); 437 IntRect(constraint.scrollContainerRelativeContainingBlockRect));
449 EXPECT_EQ(IntPoint(0, 10), 438 EXPECT_EQ(IntPoint(0, 10),
450 IntPoint(constraint.parentRelativeStickyBoxOffset)); 439 IntPoint(constraint.parentRelativeStickyBoxOffset));
451 } 440 }
452 } 441 }
453 442
454 TEST_P(ScrollingCoordinatorTest, touchEventHandler) { 443 TEST_F(ScrollingCoordinatorTest, touchEventHandler) {
455 registerMockedHttpURLLoad("touch-event-handler.html"); 444 registerMockedHttpURLLoad("touch-event-handler.html");
456 navigateTo(m_baseURL + "touch-event-handler.html"); 445 navigateTo(m_baseURL + "touch-event-handler.html");
457 forceFullCompositingUpdate(); 446 forceFullCompositingUpdate();
458 447
459 ASSERT_EQ(WebEventListenerProperties::Blocking, 448 ASSERT_EQ(WebEventListenerProperties::Blocking,
460 webLayerTreeView()->eventListenerProperties( 449 webLayerTreeView()->eventListenerProperties(
461 WebEventListenerClass::TouchStartOrMove)); 450 WebEventListenerClass::TouchStartOrMove));
462 } 451 }
463 452
464 TEST_P(ScrollingCoordinatorTest, touchEventHandlerPassive) { 453 TEST_F(ScrollingCoordinatorTest, touchEventHandlerPassive) {
465 registerMockedHttpURLLoad("touch-event-handler-passive.html"); 454 registerMockedHttpURLLoad("touch-event-handler-passive.html");
466 navigateTo(m_baseURL + "touch-event-handler-passive.html"); 455 navigateTo(m_baseURL + "touch-event-handler-passive.html");
467 forceFullCompositingUpdate(); 456 forceFullCompositingUpdate();
468 457
469 ASSERT_EQ(WebEventListenerProperties::Passive, 458 ASSERT_EQ(WebEventListenerProperties::Passive,
470 webLayerTreeView()->eventListenerProperties( 459 webLayerTreeView()->eventListenerProperties(
471 WebEventListenerClass::TouchStartOrMove)); 460 WebEventListenerClass::TouchStartOrMove));
472 } 461 }
473 462
474 TEST_P(ScrollingCoordinatorTest, touchEventHandlerBoth) { 463 TEST_F(ScrollingCoordinatorTest, touchEventHandlerBoth) {
475 registerMockedHttpURLLoad("touch-event-handler-both.html"); 464 registerMockedHttpURLLoad("touch-event-handler-both.html");
476 navigateTo(m_baseURL + "touch-event-handler-both.html"); 465 navigateTo(m_baseURL + "touch-event-handler-both.html");
477 forceFullCompositingUpdate(); 466 forceFullCompositingUpdate();
478 467
479 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, 468 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive,
480 webLayerTreeView()->eventListenerProperties( 469 webLayerTreeView()->eventListenerProperties(
481 WebEventListenerClass::TouchStartOrMove)); 470 WebEventListenerClass::TouchStartOrMove));
482 } 471 }
483 472
484 TEST_P(ScrollingCoordinatorTest, wheelEventHandler) { 473 TEST_F(ScrollingCoordinatorTest, wheelEventHandler) {
485 registerMockedHttpURLLoad("wheel-event-handler.html"); 474 registerMockedHttpURLLoad("wheel-event-handler.html");
486 navigateTo(m_baseURL + "wheel-event-handler.html"); 475 navigateTo(m_baseURL + "wheel-event-handler.html");
487 forceFullCompositingUpdate(); 476 forceFullCompositingUpdate();
488 477
489 ASSERT_EQ(WebEventListenerProperties::Blocking, 478 ASSERT_EQ(WebEventListenerProperties::Blocking,
490 webLayerTreeView()->eventListenerProperties( 479 webLayerTreeView()->eventListenerProperties(
491 WebEventListenerClass::MouseWheel)); 480 WebEventListenerClass::MouseWheel));
492 } 481 }
493 482
494 TEST_P(ScrollingCoordinatorTest, wheelEventHandlerPassive) { 483 TEST_F(ScrollingCoordinatorTest, wheelEventHandlerPassive) {
495 registerMockedHttpURLLoad("wheel-event-handler-passive.html"); 484 registerMockedHttpURLLoad("wheel-event-handler-passive.html");
496 navigateTo(m_baseURL + "wheel-event-handler-passive.html"); 485 navigateTo(m_baseURL + "wheel-event-handler-passive.html");
497 forceFullCompositingUpdate(); 486 forceFullCompositingUpdate();
498 487
499 ASSERT_EQ(WebEventListenerProperties::Passive, 488 ASSERT_EQ(WebEventListenerProperties::Passive,
500 webLayerTreeView()->eventListenerProperties( 489 webLayerTreeView()->eventListenerProperties(
501 WebEventListenerClass::MouseWheel)); 490 WebEventListenerClass::MouseWheel));
502 } 491 }
503 492
504 TEST_P(ScrollingCoordinatorTest, wheelEventHandlerBoth) { 493 TEST_F(ScrollingCoordinatorTest, wheelEventHandlerBoth) {
505 registerMockedHttpURLLoad("wheel-event-handler-both.html"); 494 registerMockedHttpURLLoad("wheel-event-handler-both.html");
506 navigateTo(m_baseURL + "wheel-event-handler-both.html"); 495 navigateTo(m_baseURL + "wheel-event-handler-both.html");
507 forceFullCompositingUpdate(); 496 forceFullCompositingUpdate();
508 497
509 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, 498 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive,
510 webLayerTreeView()->eventListenerProperties( 499 webLayerTreeView()->eventListenerProperties(
511 WebEventListenerClass::MouseWheel)); 500 WebEventListenerClass::MouseWheel));
512 } 501 }
513 502
514 TEST_P(ScrollingCoordinatorTest, scrollEventHandler) { 503 TEST_F(ScrollingCoordinatorTest, scrollEventHandler) {
515 registerMockedHttpURLLoad("scroll-event-handler.html"); 504 registerMockedHttpURLLoad("scroll-event-handler.html");
516 navigateTo(m_baseURL + "scroll-event-handler.html"); 505 navigateTo(m_baseURL + "scroll-event-handler.html");
517 forceFullCompositingUpdate(); 506 forceFullCompositingUpdate();
518 507
519 ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers()); 508 ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers());
520 } 509 }
521 510
522 TEST_P(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { 511 TEST_F(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) {
523 registerMockedHttpURLLoad("scroll-event-handler-window.html"); 512 registerMockedHttpURLLoad("scroll-event-handler-window.html");
524 navigateTo(m_baseURL + "scroll-event-handler-window.html"); 513 navigateTo(m_baseURL + "scroll-event-handler-window.html");
525 forceFullCompositingUpdate(); 514 forceFullCompositingUpdate();
526 515
527 // Simulate detaching the document from its DOM window. This should not 516 // Simulate detaching the document from its DOM window. This should not
528 // cause a crash when the WebViewImpl is closed by the test runner. 517 // cause a crash when the WebViewImpl is closed by the test runner.
529 frame()->document()->shutdown(); 518 frame()->document()->shutdown();
530 } 519 }
531 520
532 TEST_P(ScrollingCoordinatorTest, clippedBodyTest) { 521 TEST_F(ScrollingCoordinatorTest, clippedBodyTest) {
533 registerMockedHttpURLLoad("clipped-body.html"); 522 registerMockedHttpURLLoad("clipped-body.html");
534 navigateTo(m_baseURL + "clipped-body.html"); 523 navigateTo(m_baseURL + "clipped-body.html");
535 forceFullCompositingUpdate(); 524 forceFullCompositingUpdate();
536 525
537 WebLayer* rootScrollLayer = getRootScrollLayer(); 526 WebLayer* rootScrollLayer = getRootScrollLayer();
538 ASSERT_TRUE(rootScrollLayer);
539 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); 527 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size());
540 } 528 }
541 529
542 TEST_P(ScrollingCoordinatorTest, overflowScrolling) { 530 TEST_F(ScrollingCoordinatorTest, overflowScrolling) {
543 registerMockedHttpURLLoad("overflow-scrolling.html"); 531 registerMockedHttpURLLoad("overflow-scrolling.html");
544 navigateTo(m_baseURL + "overflow-scrolling.html"); 532 navigateTo(m_baseURL + "overflow-scrolling.html");
545 forceFullCompositingUpdate(); 533 forceFullCompositingUpdate();
546 534
547 // Verify the properties of the accelerated scrolling element starting from 535 // Verify the properties of the accelerated scrolling element starting from
548 // the LayoutObject all the way to the WebLayer. 536 // the LayoutObject all the way to the WebLayer.
549 Element* scrollableElement = 537 Element* scrollableElement =
550 frame()->document()->getElementById("scrollable"); 538 frame()->document()->getElementById("scrollable");
551 DCHECK(scrollableElement); 539 DCHECK(scrollableElement);
552 540
(...skipping 25 matching lines...) Expand all
578 // Now verify we've attached impl-side scrollbars onto the scrollbar layers 566 // Now verify we've attached impl-side scrollbars onto the scrollbar layers
579 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); 567 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar());
580 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar() 568 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()
581 ->hasContentsLayer()); 569 ->hasContentsLayer());
582 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); 570 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar());
583 ASSERT_TRUE( 571 ASSERT_TRUE(
584 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); 572 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer());
585 #endif 573 #endif
586 } 574 }
587 575
588 TEST_P(ScrollingCoordinatorTest, overflowHidden) { 576 TEST_F(ScrollingCoordinatorTest, overflowHidden) {
589 registerMockedHttpURLLoad("overflow-hidden.html"); 577 registerMockedHttpURLLoad("overflow-hidden.html");
590 navigateTo(m_baseURL + "overflow-hidden.html"); 578 navigateTo(m_baseURL + "overflow-hidden.html");
591 forceFullCompositingUpdate(); 579 forceFullCompositingUpdate();
592 580
593 // Verify the properties of the accelerated scrolling element starting from 581 // Verify the properties of the accelerated scrolling element starting from
594 // the LayoutObject all the way to the WebLayer. 582 // the LayoutObject all the way to the WebLayer.
595 Element* overflowElement = 583 Element* overflowElement =
596 frame()->document()->getElementById("unscrollable-y"); 584 frame()->document()->getElementById("unscrollable-y");
597 DCHECK(overflowElement); 585 DCHECK(overflowElement);
598 586
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 ASSERT_EQ(box->layer()->getScrollableArea(), 627 ASSERT_EQ(box->layer()->getScrollableArea(),
640 graphicsLayer->getScrollableArea()); 628 graphicsLayer->getScrollableArea());
641 629
642 webScrollLayer = 630 webScrollLayer =
643 compositedLayerMapping->scrollingContentsLayer()->platformLayer(); 631 compositedLayerMapping->scrollingContentsLayer()->platformLayer();
644 ASSERT_TRUE(webScrollLayer->scrollable()); 632 ASSERT_TRUE(webScrollLayer->scrollable());
645 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); 633 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal());
646 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 634 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
647 } 635 }
648 636
649 TEST_P(ScrollingCoordinatorTest, iframeScrolling) { 637 TEST_F(ScrollingCoordinatorTest, iframeScrolling) {
650 registerMockedHttpURLLoad("iframe-scrolling.html"); 638 registerMockedHttpURLLoad("iframe-scrolling.html");
651 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); 639 registerMockedHttpURLLoad("iframe-scrolling-inner.html");
652 navigateTo(m_baseURL + "iframe-scrolling.html"); 640 navigateTo(m_baseURL + "iframe-scrolling.html");
653 forceFullCompositingUpdate(); 641 forceFullCompositingUpdate();
654 642
655 // Verify the properties of the accelerated scrolling element starting from 643 // Verify the properties of the accelerated scrolling element starting from
656 // the LayoutObject all the way to the WebLayer. 644 // the LayoutObject all the way to the WebLayer.
657 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); 645 Element* scrollableFrame = frame()->document()->getElementById("scrollable");
658 ASSERT_TRUE(scrollableFrame); 646 ASSERT_TRUE(scrollableFrame);
659 647
660 LayoutObject* layoutObject = scrollableFrame->layoutObject(); 648 LayoutObject* layoutObject = scrollableFrame->layoutObject();
661 ASSERT_TRUE(layoutObject); 649 ASSERT_TRUE(layoutObject);
662 ASSERT_TRUE(layoutObject->isLayoutPart()); 650 ASSERT_TRUE(layoutObject->isLayoutPart());
663 651
664 LayoutPart* layoutPart = toLayoutPart(layoutObject); 652 LayoutPart* layoutPart = toLayoutPart(layoutObject);
665 ASSERT_TRUE(layoutPart); 653 ASSERT_TRUE(layoutPart);
666 ASSERT_TRUE(layoutPart->widget()); 654 ASSERT_TRUE(layoutPart->widget());
667 ASSERT_TRUE(layoutPart->widget()->isFrameView()); 655 ASSERT_TRUE(layoutPart->widget()->isFrameView());
668 656
669 FrameView* innerFrameView = toFrameView(layoutPart->widget()); 657 FrameView* innerFrameView = toFrameView(layoutPart->widget());
670 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); 658 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem();
671 ASSERT_FALSE(innerLayoutViewItem.isNull()); 659 ASSERT_FALSE(innerLayoutViewItem.isNull());
672 660
673 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); 661 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor();
674 ASSERT_TRUE(innerCompositor->inCompositingMode()); 662 ASSERT_TRUE(innerCompositor->inCompositingMode());
663 ASSERT_TRUE(innerCompositor->scrollLayer());
675 664
676 GraphicsLayer* scrollLayer = 665 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer();
677 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); 666 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea());
678 ASSERT_TRUE(scrollLayer);
679 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(),
680 scrollLayer->getScrollableArea());
681 667
682 WebLayer* webScrollLayer = scrollLayer->platformLayer(); 668 WebLayer* webScrollLayer = scrollLayer->platformLayer();
683 ASSERT_TRUE(webScrollLayer->scrollable()); 669 ASSERT_TRUE(webScrollLayer->scrollable());
684 670
685 #if OS(ANDROID) 671 #if OS(ANDROID)
686 // Now verify we've attached impl-side scrollbars onto the scrollbar layers 672 // Now verify we've attached impl-side scrollbars onto the scrollbar layers
687 ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar()); 673 ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar());
688 ASSERT_TRUE( 674 ASSERT_TRUE(
689 innerCompositor->layerForHorizontalScrollbar()->hasContentsLayer()); 675 innerCompositor->layerForHorizontalScrollbar()->hasContentsLayer());
690 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); 676 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar());
691 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); 677 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer());
692 #endif 678 #endif
693 } 679 }
694 680
695 TEST_P(ScrollingCoordinatorTest, rtlIframe) { 681 TEST_F(ScrollingCoordinatorTest, rtlIframe) {
696 registerMockedHttpURLLoad("rtl-iframe.html"); 682 registerMockedHttpURLLoad("rtl-iframe.html");
697 registerMockedHttpURLLoad("rtl-iframe-inner.html"); 683 registerMockedHttpURLLoad("rtl-iframe-inner.html");
698 navigateTo(m_baseURL + "rtl-iframe.html"); 684 navigateTo(m_baseURL + "rtl-iframe.html");
699 forceFullCompositingUpdate(); 685 forceFullCompositingUpdate();
700 686
701 // Verify the properties of the accelerated scrolling element starting from 687 // Verify the properties of the accelerated scrolling element starting from
702 // the LayoutObject all the way to the WebLayer. 688 // the LayoutObject all the way to the WebLayer.
703 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); 689 Element* scrollableFrame = frame()->document()->getElementById("scrollable");
704 ASSERT_TRUE(scrollableFrame); 690 ASSERT_TRUE(scrollableFrame);
705 691
706 LayoutObject* layoutObject = scrollableFrame->layoutObject(); 692 LayoutObject* layoutObject = scrollableFrame->layoutObject();
707 ASSERT_TRUE(layoutObject); 693 ASSERT_TRUE(layoutObject);
708 ASSERT_TRUE(layoutObject->isLayoutPart()); 694 ASSERT_TRUE(layoutObject->isLayoutPart());
709 695
710 LayoutPart* layoutPart = toLayoutPart(layoutObject); 696 LayoutPart* layoutPart = toLayoutPart(layoutObject);
711 ASSERT_TRUE(layoutPart); 697 ASSERT_TRUE(layoutPart);
712 ASSERT_TRUE(layoutPart->widget()); 698 ASSERT_TRUE(layoutPart->widget());
713 ASSERT_TRUE(layoutPart->widget()->isFrameView()); 699 ASSERT_TRUE(layoutPart->widget()->isFrameView());
714 700
715 FrameView* innerFrameView = toFrameView(layoutPart->widget()); 701 FrameView* innerFrameView = toFrameView(layoutPart->widget());
716 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); 702 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem();
717 ASSERT_FALSE(innerLayoutViewItem.isNull()); 703 ASSERT_FALSE(innerLayoutViewItem.isNull());
718 704
719 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); 705 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor();
720 ASSERT_TRUE(innerCompositor->inCompositingMode()); 706 ASSERT_TRUE(innerCompositor->inCompositingMode());
707 ASSERT_TRUE(innerCompositor->scrollLayer());
721 708
722 GraphicsLayer* scrollLayer = 709 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer();
723 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); 710 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea());
724 ASSERT_TRUE(scrollLayer);
725 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(),
726 scrollLayer->getScrollableArea());
727 711
728 WebLayer* webScrollLayer = scrollLayer->platformLayer(); 712 WebLayer* webScrollLayer = scrollLayer->platformLayer();
729 ASSERT_TRUE(webScrollLayer->scrollable()); 713 ASSERT_TRUE(webScrollLayer->scrollable());
730 714
731 int expectedScrollPosition = 715 int expectedScrollPosition =
732 958 + (innerFrameView->layoutViewportScrollableArea() 716 958 +
733 ->verticalScrollbar() 717 (innerFrameView->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15);
734 ->isOverlayScrollbar()
735 ? 0
736 : 15);
737 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x); 718 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x);
738 } 719 }
739 720
740 TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { 721 TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) {
741 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); 722 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html");
742 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); 723 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html");
743 forceFullCompositingUpdate(); 724 forceFullCompositingUpdate();
744 // This test document setup an iframe with scrollbars, then switch to 725 // This test document setup an iframe with scrollbars, then switch to
745 // an empty document by javascript. 726 // an empty document by javascript.
746 } 727 }
747 728
748 TEST_P(ScrollingCoordinatorTest, 729 TEST_F(ScrollingCoordinatorTest,
749 scrollbarsForceMainThreadOrHaveWebScrollbarLayer) { 730 scrollbarsForceMainThreadOrHaveWebScrollbarLayer) {
750 registerMockedHttpURLLoad("trivial-scroller.html"); 731 registerMockedHttpURLLoad("trivial-scroller.html");
751 navigateTo(m_baseURL + "trivial-scroller.html"); 732 navigateTo(m_baseURL + "trivial-scroller.html");
752 forceFullCompositingUpdate(); 733 forceFullCompositingUpdate();
753 734
754 Document* document = frame()->document(); 735 Document* document = frame()->document();
755 Element* scrollableElement = document->getElementById("scroller"); 736 Element* scrollableElement = document->getElementById("scroller");
756 DCHECK(scrollableElement); 737 DCHECK(scrollableElement);
757 738
758 LayoutObject* layoutObject = scrollableElement->layoutObject(); 739 LayoutObject* layoutObject = scrollableElement->layoutObject();
759 ASSERT_TRUE(layoutObject->isBox()); 740 ASSERT_TRUE(layoutObject->isBox());
760 LayoutBox* box = toLayoutBox(layoutObject); 741 LayoutBox* box = toLayoutBox(layoutObject);
761 ASSERT_TRUE(box->usesCompositedScrolling()); 742 ASSERT_TRUE(box->usesCompositedScrolling());
762 CompositedLayerMapping* compositedLayerMapping = 743 CompositedLayerMapping* compositedLayerMapping =
763 box->layer()->compositedLayerMapping(); 744 box->layer()->compositedLayerMapping();
764 GraphicsLayer* scrollbarGraphicsLayer = 745 GraphicsLayer* scrollbarGraphicsLayer =
765 compositedLayerMapping->layerForVerticalScrollbar(); 746 compositedLayerMapping->layerForVerticalScrollbar();
766 ASSERT_TRUE(scrollbarGraphicsLayer); 747 ASSERT_TRUE(scrollbarGraphicsLayer);
767 748
768 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent(); 749 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent();
769 ASSERT_TRUE( 750 ASSERT_TRUE(
770 hasWebScrollbarLayer || 751 hasWebScrollbarLayer ||
771 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); 752 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread());
772 } 753 }
773 754
774 #if OS(MACOSX) || OS(ANDROID) 755 #if OS(MACOSX) || OS(ANDROID)
775 TEST_P(ScrollingCoordinatorTest, 756 TEST_F(ScrollingCoordinatorTest,
776 DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque) 757 DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque)
777 #else 758 #else
778 TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) 759 TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque)
779 #endif 760 #endif
780 { 761 {
781 registerMockedHttpURLLoad("wide_document.html"); 762 registerMockedHttpURLLoad("wide_document.html");
782 navigateTo(m_baseURL + "wide_document.html"); 763 navigateTo(m_baseURL + "wide_document.html");
783 forceFullCompositingUpdate(); 764 forceFullCompositingUpdate();
784 765
785 FrameView* frameView = frame()->view(); 766 FrameView* frameView = frame()->view();
786 ASSERT_TRUE(frameView); 767 ASSERT_TRUE(frameView);
787 768
788 GraphicsLayer* scrollbarGraphicsLayer = 769 GraphicsLayer* scrollbarGraphicsLayer =
789 frameView->layoutViewportScrollableArea()->layerForHorizontalScrollbar(); 770 frameView->layerForHorizontalScrollbar();
790 ASSERT_TRUE(scrollbarGraphicsLayer); 771 ASSERT_TRUE(scrollbarGraphicsLayer);
791 772
792 WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer(); 773 WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer();
793 ASSERT_TRUE(platformLayer); 774 ASSERT_TRUE(platformLayer);
794 775
795 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer(); 776 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer();
796 ASSERT_TRUE(contentsLayer); 777 ASSERT_TRUE(contentsLayer);
797 778
798 // After scrollableAreaScrollbarLayerDidChange, 779 // After scrollableAreaScrollbarLayerDidChange,
799 // if the main frame's scrollbarLayer is opaque, 780 // if the main frame's scrollbarLayer is opaque,
800 // contentsLayer should be opaque too. 781 // contentsLayer should be opaque too.
801 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque()); 782 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque());
802 } 783 }
803 784
804 TEST_P(ScrollingCoordinatorTest, 785 TEST_F(ScrollingCoordinatorTest,
805 FixedPositionLosingBackingShouldTriggerMainThreadScroll) { 786 FixedPositionLosingBackingShouldTriggerMainThreadScroll) {
806 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); 787 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false);
807 registerMockedHttpURLLoad("fixed-position-losing-backing.html"); 788 registerMockedHttpURLLoad("fixed-position-losing-backing.html");
808 navigateTo(m_baseURL + "fixed-position-losing-backing.html"); 789 navigateTo(m_baseURL + "fixed-position-losing-backing.html");
809 forceFullCompositingUpdate(); 790 forceFullCompositingUpdate();
810 791
811 WebLayer* scrollLayer = getRootScrollLayer(); 792 WebLayer* scrollLayer = frame()
812 ASSERT_TRUE(scrollLayer); 793 ->page()
813 794 ->deprecatedLocalMainFrame()
795 ->view()
796 ->layerForScrolling()
797 ->platformLayer();
814 Document* document = frame()->document(); 798 Document* document = frame()->document();
815 Element* fixedPos = document->getElementById("fixed"); 799 Element* fixedPos = document->getElementById("fixed");
816 800
817 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) 801 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())
818 ->layer() 802 ->layer()
819 ->hasCompositedLayerMapping()); 803 ->hasCompositedLayerMapping());
820 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread()); 804 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread());
821 805
822 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone); 806 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone);
823 forceFullCompositingUpdate(); 807 forceFullCompositingUpdate();
824 808
825 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) 809 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())
826 ->layer() 810 ->layer()
827 ->hasCompositedLayerMapping()); 811 ->hasCompositedLayerMapping());
828 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); 812 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread());
829 } 813 }
830 814
831 TEST_P(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { 815 TEST_F(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) {
832 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); 816 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true);
833 webViewImpl()->setDeviceScaleFactor(2.f); 817 webViewImpl()->setDeviceScaleFactor(2.f);
834 registerMockedHttpURLLoad("custom_scrollbar.html"); 818 registerMockedHttpURLLoad("custom_scrollbar.html");
835 navigateTo(m_baseURL + "custom_scrollbar.html"); 819 navigateTo(m_baseURL + "custom_scrollbar.html");
836 forceFullCompositingUpdate(); 820 forceFullCompositingUpdate();
837 821
838 Document* document = frame()->document(); 822 Document* document = frame()->document();
839 Element* container = document->getElementById("container"); 823 Element* container = document->getElementById("container");
840 Element* content = document->getElementById("content"); 824 Element* content = document->getElementById("content");
841 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar"); 825 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar");
(...skipping 20 matching lines...) Expand all
862 container->removeAttribute("class"); 846 container->removeAttribute("class");
863 forceFullCompositingUpdate(); 847 forceFullCompositingUpdate();
864 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); 848 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar();
865 ASSERT_FALSE( 849 ASSERT_FALSE(
866 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); 850 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread());
867 ASSERT_FALSE( 851 ASSERT_FALSE(
868 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & 852 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() &
869 MainThreadScrollingReason::kCustomScrollbarScrolling); 853 MainThreadScrollingReason::kCustomScrollbarScrolling);
870 } 854 }
871 855
872 TEST_P(ScrollingCoordinatorTest, 856 TEST_F(ScrollingCoordinatorTest,
873 BackgroundAttachmentFixedShouldTriggerMainThreadScroll) { 857 BackgroundAttachmentFixedShouldTriggerMainThreadScroll) {
874 registerMockedHttpURLLoad("iframe-background-attachment-fixed.html"); 858 registerMockedHttpURLLoad("iframe-background-attachment-fixed.html");
875 registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html"); 859 registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html");
876 registerMockedHttpURLLoad("white-1x1.png"); 860 registerMockedHttpURLLoad("white-1x1.png");
877 navigateTo(m_baseURL + "iframe-background-attachment-fixed.html"); 861 navigateTo(m_baseURL + "iframe-background-attachment-fixed.html");
878 forceFullCompositingUpdate(); 862 forceFullCompositingUpdate();
879 863
880 Element* iframe = frame()->document()->getElementById("iframe"); 864 Element* iframe = frame()->document()->getElementById("iframe");
881 ASSERT_TRUE(iframe); 865 ASSERT_TRUE(iframe);
882 866
883 LayoutObject* layoutObject = iframe->layoutObject(); 867 LayoutObject* layoutObject = iframe->layoutObject();
884 ASSERT_TRUE(layoutObject); 868 ASSERT_TRUE(layoutObject);
885 ASSERT_TRUE(layoutObject->isLayoutPart()); 869 ASSERT_TRUE(layoutObject->isLayoutPart());
886 870
887 LayoutPart* layoutPart = toLayoutPart(layoutObject); 871 LayoutPart* layoutPart = toLayoutPart(layoutObject);
888 ASSERT_TRUE(layoutPart); 872 ASSERT_TRUE(layoutPart);
889 ASSERT_TRUE(layoutPart->widget()); 873 ASSERT_TRUE(layoutPart->widget());
890 ASSERT_TRUE(layoutPart->widget()->isFrameView()); 874 ASSERT_TRUE(layoutPart->widget()->isFrameView());
891 875
892 FrameView* innerFrameView = toFrameView(layoutPart->widget()); 876 FrameView* innerFrameView = toFrameView(layoutPart->widget());
893 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); 877 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem();
894 ASSERT_FALSE(innerLayoutViewItem.isNull()); 878 ASSERT_FALSE(innerLayoutViewItem.isNull());
895 879
896 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); 880 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor();
897 ASSERT_TRUE(innerCompositor->inCompositingMode()); 881 ASSERT_TRUE(innerCompositor->inCompositingMode());
882 ASSERT_TRUE(innerCompositor->scrollLayer());
898 883
899 GraphicsLayer* scrollLayer = 884 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer();
900 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); 885 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea());
901 ASSERT_TRUE(scrollLayer);
902 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(),
903 scrollLayer->getScrollableArea());
904 886
905 WebLayer* webScrollLayer = scrollLayer->platformLayer(); 887 WebLayer* webScrollLayer = scrollLayer->platformLayer();
906 ASSERT_TRUE(webScrollLayer->scrollable()); 888 ASSERT_TRUE(webScrollLayer->scrollable());
907 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & 889 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() &
908 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
909 891
910 // Remove fixed background-attachment should make the iframe 892 // Remove fixed background-attachment should make the iframe
911 // scroll on cc. 893 // scroll on cc.
912 auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument(); 894 auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument();
913 iframe = iframeDoc->getElementById("scrollable"); 895 iframe = iframeDoc->getElementById("scrollable");
914 ASSERT_TRUE(iframe); 896 ASSERT_TRUE(iframe);
915 897
916 iframe->removeAttribute("class"); 898 iframe->removeAttribute("class");
917 forceFullCompositingUpdate(); 899 forceFullCompositingUpdate();
918 900
919 layoutObject = iframe->layoutObject(); 901 layoutObject = iframe->layoutObject();
920 ASSERT_TRUE(layoutObject); 902 ASSERT_TRUE(layoutObject);
921 903
922 scrollLayer = layoutObject->frameView() 904 scrollLayer = layoutObject->frameView()->layerForScrolling();
923 ->layoutViewportScrollableArea()
924 ->layerForScrolling();
925 ASSERT_TRUE(scrollLayer); 905 ASSERT_TRUE(scrollLayer);
926 906
927 webScrollLayer = scrollLayer->platformLayer(); 907 webScrollLayer = scrollLayer->platformLayer();
928 ASSERT_TRUE(webScrollLayer->scrollable()); 908 ASSERT_TRUE(webScrollLayer->scrollable());
929 ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() & 909 ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() &
930 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 910 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
931 911
932 // Force main frame to scroll on main thread. All its descendants 912 // Force main frame to scroll on main thread. All its descendants
933 // should scroll on main thread as well. 913 // should scroll on main thread as well.
934 Element* element = frame()->document()->getElementById("scrollable"); 914 Element* element = frame()->document()->getElementById("scrollable");
935 element->setAttribute( 915 element->setAttribute(
936 "style", 916 "style",
937 "background-image: url('white-1x1.png'); background-attachment: fixed;", 917 "background-image: url('white-1x1.png'); background-attachment: fixed;",
938 ASSERT_NO_EXCEPTION); 918 ASSERT_NO_EXCEPTION);
939 919
940 forceFullCompositingUpdate(); 920 forceFullCompositingUpdate();
941 921
942 layoutObject = iframe->layoutObject(); 922 layoutObject = iframe->layoutObject();
943 ASSERT_TRUE(layoutObject); 923 ASSERT_TRUE(layoutObject);
944 924
945 scrollLayer = layoutObject->frameView() 925 scrollLayer = layoutObject->frameView()->layerForScrolling();
946 ->layoutViewportScrollableArea()
947 ->layerForScrolling();
948 ASSERT_TRUE(scrollLayer); 926 ASSERT_TRUE(scrollLayer);
949 927
950 webScrollLayer = scrollLayer->platformLayer(); 928 webScrollLayer = scrollLayer->platformLayer();
951 ASSERT_TRUE(webScrollLayer->scrollable()); 929 ASSERT_TRUE(webScrollLayer->scrollable());
952 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & 930 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() &
953 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 931 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
954 } 932 }
955 933
956 // Upon resizing the content size, the main thread scrolling reason 934 // Upon resizing the content size, the main thread scrolling reason
957 // kHasNonLayerViewportConstrainedObject should be updated on all frames 935 // kHasNonLayerViewportConstrainedObject should be updated on all frames
958 TEST_P(ScrollingCoordinatorTest, 936 TEST_F(ScrollingCoordinatorTest,
959 RecalculateMainThreadScrollingReasonsUponResize) { 937 RecalculateMainThreadScrollingReasonsUponResize) {
960 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); 938 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false);
961 registerMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); 939 registerMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html");
962 navigateTo(m_baseURL + "has-non-layer-viewport-constrained-objects.html"); 940 navigateTo(m_baseURL + "has-non-layer-viewport-constrained-objects.html");
963 forceFullCompositingUpdate(); 941 forceFullCompositingUpdate();
964 942
965 LOG(ERROR) << frame()->view()->mainThreadScrollingReasons(); 943 LOG(ERROR) << frame()->view()->mainThreadScrollingReasons();
966 Element* element = frame()->document()->getElementById("scrollable"); 944 Element* element = frame()->document()->getElementById("scrollable");
967 ASSERT_TRUE(element); 945 ASSERT_TRUE(element);
968 946
969 LayoutObject* layoutObject = element->layoutObject(); 947 LayoutObject* layoutObject = element->layoutObject();
970 ASSERT_TRUE(layoutObject); 948 ASSERT_TRUE(layoutObject);
971 949
972 GraphicsLayer* scrollLayer = layoutObject->frameView() 950 GraphicsLayer* scrollLayer = layoutObject->frameView()->layerForScrolling();
973 ->layoutViewportScrollableArea() 951 ASSERT_TRUE(scrollLayer);
974 ->layerForScrolling();
975 WebLayer* webScrollLayer;
976 952
977 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 953 WebLayer* webScrollLayer = scrollLayer->platformLayer();
978 // When RLS is enabled, the LayoutView won't have a scrolling contents 954 ASSERT_TRUE(webScrollLayer->scrollable());
979 // because it does not overflow. 955 ASSERT_FALSE(
980 ASSERT_FALSE(scrollLayer); 956 webScrollLayer->mainThreadScrollingReasons() &
981 } else { 957 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
982 ASSERT_TRUE(scrollLayer); 958
983 webScrollLayer = scrollLayer->platformLayer(); 959 Element* iframe = frame()->document()->getElementById("iframe");
984 ASSERT_TRUE(webScrollLayer->scrollable()); 960 ASSERT_TRUE(iframe);
985 ASSERT_FALSE( 961
986 webScrollLayer->mainThreadScrollingReasons() & 962 layoutObject = iframe->layoutObject();
987 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); 963 ASSERT_TRUE(layoutObject);
988 } 964
965 scrollLayer = layoutObject->frameView()->layerForScrolling();
966 ASSERT_TRUE(scrollLayer);
967
968 webScrollLayer = scrollLayer->platformLayer();
969 ASSERT_TRUE(webScrollLayer->scrollable());
970 ASSERT_FALSE(
971 webScrollLayer->mainThreadScrollingReasons() &
972 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
989 973
990 // When the div becomes to scrollable it should scroll on main thread 974 // When the div becomes to scrollable it should scroll on main thread
991 element->setAttribute("style", 975 element->setAttribute("style",
992 "overflow:scroll;height:2000px;will-change:transform;", 976 "overflow:scroll;height:2000px;will-change:transform;",
993 ASSERT_NO_EXCEPTION); 977 ASSERT_NO_EXCEPTION);
994 forceFullCompositingUpdate(); 978 forceFullCompositingUpdate();
995 979
996 layoutObject = element->layoutObject(); 980 layoutObject = element->layoutObject();
997 ASSERT_TRUE(layoutObject); 981 ASSERT_TRUE(layoutObject);
998 982
999 scrollLayer = layoutObject->frameView() 983 scrollLayer = layoutObject->frameView()->layerForScrolling();
1000 ->layoutViewportScrollableArea()
1001 ->layerForScrolling();
1002 ASSERT_TRUE(scrollLayer); 984 ASSERT_TRUE(scrollLayer);
1003 985
1004 webScrollLayer = scrollLayer->platformLayer(); 986 webScrollLayer = scrollLayer->platformLayer();
987 ASSERT_TRUE(webScrollLayer->scrollable());
988 ASSERT_TRUE(
989 webScrollLayer->mainThreadScrollingReasons() &
990 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
991
992 layoutObject = iframe->layoutObject();
993 ASSERT_TRUE(layoutObject);
994
995 scrollLayer = layoutObject->frameView()->layerForScrolling();
996 ASSERT_TRUE(scrollLayer);
997
998 webScrollLayer = scrollLayer->platformLayer();
1005 ASSERT_TRUE(webScrollLayer->scrollable()); 999 ASSERT_TRUE(webScrollLayer->scrollable());
1006 ASSERT_TRUE( 1000 ASSERT_TRUE(
1007 webScrollLayer->mainThreadScrollingReasons() & 1001 webScrollLayer->mainThreadScrollingReasons() &
1008 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); 1002 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
1009 1003
1010 // The main thread scrolling reason should be reset upon the following change 1004 // The main thread scrolling reason should be reset upon the following change
1011 element->setAttribute("style", 1005 element->setAttribute("style",
1012 "overflow:scroll;height:200px;will-change:transform;", 1006 "overflow:scroll;height:200px;will-change:transform;",
1013 ASSERT_NO_EXCEPTION); 1007 ASSERT_NO_EXCEPTION);
1014 forceFullCompositingUpdate(); 1008 forceFullCompositingUpdate();
1015 1009
1016 layoutObject = element->layoutObject(); 1010 layoutObject = element->layoutObject();
1017 ASSERT_TRUE(layoutObject); 1011 ASSERT_TRUE(layoutObject);
1018 1012
1019 scrollLayer = layoutObject->frameView() 1013 scrollLayer = layoutObject->frameView()->layerForScrolling();
1020 ->layoutViewportScrollableArea() 1014 ASSERT_TRUE(scrollLayer);
1021 ->layerForScrolling(); 1015
1022 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 1016 webScrollLayer = scrollLayer->platformLayer();
1023 // When RLS is enabled, the LayoutView won't have a scrolling contents 1017 ASSERT_TRUE(webScrollLayer->scrollable());
1024 // because it does not overflow. 1018 ASSERT_FALSE(
1025 ASSERT_FALSE(scrollLayer); 1019 webScrollLayer->mainThreadScrollingReasons() &
1026 } else { 1020 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
1027 ASSERT_TRUE(scrollLayer); 1021
1028 webScrollLayer = scrollLayer->platformLayer(); 1022 layoutObject = iframe->layoutObject();
1029 ASSERT_TRUE(webScrollLayer->scrollable()); 1023 ASSERT_TRUE(layoutObject);
1030 ASSERT_FALSE( 1024
1031 webScrollLayer->mainThreadScrollingReasons() & 1025 scrollLayer = layoutObject->frameView()->layerForScrolling();
1032 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); 1026 ASSERT_TRUE(scrollLayer);
1033 } 1027
1028 webScrollLayer = scrollLayer->platformLayer();
1029 ASSERT_TRUE(webScrollLayer->scrollable());
1030 ASSERT_FALSE(
1031 webScrollLayer->mainThreadScrollingReasons() &
1032 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
1034 } 1033 }
1035 1034
1036 class StyleRelatedMainThreadScrollingReasonTest 1035 class StyleRelatedMainThreadScrollingReasonTest
1037 : public ScrollingCoordinatorTest { 1036 : public ScrollingCoordinatorTest {
1038 static const uint32_t m_LCDTextRelatedReasons = 1037 static const uint32_t m_LCDTextRelatedReasons =
1039 MainThreadScrollingReason::kHasOpacityAndLCDText | 1038 MainThreadScrollingReason::kHasOpacityAndLCDText |
1040 MainThreadScrollingReason::kHasTransformAndLCDText | 1039 MainThreadScrollingReason::kHasTransformAndLCDText |
1041 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; 1040 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText;
1042 1041
1043 protected: 1042 protected:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1085
1087 if ((reason & m_LCDTextRelatedReasons) && 1086 if ((reason & m_LCDTextRelatedReasons) &&
1088 !(reason & ~m_LCDTextRelatedReasons)) { 1087 !(reason & ~m_LCDTextRelatedReasons)) {
1089 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); 1088 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true);
1090 forceFullCompositingUpdate(); 1089 forceFullCompositingUpdate();
1091 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); 1090 ASSERT_FALSE(frameView->mainThreadScrollingReasons());
1092 } 1091 }
1093 } 1092 }
1094 }; 1093 };
1095 1094
1096 INSTANTIATE_TEST_CASE_P(All, 1095 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) {
1097 StyleRelatedMainThreadScrollingReasonTest,
1098 ::testing::Bool());
1099
1100 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) {
1101 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); 1096 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText);
1102 } 1097 }
1103 1098
1104 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { 1099 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) {
1105 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); 1100 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText);
1106 } 1101 }
1107 1102
1108 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { 1103 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) {
1109 testStyle("background-not-opaque", 1104 testStyle("background-not-opaque",
1110 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); 1105 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText);
1111 } 1106 }
1112 1107
1113 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { 1108 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) {
1114 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); 1109 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius);
1115 } 1110 }
1116 1111
1117 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { 1112 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipTest) {
1118 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); 1113 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty);
1119 } 1114 }
1120 1115
1121 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { 1116 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) {
1122 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; 1117 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty;
1123 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); 1118 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false);
1124 Document* document = frame()->document(); 1119 Document* document = frame()->document();
1125 // Test ancestor with ClipPath 1120 // Test ancestor with ClipPath
1126 Element* element = document->body(); 1121 Element* element = document->body();
1127 DCHECK(element); 1122 DCHECK(element);
1128 element->setAttribute(HTMLNames::styleAttr, 1123 element->setAttribute(HTMLNames::styleAttr,
1129 "clip-path:circle(115px at 20px 20px);"); 1124 "clip-path:circle(115px at 20px 20px);");
1130 forceFullCompositingUpdate(); 1125 forceFullCompositingUpdate();
1131 1126
(...skipping 14 matching lines...) Expand all
1146 "clip-path:circle(115px at 20px 20px);"); 1141 "clip-path:circle(115px at 20px 20px);");
1147 forceFullCompositingUpdate(); 1142 forceFullCompositingUpdate();
1148 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); 1143 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason);
1149 1144
1150 // Remove clip path from descendant. 1145 // Remove clip path from descendant.
1151 element->removeAttribute(HTMLNames::styleAttr); 1146 element->removeAttribute(HTMLNames::styleAttr);
1152 forceFullCompositingUpdate(); 1147 forceFullCompositingUpdate();
1153 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); 1148 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason);
1154 } 1149 }
1155 1150
1156 TEST_P(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { 1151 TEST_F(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) {
1157 testStyle("transparent border-radius", 1152 testStyle("transparent border-radius",
1158 MainThreadScrollingReason::kHasOpacityAndLCDText | 1153 MainThreadScrollingReason::kHasOpacityAndLCDText |
1159 MainThreadScrollingReason::kHasBorderRadius); 1154 MainThreadScrollingReason::kHasBorderRadius);
1160 } 1155 }
1161 1156
1162 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { 1157 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) {
1163 testStyle("box-shadow", 1158 testStyle("box-shadow",
1164 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); 1159 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer);
1165 } 1160 }
1166 1161
1167 } // namespace blink 1162 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698