diff options
-rw-r--r-- | ash/drag_drop/drag_drop_controller.cc | 8 | ||||
-rw-r--r-- | ash/drag_drop/drag_drop_controller.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc | 5 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_view_aura.cc | 5 | ||||
-rw-r--r-- | ui/base/dragdrop/drag_utils_aura.cc | 3 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_aura.h | 10 |
6 files changed, 21 insertions, 11 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index 00949c7..8bc0b67 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -27,7 +27,6 @@ namespace internal { using aura::RootWindow; namespace { -const gfx::Point kDragDropWidgetOffset(0, 0); const base::TimeDelta kDragDropAnimationDuration = base::TimeDelta::FromMilliseconds(250); } // namespace @@ -69,13 +68,14 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data, drag_image_.reset(new DragImageView); drag_image_->SetImage(provider.drag_image()); + drag_image_offset_ = provider.drag_image_offset(); drag_image_->SetScreenBounds(gfx::Rect( - root_location.Add(kDragDropWidgetOffset), + root_location.Subtract(drag_image_offset_), drag_image_->GetPreferredSize())); drag_image_->SetWidgetVisible(true); drag_window_ = NULL; - drag_start_location_ = root_location; + drag_start_location_ = root_location.Subtract(drag_image_offset_); #if !defined(OS_MACOSX) if (should_block_during_drag_drop_) { @@ -122,7 +122,7 @@ void DragDropController::DragUpdate(aura::Window* target, DCHECK(drag_image_.get()); if (drag_image_->visible()) { drag_image_->SetScreenPosition( - event.root_location().Add(kDragDropWidgetOffset)); + event.root_location().Subtract(drag_image_offset_)); } } diff --git a/ash/drag_drop/drag_drop_controller.h b/ash/drag_drop/drag_drop_controller.h index 0a7f075..1bb2503 100644 --- a/ash/drag_drop/drag_drop_controller.h +++ b/ash/drag_drop/drag_drop_controller.h @@ -85,6 +85,7 @@ public: void Cleanup(); scoped_ptr<DragImageView> drag_image_; + gfx::Point drag_image_offset_; const ui::OSExchangeData* drag_data_; int drag_operation_; diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc index eeb3ae2..f43e24e 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc @@ -256,8 +256,10 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura; PrepareDragData(drop_data, provider); - if (!image.isNull()) + if (!image.isNull()) { provider->set_drag_image(image); + provider->set_drag_image_offset(image_offset); + } ui::OSExchangeData data(provider); // takes ownership of |provider|. scoped_ptr<WebDragSourceAura> drag_source(new WebDragSourceAura(this)); @@ -274,7 +276,6 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, // initiate the drag). The location information should be carried over from // webkit. http://crbug.com/114754 gfx::Point location(root_window->last_mouse_location()); - location.Offset(-image_offset.x(), -image_offset.y()); MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( data, location, ConvertFromWeb(ops)); diff --git a/content/browser/tab_contents/tab_contents_view_aura.cc b/content/browser/tab_contents/tab_contents_view_aura.cc index 5b333d0..23d0e37 100644 --- a/content/browser/tab_contents/tab_contents_view_aura.cc +++ b/content/browser/tab_contents/tab_contents_view_aura.cc @@ -424,8 +424,10 @@ void TabContentsViewAura::StartDragging( ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura; PrepareDragData(drop_data, provider); - if (!image.isNull()) + if (!image.isNull()) { provider->set_drag_image(image); + provider->set_drag_image_offset(image_offset); + } ui::OSExchangeData data(provider); // takes ownership of |provider|. scoped_ptr<WebDragSourceAura> drag_source( @@ -440,7 +442,6 @@ void TabContentsViewAura::StartDragging( // initiate the drag). The location information should be carried over from // webkit. http://crbug.com/114754 gfx::Point location(root_window->last_mouse_location()); - location.Offset(-image_offset.x(), -image_offset.y()); MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( data, location, ConvertFromWeb(operations)); diff --git a/ui/base/dragdrop/drag_utils_aura.cc b/ui/base/dragdrop/drag_utils_aura.cc index 41a9636..54a78c6 100644 --- a/ui/base/dragdrop/drag_utils_aura.cc +++ b/ui/base/dragdrop/drag_utils_aura.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,7 @@ void SetDragImageOnDataObject(const SkBitmap& bitmap, ui::OSExchangeDataProviderAura& provider( static_cast<ui::OSExchangeDataProviderAura&>(data_object->provider())); provider.set_drag_image(bitmap); + provider.set_drag_image_offset(cursor_offset); } } // namespace drag_utils diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.h b/ui/base/dragdrop/os_exchange_data_provider_aura.h index 840e625..ad5c312 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_aura.h +++ b/ui/base/dragdrop/os_exchange_data_provider_aura.h @@ -8,11 +8,12 @@ #include <map> -#include "ui/base/dragdrop/os_exchange_data.h" -#include "googleurl/src/gurl.h" #include "base/pickle.h" #include "base/file_path.h" +#include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/dragdrop/os_exchange_data.h" +#include "ui/gfx/point.h" namespace ui { @@ -58,6 +59,10 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider { void set_drag_image(const SkBitmap& drag_image) { drag_image_ = drag_image; } const SkBitmap& drag_image() const { return drag_image_; } + void set_drag_image_offset(const gfx::Point& drag_image_offset) { + drag_image_offset_ = drag_image_offset; + } + const gfx::Point& drag_image_offset() const { return drag_image_offset_; } private: typedef std::map<OSExchangeData::CustomFormat, Pickle> PickleData; @@ -85,6 +90,7 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider { // Drag image and offset data. SkBitmap drag_image_; + gfx::Point drag_image_offset_; // For HTML format string16 html_; |