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

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

Issue 1214673006: Reset unusedDelta on Onverscroll for residual values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 #include "platform/heap/Handle.h" 90 #include "platform/heap/Handle.h"
91 #include "platform/scroll/ScrollAnimator.h" 91 #include "platform/scroll/ScrollAnimator.h"
92 #include "platform/scroll/Scrollbar.h" 92 #include "platform/scroll/Scrollbar.h"
93 #include "wtf/Assertions.h" 93 #include "wtf/Assertions.h"
94 #include "wtf/CurrentTime.h" 94 #include "wtf/CurrentTime.h"
95 #include "wtf/StdLibExtras.h" 95 #include "wtf/StdLibExtras.h"
96 #include "wtf/TemporaryChange.h" 96 #include "wtf/TemporaryChange.h"
97 97
98 namespace blink { 98 namespace blink {
99 99
100 const float kEpsilon = 0.1;
majidvp 2015/07/09 15:02:46 Please add a comment explaining why 0.1. I suppose
MuVen 2015/07/09 17:51:34 Done.
101
102 bool IsApproxZero(float value)
majidvp 2015/07/09 15:02:46 This function is superfluous as it is only used on
MuVen 2015/07/09 17:51:35 Done.
103 {
104 return std::abs(value) < kEpsilon;
105 }
106
107 FloatSize ZeroSmallComponents(FloatSize unUsedDelta)
majidvp 2015/07/09 15:02:46 I think the name should reflect that it is meant t
MuVen 2015/07/09 17:51:35 Done.
108 {
109 if (IsApproxZero(unUsedDelta.width()))
majidvp 2015/07/09 15:02:46 s/unUsedDelta/unusedDelta/ for consistency
MuVen 2015/07/09 17:51:35 Done.
110 unUsedDelta.setWidth(0);
111 if (IsApproxZero(unUsedDelta.height()))
112 unUsedDelta.setHeight(0);
113 return unUsedDelta;
114 }
115
100 using namespace HTMLNames; 116 using namespace HTMLNames;
101 117
102 // The link drag hysteresis is much larger than the others because there 118 // The link drag hysteresis is much larger than the others because there
103 // needs to be enough space to cancel the link press without starting a link dra g, 119 // needs to be enough space to cancel the link press without starting a link dra g,
104 // and because dragging links is rare. 120 // and because dragging links is rare.
105 static const int LinkDragHysteresis = 40; 121 static const int LinkDragHysteresis = 40;
106 static const int ImageDragHysteresis = 5; 122 static const int ImageDragHysteresis = 5;
107 static const int TextDragHysteresis = 3; 123 static const int TextDragHysteresis = 3;
108 static const int GeneralDragHysteresis = 3; 124 static const int GeneralDragHysteresis = 3;
109 125
(...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 { 2252 {
2237 if (didScrollX) 2253 if (didScrollX)
2238 m_accumulatedRootOverscroll.setWidth(0); 2254 m_accumulatedRootOverscroll.setWidth(0);
2239 if (didScrollY) 2255 if (didScrollY)
2240 m_accumulatedRootOverscroll.setHeight(0); 2256 m_accumulatedRootOverscroll.setHeight(0);
2241 } 2257 }
2242 2258
2243 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa tPoint& position, const FloatSize& velocity) 2259 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa tPoint& position, const FloatSize& velocity)
2244 { 2260 {
2245 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY); 2261 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY);
2262 unusedDelta = ZeroSmallComponents(unusedDelta);
2246 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); 2263 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY);
2247 if (unusedDelta != FloatSize()) { 2264 if (unusedDelta != FloatSize()) {
2248 m_accumulatedRootOverscroll += unusedDelta; 2265 m_accumulatedRootOverscroll += unusedDelta;
2249 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); 2266 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity);
2250 } 2267 }
2251 } 2268 }
2252 2269
2253 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) 2270 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event)
2254 { 2271 {
2255 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); 2272 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate);
2256 2273
2257 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); 2274 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY());
2275
majidvp 2015/07/09 15:02:46 unnecessary blank line.
MuVen 2015/07/09 17:51:35 Done.
2258 if (delta.isZero()) 2276 if (delta.isZero())
2259 return false; 2277 return false;
2260 2278
2261 Node* node = m_scrollGestureHandlingNode.get(); 2279 Node* node = m_scrollGestureHandlingNode.get();
2262 if (node) { 2280 if (node) {
2263 LayoutObject* layoutObject = node->layoutObject(); 2281 LayoutObject* layoutObject = node->layoutObject();
2264 if (!layoutObject) 2282 if (!layoutObject)
2265 return false; 2283 return false;
2266 2284
2267 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 2285 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 unsigned EventHandler::accessKeyModifiers() 3940 unsigned EventHandler::accessKeyModifiers()
3923 { 3941 {
3924 #if OS(MACOSX) 3942 #if OS(MACOSX)
3925 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3943 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3926 #else 3944 #else
3927 return PlatformEvent::AltKey; 3945 return PlatformEvent::AltKey;
3928 #endif 3946 #endif
3929 } 3947 }
3930 3948
3931 } // namespace blink 3949 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698