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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { 104 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) {
105 return wm::GetModalTransient(window); 105 return wm::GetModalTransient(window);
106 } 106 }
107 #else 107 #else
108 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { 108 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) {
109 NOTIMPLEMENTED(); 109 NOTIMPLEMENTED();
110 return NULL; 110 return NULL;
111 } 111 }
112 #endif 112 #endif
113 113
114 // Returns the browser view that contains the |tabstrip|.
115 BrowserView* GetBrowserViewForTabStrip(TabStrip* tabstrip) {
116 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?
117 return BrowserView::GetBrowserViewForNativeWindow(window);
118 }
119
120 // Returns the bounds of the tabstrip in browser view coordinates.
121 gfx::Rect GetBoundsForTabStripInBrowserView(TabStrip* tabstrip) {
122 BrowserView* browser_view = GetBrowserViewForTabStrip(tabstrip);
123 gfx::RectF bounds_f(
124 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
125 views::View::ConvertRectToTarget(browser_view->parent(), browser_view,
126 &bounds_f);
127 return gfx::ToEnclosingRect(bounds_f);
128 }
129
114 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate 130 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate
115 // of |bounds| is adjusted by |vertical_adjustment|. 131 // of |bounds| is adjusted by |vertical_adjustment|.
116 bool DoesRectContainVerticalPointExpanded( 132 bool DoesRectContainVerticalPointExpanded(
117 const gfx::Rect& bounds, 133 const gfx::Rect& bounds,
118 int vertical_adjustment, 134 int vertical_adjustment,
119 int y) { 135 int y) {
120 int upper_threshold = bounds.bottom() + vertical_adjustment; 136 int upper_threshold = bounds.bottom() + vertical_adjustment;
121 int lower_threshold = bounds.y() - vertical_adjustment; 137 int lower_threshold = bounds.y() - vertical_adjustment;
122 return y >= lower_threshold && y <= upper_threshold; 138 return y >= lower_threshold && y <= upper_threshold;
123 } 139 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 TabStrip* target_tabstrip, 578 TabStrip* target_tabstrip,
563 const gfx::Point& point_in_screen) { 579 const gfx::Point& point_in_screen) {
564 TRACE_EVENT1("views", "TabDragController::DragBrowserToNewTabStrip", 580 TRACE_EVENT1("views", "TabDragController::DragBrowserToNewTabStrip",
565 "point_in_screen", point_in_screen.ToString()); 581 "point_in_screen", point_in_screen.ToString());
566 582
567 if (!target_tabstrip) { 583 if (!target_tabstrip) {
568 DetachIntoNewBrowserAndRunMoveLoop(point_in_screen); 584 DetachIntoNewBrowserAndRunMoveLoop(point_in_screen);
569 return DRAG_BROWSER_RESULT_STOP; 585 return DRAG_BROWSER_RESULT_STOP;
570 } 586 }
571 587
588 // If tabstrip is invisible, it is not eligible to determine the tab insertion
589 // position, so show the tabstrip here.
590 if (!target_tabstrip->visible()) {
sky 2017/01/20 18:03:43 You should not be changing the visibility of the t
591 gfx::Rect tabstrip_bounds =
592 GetBoundsForTabStripInBrowserView(target_tabstrip);
593 target_tabstrip->SetVisible(true);
594 target_tabstrip->SetBoundsRect(tabstrip_bounds);
595 }
596
572 #if defined(USE_AURA) 597 #if defined(USE_AURA)
573 // Only Aura windows are gesture consumers. 598 // Only Aura windows are gesture consumers.
574 ui::GestureRecognizer::Get()->TransferEventsTo( 599 ui::GestureRecognizer::Get()->TransferEventsTo(
575 GetAttachedBrowserWidget()->GetNativeView(), 600 GetAttachedBrowserWidget()->GetNativeView(),
576 target_tabstrip->GetWidget()->GetNativeView(), 601 target_tabstrip->GetWidget()->GetNativeView(),
577 ui::GestureRecognizer::ShouldCancelTouches::DontCancel); 602 ui::GestureRecognizer::ShouldCancelTouches::DontCancel);
578 #endif 603 #endif
579 604
580 if (is_dragging_window_) { 605 if (is_dragging_window_) {
581 // ReleaseCapture() is going to result in calling back to us (because it 606 // ReleaseCapture() is going to result in calling back to us (because it
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_; 874 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_;
850 DCHECK(tab_strip); 875 DCHECK(tab_strip);
851 876
852 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ? 877 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ?
853 other_tabstrip : NULL; 878 other_tabstrip : NULL;
854 } 879 }
855 880
856 bool TabDragController::DoesTabStripContain( 881 bool TabDragController::DoesTabStripContain(
857 TabStrip* tabstrip, 882 TabStrip* tabstrip,
858 const gfx::Point& point_in_screen) const { 883 const gfx::Point& point_in_screen) const {
859 // Make sure the specified screen point is actually within the bounds of the 884 // Make sure the specified screen point is within the bounds of the specified
860 // specified tabstrip... 885 // tabstrip where it should be laid when revealed.
861 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); 886 gfx::Rect tabstrip_bounds = GetBoundsForTabStripInBrowserView(tabstrip);
862 return point_in_screen.x() < tabstrip_bounds.right() && 887 BrowserView* browser_view = GetBrowserViewForTabStrip(tabstrip);
863 point_in_screen.x() >= tabstrip_bounds.x() && 888 gfx::Point point_in_browser_view(point_in_screen.x(), point_in_screen.y());
864 DoesRectContainVerticalPointExpanded(tabstrip_bounds, 889 views::View::ConvertPointFromScreen(browser_view, &point_in_browser_view);
865 kVerticalDetachMagnetism, 890 return point_in_browser_view.x() < tabstrip_bounds.right() &&
866 point_in_screen.y()); 891 point_in_browser_view.x() >= tabstrip_bounds.x() &&
892 DoesRectContainVerticalPointExpanded(tabstrip_bounds,
893 kVerticalDetachMagnetism,
894 point_in_browser_view.y());
867 } 895 }
868 896
869 void TabDragController::Attach(TabStrip* attached_tabstrip, 897 void TabDragController::Attach(TabStrip* attached_tabstrip,
870 const gfx::Point& point_in_screen) { 898 const gfx::Point& point_in_screen) {
871 TRACE_EVENT1("views", "TabDragController::Attach", 899 TRACE_EVENT1("views", "TabDragController::Attach",
872 "point_in_screen", point_in_screen.ToString()); 900 "point_in_screen", point_in_screen.ToString());
873 901
874 DCHECK(!attached_tabstrip_); // We should already have detached by the time 902 DCHECK(!attached_tabstrip_); // We should already have detached by the time
875 // we get here. 903 // we get here.
876 904
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 // TODO(pkotwicz): Fix this properly (crbug.com/358482) 1823 // TODO(pkotwicz): Fix this properly (crbug.com/358482)
1796 for (auto* browser : *BrowserList::GetInstance()) { 1824 for (auto* browser : *BrowserList::GetInstance()) {
1797 if (browser->tab_strip_model()->empty()) 1825 if (browser->tab_strip_model()->empty())
1798 exclude.insert(browser->window()->GetNativeWindow()); 1826 exclude.insert(browser->window()->GetNativeWindow());
1799 } 1827 }
1800 #endif 1828 #endif
1801 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); 1829 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr());
1802 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); 1830 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude);
1803 return ref ? Liveness::ALIVE : Liveness::DELETED; 1831 return ref ? Liveness::ALIVE : Liveness::DELETED;
1804 } 1832 }
OLDNEW
« 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