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 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2373 if (unusedDelta != FloatSize()) { | 2373 if (unusedDelta != FloatSize()) { |
| 2374 m_accumulatedRootOverscroll += unusedDelta; | 2374 m_accumulatedRootOverscroll += unusedDelta; |
| 2375 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); | 2375 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); |
| 2376 } | 2376 } |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) | 2379 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) |
| 2380 { | 2380 { |
| 2381 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2381 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
| 2382 | 2382 |
| 2383 // TODO(bokan): This delta is specific to the event which is positive up and | 2383 // Negate since the delta is in screen space, that is, moving a touch point |
| 2384 // to the left. Since we're passing it into a bunch of scrolling code below, | 2384 // down (positive gestureEvent.deltaY) should cause upwards scrolling |
| 2385 // it should probably be inverted here. | 2385 // (negative scroll delta). |
|
tdresser
2016/03/01 19:24:09
Both units are in screen space, right?
I'd say so
bokan
2016/03/01 19:40:57
Done.
| |
| 2386 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); | 2386 FloatSize delta(-gestureEvent.deltaX(), -gestureEvent.deltaY()); |
| 2387 FloatSize velocity(-gestureEvent.velocityX(), -gestureEvent.velocityY()); | |
| 2387 if (delta.isZero()) | 2388 if (delta.isZero()) |
| 2388 return WebInputEventResult::NotHandled; | 2389 return WebInputEventResult::NotHandled; |
| 2389 | 2390 |
| 2390 ScrollGranularity granularity = gestureEvent.deltaUnits(); | 2391 ScrollGranularity granularity = gestureEvent.deltaUnits(); |
| 2391 Node* node = m_scrollGestureHandlingNode.get(); | 2392 Node* node = m_scrollGestureHandlingNode.get(); |
| 2392 | 2393 |
| 2393 // Scroll customization is only available for touch. | 2394 // Scroll customization is only available for touch. |
| 2394 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen; | 2395 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen; |
| 2395 if (node) { | 2396 if (node) { |
| 2396 LayoutObject* layoutObject = node->layoutObject(); | 2397 LayoutObject* layoutObject = node->layoutObject(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2410 } | 2411 } |
| 2411 // FIXME: we should allow simultaneous scrolling of nested | 2412 // FIXME: we should allow simultaneous scrolling of nested |
| 2412 // iframes along perpendicular axes. See crbug.com/466991. | 2413 // iframes along perpendicular axes. See crbug.com/466991. |
| 2413 m_deltaConsumedForScrollSequence = true; | 2414 m_deltaConsumedForScrollSequence = true; |
| 2414 return result; | 2415 return result; |
| 2415 } | 2416 } |
| 2416 | 2417 |
| 2417 bool scrolled = false; | 2418 bool scrolled = false; |
| 2418 if (handleScrollCustomization) { | 2419 if (handleScrollCustomization) { |
| 2419 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); | 2420 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); |
| 2420 scrollStateData->delta_x = gestureEvent.deltaX(); | 2421 scrollStateData->delta_x = delta.width(); |
| 2421 scrollStateData->delta_y = gestureEvent.deltaY(); | 2422 scrollStateData->delta_y = delta.height(); |
| 2422 scrollStateData->velocity_x = gestureEvent.velocityX(); | 2423 scrollStateData->velocity_x = velocity.width(); |
| 2423 scrollStateData->velocity_y = gestureEvent.velocityY(); | 2424 scrollStateData->velocity_y = velocity.height(); |
| 2424 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); | 2425 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); |
| 2425 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); | 2426 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); |
| 2426 scrollStateData->from_user_input = true; | 2427 scrollStateData->from_user_input = true; |
| 2427 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; | 2428 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; |
| 2428 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release()); | 2429 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release()); |
| 2429 if (m_previousGestureScrolledNode) { | 2430 if (m_previousGestureScrolledNode) { |
| 2430 // The ScrollState needs to know what the current | 2431 // The ScrollState needs to know what the current |
| 2431 // native scrolling element is, so that for an | 2432 // native scrolling element is, so that for an |
| 2432 // inertial scroll that shouldn't propagate, only the | 2433 // inertial scroll that shouldn't propagate, only the |
| 2433 // currently scrolling element responds. | 2434 // currently scrolling element responds. |
| 2434 ASSERT(m_previousGestureScrolledNode->isElementNode()); | 2435 ASSERT(m_previousGestureScrolledNode->isElementNode()); |
| 2435 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); | 2436 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); |
| 2436 } | 2437 } |
| 2437 customizedScroll(*node, *scrollState); | 2438 customizedScroll(*node, *scrollState); |
| 2438 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); | 2439 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); |
| 2439 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); | 2440 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); |
| 2440 scrolled = scrollState->deltaX() != gestureEvent.deltaX() | 2441 scrolled = scrollState->deltaX() != delta.width() |
| 2441 || scrollState->deltaY() != gestureEvent.deltaY(); | 2442 || scrollState->deltaY() != delta.height(); |
| 2442 } else { | 2443 } else { |
| 2443 Node* stopNode = nullptr; | 2444 Node* stopNode = nullptr; |
| 2444 if (gestureEvent.preventPropagation()) | 2445 if (gestureEvent.preventPropagation()) |
| 2445 stopNode = m_previousGestureScrolledNode.get(); | 2446 stopNode = m_previousGestureScrolledNode.get(); |
| 2446 | 2447 |
| 2447 // Scale by -1 because the delta is the GestureEvent delta (see TODO at top of function). | 2448 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node); |
| 2448 ScrollResult result = physicalScroll(granularity, delta.scaledBy(-1) , node, &stopNode); | |
| 2449 | 2449 |
| 2450 scrolled = result.didScroll(); | 2450 scrolled = result.didScroll(); |
| 2451 | 2451 |
| 2452 if (gestureEvent.preventPropagation()) | 2452 if (gestureEvent.preventPropagation()) |
| 2453 m_previousGestureScrolledNode = stopNode; | 2453 m_previousGestureScrolledNode = stopNode; |
| 2454 | 2454 |
| 2455 resetOverscroll(result.didScrollX, result.didScrollY); | 2455 resetOverscroll(result.didScrollX, result.didScrollY); |
| 2456 } | 2456 } |
| 2457 if (scrolled) { | 2457 if (scrolled) { |
| 2458 setFrameWasScrolledByUser(); | 2458 setFrameWasScrolledByUser(); |
| 2459 return WebInputEventResult::HandledSystem; | 2459 return WebInputEventResult::HandledSystem; |
| 2460 } | 2460 } |
| 2461 } | 2461 } |
| 2462 | 2462 |
| 2463 if (handleScrollCustomization) | 2463 if (handleScrollCustomization) |
| 2464 return WebInputEventResult::NotHandled; | 2464 return WebInputEventResult::NotHandled; |
| 2465 | 2465 |
| 2466 // Try to scroll the frame view. | 2466 // Try to scroll the frame view. |
| 2467 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse); | 2467 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse); |
| 2468 if (m_frame->isMainFrame()) { | 2468 if (m_frame->isMainFrame()) { |
| 2469 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y()); | 2469 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y()); |
| 2470 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.ve locityY()); | |
| 2471 handleOverscroll(scrollResult, position, velocity); | 2470 handleOverscroll(scrollResult, position, velocity); |
| 2472 } | 2471 } |
| 2473 if (scrollResult.didScroll()) { | 2472 if (scrollResult.didScroll()) { |
| 2474 setFrameWasScrolledByUser(); | 2473 setFrameWasScrolledByUser(); |
| 2475 return WebInputEventResult::HandledSystem; | 2474 return WebInputEventResult::HandledSystem; |
| 2476 } | 2475 } |
| 2477 | 2476 |
| 2478 return WebInputEventResult::NotHandled; | 2477 return WebInputEventResult::NotHandled; |
| 2479 } | 2478 } |
| 2480 | 2479 |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 3993 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 3995 { | 3994 { |
| 3996 #if OS(MACOSX) | 3995 #if OS(MACOSX) |
| 3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); | 3996 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); |
| 3998 #else | 3997 #else |
| 3999 return PlatformEvent::AltKey; | 3998 return PlatformEvent::AltKey; |
| 4000 #endif | 3999 #endif |
| 4001 } | 4000 } |
| 4002 | 4001 |
| 4003 } // namespace blink | 4002 } // namespace blink |
| OLD | NEW |