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 @@
#ifndef UI_EVENTS_EVENT_H_
#define UI_EVENTS_EVENT_H_
#include <stdint.h>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
......@@ -18,7 +17,6 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/events/event_constants.h"
#include "ui/events/gesture_event_details.h"
#include "ui/events/gestures/gesture_types.h"
......@@ -36,6 +34,7 @@ class Transform;
}
namespace ui {
class CancelModeEvent;
class Event;
class EventTarget;
......@@ -62,9 +61,7 @@ class EVENTS_EXPORT Event {
public:
explicit DispatcherApi(Event* event) : event_(event) {}
void set_target(EventTarget* target) {
event_->target_ = target;
}
void set_target(EventTarget* target) { event_->target_ = target; }
void set_phase(EventPhase phase) { event_->phase_ = phase; }
void set_result(int result) {
......@@ -130,9 +127,7 @@ class EVENTS_EXPORT Event {
bool IsSynthesized() const { return (flags_ & EF_IS_SYNTHESIZED) != 0; }
bool IsCancelModeEvent() const {
return type_ == ET_CANCEL_MODE;
}
bool IsCancelModeEvent() const { return type_ == ET_CANCEL_MODE; }
bool IsKeyEvent() const {
return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
......@@ -195,12 +190,12 @@ class EVENTS_EXPORT Event {
// An ending event is paired with the event which started it. Setting capture
// should not prevent ending events from getting to their initial target.
bool IsEndingEvent() const {
switch(type_) {
case ui::ET_TOUCH_CANCELLED:
case ui::ET_GESTURE_TAP_CANCEL:
case ui::ET_GESTURE_END:
case ui::ET_GESTURE_SCROLL_END:
case ui::ET_GESTURE_PINCH_END:
switch (type_) {
case ET_TOUCH_CANCELLED:
case ET_GESTURE_TAP_CANCEL:
case ET_GESTURE_END:
case ET_GESTURE_SCROLL_END:
case ET_GESTURE_PINCH_END:
return true;
default:
return false;
......@@ -210,10 +205,9 @@ class EVENTS_EXPORT Event {
bool IsScrollEvent() const {
// Flings can be GestureEvents too. EF_FROM_TOUCH determines if they're
// Gesture or Scroll events.
return type_ == ET_SCROLL ||
((type_ == ET_SCROLL_FLING_START ||
type_ == ET_SCROLL_FLING_CANCEL) &&
!(flags() & EF_FROM_TOUCH));
return type_ == ET_SCROLL || ((type_ == ET_SCROLL_FLING_START ||
type_ == ET_SCROLL_FLING_CANCEL) &&
!(flags() & EF_FROM_TOUCH));
}
bool IsPinchEvent() const {
......@@ -223,18 +217,14 @@ class EVENTS_EXPORT Event {
bool IsScrollGestureEvent() const {
return type_ == ET_GESTURE_SCROLL_BEGIN ||
type_ == ET_GESTURE_SCROLL_UPDATE ||
type_ == ET_GESTURE_SCROLL_END;
type_ == ET_GESTURE_SCROLL_UPDATE || type_ == ET_GESTURE_SCROLL_END;
}
bool IsFlingScrollEvent() const {
return type_ == ET_SCROLL_FLING_CANCEL ||
type_ == ET_SCROLL_FLING_START;
return type_ == ET_SCROLL_FLING_CANCEL || type_ == ET_SCROLL_FLING_START;
}
bool IsMouseWheelEvent() const {
return type_ == ET_MOUSEWHEEL;
}
bool IsMouseWheelEvent() const { return type_ == ET_MOUSEWHEEL; }
bool IsLocatedEvent() const {
return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() ||
......@@ -313,9 +303,7 @@ class EVENTS_EXPORT Event {
void SetType(EventType type);
void set_cancelable(bool cancelable) { cancelable_ = cancelable; }
void set_time_stamp(base::TimeTicks time_stamp) {
time_stamp_ = time_stamp;
}
void set_time_stamp(base::TimeTicks time_stamp) { time_stamp_ = time_stamp; }
private:
friend class EventTestApi;
......@@ -348,7 +336,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
public:
// Convenience function that casts |event| to a LocatedEvent if it is one,
// 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;
}
......@@ -371,9 +359,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
gfx::Point root_location() const {
return gfx::ToFlooredPoint(root_location_);
}
const gfx::PointF& root_location_f() const {
return root_location_;
}
const gfx::PointF& root_location_f() const { return root_location_; }
// Transform the locations using |inverted_root_transform| and
// |inverted_local_transform|. |inverted_local_transform| is only used if
......@@ -529,9 +515,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
return (flags() & EF_RIGHT_MOUSE_BUTTON) != 0;
}
bool IsAnyButton() const {
return button_flags() != 0;
}
bool IsAnyButton() const { return button_flags() != 0; }
// Returns the flags for the mouse buttons.
int button_flags() const {
......@@ -542,9 +526,8 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
// Compares two mouse down events and returns true if the second one should
// be considered a repeat of the first.
static bool IsRepeatedClickEvent(
const MouseEvent& event1,
const MouseEvent& event2);
static bool IsRepeatedClickEvent(const MouseEvent& event1,
const MouseEvent& event2);
// Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise.
int GetClickCount() const;
......@@ -607,12 +590,9 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
~MouseWheelEvent() override;
template <class T>
MouseWheelEvent(const MouseWheelEvent& model,
T* source,
T* target)
MouseWheelEvent(const MouseWheelEvent& model, T* source, T* target)
: 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.
MouseWheelEvent(const gfx::Vector2d& offset,
......@@ -800,10 +780,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
// Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
// See also: ui/events/keycodes/dom/dom_values.txt
KeyEvent(EventType type,
KeyboardCode key_code,
DomCode code,
int flags);
KeyEvent(EventType type, KeyboardCode key_code, DomCode code, int flags);
KeyEvent(const KeyEvent& rhs);
......@@ -1018,8 +995,8 @@ class EVENTS_EXPORT ScrollEvent : public MouseEvent {
class EVENTS_EXPORT GestureEvent : public LocatedEvent {
public:
// The constructor takes a default unique_touch_id of zero to support many
// (80+) existing tests that doesn't care about this id.
// The constructor takes a default unique_touch_id of zero to support many
// (80+) existing tests that doesn't care about this id.
GestureEvent(float x,
float y,
int flags,
......@@ -1032,17 +1009,13 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent {
// converted from |source| coordinate system to |target| coordinate system.
template <typename T>
GestureEvent(const GestureEvent& model, T* source, T* target)
: LocatedEvent(model, source, target),
details_(model.details_) {
}
: LocatedEvent(model, source, target), details_(model.details_) {}
GestureEvent(const GestureEvent& copy);
~GestureEvent() override;
const GestureEventDetails& details() const { return details_; }
uint32_t unique_touch_event_id() const {
return unique_touch_event_id_;
}
uint32_t unique_touch_event_id() const { return unique_touch_event_id_; }
private:
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