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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 gfx::NativeWindow window = tabstrip->GetWidget()->GetNativeWindow(); | |
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_; | 865 attached_tabstrip_ ? attached_tabstrip_ : source_tabstrip_; |
850 DCHECK(tab_strip); | 866 DCHECK(tab_strip); |
851 | 867 |
852 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ? | 868 return other_tabstrip->controller()->IsCompatibleWith(tab_strip) ? |
853 other_tabstrip : NULL; | 869 other_tabstrip : NULL; |
854 } | 870 } |
855 | 871 |
856 bool TabDragController::DoesTabStripContain( | 872 bool TabDragController::DoesTabStripContain( |
857 TabStrip* tabstrip, | 873 TabStrip* tabstrip, |
858 const gfx::Point& point_in_screen) const { | 874 const gfx::Point& point_in_screen) const { |
859 // Make sure the specified screen point is actually within the bounds of the | 875 // Make sure the specified screen point is within the bounds of the specified |
860 // specified tabstrip... | 876 // tabstrip where it should be laid when revealed. |
861 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); | 877 gfx::Rect tabstrip_bounds = GetBoundsForTabStripInBrowserView(tabstrip); |
862 return point_in_screen.x() < tabstrip_bounds.right() && | 878 BrowserView* browser_view = GetBrowserViewForTabStrip(tabstrip); |
863 point_in_screen.x() >= tabstrip_bounds.x() && | 879 gfx::Point point_in_browser_view(point_in_screen.x(), point_in_screen.y()); |
864 DoesRectContainVerticalPointExpanded(tabstrip_bounds, | 880 views::View::ConvertPointFromScreen(browser_view, &point_in_browser_view); |
865 kVerticalDetachMagnetism, | 881 return point_in_browser_view.x() < tabstrip_bounds.right() && |
866 point_in_screen.y()); | 882 point_in_browser_view.x() >= tabstrip_bounds.x() && |
883 DoesRectContainVerticalPointExpanded(tabstrip_bounds, | |
884 kVerticalDetachMagnetism, | |
885 point_in_browser_view.y()); | |
867 } | 886 } |
868 | 887 |
869 void TabDragController::Attach(TabStrip* attached_tabstrip, | 888 void TabDragController::Attach(TabStrip* attached_tabstrip, |
870 const gfx::Point& point_in_screen) { | 889 const gfx::Point& point_in_screen) { |
871 TRACE_EVENT1("views", "TabDragController::Attach", | 890 TRACE_EVENT1("views", "TabDragController::Attach", |
872 "point_in_screen", point_in_screen.ToString()); | 891 "point_in_screen", point_in_screen.ToString()); |
873 | 892 |
874 DCHECK(!attached_tabstrip_); // We should already have detached by the time | 893 DCHECK(!attached_tabstrip_); // We should already have detached by the time |
875 // we get here. | 894 // we get here. |
876 | 895 |
877 attached_tabstrip_ = attached_tabstrip; | 896 attached_tabstrip_ = attached_tabstrip; |
878 | 897 |
879 std::vector<Tab*> tabs = | 898 std::vector<Tab*> tabs = |
880 GetTabsMatchingDraggedContents(attached_tabstrip_); | 899 GetTabsMatchingDraggedContents(attached_tabstrip_); |
881 | 900 |
901 // Make a StartedDraggingTabs call here to GetRevealedLock so that if | |
902 // immersive mode is unrevealed, reveal it. | |
903 attached_tabstrip_->StartedDraggingTabs(tabs); | |
Qiang(Joe) Xu
2017/01/22 01:43:57
We should get ImmersiveModeCOntrollerAsh::OnImmers
sky
2017/01/23 16:19:06
StartedDraggingTabs is called on line 949.
Qiang(Joe) Xu
2017/01/23 17:50:37
Yes, I am aware of that. The problem is here: http
sky
2017/01/23 20:07:26
So, you're solution to this is to call the functio
Qiang(Joe) Xu
2017/01/26 17:43:08
Hi, I am sorry I thought this could work. Another
| |
904 | |
882 if (tabs.empty()) { | 905 if (tabs.empty()) { |
883 // Transitioning from detached to attached to a new tabstrip. Add tabs to | 906 // Transitioning from detached to attached to a new tabstrip. Add tabs to |
884 // the new model. | 907 // the new model. |
885 | 908 |
886 selection_model_before_attach_.Copy(attached_tabstrip->GetSelectionModel()); | 909 selection_model_before_attach_.Copy(attached_tabstrip->GetSelectionModel()); |
887 | 910 |
888 // Inserting counts as a move. We don't want the tabs to jitter when the | 911 // Inserting counts as a move. We don't want the tabs to jitter when the |
889 // user moves the tab immediately after attaching it. | 912 // user moves the tab immediately after attaching it. |
890 last_move_screen_loc_ = point_in_screen.x(); | 913 last_move_screen_loc_ = point_in_screen.x(); |
891 | 914 |
(...skipping 903 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 |