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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 if (!original_selection.IsSelected(model_index)) | 995 if (!original_selection.IsSelected(model_index)) |
996 selection_model.Copy(original_selection); | 996 selection_model.Copy(original_selection); |
997 // Delete the existing DragController before creating a new one. We do this as | 997 // Delete the existing DragController before creating a new one. We do this as |
998 // creating the DragController remembers the WebContents delegates and we need | 998 // creating the DragController remembers the WebContents delegates and we need |
999 // to make sure the existing DragController isn't still a delegate. | 999 // to make sure the existing DragController isn't still a delegate. |
1000 drag_controller_.reset(); | 1000 drag_controller_.reset(); |
1001 TabDragController::DetachBehavior detach_behavior = | 1001 TabDragController::DetachBehavior detach_behavior = |
1002 TabDragController::DETACHABLE; | 1002 TabDragController::DETACHABLE; |
1003 TabDragController::MoveBehavior move_behavior = | 1003 TabDragController::MoveBehavior move_behavior = |
1004 TabDragController::REORDER; | 1004 TabDragController::REORDER; |
1005 // Use MOVE_VISIBILE_TABS in the following two conditions: | 1005 // Use MOVE_VISIBILE_TABS in the following conditions: |
1006 // . Mouse event generated from touch and the left button is down (the right | 1006 // . Mouse event generated from touch and the left button is down (the right |
1007 // button corresponds to a long press, which we want to reorder). | 1007 // button corresponds to a long press, which we want to reorder). |
| 1008 // . Gesture begin and control key isn't down. |
1008 // . Real mouse event and control is down. This is mostly for testing. | 1009 // . Real mouse event and control is down. This is mostly for testing. |
1009 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || | 1010 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || |
1010 event.type() == ui::ET_GESTURE_BEGIN); | 1011 event.type() == ui::ET_GESTURE_BEGIN); |
1011 if (touch_layout_.get() && | 1012 if (adjust_layout_ && |
1012 ((event.type() == ui::ET_MOUSE_PRESSED && | 1013 ((event.type() == ui::ET_MOUSE_PRESSED && |
1013 (((event.flags() & ui::EF_FROM_TOUCH) && | 1014 (((event.flags() & ui::EF_FROM_TOUCH) && |
1014 static_cast<const views::MouseEvent&>(event).IsLeftMouseButton()) || | 1015 static_cast<const views::MouseEvent&>(event).IsLeftMouseButton()) || |
1015 (!(event.flags() & ui::EF_FROM_TOUCH) && | 1016 (!(event.flags() & ui::EF_FROM_TOUCH) && |
1016 static_cast<const views::MouseEvent&>(event).IsControlDown()))) || | 1017 static_cast<const views::MouseEvent&>(event).IsControlDown()))) || |
1017 (event.type() == ui::ET_GESTURE_BEGIN))) { | 1018 (event.type() == ui::ET_GESTURE_BEGIN && !event.IsControlDown()))) { |
1018 move_behavior = TabDragController::MOVE_VISIBILE_TABS; | 1019 move_behavior = TabDragController::MOVE_VISIBILE_TABS; |
1019 } | 1020 } |
1020 #if defined(OS_WIN) | 1021 #if defined(OS_WIN) |
1021 // It doesn't make sense to drag tabs out on metro. | 1022 // It doesn't make sense to drag tabs out on metro. |
1022 if (base::win::IsMetroProcess()) | 1023 if (base::win::IsMetroProcess()) |
1023 detach_behavior = TabDragController::NOT_DETACHABLE; | 1024 detach_behavior = TabDragController::NOT_DETACHABLE; |
1024 #endif | 1025 #endif |
1025 // Gestures don't automatically do a capture. We don't allow multiple drags at | 1026 // Gestures don't automatically do a capture. We don't allow multiple drags at |
1026 // the same time, so we explicitly capture. | 1027 // the same time, so we explicitly capture. |
1027 if (event.type() == ui::ET_GESTURE_BEGIN) | 1028 if (event.type() == ui::ET_GESTURE_BEGIN) |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2348 | 2349 |
2349 int mini_tab_count = GetMiniTabCount(); | 2350 int mini_tab_count = GetMiniTabCount(); |
2350 int normal_count = tab_count() - mini_tab_count; | 2351 int normal_count = tab_count() - mini_tab_count; |
2351 if (normal_count <= 1 || normal_count == mini_tab_count) | 2352 if (normal_count <= 1 || normal_count == mini_tab_count) |
2352 return false; | 2353 return false; |
2353 int x = GetStartXForNormalTabs(); | 2354 int x = GetStartXForNormalTabs(); |
2354 int available_width = width() - x - new_tab_button_width(); | 2355 int available_width = width() - x - new_tab_button_width(); |
2355 return (Tab::GetTouchWidth() * normal_count + | 2356 return (Tab::GetTouchWidth() * normal_count + |
2356 tab_h_offset() * (normal_count - 1)) > available_width; | 2357 tab_h_offset() * (normal_count - 1)) > available_width; |
2357 } | 2358 } |
OLD | NEW |