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

Side by Side Diff: chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix step one more time Created 8 years, 1 month 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
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/gtk/tabs/dragged_tab_controller_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 498
499 // Detaching resets the delegate, but we still want to be the delegate. 499 // Detaching resets the delegate, but we still want to be the delegate.
500 for (size_t i = 0; i < drag_data_->size(); ++i) 500 for (size_t i = 0; i < drag_data_->size(); ++i)
501 drag_data_->get(i)->contents_->web_contents()->SetDelegate(this); 501 drag_data_->get(i)->contents_->web_contents()->SetDelegate(this);
502 502
503 attached_tabstrip_ = NULL; 503 attached_tabstrip_ = NULL;
504 } 504 }
505 505
506 gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint( 506 gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint(
507 TabStripGtk* tabstrip, const gfx::Point& screen_point) { 507 TabStripGtk* tabstrip, const gfx::Point& screen_point) {
508 gfx::Point tabstrip_screen_point = 508 return screen_point - ui::GetWidgetScreenOffset(tabstrip->tabstrip_.get());
509 ui::GetWidgetScreenPosition(tabstrip->tabstrip_.get());
510 return screen_point.Subtract(tabstrip_screen_point);
511 } 509 }
512 510
513 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds( 511 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds(
514 const gfx::Point& screen_point) { 512 const gfx::Point& screen_point) {
515 gfx::Point client_point = 513 gfx::Point client_point =
516 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point); 514 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point);
517 gfx::Size tab_size = dragged_view_->attached_tab_size(); 515 gfx::Size tab_size = dragged_view_->attached_tab_size();
518 return gfx::Rect(client_point.x(), client_point.y(), 516 return gfx::Rect(client_point.x(), client_point.y(),
519 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height()); 517 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height());
520 } 518 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // 808 //
811 // We use the requested bounds instead of the allocation because the 809 // We use the requested bounds instead of the allocation because the
812 // allocation is relative to the first windowed widget ancestor of the tab. 810 // allocation is relative to the first windowed widget ancestor of the tab.
813 // Because of this, we can't use the tabs allocation to get the screen bounds. 811 // Because of this, we can't use the tabs allocation to get the screen bounds.
814 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents( 812 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents(
815 attached_tabstrip_); 813 attached_tabstrip_);
816 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back(); 814 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back();
817 gfx::Rect bounds = tab->GetRequisition(); 815 gfx::Rect bounds = tab->GetRequisition();
818 GtkWidget* widget = tab->widget(); 816 GtkWidget* widget = tab->widget();
819 GtkWidget* parent = gtk_widget_get_parent(widget); 817 GtkWidget* parent = gtk_widget_get_parent(widget);
820 gfx::Point point = ui::GetWidgetScreenPosition(parent); 818 bounds.Offset(ui::GetWidgetScreenOffset(parent));
821 bounds.Offset(point);
822 819
823 return gfx::Rect(bounds.x(), bounds.y(), 820 return gfx::Rect(bounds.x(), bounds.y(),
824 dragged_view_->GetTotalWidthInTabStrip(), bounds.height()); 821 dragged_view_->GetTotalWidthInTabStrip(), bounds.height());
825 } 822 }
826 823
827 void DraggedTabControllerGtk::HideWindow() { 824 void DraggedTabControllerGtk::HideWindow() {
828 GtkWidget* tabstrip = source_tabstrip_->widget(); 825 GtkWidget* tabstrip = source_tabstrip_->widget();
829 GtkWindow* window = platform_util::GetTopLevel(tabstrip); 826 GtkWindow* window = platform_util::GetTopLevel(tabstrip);
830 gtk_widget_hide(GTK_WIDGET(window)); 827 gtk_widget_hide(GTK_WIDGET(window));
831 } 828 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 887
891 bool DraggedTabControllerGtk::AreTabsConsecutive() { 888 bool DraggedTabControllerGtk::AreTabsConsecutive() {
892 for (size_t i = 1; i < drag_data_->size(); ++i) { 889 for (size_t i = 1; i < drag_data_->size(); ++i) {
893 if (drag_data_->get(i - 1)->source_model_index_ + 1 != 890 if (drag_data_->get(i - 1)->source_model_index_ + 1 !=
894 drag_data_->get(i)->source_model_index_) { 891 drag_data_->get(i)->source_model_index_) {
895 return false; 892 return false;
896 } 893 }
897 } 894 }
898 return true; 895 return true;
899 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698