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

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

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse constructor Created 3 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
« no previous file with comments | « ui/events/blink/web_input_event_unittest.cc ('k') | ui/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_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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 int id = 0; 474 int id = 0;
475 475
476 // Only used by mouse wheel events. The amount to scroll. This is in multiples 476 // Only used by mouse wheel events. The amount to scroll. This is in multiples
477 // of kWheelDelta. 477 // of kWheelDelta.
478 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up. 478 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up.
479 gfx::Vector2d offset; 479 gfx::Vector2d offset;
480 }; 480 };
481 481
482 class EVENTS_EXPORT MouseEvent : public LocatedEvent { 482 class EVENTS_EXPORT MouseEvent : public LocatedEvent {
483 public: 483 public:
484 static const int32_t kMousePointerId;
485
484 explicit MouseEvent(const base::NativeEvent& native_event); 486 explicit MouseEvent(const base::NativeEvent& native_event);
485 487
486 // |pointer_event.IsMousePointerEvent()| must be true. 488 // |pointer_event.IsMousePointerEvent()| must be true.
487 // Note: If |pointer_event| is a mouse wheel pointer event, use the 489 // Note: If |pointer_event| is a mouse wheel pointer event, use the
488 // MouseWheelEvent version of this function to convert to a MouseWheelEvent 490 // MouseWheelEvent version of this function to convert to a MouseWheelEvent
489 // instead. 491 // instead.
490 explicit MouseEvent(const PointerEvent& pointer_event); 492 explicit MouseEvent(const PointerEvent& pointer_event);
491 493
492 // Create a new MouseEvent based on the provided model. 494 // Create a new MouseEvent based on the provided model.
493 // Uses the provided |type| and |flags| for the new event. 495 // Uses the provided |type| and |flags| for the new event.
(...skipping 18 matching lines...) Expand all
512 set_flags(flags); 514 set_flags(flags);
513 } 515 }
514 516
515 // Used for synthetic events in testing, gesture recognizer and Ozone 517 // Used for synthetic events in testing, gesture recognizer and Ozone
516 // Note: Use the ctor for MouseWheelEvent if type is ET_MOUSEWHEEL. 518 // Note: Use the ctor for MouseWheelEvent if type is ET_MOUSEWHEEL.
517 MouseEvent(EventType type, 519 MouseEvent(EventType type,
518 const gfx::Point& location, 520 const gfx::Point& location,
519 const gfx::Point& root_location, 521 const gfx::Point& root_location,
520 base::TimeTicks time_stamp, 522 base::TimeTicks time_stamp,
521 int flags, 523 int flags,
522 int changed_button_flags); 524 int changed_button_flags,
525 const PointerDetails& pointer_details =
526 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE,
527 kMousePointerId));
sadrul 2017/04/10 18:10:06 I was a bit worried about the lifetime of the obje
523 528
524 // Conveniences to quickly test what button is down 529 // Conveniences to quickly test what button is down
525 bool IsOnlyLeftMouseButton() const { 530 bool IsOnlyLeftMouseButton() const {
526 return button_flags() == EF_LEFT_MOUSE_BUTTON; 531 return button_flags() == EF_LEFT_MOUSE_BUTTON;
527 } 532 }
528 533
529 bool IsLeftMouseButton() const { 534 bool IsLeftMouseButton() const {
530 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; 535 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0;
531 } 536 }
532 537
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // that was released. 579 // that was released.
575 // NOTE: during a press and release flags() contains the complete set of 580 // NOTE: during a press and release flags() contains the complete set of
576 // flags. Use this to determine the button that was pressed or released. 581 // flags. Use this to determine the button that was pressed or released.
577 int changed_button_flags() const { return changed_button_flags_; } 582 int changed_button_flags() const { return changed_button_flags_; }
578 583
579 // Updates the button that changed. 584 // Updates the button that changed.
580 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } 585 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; }
581 586
582 // Event details common to MouseEvent and TouchEvent. 587 // Event details common to MouseEvent and TouchEvent.
583 const PointerDetails& pointer_details() const { return pointer_details_; } 588 const PointerDetails& pointer_details() const { return pointer_details_; }
584 void set_pointer_details(const PointerDetails& details);
585 589
586 private: 590 private:
587 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); 591 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease);
588 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); 592 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft);
589 593
590 // Returns the repeat count based on the previous mouse click, if it is 594 // Returns the repeat count based on the previous mouse click, if it is
591 // recent enough and within a small enough distance. 595 // recent enough and within a small enough distance.
592 static int GetRepeatCount(const MouseEvent& click_event); 596 static int GetRepeatCount(const MouseEvent& click_event);
593 597
594 // Resets the last_click_event_ for unit tests. 598 // Resets the last_click_event_ for unit tests.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // release and cancel events where the associated touch press event 730 // release and cancel events where the associated touch press event
727 // created a mapping between the native id and the touch_id_. 731 // created a mapping between the native id and the touch_id_.
728 bool should_remove_native_touch_id_mapping_; 732 bool should_remove_native_touch_id_mapping_;
729 733
730 // Structure for holding pointer details for implementing PointerEvents API. 734 // Structure for holding pointer details for implementing PointerEvents API.
731 PointerDetails pointer_details_; 735 PointerDetails pointer_details_;
732 }; 736 };
733 737
734 class EVENTS_EXPORT PointerEvent : public LocatedEvent { 738 class EVENTS_EXPORT PointerEvent : public LocatedEvent {
735 public: 739 public:
736 static const int32_t kMousePointerId;
737
738 // Returns true if a PointerEvent can be constructed from |event|. Currently, 740 // Returns true if a PointerEvent can be constructed from |event|. Currently,
739 // only mouse and touch events can be converted to pointer events. 741 // only mouse and touch events can be converted to pointer events.
740 static bool CanConvertFrom(const Event& event); 742 static bool CanConvertFrom(const Event& event);
741 743
742 PointerEvent(const PointerEvent& pointer_event); 744 PointerEvent(const PointerEvent& pointer_event);
743 explicit PointerEvent(const MouseEvent& mouse_event); 745 explicit PointerEvent(const MouseEvent& mouse_event);
744 explicit PointerEvent(const TouchEvent& touch_event); 746 explicit PointerEvent(const TouchEvent& touch_event);
745 747
746 PointerEvent(EventType type, 748 PointerEvent(EventType type,
747 const gfx::Point& location, 749 const gfx::Point& location,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 // dispatched. This field gets a non-zero value only for gestures that are 1050 // dispatched. This field gets a non-zero value only for gestures that are
1049 // released through TouchDispositionGestureFilter::SendGesture. The gesture 1051 // released through TouchDispositionGestureFilter::SendGesture. The gesture
1050 // events that aren't fired directly in response to processing a touch-event 1052 // events that aren't fired directly in response to processing a touch-event
1051 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. 1053 // (e.g. timer fired ones), this id is zero. See crbug.com/618738.
1052 uint32_t unique_touch_event_id_; 1054 uint32_t unique_touch_event_id_;
1053 }; 1055 };
1054 1056
1055 } // namespace ui 1057 } // namespace ui
1056 1058
1057 #endif // UI_EVENTS_EVENT_H_ 1059 #endif // UI_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/events/blink/web_input_event_unittest.cc ('k') | ui/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698