| OLD | NEW |
| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 explicit MouseEvent(const PointerEvent& pointer_event); | 493 explicit MouseEvent(const PointerEvent& pointer_event); |
| 494 | 494 |
| 495 // Create a new MouseEvent based on the provided model. | 495 // Create a new MouseEvent based on the provided model. |
| 496 // Uses the provided |type| and |flags| for the new event. | 496 // Uses the provided |type| and |flags| for the new event. |
| 497 // If source / target windows are provided, the model location will be | 497 // If source / target windows are provided, the model location will be |
| 498 // converted from |source| coordinate system to |target| coordinate system. | 498 // converted from |source| coordinate system to |target| coordinate system. |
| 499 template <class T> | 499 template <class T> |
| 500 MouseEvent(const MouseEvent& model, T* source, T* target) | 500 MouseEvent(const MouseEvent& model, T* source, T* target) |
| 501 : LocatedEvent(model, source, target), | 501 : LocatedEvent(model, source, target), |
| 502 changed_button_flags_(model.changed_button_flags_), | 502 changed_button_flags_(model.changed_button_flags_), |
| 503 pointer_details_(model.pointer_details_) {} | 503 pointer_details_(model.pointer_details_), |
| 504 only_for_ui_hover_state_(model.only_for_ui_hover_state_) {} |
| 504 | 505 |
| 505 template <class T> | 506 template <class T> |
| 506 MouseEvent(const MouseEvent& model, | 507 MouseEvent(const MouseEvent& model, |
| 507 T* source, | 508 T* source, |
| 508 T* target, | 509 T* target, |
| 509 EventType type, | 510 EventType type, |
| 510 int flags) | 511 int flags) |
| 511 : LocatedEvent(model, source, target), | 512 : LocatedEvent(model, source, target), |
| 512 changed_button_flags_(model.changed_button_flags_), | 513 changed_button_flags_(model.changed_button_flags_), |
| 513 pointer_details_(model.pointer_details_) { | 514 pointer_details_(model.pointer_details_), |
| 515 only_for_ui_hover_state_(model.only_for_ui_hover_state_) { |
| 514 SetType(type); | 516 SetType(type); |
| 515 set_flags(flags); | 517 set_flags(flags); |
| 516 } | 518 } |
| 517 | 519 |
| 518 // Used for synthetic events in testing, gesture recognizer and Ozone | 520 // Used for synthetic events in testing, gesture recognizer and Ozone |
| 519 // Note: Use the ctor for MouseWheelEvent if type is ET_MOUSEWHEEL. | 521 // Note: Use the ctor for MouseWheelEvent if type is ET_MOUSEWHEEL. |
| 520 MouseEvent(EventType type, | 522 MouseEvent(EventType type, |
| 521 const gfx::Point& location, | 523 const gfx::Point& location, |
| 522 const gfx::Point& root_location, | 524 const gfx::Point& root_location, |
| 523 base::TimeTicks time_stamp, | 525 base::TimeTicks time_stamp, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 // NOTE: during a press and release flags() contains the complete set of | 583 // NOTE: during a press and release flags() contains the complete set of |
| 582 // flags. Use this to determine the button that was pressed or released. | 584 // flags. Use this to determine the button that was pressed or released. |
| 583 int changed_button_flags() const { return changed_button_flags_; } | 585 int changed_button_flags() const { return changed_button_flags_; } |
| 584 | 586 |
| 585 // Updates the button that changed. | 587 // Updates the button that changed. |
| 586 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } | 588 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } |
| 587 | 589 |
| 588 // Event details common to MouseEvent and TouchEvent. | 590 // Event details common to MouseEvent and TouchEvent. |
| 589 const PointerDetails& pointer_details() const { return pointer_details_; } | 591 const PointerDetails& pointer_details() const { return pointer_details_; } |
| 590 | 592 |
| 593 // Set the event is for browser UI hover state update. |
| 594 void set_only_for_ui_hover_state(bool yes) { only_for_ui_hover_state_ = yes; } |
| 595 |
| 596 // Get the event is for browser UI hover state update. |
| 597 bool only_for_ui_hover_state() const { return only_for_ui_hover_state_; } |
| 598 |
| 591 private: | 599 private: |
| 592 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); | 600 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); |
| 593 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); | 601 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); |
| 594 | 602 |
| 595 // Returns the repeat count based on the previous mouse click, if it is | 603 // Returns the repeat count based on the previous mouse click, if it is |
| 596 // recent enough and within a small enough distance. | 604 // recent enough and within a small enough distance. |
| 597 static int GetRepeatCount(const MouseEvent& click_event); | 605 static int GetRepeatCount(const MouseEvent& click_event); |
| 598 | 606 |
| 599 // Resets the last_click_event_ for unit tests. | 607 // Resets the last_click_event_ for unit tests. |
| 600 static void ResetLastClickForTest(); | 608 static void ResetLastClickForTest(); |
| 601 | 609 |
| 602 // See description above getter for details. | 610 // See description above getter for details. |
| 603 int changed_button_flags_; | 611 int changed_button_flags_; |
| 604 | 612 |
| 605 static MouseEvent* last_click_event_; | 613 static MouseEvent* last_click_event_; |
| 606 | 614 |
| 607 // We can create a MouseEvent for a native event more than once. We set this | 615 // We can create a MouseEvent for a native event more than once. We set this |
| 608 // to true when the next event either has a different timestamp or we see a | 616 // to true when the next event either has a different timestamp or we see a |
| 609 // release signalling that the press (click) event was completed. | 617 // release signalling that the press (click) event was completed. |
| 610 static bool last_click_complete_; | 618 static bool last_click_complete_; |
| 611 | 619 |
| 612 // Structure for holding pointer details for implementing PointerEvents API. | 620 // Structure for holding pointer details for implementing PointerEvents API. |
| 613 PointerDetails pointer_details_; | 621 PointerDetails pointer_details_; |
| 622 |
| 623 // ChOS dispatch a mouse event only for update UI hover state, event with |
| 624 // this flag should be filter in Blink. |
| 625 bool only_for_ui_hover_state_; |
| 614 }; | 626 }; |
| 615 | 627 |
| 616 class ScrollEvent; | 628 class ScrollEvent; |
| 617 | 629 |
| 618 class EVENTS_EXPORT MouseWheelEvent : public MouseEvent { | 630 class EVENTS_EXPORT MouseWheelEvent : public MouseEvent { |
| 619 public: | 631 public: |
| 620 // See |offset| for details. | 632 // See |offset| for details. |
| 621 static const int kWheelDelta; | 633 static const int kWheelDelta; |
| 622 | 634 |
| 623 explicit MouseWheelEvent(const base::NativeEvent& native_event); | 635 explicit MouseWheelEvent(const base::NativeEvent& native_event); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 // dispatched. This field gets a non-zero value only for gestures that are | 1066 // dispatched. This field gets a non-zero value only for gestures that are |
| 1055 // released through TouchDispositionGestureFilter::SendGesture. The gesture | 1067 // released through TouchDispositionGestureFilter::SendGesture. The gesture |
| 1056 // events that aren't fired directly in response to processing a touch-event | 1068 // events that aren't fired directly in response to processing a touch-event |
| 1057 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. | 1069 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. |
| 1058 uint32_t unique_touch_event_id_; | 1070 uint32_t unique_touch_event_id_; |
| 1059 }; | 1071 }; |
| 1060 | 1072 |
| 1061 } // namespace ui | 1073 } // namespace ui |
| 1062 | 1074 |
| 1063 #endif // UI_EVENTS_EVENT_H_ | 1075 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |