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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 #if defined(USE_ASH) | 41 #if defined(USE_ASH) |
42 #include "ash/accelerators/accelerator_commands.h" | 42 #include "ash/accelerators/accelerator_commands.h" |
43 #include "ash/shell.h" | 43 #include "ash/shell.h" |
44 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 44 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
45 #include "ash/wm/window_state.h" | 45 #include "ash/wm/window_state.h" |
46 #include "ui/wm/core/coordinate_conversion.h" | 46 #include "ui/wm/core/coordinate_conversion.h" |
47 #endif | 47 #endif |
48 | 48 |
49 #if defined(USE_AURA) | 49 #if defined(USE_AURA) |
| 50 #if defined(OS_ANDROID) |
| 51 #include "ui/aura/client/screen_position_client.h" |
| 52 #endif |
50 #include "ui/aura/env.h" | 53 #include "ui/aura/env.h" |
51 #include "ui/aura/window.h" | 54 #include "ui/aura/window.h" |
52 #include "ui/wm/core/window_modality_controller.h" | 55 #include "ui/wm/core/window_modality_controller.h" |
53 #endif | 56 #endif |
54 | 57 |
55 using base::UserMetricsAction; | 58 using base::UserMetricsAction; |
56 using content::OpenURLParams; | 59 using content::OpenURLParams; |
57 using content::WebContents; | 60 using content::WebContents; |
58 | 61 |
59 // If non-null there is a drag underway. | 62 // If non-null there is a drag underway. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { | 111 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
109 return wm::GetModalTransient(window); | 112 return wm::GetModalTransient(window); |
110 } | 113 } |
111 #else | 114 #else |
112 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { | 115 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
113 NOTIMPLEMENTED(); | 116 NOTIMPLEMENTED(); |
114 return NULL; | 117 return NULL; |
115 } | 118 } |
116 #endif | 119 #endif |
117 | 120 |
| 121 // TODO(mfomitchev): figure out how to not have code duplication with |
| 122 // Ahs's window_finder impl |
| 123 #if defined(OS_ANDROID) && defined(USE_AURA) |
| 124 gfx::NativeWindow GetLocalProcessWindowAtPointImpl( |
| 125 const gfx::Point& screen_point, |
| 126 const std::set<gfx::NativeWindow>& ignore, |
| 127 gfx::NativeWindow window) { |
| 128 if (ignore.find(window) != ignore.end()) |
| 129 return nullptr; |
| 130 |
| 131 if (!window->IsVisible()) |
| 132 return nullptr; |
| 133 |
| 134 if (window->layer()->type() == ui::LAYER_TEXTURED) { |
| 135 // Returns the window that has visible layer and can hit the |
| 136 // |screen_point|, because we want to detach the tab as soon as |
| 137 // the dragging mouse moved over to the window that can hide the |
| 138 // moving tab. |
| 139 aura::client::ScreenPositionClient* client = |
| 140 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 141 gfx::Point local_point = screen_point; |
| 142 client->ConvertPointFromScreen(window, &local_point); |
| 143 return window->GetEventHandlerForPoint(local_point) ? window : nullptr; |
| 144 } |
| 145 |
| 146 for (aura::Window::Windows::const_reverse_iterator i = |
| 147 window->children().rbegin(); i != window->children().rend(); ++i) { |
| 148 gfx::NativeWindow result = |
| 149 GetLocalProcessWindowAtPointImpl(screen_point, ignore, *i); |
| 150 if (result) |
| 151 return result; |
| 152 } |
| 153 return nullptr; |
| 154 } |
| 155 #endif // defined(OS_ANDROID) && defined(USE_AURA) |
| 156 |
| 157 |
118 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate | 158 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate |
119 // of |bounds| is adjusted by |vertical_adjustment|. | 159 // of |bounds| is adjusted by |vertical_adjustment|. |
120 bool DoesRectContainVerticalPointExpanded( | 160 bool DoesRectContainVerticalPointExpanded( |
121 const gfx::Rect& bounds, | 161 const gfx::Rect& bounds, |
122 int vertical_adjustment, | 162 int vertical_adjustment, |
123 int y) { | 163 int y) { |
124 int upper_threshold = bounds.bottom() + vertical_adjustment; | 164 int upper_threshold = bounds.bottom() + vertical_adjustment; |
125 int lower_threshold = bounds.y() - vertical_adjustment; | 165 int lower_threshold = bounds.y() - vertical_adjustment; |
126 return y >= lower_threshold && y <= upper_threshold; | 166 return y >= lower_threshold && y <= upper_threshold; |
127 } | 167 } |
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 gfx::NativeWindow TabDragController::GetLocalProcessWindow( | 1837 gfx::NativeWindow TabDragController::GetLocalProcessWindow( |
1798 const gfx::Point& screen_point, | 1838 const gfx::Point& screen_point, |
1799 bool exclude_dragged_view) { | 1839 bool exclude_dragged_view) { |
1800 std::set<gfx::NativeWindow> exclude; | 1840 std::set<gfx::NativeWindow> exclude; |
1801 if (exclude_dragged_view) { | 1841 if (exclude_dragged_view) { |
1802 gfx::NativeWindow dragged_window = | 1842 gfx::NativeWindow dragged_window = |
1803 attached_tabstrip_->GetWidget()->GetNativeWindow(); | 1843 attached_tabstrip_->GetWidget()->GetNativeWindow(); |
1804 if (dragged_window) | 1844 if (dragged_window) |
1805 exclude.insert(dragged_window); | 1845 exclude.insert(dragged_window); |
1806 } | 1846 } |
| 1847 #if defined(OS_ANDROID) |
| 1848 gfx::NativeWindow dragged_window = |
| 1849 attached_tabstrip_->GetWidget()->GetNativeWindow(); |
| 1850 return GetLocalProcessWindowAtPointImpl(screen_point, |
| 1851 exclude, |
| 1852 dragged_window->GetRootWindow()); |
| 1853 #else |
1807 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1854 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1808 // Exclude windows which are pending deletion via Browser::TabStripEmpty(). | 1855 // Exclude windows which are pending deletion via Browser::TabStripEmpty(). |
1809 // These windows can be returned in the Linux Aura port because the browser | 1856 // These windows can be returned in the Linux Aura port because the browser |
1810 // window which was used for dragging is not hidden once all of its tabs are | 1857 // window which was used for dragging is not hidden once all of its tabs are |
1811 // attached to another browser window in DragBrowserToNewTabStrip(). | 1858 // attached to another browser window in DragBrowserToNewTabStrip(). |
1812 // TODO(pkotwicz): Fix this properly (crbug.com/358482) | 1859 // TODO(pkotwicz): Fix this properly (crbug.com/358482) |
1813 BrowserList* browser_list = BrowserList::GetInstance( | 1860 BrowserList* browser_list = BrowserList::GetInstance( |
1814 chrome::HOST_DESKTOP_TYPE_NATIVE); | 1861 chrome::HOST_DESKTOP_TYPE_NATIVE); |
1815 for (BrowserList::const_iterator it = browser_list->begin(); | 1862 for (BrowserList::const_iterator it = browser_list->begin(); |
1816 it != browser_list->end(); ++it) { | 1863 it != browser_list->end(); ++it) { |
1817 if ((*it)->tab_strip_model()->empty()) | 1864 if ((*it)->tab_strip_model()->empty()) |
1818 exclude.insert((*it)->window()->GetNativeWindow()); | 1865 exclude.insert((*it)->window()->GetNativeWindow()); |
1819 } | 1866 } |
1820 #endif | 1867 #endif |
1821 return GetLocalProcessWindowAtPoint(host_desktop_type_, | 1868 return GetLocalProcessWindowAtPoint(host_desktop_type_, |
1822 screen_point, | 1869 screen_point, |
1823 exclude); | 1870 exclude); |
1824 | 1871 #endif // defined(OS_ANDROID) |
1825 } | 1872 } |
OLD | NEW |