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

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

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // the time the event was created. 87 // the time the event was created.
88 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } 88 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
89 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } 89 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
90 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } 90 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; }
91 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } 91 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
92 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } 92 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; }
93 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } 93 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; }
94 bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; } 94 bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; }
95 95
96 bool IsKeyEvent() const { 96 bool IsKeyEvent() const {
97 return type_ == ET_KEY_PRESSED || 97 return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
98 type_ == ET_KEY_RELEASED ||
99 type_ == ET_TRANSLATED_KEY_PRESS ||
100 type_ == ET_TRANSLATED_KEY_RELEASE;
101 } 98 }
102 99
103 bool IsMouseEvent() const { 100 bool IsMouseEvent() const {
104 return type_ == ET_MOUSE_PRESSED || 101 return type_ == ET_MOUSE_PRESSED ||
105 type_ == ET_MOUSE_DRAGGED || 102 type_ == ET_MOUSE_DRAGGED ||
106 type_ == ET_MOUSE_RELEASED || 103 type_ == ET_MOUSE_RELEASED ||
107 type_ == ET_MOUSE_MOVED || 104 type_ == ET_MOUSE_MOVED ||
108 type_ == ET_MOUSE_ENTERED || 105 type_ == ET_MOUSE_ENTERED ||
109 type_ == ET_MOUSE_EXITED || 106 type_ == ET_MOUSE_EXITED ||
110 type_ == ET_MOUSEWHEEL || 107 type_ == ET_MOUSEWHEEL ||
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 592
596 virtual ExtendedKeyEventData* Clone() const = 0; 593 virtual ExtendedKeyEventData* Clone() const = 0;
597 }; 594 };
598 595
599 // A KeyEvent is really two distinct classes, melded together due to the 596 // A KeyEvent is really two distinct classes, melded together due to the
600 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), 597 // DOM legacy of Windows key events: a keystroke event (is_char_ == false),
601 // or a character event (is_char_ == true). 598 // or a character event (is_char_ == true).
602 // 599 //
603 // For a keystroke event, 600 // For a keystroke event,
604 // -- is_char_ is false. 601 // -- is_char_ is false.
605 // -- Event::type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED, 602 // -- Event::type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED.
606 // ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE.
607 // -- code_ and Event::flags() represent the physical key event. 603 // -- code_ and Event::flags() represent the physical key event.
608 // - code_ is a platform-independent representation of the physical key, 604 // - code_ is a platform-independent representation of the physical key,
609 // based on DOM KeyboardEvent |code| values. It does not vary depending 605 // based on DOM KeyboardEvent |code| values. It does not vary depending
610 // on key layout. 606 // on key layout.
611 // - Event::flags() provides the active modifiers for the physical key 607 // - Event::flags() provides the active modifiers for the physical key
612 // press. Its value reflects the state after the event; that is, for 608 // press. Its value reflects the state after the event; that is, for
613 // a modifier key, a press includes the corresponding flag and a release 609 // a modifier key, a press includes the corresponding flag and a release
614 // does not. 610 // does not.
615 // -- key_ and character_ provide the meaning of the key event, in the context 611 // -- key_ and character_ provide the meaning of the key event, in the context
616 // of the active layout and modifiers. Together they correspond to DOM 612 // of the active layout and modifiers. Together they correspond to DOM
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 DomCode code() const { return code_; }; 733 DomCode code() const { return code_; };
738 std::string GetCodeString() const; 734 std::string GetCodeString() const;
739 735
740 // Returns the DOM .key (layout meaning) for a keystroke event. 736 // Returns the DOM .key (layout meaning) for a keystroke event.
741 DomKey GetDomKey() const; 737 DomKey GetDomKey() const;
742 738
743 // Normalizes flags_ so that it describes the state after the event. 739 // Normalizes flags_ so that it describes the state after the event.
744 // (Native X11 event flags describe the state before the event.) 740 // (Native X11 event flags describe the state before the event.)
745 void NormalizeFlags(); 741 void NormalizeFlags();
746 742
747 // Returns true if the key event has already been processed by an input method
748 // and there is no need to pass the key event to the input method again.
749 bool IsTranslated() const;
750 // Marks this key event as translated or not translated.
751 void SetTranslated(bool translated);
752
753 protected: 743 protected:
754 friend class KeyEventTestApi; 744 friend class KeyEventTestApi;
755 745
756 // This allows a subclass TranslatedKeyEvent to be a non character event. 746 // This allows a subclass TranslatedKeyEvent to be a non character event.
757 void set_is_char(bool is_char) { is_char_ = is_char; } 747 void set_is_char(bool is_char) { is_char_ = is_char; }
758 748
759 private: 749 private:
760 // Determine key_ and character_ on a keystroke event from code_ and flags(). 750 // Determine key_ and character_ on a keystroke event from code_ and flags().
761 void ApplyLayout() const; 751 void ApplyLayout() const;
762 752
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 869
880 const GestureEventDetails& details() const { return details_; } 870 const GestureEventDetails& details() const { return details_; }
881 871
882 private: 872 private:
883 GestureEventDetails details_; 873 GestureEventDetails details_;
884 }; 874 };
885 875
886 } // namespace ui 876 } // namespace ui
887 877
888 #endif // UI_EVENTS_EVENT_H_ 878 #endif // UI_EVENTS_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698