Commit 3f6b636c authored by Will Harris's avatar Will Harris Committed by Commit Bot

Fix -Wshorten-64-to-32 warnings in ui/events.

../../ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc(58,32):  warning: implicit conversion loses integer precision: 'std::vector<HKL__ *, std::allocator<HKL__ *> >::size_type' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
      keyboard_layout_handles_.size(), keyboard_layout_handles_.data());
      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
../../ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc(75,35):  warning: implicit conversion loses integer precision: 'std::vector<HKL__ *, std::allocator<HKL__ *> >::size_type' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  return keyboard_layout_handles_.size();
  ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~

../../ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc(32,44):  warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
        keyboard_layout_manager->GetLayout(i);
                                 ~~~~~~~~~ ^
../../ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc(33,20):  warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    PopulateLayout(i, dom_keyboard_layout);
    ~~~~~~~~~~~~~~ ^

../../ui/events/test/event_generator.cc(673,51):  warning: implicit conversion loses integer precision: 'int64_t' (aka 'long long') to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
      (ui::EventTimeForNow() - base::TimeTicks()).InMicroseconds();
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

../../ui/events/win/events_win_utils.cc(257,36):  warning: implicit conversion loses integer precision: 'const LPARAM' (aka 'const long long') to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
    return gfx::Point(native_event.lParam);
           ~~~        ~~~~~~~~~~~~~^~~~~~

../../ui/events/event_utils.cc(112,41):  warning: implicit conversion loses integer precision: 'int64_t' (aka 'long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
                                  delta.InMicroseconds(), 1, 1000000, 50);
                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../ui/events/event_utils.cc(116,41):  warning: implicit conversion loses integer precision: 'int64_t' (aka 'long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
                                  delta.InMicroseconds(), 1, 1000000, 50);
                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../ui/events/event_utils.cc(120,41):  warning: implicit conversion loses integer precision: 'int64_t' (aka 'long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
                                  delta.InMicroseconds(), 1, 1000000, 50);
                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../ui/events/event_utils.cc(124,41):  warning: implicit conversion loses integer precision: 'int64_t' (aka 'long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
                                  delta.InMicroseconds(), 1, 1000000, 50);
                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
