Chromium Code Reviews

Unified 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.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_strip.cc
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 7660eed2f5b61697c39d721a64f58e3bf499c1b9..567a11810279733eb016601d0d194e088ac8cca0 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -1507,6 +1507,15 @@ void TabStrip::OnGestureEvent(ui::GestureEvent* event) {
drag_controller_->SetMoveBehavior(TabDragController::REORDER);
break;
+ case ui::ET_GESTURE_LONG_TAP: {
+ gfx::Point local_point = event->location();
+ Tab* tab = FindTabForEvent(local_point);
+ if (tab) {
+ ConvertPointToScreen(this, &local_point);
+ ShowContextMenuForTab(tab, local_point);
+ }
+ }
sadrul 2013/03/20 02:15:52 Missing a break; here
Yufeng Shen (Slow to review) 2013/03/20 02:22:47 Done.
+
case ui::ET_GESTURE_SCROLL_UPDATE:
ContinueDrag(this, *event);
break;
@@ -2493,15 +2502,23 @@ int TabStrip::GetStartXForNormalTabs() const {
}
Tab* TabStrip::FindTabForEvent(const gfx::Point& point) {
- DCHECK(touch_layout_.get());
- int active_tab_index = touch_layout_->active_index();
Tab* tab = NULL;
- if (active_tab_index != -1) {
- tab = FindTabForEventFrom(point, active_tab_index, -1);
- if (!tab)
- tab = FindTabForEventFrom(point, active_tab_index + 1, 1);
- } else if (tab_count()) {
- tab = FindTabForEventFrom(point, 0, 1);
+ if (touch_layout_.get()) {
+ int active_tab_index = touch_layout_->active_index();
+ if (active_tab_index != -1) {
+ tab = FindTabForEventFrom(point, active_tab_index, -1);
+ if (!tab)
+ tab = FindTabForEventFrom(point, active_tab_index + 1, 1);
+ } else if (tab_count()) {
+ tab = FindTabForEventFrom(point, 0, 1);
+ }
+ } else {
+ for (int i = 0; i < tab_count(); ++i) {
+ if (IsPointInTab(tab_at(i), point)) {
+ tab = tab_at(i);
+ break;
+ }
+ }
}
return tab;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine