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

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 11821036: Fixes couple of bugs in the TabStrip that could cause tabs to dance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_drag_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab.cc
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 376fef40a47a2f18a102db6cec2d96841c21cc7f..04bb8c05398547918206799aa3ad7e630b4de95e 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -867,6 +867,11 @@ bool Tab::OnMousePressed(const ui::MouseEvent& event) {
(event.IsOnlyRightMouseButton() && event.flags() & ui::EF_FROM_TOUCH)) {
ui::ListSelectionModel original_selection;
original_selection.Copy(controller()->GetSelectionModel());
+ // Changing the selection may cause our bounds to change. If that happens
+ // the location of the event may no longer be valid. Create a copy of the
+ // event in the parents coordinate, which won't change, and recreate an
+ // event after changing so the coordinates are correct.
+ ui::MouseEvent event_in_parent(event, static_cast<View*>(this), parent());
if (controller()->SupportsMultipleSelection()) {
if (event.IsShiftDown() && event.IsControlDown()) {
controller()->AddSelectionFromAnchorTo(this);
@@ -884,7 +889,9 @@ bool Tab::OnMousePressed(const ui::MouseEvent& event) {
} else if (!IsSelected()) {
controller()->SelectTab(this);
}
- controller()->MaybeStartDrag(this, event, original_selection);
+ ui::MouseEvent cloned_event(event_in_parent, parent(),
+ static_cast<View*>(this));
+ controller()->MaybeStartDrag(this, cloned_event, original_selection);
}
return true;
}
@@ -963,13 +970,18 @@ void Tab::OnGestureEvent(ui::GestureEvent* event) {
if (event->details().touch_points() != 1)
return;
+ // See comment in OnMousePressed() as to why we copy the event.
+ ui::GestureEvent event_in_parent(*event, static_cast<View*>(this),
+ parent());
ui::ListSelectionModel original_selection;
original_selection.Copy(controller()->GetSelectionModel());
if (!IsSelected())
controller()->SelectTab(this);
gfx::Point loc(event->location());
views::View::ConvertPointToScreen(this, &loc);
- controller()->MaybeStartDrag(this, *event, original_selection);
+ ui::GestureEvent cloned_event(event_in_parent, parent(),
+ static_cast<View*>(this));
+ controller()->MaybeStartDrag(this, cloned_event, original_selection);
break;
}
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_drag_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698