Commit c20cccbe authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Fix of tab-dragging in tablet-mode with Mash

To process Left/Right snapping properly, CompleteDrag() in
TabDragController needs some properties, thus r596783 moves
ClearTabDraggingInfo() after CompleteDrag(). However
https://crbug.com/892221 revealed that another propertly
kIsDraggingTabsKey needs to be cleared beforehand, otherwise
some bounds calculation goes wrong.

This CL moves ClearTabDraggingInfo() as my previous CL does,
but clears kIsDraggingTabsKey earlier so issue 892221 won't
be affected.

BUG=880635, 892221
TEST=manually

Change-Id: Ib7edaab5e968e006bc919b027c138ad9f3d5827d
Reviewed-on: https://chromium-review.googlesource.com/c/1266495Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597616}
parent 555e0ca1
......@@ -1214,6 +1214,7 @@ void TabDragController::Detach(ReleaseCapture release_capture) {
}
}
ClearIsDraggingTabs();
ClearTabDraggingInfo();
attached_tabstrip_->DraggedTabsDetached();
attached_tabstrip_ = NULL;
......@@ -1549,7 +1550,9 @@ void TabDragController::EndDragImpl(EndDragType type) {
GetAttachedBrowserWidget()->EndMoveLoop();
}
ClearTabDraggingInfo();
// "IsDraggingTabs" flag needs to be cleared since some part of CompleteDrag()
// assumes it's cleared beforehand. See https://crbug.com/892221.
ClearIsDraggingTabs();
if (type != TAB_DESTROYED) {
// We only finish up the drag if we were actually dragging. If start_drag_
......@@ -1573,6 +1576,10 @@ void TabDragController::EndDragImpl(EndDragType type) {
RevertDrag();
} // else case the only tab we were dragging was deleted. Nothing to do.
// Clear tab dragging info after the complete/revert as CompleteDrag() may
// need to use some of the properties.
ClearTabDraggingInfo();
// Clear out drag data so we don't attempt to do anything with it.
drag_data_.clear();
......@@ -2113,22 +2120,32 @@ void TabDragController::SetTabDraggingInfo() {
#endif
}
void TabDragController::ClearTabDraggingInfo() {
void TabDragController::ClearIsDraggingTabs() {
#if defined(OS_CHROMEOS)
TabStrip* dragged_tabstrip =
attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_;
DCHECK(!dragged_tabstrip->IsDragSessionActive() || !active_);
// Do not clear the dragging info properties for a to-be-destroyed window.
// They will be cleared later in Window's destrutor. It's intentional as
// They will be cleared later in Window's destructor. It's intentional as
// ash::SplitViewController::TabDraggedWindowObserver listens to both
// OnWindowDestroying() event and the window properties change event, and uses
// the two events to decide what to do next.
if (GetModel(dragged_tabstrip)->empty())
return;
GetWindowForTabDraggingProperties(dragged_tabstrip)
->ClearProperty(ash::kIsDraggingTabsKey);
#endif
}
void TabDragController::ClearTabDraggingInfo() {
#if defined(OS_CHROMEOS)
TabStrip* dragged_tabstrip =
attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_;
DCHECK(!dragged_tabstrip->IsDragSessionActive() || !active_);
aura::Window* dragged_window =
GetWindowForTabDraggingProperties(dragged_tabstrip);
dragged_window->ClearProperty(ash::kIsDraggingTabsKey);
dragged_window->ClearProperty(ash::kTabDraggingSourceWindowKey);
dragged_window->ClearProperty(ash::kTabDroppedWindowStateTypeKey);
#endif
......
......@@ -492,6 +492,11 @@ class TabDragController : public views::WidgetObserver,
// whenever the dragged tabs are attached to a new tabstrip.
void SetTabDraggingInfo();
// Clears the flag to indicate that the tab dragging is happening in the
// tabstrip. This is separated from ClearTabDraggingInfo() since this needs
// to happen slightly before ClearTabDraggingInfo().
void ClearIsDraggingTabs();
// Clears the tab dragging info for the current dragged tabstrip. This
// function is supposed to be called whenever the dragged tabs are detached
// from the old tabstrip or the tab dragging is ended.
......
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