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

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: showing context menu after long press & finger lift (long tap) 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 gfx::Point local_point = event->location();
1512 Tab* tab = FindTabForEvent(local_point);
1513 if (tab) {
1514 ConvertPointToScreen(this, &local_point);
1515 ShowContextMenuForTab(tab, local_point);
1516 }
1517 }
sadrul 2013/03/20 02:15:52 Missing a break; here
Yufeng Shen (Slow to review) 2013/03/20 02:22:47 Done.
1518
1510 case ui::ET_GESTURE_SCROLL_UPDATE: 1519 case ui::ET_GESTURE_SCROLL_UPDATE:
1511 ContinueDrag(this, *event); 1520 ContinueDrag(this, *event);
1512 break; 1521 break;
1513 1522
1514 case ui::ET_GESTURE_BEGIN: 1523 case ui::ET_GESTURE_BEGIN:
1515 EndDrag(END_DRAG_CANCEL); 1524 EndDrag(END_DRAG_CANCEL);
1516 break; 1525 break;
1517 1526
1518 default: 1527 default:
1519 break; 1528 break;
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 2495
2487 int TabStrip::GetStartXForNormalTabs() const { 2496 int TabStrip::GetStartXForNormalTabs() const {
2488 int mini_tab_count = GetMiniTabCount(); 2497 int mini_tab_count = GetMiniTabCount();
2489 if (mini_tab_count == 0) 2498 if (mini_tab_count == 0)
2490 return 0; 2499 return 0;
2491 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + 2500 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) +
2492 kMiniToNonMiniGap; 2501 kMiniToNonMiniGap;
2493 } 2502 }
2494 2503
2495 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { 2504 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) {
2496 DCHECK(touch_layout_.get());
2497 int active_tab_index = touch_layout_->active_index();
2498 Tab* tab = NULL; 2505 Tab* tab = NULL;
2499 if (active_tab_index != -1) { 2506 if (touch_layout_.get()) {
2500 tab = FindTabForEventFrom(point, active_tab_index, -1); 2507 int active_tab_index = touch_layout_->active_index();
2501 if (!tab) 2508 if (active_tab_index != -1) {
2502 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); 2509 tab = FindTabForEventFrom(point, active_tab_index, -1);
2503 } else if (tab_count()) { 2510 if (!tab)
2504 tab = FindTabForEventFrom(point, 0, 1); 2511 tab = FindTabForEventFrom(point, active_tab_index + 1, 1);
2512 } else if (tab_count()) {
2513 tab = FindTabForEventFrom(point, 0, 1);
2514 }
2515 } else {
2516 for (int i = 0; i < tab_count(); ++i) {
2517 if (IsPointInTab(tab_at(i), point)) {
2518 tab = tab_at(i);
2519 break;
2520 }
2521 }
2505 } 2522 }
2506 return tab; 2523 return tab;
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;
(...skipping 78 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