Commit fb228a96 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

Fix style in ui/event/event.{h,cc}

No functional change, just fixing coding style and a couple cleanups.

R=sadrul@chromium.org

Bug: None
Change-Id: I437a973ad6a50957c642923e8e088c2c3744e782
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216710
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774628}
parent f9e92628
This diff is collapsed.
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
#ifndef UI_EVENTS_EVENT_H_ #ifndef UI_EVENTS_EVENT_H_
#define UI_EVENTS_EVENT_H_ #define UI_EVENTS_EVENT_H_
#include <stdint.h> #include <cstdint>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/gesture_event_details.h" #include "ui/events/gesture_event_details.h"
#include "ui/events/gestures/gesture_types.h" #include "ui/events/gestures/gesture_types.h"
...@@ -36,6 +34,7 @@ class Transform; ...@@ -36,6 +34,7 @@ class Transform;
} }
namespace ui { namespace ui {
class CancelModeEvent; class CancelModeEvent;
class Event; class Event;
class EventTarget; class EventTarget;
...@@ -62,9 +61,7 @@ class EVENTS_EXPORT Event { ...@@ -62,9 +61,7 @@ class EVENTS_EXPORT Event {
public: public:
explicit DispatcherApi(Event* event) : event_(event) {} explicit DispatcherApi(Event* event) : event_(event) {}
void set_target(EventTarget* target) { void set_target(EventTarget* target) { event_->target_ = target; }
event_->target_ = target;
}
void set_phase(EventPhase phase) { event_->phase_ = phase; } void set_phase(EventPhase phase) { event_->phase_ = phase; }
void set_result(int result) { void set_result(int result) {
...@@ -130,9 +127,7 @@ class EVENTS_EXPORT Event { ...@@ -130,9 +127,7 @@ class EVENTS_EXPORT Event {
bool IsSynthesized() const { return (flags_ & EF_IS_SYNTHESIZED) != 0; } bool IsSynthesized() const { return (flags_ & EF_IS_SYNTHESIZED) != 0; }
bool IsCancelModeEvent() const { bool IsCancelModeEvent() const { return type_ == ET_CANCEL_MODE; }
return type_ == ET_CANCEL_MODE;
}
bool IsKeyEvent() const { bool IsKeyEvent() const {
return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED; return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
...@@ -195,12 +190,12 @@ class EVENTS_EXPORT Event { ...@@ -195,12 +190,12 @@ class EVENTS_EXPORT Event {
// An ending event is paired with the event which started it. Setting capture // An ending event is paired with the event which started it. Setting capture
// should not prevent ending events from getting to their initial target. // should not prevent ending events from getting to their initial target.
bool IsEndingEvent() const { bool IsEndingEvent() const {
switch(type_) { switch (type_) {
case ui::ET_TOUCH_CANCELLED: case ET_TOUCH_CANCELLED:
case ui::ET_GESTURE_TAP_CANCEL: case ET_GESTURE_TAP_CANCEL:
case ui::ET_GESTURE_END: case ET_GESTURE_END:
case ui::ET_GESTURE_SCROLL_END: case ET_GESTURE_SCROLL_END:
case ui::ET_GESTURE_PINCH_END: case ET_GESTURE_PINCH_END:
return true; return true;
default: default:
return false; return false;
...@@ -210,8 +205,7 @@ class EVENTS_EXPORT Event { ...@@ -210,8 +205,7 @@ class EVENTS_EXPORT Event {
bool IsScrollEvent() const { bool IsScrollEvent() const {
// Flings can be GestureEvents too. EF_FROM_TOUCH determines if they're // Flings can be GestureEvents too. EF_FROM_TOUCH determines if they're
// Gesture or Scroll events. // Gesture or Scroll events.
return type_ == ET_SCROLL || return type_ == ET_SCROLL || ((type_ == ET_SCROLL_FLING_START ||
((type_ == ET_SCROLL_FLING_START ||
type_ == ET_SCROLL_FLING_CANCEL) && type_ == ET_SCROLL_FLING_CANCEL) &&
!(flags() & EF_FROM_TOUCH)); !(flags() & EF_FROM_TOUCH));
} }
...@@ -223,18 +217,14 @@ class EVENTS_EXPORT Event { ...@@ -223,18 +217,14 @@ class EVENTS_EXPORT Event {
bool IsScrollGestureEvent() const { bool IsScrollGestureEvent() const {
return type_ == ET_GESTURE_SCROLL_BEGIN || return type_ == ET_GESTURE_SCROLL_BEGIN ||
type_ == ET_GESTURE_SCROLL_UPDATE || type_ == ET_GESTURE_SCROLL_UPDATE || type_ == ET_GESTURE_SCROLL_END;
type_ == ET_GESTURE_SCROLL_END;
} }
bool IsFlingScrollEvent() const { bool IsFlingScrollEvent() const {
return type_ == ET_SCROLL_FLING_CANCEL || return type_ == ET_SCROLL_FLING_CANCEL || type_ == ET_SCROLL_FLING_START;
type_ == ET_SCROLL_FLING_START;
} }
bool IsMouseWheelEvent() const { bool IsMouseWheelEvent() const { return type_ == ET_MOUSEWHEEL; }
return type_ == ET_MOUSEWHEEL;
}
bool IsLocatedEvent() const { bool IsLocatedEvent() const {
return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() || return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() ||
...@@ -313,9 +303,7 @@ class EVENTS_EXPORT Event { ...@@ -313,9 +303,7 @@ class EVENTS_EXPORT Event {
void SetType(EventType type); void SetType(EventType type);
void set_cancelable(bool cancelable) { cancelable_ = cancelable; } void set_cancelable(bool cancelable) { cancelable_ = cancelable; }
void set_time_stamp(base::TimeTicks time_stamp) { void set_time_stamp(base::TimeTicks time_stamp) { time_stamp_ = time_stamp; }
time_stamp_ = time_stamp;
}
private: private:
friend class EventTestApi; friend class EventTestApi;
...@@ -348,7 +336,7 @@ class EVENTS_EXPORT LocatedEvent : public Event { ...@@ -348,7 +336,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
public: public:
// Convenience function that casts |event| to a LocatedEvent if it is one, // Convenience function that casts |event| to a LocatedEvent if it is one,
// otherwise returns null. // otherwise returns null.
static const ui::LocatedEvent* FromIfValid(const ui::Event* event) { static const LocatedEvent* FromIfValid(const Event* event) {
return event && event->IsLocatedEvent() ? event->AsLocatedEvent() : nullptr; return event && event->IsLocatedEvent() ? event->AsLocatedEvent() : nullptr;
} }
...@@ -371,9 +359,7 @@ class EVENTS_EXPORT LocatedEvent : public Event { ...@@ -371,9 +359,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
gfx::Point root_location() const { gfx::Point root_location() const {
return gfx::ToFlooredPoint(root_location_); return gfx::ToFlooredPoint(root_location_);
} }
const gfx::PointF& root_location_f() const { const gfx::PointF& root_location_f() const { return root_location_; }
return root_location_;
}
// Transform the locations using |inverted_root_transform| and // Transform the locations using |inverted_root_transform| and
// |inverted_local_transform|. |inverted_local_transform| is only used if // |inverted_local_transform|. |inverted_local_transform| is only used if
...@@ -529,9 +515,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { ...@@ -529,9 +515,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
return (flags() & EF_RIGHT_MOUSE_BUTTON) != 0; return (flags() & EF_RIGHT_MOUSE_BUTTON) != 0;
} }
bool IsAnyButton() const { bool IsAnyButton() const { return button_flags() != 0; }
return button_flags() != 0;
}
// Returns the flags for the mouse buttons. // Returns the flags for the mouse buttons.
int button_flags() const { int button_flags() const {
...@@ -542,8 +526,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { ...@@ -542,8 +526,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
// Compares two mouse down events and returns true if the second one should // Compares two mouse down events and returns true if the second one should
// be considered a repeat of the first. // be considered a repeat of the first.
static bool IsRepeatedClickEvent( static bool IsRepeatedClickEvent(const MouseEvent& event1,
const MouseEvent& event1,
const MouseEvent& event2); const MouseEvent& event2);
// Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise. // Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise.
...@@ -607,12 +590,9 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent { ...@@ -607,12 +590,9 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
~MouseWheelEvent() override; ~MouseWheelEvent() override;
template <class T> template <class T>
MouseWheelEvent(const MouseWheelEvent& model, MouseWheelEvent(const MouseWheelEvent& model, T* source, T* target)
T* source,
T* target)
: MouseEvent(model, source, target, model.type(), model.flags()), : MouseEvent(model, source, target, model.type(), model.flags()),
offset_(model.x_offset(), model.y_offset()) { offset_(model.x_offset(), model.y_offset()) {}
}
// Used for synthetic events in testing and by the gesture recognizer. // Used for synthetic events in testing and by the gesture recognizer.
MouseWheelEvent(const gfx::Vector2d& offset, MouseWheelEvent(const gfx::Vector2d& offset,
...@@ -800,10 +780,7 @@ class EVENTS_EXPORT KeyEvent : public Event { ...@@ -800,10 +780,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
// Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
// See also: ui/events/keycodes/dom/dom_values.txt // See also: ui/events/keycodes/dom/dom_values.txt
KeyEvent(EventType type, KeyEvent(EventType type, KeyboardCode key_code, DomCode code, int flags);
KeyboardCode key_code,
DomCode code,
int flags);
KeyEvent(const KeyEvent& rhs); KeyEvent(const KeyEvent& rhs);
...@@ -1032,17 +1009,13 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent { ...@@ -1032,17 +1009,13 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent {
// converted from |source| coordinate system to |target| coordinate system. // converted from |source| coordinate system to |target| coordinate system.
template <typename T> template <typename T>
GestureEvent(const GestureEvent& model, T* source, T* target) GestureEvent(const GestureEvent& model, T* source, T* target)
: LocatedEvent(model, source, target), : LocatedEvent(model, source, target), details_(model.details_) {}
details_(model.details_) {
}
GestureEvent(const GestureEvent& copy); GestureEvent(const GestureEvent& copy);
~GestureEvent() override; ~GestureEvent() override;
const GestureEventDetails& details() const { return details_; } const GestureEventDetails& details() const { return details_; }
uint32_t unique_touch_event_id() const { uint32_t unique_touch_event_id() const { return unique_touch_event_id_; }
return unique_touch_event_id_;
}
private: private:
GestureEventDetails details_; GestureEventDetails details_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment