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

Unified Diff: content/browser/web_contents/web_drag_dest_mac.mm

Issue 878413003: Support buttons attribute for drag event (chromium side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_drag_dest_mac.mm
diff --git a/content/browser/web_contents/web_drag_dest_mac.mm b/content/browser/web_contents/web_drag_dest_mac.mm
index 0e57d4fffdee46ca083f189ca7a90f08e91da6ae..764ff6b0e85fa554f93b2c317dce467ffa8fcba6 100644
--- a/content/browser/web_contents/web_drag_dest_mac.mm
+++ b/content/browser/web_contents/web_drag_dest_mac.mm
@@ -35,6 +35,19 @@ int GetModifierFlags() {
modifier_state |= blink::WebInputEvent::AltKey;
if (currentModifiers & ::cmdKey)
modifier_state |= blink::WebInputEvent::MetaKey;
+
+ // The return value of 1 << 0 corresponds to the left mouse button,
+ // 1 << 1 corresponds to the right mouse button,
+ // 1 << n, n >= 2 correspond to other mouse buttons.
+ NSUInteger pressedButtons = [NSEvent pressedMouseButtons];
+
+ if (pressedButtons & (1 << 0))
+ modifier_state |= blink::WebInputEvent::LeftButtonDown;
+ if (pressedButtons & (1 << 1))
+ modifier_state |= blink::WebInputEvent::RightButtonDown;
+ if (pressedButtons & (1 << 2))
+ modifier_state |= blink::WebInputEvent::MiddleButtonDown;
+
return modifier_state;
}

Powered by Google App Engine
This is Rietveld 408576698