Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #if defined(USE_ASH) | 49 #if defined(USE_ASH) |
| 50 #include "ash/shell.h" | 50 #include "ash/shell.h" |
| 51 #include "ash/wm/coordinate_conversion.h" | 51 #include "ash/wm/coordinate_conversion.h" |
| 52 #include "ash/wm/property_util.h" | 52 #include "ash/wm/property_util.h" |
| 53 #include "ash/wm/window_util.h" | 53 #include "ash/wm/window_util.h" |
| 54 #include "ui/aura/env.h" | 54 #include "ui/aura/env.h" |
| 55 #include "ui/aura/root_window.h" | 55 #include "ui/aura/root_window.h" |
| 56 #include "ui/base/gestures/gesture_recognizer.h" | 56 #include "ui/base/gestures/gesture_recognizer.h" |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #if defined(OS_WIN) | |
| 60 #include "ui/base/win/dpi.h" | |
| 61 #endif | |
| 62 | |
| 59 using content::OpenURLParams; | 63 using content::OpenURLParams; |
| 60 using content::UserMetricsAction; | 64 using content::UserMetricsAction; |
| 61 using content::WebContents; | 65 using content::WebContents; |
| 62 | 66 |
| 63 static const int kHorizontalMoveThreshold = 16; // Pixels. | 67 static const int kHorizontalMoveThreshold = 16; // Pixels. |
| 64 | 68 |
| 65 // Distance from the next/previous stacked before before we consider the tab | 69 // Distance from the next/previous stacked before before we consider the tab |
| 66 // close enough to trigger moving. | 70 // close enough to trigger moving. |
| 67 static const int kStackedDistance = 36; | 71 static const int kStackedDistance = 36; |
| 68 | 72 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 switches::kTabBrowserDragging); | 213 switches::kTabBrowserDragging); |
| 210 #endif | 214 #endif |
| 211 } | 215 } |
| 212 | 216 |
| 213 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate | 217 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate |
| 214 // of |bounds| is adjusted by |vertical_adjustment|. | 218 // of |bounds| is adjusted by |vertical_adjustment|. |
| 215 bool DoesRectContainVerticalPointExpanded( | 219 bool DoesRectContainVerticalPointExpanded( |
| 216 const gfx::Rect& bounds, | 220 const gfx::Rect& bounds, |
| 217 int vertical_adjustment, | 221 int vertical_adjustment, |
| 218 int y) { | 222 int y) { |
| 219 int upper_threshold = bounds.bottom() + vertical_adjustment; | 223 #if defined(OS_WIN) |
|
kevers
2013/06/03 17:28:50
Looks like we're mixing pixels and DIP in argument
| |
| 220 int lower_threshold = bounds.y() - vertical_adjustment; | 224 static float scale = ui::win::GetDeviceScaleFactor(); |
| 225 #else | |
| 226 static float scale = 1.0; | |
| 227 #endif | |
| 228 int upper_threshold = bounds.bottom() + scale * vertical_adjustment; | |
| 229 int lower_threshold = bounds.y() - scale * vertical_adjustment; | |
| 221 return y >= lower_threshold && y <= upper_threshold; | 230 return y >= lower_threshold && y <= upper_threshold; |
| 222 } | 231 } |
| 223 | 232 |
| 224 // WidgetObserver implementation that resets the window position managed | 233 // WidgetObserver implementation that resets the window position managed |
| 225 // property on Show. | 234 // property on Show. |
| 226 // We're forced to do this here since BrowserFrameAura resets the 'window | 235 // We're forced to do this here since BrowserFrameAura resets the 'window |
| 227 // position managed' property during a show and we need the property set to | 236 // position managed' property during a show and we need the property set to |
| 228 // false before WorkspaceLayoutManager2 sees the visibility change. | 237 // false before WorkspaceLayoutManager2 sees the visibility change. |
| 229 class WindowPositionManagedUpdater : public views::WidgetObserver { | 238 class WindowPositionManagedUpdater : public views::WidgetObserver { |
| 230 public: | 239 public: |
| (...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2071 gfx::Vector2d TabDragController::GetWindowOffset( | 2080 gfx::Vector2d TabDragController::GetWindowOffset( |
| 2072 const gfx::Point& point_in_screen) { | 2081 const gfx::Point& point_in_screen) { |
| 2073 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2082 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
| 2074 attached_tabstrip_ : source_tabstrip_; | 2083 attached_tabstrip_ : source_tabstrip_; |
| 2075 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2084 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
| 2076 | 2085 |
| 2077 gfx::Point point = point_in_screen; | 2086 gfx::Point point = point_in_screen; |
| 2078 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2087 views::View::ConvertPointFromScreen(toplevel_view, &point); |
| 2079 return point.OffsetFromOrigin(); | 2088 return point.OffsetFromOrigin(); |
| 2080 } | 2089 } |
| OLD | NEW |