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

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

Issue 660173002: Type conversion fixes, ui/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/display/util/display_util.cc ('k') | ui/events/gesture_detection/gesture_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #endif 11 #endif
12 12
13 #include <cmath> 13 #include <cmath>
14 #include <cstring> 14 #include <cstring>
15 15
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
19 #include "ui/events/keycodes/keyboard_code_conversion.h" 19 #include "ui/events/keycodes/keyboard_code_conversion.h"
20 #include "ui/gfx/geometry/safe_integer_conversions.h"
20 #include "ui/gfx/point3_f.h" 21 #include "ui/gfx/point3_f.h"
21 #include "ui/gfx/point_conversions.h" 22 #include "ui/gfx/point_conversions.h"
22 #include "ui/gfx/transform.h" 23 #include "ui/gfx/transform.h"
23 #include "ui/gfx/transform_util.h" 24 #include "ui/gfx/transform_util.h"
24 25
25 #if defined(USE_X11) 26 #if defined(USE_X11)
26 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 27 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
27 #elif defined(USE_OZONE) 28 #elif defined(USE_OZONE)
28 #include "ui/events/keycodes/keyboard_code_conversion.h" 29 #include "ui/events/keycodes/keyboard_code_conversion.h"
29 #endif 30 #endif
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 native_event_(native_event), 208 native_event_(native_event),
208 delete_native_event_(false), 209 delete_native_event_(false),
209 cancelable_(true), 210 cancelable_(true),
210 target_(NULL), 211 target_(NULL),
211 phase_(EP_PREDISPATCH), 212 phase_(EP_PREDISPATCH),
212 result_(ER_UNHANDLED), 213 result_(ER_UNHANDLED),
213 source_device_id_(ED_UNKNOWN_DEVICE) { 214 source_device_id_(ED_UNKNOWN_DEVICE) {
214 base::TimeDelta delta = EventTimeForNow() - time_stamp_; 215 base::TimeDelta delta = EventTimeForNow() - time_stamp_;
215 if (type_ < ET_LAST) 216 if (type_ < ET_LAST)
216 name_ = EventTypeName(type_); 217 name_ = EventTypeName(type_);
217 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", 218 base::HistogramBase::Sample delta_sample =
218 delta.InMicroseconds(), 1, 1000000, 100); 219 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds());
220 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000,
221 100);
219 std::string name_for_event = 222 std::string name_for_event =
220 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); 223 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str());
221 base::HistogramBase* counter_for_type = 224 base::HistogramBase* counter_for_type =
222 base::Histogram::FactoryGet( 225 base::Histogram::FactoryGet(
223 name_for_event, 226 name_for_event,
224 1, 227 1,
225 1000000, 228 1000000,
226 100, 229 100,
227 base::HistogramBase::kUmaTargetedHistogramFlag); 230 base::HistogramBase::kUmaTargetedHistogramFlag);
228 counter_for_type->Add(delta.InMicroseconds()); 231 counter_for_type->Add(delta_sample);
229 232
230 #if defined(USE_X11) 233 #if defined(USE_X11)
231 if (native_event->type == GenericEvent) { 234 if (native_event->type == GenericEvent) {
232 XIDeviceEvent* xiev = 235 XIDeviceEvent* xiev =
233 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 236 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
234 source_device_id_ = xiev->sourceid; 237 source_device_id_ = xiev->sourceid;
235 } 238 }
236 #endif 239 #endif
237 } 240 }
238 241
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 //////////////////////////////////////////////////////////////////////////////// 446 ////////////////////////////////////////////////////////////////////////////////
444 // MouseWheelEvent 447 // MouseWheelEvent
445 448
446 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event) 449 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event)
447 : MouseEvent(native_event), 450 : MouseEvent(native_event),
448 offset_(GetMouseWheelOffset(native_event)) { 451 offset_(GetMouseWheelOffset(native_event)) {
449 } 452 }
450 453
451 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) 454 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event)
452 : MouseEvent(scroll_event), 455 : MouseEvent(scroll_event),
453 offset_(scroll_event.x_offset(), scroll_event.y_offset()){ 456 offset_(gfx::ToRoundedInt(scroll_event.x_offset()),
457 gfx::ToRoundedInt(scroll_event.y_offset())) {
454 SetType(ET_MOUSEWHEEL); 458 SetType(ET_MOUSEWHEEL);
455 } 459 }
456 460
457 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, 461 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event,
458 int x_offset, 462 int x_offset,
459 int y_offset) 463 int y_offset)
460 : MouseEvent(mouse_event), offset_(x_offset, y_offset) { 464 : MouseEvent(mouse_event), offset_(x_offset, y_offset) {
461 DCHECK(type() == ET_MOUSEWHEEL); 465 DCHECK(type() == ET_MOUSEWHEEL);
462 } 466 }
463 467
(...skipping 21 matching lines...) Expand all
485 // This value matches GTK+ wheel scroll amount. 489 // This value matches GTK+ wheel scroll amount.
486 const int MouseWheelEvent::kWheelDelta = 53; 490 const int MouseWheelEvent::kWheelDelta = 53;
487 #endif 491 #endif
488 492
489 void MouseWheelEvent::UpdateForRootTransform( 493 void MouseWheelEvent::UpdateForRootTransform(
490 const gfx::Transform& inverted_root_transform) { 494 const gfx::Transform& inverted_root_transform) {
491 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 495 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
492 gfx::DecomposedTransform decomp; 496 gfx::DecomposedTransform decomp;
493 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 497 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
494 DCHECK(success); 498 DCHECK(success);
495 if (decomp.scale[0]) 499 if (decomp.scale[0]) {
496 offset_.set_x(offset_.x() * decomp.scale[0]); 500 offset_.set_x(
497 if (decomp.scale[1]) 501 gfx::ToRoundedInt(SkMScalarToFloat(offset_.x() * decomp.scale[0])));
498 offset_.set_y(offset_.y() * decomp.scale[1]); 502 }
503 if (decomp.scale[1]) {
504 offset_.set_y(
505 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1])));
506 }
499 } 507 }
500 508
501 //////////////////////////////////////////////////////////////////////////////// 509 ////////////////////////////////////////////////////////////////////////////////
502 // TouchEvent 510 // TouchEvent
503 511
504 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 512 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
505 : LocatedEvent(native_event), 513 : LocatedEvent(native_event),
506 touch_id_(GetTouchId(native_event)), 514 touch_id_(GetTouchId(native_event)),
507 radius_x_(GetTouchRadiusX(native_event)), 515 radius_x_(GetTouchRadiusX(native_event)),
508 radius_y_(GetTouchRadiusY(native_event)), 516 radius_y_(GetTouchRadiusY(native_event)),
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 gfx::PointF(x, y), 969 gfx::PointF(x, y),
962 time_stamp, 970 time_stamp,
963 flags | EF_FROM_TOUCH), 971 flags | EF_FROM_TOUCH),
964 details_(details) { 972 details_(details) {
965 } 973 }
966 974
967 GestureEvent::~GestureEvent() { 975 GestureEvent::~GestureEvent() {
968 } 976 }
969 977
970 } // namespace ui 978 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/util/display_util.cc ('k') | ui/events/gesture_detection/gesture_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698