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

Side by Side Diff: Source/platform/mac/ScrollElasticityController.mm

Issue 197213011: Selectively disable rubber banding on mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved can_rubberband parameters into WheelEvent. Created 6 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) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 , m_ignoreMomentumScrolls(false) 103 , m_ignoreMomentumScrolls(false)
104 , m_lastMomentumScrollTimestamp(0) 104 , m_lastMomentumScrollTimestamp(0)
105 , m_startTime(0) 105 , m_startTime(0)
106 , m_snapRubberbandTimerIsActive(false) 106 , m_snapRubberbandTimerIsActive(false)
107 { 107 {
108 } 108 }
109 109
110 bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& whee lEvent) 110 bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& whee lEvent)
111 { 111 {
112 if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) { 112 if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
113 // First, check if we should rubber-band at all. 113 if (!shouldStartRubberBanding(wheelEvent))
114 if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) &&
115 !shouldRubberBandInHorizontalDirection(wheelEvent))
116 return false; 114 return false;
117 115
118 m_inScrollGesture = true; 116 m_inScrollGesture = true;
119 m_momentumScrollInProgress = false; 117 m_momentumScrollInProgress = false;
120 m_ignoreMomentumScrolls = false; 118 m_ignoreMomentumScrolls = false;
121 m_lastMomentumScrollTimestamp = 0; 119 m_lastMomentumScrollTimestamp = 0;
122 m_momentumVelocity = FloatSize(); 120 m_momentumVelocity = FloatSize();
123 121
124 IntSize stretchAmount = m_client->stretchAmount(); 122 IntSize stretchAmount = m_client->stretchAmount();
125 m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount. width())); 123 m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount. width()));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 deltaX = 0; 176 deltaX = 0;
179 else 177 else
180 deltaY = 0; 178 deltaY = 0;
181 179
182 bool shouldStretch = false; 180 bool shouldStretch = false;
183 181
184 PlatformWheelEventPhase momentumPhase = wheelEvent.momentumPhase(); 182 PlatformWheelEventPhase momentumPhase = wheelEvent.momentumPhase();
185 183
186 // If we are starting momentum scrolling then do some setup. 184 // If we are starting momentum scrolling then do some setup.
187 if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase Began || momentumPhase == PlatformWheelEventPhaseChanged)) { 185 if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase Began || momentumPhase == PlatformWheelEventPhaseChanged)) {
186 if (!shouldStartRubberBanding(wheelEvent))
187 return false;
188
188 m_momentumScrollInProgress = true; 189 m_momentumScrollInProgress = true;
189 // Start the snap rubber band timer if it's not running. This is needed to 190 // Start the snap rubber band timer if it's not running. This is needed to
190 // snap back from the over scroll caused by momentum events. 191 // snap back from the over scroll caused by momentum events.
191 if (!m_snapRubberbandTimerIsActive && m_startTime == 0) 192 if (!m_snapRubberbandTimerIsActive && m_startTime == 0)
192 snapRubberBand(); 193 snapRubberBand();
193 } 194 }
194 195
195 CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTime stamp; 196 CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTime stamp;
196 if (m_inScrollGesture || m_momentumScrollInProgress) { 197 if (m_inScrollGesture || m_momentumScrollInProgress) {
197 if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scroll VelocityZeroingTimeout) { 198 if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scroll VelocityZeroingTimeout) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 m_startTime = 0; 407 m_startTime = 0;
407 m_stretchScrollForce = FloatSize(); 408 m_stretchScrollForce = FloatSize();
408 return; 409 return;
409 } 410 }
410 411
411 m_startTime = [NSDate timeIntervalSinceReferenceDate]; 412 m_startTime = [NSDate timeIntervalSinceReferenceDate];
412 m_client->startSnapRubberbandTimer(); 413 m_client->startSnapRubberbandTimer();
413 m_snapRubberbandTimerIsActive = true; 414 m_snapRubberbandTimerIsActive = true;
414 } 415 }
415 416
416 bool ScrollElasticityController::shouldRubberBandInHorizontalDirection(const Pla tformWheelEvent& wheelEvent) 417 bool ScrollElasticityController::shouldStartRubberBanding(const PlatformWheelEve nt& wheelEvent)
417 { 418 {
418 if (wheelEvent.deltaX() > 0) 419 if (wheelEvent.deltaX() > 0) {
419 return m_client->shouldRubberBandInDirection(ScrollLeft); 420 if (!wheelEvent.canRubberbandLeft())
420 if (wheelEvent.deltaX() < 0) 421 return false;
421 return m_client->shouldRubberBandInDirection(ScrollRight); 422 if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && ! m_client->shouldRubberBandInDirection(ScrollLeft))
Alexei Svitkine (slow) 2014/03/20 18:38:09 Could the pinnedInDirection() check be made inside
erikchen 2014/03/24 22:12:04 I've reworked the logic of this method to be much
423 return false;
424 return true;
425 }
426 if (wheelEvent.deltaX() < 0) {
427 if (!wheelEvent.canRubberbandRight())
428 return false;
429 if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && ! m_client->shouldRubberBandInDirection(ScrollRight))
430 return false;
431 return true;
432 }
422 433
423 return true; 434 return true;
424 } 435 }
425 436
426 } // namespace WebCore 437 } // namespace WebCore
427 438
428 #endif // USE(RUBBER_BANDING) 439 #endif // USE(RUBBER_BANDING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698