Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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& velocity) |
|
majidvp
2016/04/13 18:20:38
s/velocity/velocityInRootFram/
bokan
2016/04/13 19:43:49
Done.
| |
| 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 // The incoming event had its delta, position, and velocity transformed by | |
| 2385 // the visual viewport transform so when we pass it back we should undo it | |
| 2386 // to go back to viewport space. | |
|
majidvp
2016/04/13 18:20:38
Can we simplify this comment by referencing from->
bokan
2016/04/13 19:43:49
Looking at this again, this comment isn't adding m
| |
| 2387 FloatSize deltaInViewport = unusedDelta.scaledBy(visualViewport.scale()); | |
| 2388 FloatSize velocityInViewport = velocity.scaledBy(visualViewport.scale()); | |
| 2389 FloatPoint positionInViewport = | |
| 2390 visualViewport.rootFrameToViewport(positionInRootFrame); | |
| 2391 | |
| 2382 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); | 2392 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); |
| 2383 if (unusedDelta != FloatSize()) { | 2393 if (deltaInViewport != FloatSize()) { |
| 2384 m_accumulatedRootOverscroll += unusedDelta; | 2394 m_accumulatedRootOverscroll += deltaInViewport; |
| 2385 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); | 2395 m_frame->chromeClient().didOverscroll(deltaInViewport, m_accumulatedRoot Overscroll, positionInViewport, velocityInViewport); |
| 2386 } | 2396 } |
| 2387 } | 2397 } |
| 2388 | 2398 |
| 2389 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) | 2399 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) |
| 2390 { | 2400 { |
| 2391 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2401 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
| 2392 | 2402 |
| 2393 // Negate the deltas since the gesture event stores finger movement and | 2403 // Negate the deltas since the gesture event stores finger movement and |
| 2394 // scrolling occurs in the direction opposite the finger's movement | 2404 // scrolling occurs in the direction opposite the finger's movement |
| 2395 // direction. e.g. Finger moving up has negative event delta but causes the | 2405 // 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 Loading... | |
| 2456 if (gestureEvent.preventPropagation()) | 2466 if (gestureEvent.preventPropagation()) |
| 2457 stopNode = m_previousGestureScrolledNode.get(); | 2467 stopNode = m_previousGestureScrolledNode.get(); |
| 2458 | 2468 |
| 2459 bool consumed = false; | 2469 bool consumed = false; |
| 2460 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, &consumed); | 2470 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, &consumed); |
| 2461 | 2471 |
| 2462 if (gestureEvent.preventPropagation()) | 2472 if (gestureEvent.preventPropagation()) |
| 2463 m_previousGestureScrolledNode = stopNode; | 2473 m_previousGestureScrolledNode = stopNode; |
| 2464 | 2474 |
| 2465 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) { | 2475 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) { |
| 2466 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge stureEvent.position().y()); | 2476 FloatPoint positionInRootFrame = FloatPoint(gestureEvent.positio n().x(), gestureEvent.position().y()); |
| 2467 handleOverscroll(result, position, velocity); | 2477 handleOverscroll(result, positionInRootFrame, velocity); |
| 2468 } else { | 2478 } else { |
| 2469 resetOverscroll(result.didScrollX, result.didScrollY); | 2479 resetOverscroll(result.didScrollX, result.didScrollY); |
| 2470 } | 2480 } |
| 2471 | 2481 |
| 2472 if (consumed) | 2482 if (consumed) |
| 2473 return WebInputEventResult::HandledSystem; | 2483 return WebInputEventResult::HandledSystem; |
| 2474 } | 2484 } |
| 2475 } | 2485 } |
| 2476 | 2486 |
| 2477 return WebInputEventResult::NotHandled; | 2487 return WebInputEventResult::NotHandled; |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4013 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4023 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4014 { | 4024 { |
| 4015 #if OS(MACOSX) | 4025 #if OS(MACOSX) |
| 4016 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); | 4026 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); |
| 4017 #else | 4027 #else |
| 4018 return PlatformEvent::AltKey; | 4028 return PlatformEvent::AltKey; |
| 4019 #endif | 4029 #endif |
| 4020 } | 4030 } |
| 4021 | 4031 |
| 4022 } // namespace blink | 4032 } // namespace blink |
| OLD | NEW |