OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/tabs/tab_strip_selection_model.h" | 8 #include "chrome/browser/tabs/tab_strip_selection_model.h" |
9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
10 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 10 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 size_to_selected = GetSizeNeededForTabs(tabs); | 336 size_to_selected = GetSizeNeededForTabs(tabs); |
337 x = size_to_selected - tab->width() + x; | 337 x = size_to_selected - tab->width() + x; |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 DCHECK(!tabs.empty()); | 341 DCHECK(!tabs.empty()); |
342 DCHECK(std::find(tabs.begin(), tabs.end(), tab) != tabs.end()); | 342 DCHECK(std::find(tabs.begin(), tabs.end(), tab) != tabs.end()); |
343 TabStripSelectionModel selection_model; | 343 TabStripSelectionModel selection_model; |
344 if (!original_selection.IsSelected(model_index)) | 344 if (!original_selection.IsSelected(model_index)) |
345 selection_model.Copy(original_selection); | 345 selection_model.Copy(original_selection); |
| 346 // Delete the existing DragController before creating a new one. We do this as |
| 347 // creating the DragController remembers the TabContents delegates and we need |
| 348 // to make sure the existing DragController isn't still a delegate. |
| 349 drag_controller_.reset(); |
346 drag_controller_.reset(TabDragController::Create( | 350 drag_controller_.reset(TabDragController::Create( |
347 this, tab, tabs, gfx::Point(x, y), tab->GetMirroredXInView(event.x()), | 351 this, tab, tabs, gfx::Point(x, y), tab->GetMirroredXInView(event.x()), |
348 selection_model)); | 352 selection_model)); |
349 } | 353 } |
350 | 354 |
351 void BaseTabStrip::ContinueDrag(const views::MouseEvent& event) { | 355 void BaseTabStrip::ContinueDrag(const views::MouseEvent& event) { |
352 // We can get called even if |MaybeStartDrag| wasn't called in the event of | 356 // We can get called even if |MaybeStartDrag| wasn't called in the event of |
353 // a TabStrip animation when the mouse button is down. In this case we should | 357 // a TabStrip animation when the mouse button is down. In this case we should |
354 // _not_ continue the drag because it can lead to weird bugs. | 358 // _not_ continue the drag because it can lead to weird bugs. |
355 if (drag_controller_.get()) { | 359 if (drag_controller_.get()) { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 // Animate the view back to its correct position. | 586 // Animate the view back to its correct position. |
583 GenerateIdealBounds(); | 587 GenerateIdealBounds(); |
584 AnimateToIdealBounds(); | 588 AnimateToIdealBounds(); |
585 } | 589 } |
586 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab))); | 590 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab))); |
587 // Install a delegate to reset the dragging state when done. We have to leave | 591 // Install a delegate to reset the dragging state when done. We have to leave |
588 // dragging true for the tab otherwise it'll draw beneath the new tab button. | 592 // dragging true for the tab otherwise it'll draw beneath the new tab button. |
589 bounds_animator_.SetAnimationDelegate( | 593 bounds_animator_.SetAnimationDelegate( |
590 tab, new ResetDraggingStateDelegate(tab), true); | 594 tab, new ResetDraggingStateDelegate(tab), true); |
591 } | 595 } |
OLD | NEW |