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

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

Issue 1755773002: Pass the physical scroll delta through the scroll customization path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeOneDimensionalScrolls
Patch Set: Updated LayoutTest Created 4 years, 9 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 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 the deltas since the gesture event stores finger movement and
2384 // to the left. Since we're passing it into a bunch of scrolling code below, 2384 // scrolling occurs in the direction opposite the finger's movement
2385 // it should probably be inverted here. 2385 // direction. e.g. Finger moving up has negative event delta but causes the
2386 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); 2386 // page to scroll down causing positive scroll delta.
2387 FloatSize delta(-gestureEvent.deltaX(), -gestureEvent.deltaY());
2388 FloatSize velocity(-gestureEvent.velocityX(), -gestureEvent.velocityY());
2387 if (delta.isZero()) 2389 if (delta.isZero())
2388 return WebInputEventResult::NotHandled; 2390 return WebInputEventResult::NotHandled;
2389 2391
2390 ScrollGranularity granularity = gestureEvent.deltaUnits(); 2392 ScrollGranularity granularity = gestureEvent.deltaUnits();
2391 Node* node = m_scrollGestureHandlingNode.get(); 2393 Node* node = m_scrollGestureHandlingNode.get();
2392 2394
2393 // Scroll customization is only available for touch. 2395 // Scroll customization is only available for touch.
2394 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen; 2396 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen;
2395 if (node) { 2397 if (node) {
2396 LayoutObject* layoutObject = node->layoutObject(); 2398 LayoutObject* layoutObject = node->layoutObject();
(...skipping 13 matching lines...) Expand all
2410 } 2412 }
2411 // FIXME: we should allow simultaneous scrolling of nested 2413 // FIXME: we should allow simultaneous scrolling of nested
2412 // iframes along perpendicular axes. See crbug.com/466991. 2414 // iframes along perpendicular axes. See crbug.com/466991.
2413 m_deltaConsumedForScrollSequence = true; 2415 m_deltaConsumedForScrollSequence = true;
2414 return result; 2416 return result;
2415 } 2417 }
2416 2418
2417 bool scrolled = false; 2419 bool scrolled = false;
2418 if (handleScrollCustomization) { 2420 if (handleScrollCustomization) {
2419 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); 2421 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta());
2420 scrollStateData->delta_x = gestureEvent.deltaX(); 2422 scrollStateData->delta_x = delta.width();
2421 scrollStateData->delta_y = gestureEvent.deltaY(); 2423 scrollStateData->delta_y = delta.height();
2422 scrollStateData->velocity_x = gestureEvent.velocityX(); 2424 scrollStateData->velocity_x = velocity.width();
2423 scrollStateData->velocity_y = gestureEvent.velocityY(); 2425 scrollStateData->velocity_y = velocity.height();
2424 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); 2426 scrollStateData->should_propagate = !gestureEvent.preventPropagation ();
2425 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); 2427 scrollStateData->is_in_inertial_phase = gestureEvent.inertial();
2426 scrollStateData->from_user_input = true; 2428 scrollStateData->from_user_input = true;
2427 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; 2429 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence;
2428 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release()); 2430 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release());
2429 if (m_previousGestureScrolledNode) { 2431 if (m_previousGestureScrolledNode) {
2430 // The ScrollState needs to know what the current 2432 // The ScrollState needs to know what the current
2431 // native scrolling element is, so that for an 2433 // native scrolling element is, so that for an
2432 // inertial scroll that shouldn't propagate, only the 2434 // inertial scroll that shouldn't propagate, only the
2433 // currently scrolling element responds. 2435 // currently scrolling element responds.
2434 ASSERT(m_previousGestureScrolledNode->isElementNode()); 2436 ASSERT(m_previousGestureScrolledNode->isElementNode());
2435 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); 2437 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get()));
2436 } 2438 }
2437 customizedScroll(*node, *scrollState); 2439 customizedScroll(*node, *scrollState);
2438 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); 2440 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement();
2439 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); 2441 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence();
2440 scrolled = scrollState->deltaX() != gestureEvent.deltaX() 2442 scrolled = scrollState->deltaX() != delta.width()
2441 || scrollState->deltaY() != gestureEvent.deltaY(); 2443 || scrollState->deltaY() != delta.height();
2442 } else { 2444 } else {
2443 Node* stopNode = nullptr; 2445 Node* stopNode = nullptr;
2444 if (gestureEvent.preventPropagation()) 2446 if (gestureEvent.preventPropagation())
2445 stopNode = m_previousGestureScrolledNode.get(); 2447 stopNode = m_previousGestureScrolledNode.get();
2446 2448
2447 // Scale by -1 because the delta is the GestureEvent delta (see TODO at top of function). 2449 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node);
2448 ScrollResult result = physicalScroll(granularity, delta.scaledBy(-1) , node, &stopNode);
2449 2450
2450 scrolled = result.didScroll(); 2451 scrolled = result.didScroll();
2451 2452
2452 if (gestureEvent.preventPropagation()) 2453 if (gestureEvent.preventPropagation())
2453 m_previousGestureScrolledNode = stopNode; 2454 m_previousGestureScrolledNode = stopNode;
2454 2455
2455 resetOverscroll(result.didScrollX, result.didScrollY); 2456 resetOverscroll(result.didScrollX, result.didScrollY);
2456 } 2457 }
2457 if (scrolled) { 2458 if (scrolled) {
2458 setFrameWasScrolledByUser(); 2459 setFrameWasScrolledByUser();
2459 return WebInputEventResult::HandledSystem; 2460 return WebInputEventResult::HandledSystem;
2460 } 2461 }
2461 } 2462 }
2462 2463
2463 if (handleScrollCustomization) 2464 if (handleScrollCustomization)
2464 return WebInputEventResult::NotHandled; 2465 return WebInputEventResult::NotHandled;
2465 2466
2466 // Try to scroll the frame view. 2467 // Try to scroll the frame view.
2467 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse); 2468 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse);
2468 if (m_frame->isMainFrame()) { 2469 if (m_frame->isMainFrame()) {
2469 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y()); 2470 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y());
2470 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.ve locityY());
2471 handleOverscroll(scrollResult, position, velocity); 2471 handleOverscroll(scrollResult, position, velocity);
2472 } 2472 }
2473 if (scrollResult.didScroll()) { 2473 if (scrollResult.didScroll()) {
2474 setFrameWasScrolledByUser(); 2474 setFrameWasScrolledByUser();
2475 return WebInputEventResult::HandledSystem; 2475 return WebInputEventResult::HandledSystem;
2476 } 2476 }
2477 2477
2478 return WebInputEventResult::NotHandled; 2478 return WebInputEventResult::NotHandled;
2479 } 2479 }
2480 2480
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3995 { 3995 {
3996 #if OS(MACOSX) 3996 #if OS(MACOSX)
3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3998 #else 3998 #else
3999 return PlatformEvent::AltKey; 3999 return PlatformEvent::AltKey;
4000 #endif 4000 #endif
4001 } 4001 }
4002 4002
4003 } // namespace blink 4003 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/TopControls.cpp ('k') | third_party/WebKit/Source/web/tests/TopControlsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698