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

Unified Diff: content/browser/web_contents/web_drag_dest_win.cc

Issue 10377119: Plumb event flags (shift/alt/ctrl modifiers) for drag/drop events to WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed compile error Created 8 years, 7 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
« no previous file with comments | « content/browser/web_contents/web_drag_dest_mac.mm ('k') | content/common/drag_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_drag_dest_win.cc
diff --git a/content/browser/web_contents/web_drag_dest_win.cc b/content/browser/web_contents/web_drag_dest_win.cc
index 8a3142d388caf1865150217fde715e6cbfd0c4dd..ab0a69b2b87846e8d8fb7f6db085b7de883d4852 100644
--- a/content/browser/web_contents/web_drag_dest_win.cc
+++ b/content/browser/web_contents/web_drag_dest_win.cc
@@ -13,6 +13,7 @@
#include "content/public/browser/web_drag_dest_delegate.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/base/clipboard/clipboard_util_win.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_win.h"
@@ -31,6 +32,8 @@ using content::WebContents;
namespace {
+const unsigned short kHighBitMaskShort = 0x8000;
+
// A helper method for getting the preferred drop effect.
DWORD GetPreferredDropEffect(DWORD effect) {
if (effect & DROPEFFECT_COPY)
@@ -42,6 +45,21 @@ DWORD GetPreferredDropEffect(DWORD effect) {
return DROPEFFECT_NONE;
}
+int GetModifierFlags() {
+ int modifier_state = 0;
+ if (::GetKeyState(VK_SHIFT) & kHighBitMaskShort)
+ modifier_state |= WebKit::WebInputEvent::ShiftKey;
+ if (::GetKeyState(VK_CONTROL) & kHighBitMaskShort)
+ modifier_state |= WebKit::WebInputEvent::ControlKey;
+ if (::GetKeyState(VK_MENU) & kHighBitMaskShort)
+ modifier_state |= WebKit::WebInputEvent::AltKey;
+ if (::GetKeyState(VK_LWIN) & kHighBitMaskShort)
+ modifier_state |= WebKit::WebInputEvent::MetaKey;
+ if (::GetKeyState(VK_RWIN) & kHighBitMaskShort)
+ modifier_state |= WebKit::WebInputEvent::MetaKey;
+ return modifier_state;
+}
+
} // namespace
// InterstitialDropTarget is like a ui::DropTarget implementation that
@@ -129,7 +147,8 @@ DWORD WebDragDest::OnDragEnter(IDataObject* data_object,
web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_,
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
+ web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects),
+ GetModifierFlags());
if (delegate_)
delegate_->OnDragEnter(data_object);
@@ -155,7 +174,8 @@ DWORD WebDragDest::OnDragOver(IDataObject* data_object,
web_contents_->GetRenderViewHost()->DragTargetDragOver(
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
+ web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects),
+ GetModifierFlags());
if (delegate_)
delegate_->OnDragOver(data_object);
@@ -198,7 +218,8 @@ DWORD WebDragDest::OnDrop(IDataObject* data_object,
ScreenToClient(GetHWND(), &client_pt);
web_contents_->GetRenderViewHost()->DragTargetDrop(
gfx::Point(client_pt.x, client_pt.y),
- gfx::Point(cursor_position.x, cursor_position.y));
+ gfx::Point(cursor_position.x, cursor_position.y),
+ GetModifierFlags());
if (delegate_)
delegate_->OnDrop(data_object);
« no previous file with comments | « content/browser/web_contents/web_drag_dest_mac.mm ('k') | content/common/drag_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698