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

Side by Side Diff: ui/base/events/event.h

Issue 13902003: Remove Event::system_location (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « ui/aura/test/event_generator.cc ('k') | ui/base/events/event.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_EVENTS_EVENT_H_ 5 #ifndef UI_BASE_EVENTS_EVENT_H_
6 #define UI_BASE_EVENTS_EVENT_H_ 6 #define UI_BASE_EVENTS_EVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/event_types.h" 10 #include "base/event_types.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 void set_name(const std::string& name) { name_ = name; } 208 void set_name(const std::string& name) { name_ = name; }
209 209
210 private: 210 private:
211 void operator=(const Event&); 211 void operator=(const Event&);
212 212
213 // Safely initializes the native event members of this class. 213 // Safely initializes the native event members of this class.
214 void Init(); 214 void Init();
215 void InitWithNativeEvent(const base::NativeEvent& native_event); 215 void InitWithNativeEvent(const base::NativeEvent& native_event);
216 216
217 base::NativeEvent native_event_;
218 EventType type_; 217 EventType type_;
219 std::string name_; 218 std::string name_;
220 base::TimeDelta time_stamp_; 219 base::TimeDelta time_stamp_;
221 int flags_; 220 int flags_;
222 bool dispatch_to_hidden_targets_; 221 bool dispatch_to_hidden_targets_;
222 base::NativeEvent native_event_;
223 bool delete_native_event_; 223 bool delete_native_event_;
224 bool cancelable_; 224 bool cancelable_;
225 EventTarget* target_; 225 EventTarget* target_;
226 EventPhase phase_; 226 EventPhase phase_;
227 EventResult result_; 227 EventResult result_;
228 }; 228 };
229 229
230 class UI_EXPORT CancelModeEvent : public Event { 230 class UI_EXPORT CancelModeEvent : public Event {
231 public: 231 public:
232 CancelModeEvent(); 232 CancelModeEvent();
(...skipping 22 matching lines...) Expand all
255 255
256 int x() const { return location_.x(); } 256 int x() const { return location_.x(); }
257 int y() const { return location_.y(); } 257 int y() const { return location_.y(); }
258 void set_location(const gfx::Point& location) { location_ = location; } 258 void set_location(const gfx::Point& location) { location_ = location; }
259 gfx::Point location() const { return location_; } 259 gfx::Point location() const { return location_; }
260 void set_root_location(const gfx::Point& root_location) { 260 void set_root_location(const gfx::Point& root_location) {
261 root_location_ = root_location; 261 root_location_ = root_location;
262 } 262 }
263 gfx::Point root_location() const { return root_location_; } 263 gfx::Point root_location() const { return root_location_; }
264 264
265 bool valid_system_location() const { return valid_system_location_; }
266 void set_system_location(const gfx::Point& loc) {
267 valid_system_location_ = true;
268 system_location_ = loc;
269 }
270 const gfx::Point& system_location() const { return system_location_; }
271
272 // Transform the locations using |inverted_root_transform|. 265 // Transform the locations using |inverted_root_transform|.
273 // This is applied to both |location_| and |root_location_|. 266 // This is applied to both |location_| and |root_location_|.
274 virtual void UpdateForRootTransform( 267 virtual void UpdateForRootTransform(
275 const gfx::Transform& inverted_root_transform); 268 const gfx::Transform& inverted_root_transform);
276 269
277 template <class T> void ConvertLocationToTarget(T* source, T* target) { 270 template <class T> void ConvertLocationToTarget(T* source, T* target) {
278 if (target && target != source) 271 if (target && target != source)
279 T::ConvertPointToTarget(source, target, &location_); 272 T::ConvertPointToTarget(source, target, &location_);
280 } 273 }
281 274
282 protected: 275 protected:
283 explicit LocatedEvent(const base::NativeEvent& native_event); 276 explicit LocatedEvent(const base::NativeEvent& native_event);
284 277
285 // Create a new LocatedEvent which is identical to the provided model. 278 // Create a new LocatedEvent which is identical to the provided model.
286 // If source / target windows are provided, the model location will be 279 // If source / target windows are provided, the model location will be
287 // converted from |source| coordinate system to |target| coordinate system. 280 // converted from |source| coordinate system to |target| coordinate system.
288 template <class T> 281 template <class T>
289 LocatedEvent(const LocatedEvent& model, T* source, T* target) 282 LocatedEvent(const LocatedEvent& model, T* source, T* target)
290 : Event(model), 283 : Event(model),
291 location_(model.location_), 284 location_(model.location_),
292 root_location_(model.root_location_), 285 root_location_(model.root_location_) {
293 valid_system_location_(model.valid_system_location_),
294 system_location_(model.system_location_) {
295 // TODO(erg): May need to create system_location_ by converting location to
296 // system coordinates here.
297 ConvertLocationToTarget(source, target); 286 ConvertLocationToTarget(source, target);
298 } 287 }
299 288
300 // Used for synthetic events in testing. 289 // Used for synthetic events in testing.
301 LocatedEvent(EventType type, 290 LocatedEvent(EventType type,
302 const gfx::Point& location, 291 const gfx::Point& location,
303 const gfx::Point& root_location, 292 const gfx::Point& root_location,
304 base::TimeDelta time_stamp, 293 base::TimeDelta time_stamp,
305 int flags); 294 int flags);
306 295
307 gfx::Point location_; 296 gfx::Point location_;
308 297
309 // |location_| multiplied by an optional transformation matrix for 298 // |location_| multiplied by an optional transformation matrix for
310 // rotations, animations and skews. 299 // rotations, animations and skews.
311 gfx::Point root_location_; 300 gfx::Point root_location_;
312
313 // |location_| in underlying system screen coordinates. This can be invalid
314 // |during synthesized events if a location isn't explicitly set.
315 bool valid_system_location_;
316 gfx::Point system_location_;
317 }; 301 };
318 302
319 class UI_EXPORT MouseEvent : public LocatedEvent { 303 class UI_EXPORT MouseEvent : public LocatedEvent {
320 public: 304 public:
321 explicit MouseEvent(const base::NativeEvent& native_event); 305 explicit MouseEvent(const base::NativeEvent& native_event);
322 306
323 // Create a new MouseEvent based on the provided model. 307 // Create a new MouseEvent based on the provided model.
324 // Uses the provided |type| and |flags| for the new event. 308 // Uses the provided |type| and |flags| for the new event.
325 // If source / target windows are provided, the model location will be 309 // If source / target windows are provided, the model location will be
326 // converted from |source| coordinate system to |target| coordinate system. 310 // converted from |source| coordinate system to |target| coordinate system.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // This value is stored as a bitfield because the number of touch ids varies, 694 // This value is stored as a bitfield because the number of touch ids varies,
711 // but we currently don't need more than 32 touches at a time. 695 // but we currently don't need more than 32 touches at a time.
712 const unsigned int touch_ids_bitfield_; 696 const unsigned int touch_ids_bitfield_;
713 697
714 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 698 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
715 }; 699 };
716 700
717 } // namespace ui 701 } // namespace ui
718 702
719 #endif // UI_BASE_EVENTS_EVENT_H_ 703 #endif // UI_BASE_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/aura/test/event_generator.cc ('k') | ui/base/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698