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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1879103002: Convert main-thread overscroll parameters into viewport space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Majid's review Created 4 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 static inline FloatSize adjustOverscroll(FloatSize unusedDelta) 2366 static inline FloatSize adjustOverscroll(FloatSize unusedDelta)
2367 { 2367 {
2368 if (std::abs(unusedDelta.width()) < minimumOverscrollDelta) 2368 if (std::abs(unusedDelta.width()) < minimumOverscrollDelta)
2369 unusedDelta.setWidth(0); 2369 unusedDelta.setWidth(0);
2370 if (std::abs(unusedDelta.height()) < minimumOverscrollDelta) 2370 if (std::abs(unusedDelta.height()) < minimumOverscrollDelta)
2371 unusedDelta.setHeight(0); 2371 unusedDelta.setHeight(0);
2372 2372
2373 return unusedDelta; 2373 return unusedDelta;
2374 } 2374 }
2375 2375
2376 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa tPoint& position, const FloatSize& velocity) 2376 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa tPoint& positionInRootFrame, const FloatSize& velocityInRootFrame)
2377 { 2377 {
2378 ASSERT(m_frame->isMainFrame()); 2378 ASSERT(m_frame->isMainFrame());
2379 VisualViewport& visualViewport = m_frame->page()->frameHost().visualViewport ();
2379 2380
2380 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY); 2381 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY);
2381 unusedDelta = adjustOverscroll(unusedDelta); 2382 unusedDelta = adjustOverscroll(unusedDelta);
2383
2384 FloatSize deltaInViewport = unusedDelta.scaledBy(visualViewport.scale());
2385 FloatSize velocityInViewport = velocityInRootFrame.scaledBy(visualViewport.s cale());
2386 FloatPoint positionInViewport =
2387 visualViewport.rootFrameToViewport(positionInRootFrame);
2388
2382 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); 2389 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY);
2383 if (unusedDelta != FloatSize()) { 2390 if (deltaInViewport != FloatSize()) {
2384 m_accumulatedRootOverscroll += unusedDelta; 2391 m_accumulatedRootOverscroll += deltaInViewport;
2385 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); 2392 m_frame->chromeClient().didOverscroll(deltaInViewport, m_accumulatedRoot Overscroll, positionInViewport, velocityInViewport);
2386 } 2393 }
2387 } 2394 }
2388 2395
2389 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) 2396 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent)
2390 { 2397 {
2391 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); 2398 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate);
2392 2399
2393 // Negate the deltas since the gesture event stores finger movement and 2400 // Negate the deltas since the gesture event stores finger movement and
2394 // scrolling occurs in the direction opposite the finger's movement 2401 // scrolling occurs in the direction opposite the finger's movement
2395 // direction. e.g. Finger moving up has negative event delta but causes the 2402 // direction. e.g. Finger moving up has negative event delta but causes the
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 if (gestureEvent.preventPropagation()) 2463 if (gestureEvent.preventPropagation())
2457 stopNode = m_previousGestureScrolledNode.get(); 2464 stopNode = m_previousGestureScrolledNode.get();
2458 2465
2459 bool consumed = false; 2466 bool consumed = false;
2460 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, &consumed); 2467 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, &consumed);
2461 2468
2462 if (gestureEvent.preventPropagation()) 2469 if (gestureEvent.preventPropagation())
2463 m_previousGestureScrolledNode = stopNode; 2470 m_previousGestureScrolledNode = stopNode;
2464 2471
2465 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) { 2472 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) {
2466 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge stureEvent.position().y()); 2473 FloatPoint positionInRootFrame = FloatPoint(gestureEvent.positio n().x(), gestureEvent.position().y());
2467 handleOverscroll(result, position, velocity); 2474 handleOverscroll(result, positionInRootFrame, velocity);
2468 } else { 2475 } else {
2469 resetOverscroll(result.didScrollX, result.didScrollY); 2476 resetOverscroll(result.didScrollX, result.didScrollY);
2470 } 2477 }
2471 2478
2472 if (consumed) 2479 if (consumed)
2473 return WebInputEventResult::HandledSystem; 2480 return WebInputEventResult::HandledSystem;
2474 } 2481 }
2475 } 2482 }
2476 2483
2477 return WebInputEventResult::NotHandled; 2484 return WebInputEventResult::NotHandled;
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4020 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4014 { 4021 {
4015 #if OS(MACOSX) 4022 #if OS(MACOSX)
4016 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4023 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4017 #else 4024 #else
4018 return PlatformEvent::AltKey; 4025 return PlatformEvent::AltKey;
4019 #endif 4026 #endif
4020 } 4027 }
4021 4028
4022 } // namespace blink 4029 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/page/ChromeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698