summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 22:00:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 22:00:42 +0000
commit937105b42b6f50d9a29aa7180b939324da80911e (patch)
tree21f635f71b537cc376ce3f8c9de03f72e2303055 /chrome/browser/views/tabs
parent7715d63a3b9da9c149cdd0f544dbdf4cb13a8ed7 (diff)
downloadchromium_src-937105b42b6f50d9a29aa7180b939324da80911e.zip
chromium_src-937105b42b6f50d9a29aa7180b939324da80911e.tar.gz
chromium_src-937105b42b6f50d9a29aa7180b939324da80911e.tar.bz2
Fixes bug in dragging tabs around that could occassionally result in
the tab jumping around. The bug occurred if you dragged a tab from one tabstrip to another, and was the result of the target tab strip not knowing a drag is underway. BUG=47930 TEST=see bug Review URL: http://codereview.chromium.org/2858038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r--chrome/browser/views/tabs/base_tab_strip.cc2
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc18
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.h9
3 files changed, 27 insertions, 2 deletions
diff --git a/chrome/browser/views/tabs/base_tab_strip.cc b/chrome/browser/views/tabs/base_tab_strip.cc
index 6457d5c..316f038 100644
--- a/chrome/browser/views/tabs/base_tab_strip.cc
+++ b/chrome/browser/views/tabs/base_tab_strip.cc
@@ -430,7 +430,7 @@ void BaseTabStrip::StoppedDraggingTab(BaseTab* tab) {
}
void BaseTabStrip::PrepareForAnimation() {
- if (!IsDragSessionActive()) {
+ if (!IsDragSessionActive() && !DraggedTabController::IsAttachedTo(this)) {
for (int i = 0; i < tab_count(); ++i)
base_tab_at_tab_index(i)->set_dragging(false);
}
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 7f7f7a5..18297dd 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -53,6 +53,9 @@ static const int kHorizontalMoveThreshold = 16; // Pixels.
// an attached vertical tab.
static const int kVerticalMoveThreshold = 8;
+// If non-null there is a drag underway.
+static DraggedTabController* instance_;
+
namespace {
// Delay, in ms, during dragging before we bring a window to front.
@@ -341,7 +344,9 @@ DraggedTabController::DraggedTabController(BaseTab* source_tab,
last_move_screen_loc_(0),
mini_(source_tab->data().mini),
pinned_(source_tabstrip->IsTabPinned(source_tab)),
- started_drag_(false) {
+ started_drag_(false),
+ active_(true) {
+ instance_ = this;
SetDraggedContents(
GetModel(source_tabstrip_)->GetTabContentsAt(source_model_index_));
// Listen for Esc key presses.
@@ -349,6 +354,9 @@ DraggedTabController::DraggedTabController(BaseTab* source_tab,
}
DraggedTabController::~DraggedTabController() {
+ if (instance_ == this)
+ instance_ = NULL;
+
in_destructor_ = true;
MessageLoopForUI::current()->RemoveObserver(this);
// Need to delete the view here manually _before_ we reset the dragged
@@ -359,6 +367,12 @@ DraggedTabController::~DraggedTabController() {
SetDraggedContents(NULL); // This removes our observer.
}
+// static
+bool DraggedTabController::IsAttachedTo(BaseTabStrip* tab_strip) {
+ return instance_ && instance_->active_ &&
+ instance_->attached_tabstrip_ == tab_strip;
+}
+
void DraggedTabController::CaptureDragInfo(views::View* tab,
const gfx::Point& mouse_offset) {
if (tab->width() > 0) {
@@ -1045,6 +1059,8 @@ void DraggedTabController::EndDragImpl(EndDragType type) {
// the animation finishes, this is invoked twice. The second time through
// type == TAB_DESTROYED.
+ active_ = false;
+
bring_to_front_timer_.Stop();
// Hide the current dock controllers.
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.h b/chrome/browser/views/tabs/dragged_tab_controller.h
index 280c3af..a860a18 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.h
+++ b/chrome/browser/views/tabs/dragged_tab_controller.h
@@ -42,6 +42,12 @@ class DraggedTabController : public TabContentsDelegate,
BaseTabStrip* source_tabstrip);
virtual ~DraggedTabController();
+ // Returns true if there is a drag underway and the drag is attached to
+ // |tab_strip|.
+ // NOTE: this returns false if the dragged tab controller is in the process
+ // of finishing the drag.
+ static bool IsAttachedTo(BaseTabStrip* tab_strip);
+
// Capture information needed to be used during a drag session for this
// controller's associated source tab and BaseTabStrip. |mouse_offset| is the
// distance of the mouse pointer from the tab's origin.
@@ -323,6 +329,9 @@ class DraggedTabController : public TabContentsDelegate,
// Did the mouse move enough that we started a drag?
bool started_drag_;
+ // Is the drag active?
+ bool active_;
+
DISALLOW_COPY_AND_ASSIGN(DraggedTabController);
};