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

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

Issue 338543003: Gesture event hit test refactoring and reduction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix release build Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/testing/Internals.cpp ('k') | Source/platform/TraceLocation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 { 42 {
43 memset(&m_data, 0, sizeof(m_data)); 43 memset(&m_data, 0, sizeof(m_data));
44 } 44 }
45 45
46 PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& gl obalPosition, const IntSize& area, double timestamp, bool shiftKey, bool ctrlKey , bool altKey, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY) 46 PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& gl obalPosition, const IntSize& area, double timestamp, bool shiftKey, bool ctrlKey , bool altKey, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY)
47 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp) 47 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
48 , m_position(position) 48 , m_position(position)
49 , m_globalPosition(globalPosition) 49 , m_globalPosition(globalPosition)
50 , m_area(area) 50 , m_area(area)
51 { 51 {
52 ASSERT(type == PlatformEvent::GestureScrollBegin 52 memset(&m_data, 0, sizeof(m_data));
53 if (type == PlatformEvent::GestureScrollBegin
53 || type == PlatformEvent::GestureScrollEnd 54 || type == PlatformEvent::GestureScrollEnd
54 || type == PlatformEvent::GestureScrollUpdate 55 || type == PlatformEvent::GestureScrollUpdate
55 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation); 56 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation) {
56 memset(&m_data, 0, sizeof(m_data)); 57 m_data.m_scrollUpdate.m_deltaX = deltaX;
57 m_data.m_scrollUpdate.m_deltaX = deltaX; 58 m_data.m_scrollUpdate.m_deltaY = deltaY;
58 m_data.m_scrollUpdate.m_deltaY = deltaY; 59 m_data.m_scrollUpdate.m_velocityX = velocityX;
59 m_data.m_scrollUpdate.m_velocityX = velocityX; 60 m_data.m_scrollUpdate.m_velocityY = velocityY;
60 m_data.m_scrollUpdate.m_velocityY = velocityY; 61 }
61 } 62 }
62 63
63 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates. 64 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates.
64 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates. 65 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates.
65 66
66 const IntSize& area() const { return m_area; } 67 const IntSize& area() const { return m_area; }
67 68
68 float deltaX() const 69 float deltaX() const
69 { 70 {
70 ASSERT(m_type == PlatformEvent::GestureScrollUpdate 71 ASSERT(m_type == PlatformEvent::GestureScrollUpdate
(...skipping 27 matching lines...) Expand all
98 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); 99 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation);
99 return m_data.m_scrollUpdate.m_velocityY; 100 return m_data.m_scrollUpdate.m_velocityY;
100 } 101 }
101 102
102 float scale() const 103 float scale() const
103 { 104 {
104 ASSERT(m_type == PlatformEvent::GesturePinchUpdate); 105 ASSERT(m_type == PlatformEvent::GesturePinchUpdate);
105 return m_data.m_pinchUpdate.m_scale; 106 return m_data.m_pinchUpdate.m_scale;
106 } 107 }
107 108
109 void applyTouchAdjustment(const IntPoint& adjustedPosition)
110 {
111 // Update the window-relative position of the event so that the node tha t was
112 // ultimately hit is under this point (i.e. elementFromPoint for the cli ent
113 // co-ordinates in a 'click' event should yield the target). The global
114 // position is intentionally left unmodified because it's intended to re flect
115 // raw co-ordinates unrelated to any content.
116 m_position = adjustedPosition;
117 }
118
119 bool isScrollEvent() const
120 {
121 switch (m_type) {
122 case GestureScrollBegin:
123 case GestureScrollEnd:
124 case GestureScrollUpdate:
125 case GestureScrollUpdateWithoutPropagation:
126 case GestureFlingStart:
127 case GesturePinchBegin:
128 case GesturePinchEnd:
129 case GesturePinchUpdate:
130 return true;
131 case GestureTap:
132 case GestureTapUnconfirmed:
133 case GestureTapDown:
134 case GestureShowPress:
135 case GestureTapDownCancel:
136 case GestureTwoFingerTap:
137 case GestureLongPress:
138 case GestureLongTap:
139 return false;
140 default:
141 ASSERT_NOT_REACHED();
142 return false;
143 }
144 }
145
108 protected: 146 protected:
109 IntPoint m_position; 147 IntPoint m_position;
110 IntPoint m_globalPosition; 148 IntPoint m_globalPosition;
111 IntSize m_area; 149 IntSize m_area;
112 150
113 union { 151 union {
114 struct { 152 struct {
115 int m_tapCount; 153 int m_tapCount;
116 } m_tap; 154 } m_tap;
117 155
118 struct { 156 struct {
119 float m_deltaX; 157 float m_deltaX;
120 float m_deltaY; 158 float m_deltaY;
121 float m_velocityX; 159 float m_velocityX;
122 float m_velocityY; 160 float m_velocityY;
123 } m_scrollUpdate; 161 } m_scrollUpdate;
124 162
125 struct { 163 struct {
126 float m_scale; 164 float m_scale;
127 } m_pinchUpdate; 165 } m_pinchUpdate;
128 } m_data; 166 } m_data;
129 }; 167 };
130 168
131 } // namespace WebCore 169 } // namespace WebCore
132 170
133 #endif // PlatformGestureEvent_h 171 #endif // PlatformGestureEvent_h
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.cpp ('k') | Source/platform/TraceLocation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698