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

Side by Side Diff: content/renderer/input/input_scroll_elasticity_controller.h

Issue 703753003: Rename ScrollElasticityController variables to Chromium style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase before land Created 6 years, 1 month 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 | content/renderer/input/input_scroll_elasticity_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_INPUT_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
6 #define CONTENT_RENDERER_INPUT_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
7
1 /* 8 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 9 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 10 *
4 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
6 * are met: 13 * are met:
7 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 15 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 16 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 17 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 18 * documentation and/or other materials provided with the distribution.
12 * 19 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 20 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 30 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 31 */
25 32
26 #ifndef ScrollElasticityController_h 33 namespace content {
27 #define ScrollElasticityController_h
28
29 #if USE(RUBBER_BANDING)
30
31 // #include "platform/PlatformExport.h"
32 // #include "platform/geometry/FloatPoint.h"
33 // #include "platform/geometry/FloatSize.h"
34 // #include "platform/scroll/ScrollTypes.h"
35 // #include "wtf/Noncopyable.h"
36
37 namespace blink {
38
39 class PlatformWheelEvent;
40 34
41 class ScrollElasticityControllerClient { 35 class ScrollElasticityControllerClient {
42 protected: 36 protected:
43 virtual ~ScrollElasticityControllerClient() { } 37 virtual ~ScrollElasticityControllerClient() { }
44 38
45 public: 39 public:
46 virtual bool allowsHorizontalStretching() = 0; 40 virtual bool AllowsHorizontalStretching() = 0;
47 virtual bool allowsVerticalStretching() = 0; 41 virtual bool AllowsVerticalStretching() = 0;
48 // The amount that the view is stretched past the normal allowable bounds. 42 // The amount that the view is stretched past the normal allowable bounds.
49 // The "overhang" amount. 43 // The "overhang" amount.
50 virtual IntSize stretchAmount() = 0; 44 virtual IntSize StretchAmount() = 0;
51 virtual bool pinnedInDirection(const FloatSize&) = 0; 45 virtual bool PinnedInDirection(const FloatSize&) = 0;
52 virtual bool canScrollHorizontally() = 0; 46 virtual bool CanScrollHorizontally() = 0;
53 virtual bool canScrollVertically() = 0; 47 virtual bool CanScrollVertically() = 0;
54 48
55 // Return the absolute scroll position, not relative to the scroll origin. 49 // Return the absolute scroll position, not relative to the scroll origin.
56 virtual blink::IntPoint absoluteScrollPosition() = 0; 50 virtual blink::IntPoint AbsoluteScrollPosition() = 0;
57 51
58 virtual void immediateScrollBy(const FloatSize&) = 0; 52 virtual void ImmediateScrollBy(const FloatSize&) = 0;
59 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize& ) = 0; 53 virtual void ImmediateScrollByWithoutContentEdgeConstraints(const FloatSize& ) = 0;
60 virtual void startSnapRubberbandTimer() = 0; 54 virtual void StartSnapRubberbandTimer() = 0;
61 virtual void stopSnapRubberbandTimer() = 0; 55 virtual void StopSnapRubberbandTimer() = 0;
62 56
63 // If the current scroll position is within the overhang area, this function will cause 57 // If the current scroll position is within the overhang area, this function will cause
64 // the page to scroll to the nearest boundary point. 58 // the page to scroll to the nearest boundary point.
65 virtual void adjustScrollPositionToBoundsIfNecessary() = 0; 59 virtual void AdjustScrollPositionToBoundsIfNecessary() = 0;
66 }; 60 };
67 61
68 class PLATFORM_EXPORT ScrollElasticityController { 62 class ScrollElasticityController {
69 WTF_MAKE_NONCOPYABLE(ScrollElasticityController);
70 63
71 public: 64 public:
72 explicit ScrollElasticityController(ScrollElasticityControllerClient*); 65 explicit ScrollElasticityController(ScrollElasticityControllerClient*);
73 66
74 // This method is responsible for both scrolling and rubber-banding. 67 // This method is responsible for both scrolling and rubber-banding.
75 // 68 //
76 // Events are passed by IPC from the embedder. Events on Mac are grouped 69 // Events are passed by IPC from the embedder. Events on Mac are grouped
77 // into "gestures". If this method returns 'true', then this object has 70 // into "gestures". If this method returns 'true', then this object has
78 // handled the event. It expects the embedder to continue to forward events 71 // handled the event. It expects the embedder to continue to forward events
79 // from the gesture. 72 // from the gesture.
80 // 73 //
81 // This method makes the assumption that there is only 1 input device being 74 // This method makes the assumption that there is only 1 input device being
82 // used at a time. If the user simultaneously uses multiple input devices, 75 // used at a time. If the user simultaneously uses multiple input devices,
83 // Cocoa does not correctly pass all the gestureBegin/End events. The state 76 // Cocoa does not correctly pass all the gestureBegin/End events. The state
84 // of this class is guaranteed to become eventually consistent, once the 77 // of this class is guaranteed to become eventually consistent, once the
85 // user stops using multiple input devices. 78 // user stops using multiple input devices.
86 bool handleWheelEvent(const PlatformWheelEvent&); 79 bool HandleWheelEvent(const PlatformWheelEvent&);
87 void snapRubberBandTimerFired(); 80 void SnapRubberbandTimerFired();
88 81
89 bool isRubberBandInProgress() const; 82 bool IsRubberbandInProgress() const;
90 83
91 private: 84 private:
92 void stopSnapRubberbandTimer(); 85 void StopSnapRubberbandTimer();
93 void snapRubberBand(); 86 void SnapRubberband();
94 87
95 // This method determines whether a given event should be handled. The 88 // This method determines whether a given event should be handled. The
96 // logic for control events of gestures (PhaseBegan, PhaseEnded) is handled 89 // logic for control events of gestures (PhaseBegan, PhaseEnded) is handled
97 // elsewhere. 90 // elsewhere.
98 // 91 //
99 // This class handles almost all wheel events. All of the following 92 // This class handles almost all wheel events. All of the following
100 // conditions must be met for this class to ignore an event: 93 // conditions must be met for this class to ignore an event:
101 // + No previous events in this gesture have caused any scrolling or rubber 94 // + No previous events in this gesture have caused any scrolling or rubber
102 // banding. 95 // banding.
103 // + The event contains a horizontal component. 96 // + The event contains a horizontal component.
104 // + The client's view is pinned in the horizontal direction of the event. 97 // + The client's view is pinned in the horizontal direction of the event.
105 // + The wheel event disallows rubber banding in the horizontal direction 98 // + The wheel event disallows rubber banding in the horizontal direction
106 // of the event. 99 // of the event.
107 bool shouldHandleEvent(const PlatformWheelEvent&); 100 bool shouldHandleEvent(const PlatformWheelEvent&);
108 101
109 ScrollElasticityControllerClient* m_client; 102 ScrollElasticityControllerClient* client_;
110 103
111 // There is an active scroll gesture event. This parameter only gets set to 104 // There is an active scroll gesture event. This parameter only gets set to
112 // false after the rubber band has been snapped, and before a new gesture 105 // false after the rubber band has been snapped, and before a new gesture
113 // has begun. A careful audit of the code may deprecate the need for this 106 // has begun. A careful audit of the code may deprecate the need for this
114 // parameter. 107 // parameter.
115 bool m_inScrollGesture; 108 bool in_scroll_gesture_;
116 // At least one event in the current gesture has been consumed and has 109 // At least one event in the current gesture has been consumed and has
117 // caused the view to scroll or rubber band. All future events in this 110 // caused the view to scroll or rubber band. All future events in this
118 // gesture will be consumed and overscrolls will cause rubberbanding. 111 // gesture will be consumed and overscrolls will cause rubberbanding.
119 bool m_hasScrolled; 112 bool has_scrolled_;
120 bool m_momentumScrollInProgress; 113 bool momentum_scroll_in_progress_;
121 bool m_ignoreMomentumScrolls; 114 bool ignore_momentum_scrolls_;
122 115
123 CFTimeInterval m_lastMomentumScrollTimestamp; 116 CFTimeInterval last_momentum_scroll_timestamp_;
124 FloatSize m_overflowScrollDelta; 117 FloatSize overflow_scroll_delta_;
125 FloatSize m_stretchScrollForce; 118 FloatSize stretch_scroll_force_;
126 FloatSize m_momentumVelocity; 119 FloatSize momentum_velocity_;
127 120
128 // Rubber band state. 121 // Rubber band state.
129 CFTimeInterval m_startTime; 122 CFTimeInterval start_time_;
130 FloatSize m_startStretch; 123 FloatSize start_stretch_;
131 FloatPoint m_origOrigin; 124 FloatPoint orig_origin_;
132 FloatSize m_origVelocity; 125 FloatSize orig_velocity_;
133 126
134 bool m_snapRubberbandTimerIsActive; 127 bool snap_rubberband_timer_is_active_;
135 }; 128 };
136 129
137 } // namespace blink 130 } // namespace content
138 131
139 #endif // USE(RUBBER_BANDING) 132 #endif // CONTENT_RENDERER_INPUT_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
140
141 #endif // ScrollElasticityController_h
OLDNEW
« no previous file with comments | « no previous file | content/renderer/input/input_scroll_elasticity_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698