OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 waiting_for_run_loop_to_exit_ = false; | 1536 waiting_for_run_loop_to_exit_ = false; |
1537 if (end_run_loop_behavior_ == END_RUN_LOOP_CONTINUE_DRAGGING) { | 1537 if (end_run_loop_behavior_ == END_RUN_LOOP_CONTINUE_DRAGGING) { |
1538 end_run_loop_behavior_ = END_RUN_LOOP_STOP_DRAGGING; | 1538 end_run_loop_behavior_ = END_RUN_LOOP_STOP_DRAGGING; |
1539 if (tab_strip_to_attach_to_after_exit_) { | 1539 if (tab_strip_to_attach_to_after_exit_) { |
1540 gfx::Point point_in_screen(GetCursorScreenPoint()); | 1540 gfx::Point point_in_screen(GetCursorScreenPoint()); |
1541 Detach(DONT_RELEASE_CAPTURE); | 1541 Detach(DONT_RELEASE_CAPTURE); |
1542 Attach(tab_strip_to_attach_to_after_exit_, point_in_screen); | 1542 Attach(tab_strip_to_attach_to_after_exit_, point_in_screen); |
1543 // Move the tabs into position. | 1543 // Move the tabs into position. |
1544 MoveAttached(point_in_screen); | 1544 MoveAttached(point_in_screen); |
1545 attached_tabstrip_->GetWidget()->Activate(); | 1545 attached_tabstrip_->GetWidget()->Activate(); |
| 1546 // Activate may trigger a focus loss, destroying us. |
| 1547 if (!ref) |
| 1548 return; |
1546 tab_strip_to_attach_to_after_exit_ = NULL; | 1549 tab_strip_to_attach_to_after_exit_ = NULL; |
1547 } | 1550 } |
1548 DCHECK(attached_tabstrip_); | 1551 DCHECK(attached_tabstrip_); |
1549 attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); | 1552 attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); |
1550 } else if (active_) { | 1553 } else if (active_) { |
1551 EndDrag(result == views::Widget::MOVE_LOOP_CANCELED ? | 1554 EndDrag(result == views::Widget::MOVE_LOOP_CANCELED ? |
1552 END_DRAG_CANCEL : END_DRAG_COMPLETE); | 1555 END_DRAG_CANCEL : END_DRAG_COMPLETE); |
1553 } | 1556 } |
1554 } | 1557 } |
1555 | 1558 |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 gfx::Vector2d TabDragController::GetWindowOffset( | 2298 gfx::Vector2d TabDragController::GetWindowOffset( |
2296 const gfx::Point& point_in_screen) { | 2299 const gfx::Point& point_in_screen) { |
2297 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2300 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
2298 attached_tabstrip_ : source_tabstrip_; | 2301 attached_tabstrip_ : source_tabstrip_; |
2299 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2302 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
2300 | 2303 |
2301 gfx::Point point = point_in_screen; | 2304 gfx::Point point = point_in_screen; |
2302 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2305 views::View::ConvertPointFromScreen(toplevel_view, &point); |
2303 return point.OffsetFromOrigin(); | 2306 return point.OffsetFromOrigin(); |
2304 } | 2307 } |
OLD | NEW |