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

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: nit Created 5 years, 9 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..bc41d43a49a36578be349304795d999316f74ecd 100644
--- a/content/browser/web_contents/web_drag_dest_mac.mm
+++ b/content/browser/web_contents/web_drag_dest_mac.mm
@@ -24,6 +24,8 @@ using content::OpenURLParams;
using content::Referrer;
using content::WebContentsImpl;
+namespace {
+
int GetModifierFlags() {
int modifier_state = 0;
UInt32 currentModifiers = GetCurrentKeyModifiers();
@@ -35,9 +37,24 @@ 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;
}
+} // namespace
+
@implementation WebDragDest
// |contents| is the WebContentsImpl representing this tab, used to communicate
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.cc ('k') | content/shell/renderer/test_runner/event_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698