Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| index 1997b873a2349ff601ee1869a531a63314eee050..5e445a6e3e812b83f49e5202a0d74b6c19fb27a4 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| @@ -111,6 +111,24 @@ gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
| } |
| #endif |
| +// Get tabstrip bounds from non-client view coordinates where tabstrip should be |
|
sky
2017/01/18 16:40:46
I think you mean, "Returns the bounds of the tabst
Qiang(Joe) Xu
2017/01/20 17:36:25
changed to GetBoundsForTabStripInBrowserView, so c
|
| +// laid when revealed, then convert to screen coordinates. Return false if the |
| +// corresponding browser view doesn't exist. |
| +bool GetBoundsForTabStripInScreen(TabStrip* tabstrip, gfx::Rect* rect) { |
| + if (!tabstrip) |
| + return false; |
|
sky
2017/01/18 16:40:46
I think callers should check for this case.
Qiang(Joe) Xu
2017/01/20 17:36:25
caller will make sure it
|
| + gfx::NativeWindow window = tabstrip->GetWidget()->GetNativeWindow(); |
| + if (!window) |
|
sky
2017/01/18 16:40:46
Can this case really happen?
Qiang(Joe) Xu
2017/01/20 17:36:25
seems cannot happen. remove it.
|
| + return false; |
| + BrowserView* browser_view = |
| + BrowserView::GetBrowserViewForNativeWindow(window); |
| + if (!browser_view) |
|
sky
2017/01/18 16:40:46
Same comment here. Can this case really happen?
Qiang(Joe) Xu
2017/01/20 17:36:25
Done.
|
| + return false; |
| + *rect = browser_view->frame()->GetBoundsForTabStrip(tabstrip); |
|
sky
2017/01/18 16:40:46
Why do you need to use GetBoundsForTabStrip rather
Qiang(Joe) Xu
2017/01/20 17:36:25
the actual bounds will return (0, 0, 0x0) for this
|
| + aura::Window::ConvertRectToTarget(window, window->GetRootWindow(), rect); |
| + return true; |
| +} |
| + |
| // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate |
| // of |bounds| is adjusted by |vertical_adjustment|. |
| bool DoesRectContainVerticalPointExpanded( |
| @@ -569,6 +587,15 @@ TabDragController::DragBrowserToNewTabStrip( |
| return DRAG_BROWSER_RESULT_STOP; |
| } |
| + // If tabstrip is invisible, it is not eligible to determine the tab insertion |
| + // position, so show the tabstrip here. |
| + gfx::Rect tabstrip_bounds; |
| + if (!target_tabstrip->visible() && |
| + GetBoundsForTabStripInScreen(target_tabstrip, &tabstrip_bounds)) { |
| + target_tabstrip->SetVisible(true); |
| + target_tabstrip->SetBoundsRect(tabstrip_bounds); |
| + } |
| + |
| #if defined(USE_AURA) |
| // Only Aura windows are gesture consumers. |
| ui::GestureRecognizer::Get()->TransferEventsTo( |
| @@ -856,14 +883,15 @@ TabStrip* TabDragController::GetTabStripForWindow(gfx::NativeWindow window) { |
| bool TabDragController::DoesTabStripContain( |
| TabStrip* tabstrip, |
| const gfx::Point& point_in_screen) const { |
| - // Make sure the specified screen point is actually within the bounds of the |
| - // specified tabstrip... |
| - gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); |
| + // Make sure the specified screen point is within the bounds of the specified |
| + // tabstrip where it should be laid when revealed. |
| + gfx::Rect tabstrip_bounds; |
| + DCHECK(GetBoundsForTabStripInScreen(tabstrip, &tabstrip_bounds)); |
| + |
| return point_in_screen.x() < tabstrip_bounds.right() && |
| - point_in_screen.x() >= tabstrip_bounds.x() && |
| - DoesRectContainVerticalPointExpanded(tabstrip_bounds, |
| - kVerticalDetachMagnetism, |
| - point_in_screen.y()); |
| + point_in_screen.x() >= tabstrip_bounds.x() && |
| + DoesRectContainVerticalPointExpanded( |
| + tabstrip_bounds, kVerticalDetachMagnetism, point_in_screen.y()); |
| } |
| void TabDragController::Attach(TabStrip* attached_tabstrip, |