| 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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 selection_model.Copy(original_selection); | 1076 selection_model.Copy(original_selection); |
| 1077 // Delete the existing DragController before creating a new one. We do this as | 1077 // Delete the existing DragController before creating a new one. We do this as |
| 1078 // creating the DragController remembers the WebContents delegates and we need | 1078 // creating the DragController remembers the WebContents delegates and we need |
| 1079 // to make sure the existing DragController isn't still a delegate. | 1079 // to make sure the existing DragController isn't still a delegate. |
| 1080 drag_controller_.reset(); | 1080 drag_controller_.reset(); |
| 1081 TabDragController::MoveBehavior move_behavior = | 1081 TabDragController::MoveBehavior move_behavior = |
| 1082 TabDragController::REORDER; | 1082 TabDragController::REORDER; |
| 1083 // Use MOVE_VISIBILE_TABS in the following conditions: | 1083 // Use MOVE_VISIBILE_TABS in the following conditions: |
| 1084 // . Mouse event generated from touch and the left button is down (the right | 1084 // . Mouse event generated from touch and the left button is down (the right |
| 1085 // button corresponds to a long press, which we want to reorder). | 1085 // button corresponds to a long press, which we want to reorder). |
| 1086 // . Gesture begin and control key isn't down. | 1086 // . Gesture tap down and control key isn't down. |
| 1087 // . Real mouse event and control is down. This is mostly for testing. | 1087 // . Real mouse event and control is down. This is mostly for testing. |
| 1088 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || | 1088 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || |
| 1089 event.type() == ui::ET_GESTURE_BEGIN); | 1089 event.type() == ui::ET_GESTURE_TAP_DOWN); |
| 1090 if (touch_layout_ && | 1090 if (touch_layout_ && |
| 1091 ((event.type() == ui::ET_MOUSE_PRESSED && | 1091 ((event.type() == ui::ET_MOUSE_PRESSED && |
| 1092 (((event.flags() & ui::EF_FROM_TOUCH) && | 1092 (((event.flags() & ui::EF_FROM_TOUCH) && |
| 1093 static_cast<const ui::MouseEvent&>(event).IsLeftMouseButton()) || | 1093 static_cast<const ui::MouseEvent&>(event).IsLeftMouseButton()) || |
| 1094 (!(event.flags() & ui::EF_FROM_TOUCH) && | 1094 (!(event.flags() & ui::EF_FROM_TOUCH) && |
| 1095 static_cast<const ui::MouseEvent&>(event).IsControlDown()))) || | 1095 static_cast<const ui::MouseEvent&>(event).IsControlDown()))) || |
| 1096 (event.type() == ui::ET_GESTURE_BEGIN && !event.IsControlDown()))) { | 1096 (event.type() == ui::ET_GESTURE_TAP_DOWN && !event.IsControlDown()))) { |
| 1097 move_behavior = TabDragController::MOVE_VISIBILE_TABS; | 1097 move_behavior = TabDragController::MOVE_VISIBILE_TABS; |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 drag_controller_.reset(new TabDragController); | 1100 drag_controller_.reset(new TabDragController); |
| 1101 drag_controller_->Init( | 1101 drag_controller_->Init( |
| 1102 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model, | 1102 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model, |
| 1103 move_behavior, EventSourceFromEvent(event)); | 1103 move_behavior, EventSourceFromEvent(event)); |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { | 1106 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { |
| (...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 | 2639 |
| 2640 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { | 2640 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { |
| 2641 SetResetToShrinkOnExit(true); | 2641 SetResetToShrinkOnExit(true); |
| 2642 } | 2642 } |
| 2643 | 2643 |
| 2644 void TabStrip::OnGestureEvent(ui::GestureEvent* event) { | 2644 void TabStrip::OnGestureEvent(ui::GestureEvent* event) { |
| 2645 SetResetToShrinkOnExit(false); | 2645 SetResetToShrinkOnExit(false); |
| 2646 switch (event->type()) { | 2646 switch (event->type()) { |
| 2647 case ui::ET_GESTURE_SCROLL_END: | 2647 case ui::ET_GESTURE_SCROLL_END: |
| 2648 case ui::ET_SCROLL_FLING_START: | 2648 case ui::ET_SCROLL_FLING_START: |
| 2649 case ui::ET_GESTURE_END: | |
| 2650 EndDrag(END_DRAG_COMPLETE); | 2649 EndDrag(END_DRAG_COMPLETE); |
| 2651 if (adjust_layout_) { | 2650 if (adjust_layout_) { |
| 2652 SetStackedLayout(true); | 2651 SetStackedLayout(true); |
| 2653 controller_->StackedLayoutMaybeChanged(); | 2652 controller_->StackedLayoutMaybeChanged(); |
| 2654 } | 2653 } |
| 2655 break; | 2654 break; |
| 2656 | 2655 |
| 2657 case ui::ET_GESTURE_LONG_PRESS: | 2656 case ui::ET_GESTURE_LONG_PRESS: |
| 2658 if (drag_controller_.get()) | 2657 if (drag_controller_.get()) |
| 2659 drag_controller_->SetMoveBehavior(TabDragController::REORDER); | 2658 drag_controller_->SetMoveBehavior(TabDragController::REORDER); |
| 2660 break; | 2659 break; |
| 2661 | 2660 |
| 2662 case ui::ET_GESTURE_LONG_TAP: { | 2661 case ui::ET_GESTURE_LONG_TAP: { |
| 2663 EndDrag(END_DRAG_CANCEL); | 2662 EndDrag(END_DRAG_CANCEL); |
| 2664 gfx::Point local_point = event->location(); | 2663 gfx::Point local_point = event->location(); |
| 2665 Tab* tab = FindTabForEvent(local_point); | 2664 Tab* tab = FindTabForEvent(local_point); |
| 2666 if (tab) { | 2665 if (tab) { |
| 2667 ConvertPointToScreen(this, &local_point); | 2666 ConvertPointToScreen(this, &local_point); |
| 2668 ShowContextMenuForTab(tab, local_point, ui::MENU_SOURCE_TOUCH); | 2667 ShowContextMenuForTab(tab, local_point, ui::MENU_SOURCE_TOUCH); |
| 2669 } | 2668 } |
| 2670 break; | 2669 break; |
| 2671 } | 2670 } |
| 2672 | 2671 |
| 2673 case ui::ET_GESTURE_SCROLL_UPDATE: | 2672 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 2674 ContinueDrag(this, *event); | 2673 ContinueDrag(this, *event); |
| 2675 break; | 2674 break; |
| 2676 | 2675 |
| 2677 case ui::ET_GESTURE_BEGIN: | |
| 2678 EndDrag(END_DRAG_CANCEL); | |
| 2679 break; | |
| 2680 | |
| 2681 case ui::ET_GESTURE_TAP: { | 2676 case ui::ET_GESTURE_TAP: { |
| 2682 const int active_index = controller_->GetActiveIndex(); | 2677 const int active_index = controller_->GetActiveIndex(); |
| 2683 DCHECK_NE(-1, active_index); | 2678 DCHECK_NE(-1, active_index); |
| 2684 Tab* active_tab = tab_at(active_index); | 2679 Tab* active_tab = tab_at(active_index); |
| 2685 TouchUMA::GestureActionType action = TouchUMA::GESTURE_TABNOSWITCH_TAP; | 2680 TouchUMA::GestureActionType action = TouchUMA::GESTURE_TABNOSWITCH_TAP; |
| 2686 if (active_tab->tab_activated_with_last_gesture_begin()) | 2681 if (active_tab->tab_activated_with_last_tap_down()) |
| 2687 action = TouchUMA::GESTURE_TABSWITCH_TAP; | 2682 action = TouchUMA::GESTURE_TABSWITCH_TAP; |
| 2688 TouchUMA::RecordGestureAction(action); | 2683 TouchUMA::RecordGestureAction(action); |
| 2689 break; | 2684 break; |
| 2690 } | 2685 } |
| 2691 | 2686 |
| 2692 default: | 2687 default: |
| 2693 break; | 2688 break; |
| 2694 } | 2689 } |
| 2695 event->SetHandled(); | 2690 event->SetHandled(); |
| 2696 } | 2691 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2718 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2713 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| 2719 if (view) | 2714 if (view) |
| 2720 return view; | 2715 return view; |
| 2721 } | 2716 } |
| 2722 Tab* tab = FindTabForEvent(point); | 2717 Tab* tab = FindTabForEvent(point); |
| 2723 if (tab) | 2718 if (tab) |
| 2724 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2719 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
| 2725 } | 2720 } |
| 2726 return this; | 2721 return this; |
| 2727 } | 2722 } |
| OLD | NEW |