[22971/48339] CXX obj/ui/events/events/keyboard_hook_win.obj
../../ui/events/win/keyboard_hook_win.cc(117,25):  warning: implicit conversion loses integer precision: 'WPARAM' (aka 'unsigned long long') to 'UINT' (aka 'unsigned int') [-Wshorten-64-to-32]
    MSG msg = {nullptr, w_param, ll_hooks->vkCode,
              ~         ^~~~~~~

../../ui/events/event.cc(1137,47):  warning: implicit conversion loses integer precision: 'const WPARAM' (aka 'const unsigned long long') to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
    key_ = DomKey::FromCharacter(native_event.wParam);
           ~~~~~~                ~~~~~~~~~~~~~^~~~~~

BUG=879657

Change-Id: If41fb68b2e054ff4f429396e78048d48f71a3e38
Reviewed-on: https://chromium-review.googlesource.com/1214682Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590185}
parent 68c436ef
...@@ -1134,7 +1134,7 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags) ...@@ -1134,7 +1134,7 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags)
#if defined(OS_WIN) #if defined(OS_WIN)
// Only Windows has native character events. // Only Windows has native character events.
if (is_char_) { if (is_char_) {
key_ = DomKey::FromCharacter(native_event.wParam); key_ = DomKey::FromCharacter(static_cast<int32_t>(native_event.wParam));
set_flags(PlatformKeyMap::ReplaceControlAndAltWithAltGraph(flags())); set_flags(PlatformKeyMap::ReplaceControlAndAltWithAltGraph(flags()));
} else { } else {
int adjusted_flags = flags(); int adjusted_flags = flags();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
...@@ -108,20 +109,24 @@ void ComputeEventLatencyOS(const PlatformEvent& native_event) { ...@@ -108,20 +109,24 @@ void ComputeEventLatencyOS(const PlatformEvent& native_event) {
case ET_SCROLL: case ET_SCROLL:
#endif #endif
case ET_MOUSEWHEEL: case ET_MOUSEWHEEL:
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.MOUSE_WHEEL", UMA_HISTOGRAM_CUSTOM_COUNTS(
delta.InMicroseconds(), 1, 1000000, 50); "Event.Latency.OS.MOUSE_WHEEL",
base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
return; return;
case ET_TOUCH_MOVED: case ET_TOUCH_MOVED:
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_MOVED", UMA_HISTOGRAM_CUSTOM_COUNTS(
delta.InMicroseconds(), 1, 1000000, 50); "Event.Latency.OS.TOUCH_MOVED",
base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
return; return;
case ET_TOUCH_PRESSED: case ET_TOUCH_PRESSED:
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_PRESSED", UMA_HISTOGRAM_CUSTOM_COUNTS(
delta.InMicroseconds(), 1, 1000000, 50); "Event.Latency.OS.TOUCH_PRESSED",
base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
return; return;
case ET_TOUCH_RELEASED: case ET_TOUCH_RELEASED:
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", UMA_HISTOGRAM_CUSTOM_COUNTS(
delta.InMicroseconds(), 1, 1000000, 50); "Event.Latency.OS.TOUCH_RELEASED",
base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
return; return;
default: default:
return; return;
......
...@@ -670,7 +670,7 @@ void EventGenerator::DispatchKeyEvent(bool is_press, ...@@ -670,7 +670,7 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
MSG native_event = MSG native_event =
{ NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 }; { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
native_event.time = native_event.time =
(ui::EventTimeForNow() - base::TimeTicks()).InMicroseconds(); (ui::EventTimeForNow() - base::TimeTicks()).InMilliseconds() & UINT32_MAX;
ui::KeyEvent keyev(native_event, flags); ui::KeyEvent keyev(native_event, flags);
#elif defined(USE_X11) #elif defined(USE_X11)
ui::ScopedXI2Event xevent; ui::ScopedXI2Event xevent;
......
...@@ -254,7 +254,7 @@ gfx::Point EventLocationFromMSG(const MSG& native_event) { ...@@ -254,7 +254,7 @@ gfx::Point EventLocationFromMSG(const MSG& native_event) {
// Note: Wheel events are considered client, but their position is in screen // Note: Wheel events are considered client, but their position is in screen
// coordinates. // coordinates.
// Client message. The position is contained in the LPARAM. // Client message. The position is contained in the LPARAM.
return gfx::Point(native_event.lParam); return gfx::Point(static_cast<DWORD>(native_event.lParam));
} else { } else {
DCHECK(IsNonClientMouseEvent(native_event) || DCHECK(IsNonClientMouseEvent(native_event) ||
IsMouseWheelEvent(native_event) || IsScrollEvent(native_event)); IsMouseWheelEvent(native_event) || IsScrollEvent(native_event));
......
...@@ -114,7 +114,7 @@ LRESULT CALLBACK KeyboardHookWin::ProcessKeyEvent(int code, ...@@ -114,7 +114,7 @@ LRESULT CALLBACK KeyboardHookWin::ProcessKeyEvent(int code,
KeycodeConverter::NativeKeycodeToDomCode(ll_hooks->scanCode); KeycodeConverter::NativeKeycodeToDomCode(ll_hooks->scanCode);
if (!IsOSReservedKey(ll_hooks->vkCode) && if (!IsOSReservedKey(ll_hooks->vkCode) &&
instance_->ShouldCaptureKeyEvent(dom_code)) { instance_->ShouldCaptureKeyEvent(dom_code)) {
MSG msg = {nullptr, w_param, ll_hooks->vkCode, MSG msg = {nullptr, static_cast<UINT>(w_param), ll_hooks->vkCode,
(ll_hooks->scanCode << 16) | (ll_hooks->flags & 0xFFFF), (ll_hooks->scanCode << 16) | (ll_hooks->flags & 0xFFFF),
ll_hooks->time}; ll_hooks->time};
KeyEvent key_event = KeyEventFromMSG(msg); KeyEvent key_event = KeyEventFromMSG(msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment