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

Unified Diff: ui/events/event.h

Issue 1559163002: Clean up event flags a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/event.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index b86b8feffe4efb20da705c7281e57c40101f0a90..dd3ce7fd6bd33344f1fd0f1bedb3526b96cf7011 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -89,11 +89,10 @@ class EVENTS_EXPORT Event {
// the time the event was created.
bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
- bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; }
bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
- bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; }
bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; }
- bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; }
+ bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; }
+ bool IsCapsLockOn() const { return (flags_ & EF_CAPS_LOCK_ON) != 0; }
bool IsKeyEvent() const {
return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
@@ -444,6 +443,13 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
return button_flags() != 0;
}
+ // Returns the flags for the mouse buttons.
+ int button_flags() const {
+ return flags() & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
+ EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON |
+ EF_FORWARD_MOUSE_BUTTON);
+ }
+
// Compares two mouse down events and returns true if the second one should
// be considered a repeat of the first.
static bool IsRepeatedClickEvent(
@@ -476,13 +482,6 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease);
FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft);
- // Returns the flags for the mouse buttons.
- int button_flags() const {
- return flags() & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
- EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON |
- EF_FORWARD_MOUSE_BUTTON);
- }
-
// Returns the repeat count based on the previous mouse click, if it is
// recent enough and within a small enough distance.
static int GetRepeatCount(const MouseEvent& click_event);
@@ -758,6 +757,11 @@ class EVENTS_EXPORT KeyEvent : public Event {
// as GetUnmodifiedText().
base::char16 GetText() const;
+ // True if this is a character event, false if this is a keystroke event.
+ bool is_char() const { return is_char_; }
+
+ bool is_repeat() const { return (flags() & EF_IS_REPEAT) != 0; }
+
// Gets the associated (Windows-based) KeyboardCode for this key event.
// Historically, this has also been used to obtain the character associated
// with a character event, because both use the Window message 'wParam' field.
@@ -765,9 +769,6 @@ class EVENTS_EXPORT KeyEvent : public Event {
// GetConflatedWindowsKeyCode().
KeyboardCode key_code() const { return key_code_; }
- // True if this is a character event, false if this is a keystroke event.
- bool is_char() const { return is_char_; }
-
// This is only intended to be used externally by classes that are modifying
// events in an EventRewriter.
void set_key_code(KeyboardCode key_code) { key_code_ = key_code; }
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698