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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 if (move_loop_widget_) { | 397 if (move_loop_widget_) { |
398 move_loop_widget_->RemoveObserver(this); | 398 move_loop_widget_->RemoveObserver(this); |
399 SetTrackedByWorkspace(move_loop_widget_->GetNativeView(), true); | 399 SetTrackedByWorkspace(move_loop_widget_->GetNativeView(), true); |
400 SetWindowPositionManaged(move_loop_widget_->GetNativeView(), true); | 400 SetWindowPositionManaged(move_loop_widget_->GetNativeView(), true); |
401 } | 401 } |
402 | 402 |
403 if (source_tabstrip_ && detach_into_browser_) | 403 if (source_tabstrip_ && detach_into_browser_) |
404 GetModel(source_tabstrip_)->RemoveObserver(this); | 404 GetModel(source_tabstrip_)->RemoveObserver(this); |
405 | 405 |
406 MessageLoopForUI::current()->RemoveObserver(this); | 406 base::MessageLoopForUI::current()->RemoveObserver(this); |
407 | 407 |
408 // Need to delete the view here manually _before_ we reset the dragged | 408 // Need to delete the view here manually _before_ we reset the dragged |
409 // contents to NULL, otherwise if the view is animating to its destination | 409 // contents to NULL, otherwise if the view is animating to its destination |
410 // bounds, it won't be able to clean up properly since its cleanup routine | 410 // bounds, it won't be able to clean up properly since its cleanup routine |
411 // uses GetIndexForDraggedContents, which will be invalid. | 411 // uses GetIndexForDraggedContents, which will be invalid. |
412 view_.reset(NULL); | 412 view_.reset(NULL); |
413 | 413 |
414 // Reset the delegate of the dragged WebContents. This ends up doing nothing | 414 // Reset the delegate of the dragged WebContents. This ends up doing nothing |
415 // if the drag was completed. | 415 // if the drag was completed. |
416 if (!detach_into_browser_) | 416 if (!detach_into_browser_) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (detach_into_browser_) | 449 if (detach_into_browser_) |
450 GetModel(source_tabstrip_)->AddObserver(this); | 450 GetModel(source_tabstrip_)->AddObserver(this); |
451 | 451 |
452 drag_data_.resize(tabs.size()); | 452 drag_data_.resize(tabs.size()); |
453 for (size_t i = 0; i < tabs.size(); ++i) | 453 for (size_t i = 0; i < tabs.size(); ++i) |
454 InitTabDragData(tabs[i], &(drag_data_[i])); | 454 InitTabDragData(tabs[i], &(drag_data_[i])); |
455 source_tab_index_ = | 455 source_tab_index_ = |
456 std::find(tabs.begin(), tabs.end(), source_tab) - tabs.begin(); | 456 std::find(tabs.begin(), tabs.end(), source_tab) - tabs.begin(); |
457 | 457 |
458 // Listen for Esc key presses. | 458 // Listen for Esc key presses. |
459 MessageLoopForUI::current()->AddObserver(this); | 459 base::MessageLoopForUI::current()->AddObserver(this); |
460 | 460 |
461 if (source_tab->width() > 0) { | 461 if (source_tab->width() > 0) { |
462 offset_to_width_ratio_ = static_cast<float>( | 462 offset_to_width_ratio_ = static_cast<float>( |
463 source_tab->GetMirroredXInView(source_tab_offset)) / | 463 source_tab->GetMirroredXInView(source_tab_offset)) / |
464 static_cast<float>(source_tab->width()); | 464 static_cast<float>(source_tab->width()); |
465 } | 465 } |
466 InitWindowCreatePoint(); | 466 InitWindowCreatePoint(); |
467 initial_selection_model_.Copy(initial_selection_model); | 467 initial_selection_model_.Copy(initial_selection_model); |
468 } | 468 } |
469 | 469 |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 gfx::Vector2d TabDragController::GetWindowOffset( | 2065 gfx::Vector2d TabDragController::GetWindowOffset( |
2066 const gfx::Point& point_in_screen) { | 2066 const gfx::Point& point_in_screen) { |
2067 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2067 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
2068 attached_tabstrip_ : source_tabstrip_; | 2068 attached_tabstrip_ : source_tabstrip_; |
2069 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2069 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
2070 | 2070 |
2071 gfx::Point point = point_in_screen; | 2071 gfx::Point point = point_in_screen; |
2072 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2072 views::View::ConvertPointFromScreen(toplevel_view, &point); |
2073 return point.OffsetFromOrigin(); | 2073 return point.OffsetFromOrigin(); |
2074 } | 2074 } |
OLD | NEW |