| Index: ui/events/event.h
|
| diff --git a/ui/events/event.h b/ui/events/event.h
|
| index 334dc7e6be4903347982d4f2a9155ab6c98001a8..e1e4e8e083deac66d7c65432e9729f951c6fd35f 100644
|
| --- a/ui/events/event.h
|
| +++ b/ui/events/event.h
|
| @@ -17,8 +17,8 @@
|
| #include "ui/events/gestures/gesture_types.h"
|
| #include "ui/events/keycodes/keyboard_codes.h"
|
| #include "ui/events/latency_info.h"
|
| -#include "ui/gfx/point.h"
|
| -#include "ui/gfx/point_conversions.h"
|
| +#include "ui/gfx/geometry/point.h"
|
| +#include "ui/gfx/geometry/point_conversions.h"
|
|
|
| namespace gfx {
|
| class Transform;
|
| @@ -26,6 +26,8 @@ class Transform;
|
|
|
| namespace ui {
|
| class EventTarget;
|
| +enum class DomCode;
|
| +enum class DomKey;
|
|
|
| class EVENTS_EXPORT Event {
|
| public:
|
| @@ -53,14 +55,15 @@ class EVENTS_EXPORT Event {
|
| DISALLOW_COPY_AND_ASSIGN(DispatcherApi);
|
| };
|
|
|
| + const base::NativeEvent& native_event() const { return native_event_; }
|
| EventType type() const { return type_; }
|
| - void set_type(EventType type) { type_ = type; }
|
| -
|
| + const std::string& name() const { return name_; }
|
| // time_stamp represents time since machine was booted.
|
| const base::TimeDelta& time_stamp() const { return time_stamp_; }
|
| - void set_time_stamp(const base::TimeDelta& stamp) { time_stamp_ = stamp; }
|
| -
|
| int flags() const { return flags_; }
|
| +
|
| + // This is only intended to be used externally by classes that are modifying
|
| + // events in an EventRewriter.
|
| void set_flags(int flags) { flags_ = flags; }
|
|
|
| EventTarget* target() const { return target_; }
|
| @@ -72,7 +75,7 @@ class EVENTS_EXPORT Event {
|
| void set_latency(const LatencyInfo& latency) { latency_ = latency; }
|
|
|
| int source_device_id() const { return source_device_id_; }
|
| - void set_source_device_id(const int id) { source_device_id_ = id; }
|
| + void set_source_device_id(int id) { source_device_id_ = id; }
|
|
|
| // By default, events are "cancelable", this means any default processing that
|
| // the containing abstraction layer may perform can be prevented by calling
|
| @@ -91,10 +94,7 @@ class EVENTS_EXPORT Event {
|
| bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; }
|
|
|
| bool IsKeyEvent() const {
|
| - return type_ == ET_KEY_PRESSED ||
|
| - type_ == ET_KEY_RELEASED ||
|
| - type_ == ET_TRANSLATED_KEY_PRESS ||
|
| - type_ == ET_TRANSLATED_KEY_RELEASE;
|
| + return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
|
| }
|
|
|
| bool IsMouseEvent() const {
|
| @@ -199,6 +199,9 @@ class EVENTS_EXPORT Event {
|
| GestureEvent* AsGestureEvent();
|
| const GestureEvent* AsGestureEvent() const;
|
|
|
| + // Returns true if the event has a valid |native_event_|.
|
| + bool HasNativeEvent() const;
|
| +
|
| // Immediately stops the propagation of the event. This must be called only
|
| // from an EventHandler during an event-dispatch. Any event handler that may
|
| // be in the list will not receive the event after this is called.
|
| @@ -215,19 +218,28 @@ class EVENTS_EXPORT Event {
|
| bool handled() const { return result_ != ER_UNHANDLED; }
|
|
|
| protected:
|
| - Event();
|
| Event(EventType type, base::TimeDelta time_stamp, int flags);
|
| + Event(const base::NativeEvent& native_event, EventType type, int flags);
|
| Event(const Event& copy);
|
| void SetType(EventType type);
|
| void set_cancelable(bool cancelable) { cancelable_ = cancelable; }
|
|
|
| + void set_time_stamp(const base::TimeDelta& time_stamp) {
|
| + time_stamp_ = time_stamp;
|
| + }
|
| +
|
| + void set_name(const std::string& name) { name_ = name; }
|
| +
|
| private:
|
| friend class EventTestApi;
|
|
|
| EventType type_;
|
| + std::string name_;
|
| base::TimeDelta time_stamp_;
|
| LatencyInfo latency_;
|
| int flags_;
|
| + base::NativeEvent native_event_;
|
| + bool delete_native_event_;
|
| bool cancelable_;
|
| EventTarget* target_;
|
| EventPhase phase_;
|
| @@ -246,7 +258,6 @@ class EVENTS_EXPORT CancelModeEvent : public Event {
|
|
|
| class EVENTS_EXPORT LocatedEvent : public Event {
|
| public:
|
| - LocatedEvent();
|
| ~LocatedEvent() override;
|
|
|
| float x() const { return location_.x(); }
|
| @@ -265,10 +276,6 @@ class EVENTS_EXPORT LocatedEvent : public Event {
|
| const gfx::PointF& root_location_f() const {
|
| return root_location_;
|
| }
|
| - const gfx::Point& screen_location() const { return screen_location_; }
|
| - void set_screen_location(const gfx::Point& screen_location) {
|
| - screen_location_ = screen_location;
|
| - }
|
|
|
| // Transform the locations using |inverted_root_transform|.
|
| // This is applied to both |location_| and |root_location_|.
|
| @@ -288,6 +295,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
|
|
|
| protected:
|
| friend class LocatedEventTestApi;
|
| + explicit LocatedEvent(const base::NativeEvent& native_event);
|
|
|
| // Create a new LocatedEvent which is identical to the provided model.
|
| // If source / target windows are provided, the model location will be
|
| @@ -296,8 +304,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
|
| LocatedEvent(const LocatedEvent& model, T* source, T* target)
|
| : Event(model),
|
| location_(model.location_),
|
| - root_location_(model.root_location_),
|
| - screen_location_(model.screen_location_) {
|
| + root_location_(model.root_location_) {
|
| ConvertLocationToTarget(source, target);
|
| }
|
|
|
| @@ -313,14 +320,11 @@ class EVENTS_EXPORT LocatedEvent : public Event {
|
| // |location_| multiplied by an optional transformation matrix for
|
| // rotations, animations and skews.
|
| gfx::PointF root_location_;
|
| -
|
| - // The system provided location of the event.
|
| - gfx::Point screen_location_;
|
| };
|
|
|
| class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| public:
|
| - MouseEvent();
|
| + explicit MouseEvent(const base::NativeEvent& native_event);
|
|
|
| // Create a new MouseEvent based on the provided model.
|
| // Uses the provided |type| and |flags| for the new event.
|
| @@ -344,17 +348,17 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| set_flags(flags);
|
| }
|
|
|
| - // Used for synthetic events in testing and by the gesture recognizer.
|
| + // Used for synthetic events in testing, gesture recognizer and Ozone
|
| MouseEvent(EventType type,
|
| const gfx::PointF& location,
|
| const gfx::PointF& root_location,
|
| + base::TimeDelta time_stamp,
|
| int flags,
|
| int changed_button_flags);
|
|
|
| // Conveniences to quickly test what button is down
|
| bool IsOnlyLeftMouseButton() const {
|
| - return (flags() & EF_LEFT_MOUSE_BUTTON) &&
|
| - !(flags() & (EF_MIDDLE_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON));
|
| + return button_flags() == EF_LEFT_MOUSE_BUTTON;
|
| }
|
|
|
| bool IsLeftMouseButton() const {
|
| @@ -362,8 +366,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| }
|
|
|
| bool IsOnlyMiddleMouseButton() const {
|
| - return (flags() & EF_MIDDLE_MOUSE_BUTTON) &&
|
| - !(flags() & (EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON));
|
| + return button_flags() == EF_MIDDLE_MOUSE_BUTTON;
|
| }
|
|
|
| bool IsMiddleMouseButton() const {
|
| @@ -371,8 +374,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| }
|
|
|
| bool IsOnlyRightMouseButton() const {
|
| - return (flags() & EF_RIGHT_MOUSE_BUTTON) &&
|
| - !(flags() & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON));
|
| + return button_flags() == EF_RIGHT_MOUSE_BUTTON;
|
| }
|
|
|
| bool IsRightMouseButton() const {
|
| @@ -380,8 +382,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| }
|
|
|
| bool IsAnyButton() const {
|
| - return (flags() & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
|
| - EF_RIGHT_MOUSE_BUTTON)) != 0;
|
| + return button_flags() != 0;
|
| }
|
|
|
| // Compares two mouse down events and returns true if the second one should
|
| @@ -406,16 +407,33 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
|
| // Updates the button that changed.
|
| void set_changed_button_flags(int flags) { changed_button_flags_ = flags; }
|
|
|
| + private:
|
| + 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);
|
|
|
| - private:
|
| - FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease);
|
| - FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft);
|
| + // Resets the last_click_event_ for unit tests.
|
| + static void ResetLastClickForTest();
|
|
|
| // See description above getter for details.
|
| int changed_button_flags_;
|
| +
|
| + static MouseEvent* last_click_event_;
|
| +
|
| + // We can create a MouseEvent for a native event more than once. We set this
|
| + // to true when the next event either has a different timestamp or we see a
|
| + // release signalling that the press (click) event was completed.
|
| + static bool last_click_complete_;
|
| };
|
|
|
| class ScrollEvent;
|
| @@ -425,7 +443,7 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
|
| // See |offset| for details.
|
| static const int kWheelDelta;
|
|
|
| - MouseWheelEvent();
|
| + explicit MouseWheelEvent(const base::NativeEvent& native_event);
|
| explicit MouseWheelEvent(const ScrollEvent& scroll_event);
|
| MouseWheelEvent(const MouseEvent& mouse_event, int x_offset, int y_offset);
|
| MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event);
|
| @@ -442,6 +460,7 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
|
| MouseWheelEvent(const gfx::Vector2d& offset,
|
| const gfx::PointF& location,
|
| const gfx::PointF& root_location,
|
| + base::TimeDelta time_stamp,
|
| int flags,
|
| int changed_button_flags);
|
|
|
| @@ -450,11 +469,6 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
|
| int x_offset() const { return offset_.x(); }
|
| int y_offset() const { return offset_.y(); }
|
| const gfx::Vector2d& offset() const { return offset_; }
|
| - void set_offset(const gfx::Vector2d& offset) { offset_ = offset; }
|
| -
|
| - // Overridden from LocatedEvent.
|
| - void UpdateForRootTransform(
|
| - const gfx::Transform& inverted_root_transform) override;
|
|
|
| private:
|
| gfx::Vector2d offset_;
|
| @@ -462,7 +476,7 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
|
|
|
| class EVENTS_EXPORT TouchEvent : public LocatedEvent {
|
| public:
|
| - TouchEvent();
|
| + explicit TouchEvent(const base::NativeEvent& native_event);
|
|
|
| // Create a new TouchEvent which is identical to the provided model.
|
| // If source / target windows are provided, the model location will be
|
| @@ -471,11 +485,13 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
|
| TouchEvent(const TouchEvent& model, T* source, T* target)
|
| : LocatedEvent(model, source, target),
|
| touch_id_(model.touch_id_),
|
| + unique_event_id_(model.unique_event_id_),
|
| radius_x_(model.radius_x_),
|
| radius_y_(model.radius_y_),
|
| rotation_angle_(model.rotation_angle_),
|
| - force_(model.force_) {
|
| - }
|
| + force_(model.force_),
|
| + may_cause_scrolling_(model.may_cause_scrolling_),
|
| + should_remove_native_touch_id_mapping_(false) {}
|
|
|
| TouchEvent(EventType type,
|
| const gfx::PointF& location,
|
| @@ -492,38 +508,54 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
|
| float angle,
|
| float force);
|
|
|
| + TouchEvent(const TouchEvent& copy);
|
| +
|
| ~TouchEvent() override;
|
|
|
| + // The id of the pointer this event modifies.
|
| int touch_id() const { return touch_id_; }
|
| - void set_touch_id(int touch_id) { touch_id_ = touch_id; }
|
| + // A unique identifier for this event.
|
| + uint32 unique_event_id() const { return unique_event_id_; }
|
| + // If we aren't provided with a radius on one axis, use the
|
| + // information from the other axis.
|
| + float radius_x() const { return radius_x_ > 0 ? radius_x_ : radius_y_; }
|
| + float radius_y() const { return radius_y_ > 0 ? radius_y_ : radius_x_; }
|
| + float rotation_angle() const { return rotation_angle_; }
|
| + float force() const { return force_; }
|
| +
|
| + void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; }
|
| + bool may_cause_scrolling() const { return may_cause_scrolling_; }
|
|
|
| - float radius_x() const { return radius_x_; }
|
| + // Used for unit tests.
|
| void set_radius_x(const float r) { radius_x_ = r; }
|
| - float radius_y() const { return radius_y_; }
|
| void set_radius_y(const float r) { radius_y_ = r; }
|
|
|
| - float rotation_angle() const { return rotation_angle_; }
|
| - void set_rotation_angle(float rotation_angle) {
|
| - rotation_angle_ = rotation_angle;
|
| + void set_should_remove_native_touch_id_mapping(
|
| + bool should_remove_native_touch_id_mapping) {
|
| + should_remove_native_touch_id_mapping_ =
|
| + should_remove_native_touch_id_mapping;
|
| }
|
|
|
| - float force() const { return force_; }
|
| - void set_force(float force) { force_ = force; }
|
| -
|
| // Overridden from LocatedEvent.
|
| void UpdateForRootTransform(
|
| const gfx::Transform& inverted_root_transform) override;
|
|
|
| - protected:
|
| - void set_radius(float radius_x, float radius_y) {
|
| - radius_x_ = radius_x;
|
| - radius_y_ = radius_y;
|
| + // Marks the event as not participating in synchronous gesture recognition.
|
| + void DisableSynchronousHandling();
|
| + bool synchronous_handling_disabled() const {
|
| + return !!(result() & ER_DISABLE_SYNC_HANDLING);
|
| }
|
|
|
| private:
|
| + // Adjusts rotation_angle_ to within the acceptable range.
|
| + void FixRotationAngle();
|
| +
|
| // The identity (typically finger) of the touch starting at 0 and incrementing
|
| // for each separable additional touch that the hardware can detect.
|
| - int touch_id_;
|
| + const int touch_id_;
|
| +
|
| + // A unique identifier for the touch event.
|
| + const uint32 unique_event_id_;
|
|
|
| // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown.
|
| float radius_x_;
|
| @@ -531,11 +563,23 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
|
| // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown.
|
| float radius_y_;
|
|
|
| - // Angle of the major axis away from the X axis. Default 0.0.
|
| + // Clockwise angle (in degrees) of the major axis from the X axis. Must be
|
| + // less than 180 and non-negative.
|
| float rotation_angle_;
|
|
|
| // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
|
| float force_;
|
| +
|
| + // Whether the (unhandled) touch event will produce a scroll event (e.g., a
|
| + // touchmove that exceeds the platform slop region, or a touchend that
|
| + // causes a fling). Defaults to false.
|
| + bool may_cause_scrolling_;
|
| +
|
| + // True if this event should remove the mapping between the native
|
| + // event id and the touch_id_. This should only be the case for
|
| + // release and cancel events where the associated touch press event
|
| + // created a mapping between the native id and the touch_id_.
|
| + bool should_remove_native_touch_id_mapping_;
|
| };
|
|
|
| // An interface that individual platforms can use to store additional data on
|
| @@ -555,41 +599,65 @@ class EVENTS_EXPORT ExtendedKeyEventData {
|
| //
|
| // For a keystroke event,
|
| // -- is_char_ is false.
|
| -// -- type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED,
|
| -// ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE.
|
| -// -- character_ functions as a bypass or cache for GetCharacter().
|
| -// -- key_code_ is a VKEY_ value associated with the key. For printable
|
| -// characters, this may or may not be a mapped value, imitating MS Windows:
|
| +// -- Event::type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED.
|
| +// -- code_ and Event::flags() represent the physical key event.
|
| +// - code_ is a platform-independent representation of the physical key,
|
| +// based on DOM KeyboardEvent |code| values. It does not vary depending
|
| +// on key layout.
|
| +// - Event::flags() provides the active modifiers for the physical key
|
| +// press. Its value reflects the state after the event; that is, for
|
| +// a modifier key, a press includes the corresponding flag and a release
|
| +// does not.
|
| +// -- key_ and character_ provide the meaning of the key event, in the context
|
| +// of the active layout and modifiers. Together they correspond to DOM
|
| +// KeyboardEvent |key| values.
|
| +// - key_ is an enumeration of non-Unicode meanings, plus sentinels
|
| +// (specifically DomKey::CHARACTER for Unicode meanings).
|
| +// - character_ is the code point for Unicode meanings.
|
| +// -- key_code_ is a KeyboardCode value associated with the key. This supports
|
| +// the legacy web event |keyCode| field, and the VKEY_ values are chosen
|
| +// to match Windows/IE for compatibility. For printable characters, this
|
| +// may or may not be a layout-mapped value, imitating MS Windows:
|
| // if the mapped key generates a character that has an associated VKEY_
|
| // code, then key_code_ is that code; if not, then key_code_ is the unmapped
|
| // VKEY_ code. For example, US, Greek, Cyrillic, Japanese, etc. all use
|
| // VKEY_Q for the key beside Tab, while French uses VKEY_A.
|
| -// -- code_ is in one-to-one correspondence with a physical keyboard
|
| -// location, and does not vary depending on key layout.
|
| //
|
| // For a character event,
|
| // -- is_char_ is true.
|
| // -- type() is ET_KEY_PRESSED.
|
| -// -- character_ is a UTF-16 character value.
|
| +// -- code_ is DomCode::NONE.
|
| +// -- key_ is DomKey::CHARACTER and character_ is a UTF-16 code point.
|
| // -- key_code_ is conflated with character_ by some code, because both
|
| // arrive in the wParam field of a Windows event.
|
| -// -- code_ is the empty string.
|
| //
|
| class EVENTS_EXPORT KeyEvent : public Event {
|
| public:
|
| - KeyEvent();
|
| + // Create a KeyEvent from a NativeEvent. For Windows this native event can
|
| + // be either a keystroke message (WM_KEYUP/WM_KEYDOWN) or a character message
|
| + // (WM_CHAR). Other systems have only keystroke events.
|
| + explicit KeyEvent(const base::NativeEvent& native_event);
|
|
|
| // Create a keystroke event.
|
| KeyEvent(EventType type, KeyboardCode key_code, int flags);
|
|
|
| + // Create a fully defined keystroke event.
|
| + KeyEvent(EventType type,
|
| + KeyboardCode key_code,
|
| + DomCode code,
|
| + int flags,
|
| + DomKey key,
|
| + base::char16 character,
|
| + base::TimeDelta time_stamp);
|
| +
|
| // Create a character event.
|
| KeyEvent(base::char16 character, KeyboardCode key_code, int flags);
|
|
|
| // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
|
| - // See also: ui/events/keycodes/dom4/keycode_converter_data.h
|
| + // See also: ui/events/keycodes/dom/dom_values.txt
|
| KeyEvent(EventType type,
|
| KeyboardCode key_code,
|
| - const std::string& code,
|
| + DomCode code,
|
| int flags);
|
|
|
| KeyEvent(const KeyEvent& rhs);
|
| @@ -629,8 +697,8 @@ class EVENTS_EXPORT KeyEvent : public Event {
|
| base::char16 GetText() const;
|
|
|
| // Gets the platform key code. For XKB, this is the xksym value.
|
| - uint32 platform_keycode() const { return platform_keycode_; }
|
| void set_platform_keycode(uint32 keycode) { platform_keycode_ = keycode; }
|
| + uint32 platform_keycode() const { return platform_keycode_; }
|
|
|
| // Gets the associated (Windows-based) KeyboardCode for this key event.
|
| // Historically, this has also been used to obtain the character associated
|
| @@ -638,11 +706,13 @@ class EVENTS_EXPORT KeyEvent : public Event {
|
| // This should be avoided; if necessary for backwards compatibility, use
|
| // GetConflatedWindowsKeyCode().
|
| KeyboardCode key_code() const { return key_code_; }
|
| - void set_key_code(KeyboardCode key_code) { key_code_ = key_code; }
|
|
|
| // True if this is a character event, false if this is a keystroke event.
|
| bool is_char() const { return is_char_; }
|
| - void set_is_char(bool is_char) { is_char_ = 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; }
|
|
|
| // Returns the same value as key_code(), except that located codes are
|
| // returned in place of non-located ones (e.g. VKEY_LSHIFT or VKEY_RSHIFT
|
| @@ -659,41 +729,57 @@ class EVENTS_EXPORT KeyEvent : public Event {
|
| // TODO(msw): Additional work may be needed for analogues on other platforms.
|
| bool IsUnicodeKeyCode() const;
|
|
|
| - std::string code() const { return code_; }
|
| - void set_code(const std::string& code) { code_ = code; }
|
| + // Returns the DOM .code (physical key identifier) for a keystroke event.
|
| + DomCode code() const { return code_; };
|
| + std::string GetCodeString() const;
|
| +
|
| + // Returns the DOM .key (layout meaning) for a keystroke event.
|
| + DomKey GetDomKey() const;
|
|
|
| // Normalizes flags_ so that it describes the state after the event.
|
| // (Native X11 event flags describe the state before the event.)
|
| void NormalizeFlags();
|
|
|
| - // Returns true if the key event has already been processed by an input method
|
| - // and there is no need to pass the key event to the input method again.
|
| - bool IsTranslated() const;
|
| - // Marks this key event as translated or not translated.
|
| - void SetTranslated(bool translated);
|
| -
|
| protected:
|
| friend class KeyEventTestApi;
|
|
|
| + // This allows a subclass TranslatedKeyEvent to be a non character event.
|
| + void set_is_char(bool is_char) { is_char_ = is_char; }
|
| +
|
| private:
|
| - // True if the key press originated from a 'right' key (VKEY_RSHIFT, etc.).
|
| - bool IsRightSideKey() const;
|
| + // Determine key_ and character_ on a keystroke event from code_ and flags().
|
| + void ApplyLayout() const;
|
|
|
| KeyboardCode key_code_;
|
|
|
| - // String of 'code' defined in DOM KeyboardEvent (e.g. 'KeyA', 'Space')
|
| - // http://www.w3.org/TR/uievents/#keyboard-key-codes.
|
| + // DOM KeyboardEvent |code| (e.g. DomCode::KEY_A, DomCode::SPACE).
|
| + // http://www.w3.org/TR/DOM-Level-3-Events-code/
|
| //
|
| // This value represents the physical position in the keyboard and can be
|
| // converted from / to keyboard scan code like XKB.
|
| - std::string code_;
|
| + DomCode code_;
|
|
|
| // True if this is a character event, false if this is a keystroke event.
|
| bool is_char_;
|
|
|
| // The platform related keycode value. For XKB, it's keysym value.
|
| // For now, this is used for CharacterComposer in ChromeOS.
|
| - uint32 platform_keycode_;
|
| + mutable uint32 platform_keycode_;
|
| +
|
| + // TODO(kpschoedel): refactor so that key_ and character_ are not mutable.
|
| + // This requires defining the KeyEvent completely at construction rather
|
| + // than lazily under GetCharacter(), which likely also means removing
|
| + // the two 'incomplete' constructors. crbug.com/444045
|
| + //
|
| + // DOM KeyboardEvent |key|
|
| + // http://www.w3.org/TR/DOM-Level-3-Events-key/
|
| + //
|
| + // This value, together with character_, represents the meaning of a key.
|
| + // The value is DomKey::CHARACTER when the interpretation is a character.
|
| + // This, along with character_, is not necessarily initialized when the
|
| + // event is constructed; it may be set only if and when GetCharacter()
|
| + // or GetDomKey() is called.
|
| + mutable DomKey key_;
|
|
|
| // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'รข')
|
| // http://www.w3.org/TR/uievents/#keyboard-key-codes.
|
| @@ -708,11 +794,15 @@ class EVENTS_EXPORT KeyEvent : public Event {
|
| // mojo instead serializes and deserializes events in potentially different
|
| // processes, we need to have a mechanism to keep track of this data.
|
| scoped_ptr<ExtendedKeyEventData> extended_key_event_data_;
|
| +
|
| + static bool IsRepeated(const KeyEvent& event);
|
| +
|
| + static KeyEvent* last_key_event_;
|
| };
|
|
|
| class EVENTS_EXPORT ScrollEvent : public MouseEvent {
|
| public:
|
| - ScrollEvent();
|
| + explicit ScrollEvent(const base::NativeEvent& native_event);
|
| template <class T>
|
| ScrollEvent(const ScrollEvent& model,
|
| T* source,
|
| @@ -743,20 +833,9 @@ class EVENTS_EXPORT ScrollEvent : public MouseEvent {
|
|
|
| float x_offset() const { return x_offset_; }
|
| float y_offset() const { return y_offset_; }
|
| - void set_offset(float x, float y) {
|
| - x_offset_ = x;
|
| - y_offset_ = y;
|
| - }
|
| -
|
| float x_offset_ordinal() const { return x_offset_ordinal_; }
|
| float y_offset_ordinal() const { return y_offset_ordinal_; }
|
| - void set_offset_ordinal(float x, float y) {
|
| - x_offset_ordinal_ = x;
|
| - y_offset_ordinal_ = y;
|
| - }
|
| -
|
| int finger_count() const { return finger_count_; }
|
| - void set_finger_count(int finger_count) { finger_count_ = finger_count; }
|
|
|
| private:
|
| // Potential accelerated offsets.
|
|
|