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

Unified Diff: ui/events/event.cc

Issue 785753002: Don't refcount tracking id -> slot id mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sadrul's comments. Created 5 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
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index d0966da00847a13bcfe64258596a445fa57bd0e4..1cd62e3d918793c39a6a6bfd9e62735ed4fc6488 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -526,19 +526,17 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
radius_y_(GetTouchRadiusY(native_event)),
rotation_angle_(GetTouchAngle(native_event)),
force_(GetTouchForce(native_event)),
- may_cause_scrolling_(false) {
- latency()->AddLatencyNumberWithTimestamp(
- INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
- 0,
- 0,
- base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
- 1);
+ should_remove_native_touch_id_mapping_(false) {
+ if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
+ should_remove_native_touch_id_mapping_ = true;
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
- fixRotationAngle();
+ FixRotationAngle();
- if (type() == ET_TOUCH_PRESSED)
- IncrementTouchIdRefCount(native_event);
+ latency()->AddLatencyNumberWithTimestamp(
+ INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
+ base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
+ latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
TouchEvent::TouchEvent(EventType type,
@@ -552,7 +550,7 @@ TouchEvent::TouchEvent(EventType type,
radius_y_(0.0f),
rotation_angle_(0.0f),
force_(0.0f),
- may_cause_scrolling_(false) {
+ should_remove_native_touch_id_mapping_(false) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -572,17 +570,20 @@ TouchEvent::TouchEvent(EventType type,
radius_y_(radius_y),
rotation_angle_(angle),
force_(force),
- may_cause_scrolling_(false) {
+ should_remove_native_touch_id_mapping_(false) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
- fixRotationAngle();
+ FixRotationAngle();
}
TouchEvent::~TouchEvent() {
// In ctor TouchEvent(native_event) we call GetTouchId() which in X11
// platform setups the tracking_id to slot mapping. So in dtor here,
// if this touch event is a release event, we clear the mapping accordingly.
- if (HasNativeEvent())
- ClearTouchIdIfReleased(native_event());
+ if (should_remove_native_touch_id_mapping_) {
+ DCHECK(type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED);
+ if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
+ ClearTouchIdIfReleased(native_event());
+ }
}
void TouchEvent::UpdateForRootTransform(
@@ -603,7 +604,7 @@ void TouchEvent::DisableSynchronousHandling() {
static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
}
-void TouchEvent::fixRotationAngle() {
+void TouchEvent::FixRotationAngle() {
while (rotation_angle_ < 0)
rotation_angle_ += 180;
while (rotation_angle_ >= 180)
« ui/events/event.h ('K') | « ui/events/event.h ('k') | ui/events/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698