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

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

Issue 492863002: mojo: Plumb through sufficient context to make real blink::WebInputEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final sky nits Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('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 "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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. 539 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown.
539 float radius_y_; 540 float radius_y_;
540 541
541 // Angle of the major axis away from the X axis. Default 0.0. 542 // Angle of the major axis away from the X axis. Default 0.0.
542 float rotation_angle_; 543 float rotation_angle_;
543 544
544 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. 545 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
545 float force_; 546 float force_;
546 }; 547 };
547 548
549 // An interface that individual platforms can use to store additional data on
550 // KeyEvent.
551 //
552 // Currently only used in mojo.
553 class EVENTS_EXPORT ExtendedKeyEventData {
554 public:
555 virtual ~ExtendedKeyEventData() {}
556
557 virtual ExtendedKeyEventData* Clone() const = 0;
558 };
559
548 // A KeyEvent is really two distinct classes, melded together due to the 560 // A KeyEvent is really two distinct classes, melded together due to the
549 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), 561 // DOM legacy of Windows key events: a keystroke event (is_char_ == false),
550 // or a character event (is_char_ == true). 562 // or a character event (is_char_ == true).
551 // 563 //
552 // For a keystroke event, 564 // For a keystroke event,
553 // -- is_char_ is false. 565 // -- is_char_ is false.
554 // -- type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED, 566 // -- type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED,
555 // ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE. 567 // ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE.
556 // -- character_ functions as a bypass or cache for GetCharacter(). 568 // -- character_ functions as a bypass or cache for GetCharacter().
557 // -- key_code_ is a VKEY_ value associated with the key. For printable 569 // -- key_code_ is a VKEY_ value associated with the key. For printable
(...skipping 26 matching lines...) Expand all
584 // Create a character event. 596 // Create a character event.
585 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); 597 KeyEvent(base::char16 character, KeyboardCode key_code, int flags);
586 598
587 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') 599 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
588 // See also: ui/events/keycodes/dom4/keycode_converter_data.h 600 // See also: ui/events/keycodes/dom4/keycode_converter_data.h
589 KeyEvent(EventType type, 601 KeyEvent(EventType type,
590 KeyboardCode key_code, 602 KeyboardCode key_code,
591 const std::string& code, 603 const std::string& code,
592 int flags); 604 int flags);
593 605
606 KeyEvent(const KeyEvent& rhs);
607
608 KeyEvent& operator=(const KeyEvent& rhs);
609
610 virtual ~KeyEvent();
611
612 // TODO(erg): While we transition to mojo, we have to hack around a mismatch
613 // in our event types. Our ui::Events don't really have all the data we need
614 // to process key events, and we instead do per-platform conversions with
615 // native HWNDs or XEvents. And we can't reliably send those native data
616 // types across mojo types in a cross-platform way. So instead, we set the
617 // resulting data when read across IPC boundaries.
618 void SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data);
619 const ExtendedKeyEventData* extended_key_event_data() const {
620 return extended_key_event_data_.get();
621 }
622
594 // This bypasses the normal mapping from keystroke events to characters, 623 // This bypasses the normal mapping from keystroke events to characters,
595 // which allows an I18N virtual keyboard to fabricate a keyboard event that 624 // which allows an I18N virtual keyboard to fabricate a keyboard event that
596 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small 625 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small
597 // letter A with acute, U+0410 Cyrillic capital letter A). 626 // letter A with acute, U+0410 Cyrillic capital letter A).
598 void set_character(base::char16 character) { character_ = character; } 627 void set_character(base::char16 character) { character_ = character; }
599 628
600 // Gets the character generated by this key event. It only supports Unicode 629 // Gets the character generated by this key event. It only supports Unicode
601 // BMP characters. 630 // BMP characters.
602 base::char16 GetCharacter() const; 631 base::char16 GetCharacter() const;
603 632
604 // Gets the platform key code. For XKB, this is the xksym value. 633 // Gets the platform key code. For XKB, this is the xksym value.
634 void set_platform_keycode(uint32 keycode) { platform_keycode_ = keycode; }
605 uint32 platform_keycode() const { return platform_keycode_; } 635 uint32 platform_keycode() const { return platform_keycode_; }
606 KeyboardCode key_code() const { return key_code_; } 636 KeyboardCode key_code() const { return key_code_; }
607 637
608 // True if this is a character event, false if this is a keystroke event. 638 // True if this is a character event, false if this is a keystroke event.
609 bool is_char() const { return is_char_; } 639 bool is_char() const { return is_char_; }
610 640
611 // This is only intended to be used externally by classes that are modifying 641 // This is only intended to be used externally by classes that are modifying
612 // events in an EventRewriter. 642 // events in an EventRewriter.
613 void set_key_code(KeyboardCode key_code) { key_code_ = key_code; } 643 void set_key_code(KeyboardCode key_code) { key_code_ = key_code; }
614 644
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 uint32 platform_keycode_; 682 uint32 platform_keycode_;
653 683
654 // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'â') 684 // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'â')
655 // http://www.w3.org/TR/uievents/#keyboard-key-codes. 685 // http://www.w3.org/TR/uievents/#keyboard-key-codes.
656 // 686 //
657 // This value represents the text that the key event will insert to input 687 // 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. 688 // field. For key with modifier key, it may have specifial text.
659 // e.g. CTRL+A has '\x01'. 689 // e.g. CTRL+A has '\x01'.
660 base::char16 character_; 690 base::char16 character_;
661 691
692 // Parts of our event handling require raw native events (see both the
693 // windows and linux implementations of web_input_event in content/). Because
694 // mojo instead serializes and deserializes events in potentially different
695 // processes, we need to have a mechanism to keep track of this data.
696 scoped_ptr<ExtendedKeyEventData> extended_key_event_data_;
697
662 static bool IsRepeated(const KeyEvent& event); 698 static bool IsRepeated(const KeyEvent& event);
663 699
664 static KeyEvent* last_key_event_; 700 static KeyEvent* last_key_event_;
665 }; 701 };
666 702
667 class EVENTS_EXPORT ScrollEvent : public MouseEvent { 703 class EVENTS_EXPORT ScrollEvent : public MouseEvent {
668 public: 704 public:
669 explicit ScrollEvent(const base::NativeEvent& native_event); 705 explicit ScrollEvent(const base::NativeEvent& native_event);
670 template <class T> 706 template <class T>
671 ScrollEvent(const ScrollEvent& model, 707 ScrollEvent(const ScrollEvent& model,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 769
734 const GestureEventDetails& details() const { return details_; } 770 const GestureEventDetails& details() const { return details_; }
735 771
736 private: 772 private:
737 GestureEventDetails details_; 773 GestureEventDetails details_;
738 }; 774 };
739 775
740 } // namespace ui 776 } // namespace ui
741 777
742 #endif // UI_EVENTS_EVENT_H_ 778 #endif // UI_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('k') | ui/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698