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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 10986029: Attempt 3 at: Makes tab dragging code set bounds before creating window, that way (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« 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/callback.h" 10 #include "base/callback.h"
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 } 1915 }
1916 } 1916 }
1917 return true; 1917 return true;
1918 } 1918 }
1919 1919
1920 Browser* TabDragController::CreateBrowserForDrag( 1920 Browser* TabDragController::CreateBrowserForDrag(
1921 TabStrip* source, 1921 TabStrip* source,
1922 const gfx::Point& point_in_screen, 1922 const gfx::Point& point_in_screen,
1923 gfx::Point* drag_offset, 1923 gfx::Point* drag_offset,
1924 std::vector<gfx::Rect>* drag_bounds) { 1924 std::vector<gfx::Rect>* drag_bounds) {
1925 Browser* browser = new Browser(
1926 Browser::CreateParams(drag_data_[0].contents->profile()));
1927 gfx::Point center(0, source->height() / 2); 1925 gfx::Point center(0, source->height() / 2);
1928 views::View::ConvertPointToWidget(source, &center); 1926 views::View::ConvertPointToWidget(source, &center);
1929 gfx::Rect new_bounds(source->GetWidget()->GetWindowBoundsInScreen()); 1927 gfx::Rect new_bounds(source->GetWidget()->GetWindowBoundsInScreen());
1930 new_bounds.set_y(point_in_screen.y() - center.y()); 1928 new_bounds.set_y(point_in_screen.y() - center.y());
1931 switch (GetDetachPosition(point_in_screen)) { 1929 switch (GetDetachPosition(point_in_screen)) {
1932 case DETACH_BEFORE: 1930 case DETACH_BEFORE:
1933 new_bounds.set_x(point_in_screen.x() - center.x()); 1931 new_bounds.set_x(point_in_screen.x() - center.x());
1934 new_bounds.Offset(-mouse_offset_.x(), 0); 1932 new_bounds.Offset(-mouse_offset_.x(), 0);
1935 break; 1933 break;
1936 1934
1937 case DETACH_AFTER: { 1935 case DETACH_AFTER: {
1938 gfx::Point right_edge(source->width(), 0); 1936 gfx::Point right_edge(source->width(), 0);
1939 views::View::ConvertPointToWidget(source, &right_edge); 1937 views::View::ConvertPointToWidget(source, &right_edge);
1940 new_bounds.set_x(point_in_screen.x() - right_edge.x()); 1938 new_bounds.set_x(point_in_screen.x() - right_edge.x());
1941 new_bounds.Offset(drag_bounds->back().right() - mouse_offset_.x(), 0); 1939 new_bounds.Offset(drag_bounds->back().right() - mouse_offset_.x(), 0);
1942 int delta = (*drag_bounds)[0].x(); 1940 int delta = (*drag_bounds)[0].x();
1943 for (size_t i = 0; i < drag_bounds->size(); ++i) 1941 for (size_t i = 0; i < drag_bounds->size(); ++i)
1944 (*drag_bounds)[i].Offset(-delta, 0); 1942 (*drag_bounds)[i].Offset(-delta, 0);
1945 break; 1943 break;
1946 } 1944 }
1947 1945
1948 default: 1946 default:
1949 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. 1947 break; // Nothing to do for DETACH_ABOVE_OR_BELOW.
1950 } 1948 }
1951 1949
1952 *drag_offset = point_in_screen.Subtract(new_bounds.origin()); 1950 *drag_offset = point_in_screen.Subtract(new_bounds.origin());
1953 1951
1952 Browser::CreateParams create_params(drag_data_[0].contents->profile());
1953 create_params.initial_bounds = new_bounds;
1954 Browser* browser = new Browser(create_params);
1954 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); 1955 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false);
1955 browser->window()->SetBounds(new_bounds);
1956 return browser; 1956 return browser;
1957 } 1957 }
1958 1958
1959 gfx::Point TabDragController::GetCursorScreenPoint() { 1959 gfx::Point TabDragController::GetCursorScreenPoint() {
1960 #if defined(USE_ASH) 1960 #if defined(USE_ASH)
1961 views::Widget* widget = GetAttachedBrowserWidget(); 1961 views::Widget* widget = GetAttachedBrowserWidget();
1962 DCHECK(widget); 1962 DCHECK(widget);
1963 if (aura::Env::GetInstance()->is_touch_down()) { 1963 if (aura::Env::GetInstance()->is_touch_down()) {
1964 aura::Window* widget_window = widget->GetNativeWindow(); 1964 aura::Window* widget_window = widget->GetNativeWindow();
1965 DCHECK(widget_window->GetRootWindow()); 1965 DCHECK(widget_window->GetRootWindow());
(...skipping 11 matching lines...) Expand all
1977 gfx::Point TabDragController::GetWindowOffset( 1977 gfx::Point TabDragController::GetWindowOffset(
1978 const gfx::Point& point_in_screen) { 1978 const gfx::Point& point_in_screen) {
1979 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 1979 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
1980 attached_tabstrip_ : source_tabstrip_; 1980 attached_tabstrip_ : source_tabstrip_;
1981 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 1981 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
1982 1982
1983 gfx::Point offset = point_in_screen; 1983 gfx::Point offset = point_in_screen;
1984 views::View::ConvertPointFromScreen(toplevel_view, &offset); 1984 views::View::ConvertPointFromScreen(toplevel_view, &offset);
1985 return offset; 1985 return offset;
1986 } 1986 }
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