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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 base::TimeTicks time_stamp); | 731 base::TimeTicks time_stamp); |
732 | 732 |
733 int32_t pointer_id() const { return pointer_id_; } | 733 int32_t pointer_id() const { return pointer_id_; } |
734 const PointerDetails& pointer_details() const { return details_; } | 734 const PointerDetails& pointer_details() const { return details_; } |
735 | 735 |
736 private: | 736 private: |
737 int32_t pointer_id_; | 737 int32_t pointer_id_; |
738 PointerDetails details_; | 738 PointerDetails details_; |
739 }; | 739 }; |
740 | 740 |
741 // An interface that individual platforms can use to store additional data on | |
742 // KeyEvent. | |
743 // | |
744 // Currently only used in mojo. | |
745 class EVENTS_EXPORT ExtendedKeyEventData { | |
746 public: | |
747 virtual ~ExtendedKeyEventData() {} | |
748 | |
749 virtual ExtendedKeyEventData* Clone() const = 0; | |
750 }; | |
751 | |
752 // A KeyEvent is really two distinct classes, melded together due to the | 741 // A KeyEvent is really two distinct classes, melded together due to the |
753 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), | 742 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), |
754 // or a character event (is_char_ == true). | 743 // or a character event (is_char_ == true). |
755 // | 744 // |
756 // For a keystroke event, | 745 // For a keystroke event, |
757 // -- |bool is_char_| is false. | 746 // -- |bool is_char_| is false. |
758 // -- |EventType Event::type()| can be ET_KEY_PRESSED or ET_KEY_RELEASED. | 747 // -- |EventType Event::type()| can be ET_KEY_PRESSED or ET_KEY_RELEASED. |
759 // -- |DomCode code_| and |int Event::flags()| represent the physical key event. | 748 // -- |DomCode code_| and |int Event::flags()| represent the physical key event. |
760 // - code_ is a platform-independent representation of the physical key, | 749 // - code_ is a platform-independent representation of the physical key, |
761 // based on DOM UI Events KeyboardEvent |code| values. It does not | 750 // based on DOM UI Events KeyboardEvent |code| values. It does not |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 KeyboardCode key_code, | 808 KeyboardCode key_code, |
820 DomCode code, | 809 DomCode code, |
821 int flags); | 810 int flags); |
822 | 811 |
823 KeyEvent(const KeyEvent& rhs); | 812 KeyEvent(const KeyEvent& rhs); |
824 | 813 |
825 KeyEvent& operator=(const KeyEvent& rhs); | 814 KeyEvent& operator=(const KeyEvent& rhs); |
826 | 815 |
827 ~KeyEvent() override; | 816 ~KeyEvent() override; |
828 | 817 |
829 // TODO(erg): While we transition to mojo, we have to hack around a mismatch | |
830 // in our event types. Our ui::Events don't really have all the data we need | |
831 // to process key events, and we instead do per-platform conversions with | |
832 // native HWNDs or XEvents. And we can't reliably send those native data | |
833 // types across mojo types in a cross-platform way. So instead, we set the | |
834 // resulting data when read across IPC boundaries. | |
835 void SetExtendedKeyEventData(std::unique_ptr<ExtendedKeyEventData> data); | |
836 const ExtendedKeyEventData* extended_key_event_data() const { | |
837 return extended_key_event_data_.get(); | |
838 } | |
839 | |
840 // This bypasses the normal mapping from keystroke events to characters, | 818 // This bypasses the normal mapping from keystroke events to characters, |
841 // which allows an I18N virtual keyboard to fabricate a keyboard event that | 819 // which allows an I18N virtual keyboard to fabricate a keyboard event that |
842 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small | 820 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small |
843 // letter A with acute, U+0410 Cyrillic capital letter A). | 821 // letter A with acute, U+0410 Cyrillic capital letter A). |
844 void set_character(base::char16 character) { | 822 void set_character(base::char16 character) { |
845 key_ = DomKey::FromCharacter(character); | 823 key_ = DomKey::FromCharacter(character); |
846 } | 824 } |
847 | 825 |
848 // Gets the character generated by this key event. It only supports Unicode | 826 // Gets the character generated by this key event. It only supports Unicode |
849 // BMP characters. | 827 // BMP characters. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 // | 907 // |
930 // DOM KeyboardEvent |key| | 908 // DOM KeyboardEvent |key| |
931 // http://www.w3.org/TR/DOM-Level-3-Events-key/ | 909 // http://www.w3.org/TR/DOM-Level-3-Events-key/ |
932 // | 910 // |
933 // This value represents the meaning of a key, which is either a Unicode | 911 // This value represents the meaning of a key, which is either a Unicode |
934 // character, or a named DomKey:: value. | 912 // character, or a named DomKey:: value. |
935 // This is not necessarily initialized when the event is constructed; | 913 // This is not necessarily initialized when the event is constructed; |
936 // it may be set only if and when GetCharacter() or GetDomKey() is called. | 914 // it may be set only if and when GetCharacter() or GetDomKey() is called. |
937 mutable DomKey key_ = DomKey::NONE; | 915 mutable DomKey key_ = DomKey::NONE; |
938 | 916 |
939 // Parts of our event handling require raw native events (see both the | |
940 // windows and linux implementations of web_input_event in content/). Because | |
941 // mojo instead serializes and deserializes events in potentially different | |
942 // processes, we need to have a mechanism to keep track of this data. | |
943 std::unique_ptr<ExtendedKeyEventData> extended_key_event_data_; | |
944 | |
945 static bool IsRepeated(const KeyEvent& event); | 917 static bool IsRepeated(const KeyEvent& event); |
946 | 918 |
947 static KeyEvent* last_key_event_; | 919 static KeyEvent* last_key_event_; |
948 }; | 920 }; |
949 | 921 |
950 class EVENTS_EXPORT ScrollEvent : public MouseEvent { | 922 class EVENTS_EXPORT ScrollEvent : public MouseEvent { |
951 public: | 923 public: |
952 explicit ScrollEvent(const base::NativeEvent& native_event); | 924 explicit ScrollEvent(const base::NativeEvent& native_event); |
953 template <class T> | 925 template <class T> |
954 ScrollEvent(const ScrollEvent& model, | 926 ScrollEvent(const ScrollEvent& model, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 // dispatched. This field gets a non-zero value only for gestures that are | 1002 // dispatched. This field gets a non-zero value only for gestures that are |
1031 // released through TouchDispositionGestureFilter::SendGesture. The gesture | 1003 // released through TouchDispositionGestureFilter::SendGesture. The gesture |
1032 // events that aren't fired directly in response to processing a touch-event | 1004 // events that aren't fired directly in response to processing a touch-event |
1033 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. | 1005 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. |
1034 uint32_t unique_touch_event_id_; | 1006 uint32_t unique_touch_event_id_; |
1035 }; | 1007 }; |
1036 | 1008 |
1037 } // namespace ui | 1009 } // namespace ui |
1038 | 1010 |
1039 #endif // UI_EVENTS_EVENT_H_ | 1011 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |