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

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

Issue 2907053004: GSB uses delta_hints to calculate scrolling chain. (Closed)
Patch Set: Merged with master. Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 10098 matching lines...) Expand 10 before | Expand all | Expand 10 after
10109 WebGestureEvent event(type, WebInputEvent::kNoModifiers, 10109 WebGestureEvent event(type, WebInputEvent::kNoModifiers,
10110 WebInputEvent::kTimeStampForTesting); 10110 WebInputEvent::kTimeStampForTesting);
10111 // TODO(wjmaclean): Make sure that touchpad device is only ever used for 10111 // TODO(wjmaclean): Make sure that touchpad device is only ever used for
10112 // gesture scrolling event types. 10112 // gesture scrolling event types.
10113 event.source_device = GetParam(); 10113 event.source_device = GetParam();
10114 event.x = 100; 10114 event.x = 100;
10115 event.y = 100; 10115 event.y = 100;
10116 if (type == WebInputEvent::kGestureScrollUpdate) { 10116 if (type == WebInputEvent::kGestureScrollUpdate) {
10117 event.data.scroll_update.delta_x = delta_x; 10117 event.data.scroll_update.delta_x = delta_x;
10118 event.data.scroll_update.delta_y = delta_y; 10118 event.data.scroll_update.delta_y = delta_y;
10119 } else if (type == WebInputEvent::kGestureScrollBegin) {
10120 event.data.scroll_begin.delta_x_hint = delta_x;
10121 event.data.scroll_begin.delta_y_hint = delta_y;
10119 } 10122 }
10120 return WebCoalescedInputEvent(event); 10123 return WebCoalescedInputEvent(event);
10121 } 10124 }
10122 10125
10123 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper) { 10126 void ScrollBegin(FrameTestHelpers::WebViewHelper* web_view_helper,
10124 web_view_helper->WebView()->HandleInputEvent( 10127 float delta_x_hint,
10125 GenerateEvent(WebInputEvent::kGestureScrollBegin)); 10128 float delta_y_hint) {
10129 web_view_helper->WebView()->HandleInputEvent(GenerateEvent(
10130 WebInputEvent::kGestureScrollBegin, delta_x_hint, delta_y_hint));
10126 } 10131 }
10127 10132
10128 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper, 10133 void ScrollUpdate(FrameTestHelpers::WebViewHelper* web_view_helper,
10129 float delta_x, 10134 float delta_x,
10130 float delta_y) { 10135 float delta_y) {
10131 web_view_helper->WebView()->HandleInputEvent( 10136 web_view_helper->WebView()->HandleInputEvent(
10132 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y)); 10137 GenerateEvent(WebInputEvent::kGestureScrollUpdate, delta_x, delta_y));
10133 } 10138 }
10134 10139
10135 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) { 10140 void ScrollEnd(FrameTestHelpers::WebViewHelper* web_view_helper) {
(...skipping 12 matching lines...) Expand all
10148 OverscrollWebViewClient client; 10153 OverscrollWebViewClient client;
10149 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10154 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10150 FrameTestHelpers::WebViewHelper web_view_helper; 10155 FrameTestHelpers::WebViewHelper web_view_helper;
10151 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10156 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10152 true, nullptr, &client, nullptr, 10157 true, nullptr, &client, nullptr,
10153 ConfigureAndroid); 10158 ConfigureAndroid);
10154 web_view_helper.Resize(WebSize(200, 200)); 10159 web_view_helper.Resize(WebSize(200, 200));
10155 10160
10156 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple 10161 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple
10157 // scrollUpdate. 10162 // scrollUpdate.
10158 ScrollBegin(&web_view_helper); 10163 ScrollBegin(&web_view_helper, -300, -316);
10159 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), 10164 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16),
10160 WebFloatPoint(100, 100), WebFloatSize())); 10165 WebFloatPoint(100, 100), WebFloatSize()));
10161 ScrollUpdate(&web_view_helper, -308, -316); 10166 ScrollUpdate(&web_view_helper, -308, -316);
10162 Mock::VerifyAndClearExpectations(&client); 10167 Mock::VerifyAndClearExpectations(&client);
10163 10168
10164 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), 10169 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29),
10165 WebFloatPoint(100, 100), WebFloatSize())); 10170 WebFloatPoint(100, 100), WebFloatSize()));
10166 ScrollUpdate(&web_view_helper, 0, -13); 10171 ScrollUpdate(&web_view_helper, 0, -13);
10167 Mock::VerifyAndClearExpectations(&client); 10172 Mock::VerifyAndClearExpectations(&client);
10168 10173
(...skipping 27 matching lines...) Expand all
10196 TEST_P(WebFrameOverscrollTest, 10201 TEST_P(WebFrameOverscrollTest,
10197 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { 10202 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) {
10198 OverscrollWebViewClient client; 10203 OverscrollWebViewClient client;
10199 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10204 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10200 FrameTestHelpers::WebViewHelper web_view_helper; 10205 FrameTestHelpers::WebViewHelper web_view_helper;
10201 web_view_helper.InitializeAndLoad( 10206 web_view_helper.InitializeAndLoad(
10202 base_url_ + "overscroll/div-overscroll.html", true, nullptr, &client, 10207 base_url_ + "overscroll/div-overscroll.html", true, nullptr, &client,
10203 nullptr, ConfigureAndroid); 10208 nullptr, ConfigureAndroid);
10204 web_view_helper.Resize(WebSize(200, 200)); 10209 web_view_helper.Resize(WebSize(200, 200));
10205 10210
10206 ScrollBegin(&web_view_helper); 10211 ScrollBegin(&web_view_helper, 0, -316);
10207 10212
10208 // Scroll the Div to the end. 10213 // Scroll the Div to the end.
10209 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10214 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
10210 ScrollUpdate(&web_view_helper, 0, -316); 10215 ScrollUpdate(&web_view_helper, 0, -316);
10211 Mock::VerifyAndClearExpectations(&client); 10216 Mock::VerifyAndClearExpectations(&client);
10212 10217
10213 ScrollEnd(&web_view_helper); 10218 ScrollEnd(&web_view_helper);
10214 ScrollBegin(&web_view_helper); 10219 ScrollBegin(&web_view_helper, 0, -100);
10215 10220
10216 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10221 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10217 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), 10222 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100),
10218 WebFloatPoint(100, 100), WebFloatSize())); 10223 WebFloatPoint(100, 100), WebFloatSize()));
10219 ScrollUpdate(&web_view_helper, 0, -100); 10224 ScrollUpdate(&web_view_helper, 0, -100);
10220 ScrollUpdate(&web_view_helper, 0, -100); 10225 ScrollUpdate(&web_view_helper, 0, -100);
10221 Mock::VerifyAndClearExpectations(&client); 10226 Mock::VerifyAndClearExpectations(&client);
10222 10227
10223 // TODO(bokan): This has never worked but by the accident that this test was 10228 // TODO(bokan): This has never worked but by the accident that this test was
10224 // being run in a WebView without a size. This test should be fixed along with 10229 // being run in a WebView without a size. This test should be fixed along with
(...skipping 18 matching lines...) Expand all
10243 10248
10244 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { 10249 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) {
10245 OverscrollWebViewClient client; 10250 OverscrollWebViewClient client;
10246 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10251 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10247 FrameTestHelpers::WebViewHelper web_view_helper; 10252 FrameTestHelpers::WebViewHelper web_view_helper;
10248 web_view_helper.InitializeAndLoad( 10253 web_view_helper.InitializeAndLoad(
10249 base_url_ + "overscroll/div-overscroll.html", true, nullptr, &client, 10254 base_url_ + "overscroll/div-overscroll.html", true, nullptr, &client,
10250 nullptr, ConfigureAndroid); 10255 nullptr, ConfigureAndroid);
10251 web_view_helper.Resize(WebSize(200, 200)); 10256 web_view_helper.Resize(WebSize(200, 200));
10252 10257
10253 ScrollBegin(&web_view_helper); 10258 ScrollBegin(&web_view_helper, 0, -316);
10254 10259
10255 // Scroll the Div to the end. 10260 // Scroll the Div to the end.
10256 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10261 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
10257 ScrollUpdate(&web_view_helper, 0, -316); 10262 ScrollUpdate(&web_view_helper, 0, -316);
10258 Mock::VerifyAndClearExpectations(&client); 10263 Mock::VerifyAndClearExpectations(&client);
10259 10264
10260 ScrollEnd(&web_view_helper); 10265 ScrollEnd(&web_view_helper);
10261 ScrollBegin(&web_view_helper); 10266 ScrollBegin(&web_view_helper, 0, -150);
10262 10267
10263 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10268 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10264 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10269 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10265 WebFloatPoint(100, 100), WebFloatSize())); 10270 WebFloatPoint(100, 100), WebFloatSize()));
10266 ScrollUpdate(&web_view_helper, 0, -150); 10271 ScrollUpdate(&web_view_helper, 0, -150);
10267 Mock::VerifyAndClearExpectations(&client); 10272 Mock::VerifyAndClearExpectations(&client);
10268 } 10273 }
10269 10274
10270 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { 10275 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) {
10271 OverscrollWebViewClient client; 10276 OverscrollWebViewClient client;
10272 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); 10277 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10273 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); 10278 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10274 FrameTestHelpers::WebViewHelper web_view_helper; 10279 FrameTestHelpers::WebViewHelper web_view_helper;
10275 web_view_helper.InitializeAndLoad( 10280 web_view_helper.InitializeAndLoad(
10276 base_url_ + "overscroll/iframe-overscroll.html", true, nullptr, &client, 10281 base_url_ + "overscroll/iframe-overscroll.html", true, nullptr, &client,
10277 nullptr, ConfigureAndroid); 10282 nullptr, ConfigureAndroid);
10278 web_view_helper.Resize(WebSize(200, 200)); 10283 web_view_helper.Resize(WebSize(200, 200));
10279 10284
10280 ScrollBegin(&web_view_helper); 10285 ScrollBegin(&web_view_helper, 0, -320);
10281 // Scroll the IFrame to the end. 10286 // Scroll the IFrame to the end.
10282 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10287 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0);
10283 10288
10284 // This scroll will fully scroll the iframe but will be consumed before being 10289 // This scroll will fully scroll the iframe but will be consumed before being
10285 // counted as overscroll. 10290 // counted as overscroll.
10286 ScrollUpdate(&web_view_helper, 0, -320); 10291 ScrollUpdate(&web_view_helper, 0, -320);
10287 10292
10288 // This scroll will again target the iframe but wont bubble further up. Make 10293 // This scroll will again target the iframe but wont bubble further up. Make
10289 // sure that the unused scroll isn't handled as overscroll. 10294 // sure that the unused scroll isn't handled as overscroll.
10290 ScrollUpdate(&web_view_helper, 0, -50); 10295 ScrollUpdate(&web_view_helper, 0, -50);
10291 Mock::VerifyAndClearExpectations(&client); 10296 Mock::VerifyAndClearExpectations(&client);
10292 10297
10293 ScrollEnd(&web_view_helper); 10298 ScrollEnd(&web_view_helper);
10294 ScrollBegin(&web_view_helper); 10299 ScrollBegin(&web_view_helper, 0, -150);
10295 10300
10296 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. 10301 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
10297 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10302 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10298 WebFloatPoint(100, 100), WebFloatSize())); 10303 WebFloatPoint(100, 100), WebFloatSize()));
10299 ScrollUpdate(&web_view_helper, 0, -150); 10304 ScrollUpdate(&web_view_helper, 0, -150);
10300 Mock::VerifyAndClearExpectations(&client); 10305 Mock::VerifyAndClearExpectations(&client);
10301 10306
10302 ScrollEnd(&web_view_helper); 10307 ScrollEnd(&web_view_helper);
10303 } 10308 }
10304 10309
10305 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { 10310 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) {
10306 OverscrollWebViewClient client; 10311 OverscrollWebViewClient client;
10307 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10312 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10308 FrameTestHelpers::WebViewHelper web_view_helper; 10313 FrameTestHelpers::WebViewHelper web_view_helper;
10309 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( 10314 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad(
10310 base_url_ + "overscroll/overscroll.html", true, nullptr, &client, nullptr, 10315 base_url_ + "overscroll/overscroll.html", true, nullptr, &client, nullptr,
10311 ConfigureAndroid); 10316 ConfigureAndroid);
10312 web_view_helper.Resize(WebSize(200, 200)); 10317 web_view_helper.Resize(WebSize(200, 200));
10313 web_view_impl->SetPageScaleFactor(3.0); 10318 web_view_impl->SetPageScaleFactor(3.0);
10314 10319
10315 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. 10320 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
10316 // The point is (99, 99) because we clamp in the division by 3 to 33 so when 10321 // The point is (99, 99) because we clamp in the division by 3 to 33 so when
10317 // we go back to viewport coordinates it becomes (99, 99). 10322 // we go back to viewport coordinates it becomes (99, 99).
10318 ScrollBegin(&web_view_helper); 10323 ScrollBegin(&web_view_helper, 0, 30);
10319 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), 10324 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30),
10320 WebFloatPoint(99, 99), WebFloatSize())); 10325 WebFloatPoint(99, 99), WebFloatSize()));
10321 ScrollUpdate(&web_view_helper, 0, 30); 10326 ScrollUpdate(&web_view_helper, 0, 30);
10322 Mock::VerifyAndClearExpectations(&client); 10327 Mock::VerifyAndClearExpectations(&client);
10323 10328
10324 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), 10329 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60),
10325 WebFloatPoint(99, 99), WebFloatSize())); 10330 WebFloatPoint(99, 99), WebFloatSize()));
10326 ScrollUpdate(&web_view_helper, 0, 30); 10331 ScrollUpdate(&web_view_helper, 0, 30);
10327 Mock::VerifyAndClearExpectations(&client); 10332 Mock::VerifyAndClearExpectations(&client);
10328 10333
(...skipping 17 matching lines...) Expand all
10346 10351
10347 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { 10352 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) {
10348 OverscrollWebViewClient client; 10353 OverscrollWebViewClient client;
10349 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10354 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10350 FrameTestHelpers::WebViewHelper web_view_helper; 10355 FrameTestHelpers::WebViewHelper web_view_helper;
10351 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10356 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10352 true, nullptr, &client, nullptr, 10357 true, nullptr, &client, nullptr,
10353 ConfigureAndroid); 10358 ConfigureAndroid);
10354 web_view_helper.Resize(WebSize(200, 200)); 10359 web_view_helper.Resize(WebSize(200, 200));
10355 10360
10356 ScrollBegin(&web_view_helper); 10361 ScrollBegin(&web_view_helper, 10, 10);
10357 EXPECT_CALL(client, 10362 EXPECT_CALL(client,
10358 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), 10363 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10),
10359 WebFloatPoint(100, 100), WebFloatSize())); 10364 WebFloatPoint(100, 100), WebFloatSize()));
10360 ScrollUpdate(&web_view_helper, 10, 10); 10365 ScrollUpdate(&web_view_helper, 10, 10);
10361 Mock::VerifyAndClearExpectations(&client); 10366 Mock::VerifyAndClearExpectations(&client);
10362 10367
10363 EXPECT_CALL(client, 10368 EXPECT_CALL(client,
10364 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), 10369 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10),
10365 WebFloatPoint(100, 100), WebFloatSize())); 10370 WebFloatPoint(100, 100), WebFloatSize()));
10366 ScrollUpdate(&web_view_helper, 0, 0.10); 10371 ScrollUpdate(&web_view_helper, 0, 0.10);
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
12258 if (obj->IsText()) { 12263 if (obj->IsText()) {
12259 LayoutText* layout_text = ToLayoutText(obj); 12264 LayoutText* layout_text = ToLayoutText(obj);
12260 text = layout_text->GetText(); 12265 text = layout_text->GetText();
12261 break; 12266 break;
12262 } 12267 }
12263 } 12268 }
12264 EXPECT_EQ("foo alt", text.Utf8()); 12269 EXPECT_EQ("foo alt", text.Utf8());
12265 } 12270 }
12266 12271
12267 } // namespace blink 12272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698