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

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

Issue 24257011: Revert "Revert 224496 "Move ui/base/latency_info* to ui/events"" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp bustage Created 7 years, 2 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 | « ui/base/latency_info_unittest.cc ('k') | ui/events/event_conversion_gtk.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 // 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_EVENTS_EVENT_H_ 5 #ifndef UI_EVENTS_EVENT_H_
6 #define UI_EVENTS_EVENT_H_ 6 #define UI_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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/base/dragdrop/os_exchange_data.h" 13 #include "ui/base/dragdrop/os_exchange_data.h"
14 #include "ui/base/gestures/gesture_types.h" 14 #include "ui/base/gestures/gesture_types.h"
15 #include "ui/base/latency_info.h"
16 #include "ui/base/ui_export.h"
17 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
18 #include "ui/events/keycodes/keyboard_codes.h" 16 #include "ui/events/keycodes/keyboard_codes.h"
17 #include "ui/events/latency_info.h"
19 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
20 19
21 namespace gfx { 20 namespace gfx {
22 class Transform; 21 class Transform;
23 } 22 }
24 23
25 namespace ui { 24 namespace ui {
26 class EventTarget; 25 class EventTarget;
27 26
28 class UI_EXPORT Event { 27 class EVENTS_EXPORT Event {
29 public: 28 public:
30 virtual ~Event(); 29 virtual ~Event();
31 30
32 class DispatcherApi { 31 class DispatcherApi {
33 public: 32 public:
34 explicit DispatcherApi(Event* event) : event_(event) {} 33 explicit DispatcherApi(Event* event) : event_(event) {}
35 34
36 void set_target(EventTarget* target) { 35 void set_target(EventTarget* target) {
37 event_->target_ = target; 36 event_->target_ = target;
38 } 37 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 int flags_; 230 int flags_;
232 bool dispatch_to_hidden_targets_; 231 bool dispatch_to_hidden_targets_;
233 base::NativeEvent native_event_; 232 base::NativeEvent native_event_;
234 bool delete_native_event_; 233 bool delete_native_event_;
235 bool cancelable_; 234 bool cancelable_;
236 EventTarget* target_; 235 EventTarget* target_;
237 EventPhase phase_; 236 EventPhase phase_;
238 EventResult result_; 237 EventResult result_;
239 }; 238 };
240 239
241 class UI_EXPORT CancelModeEvent : public Event { 240 class EVENTS_EXPORT CancelModeEvent : public Event {
242 public: 241 public:
243 CancelModeEvent(); 242 CancelModeEvent();
244 virtual ~CancelModeEvent(); 243 virtual ~CancelModeEvent();
245 }; 244 };
246 245
247 class UI_EXPORT LocatedEvent : public Event { 246 class EVENTS_EXPORT LocatedEvent : public Event {
248 public: 247 public:
249 // For testing. 248 // For testing.
250 class TestApi : public Event::TestApi { 249 class TestApi : public Event::TestApi {
251 public: 250 public:
252 explicit TestApi(LocatedEvent* located_event) 251 explicit TestApi(LocatedEvent* located_event)
253 : Event::TestApi(located_event), 252 : Event::TestApi(located_event),
254 located_event_(located_event) {} 253 located_event_(located_event) {}
255 254
256 void set_location(const gfx::Point& location) { 255 void set_location(const gfx::Point& location) {
257 located_event_->location_ = location; 256 located_event_->location_ = location;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 base::TimeDelta time_stamp, 303 base::TimeDelta time_stamp,
305 int flags); 304 int flags);
306 305
307 gfx::Point location_; 306 gfx::Point location_;
308 307
309 // |location_| multiplied by an optional transformation matrix for 308 // |location_| multiplied by an optional transformation matrix for
310 // rotations, animations and skews. 309 // rotations, animations and skews.
311 gfx::Point root_location_; 310 gfx::Point root_location_;
312 }; 311 };
313 312
314 class UI_EXPORT MouseEvent : public LocatedEvent { 313 class EVENTS_EXPORT MouseEvent : public LocatedEvent {
315 public: 314 public:
316 explicit MouseEvent(const base::NativeEvent& native_event); 315 explicit MouseEvent(const base::NativeEvent& native_event);
317 316
318 // Create a new MouseEvent based on the provided model. 317 // Create a new MouseEvent based on the provided model.
319 // Uses the provided |type| and |flags| for the new event. 318 // Uses the provided |type| and |flags| for the new event.
320 // If source / target windows are provided, the model location will be 319 // If source / target windows are provided, the model location will be
321 // converted from |source| coordinate system to |target| coordinate system. 320 // converted from |source| coordinate system to |target| coordinate system.
322 template <class T> 321 template <class T>
323 MouseEvent(const MouseEvent& model, T* source, T* target) 322 MouseEvent(const MouseEvent& model, T* source, T* target)
324 : LocatedEvent(model, source, target), 323 : LocatedEvent(model, source, target),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 static int GetRepeatCount(const MouseEvent& click_event); 400 static int GetRepeatCount(const MouseEvent& click_event);
402 401
403 // See description above getter for details. 402 // See description above getter for details.
404 int changed_button_flags_; 403 int changed_button_flags_;
405 404
406 static MouseEvent* last_click_event_; 405 static MouseEvent* last_click_event_;
407 }; 406 };
408 407
409 class ScrollEvent; 408 class ScrollEvent;
410 409
411 class UI_EXPORT MouseWheelEvent : public MouseEvent { 410 class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
412 public: 411 public:
413 // See |offset| for details. 412 // See |offset| for details.
414 static const int kWheelDelta; 413 static const int kWheelDelta;
415 414
416 explicit MouseWheelEvent(const base::NativeEvent& native_event); 415 explicit MouseWheelEvent(const base::NativeEvent& native_event);
417 explicit MouseWheelEvent(const ScrollEvent& scroll_event); 416 explicit MouseWheelEvent(const ScrollEvent& scroll_event);
418 MouseWheelEvent(const MouseEvent& mouse_event, int x_offset, int y_offset); 417 MouseWheelEvent(const MouseEvent& mouse_event, int x_offset, int y_offset);
419 MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event); 418 MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event);
420 419
421 template <class T> 420 template <class T>
(...skipping 13 matching lines...) Expand all
435 const gfx::Vector2d& offset() const { return offset_; } 434 const gfx::Vector2d& offset() const { return offset_; }
436 435
437 // Overridden from LocatedEvent. 436 // Overridden from LocatedEvent.
438 virtual void UpdateForRootTransform( 437 virtual void UpdateForRootTransform(
439 const gfx::Transform& inverted_root_transform) OVERRIDE; 438 const gfx::Transform& inverted_root_transform) OVERRIDE;
440 439
441 private: 440 private:
442 gfx::Vector2d offset_; 441 gfx::Vector2d offset_;
443 }; 442 };
444 443
445 class UI_EXPORT TouchEvent : public LocatedEvent { 444 class EVENTS_EXPORT TouchEvent : public LocatedEvent {
446 public: 445 public:
447 explicit TouchEvent(const base::NativeEvent& native_event); 446 explicit TouchEvent(const base::NativeEvent& native_event);
448 447
449 // Create a new TouchEvent which is identical to the provided model. 448 // Create a new TouchEvent which is identical to the provided model.
450 // If source / target windows are provided, the model location will be 449 // If source / target windows are provided, the model location will be
451 // converted from |source| coordinate system to |target| coordinate system. 450 // converted from |source| coordinate system to |target| coordinate system.
452 template <class T> 451 template <class T>
453 TouchEvent(const TouchEvent& model, T* source, T* target) 452 TouchEvent(const TouchEvent& model, T* source, T* target)
454 : LocatedEvent(model, source, target), 453 : LocatedEvent(model, source, target),
455 touch_id_(model.touch_id_), 454 touch_id_(model.touch_id_),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. 517 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown.
519 float radius_y_; 518 float radius_y_;
520 519
521 // Angle of the major axis away from the X axis. Default 0.0. 520 // Angle of the major axis away from the X axis. Default 0.0.
522 float rotation_angle_; 521 float rotation_angle_;
523 522
524 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. 523 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
525 float force_; 524 float force_;
526 }; 525 };
527 526
528 class UI_EXPORT KeyEvent : public Event { 527 class EVENTS_EXPORT KeyEvent : public Event {
529 public: 528 public:
530 KeyEvent(const base::NativeEvent& native_event, bool is_char); 529 KeyEvent(const base::NativeEvent& native_event, bool is_char);
531 530
532 // Used for synthetic events. 531 // Used for synthetic events.
533 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); 532 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char);
534 533
535 // These setters allow an I18N virtual keyboard to fabricate a keyboard event 534 // These setters allow an I18N virtual keyboard to fabricate a keyboard event
536 // which does not have a corresponding KeyboardCode (example: U+00E1 Latin 535 // which does not have a corresponding KeyboardCode (example: U+00E1 Latin
537 // small letter A with acute, U+0410 Cyrillic capital letter A.) 536 // small letter A with acute, U+0410 Cyrillic capital letter A.)
538 // GetCharacter() and GetUnmodifiedCharacter() return the character. 537 // GetCharacter() and GetUnmodifiedCharacter() return the character.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 uint16 character_; 577 uint16 character_;
579 uint16 unmodified_character_; 578 uint16 unmodified_character_;
580 }; 579 };
581 580
582 // A key event which is translated by an input method (IME). 581 // A key event which is translated by an input method (IME).
583 // For example, if an IME receives a KeyEvent(VKEY_SPACE), and it does not 582 // For example, if an IME receives a KeyEvent(VKEY_SPACE), and it does not
584 // consume the key, the IME usually generates and dispatches a 583 // consume the key, the IME usually generates and dispatches a
585 // TranslatedKeyEvent(VKEY_SPACE) event. If the IME receives a KeyEvent and 584 // TranslatedKeyEvent(VKEY_SPACE) event. If the IME receives a KeyEvent and
586 // it does consume the event, it might dispatch a 585 // it does consume the event, it might dispatch a
587 // TranslatedKeyEvent(VKEY_PROCESSKEY) event as defined in the DOM spec. 586 // TranslatedKeyEvent(VKEY_PROCESSKEY) event as defined in the DOM spec.
588 class UI_EXPORT TranslatedKeyEvent : public KeyEvent { 587 class EVENTS_EXPORT TranslatedKeyEvent : public KeyEvent {
589 public: 588 public:
590 TranslatedKeyEvent(const base::NativeEvent& native_event, bool is_char); 589 TranslatedKeyEvent(const base::NativeEvent& native_event, bool is_char);
591 590
592 // Used for synthetic events such as a VKEY_PROCESSKEY key event. 591 // Used for synthetic events such as a VKEY_PROCESSKEY key event.
593 TranslatedKeyEvent(bool is_press, KeyboardCode key_code, int flags); 592 TranslatedKeyEvent(bool is_press, KeyboardCode key_code, int flags);
594 593
595 // Changes the type() of the object from ET_TRANSLATED_KEY_* to ET_KEY_* so 594 // Changes the type() of the object from ET_TRANSLATED_KEY_* to ET_KEY_* so
596 // that RenderWidgetHostViewAura and NativeWidgetAura could handle the event. 595 // that RenderWidgetHostViewAura and NativeWidgetAura could handle the event.
597 void ConvertToKeyEvent(); 596 void ConvertToKeyEvent();
598 597
599 private: 598 private:
600 DISALLOW_COPY_AND_ASSIGN(TranslatedKeyEvent); 599 DISALLOW_COPY_AND_ASSIGN(TranslatedKeyEvent);
601 }; 600 };
602 601
603 class UI_EXPORT DropTargetEvent : public LocatedEvent { 602 class EVENTS_EXPORT DropTargetEvent : public LocatedEvent {
604 public: 603 public:
605 DropTargetEvent(const OSExchangeData& data, 604 DropTargetEvent(const OSExchangeData& data,
606 const gfx::Point& location, 605 const gfx::Point& location,
607 const gfx::Point& root_location, 606 const gfx::Point& root_location,
608 int source_operations); 607 int source_operations);
609 608
610 const OSExchangeData& data() const { return data_; } 609 const OSExchangeData& data() const { return data_; }
611 int source_operations() const { return source_operations_; } 610 int source_operations() const { return source_operations_; }
612 611
613 private: 612 private:
614 // Data associated with the drag/drop session. 613 // Data associated with the drag/drop session.
615 const OSExchangeData& data_; 614 const OSExchangeData& data_;
616 615
617 // Bitmask of supported DragDropTypes::DragOperation by the source. 616 // Bitmask of supported DragDropTypes::DragOperation by the source.
618 int source_operations_; 617 int source_operations_;
619 618
620 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); 619 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
621 }; 620 };
622 621
623 class UI_EXPORT ScrollEvent : public MouseEvent { 622 class EVENTS_EXPORT ScrollEvent : public MouseEvent {
624 public: 623 public:
625 explicit ScrollEvent(const base::NativeEvent& native_event); 624 explicit ScrollEvent(const base::NativeEvent& native_event);
626 template <class T> 625 template <class T>
627 ScrollEvent(const ScrollEvent& model, 626 ScrollEvent(const ScrollEvent& model,
628 T* source, 627 T* source,
629 T* target) 628 T* target)
630 : MouseEvent(model, source, target), 629 : MouseEvent(model, source, target),
631 x_offset_(model.x_offset_), 630 x_offset_(model.x_offset_),
632 y_offset_(model.y_offset_), 631 y_offset_(model.y_offset_),
633 x_offset_ordinal_(model.x_offset_ordinal_), 632 x_offset_ordinal_(model.x_offset_ordinal_),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // Potential accelerated offsets. 664 // Potential accelerated offsets.
666 float x_offset_; 665 float x_offset_;
667 float y_offset_; 666 float y_offset_;
668 // Unaccelerated offsets. 667 // Unaccelerated offsets.
669 float x_offset_ordinal_; 668 float x_offset_ordinal_;
670 float y_offset_ordinal_; 669 float y_offset_ordinal_;
671 // Number of fingers on the pad. 670 // Number of fingers on the pad.
672 int finger_count_; 671 int finger_count_;
673 }; 672 };
674 673
675 class UI_EXPORT GestureEvent : public LocatedEvent { 674 class EVENTS_EXPORT GestureEvent : public LocatedEvent {
676 public: 675 public:
677 GestureEvent(EventType type, 676 GestureEvent(EventType type,
678 int x, 677 int x,
679 int y, 678 int y,
680 int flags, 679 int flags,
681 base::TimeDelta time_stamp, 680 base::TimeDelta time_stamp,
682 const GestureEventDetails& details, 681 const GestureEventDetails& details,
683 unsigned int touch_ids_bitfield); 682 unsigned int touch_ids_bitfield);
684 683
685 // Create a new GestureEvent which is identical to the provided model. 684 // Create a new GestureEvent which is identical to the provided model.
(...skipping 24 matching lines...) Expand all
710 // The set of indices of ones in the binary representation of 709 // The set of indices of ones in the binary representation of
711 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. 710 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture.
712 // This value is stored as a bitfield because the number of touch ids varies, 711 // This value is stored as a bitfield because the number of touch ids varies,
713 // but we currently don't need more than 32 touches at a time. 712 // but we currently don't need more than 32 touches at a time.
714 const unsigned int touch_ids_bitfield_; 713 const unsigned int touch_ids_bitfield_;
715 }; 714 };
716 715
717 } // namespace ui 716 } // namespace ui
718 717
719 #endif // UI_EVENTS_EVENT_H_ 718 #endif // UI_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/base/latency_info_unittest.cc ('k') | ui/events/event_conversion_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698