Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 12660016: Make long press & release to trigger context menu on tab (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: EndDrag() on LONG_TAP to be safe Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); 1500 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true);
1501 controller_->LayoutTypeMaybeChanged(); 1501 controller_->LayoutTypeMaybeChanged();
1502 } 1502 }
1503 break; 1503 break;
1504 1504
1505 case ui::ET_GESTURE_LONG_PRESS: 1505 case ui::ET_GESTURE_LONG_PRESS:
1506 if (drag_controller_.get()) 1506 if (drag_controller_.get())
1507 drag_controller_->SetMoveBehavior(TabDragController::REORDER); 1507 drag_controller_->SetMoveBehavior(TabDragController::REORDER);
1508 break; 1508 break;
1509 1509
1510 case ui::ET_GESTURE_LONG_TAP: {
1511 EndDrag(END_DRAG_CANCEL);
1512 gfx::Point local_point = event->location();
1513 Tab* tab = FindTabForEvent(local_point);
1514 if (tab) {
1515 ConvertPointToScreen(this, &local_point);
1516 ShowContextMenuForTab(tab, local_point);
1517 }
1518 break;
1519 }
1520
1510 case ui::ET_GESTURE_SCROLL_UPDATE: 1521 case ui::ET_GESTURE_SCROLL_UPDATE:
1511 ContinueDrag(this, *event); 1522 ContinueDrag(this, *event);
1512 break; 1523 break;
1513 1524
1514 case ui::ET_GESTURE_BEGIN: 1525 case ui::ET_GESTURE_BEGIN:
1515 EndDrag(END_DRAG_CANCEL); 1526 EndDrag(END_DRAG_CANCEL);
1516 break; 1527 break;
1517 1528
1518 default: 1529 default:
1519 break; 1530 break;
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 2497
2487 int TabStrip::GetStartXForNormalTabs() const { 2498 int TabStrip::GetStartXForNormalTabs() const {
2488 int mini_tab_count = GetMiniTabCount(); 2499 int mini_tab_count = GetMiniTabCount();
2489 if (mini_tab_count == 0) 2500 if (mini_tab_count == 0)
2490 return 0; 2501 return 0;
2491 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + 2502 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) +
2492 kMiniToNonMiniGap; 2503 kMiniToNonMiniGap;
2493 } 2504 }
2494 2505
2495 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { 2506 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) {
2496 DCHECK(touch_layout_.get()); 2507 if (touch_layout_.get()) {
2497 int active_tab_index = touch_layout_->active_index(); 2508 int active_tab_index = touch_layout_->active_index();
2498 Tab* tab = NULL; 2509 if (active_tab_index != -1) {
2499 if (active_tab_index != -1) { 2510 Tab* tab = FindTabForEventFrom(point, active_tab_index, -1);
2500 tab = FindTabForEventFrom(point, active_tab_index, -1); 2511 if (!tab)
2501 if (!tab) 2512 tab = FindTabForEventFrom(point, active_tab_index + 1, 1);
2502 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); 2513 return tab;
2503 } else if (tab_count()) { 2514 } else if (tab_count()) {
2504 tab = FindTabForEventFrom(point, 0, 1); 2515 return FindTabForEventFrom(point, 0, 1);
2516 }
2517 } else {
2518 for (int i = 0; i < tab_count(); ++i) {
2519 if (IsPointInTab(tab_at(i), point))
2520 return tab_at(i);
2521 }
2505 } 2522 }
2506 return tab; 2523 return NULL;
2507 } 2524 }
2508 2525
2509 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, 2526 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point,
2510 int start, 2527 int start,
2511 int delta) { 2528 int delta) {
2512 // |start| equals tab_count() when there are only pinned tabs. 2529 // |start| equals tab_count() when there are only pinned tabs.
2513 if (start == tab_count()) 2530 if (start == tab_count())
2514 start += delta; 2531 start += delta;
2515 for (int i = start; i >= 0 && i < tab_count(); i += delta) { 2532 for (int i = start; i >= 0 && i < tab_count(); i += delta) {
2516 if (IsPointInTab(tab_at(i), point)) 2533 if (IsPointInTab(tab_at(i), point))
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 if (!adjust_layout_) 2610 if (!adjust_layout_)
2594 return false; 2611 return false;
2595 2612
2596 #if !defined(OS_CHROMEOS) 2613 #if !defined(OS_CHROMEOS)
2597 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2614 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2598 return false; 2615 return false;
2599 #endif 2616 #endif
2600 2617
2601 return true; 2618 return true;
2602 } 2619 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698