Commit 0cc39c06 authored by varkha@chromium.org's avatar varkha@chromium.org

Avoids releasing capture prematurily when dragging tabs from one to another browser window

BUG=338297

Review URL: https://codereview.chromium.org/180983002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255826 0039d316-1c4b-4281-b951-d872f2087c98
parent 2618807e
...@@ -162,6 +162,7 @@ TabDragController::TabDragController() ...@@ -162,6 +162,7 @@ TabDragController::TabDragController()
attached_tabstrip_(NULL), attached_tabstrip_(NULL),
screen_(NULL), screen_(NULL),
host_desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), host_desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE),
use_aura_capture_policy_(false),
offset_to_width_ratio_(0), offset_to_width_ratio_(0),
old_focused_view_id_( old_focused_view_id_(
views::ViewStorage::GetInstance()->CreateStorageID()), views::ViewStorage::GetInstance()->CreateStorageID()),
...@@ -236,6 +237,12 @@ void TabDragController::Init( ...@@ -236,6 +237,12 @@ void TabDragController::Init(
source_tabstrip->GetWidget()->GetNativeView()); source_tabstrip->GetWidget()->GetNativeView());
host_desktop_type_ = chrome::GetHostDesktopTypeForNativeView( host_desktop_type_ = chrome::GetHostDesktopTypeForNativeView(
source_tabstrip->GetWidget()->GetNativeView()); source_tabstrip->GetWidget()->GetNativeView());
#if defined(OS_LINUX)
use_aura_capture_policy_ = true;
#else
use_aura_capture_policy_ =
(host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH);
#endif
start_point_in_screen_ = gfx::Point(source_tab_offset, mouse_offset.y()); start_point_in_screen_ = gfx::Point(source_tab_offset, mouse_offset.y());
views::View::ConvertPointToScreen(source_tab, &start_point_in_screen_); views::View::ConvertPointToScreen(source_tab, &start_point_in_screen_);
event_source_ = event_source; event_source_ = event_source;
...@@ -659,7 +666,7 @@ TabDragController::DragBrowserToNewTabStrip( ...@@ -659,7 +666,7 @@ TabDragController::DragBrowserToNewTabStrip(
// ReleaseCapture() is going to result in calling back to us (because it // ReleaseCapture() is going to result in calling back to us (because it
// results in a move). That'll cause all sorts of problems. Reset the // results in a move). That'll cause all sorts of problems. Reset the
// observer so we don't get notified and process the event. // observer so we don't get notified and process the event.
if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { if (use_aura_capture_policy_) {
move_loop_widget_->RemoveObserver(this); move_loop_widget_->RemoveObserver(this);
move_loop_widget_ = NULL; move_loop_widget_ = NULL;
} }
...@@ -672,7 +679,7 @@ TabDragController::DragBrowserToNewTabStrip( ...@@ -672,7 +679,7 @@ TabDragController::DragBrowserToNewTabStrip(
browser_widget->SetVisibilityChangedAnimationsEnabled(false); browser_widget->SetVisibilityChangedAnimationsEnabled(false);
// For aura we can't release capture, otherwise it'll cancel a gesture. // For aura we can't release capture, otherwise it'll cancel a gesture.
// Instead we have to directly change capture. // Instead we have to directly change capture.
if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) if (use_aura_capture_policy_)
target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_);
else else
browser_widget->ReleaseCapture(); browser_widget->ReleaseCapture();
...@@ -692,9 +699,12 @@ TabDragController::DragBrowserToNewTabStrip( ...@@ -692,9 +699,12 @@ TabDragController::DragBrowserToNewTabStrip(
// that to effect the position of any windows. // that to effect the position of any windows.
SetWindowPositionManaged(browser_widget->GetNativeView(), false); SetWindowPositionManaged(browser_widget->GetNativeView(), false);
#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
// EndMoveLoop is going to snap the window back to its original location. // EndMoveLoop is going to snap the window back to its original location.
// Hide it so users don't see this. // Hide it so users don't see this. Hiding a window in Linux aura causes
// it to lose capture so skip it.
browser_widget->Hide(); browser_widget->Hide();
#endif
browser_widget->EndMoveLoop(); browser_widget->EndMoveLoop();
// Ideally we would always swap the tabs now, but on non-ash it seems that // Ideally we would always swap the tabs now, but on non-ash it seems that
...@@ -702,7 +712,7 @@ TabDragController::DragBrowserToNewTabStrip( ...@@ -702,7 +712,7 @@ TabDragController::DragBrowserToNewTabStrip(
// to all sorts of flicker. So, on non-ash, instead we process the move // to all sorts of flicker. So, on non-ash, instead we process the move
// after the loop completes. But on chromeos, we can do tab swapping now to // after the loop completes. But on chromeos, we can do tab swapping now to
// avoid the tab flashing issue(crbug.com/116329). // avoid the tab flashing issue(crbug.com/116329).
if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { if (use_aura_capture_policy_) {
is_dragging_window_ = false; is_dragging_window_ = false;
Detach(DONT_RELEASE_CAPTURE); Detach(DONT_RELEASE_CAPTURE);
Attach(target_tabstrip, point_in_screen); Attach(target_tabstrip, point_in_screen);
...@@ -1127,8 +1137,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( ...@@ -1127,8 +1137,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
gfx::NativeView attached_native_view = gfx::NativeView attached_native_view =
attached_tabstrip_->GetWidget()->GetNativeView(); attached_tabstrip_->GetWidget()->GetNativeView();
#endif #endif
Detach(host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH ? Detach(use_aura_capture_policy_ ? DONT_RELEASE_CAPTURE : RELEASE_CAPTURE);
DONT_RELEASE_CAPTURE : RELEASE_CAPTURE);
BrowserView* dragged_browser_view = BrowserView* dragged_browser_view =
BrowserView::GetBrowserViewForBrowser(browser); BrowserView::GetBrowserViewForBrowser(browser);
views::Widget* dragged_widget = dragged_browser_view->GetWidget(); views::Widget* dragged_widget = dragged_browser_view->GetWidget();
......
...@@ -505,6 +505,10 @@ class TabDragController : public content::WebContentsDelegate, ...@@ -505,6 +505,10 @@ class TabDragController : public content::WebContentsDelegate,
// object. // object.
chrome::HostDesktopType host_desktop_type_; chrome::HostDesktopType host_desktop_type_;
// Aura mouse capture and release is used on Ash platforms as well as on
// Linux to ensure that pointer grab is not released prematurely.
bool use_aura_capture_policy_;
// The position of the mouse (in screen coordinates) at the start of the drag // The position of the mouse (in screen coordinates) at the start of the drag
// operation. This is used to calculate minimum elasticity before a // operation. This is used to calculate minimum elasticity before a
// DraggedTabView is constructed. // DraggedTabView is constructed.
......
...@@ -325,7 +325,6 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, GestureEndShouldEndDragTest) { ...@@ -325,7 +325,6 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, GestureEndShouldEndDragTest) {
AddTabAndResetBrowser(browser()); AddTabAndResetBrowser(browser());
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
TabStripModel* model = browser()->tab_strip_model();
Tab* tab1 = tab_strip->tab_at(1); Tab* tab1 = tab_strip->tab_at(1);
gfx::Point tab_1_center(tab1->width() / 2, tab1->height() / 2); gfx::Point tab_1_center(tab1->width() / 2, tab1->height() / 2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment