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

Side by Side Diff: ui/events/event.cc

Issue 680413006: Re-enable Eager Gesture Recognition on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DCHECK. Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/keysym.h> 10 #include <X11/keysym.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const unsigned int kAllStateMask = 101 const unsigned int kAllStateMask =
102 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask | 102 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask |
103 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask | 103 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask |
104 LockMask | ControlMask | AnyModifier; 104 LockMask | ControlMask | AnyModifier;
105 return event && (event->xkey.state & ~kAllStateMask) != 0; 105 return event && (event->xkey.state & ~kAllStateMask) != 0;
106 #else 106 #else
107 return false; 107 return false;
108 #endif 108 #endif
109 } 109 }
110 110
111 unsigned long long get_next_touch_event_id() {
112 static unsigned long long id = 0;
113 return id++;
114 }
115
111 } // namespace 116 } // namespace
112 117
113 namespace ui { 118 namespace ui {
114 119
115 //////////////////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////////////
116 // Event 121 // Event
117 122
118 // static 123 // static
119 scoped_ptr<Event> Event::Clone(const Event& event) { 124 scoped_ptr<Event> Event::Clone(const Event& event) {
120 if (event.IsKeyEvent()) { 125 if (event.IsKeyEvent()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 CHECK(IsGestureEvent()); 168 CHECK(IsGestureEvent());
164 return static_cast<const GestureEvent*>(this); 169 return static_cast<const GestureEvent*>(this);
165 } 170 }
166 171
167 bool Event::HasNativeEvent() const { 172 bool Event::HasNativeEvent() const {
168 base::NativeEvent null_event; 173 base::NativeEvent null_event;
169 std::memset(&null_event, 0, sizeof(null_event)); 174 std::memset(&null_event, 0, sizeof(null_event));
170 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event)); 175 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event));
171 } 176 }
172 177
178 void Event::DisableSynchronousHandling() {
179 result_ = static_cast<EventResult>(result_ | ER_DISABLE_SYNC_HANDLING);
180 }
181
173 void Event::StopPropagation() { 182 void Event::StopPropagation() {
174 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch 183 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch
175 // events. 184 // events.
176 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); 185 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH);
177 CHECK(cancelable_); 186 CHECK(cancelable_);
178 result_ = static_cast<EventResult>(result_ | ER_CONSUMED); 187 result_ = static_cast<EventResult>(result_ | ER_CONSUMED);
179 } 188 }
180 189
181 void Event::SetHandled() { 190 void Event::SetHandled() {
182 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch 191 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1]))); 516 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1])));
508 } 517 }
509 } 518 }
510 519
511 //////////////////////////////////////////////////////////////////////////////// 520 ////////////////////////////////////////////////////////////////////////////////
512 // TouchEvent 521 // TouchEvent
513 522
514 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 523 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
515 : LocatedEvent(native_event), 524 : LocatedEvent(native_event),
516 touch_id_(GetTouchId(native_event)), 525 touch_id_(GetTouchId(native_event)),
526 unique_event_id_(get_next_touch_event_id()),
517 radius_x_(GetTouchRadiusX(native_event)), 527 radius_x_(GetTouchRadiusX(native_event)),
518 radius_y_(GetTouchRadiusY(native_event)), 528 radius_y_(GetTouchRadiusY(native_event)),
519 rotation_angle_(GetTouchAngle(native_event)), 529 rotation_angle_(GetTouchAngle(native_event)),
520 force_(GetTouchForce(native_event)) { 530 force_(GetTouchForce(native_event)) {
521 latency()->AddLatencyNumberWithTimestamp( 531 latency()->AddLatencyNumberWithTimestamp(
522 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 532 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
523 0, 533 0,
524 0, 534 0,
525 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 535 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
526 1); 536 1);
527 537
528 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 538 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
529 539
530 if (type() == ET_TOUCH_PRESSED) 540 if (type() == ET_TOUCH_PRESSED)
531 IncrementTouchIdRefCount(native_event); 541 IncrementTouchIdRefCount(native_event);
532 } 542 }
533 543
534 TouchEvent::TouchEvent(EventType type, 544 TouchEvent::TouchEvent(EventType type,
535 const gfx::PointF& location, 545 const gfx::PointF& location,
536 int touch_id, 546 int touch_id,
537 base::TimeDelta time_stamp) 547 base::TimeDelta time_stamp)
538 : LocatedEvent(type, location, location, time_stamp, 0), 548 : LocatedEvent(type, location, location, time_stamp, 0),
539 touch_id_(touch_id), 549 touch_id_(touch_id),
550 unique_event_id_(get_next_touch_event_id()),
540 radius_x_(0.0f), 551 radius_x_(0.0f),
541 radius_y_(0.0f), 552 radius_y_(0.0f),
542 rotation_angle_(0.0f), 553 rotation_angle_(0.0f),
543 force_(0.0f) { 554 force_(0.0f) {
544 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 555 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
545 } 556 }
546 557
547 TouchEvent::TouchEvent(EventType type, 558 TouchEvent::TouchEvent(EventType type,
548 const gfx::PointF& location, 559 const gfx::PointF& location,
549 int flags, 560 int flags,
550 int touch_id, 561 int touch_id,
551 base::TimeDelta time_stamp, 562 base::TimeDelta time_stamp,
552 float radius_x, 563 float radius_x,
553 float radius_y, 564 float radius_y,
554 float angle, 565 float angle,
555 float force) 566 float force)
556 : LocatedEvent(type, location, location, time_stamp, flags), 567 : LocatedEvent(type, location, location, time_stamp, flags),
557 touch_id_(touch_id), 568 touch_id_(touch_id),
569 unique_event_id_(get_next_touch_event_id()),
558 radius_x_(radius_x), 570 radius_x_(radius_x),
559 radius_y_(radius_y), 571 radius_y_(radius_y),
560 rotation_angle_(angle), 572 rotation_angle_(angle),
561 force_(force) { 573 force_(force) {
562 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 574 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
563 } 575 }
564 576
565 TouchEvent::~TouchEvent() { 577 TouchEvent::~TouchEvent() {
566 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 578 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
567 // platform setups the tracking_id to slot mapping. So in dtor here, 579 // platform setups the tracking_id to slot mapping. So in dtor here,
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 gfx::PointF(x, y), 991 gfx::PointF(x, y),
980 time_stamp, 992 time_stamp,
981 flags | EF_FROM_TOUCH), 993 flags | EF_FROM_TOUCH),
982 details_(details) { 994 details_(details) {
983 } 995 }
984 996
985 GestureEvent::~GestureEvent() { 997 GestureEvent::~GestureEvent() {
986 } 998 }
987 999
988 } // namespace ui 1000 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698