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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 } | 1043 } |
1044 DCHECK(!tabs.empty()); | 1044 DCHECK(!tabs.empty()); |
1045 DCHECK(std::find(tabs.begin(), tabs.end(), tab) != tabs.end()); | 1045 DCHECK(std::find(tabs.begin(), tabs.end(), tab) != tabs.end()); |
1046 ui::ListSelectionModel selection_model; | 1046 ui::ListSelectionModel selection_model; |
1047 if (!original_selection.IsSelected(model_index)) | 1047 if (!original_selection.IsSelected(model_index)) |
1048 selection_model.Copy(original_selection); | 1048 selection_model.Copy(original_selection); |
1049 // Delete the existing DragController before creating a new one. We do this as | 1049 // Delete the existing DragController before creating a new one. We do this as |
1050 // creating the DragController remembers the WebContents delegates and we need | 1050 // creating the DragController remembers the WebContents delegates and we need |
1051 // to make sure the existing DragController isn't still a delegate. | 1051 // to make sure the existing DragController isn't still a delegate. |
1052 drag_controller_.reset(); | 1052 drag_controller_.reset(); |
1053 TabDragController::DetachBehavior detach_behavior = | |
1054 TabDragController::DETACHABLE; | |
1055 TabDragController::MoveBehavior move_behavior = | 1053 TabDragController::MoveBehavior move_behavior = |
1056 TabDragController::REORDER; | 1054 TabDragController::REORDER; |
1057 // Use MOVE_VISIBILE_TABS in the following conditions: | 1055 // Use MOVE_VISIBILE_TABS in the following conditions: |
1058 // . Mouse event generated from touch and the left button is down (the right | 1056 // . Mouse event generated from touch and the left button is down (the right |
1059 // button corresponds to a long press, which we want to reorder). | 1057 // button corresponds to a long press, which we want to reorder). |
1060 // . Gesture begin and control key isn't down. | 1058 // . Gesture begin and control key isn't down. |
1061 // . Real mouse event and control is down. This is mostly for testing. | 1059 // . Real mouse event and control is down. This is mostly for testing. |
1062 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || | 1060 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || |
1063 event.type() == ui::ET_GESTURE_BEGIN); | 1061 event.type() == ui::ET_GESTURE_BEGIN); |
1064 if (touch_layout_ && | 1062 if (touch_layout_ && |
1065 ((event.type() == ui::ET_MOUSE_PRESSED && | 1063 ((event.type() == ui::ET_MOUSE_PRESSED && |
1066 (((event.flags() & ui::EF_FROM_TOUCH) && | 1064 (((event.flags() & ui::EF_FROM_TOUCH) && |
1067 static_cast<const ui::MouseEvent&>(event).IsLeftMouseButton()) || | 1065 static_cast<const ui::MouseEvent&>(event).IsLeftMouseButton()) || |
1068 (!(event.flags() & ui::EF_FROM_TOUCH) && | 1066 (!(event.flags() & ui::EF_FROM_TOUCH) && |
1069 static_cast<const ui::MouseEvent&>(event).IsControlDown()))) || | 1067 static_cast<const ui::MouseEvent&>(event).IsControlDown()))) || |
1070 (event.type() == ui::ET_GESTURE_BEGIN && !event.IsControlDown()))) { | 1068 (event.type() == ui::ET_GESTURE_BEGIN && !event.IsControlDown()))) { |
1071 move_behavior = TabDragController::MOVE_VISIBILE_TABS; | 1069 move_behavior = TabDragController::MOVE_VISIBILE_TABS; |
1072 } | 1070 } |
1073 | 1071 |
1074 drag_controller_.reset(new TabDragController); | 1072 drag_controller_.reset(new TabDragController); |
1075 drag_controller_->Init( | 1073 drag_controller_->Init( |
1076 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model, | 1074 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model, |
1077 detach_behavior, move_behavior, EventSourceFromEvent(event)); | 1075 move_behavior, EventSourceFromEvent(event)); |
1078 } | 1076 } |
1079 | 1077 |
1080 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { | 1078 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { |
1081 if (drag_controller_.get() && | 1079 if (drag_controller_.get() && |
1082 drag_controller_->event_source() == EventSourceFromEvent(event)) { | 1080 drag_controller_->event_source() == EventSourceFromEvent(event)) { |
1083 gfx::Point screen_location(event.location()); | 1081 gfx::Point screen_location(event.location()); |
1084 views::View::ConvertPointToScreen(view, &screen_location); | 1082 views::View::ConvertPointToScreen(view, &screen_location); |
1085 drag_controller_->Drag(screen_location); | 1083 drag_controller_->Drag(screen_location); |
1086 } | 1084 } |
1087 } | 1085 } |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 action = TouchUMA::GESTURE_TABSWITCH_TAP; | 2685 action = TouchUMA::GESTURE_TABSWITCH_TAP; |
2688 TouchUMA::RecordGestureAction(action); | 2686 TouchUMA::RecordGestureAction(action); |
2689 break; | 2687 break; |
2690 } | 2688 } |
2691 | 2689 |
2692 default: | 2690 default: |
2693 break; | 2691 break; |
2694 } | 2692 } |
2695 event->SetHandled(); | 2693 event->SetHandled(); |
2696 } | 2694 } |
OLD | NEW |