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

Side by Side Diff: Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp

Issue 9931004: Merge 112364 - [chromium] Transfer wheel fling via WebCompositorInputHandlerClient (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 return DidNotHandle; 262 return DidNotHandle;
263 } 263 }
264 264
265 WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h andleGestureFling(const WebGestureEvent& gestureEvent) 265 WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h andleGestureFling(const WebGestureEvent& gestureEvent)
266 { 266 {
267 CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scro llBegin(IntPoint(gestureEvent.x, gestureEvent.y), CCInputHandlerClient::Wheel); 267 CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scro llBegin(IntPoint(gestureEvent.x, gestureEvent.y), CCInputHandlerClient::Wheel);
268 switch (scrollStatus) { 268 switch (scrollStatus) {
269 case CCInputHandlerClient::ScrollStarted: { 269 case CCInputHandlerClient::ScrollStarted: {
270 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::started"); 270 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::started");
271 OwnPtr<PlatformGestureCurve> flingCurve = TouchpadFlingPlatformGestureCu rve::create(FloatPoint(-gestureEvent.deltaX, -gestureEvent.deltaY)); 271 OwnPtr<PlatformGestureCurve> flingCurve = TouchpadFlingPlatformGestureCu rve::create(FloatPoint(gestureEvent.deltaX, gestureEvent.deltaY));
272 m_wheelFlingAnimation = CCActiveGestureAnimation::create(PlatformGesture ToCCGestureAdapter::create(flingCurve.release()), this); 272 m_wheelFlingAnimation = CCActiveGestureAnimation::create(PlatformGesture ToCCGestureAdapter::create(flingCurve.release()), this);
273 m_wheelFlingPoint = IntPoint(gestureEvent.x, gestureEvent.y); 273 m_wheelFlingParameters.delta = WebFloatPoint(gestureEvent.deltaX, gestur eEvent.deltaY);
274 m_wheelFlingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y);
275 m_wheelFlingParameters.globalPoint = WebPoint(gestureEvent.globalX, gest ureEvent.globalY);
276 m_wheelFlingParameters.modifiers = gestureEvent.modifiers;
274 m_inputHandlerClient->scheduleAnimation(); 277 m_inputHandlerClient->scheduleAnimation();
275 return DidHandle; 278 return DidHandle;
276 } 279 }
277 case CCInputHandlerClient::ScrollFailed: { 280 case CCInputHandlerClient::ScrollFailed: {
278 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::failed"); 281 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::failed");
279 return DidNotHandle; 282 return DidNotHandle;
280 } 283 }
281 case CCInputHandlerClient::ScrollIgnored: { 284 case CCInputHandlerClient::ScrollIgnored: {
282 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::ignored"); 285 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGesture Fling::ignored");
283 // We still pass the curve to the main thread if there's nothing scrolla ble, in case something 286 // We still pass the curve to the main thread if there's nothing scrolla ble, in case something
284 // registers a handler before the curve is over. 287 // registers a handler before the curve is over.
285 return DidNotHandle; 288 return DidNotHandle;
286 } 289 }
287 } 290 }
288 return DidNotHandle; 291 return DidNotHandle;
289 } 292 }
290 293
291 int WebCompositorInputHandlerImpl::identifier() const 294 int WebCompositorInputHandlerImpl::identifier() const
292 { 295 {
293 ASSERT(CCProxy::isImplThread()); 296 ASSERT(CCProxy::isImplThread());
294 return m_identifier; 297 return m_identifier;
295 } 298 }
296 299
297 void WebCompositorInputHandlerImpl::animate(double monotonicTime) 300 void WebCompositorInputHandlerImpl::animate(double monotonicTime)
298 { 301 {
299 if (!m_wheelFlingAnimation) 302 if (!m_wheelFlingAnimation)
300 return; 303 return;
301 304
305 if (!m_wheelFlingParameters.startTime)
306 m_wheelFlingParameters.startTime = monotonicTime;
307
302 if (m_wheelFlingAnimation->animate(monotonicTime)) 308 if (m_wheelFlingAnimation->animate(monotonicTime))
303 m_inputHandlerClient->scheduleAnimation(); 309 m_inputHandlerClient->scheduleAnimation();
304 else { 310 else {
305 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::animate::flin gOver"); 311 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::animate::flin gOver");
306 m_wheelFlingAnimation.clear(); 312 cancelCurrentFling();
307 } 313 }
308 } 314 }
309 315
310 bool WebCompositorInputHandlerImpl::cancelCurrentFling() 316 bool WebCompositorInputHandlerImpl::cancelCurrentFling()
311 { 317 {
312 bool hadFlingAnimation = m_wheelFlingAnimation; 318 bool hadFlingAnimation = m_wheelFlingAnimation;
313 TRACE_EVENT_INSTANT1("cc", "WebCompositorInputHandlerImpl::cancelCurrentFlin g", "hadFlingAnimation", hadFlingAnimation); 319 TRACE_EVENT_INSTANT1("cc", "WebCompositorInputHandlerImpl::cancelCurrentFlin g", "hadFlingAnimation", hadFlingAnimation);
314 m_wheelFlingAnimation.clear(); 320 m_wheelFlingAnimation.clear();
321 m_wheelFlingParameters = WebActiveWheelFlingParameters();
315 return hadFlingAnimation; 322 return hadFlingAnimation;
316 } 323 }
317 324
318 void WebCompositorInputHandlerImpl::scrollBy(const IntPoint& increment) 325 void WebCompositorInputHandlerImpl::scrollBy(const IntPoint& increment)
319 { 326 {
320 if (increment == IntPoint::zero()) 327 if (increment == IntPoint::zero())
321 return; 328 return;
322 329
323 TRACE_EVENT2("cc", "WebCompositorInputHandlerImpl::scrollBy", "x", increment .x(), "y", increment.y()); 330 TRACE_EVENT2("cc", "WebCompositorInputHandlerImpl::scrollBy", "x", increment .x(), "y", increment.y());
331 WebMouseWheelEvent syntheticWheel;
332 syntheticWheel.type = WebInputEvent::MouseWheel;
333 syntheticWheel.deltaX = increment.x();
334 syntheticWheel.deltaY = increment.y();
335 syntheticWheel.hasPreciseScrollingDeltas = true;
336 syntheticWheel.x = m_wheelFlingParameters.point.x;
337 syntheticWheel.y = m_wheelFlingParameters.point.y;
338 syntheticWheel.globalX = m_wheelFlingParameters.globalPoint.x;
339 syntheticWheel.globalY = m_wheelFlingParameters.globalPoint.y;
340 syntheticWheel.modifiers = m_wheelFlingParameters.modifiers;
324 341
325 WebMouseWheelEvent event; 342 WebCompositorInputHandlerImpl::EventDisposition disposition = handleInputEve ntInternal(syntheticWheel);
326 event.type = WebInputEvent::MouseWheel;
327 event.deltaX = -increment.x();
328 event.deltaY = -increment.y();
329 event.hasPreciseScrollingDeltas = true;
330 event.x = m_wheelFlingPoint.x();
331 event.y = m_wheelFlingPoint.y();
332
333 WebCompositorInputHandlerImpl::EventDisposition disposition = handleInputEve ntInternal(event);
334 switch (disposition) { 343 switch (disposition) {
335 case DidHandle: 344 case DidHandle:
345 m_wheelFlingParameters.cumulativeScroll.width += increment.x();
346 m_wheelFlingParameters.cumulativeScroll.height += increment.y();
336 case DropEvent: 347 case DropEvent:
337 break; 348 break;
338 case DidNotHandle: 349 case DidNotHandle:
339 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::scrollBy::Abo rtFling"); 350 TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::scrollBy::Abo rtFling");
340 // FIXME: If we got a DidNotHandle, that means we need to deliver wheels on the main thread. 351 // If we got a DidNotHandle, that means we need to deliver wheels on the main thread.
341 // In this case we need to schedule a commit and transfer the fling curv e over to the main 352 // In this case we need to schedule a commit and transfer the fling curv e over to the main
342 // thread and run the rest of the wheels from there. 353 // thread and run the rest of the wheels from there.
343 // This can happen when flinging a page that contains a scrollable subar ea that we can't 354 // This can happen when flinging a page that contains a scrollable subar ea that we can't
344 // scroll on the thread if the fling starts outside the subarea but then is flung "under" the 355 // scroll on the thread if the fling starts outside the subarea but then is flung "under" the
345 // pointer. 356 // pointer.
346 // For now, just abort the fling. 357 m_client->transferActiveWheelFlingAnimation(m_wheelFlingParameters);
347 cancelCurrentFling(); 358 cancelCurrentFling();
359 break;
348 } 360 }
349 } 361 }
350 362
351 } 363 }
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h ('k') | Source/WebKit/chromium/src/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698