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

Side by Side Diff: Source/platform/PlatformWheelEvent.h

Issue 1018183002: Add rails to input wheel events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 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 23 matching lines...) Expand all
34 // Wheel events come in two flavors: 34 // Wheel events come in two flavors:
35 // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precis e number of pixels to scroll. It is sent directly by MacBook touchpads on OS X, 35 // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precis e number of pixels to scroll. It is sent directly by MacBook touchpads on OS X,
36 // and synthesized in other cases where platforms generate line-by-line scrollin g events. 36 // and synthesized in other cases where platforms generate line-by-line scrollin g events.
37 // The ScrollByPageWheelEvent indicates that the wheel event should scroll an en tire page. In this case WebCore's built in paging behavior is used to page 37 // The ScrollByPageWheelEvent indicates that the wheel event should scroll an en tire page. In this case WebCore's built in paging behavior is used to page
38 // up and down (you get the same behavior as if the user was clicking in a scrol lbar track to page up or page down). 38 // up and down (you get the same behavior as if the user was clicking in a scrol lbar track to page up or page down).
39 enum PlatformWheelEventGranularity { 39 enum PlatformWheelEventGranularity {
40 ScrollByPageWheelEvent, 40 ScrollByPageWheelEvent,
41 ScrollByPixelWheelEvent, 41 ScrollByPixelWheelEvent,
42 }; 42 };
43 43
44 enum PlatformWheelEventRailMode {
45 PlatformWheelEventRailModeFree = 0,
46 PlatformWheelEventRailModeHorizontal = 1 << 0,
47 PlatformWheelEventRailModeVertical = 1 << 1,
48 };
49
44 #if OS(MACOSX) 50 #if OS(MACOSX)
45 enum PlatformWheelEventPhase { 51 enum PlatformWheelEventPhase {
46 PlatformWheelEventPhaseNone = 0, 52 PlatformWheelEventPhaseNone = 0,
47 PlatformWheelEventPhaseBegan = 1 << 0, 53 PlatformWheelEventPhaseBegan = 1 << 0,
48 PlatformWheelEventPhaseStationary = 1 << 1, 54 PlatformWheelEventPhaseStationary = 1 << 1,
49 PlatformWheelEventPhaseChanged = 1 << 2, 55 PlatformWheelEventPhaseChanged = 1 << 2,
50 PlatformWheelEventPhaseEnded = 1 << 3, 56 PlatformWheelEventPhaseEnded = 1 << 3,
51 PlatformWheelEventPhaseCancelled = 1 << 4, 57 PlatformWheelEventPhaseCancelled = 1 << 4,
52 PlatformWheelEventPhaseMayBegin = 1 << 5, 58 PlatformWheelEventPhaseMayBegin = 1 << 5,
53 }; 59 };
54 #endif 60 #endif
55 61
56 class PlatformWheelEvent : public PlatformEvent { 62 class PlatformWheelEvent : public PlatformEvent {
57 public: 63 public:
58 PlatformWheelEvent() 64 PlatformWheelEvent()
59 : PlatformEvent(PlatformEvent::Wheel) 65 : PlatformEvent(PlatformEvent::Wheel)
60 , m_deltaX(0) 66 , m_deltaX(0)
61 , m_deltaY(0) 67 , m_deltaY(0)
62 , m_wheelTicksX(0) 68 , m_wheelTicksX(0)
63 , m_wheelTicksY(0) 69 , m_wheelTicksY(0)
64 , m_granularity(ScrollByPixelWheelEvent) 70 , m_granularity(ScrollByPixelWheelEvent)
65 , m_hasPreciseScrollingDeltas(false) 71 , m_hasPreciseScrollingDeltas(false)
66 , m_canScroll(true) 72 , m_canScroll(true)
73 , m_railMode(PlatformWheelEventRailModeFree)
67 #if OS(MACOSX) 74 #if OS(MACOSX)
68 , m_phase(PlatformWheelEventPhaseNone) 75 , m_phase(PlatformWheelEventPhaseNone)
69 , m_momentumPhase(PlatformWheelEventPhaseNone) 76 , m_momentumPhase(PlatformWheelEventPhaseNone)
70 , m_canRubberbandLeft(true) 77 , m_canRubberbandLeft(true)
71 , m_canRubberbandRight(true) 78 , m_canRubberbandRight(true)
72 #endif 79 #endif
73 { 80 {
74 } 81 }
75 82
76 PlatformWheelEvent(IntPoint position, IntPoint globalPosition, float deltaX, float deltaY, float wheelTicksX, float wheelTicksY, PlatformWheelEventGranulari ty granularity, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey) 83 PlatformWheelEvent(IntPoint position, IntPoint globalPosition, float deltaX, float deltaY, float wheelTicksX, float wheelTicksY, PlatformWheelEventGranulari ty granularity, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey)
77 : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey , 0) 84 : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey , 0)
78 , m_position(position) 85 , m_position(position)
79 , m_globalPosition(globalPosition) 86 , m_globalPosition(globalPosition)
80 , m_deltaX(deltaX) 87 , m_deltaX(deltaX)
81 , m_deltaY(deltaY) 88 , m_deltaY(deltaY)
82 , m_wheelTicksX(wheelTicksX) 89 , m_wheelTicksX(wheelTicksX)
83 , m_wheelTicksY(wheelTicksY) 90 , m_wheelTicksY(wheelTicksY)
84 , m_granularity(granularity) 91 , m_granularity(granularity)
85 , m_hasPreciseScrollingDeltas(false) 92 , m_hasPreciseScrollingDeltas(false)
86 , m_canScroll(true) 93 , m_canScroll(true)
94 , m_railMode(PlatformWheelEventRailModeFree)
87 #if OS(MACOSX) 95 #if OS(MACOSX)
88 , m_phase(PlatformWheelEventPhaseNone) 96 , m_phase(PlatformWheelEventPhaseNone)
89 , m_momentumPhase(PlatformWheelEventPhaseNone) 97 , m_momentumPhase(PlatformWheelEventPhaseNone)
90 , m_canRubberbandLeft(true) 98 , m_canRubberbandLeft(true)
91 , m_canRubberbandRight(true) 99 , m_canRubberbandRight(true)
92 #endif 100 #endif
93 { 101 {
94 } 102 }
95 103
96 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates. 104 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates.
97 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates. 105 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates.
98 106
99 float deltaX() const { return m_deltaX; } 107 float deltaX() const { return m_deltaX; }
100 float deltaY() const { return m_deltaY; } 108 float deltaY() const { return m_deltaY; }
101 109
102 float wheelTicksX() const { return m_wheelTicksX; } 110 float wheelTicksX() const { return m_wheelTicksX; }
103 float wheelTicksY() const { return m_wheelTicksY; } 111 float wheelTicksY() const { return m_wheelTicksY; }
104 112
105 PlatformWheelEventGranularity granularity() const { return m_granularity; } 113 PlatformWheelEventGranularity granularity() const { return m_granularity; }
106 114
107 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; } 115 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
108 void setHasPreciseScrollingDeltas(bool b) { m_hasPreciseScrollingDeltas = b; } 116 void setHasPreciseScrollingDeltas(bool b) { m_hasPreciseScrollingDeltas = b; }
109 bool canScroll() const { return m_canScroll; } 117 bool canScroll() const { return m_canScroll; }
110 void setCanScroll(bool b) { m_canScroll = b; } 118 void setCanScroll(bool b) { m_canScroll = b; }
119 PlatformWheelEventRailMode railMode() const { return m_railMode; }
120
111 #if OS(MACOSX) 121 #if OS(MACOSX)
112 PlatformWheelEventPhase phase() const { return m_phase; } 122 PlatformWheelEventPhase phase() const { return m_phase; }
113 PlatformWheelEventPhase momentumPhase() const { return m_momentumPhase; } 123 PlatformWheelEventPhase momentumPhase() const { return m_momentumPhase; }
114 bool useLatchedEventNode() const { return m_momentumPhase == PlatformWheelEv entPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged; } 124 bool useLatchedEventNode() const { return m_momentumPhase == PlatformWheelEv entPhaseBegan || m_momentumPhase == PlatformWheelEventPhaseChanged; }
115 bool canRubberbandLeft() const { return m_canRubberbandLeft; } 125 bool canRubberbandLeft() const { return m_canRubberbandLeft; }
116 bool canRubberbandRight() const { return m_canRubberbandRight; } 126 bool canRubberbandRight() const { return m_canRubberbandRight; }
117 #else 127 #else
118 bool useLatchedEventNode() const { return false; } 128 bool useLatchedEventNode() const { return false; }
119 #endif 129 #endif
120 130
121 protected: 131 protected:
122 IntPoint m_position; 132 IntPoint m_position;
123 IntPoint m_globalPosition; 133 IntPoint m_globalPosition;
124 float m_deltaX; 134 float m_deltaX;
125 float m_deltaY; 135 float m_deltaY;
126 float m_wheelTicksX; 136 float m_wheelTicksX;
127 float m_wheelTicksY; 137 float m_wheelTicksY;
128 PlatformWheelEventGranularity m_granularity; 138 PlatformWheelEventGranularity m_granularity;
129 bool m_hasPreciseScrollingDeltas; 139 bool m_hasPreciseScrollingDeltas;
130 bool m_canScroll; 140 bool m_canScroll;
141 PlatformWheelEventRailMode m_railMode;
131 #if OS(MACOSX) 142 #if OS(MACOSX)
132 PlatformWheelEventPhase m_phase; 143 PlatformWheelEventPhase m_phase;
133 PlatformWheelEventPhase m_momentumPhase; 144 PlatformWheelEventPhase m_momentumPhase;
134 bool m_canRubberbandLeft; 145 bool m_canRubberbandLeft;
135 bool m_canRubberbandRight; 146 bool m_canRubberbandRight;
136 #endif 147 #endif
137 }; 148 };
138 149
139 } // namespace blink 150 } // namespace blink
140 151
141 #endif // PlatformWheelEvent_h 152 #endif // PlatformWheelEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698