Commit bb151d67 authored by jdduke@chromium.org's avatar jdduke@chromium.org

Use MSG.time for WebInputEvent timestamps on Windows

Previously on Windows, WebInputEvents generated from ui::Events would call
|GetMessageTime()| to initialize the WebInputEvent timestamp. There are no
guarantees that such a call is valid at that time.  Instead, use the MSG.time
timestamp generated when the ui::Event was first created from the HWND message.

BUG=367156

Review URL: https://codereview.chromium.org/252083002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267056 0039d316-1c4b-4281-b951-d872f2087c98
parent 1a98058e
...@@ -102,15 +102,15 @@ static void SetToggleKeyState(WebInputEvent* event) { ...@@ -102,15 +102,15 @@ static void SetToggleKeyState(WebInputEvent* event) {
event->modifiers |= WebInputEvent::CapsLockOn; event->modifiers |= WebInputEvent::CapsLockOn;
} }
WebKeyboardEvent WebKeyboardEventBuilder::Build(HWND hwnd, UINT message, WebKeyboardEvent WebKeyboardEventBuilder::Build(HWND hwnd,
WPARAM wparam, LPARAM lparam) { UINT message,
WPARAM wparam,
LPARAM lparam,
DWORD time_ms) {
WebKeyboardEvent result; WebKeyboardEvent result;
// TODO(pkasting): http://b/1117926 Are we guaranteed that the message that DCHECK(time_ms);
// GetMessageTime() refers to is the same one that we're passed in? Perhaps result.timeStampSeconds = time_ms / 1000.0;
// one of the construction parameters should be the time passed by the
// caller, who would know for sure.
result.timeStampSeconds = ::GetMessageTime() / 1000.0;
result.windowsKeyCode = static_cast<int>(wparam); result.windowsKeyCode = static_cast<int>(wparam);
// Record the scan code (along with other context bits) for this key event. // Record the scan code (along with other context bits) for this key event.
...@@ -181,8 +181,11 @@ static LPARAM GetRelativeCursorPos(HWND hwnd) { ...@@ -181,8 +181,11 @@ static LPARAM GetRelativeCursorPos(HWND hwnd) {
return MAKELPARAM(pos.x, pos.y); return MAKELPARAM(pos.x, pos.y);
} }
WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, UINT message, WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd,
WPARAM wparam, LPARAM lparam) { UINT message,
WPARAM wparam,
LPARAM lparam,
DWORD time_ms) {
WebMouseEvent result; WebMouseEvent result;
switch (message) { switch (message) {
...@@ -235,11 +238,8 @@ WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, UINT message, ...@@ -235,11 +238,8 @@ WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, UINT message,
NOTREACHED(); NOTREACHED();
} }
// TODO(pkasting): http://b/1117926 Are we guaranteed that the message that DCHECK(time_ms);
// GetMessageTime() refers to is the same one that we're passed in? Perhaps result.timeStampSeconds = time_ms / 1000.0;
// one of the construction parameters should be the time passed by the
// caller, who would know for sure.
result.timeStampSeconds = ::GetMessageTime() / 1000.0;
// set position fields: // set position fields:
...@@ -312,18 +312,17 @@ WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, UINT message, ...@@ -312,18 +312,17 @@ WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, UINT message,
// WebMouseWheelEvent --------------------------------------------------------- // WebMouseWheelEvent ---------------------------------------------------------
WebMouseWheelEvent WebMouseWheelEvent WebMouseWheelEventBuilder::Build(HWND hwnd,
WebMouseWheelEventBuilder::Build(HWND hwnd, UINT message, UINT message,
WPARAM wparam, LPARAM lparam) { WPARAM wparam,
LPARAM lparam,
DWORD time_ms) {
WebMouseWheelEvent result; WebMouseWheelEvent result;
result.type = WebInputEvent::MouseWheel; result.type = WebInputEvent::MouseWheel;
// TODO(pkasting): http://b/1117926 Are we guaranteed that the message that DCHECK(time_ms);
// GetMessageTime() refers to is the same one that we're passed in? Perhaps result.timeStampSeconds = time_ms / 1000.0;
// one of the construction parameters should be the time passed by the
// caller, who would know for sure.
result.timeStampSeconds = ::GetMessageTime() / 1000.0;
result.button = WebMouseEvent::ButtonNone; result.button = WebMouseEvent::ButtonNone;
......
...@@ -13,20 +13,29 @@ namespace content { ...@@ -13,20 +13,29 @@ namespace content {
class WebKeyboardEventBuilder { class WebKeyboardEventBuilder {
public: public:
static blink::WebKeyboardEvent Build(HWND hwnd, UINT message, static blink::WebKeyboardEvent Build(HWND hwnd,
WPARAM wparam, LPARAM lparam); UINT message,
WPARAM wparam,
LPARAM lparam,
DWORD time_ms);
}; };
class WebMouseEventBuilder { class WebMouseEventBuilder {
public: public:
static blink::WebMouseEvent Build(HWND hwnd, UINT message, static blink::WebMouseEvent Build(HWND hwnd,
WPARAM wparam, LPARAM lparam); UINT message,
WPARAM wparam,
LPARAM lparam,
DWORD time_ms);
}; };
class WebMouseWheelEventBuilder { class WebMouseWheelEventBuilder {
public: public:
static blink::WebMouseWheelEvent Build(HWND hwnd, UINT message, static blink::WebMouseWheelEvent Build(HWND hwnd,
WPARAM wparam, LPARAM lparam); UINT message,
WPARAM wparam,
LPARAM lparam,
DWORD time_ms);
}; };
} // namespace content } // namespace content
......
...@@ -63,13 +63,13 @@ blink::WebUChar GetControlCharacter(int windows_key_code, bool shift) { ...@@ -63,13 +63,13 @@ blink::WebUChar GetControlCharacter(int windows_key_code, bool shift) {
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
base::NativeEvent native_event); const base::NativeEvent& native_event);
blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent( blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
base::NativeEvent native_event); const base::NativeEvent& native_event);
blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
base::NativeEvent native_event); const base::NativeEvent& native_event);
blink::WebGestureEvent MakeWebGestureEventFromNativeEvent( blink::WebGestureEvent MakeWebGestureEventFromNativeEvent(
base::NativeEvent native_event); const base::NativeEvent& native_event);
#elif defined(USE_X11) #elif defined(USE_X11)
blink::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent( blink::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
ui::KeyEvent* event); ui::KeyEvent* event);
......
...@@ -14,31 +14,34 @@ namespace content { ...@@ -14,31 +14,34 @@ namespace content {
// construct our pre-translated events. // construct our pre-translated events.
blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
base::NativeEvent native_event) { const base::NativeEvent& native_event) {
return WebMouseEventBuilder::Build(native_event.hwnd, return WebMouseEventBuilder::Build(native_event.hwnd,
native_event.message, native_event.message,
native_event.wParam, native_event.wParam,
native_event.lParam); native_event.lParam,
native_event.time);
} }
blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent( blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
base::NativeEvent native_event) { const base::NativeEvent& native_event) {
return WebMouseWheelEventBuilder::Build(native_event.hwnd, return WebMouseWheelEventBuilder::Build(native_event.hwnd,
native_event.message, native_event.message,
native_event.wParam, native_event.wParam,
native_event.lParam); native_event.lParam,
native_event.time);
} }
blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
base::NativeEvent native_event) { const base::NativeEvent& native_event) {
return WebKeyboardEventBuilder::Build(native_event.hwnd, return WebKeyboardEventBuilder::Build(native_event.hwnd,
native_event.message, native_event.message,
native_event.wParam, native_event.wParam,
native_event.lParam); native_event.lParam,
native_event.time);
} }
blink::WebGestureEvent MakeWebGestureEventFromNativeEvent( blink::WebGestureEvent MakeWebGestureEventFromNativeEvent(
base::NativeEvent native_event) { const base::NativeEvent& native_event) {
// TODO: Create gestures from native event. // TODO: Create gestures from native event.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return blink::WebGestureEvent(); return blink::WebGestureEvent();
......
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