summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 03:18:28 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 03:18:28 +0000
commitfa23bd53f70490619439cee296e084d739c15aa1 (patch)
treef5db3cdf43d327b1d4ec12165fd12bd1e70bbe0d /chrome
parentea4a1d01a2d1aad09c92821a51bb44c4412785f8 (diff)
downloadchromium_src-fa23bd53f70490619439cee296e084d739c15aa1.zip
chromium_src-fa23bd53f70490619439cee296e084d739c15aa1.tar.gz
chromium_src-fa23bd53f70490619439cee296e084d739c15aa1.tar.bz2
Fix HTML5 effectAllowed and dragEffect on Chrome Linux.
This hooks up all the chrome side plumbing, but there are a couple webkit changes that need to happen for this to fully work. BUG=14654 Review URL: http://codereview.chromium.org/1084003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42306 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc4
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.h1
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc4
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.cc46
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc3
5 files changed, 37 insertions, 21 deletions
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index 6d9ca4c..c0c9c72 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -24,6 +24,7 @@
#include "webkit/glue/webdropdata.h"
using WebKit::WebDragOperation;
+using WebKit::WebDragOperationsMask;
using WebKit::WebDragOperationNone;
TabContentsDragSource::TabContentsDragSource(
@@ -70,6 +71,7 @@ TabContents* TabContentsDragSource::tab_contents() const {
}
void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
+ WebDragOperationsMask allowed_ops,
GdkEventButton* last_mouse_down,
const SkBitmap& image,
const gfx::Point& image_offset) {
@@ -123,7 +125,7 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
// initiating event from webkit.
GdkDragContext* context = gtk_drag_begin(
drag_widget_, list,
- static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK),
+ gtk_dnd_util::WebDragOpToGdkDragAction(allowed_ops),
1, // Drags are always initiated by the left button.
reinterpret_cast<GdkEvent*>(last_mouse_down));
// The drag adds a ref; let it own the list.
diff --git a/chrome/browser/gtk/tab_contents_drag_source.h b/chrome/browser/gtk/tab_contents_drag_source.h
index 7740ee6..b7407f3 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.h
+++ b/chrome/browser/gtk/tab_contents_drag_source.h
@@ -33,6 +33,7 @@ class TabContentsDragSource : public MessageLoopForUI::Observer {
// Starts a drag for the tab contents this TabContentsDragSource was
// created for.
void StartDragging(const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask allowed_ops,
GdkEventButton* last_mouse_down,
const SkBitmap& image,
const gfx::Point& image_offset);
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index b549ada..804cf56 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -327,10 +327,8 @@ void TabContentsViewGtk::StartDragging(const WebDropData& drop_data,
const SkBitmap& image,
const gfx::Point& image_offset) {
DCHECK(GetContentNativeView());
-
- drag_source_->StartDragging(drop_data, &last_mouse_down_, image,
+ drag_source_->StartDragging(drop_data, ops, &last_mouse_down_, image,
image_offset);
- // TODO(snej): Make use of the WebDragOperationsMask somehow
}
// -----------------------------------------------------------------------------
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
index d96f6cf..1d7cd88 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
@@ -16,9 +16,25 @@
#include "net/base/net_util.h"
using WebKit::WebDragOperation;
+using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationCopy;
+using WebKit::WebDragOperationLink;
using WebKit::WebDragOperationMove;
-using WebKit::WebDragOperationNone;
+
+namespace {
+
+WebDragOperation GdkDragActionToWebDragOp(GdkDragAction action) {
+ WebDragOperation op = WebDragOperationNone;
+ if (action & GDK_ACTION_COPY)
+ op = static_cast<WebDragOperation>(op | WebDragOperationCopy);
+ if (action & GDK_ACTION_LINK)
+ op = static_cast<WebDragOperation>(op | WebDragOperationLink);
+ if (action & GDK_ACTION_MOVE)
+ op = static_cast<WebDragOperation>(op | WebDragOperationMove);
+ return op;
+}
+
+} // namespace
WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
: tab_contents_(tab_contents),
@@ -26,7 +42,10 @@ WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
context_(NULL),
method_factory_(this) {
gtk_drag_dest_set(widget, static_cast<GtkDestDefaults>(0),
- NULL, 0, GDK_ACTION_COPY);
+ NULL, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY |
+ GDK_ACTION_LINK |
+ GDK_ACTION_MOVE));
g_signal_connect(widget, "drag-motion",
G_CALLBACK(OnDragMotionThunk), this);
g_signal_connect(widget, "drag-leave",
@@ -35,6 +54,8 @@ WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
G_CALLBACK(OnDragDropThunk), this);
g_signal_connect(widget, "drag-data-received",
G_CALLBACK(OnDragDataReceivedThunk), this);
+ // TODO(tony): Need a drag-data-delete handler for moving content out of
+ // the tab contents. http://crbug.com/38989
destroy_handler_ = g_signal_connect(
widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget_);
@@ -49,12 +70,8 @@ WebDragDestGtk::~WebDragDestGtk() {
void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) {
if (context_) {
- // TODO(estade): we might want to support other actions besides copy,
- // but that would increase the cost of getting our drag success guess
- // wrong.
is_drop_target_ = operation != WebDragOperationNone;
- gdk_drag_status(context_, is_drop_target_ ? GDK_ACTION_COPY :
- static_cast<GdkDragAction>(0),
+ gdk_drag_status(context_, gtk_dnd_util::WebDragOpToGdkDragAction(operation),
drag_over_time_);
}
}
@@ -97,8 +114,7 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
tab_contents_->render_view_host()->
DragTargetDragOver(gtk_util::ClientPoint(widget_),
gtk_util::ScreenPoint(widget_),
- static_cast<WebDragOperation>(
- WebDragOperationCopy | WebDragOperationMove));
+ GdkDragActionToWebDragOp(context->actions));
if (tab_contents_->GetBookmarkDragDelegate())
tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data_);
drag_over_time_ = time;
@@ -186,10 +202,9 @@ void WebDragDestGtk::OnDragDataReceived(
// TODO(snej): Pass appropriate DragOperation instead of hardcoding.
tab_contents_->render_view_host()->
DragTargetDragEnter(*drop_data_.get(),
- gtk_util::ClientPoint(widget_),
- gtk_util::ScreenPoint(widget_),
- static_cast<WebDragOperation>(
- WebDragOperationCopy | WebDragOperationMove));
+ gtk_util::ClientPoint(widget_),
+ gtk_util::ScreenPoint(widget_),
+ GdkDragActionToWebDragOp(context->actions));
// This is non-null if tab_contents_ is showing an ExtensionDOMUI with
// support for (at the moment experimental) drag and drop extensions.
@@ -232,8 +247,9 @@ gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context,
if (tab_contents_->GetBookmarkDragDelegate())
tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data_);
- // The second parameter is just an educated guess, but at least we will
- // get the drag-end animation right sometimes.
+ // The second parameter is just an educated guess as to whether or not the
+ // drag succeeded, but at least we will get the drag-end animation right
+ // sometimes.
gtk_drag_finish(context, is_drop_target_, FALSE, time);
return TRUE;
}
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index bbeb841..e1d4d02 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -222,9 +222,8 @@ void TabContentsViewGtk::StartDragging(const WebDropData& drop_data,
WebDragOperationsMask ops,
const SkBitmap& image,
const gfx::Point& image_offset) {
- drag_source_->StartDragging(drop_data, &last_mouse_down_,
+ drag_source_->StartDragging(drop_data, ops, &last_mouse_down_,
image, image_offset);
- // TODO(snej): Make use of WebDragOperationsMask
}
void TabContentsViewGtk::SetPageTitle(const std::wstring& title) {