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

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

Issue 2640433004: ChromeOS MD: Fix cannot drag tab onto immersive fullscreen window (Closed)
Patch Set: GetBoundsForTabStripInBrowserView and fix test failures Created 3 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_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..540d8a797e2763de403bad4732e2913c54d6bf21 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -111,6 +111,22 @@ gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) {
}
#endif
+// Returns the browser view that contains the |tabstrip|.
+BrowserView* GetBrowserViewForTabStrip(TabStrip* tabstrip) {
+ aura::Window* window = tabstrip->GetWidget()->GetNativeWindow();
sky 2017/01/20 18:03:43 gfx::NativeView (so that this works in non-aura bu
Qiang(Joe) Xu 2017/01/22 01:43:56 gfx::NativeWindow?
+ return BrowserView::GetBrowserViewForNativeWindow(window);
+}
+
+// Returns the bounds of the tabstrip in browser view coordinates.
+gfx::Rect GetBoundsForTabStripInBrowserView(TabStrip* tabstrip) {
+ BrowserView* browser_view = GetBrowserViewForTabStrip(tabstrip);
+ gfx::RectF bounds_f(
+ browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
+ views::View::ConvertRectToTarget(browser_view->parent(), browser_view,
+ &bounds_f);
+ return gfx::ToEnclosingRect(bounds_f);
+}
+
// Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate
// of |bounds| is adjusted by |vertical_adjustment|.
bool DoesRectContainVerticalPointExpanded(
@@ -569,6 +585,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.
+ if (!target_tabstrip->visible()) {
sky 2017/01/20 18:03:43 You should not be changing the visibility of the t
+ gfx::Rect tabstrip_bounds =
+ GetBoundsForTabStripInBrowserView(target_tabstrip);
+ 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 +881,17 @@ 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);
- return point_in_screen.x() < tabstrip_bounds.right() &&
- point_in_screen.x() >= tabstrip_bounds.x() &&
- DoesRectContainVerticalPointExpanded(tabstrip_bounds,
- kVerticalDetachMagnetism,
- point_in_screen.y());
+ // 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 = GetBoundsForTabStripInBrowserView(tabstrip);
+ BrowserView* browser_view = GetBrowserViewForTabStrip(tabstrip);
+ gfx::Point point_in_browser_view(point_in_screen.x(), point_in_screen.y());
+ views::View::ConvertPointFromScreen(browser_view, &point_in_browser_view);
+ return point_in_browser_view.x() < tabstrip_bounds.right() &&
+ point_in_browser_view.x() >= tabstrip_bounds.x() &&
+ DoesRectContainVerticalPointExpanded(tabstrip_bounds,
+ kVerticalDetachMagnetism,
+ point_in_browser_view.y());
}
void TabDragController::Attach(TabStrip* attached_tabstrip,
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698