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

Unified Diff: Source/web/WebInputEventConversion.cpp

Issue 727593003: Implement MouseEvent buttons attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: should be 0 in contextmenu event Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/WebInputEventConversion.cpp
diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp
index 09586f45a73f41cbb1bd634171343c8e73832508..2e25342b14e2d0f9121adf97091b4a45dd17bae5 100644
--- a/Source/web/WebInputEventConversion.cpp
+++ b/Source/web/WebInputEventConversion.cpp
@@ -104,11 +104,23 @@ PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
m_modifiers |= PlatformEvent::AltKey;
if (e.modifiers & WebInputEvent::MetaKey)
m_modifiers |= PlatformEvent::MetaKey;
+ if (e.modifiers & WebInputEvent::LeftButtonDown)
+ m_modifiers |= PlatformEvent::LeftButtonDown;
+ if (e.modifiers & WebInputEvent::MiddleButtonDown)
+ m_modifiers |= PlatformEvent::MiddleButtonDown;
+ if (e.modifiers & WebInputEvent::RightButtonDown)
+ m_modifiers |= PlatformEvent::RightButtonDown;
m_modifierFlags = e.modifiers;
m_timestamp = e.timeStampSeconds;
m_clickCount = e.clickCount;
+ const unsigned buttonToModifier[] = {
+ PlatformEvent::LeftButtonDown,
+ PlatformEvent::MiddleButtonDown,
+ PlatformEvent::RightButtonDown
+ };
+
switch (e.type) {
case WebInputEvent::MouseMove:
case WebInputEvent::MouseLeave: // synthesize a move event
@@ -121,6 +133,12 @@ PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
case WebInputEvent::MouseUp:
m_type = PlatformEvent::MouseReleased;
+
+ // The MouseEvent spec requires that buttons indicates the state
+ // immediately after the event takes place. To ensure consistency
+ // between platforms here, we explicitly clear the button that is
+ // in the process of being released.
+ m_modifiers &= ~buttonToModifier[e.button];
break;
default:
@@ -152,6 +170,12 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
m_modifiers |= PlatformEvent::AltKey;
if (e.modifiers & WebInputEvent::MetaKey)
m_modifiers |= PlatformEvent::MetaKey;
+ if (e.modifiers & WebInputEvent::LeftButtonDown)
+ m_modifiers |= PlatformEvent::LeftButtonDown;
+ if (e.modifiers & WebInputEvent::MiddleButtonDown)
+ m_modifiers |= PlatformEvent::MiddleButtonDown;
+ if (e.modifiers & WebInputEvent::RightButtonDown)
+ m_modifiers |= PlatformEvent::RightButtonDown;
m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
#if OS(MACOSX)

Powered by Google App Engine
This is Rietveld 408576698