summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 02:16:44 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 02:16:44 +0000
commit2711ac053ca80da1fe280db1bfe00696feb2a10a (patch)
treea09a3350c1034d5ec888d8811727f43f4827404f /chrome/browser
parente8d99021e731d5c491311e20c7ed4c92d2d52f4b (diff)
downloadchromium_src-2711ac053ca80da1fe280db1bfe00696feb2a10a.zip
chromium_src-2711ac053ca80da1fe280db1bfe00696feb2a10a.tar.gz
chromium_src-2711ac053ca80da1fe280db1bfe00696feb2a10a.tar.bz2
Fix DCHECK in web_drop_target_win.cc.
Relax the DCHECK for asserting that only one drag op is set. WebKit occasionally only sets DragOperationMove to indicate a drag move, even though the usual convention is to set both DragOperationMove and DragOperationGeneric. BUG=41670 TEST=none Review URL: http://codereview.chromium.org/1513044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rwxr-xr-x[-rw-r--r--]chrome/browser/tab_contents/web_drag_utils_win.cc57
-rwxr-xr-x[-rw-r--r--]chrome/browser/tab_contents/web_drag_utils_win.h7
-rw-r--r--chrome/browser/tab_contents/web_drop_target_win.cc22
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_drag_win.cc2
4 files changed, 52 insertions, 36 deletions
diff --git a/chrome/browser/tab_contents/web_drag_utils_win.cc b/chrome/browser/tab_contents/web_drag_utils_win.cc
index 6796876..cd2af68 100644..100755
--- a/chrome/browser/tab_contents/web_drag_utils_win.cc
+++ b/chrome/browser/tab_contents/web_drag_utils_win.cc
@@ -5,35 +5,56 @@
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include <oleidl.h>
+#include "base/logging.h"
+using WebKit::WebDragOperation;
using WebKit::WebDragOperationsMask;
using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationCopy;
using WebKit::WebDragOperationLink;
using WebKit::WebDragOperationMove;
+using WebKit::WebDragOperationGeneric;
namespace web_drag_utils_win {
-WebDragOperationsMask WinDragOpToWebDragOp(DWORD effect) {
- WebDragOperationsMask op = WebDragOperationNone;
- if (effect & DROPEFFECT_COPY)
- op = static_cast<WebDragOperationsMask>(op | WebDragOperationCopy);
- if (effect & DROPEFFECT_LINK)
- op = static_cast<WebDragOperationsMask>(op | WebDragOperationLink);
- if (effect & DROPEFFECT_MOVE)
- op = static_cast<WebDragOperationsMask>(op | WebDragOperationMove);
- return op;
+WebDragOperation WinDragOpToWebDragOp(DWORD effect) {
+ DCHECK(effect == DROPEFFECT_NONE || effect == DROPEFFECT_COPY ||
+ effect == DROPEFFECT_LINK || effect == DROPEFFECT_MOVE);
+
+ return WinDragOpMaskToWebDragOpMask(effect);
+}
+
+WebDragOperationsMask WinDragOpMaskToWebDragOpMask(DWORD effects) {
+ WebDragOperationsMask ops = WebDragOperationNone;
+ if (effects & DROPEFFECT_COPY)
+ ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationCopy);
+ if (effects & DROPEFFECT_LINK)
+ ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationLink);
+ if (effects & DROPEFFECT_MOVE)
+ ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationMove |
+ WebDragOperationGeneric);
+ return ops;
+}
+
+DWORD WebDragOpToWinDragOp(WebDragOperation op) {
+ DCHECK(op == WebDragOperationNone ||
+ op == WebDragOperationCopy ||
+ op == WebDragOperationLink ||
+ op == WebDragOperationMove ||
+ op == (WebDragOperationMove | WebDragOperationGeneric));
+
+ return WebDragOpMaskToWinDragOpMask(op);
}
-DWORD WebDragOpToWinDragOp(WebDragOperationsMask op) {
- DWORD win_op = DROPEFFECT_NONE;
- if (op & WebDragOperationCopy)
- win_op |= DROPEFFECT_COPY;
- if (op & WebDragOperationLink)
- win_op |= DROPEFFECT_LINK;
- if (op & WebDragOperationMove)
- win_op |= DROPEFFECT_MOVE;
- return win_op;
+DWORD WebDragOpMaskToWinDragOpMask(WebDragOperationsMask ops) {
+ DWORD win_ops = DROPEFFECT_NONE;
+ if (ops & WebDragOperationCopy)
+ win_ops |= DROPEFFECT_COPY;
+ if (ops & WebDragOperationLink)
+ win_ops |= DROPEFFECT_LINK;
+ if (ops & (WebDragOperationMove | WebDragOperationGeneric))
+ win_ops |= DROPEFFECT_MOVE;
+ return win_ops;
}
} // namespace web_drag_utils_win
diff --git a/chrome/browser/tab_contents/web_drag_utils_win.h b/chrome/browser/tab_contents/web_drag_utils_win.h
index 5deae2b..6561733 100644..100755
--- a/chrome/browser/tab_contents/web_drag_utils_win.h
+++ b/chrome/browser/tab_contents/web_drag_utils_win.h
@@ -11,8 +11,11 @@
namespace web_drag_utils_win {
-WebKit::WebDragOperationsMask WinDragOpToWebDragOp(DWORD effect);
-DWORD WebDragOpToWinDragOp(WebKit::WebDragOperationsMask op);
+WebKit::WebDragOperation WinDragOpToWebDragOp(DWORD effect);
+WebKit::WebDragOperationsMask WinDragOpMaskToWebDragOpMask(DWORD effects);
+
+DWORD WebDragOpToWinDragOp(WebKit::WebDragOperation op);
+DWORD WebDragOpMaskToWinDragOpMask(WebKit::WebDragOperationsMask ops);
} // namespace web_drag_utils_win
diff --git a/chrome/browser/tab_contents/web_drop_target_win.cc b/chrome/browser/tab_contents/web_drop_target_win.cc
index 66dee6a..c79578c 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.cc
+++ b/chrome/browser/tab_contents/web_drop_target_win.cc
@@ -98,14 +98,14 @@ WebDropTarget::~WebDropTarget() {
DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
- DWORD effect) {
+ DWORD effects) {
current_rvh_ = tab_contents_->render_view_host();
// Don't pass messages to the renderer if an interstitial page is showing
// because we don't want the interstitial page to navigate. Instead,
// pass the messages on to a separate interstitial DropTarget handler.
if (tab_contents_->showing_interstitial_page())
- return interstitial_drop_target_->OnDragEnter(data_object, effect);
+ return interstitial_drop_target_->OnDragEnter(data_object, effects);
// TODO(tc): PopulateWebDropData can be slow depending on what is in the
// IDataObject. Maybe we can do this in a background thread.
@@ -122,7 +122,7 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
tab_contents_->render_view_host()->DragTargetDragEnter(drop_data,
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- web_drag_utils_win::WinDragOpToWebDragOp(effect));
+ web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
// This is non-null if tab_contents_ is showing an ExtensionDOMUI with
// support for (at the moment experimental) drag and drop extensions.
@@ -135,30 +135,26 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
// We lie here and always return a DROPEFFECT because we don't want to
// wait for the IPC call to return.
- DCHECK(drag_cursor_ == WebDragOperationNone ||
- drag_cursor_ == WebDragOperationCopy ||
- drag_cursor_ == WebDragOperationLink ||
- drag_cursor_ == (WebDragOperationMove | WebDragOperationGeneric));
return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
- DWORD effect) {
+ DWORD effects) {
DCHECK(current_rvh_);
if (current_rvh_ != tab_contents_->render_view_host())
- OnDragEnter(data_object, key_state, cursor_position, effect);
+ OnDragEnter(data_object, key_state, cursor_position, effects);
if (tab_contents_->showing_interstitial_page())
- return interstitial_drop_target_->OnDragOver(data_object, effect);
+ return interstitial_drop_target_->OnDragOver(data_object, effects);
POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt);
tab_contents_->render_view_host()->DragTargetDragOver(
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- web_drag_utils_win::WinDragOpToWebDragOp(effect));
+ web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
if (tab_contents_->GetBookmarkDragDelegate()) {
OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
@@ -167,10 +163,6 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data);
}
- DCHECK(drag_cursor_ == WebDragOperationNone ||
- drag_cursor_ == WebDragOperationCopy ||
- drag_cursor_ == WebDragOperationLink ||
- drag_cursor_ == (WebDragOperationMove | WebDragOperationGeneric));
return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
diff --git a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
index 4b84313..21fc9fd 100644
--- a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
@@ -290,7 +290,7 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
DWORD effect;
MessageLoop::current()->SetNestableTasksAllowed(true);
DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_,
- web_drag_utils_win::WebDragOpToWinDragOp(ops), &effect);
+ web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect);
// This works because WebDragSource::OnDragSourceDrop uses PostTask to
// dispatch the actual event.
drag_source_->set_effect(effect);