Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 native_event_(native_event), | 207 native_event_(native_event), |
| 208 delete_native_event_(false), | 208 delete_native_event_(false), |
| 209 cancelable_(true), | 209 cancelable_(true), |
| 210 target_(NULL), | 210 target_(NULL), |
| 211 phase_(EP_PREDISPATCH), | 211 phase_(EP_PREDISPATCH), |
| 212 result_(ER_UNHANDLED), | 212 result_(ER_UNHANDLED), |
| 213 source_device_id_(ED_UNKNOWN_DEVICE) { | 213 source_device_id_(ED_UNKNOWN_DEVICE) { |
| 214 base::TimeDelta delta = EventTimeForNow() - time_stamp_; | 214 base::TimeDelta delta = EventTimeForNow() - time_stamp_; |
| 215 if (type_ < ET_LAST) | 215 if (type_ < ET_LAST) |
| 216 name_ = EventTypeName(type_); | 216 name_ = EventTypeName(type_); |
| 217 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", | 217 base::HistogramBase::Sample delta_sample = |
| 218 delta.InMicroseconds(), 1, 1000000, 100); | 218 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); |
| 219 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, | |
| 220 100); | |
| 219 std::string name_for_event = | 221 std::string name_for_event = |
| 220 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); | 222 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); |
| 221 base::HistogramBase* counter_for_type = | 223 base::HistogramBase* counter_for_type = |
| 222 base::Histogram::FactoryGet( | 224 base::Histogram::FactoryGet( |
| 223 name_for_event, | 225 name_for_event, |
| 224 1, | 226 1, |
| 225 1000000, | 227 1000000, |
| 226 100, | 228 100, |
| 227 base::HistogramBase::kUmaTargetedHistogramFlag); | 229 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 228 counter_for_type->Add(delta.InMicroseconds()); | 230 counter_for_type->Add(delta_sample); |
| 229 | 231 |
| 230 #if defined(USE_X11) | 232 #if defined(USE_X11) |
| 231 if (native_event->type == GenericEvent) { | 233 if (native_event->type == GenericEvent) { |
| 232 XIDeviceEvent* xiev = | 234 XIDeviceEvent* xiev = |
| 233 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 235 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 234 source_device_id_ = xiev->sourceid; | 236 source_device_id_ = xiev->sourceid; |
| 235 } | 237 } |
| 236 #endif | 238 #endif |
| 237 } | 239 } |
| 238 | 240 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 //////////////////////////////////////////////////////////////////////////////// | 445 //////////////////////////////////////////////////////////////////////////////// |
| 444 // MouseWheelEvent | 446 // MouseWheelEvent |
| 445 | 447 |
| 446 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event) | 448 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event) |
| 447 : MouseEvent(native_event), | 449 : MouseEvent(native_event), |
| 448 offset_(GetMouseWheelOffset(native_event)) { | 450 offset_(GetMouseWheelOffset(native_event)) { |
| 449 } | 451 } |
| 450 | 452 |
| 451 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) | 453 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) |
| 452 : MouseEvent(scroll_event), | 454 : MouseEvent(scroll_event), |
| 453 offset_(scroll_event.x_offset(), scroll_event.y_offset()){ | 455 offset_(static_cast<int>(scroll_event.x_offset()), |
| 456 static_cast<int>(scroll_event.y_offset())) { | |
|
Peter Kasting
2014/10/17 01:47:16
Note: Perhaps the changes here and/or below should
sky
2014/10/20 15:38:33
Not sure. I suspect in practice it doesn't matter
Peter Kasting
2014/10/20 20:41:40
I think in that case I'll change these to round.
| |
| 454 SetType(ET_MOUSEWHEEL); | 457 SetType(ET_MOUSEWHEEL); |
| 455 } | 458 } |
| 456 | 459 |
| 457 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, | 460 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, |
| 458 int x_offset, | 461 int x_offset, |
| 459 int y_offset) | 462 int y_offset) |
| 460 : MouseEvent(mouse_event), offset_(x_offset, y_offset) { | 463 : MouseEvent(mouse_event), offset_(x_offset, y_offset) { |
| 461 DCHECK(type() == ET_MOUSEWHEEL); | 464 DCHECK(type() == ET_MOUSEWHEEL); |
| 462 } | 465 } |
| 463 | 466 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 485 // This value matches GTK+ wheel scroll amount. | 488 // This value matches GTK+ wheel scroll amount. |
| 486 const int MouseWheelEvent::kWheelDelta = 53; | 489 const int MouseWheelEvent::kWheelDelta = 53; |
| 487 #endif | 490 #endif |
| 488 | 491 |
| 489 void MouseWheelEvent::UpdateForRootTransform( | 492 void MouseWheelEvent::UpdateForRootTransform( |
| 490 const gfx::Transform& inverted_root_transform) { | 493 const gfx::Transform& inverted_root_transform) { |
| 491 LocatedEvent::UpdateForRootTransform(inverted_root_transform); | 494 LocatedEvent::UpdateForRootTransform(inverted_root_transform); |
| 492 gfx::DecomposedTransform decomp; | 495 gfx::DecomposedTransform decomp; |
| 493 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); | 496 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); |
| 494 DCHECK(success); | 497 DCHECK(success); |
| 495 if (decomp.scale[0]) | 498 if (decomp.scale[0]) { |
| 496 offset_.set_x(offset_.x() * decomp.scale[0]); | 499 offset_.set_x( |
| 497 if (decomp.scale[1]) | 500 static_cast<int>(SkMScalarToFloat(offset_.x() * decomp.scale[0]))); |
| 498 offset_.set_y(offset_.y() * decomp.scale[1]); | 501 } |
| 502 if (decomp.scale[1]) { | |
| 503 offset_.set_y( | |
| 504 static_cast<int>(SkMScalarToFloat(offset_.y() * decomp.scale[1]))); | |
| 505 } | |
| 499 } | 506 } |
| 500 | 507 |
| 501 //////////////////////////////////////////////////////////////////////////////// | 508 //////////////////////////////////////////////////////////////////////////////// |
| 502 // TouchEvent | 509 // TouchEvent |
| 503 | 510 |
| 504 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | 511 TouchEvent::TouchEvent(const base::NativeEvent& native_event) |
| 505 : LocatedEvent(native_event), | 512 : LocatedEvent(native_event), |
| 506 touch_id_(GetTouchId(native_event)), | 513 touch_id_(GetTouchId(native_event)), |
| 507 radius_x_(GetTouchRadiusX(native_event)), | 514 radius_x_(GetTouchRadiusX(native_event)), |
| 508 radius_y_(GetTouchRadiusY(native_event)), | 515 radius_y_(GetTouchRadiusY(native_event)), |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 gfx::PointF(x, y), | 968 gfx::PointF(x, y), |
| 962 time_stamp, | 969 time_stamp, |
| 963 flags | EF_FROM_TOUCH), | 970 flags | EF_FROM_TOUCH), |
| 964 details_(details) { | 971 details_(details) { |
| 965 } | 972 } |
| 966 | 973 |
| 967 GestureEvent::~GestureEvent() { | 974 GestureEvent::~GestureEvent() { |
| 968 } | 975 } |
| 969 | 976 |
| 970 } // namespace ui | 977 } // namespace ui |
| OLD | NEW |