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/dragged_tab_controller.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 tabs_to_source.erase(tabs_to_source.begin() + source_tab_index_ + 1, | 919 tabs_to_source.erase(tabs_to_source.begin() + source_tab_index_ + 1, |
920 tabs_to_source.end()); | 920 tabs_to_source.end()); |
921 int new_x = attached_tabstrip_->GetSizeNeededForTabs(tabs_to_source) - | 921 int new_x = attached_tabstrip_->GetSizeNeededForTabs(tabs_to_source) - |
922 tabs[source_tab_index_]->width() + | 922 tabs[source_tab_index_]->width() + |
923 static_cast<int>(offset_to_width_ratio_ * | 923 static_cast<int>(offset_to_width_ratio_ * |
924 tabs[source_tab_index_]->width()); | 924 tabs[source_tab_index_]->width()); |
925 mouse_offset_.set_x(new_x); | 925 mouse_offset_.set_x(new_x); |
926 } | 926 } |
927 | 927 |
928 // Move the corresponding window to the front. | 928 // Move the corresponding window to the front. |
929 attached_tabstrip_->GetWindow()->Activate(); | 929 attached_tabstrip_->GetWidget()->Activate(); |
930 } | 930 } |
931 | 931 |
932 void DraggedTabController::Detach() { | 932 void DraggedTabController::Detach() { |
933 // Prevent the TabContents' HWND from being hidden by any of the model | 933 // Prevent the TabContents' HWND from being hidden by any of the model |
934 // operations performed during the drag. | 934 // operations performed during the drag. |
935 source_dragged_contents()->tab_contents()->set_capturing_contents(true); | 935 source_dragged_contents()->tab_contents()->set_capturing_contents(true); |
936 | 936 |
937 // Calculate the drag bounds. | 937 // Calculate the drag bounds. |
938 std::vector<gfx::Rect> drag_bounds; | 938 std::vector<gfx::Rect> drag_bounds; |
939 std::vector<BaseTab*> attached_tabs; | 939 std::vector<BaseTab*> attached_tabs; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 UserMetrics::RecordAction( | 1268 UserMetrics::RecordAction( |
1269 UserMetricsAction("DockingWindow_BottomHalf")); | 1269 UserMetricsAction("DockingWindow_BottomHalf")); |
1270 break; | 1270 break; |
1271 | 1271 |
1272 default: | 1272 default: |
1273 NOTREACHED(); | 1273 NOTREACHED(); |
1274 break; | 1274 break; |
1275 } | 1275 } |
1276 } | 1276 } |
1277 // Compel the model to construct a new window for the detached TabContents. | 1277 // Compel the model to construct a new window for the detached TabContents. |
1278 views::Window* window = source_tabstrip_->GetWindow(); | 1278 views::Widget* widget = source_tabstrip_->GetWidget(); |
1279 gfx::Rect window_bounds(window->GetNormalBounds()); | 1279 gfx::Rect window_bounds(widget->GetRestoredBounds()); |
1280 window_bounds.set_origin(GetWindowCreatePoint()); | 1280 window_bounds.set_origin(GetWindowCreatePoint()); |
1281 // When modifying the following if statement, please make sure not to | 1281 // When modifying the following if statement, please make sure not to |
1282 // introduce issue listed in http://crbug.com/6223 comment #11. | 1282 // introduce issue listed in http://crbug.com/6223 comment #11. |
1283 bool rtl_ui = base::i18n::IsRTL(); | 1283 bool rtl_ui = base::i18n::IsRTL(); |
1284 bool has_dock_position = (dock_info_.type() != DockInfo::NONE); | 1284 bool has_dock_position = (dock_info_.type() != DockInfo::NONE); |
1285 if (rtl_ui && has_dock_position) { | 1285 if (rtl_ui && has_dock_position) { |
1286 // Mirror X axis so the docked tab is aligned using the mouse click as | 1286 // Mirror X axis so the docked tab is aligned using the mouse click as |
1287 // the top-right corner. | 1287 // the top-right corner. |
1288 window_bounds.set_x(window_bounds.x() - window_bounds.width()); | 1288 window_bounds.set_x(window_bounds.x() - window_bounds.width()); |
1289 } | 1289 } |
1290 Browser* new_browser = | 1290 Browser* new_browser = |
1291 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents( | 1291 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents( |
1292 drag_data_[0].contents, window_bounds, dock_info_, | 1292 drag_data_[0].contents, window_bounds, dock_info_, |
1293 window->IsMaximized()); | 1293 widget->IsMaximized()); |
1294 TabStripModel* new_model = new_browser->tabstrip_model(); | 1294 TabStripModel* new_model = new_browser->tabstrip_model(); |
1295 new_model->SetTabPinned( | 1295 new_model->SetTabPinned( |
1296 new_model->GetIndexOfTabContents(drag_data_[0].contents), | 1296 new_model->GetIndexOfTabContents(drag_data_[0].contents), |
1297 drag_data_[0].pinned); | 1297 drag_data_[0].pinned); |
1298 for (size_t i = 1; i < drag_data_.size(); ++i) { | 1298 for (size_t i = 1; i < drag_data_.size(); ++i) { |
1299 new_model->InsertTabContentsAt( | 1299 new_model->InsertTabContentsAt( |
1300 static_cast<int>(i), | 1300 static_cast<int>(i), |
1301 drag_data_[i].contents, | 1301 drag_data_[i].contents, |
1302 drag_data_[i].pinned ? TabStripModel::ADD_PINNED : | 1302 drag_data_[i].pinned ? TabStripModel::ADD_PINNED : |
1303 TabStripModel::ADD_NONE); | 1303 TabStripModel::ADD_NONE); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 | 1441 |
1442 bool DraggedTabController::AreTabsConsecutive() { | 1442 bool DraggedTabController::AreTabsConsecutive() { |
1443 for (size_t i = 1; i < drag_data_.size(); ++i) { | 1443 for (size_t i = 1; i < drag_data_.size(); ++i) { |
1444 if (drag_data_[i - 1].source_model_index + 1 != | 1444 if (drag_data_[i - 1].source_model_index + 1 != |
1445 drag_data_[i].source_model_index) { | 1445 drag_data_[i].source_model_index) { |
1446 return false; | 1446 return false; |
1447 } | 1447 } |
1448 } | 1448 } |
1449 return true; | 1449 return true; |
1450 } | 1450 } |
OLD | NEW |