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 "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/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
15 #include "ui/events/gesture_event_details.h" | 16 #include "ui/events/gesture_event_details.h" |
16 #include "ui/events/gestures/gesture_types.h" | 17 #include "ui/events/gestures/gesture_types.h" |
17 #include "ui/events/keycodes/keyboard_codes.h" | 18 #include "ui/events/keycodes/keyboard_codes.h" |
18 #include "ui/events/latency_info.h" | 19 #include "ui/events/latency_info.h" |
19 #include "ui/gfx/point.h" | 20 #include "ui/gfx/point.h" |
20 #include "ui/gfx/point_conversions.h" | 21 #include "ui/gfx/point_conversions.h" |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 // Create a character event. | 585 // Create a character event. |
585 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); | 586 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); |
586 | 587 |
587 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 588 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
588 // See also: ui/events/keycodes/dom4/keycode_converter_data.h | 589 // See also: ui/events/keycodes/dom4/keycode_converter_data.h |
589 KeyEvent(EventType type, | 590 KeyEvent(EventType type, |
590 KeyboardCode key_code, | 591 KeyboardCode key_code, |
591 const std::string& code, | 592 const std::string& code, |
592 int flags); | 593 int flags); |
593 | 594 |
595 KeyEvent(const KeyEvent& rhs); | |
596 | |
597 KeyEvent& operator=(const KeyEvent& rhs); | |
598 | |
599 virtual ~KeyEvent(); | |
600 | |
601 // Used for synthetic events inside of mojo. | |
602 // | |
603 // TODO(erg): While we transition to mojo, we have to hack around a mismatch | |
604 // in our event types. Our ui::Events don't really have all the data we need | |
605 // to process key events, and we instead do per-platform conversions with | |
606 // native HWNDs or XEvents. And we can't reliably send those native data | |
607 // types across mojo types in a cross-platform way. So instead, we set the | |
608 // resulting data when read across IPC boundaries. | |
609 // | |
610 // Please note that |windows_key_code| does not necessarily have the same | |
611 // value as |key_code()|. Long term, those values will go away as we | |
612 // transition to mojo. | |
613 void SetSelfContainedKeyEventData(int32_t windows_key_code, | |
sky
2014/08/21 15:44:42
SelfContained? Maybe SetExtendedData? (KeyEvent is
| |
614 int32_t platform_key_code, | |
615 base::char16 text, | |
616 base::char16 unmodified_text); | |
617 | |
618 // These accessors will first return data from a native event if it exists, | |
619 // and will then check explicitly set values from | |
620 // SetSelfContainedKeyEventData(). | |
621 int32_t GetWindowsKeyCode() const; | |
622 base::char16 GetKeyText() const; | |
623 base::char16 GetKeyUnmodifiedText() const; | |
624 | |
594 // This bypasses the normal mapping from keystroke events to characters, | 625 // This bypasses the normal mapping from keystroke events to characters, |
595 // which allows an I18N virtual keyboard to fabricate a keyboard event that | 626 // which allows an I18N virtual keyboard to fabricate a keyboard event that |
596 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small | 627 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small |
597 // letter A with acute, U+0410 Cyrillic capital letter A). | 628 // letter A with acute, U+0410 Cyrillic capital letter A). |
598 void set_character(base::char16 character) { character_ = character; } | 629 void set_character(base::char16 character) { character_ = character; } |
599 | 630 |
600 // Gets the character generated by this key event. It only supports Unicode | 631 // Gets the character generated by this key event. It only supports Unicode |
601 // BMP characters. | 632 // BMP characters. |
602 base::char16 GetCharacter() const; | 633 base::char16 GetCharacter() const; |
603 | 634 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 uint32 platform_keycode_; | 683 uint32 platform_keycode_; |
653 | 684 |
654 // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'â') | 685 // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'â') |
655 // http://www.w3.org/TR/uievents/#keyboard-key-codes. | 686 // http://www.w3.org/TR/uievents/#keyboard-key-codes. |
656 // | 687 // |
657 // This value represents the text that the key event will insert to input | 688 // This value represents the text that the key event will insert to input |
658 // field. For key with modifier key, it may have specifial text. | 689 // field. For key with modifier key, it may have specifial text. |
659 // e.g. CTRL+A has '\x01'. | 690 // e.g. CTRL+A has '\x01'. |
660 base::char16 character_; | 691 base::char16 character_; |
661 | 692 |
693 // Parts of our event handling require raw native events (see both the | |
694 // windows and linux implementations of web_input_event in content/). Because | |
695 // mojo instead serializes and deserializes events in potentially different | |
696 // processes, we need to have a mechanism to keep track of this data. | |
697 struct ExtendedMojoData; | |
698 scoped_ptr<ExtendedMojoData> extended_mojo_data_; | |
699 | |
662 static bool IsRepeated(const KeyEvent& event); | 700 static bool IsRepeated(const KeyEvent& event); |
663 | 701 |
664 static KeyEvent* last_key_event_; | 702 static KeyEvent* last_key_event_; |
665 }; | 703 }; |
666 | 704 |
667 class EVENTS_EXPORT ScrollEvent : public MouseEvent { | 705 class EVENTS_EXPORT ScrollEvent : public MouseEvent { |
668 public: | 706 public: |
669 explicit ScrollEvent(const base::NativeEvent& native_event); | 707 explicit ScrollEvent(const base::NativeEvent& native_event); |
670 template <class T> | 708 template <class T> |
671 ScrollEvent(const ScrollEvent& model, | 709 ScrollEvent(const ScrollEvent& model, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 | 771 |
734 const GestureEventDetails& details() const { return details_; } | 772 const GestureEventDetails& details() const { return details_; } |
735 | 773 |
736 private: | 774 private: |
737 GestureEventDetails details_; | 775 GestureEventDetails details_; |
738 }; | 776 }; |
739 | 777 |
740 } // namespace ui | 778 } // namespace ui |
741 | 779 |
742 #endif // UI_EVENTS_EVENT_H_ | 780 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |