OLD | NEW |
---|---|
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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 gfx::NativeWindow local_window; | 816 gfx::NativeWindow local_window; |
817 const Liveness state = GetLocalProcessWindow( | 817 const Liveness state = GetLocalProcessWindow( |
818 point_in_screen, is_dragging_window_, &local_window); | 818 point_in_screen, is_dragging_window_, &local_window); |
819 if (state == Liveness::DELETED) | 819 if (state == Liveness::DELETED) |
820 return Liveness::DELETED; | 820 return Liveness::DELETED; |
821 | 821 |
822 // Do not allow dragging into a window with a modal dialog, it causes a weird | 822 // Do not allow dragging into a window with a modal dialog, it causes a weird |
823 // behavior. See crbug.com/336691 | 823 // behavior. See crbug.com/336691 |
824 if (!GetModalTransient(local_window)) { | 824 if (!GetModalTransient(local_window)) { |
825 TabStrip* result = GetTabStripForWindow(local_window); | 825 TabStrip* result = GetTabStripForWindow(local_window); |
826 if (result && DoesTabStripContain(result, point_in_screen)) { | 826 if (result && DoesTabStripContain(result, point_in_screen, local_window)) { |
827 *tab_strip = result; | 827 *tab_strip = result; |
828 return Liveness::ALIVE; | 828 return Liveness::ALIVE; |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 *tab_strip = is_dragging_window_ ? attached_tabstrip_ : nullptr; | 832 *tab_strip = is_dragging_window_ ? attached_tabstrip_ : nullptr; |
833 return Liveness::ALIVE; | 833 return Liveness::ALIVE; |
834 } | 834 } |
835 | 835 |
836 TabStrip* TabDragController::GetTabStripForWindow(gfx::NativeWindow window) { | 836 TabStrip* TabDragController::GetTabStripForWindow(gfx::NativeWindow window) { |
837 if (!window) | 837 if (!window) |
838 return NULL; | 838 return NULL; |
839 BrowserView* browser_view = | 839 BrowserView* browser_view = |
840 BrowserView::GetBrowserViewForNativeWindow(window); | 840 BrowserView::GetBrowserViewForNativeWindow(window); |
841 // We don't allow drops on windows that don't have tabstrips. | 841 // We don't allow drops on windows that don't have tabstrips. |
842 if (!browser_view || | 842 if (!browser_view || |
843 !browser_view->browser()->SupportsWindowFeature( | 843 !browser_view->browser()->SupportsWindowFeature( |
844 Browser::FEATURE_TABSTRIP)) | 844 Browser::FEATURE_TABSTRIP)) |
845 return NULL; | 845 return NULL; |
846 | 846 |
847 TabStrip* other_tabstrip = browser_view->tabstrip(); | 847 TabStrip* other_tabstrip = browser_view->tabstrip(); |
848 TabStrip* tab_strip = | 848 TabStrip* tab_strip = |
849 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_; | 849 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_; |
850 DCHECK(tab_strip); | 850 DCHECK(tab_strip); |
851 | 851 |
852 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ? | 852 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ? |
853 other_tabstrip : NULL; | 853 other_tabstrip : NULL; |
854 } | 854 } |
855 | 855 |
856 bool TabDragController::DoesTabStripContain( | 856 bool TabDragController::DoesTabStripContain(TabStrip* tabstrip, |
857 TabStrip* tabstrip, | 857 const gfx::Point& point_in_screen, |
858 const gfx::Point& point_in_screen) const { | 858 gfx::NativeWindow window) const { |
859 // Make sure the specified screen point is actually within the bounds of the | 859 // Make sure the specified screen point is actually within the bounds of the |
860 // specified tabstrip... | 860 // specified tabstrip. |
861 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); | 861 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); |
862 return point_in_screen.x() < tabstrip_bounds.right() && | 862 #if defined(OS_CHROMEOS) |
sky
2017/01/17 18:07:01
Why does this need to be chromeos specific? Immers
Qiang(Joe) Xu
2017/01/18 01:13:52
done
| |
863 DCHECK(window); | |
864 BrowserView* browser_view = | |
865 BrowserView::GetBrowserViewForNativeWindow(window); | |
866 DCHECK(browser_view); | |
867 bool hidden_top_views = | |
868 browser_view->immersive_mode_controller()->ShouldHideTopViews(); | |
869 // When |window| is immersive non-revealed mode, get |tabstrip_bounds| from | |
870 // non-client view coordinates where tabstrip should be laid when revealed. | |
871 if (hidden_top_views) { | |
872 tabstrip_bounds = browser_view->frame()->GetBoundsForTabStrip(tabstrip); | |
873 aura::Window::ConvertRectToTarget(window, window->GetRootWindow(), | |
874 &tabstrip_bounds); | |
875 } | |
876 #endif | |
877 | |
878 bool res = | |
879 point_in_screen.x() < tabstrip_bounds.right() && | |
863 point_in_screen.x() >= tabstrip_bounds.x() && | 880 point_in_screen.x() >= tabstrip_bounds.x() && |
864 DoesRectContainVerticalPointExpanded(tabstrip_bounds, | 881 DoesRectContainVerticalPointExpanded( |
865 kVerticalDetachMagnetism, | 882 tabstrip_bounds, kVerticalDetachMagnetism, point_in_screen.y()); |
866 point_in_screen.y()); | 883 #if defined(OS_CHROMEOS) |
884 if (res && hidden_top_views) { | |
885 tabstrip->SetVisible(true); | |
sky
2017/01/17 18:07:01
This function is meant to check whether the tabstr
Qiang(Joe) Xu
2017/01/18 01:13:52
done by moving to DragBrowserToNewTabStrip
| |
886 tabstrip->SetBoundsRect(tabstrip_bounds); | |
887 } | |
888 #endif | |
889 return res; | |
867 } | 890 } |
868 | 891 |
869 void TabDragController::Attach(TabStrip* attached_tabstrip, | 892 void TabDragController::Attach(TabStrip* attached_tabstrip, |
870 const gfx::Point& point_in_screen) { | 893 const gfx::Point& point_in_screen) { |
871 TRACE_EVENT1("views", "TabDragController::Attach", | 894 TRACE_EVENT1("views", "TabDragController::Attach", |
872 "point_in_screen", point_in_screen.ToString()); | 895 "point_in_screen", point_in_screen.ToString()); |
873 | 896 |
874 DCHECK(!attached_tabstrip_); // We should already have detached by the time | 897 DCHECK(!attached_tabstrip_); // We should already have detached by the time |
875 // we get here. | 898 // we get here. |
876 | 899 |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 // TODO(pkotwicz): Fix this properly (crbug.com/358482) | 1818 // TODO(pkotwicz): Fix this properly (crbug.com/358482) |
1796 for (auto* browser : *BrowserList::GetInstance()) { | 1819 for (auto* browser : *BrowserList::GetInstance()) { |
1797 if (browser->tab_strip_model()->empty()) | 1820 if (browser->tab_strip_model()->empty()) |
1798 exclude.insert(browser->window()->GetNativeWindow()); | 1821 exclude.insert(browser->window()->GetNativeWindow()); |
1799 } | 1822 } |
1800 #endif | 1823 #endif |
1801 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); | 1824 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); |
1802 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); | 1825 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); |
1803 return ref ? Liveness::ALIVE : Liveness::DELETED; | 1826 return ref ? Liveness::ALIVE : Liveness::DELETED; |
1804 } | 1827 } |
OLD | NEW |