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

Unified Diff: ui/events/event.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move mutators to MouseEvent/TouchEvent Created 5 years, 4 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/event.h ('k') | ui/events/event_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index 953220d0a634f1de2ae7ec3ca738dfc34a879839..8b5b47da5be1afd54e806928bff62c371624bcb8 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -319,8 +319,8 @@ void LocatedEvent::UpdateForRootTransform(
MouseEvent::MouseEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
- changed_button_flags_(
- GetChangedMouseButtonFlagsFromNative(native_event)) {
+ changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) {
if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED)
SetClickCount(GetRepeatCount(*this));
}
@@ -332,7 +332,8 @@ MouseEvent::MouseEvent(EventType type,
int flags,
int changed_button_flags)
: LocatedEvent(type, location, root_location, time_stamp, flags),
- changed_button_flags_(changed_button_flags) {
+ changed_button_flags_(changed_button_flags),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) {
if (this->type() == ET_MOUSE_MOVED && IsAnyButton())
SetType(ET_MOUSE_DRAGGED);
}
@@ -514,12 +515,15 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
touch_id_(GetTouchId(native_event)),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(GetTouchRadiusX(native_event)),
- radius_y_(GetTouchRadiusY(native_event)),
rotation_angle_(GetTouchAngle(native_event)),
- force_(GetTouchForce(native_event)),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ GetTouchRadiusX(native_event),
+ GetTouchRadiusY(native_event),
+ GetTouchForce(native_event),
+ /* tilt_x */ 0.0f,
+ /* tilt_y */ 0.0f)) {
latency()->AddLatencyNumberWithTimestamp(
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
@@ -537,12 +541,10 @@ TouchEvent::TouchEvent(EventType type,
: LocatedEvent(type, location, location, time_stamp, 0),
touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(0.0f),
- radius_y_(0.0f),
rotation_angle_(0.0f),
- force_(0.0f),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -558,12 +560,15 @@ TouchEvent::TouchEvent(EventType type,
: LocatedEvent(type, location, location, time_stamp, flags),
touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(radius_x),
- radius_y_(radius_y),
rotation_angle_(angle),
- force_(force),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ radius_x,
+ radius_y,
+ force,
+ /* tilt_x */ 0.0f,
+ /* tilt_y */ 0.0f)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
FixRotationAngle();
}
@@ -572,12 +577,10 @@ TouchEvent::TouchEvent(const TouchEvent& copy)
: LocatedEvent(copy),
touch_id_(copy.touch_id_),
unique_event_id_(copy.unique_event_id_),
- radius_x_(copy.radius_x_),
- radius_y_(copy.radius_y_),
rotation_angle_(copy.rotation_angle_),
- force_(copy.force_),
may_cause_scrolling_(copy.may_cause_scrolling_),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(copy.pointer_details_) {
// Copied events should not remove touch id mapping, as this either causes the
// mapping to be lost before the initial event has finished dispatching, or
// the copy to attempt to remove the mapping from a null |native_event_|.
@@ -601,9 +604,9 @@ void TouchEvent::UpdateForRootTransform(
bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
DCHECK(success);
if (decomp.scale[0])
- radius_x_ *= decomp.scale[0];
+ pointer_details_.radius_x_ *= decomp.scale[0];
if (decomp.scale[1])
- radius_y_ *= decomp.scale[1];
+ pointer_details_.radius_y_ *= decomp.scale[1];
}
void TouchEvent::DisableSynchronousHandling() {
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698