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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge master Created 4 years, 6 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 // 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 DispatcherApi(); 70 DispatcherApi();
71 Event* event_; 71 Event* event_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); 73 DISALLOW_COPY_AND_ASSIGN(DispatcherApi);
74 }; 74 };
75 75
76 const base::NativeEvent& native_event() const { return native_event_; } 76 const base::NativeEvent& native_event() const { return native_event_; }
77 EventType type() const { return type_; } 77 EventType type() const { return type_; }
78 const std::string& name() const { return name_; } 78 const std::string& name() const { return name_; }
79 // time_stamp represents time since machine was booted. 79 // time_stamp represents time since machine was booted.
80 const base::TimeDelta& time_stamp() const { return time_stamp_; } 80 const base::TimeTicks time_stamp() const { return time_stamp_; }
81 int flags() const { return flags_; } 81 int flags() const { return flags_; }
82 82
83 // This is only intended to be used externally by classes that are modifying 83 // This is only intended to be used externally by classes that are modifying
84 // events in an EventRewriter. 84 // events in an EventRewriter.
85 void set_flags(int flags) { flags_ = flags; } 85 void set_flags(int flags) { flags_ = flags; }
86 86
87 EventTarget* target() const { return target_; } 87 EventTarget* target() const { return target_; }
88 EventPhase phase() const { return phase_; } 88 EventPhase phase() const { return phase_; }
89 EventResult result() const { return result_; } 89 EventResult result() const { return result_; }
90 90
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 // Marks the event as having been handled. A handled event does not reach the 276 // Marks the event as having been handled. A handled event does not reach the
277 // next event phase. For example, if an event is handled during the pre-target 277 // next event phase. For example, if an event is handled during the pre-target
278 // phase, then the event is dispatched to all pre-target handlers, but not to 278 // phase, then the event is dispatched to all pre-target handlers, but not to
279 // the target or post-target handlers. 279 // the target or post-target handlers.
280 // Note that SetHandled() can be called only for cancelable events. 280 // Note that SetHandled() can be called only for cancelable events.
281 void SetHandled(); 281 void SetHandled();
282 bool handled() const { return result_ != ER_UNHANDLED; } 282 bool handled() const { return result_ != ER_UNHANDLED; }
283 283
284 protected: 284 protected:
285 Event(EventType type, base::TimeDelta time_stamp, int flags); 285 Event(EventType type, base::TimeTicks time_stamp, int flags);
286 Event(const base::NativeEvent& native_event, EventType type, int flags); 286 Event(const base::NativeEvent& native_event, EventType type, int flags);
287 Event(const Event& copy); 287 Event(const Event& copy);
288 void SetType(EventType type); 288 void SetType(EventType type);
289 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } 289 void set_cancelable(bool cancelable) { cancelable_ = cancelable; }
290 290
291 void set_time_stamp(const base::TimeDelta& time_stamp) { 291 void set_time_stamp(base::TimeTicks time_stamp) {
292 time_stamp_ = time_stamp; 292 time_stamp_ = time_stamp;
293 } 293 }
294 294
295 void set_name(const std::string& name) { name_ = name; } 295 void set_name(const std::string& name) { name_ = name; }
296 296
297 private: 297 private:
298 friend class EventTestApi; 298 friend class EventTestApi;
299 299
300 // For (de)serialization. 300 // For (de)serialization.
301 friend struct IPC::ParamTraits<ui::ScopedEvent>; 301 friend struct IPC::ParamTraits<ui::ScopedEvent>;
302 302
303 EventType type_; 303 EventType type_;
304 std::string name_; 304 std::string name_;
305 base::TimeDelta time_stamp_; 305 base::TimeTicks time_stamp_;
306 LatencyInfo latency_; 306 LatencyInfo latency_;
307 int flags_; 307 int flags_;
308 base::NativeEvent native_event_; 308 base::NativeEvent native_event_;
309 bool delete_native_event_; 309 bool delete_native_event_;
310 bool cancelable_; 310 bool cancelable_;
311 EventTarget* target_; 311 EventTarget* target_;
312 EventPhase phase_; 312 EventPhase phase_;
313 EventResult result_; 313 EventResult result_;
314 314
315 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information 315 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information
316 // is not available. 316 // is not available.
317 int source_device_id_; 317 int source_device_id_;
318 }; 318 };
319 319
320 class EVENTS_EXPORT CancelModeEvent : public Event { 320 class EVENTS_EXPORT CancelModeEvent : public Event {
321 public: 321 public:
322 CancelModeEvent(); 322 CancelModeEvent();
323 ~CancelModeEvent() override; 323 ~CancelModeEvent() override;
324 324
325 private: 325 private:
326 // For (de)serialization. 326 // For (de)serialization.
327 CancelModeEvent(EventType type, base::TimeDelta time_stamp, int flags) 327 CancelModeEvent(EventType type, base::TimeTicks time_stamp, int flags)
328 : Event(type, time_stamp, flags) {} 328 : Event(type, time_stamp, flags) {}
329 friend struct IPC::ParamTraits<ui::ScopedEvent>; 329 friend struct IPC::ParamTraits<ui::ScopedEvent>;
330 friend struct IPC::ParamTraits<ui::CancelModeEvent>; 330 friend struct IPC::ParamTraits<ui::CancelModeEvent>;
331 }; 331 };
332 332
333 class EVENTS_EXPORT LocatedEvent : public Event { 333 class EVENTS_EXPORT LocatedEvent : public Event {
334 public: 334 public:
335 ~LocatedEvent() override; 335 ~LocatedEvent() override;
336 336
337 float x() const { return location_.x(); } 337 float x() const { return location_.x(); }
(...skipping 28 matching lines...) Expand all
366 gfx::Point offset = gfx::ToFlooredPoint(location_); 366 gfx::Point offset = gfx::ToFlooredPoint(location_);
367 T::ConvertPointToTarget(source, target, &offset); 367 T::ConvertPointToTarget(source, target, &offset);
368 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset; 368 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset;
369 location_= location_ - diff; 369 location_= location_ - diff;
370 } 370 }
371 371
372 protected: 372 protected:
373 friend class LocatedEventTestApi; 373 friend class LocatedEventTestApi;
374 374
375 // For (de)serialization. 375 // For (de)serialization.
376 LocatedEvent(EventType type, base::TimeDelta time_stamp, int flags) 376 LocatedEvent(EventType type, base::TimeTicks time_stamp, int flags)
377 : Event(type, time_stamp, flags) {} 377 : Event(type, time_stamp, flags) {}
378 friend struct IPC::ParamTraits<ui::ScopedEvent>; 378 friend struct IPC::ParamTraits<ui::ScopedEvent>;
379 friend struct IPC::ParamTraits<ui::LocatedEvent>; 379 friend struct IPC::ParamTraits<ui::LocatedEvent>;
380 380
381 explicit LocatedEvent(const base::NativeEvent& native_event); 381 explicit LocatedEvent(const base::NativeEvent& native_event);
382 382
383 // Create a new LocatedEvent which is identical to the provided model. 383 // Create a new LocatedEvent which is identical to the provided model.
384 // If source / target windows are provided, the model location will be 384 // If source / target windows are provided, the model location will be
385 // converted from |source| coordinate system to |target| coordinate system. 385 // converted from |source| coordinate system to |target| coordinate system.
386 template <class T> 386 template <class T>
387 LocatedEvent(const LocatedEvent& model, T* source, T* target) 387 LocatedEvent(const LocatedEvent& model, T* source, T* target)
388 : Event(model), 388 : Event(model),
389 location_(model.location_), 389 location_(model.location_),
390 root_location_(model.root_location_) { 390 root_location_(model.root_location_) {
391 ConvertLocationToTarget(source, target); 391 ConvertLocationToTarget(source, target);
392 } 392 }
393 393
394 // Used for synthetic events in testing. 394 // Used for synthetic events in testing.
395 LocatedEvent(EventType type, 395 LocatedEvent(EventType type,
396 const gfx::PointF& location, 396 const gfx::PointF& location,
397 const gfx::PointF& root_location, 397 const gfx::PointF& root_location,
398 base::TimeDelta time_stamp, 398 base::TimeTicks time_stamp,
399 int flags); 399 int flags);
400 400
401 gfx::PointF location_; 401 gfx::PointF location_;
402 402
403 // |location_| multiplied by an optional transformation matrix for 403 // |location_| multiplied by an optional transformation matrix for
404 // rotations, animations and skews. 404 // rotations, animations and skews.
405 gfx::PointF root_location_; 405 gfx::PointF root_location_;
406 }; 406 };
407 407
408 // Structure for handling common fields between touch and mouse to support 408 // Structure for handling common fields between touch and mouse to support
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 changed_button_flags_(model.changed_button_flags_), 488 changed_button_flags_(model.changed_button_flags_),
489 pointer_details_(model.pointer_details_) { 489 pointer_details_(model.pointer_details_) {
490 SetType(type); 490 SetType(type);
491 set_flags(flags); 491 set_flags(flags);
492 } 492 }
493 493
494 // Used for synthetic events in testing, gesture recognizer and Ozone 494 // Used for synthetic events in testing, gesture recognizer and Ozone
495 MouseEvent(EventType type, 495 MouseEvent(EventType type,
496 const gfx::Point& location, 496 const gfx::Point& location,
497 const gfx::Point& root_location, 497 const gfx::Point& root_location,
498 base::TimeDelta time_stamp, 498 base::TimeTicks time_stamp,
499 int flags, 499 int flags,
500 int changed_button_flags); 500 int changed_button_flags);
501 501
502 // Conveniences to quickly test what button is down 502 // Conveniences to quickly test what button is down
503 bool IsOnlyLeftMouseButton() const { 503 bool IsOnlyLeftMouseButton() const {
504 return button_flags() == EF_LEFT_MOUSE_BUTTON; 504 return button_flags() == EF_LEFT_MOUSE_BUTTON;
505 } 505 }
506 506
507 bool IsLeftMouseButton() const { 507 bool IsLeftMouseButton() const {
508 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; 508 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } 558 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; }
559 559
560 // Event details common to MouseEvent and TouchEvent. 560 // Event details common to MouseEvent and TouchEvent.
561 const PointerDetails& pointer_details() const { return pointer_details_; } 561 const PointerDetails& pointer_details() const { return pointer_details_; }
562 void set_pointer_details(const PointerDetails& details) { 562 void set_pointer_details(const PointerDetails& details) {
563 pointer_details_ = details; 563 pointer_details_ = details;
564 } 564 }
565 565
566 protected: 566 protected:
567 // For (de)serialization. 567 // For (de)serialization.
568 MouseEvent(EventType type, base::TimeDelta time_stamp, int flags) 568 MouseEvent(EventType type, base::TimeTicks time_stamp, int flags)
569 : LocatedEvent(type, time_stamp, flags) {} 569 : LocatedEvent(type, time_stamp, flags) {}
570 friend struct IPC::ParamTraits<ui::ScopedEvent>; 570 friend struct IPC::ParamTraits<ui::ScopedEvent>;
571 friend struct IPC::ParamTraits<ui::MouseEvent>; 571 friend struct IPC::ParamTraits<ui::MouseEvent>;
572 572
573 private: 573 private:
574 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); 574 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease);
575 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); 575 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft);
576 576
577 // Returns the repeat count based on the previous mouse click, if it is 577 // Returns the repeat count based on the previous mouse click, if it is
578 // recent enough and within a small enough distance. 578 // recent enough and within a small enough distance.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 T* source, 612 T* source,
613 T* target) 613 T* target)
614 : MouseEvent(model, source, target, model.type(), model.flags()), 614 : MouseEvent(model, source, target, model.type(), model.flags()),
615 offset_(model.x_offset(), model.y_offset()) { 615 offset_(model.x_offset(), model.y_offset()) {
616 } 616 }
617 617
618 // Used for synthetic events in testing and by the gesture recognizer. 618 // Used for synthetic events in testing and by the gesture recognizer.
619 MouseWheelEvent(const gfx::Vector2d& offset, 619 MouseWheelEvent(const gfx::Vector2d& offset,
620 const gfx::Point& location, 620 const gfx::Point& location,
621 const gfx::Point& root_location, 621 const gfx::Point& root_location,
622 base::TimeDelta time_stamp, 622 base::TimeTicks time_stamp,
623 int flags, 623 int flags,
624 int changed_button_flags); 624 int changed_button_flags);
625 625
626 // The amount to scroll. This is in multiples of kWheelDelta. 626 // The amount to scroll. This is in multiples of kWheelDelta.
627 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. 627 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up.
628 int x_offset() const { return offset_.x(); } 628 int x_offset() const { return offset_.x(); }
629 int y_offset() const { return offset_.y(); } 629 int y_offset() const { return offset_.y(); }
630 const gfx::Vector2d& offset() const { return offset_; } 630 const gfx::Vector2d& offset() const { return offset_; }
631 631
632 private: 632 private:
633 // For (de)serialization. 633 // For (de)serialization.
634 MouseWheelEvent(EventType type, base::TimeDelta time_stamp, int flags) 634 MouseWheelEvent(EventType type, base::TimeTicks time_stamp, int flags)
635 : MouseEvent(type, time_stamp, flags) {} 635 : MouseEvent(type, time_stamp, flags) {}
636 friend struct IPC::ParamTraits<ui::ScopedEvent>; 636 friend struct IPC::ParamTraits<ui::ScopedEvent>;
637 friend struct IPC::ParamTraits<ui::MouseWheelEvent>; 637 friend struct IPC::ParamTraits<ui::MouseWheelEvent>;
638 638
639 gfx::Vector2d offset_; 639 gfx::Vector2d offset_;
640 }; 640 };
641 641
642 class EVENTS_EXPORT TouchEvent : public LocatedEvent { 642 class EVENTS_EXPORT TouchEvent : public LocatedEvent {
643 public: 643 public:
644 explicit TouchEvent(const base::NativeEvent& native_event); 644 explicit TouchEvent(const base::NativeEvent& native_event);
(...skipping 10 matching lines...) Expand all
655 touch_id_(model.touch_id_), 655 touch_id_(model.touch_id_),
656 unique_event_id_(model.unique_event_id_), 656 unique_event_id_(model.unique_event_id_),
657 rotation_angle_(model.rotation_angle_), 657 rotation_angle_(model.rotation_angle_),
658 may_cause_scrolling_(model.may_cause_scrolling_), 658 may_cause_scrolling_(model.may_cause_scrolling_),
659 should_remove_native_touch_id_mapping_(false), 659 should_remove_native_touch_id_mapping_(false),
660 pointer_details_(model.pointer_details_) {} 660 pointer_details_(model.pointer_details_) {}
661 661
662 TouchEvent(EventType type, 662 TouchEvent(EventType type,
663 const gfx::Point& location, 663 const gfx::Point& location,
664 int touch_id, 664 int touch_id,
665 base::TimeDelta time_stamp); 665 base::TimeTicks time_stamp);
666 666
667 TouchEvent(EventType type, 667 TouchEvent(EventType type,
668 const gfx::Point& location, 668 const gfx::Point& location,
669 int flags, 669 int flags,
670 int touch_id, 670 int touch_id,
671 base::TimeDelta timestamp, 671 base::TimeTicks timestamp,
672 float radius_x, 672 float radius_x,
673 float radius_y, 673 float radius_y,
674 float angle, 674 float angle,
675 float force); 675 float force);
676 676
677 TouchEvent(const TouchEvent& copy); 677 TouchEvent(const TouchEvent& copy);
678 678
679 ~TouchEvent() override; 679 ~TouchEvent() override;
680 680
681 // The id of the pointer this event modifies. 681 // The id of the pointer this event modifies.
(...skipping 23 matching lines...) Expand all
705 } 705 }
706 706
707 // Event details common to MouseEvent and TouchEvent. 707 // Event details common to MouseEvent and TouchEvent.
708 const PointerDetails& pointer_details() const { return pointer_details_; } 708 const PointerDetails& pointer_details() const { return pointer_details_; }
709 void set_pointer_details(const PointerDetails& pointer_details) { 709 void set_pointer_details(const PointerDetails& pointer_details) {
710 pointer_details_ = pointer_details; 710 pointer_details_ = pointer_details;
711 } 711 }
712 712
713 private: 713 private:
714 // For (de)serialization. 714 // For (de)serialization.
715 TouchEvent(EventType type, base::TimeDelta time_stamp, int flags) 715 TouchEvent(EventType type, base::TimeTicks time_stamp, int flags)
716 : LocatedEvent(type, time_stamp, flags), 716 : LocatedEvent(type, time_stamp, flags),
717 should_remove_native_touch_id_mapping_(false) {} 717 should_remove_native_touch_id_mapping_(false) {}
718 friend struct IPC::ParamTraits<ui::ScopedEvent>; 718 friend struct IPC::ParamTraits<ui::ScopedEvent>;
719 friend struct IPC::ParamTraits<ui::TouchEvent>; 719 friend struct IPC::ParamTraits<ui::TouchEvent>;
720 720
721 // Adjusts rotation_angle_ to within the acceptable range. 721 // Adjusts rotation_angle_ to within the acceptable range.
722 void FixRotationAngle(); 722 void FixRotationAngle();
723 723
724 // The identity (typically finger) of the touch starting at 0 and incrementing 724 // The identity (typically finger) of the touch starting at 0 and incrementing
725 // for each separable additional touch that the hardware can detect. 725 // for each separable additional touch that the hardware can detect.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 PointerEvent(const PointerEvent& pointer_event); 759 PointerEvent(const PointerEvent& pointer_event);
760 explicit PointerEvent(const MouseEvent& mouse_event); 760 explicit PointerEvent(const MouseEvent& mouse_event);
761 explicit PointerEvent(const TouchEvent& touch_event); 761 explicit PointerEvent(const TouchEvent& touch_event);
762 762
763 PointerEvent(EventType type, 763 PointerEvent(EventType type,
764 EventPointerType pointer_type, 764 EventPointerType pointer_type,
765 const gfx::Point& location, 765 const gfx::Point& location,
766 const gfx::Point& root_location, 766 const gfx::Point& root_location,
767 int flags, 767 int flags,
768 int pointer_id, 768 int pointer_id,
769 base::TimeDelta time_stamp); 769 base::TimeTicks time_stamp);
770 770
771 int32_t pointer_id() const { return pointer_id_; } 771 int32_t pointer_id() const { return pointer_id_; }
772 const PointerDetails& pointer_details() const { return details_; } 772 const PointerDetails& pointer_details() const { return details_; }
773 773
774 protected: 774 protected:
775 // For (de)serialization. 775 // For (de)serialization.
776 PointerEvent(EventType type, base::TimeDelta time_stamp, int flags) 776 PointerEvent(EventType type, base::TimeTicks time_stamp, int flags)
777 : LocatedEvent(type, time_stamp, flags) {} 777 : LocatedEvent(type, time_stamp, flags) {}
778 friend struct IPC::ParamTraits<ui::ScopedEvent>; 778 friend struct IPC::ParamTraits<ui::ScopedEvent>;
779 friend struct IPC::ParamTraits<ui::PointerEvent>; 779 friend struct IPC::ParamTraits<ui::PointerEvent>;
780 780
781 private: 781 private:
782 int32_t pointer_id_; 782 int32_t pointer_id_;
783 PointerDetails details_; 783 PointerDetails details_;
784 }; 784 };
785 785
786 // An interface that individual platforms can use to store additional data on 786 // An interface that individual platforms can use to store additional data on
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // Create a keystroke event from a legacy KeyboardCode. 842 // Create a keystroke event from a legacy KeyboardCode.
843 // This should not be used in new code. 843 // This should not be used in new code.
844 KeyEvent(EventType type, KeyboardCode key_code, int flags); 844 KeyEvent(EventType type, KeyboardCode key_code, int flags);
845 845
846 // Create a fully defined keystroke event. 846 // Create a fully defined keystroke event.
847 KeyEvent(EventType type, 847 KeyEvent(EventType type,
848 KeyboardCode key_code, 848 KeyboardCode key_code,
849 DomCode code, 849 DomCode code,
850 int flags, 850 int flags,
851 DomKey key, 851 DomKey key,
852 base::TimeDelta time_stamp); 852 base::TimeTicks time_stamp);
853 853
854 // Create a character event. 854 // Create a character event.
855 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); 855 KeyEvent(base::char16 character, KeyboardCode key_code, int flags);
856 856
857 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') 857 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
858 // See also: ui/events/keycodes/dom/dom_values.txt 858 // See also: ui/events/keycodes/dom/dom_values.txt
859 KeyEvent(EventType type, 859 KeyEvent(EventType type,
860 KeyboardCode key_code, 860 KeyboardCode key_code,
861 DomCode code, 861 DomCode code,
862 int flags); 862 int flags);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 void NormalizeFlags(); 942 void NormalizeFlags();
943 943
944 protected: 944 protected:
945 friend class KeyEventTestApi; 945 friend class KeyEventTestApi;
946 946
947 // This allows a subclass TranslatedKeyEvent to be a non character event. 947 // This allows a subclass TranslatedKeyEvent to be a non character event.
948 void set_is_char(bool is_char) { is_char_ = is_char; } 948 void set_is_char(bool is_char) { is_char_ = is_char; }
949 949
950 private: 950 private:
951 // For (de)serialization. 951 // For (de)serialization.
952 KeyEvent(EventType type, base::TimeDelta time_stamp, int flags); 952 KeyEvent(EventType type, base::TimeTicks time_stamp, int flags);
953 friend struct IPC::ParamTraits<ui::ScopedEvent>; 953 friend struct IPC::ParamTraits<ui::ScopedEvent>;
954 friend struct IPC::ParamTraits<ui::KeyEvent>; 954 friend struct IPC::ParamTraits<ui::KeyEvent>;
955 955
956 // Determine key_ on a keystroke event from code_ and flags(). 956 // Determine key_ on a keystroke event from code_ and flags().
957 void ApplyLayout() const; 957 void ApplyLayout() const;
958 958
959 KeyboardCode key_code_; 959 KeyboardCode key_code_;
960 960
961 // DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE). 961 // DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE).
962 // http://www.w3.org/TR/DOM-Level-3-Events-code/ 962 // http://www.w3.org/TR/DOM-Level-3-Events-code/
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 x_offset_(model.x_offset_), 1004 x_offset_(model.x_offset_),
1005 y_offset_(model.y_offset_), 1005 y_offset_(model.y_offset_),
1006 x_offset_ordinal_(model.x_offset_ordinal_), 1006 x_offset_ordinal_(model.x_offset_ordinal_),
1007 y_offset_ordinal_(model.y_offset_ordinal_), 1007 y_offset_ordinal_(model.y_offset_ordinal_),
1008 finger_count_(model.finger_count_){ 1008 finger_count_(model.finger_count_){
1009 } 1009 }
1010 1010
1011 // Used for tests. 1011 // Used for tests.
1012 ScrollEvent(EventType type, 1012 ScrollEvent(EventType type,
1013 const gfx::Point& location, 1013 const gfx::Point& location,
1014 base::TimeDelta time_stamp, 1014 base::TimeTicks time_stamp,
1015 int flags, 1015 int flags,
1016 float x_offset, 1016 float x_offset,
1017 float y_offset, 1017 float y_offset,
1018 float x_offset_ordinal, 1018 float x_offset_ordinal,
1019 float y_offset_ordinal, 1019 float y_offset_ordinal,
1020 int finger_count); 1020 int finger_count);
1021 1021
1022 // Scale the scroll event's offset value. 1022 // Scale the scroll event's offset value.
1023 // This is useful in the multi-monitor setup where it needs to be scaled 1023 // This is useful in the multi-monitor setup where it needs to be scaled
1024 // to provide a consistent user experience. 1024 // to provide a consistent user experience.
1025 void Scale(const float factor); 1025 void Scale(const float factor);
1026 1026
1027 float x_offset() const { return x_offset_; } 1027 float x_offset() const { return x_offset_; }
1028 float y_offset() const { return y_offset_; } 1028 float y_offset() const { return y_offset_; }
1029 float x_offset_ordinal() const { return x_offset_ordinal_; } 1029 float x_offset_ordinal() const { return x_offset_ordinal_; }
1030 float y_offset_ordinal() const { return y_offset_ordinal_; } 1030 float y_offset_ordinal() const { return y_offset_ordinal_; }
1031 int finger_count() const { return finger_count_; } 1031 int finger_count() const { return finger_count_; }
1032 1032
1033 private: 1033 private:
1034 // For (de)serialization. 1034 // For (de)serialization.
1035 ScrollEvent(EventType type, base::TimeDelta time_stamp, int flags) 1035 ScrollEvent(EventType type, base::TimeTicks time_stamp, int flags)
1036 : MouseEvent(type, time_stamp, flags) {} 1036 : MouseEvent(type, time_stamp, flags) {}
1037 friend struct IPC::ParamTraits<ui::ScopedEvent>; 1037 friend struct IPC::ParamTraits<ui::ScopedEvent>;
1038 friend struct IPC::ParamTraits<ui::ScrollEvent>; 1038 friend struct IPC::ParamTraits<ui::ScrollEvent>;
1039 1039
1040 // Potential accelerated offsets. 1040 // Potential accelerated offsets.
1041 float x_offset_; 1041 float x_offset_;
1042 float y_offset_; 1042 float y_offset_;
1043 // Unaccelerated offsets. 1043 // Unaccelerated offsets.
1044 float x_offset_ordinal_; 1044 float x_offset_ordinal_;
1045 float y_offset_ordinal_; 1045 float y_offset_ordinal_;
1046 // Number of fingers on the pad. 1046 // Number of fingers on the pad.
1047 int finger_count_; 1047 int finger_count_;
1048 }; 1048 };
1049 1049
1050 class EVENTS_EXPORT GestureEvent : public LocatedEvent { 1050 class EVENTS_EXPORT GestureEvent : public LocatedEvent {
1051 public: 1051 public:
1052 GestureEvent(float x, 1052 GestureEvent(float x,
1053 float y, 1053 float y,
1054 int flags, 1054 int flags,
1055 base::TimeDelta time_stamp, 1055 base::TimeTicks time_stamp,
1056 const GestureEventDetails& details); 1056 const GestureEventDetails& details);
1057 1057
1058 // Create a new GestureEvent which is identical to the provided model. 1058 // Create a new GestureEvent which is identical to the provided model.
1059 // If source / target windows are provided, the model location will be 1059 // If source / target windows are provided, the model location will be
1060 // converted from |source| coordinate system to |target| coordinate system. 1060 // converted from |source| coordinate system to |target| coordinate system.
1061 template <typename T> 1061 template <typename T>
1062 GestureEvent(const GestureEvent& model, T* source, T* target) 1062 GestureEvent(const GestureEvent& model, T* source, T* target)
1063 : LocatedEvent(model, source, target), 1063 : LocatedEvent(model, source, target),
1064 details_(model.details_) { 1064 details_(model.details_) {
1065 } 1065 }
1066 1066
1067 ~GestureEvent() override; 1067 ~GestureEvent() override;
1068 1068
1069 const GestureEventDetails& details() const { return details_; } 1069 const GestureEventDetails& details() const { return details_; }
1070 1070
1071 private: 1071 private:
1072 // For (de)serialization. 1072 // For (de)serialization.
1073 GestureEvent(EventType type, base::TimeDelta time_stamp, int flags) 1073 GestureEvent(EventType type, base::TimeTicks time_stamp, int flags)
1074 : LocatedEvent(type, time_stamp, flags) {} 1074 : LocatedEvent(type, time_stamp, flags) {}
1075 friend struct IPC::ParamTraits<ui::ScopedEvent>; 1075 friend struct IPC::ParamTraits<ui::ScopedEvent>;
1076 friend struct IPC::ParamTraits<ui::GestureEvent>; 1076 friend struct IPC::ParamTraits<ui::GestureEvent>;
1077 1077
1078 GestureEventDetails details_; 1078 GestureEventDetails details_;
1079 }; 1079 };
1080 1080
1081 } // namespace ui 1081 } // namespace ui
1082 1082
1083 #endif // UI_EVENTS_EVENT_H_ 1083 #endif // UI_EVENTS_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698