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

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: rebasefinal 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 gfx::Vector2d tabstrip_screen_offset =
509 ui::GetWidgetScreenPosition(tabstrip->tabstrip_.get()); 509 ui::GetWidgetScreenOffset(tabstrip->tabstrip_.get());
510 return screen_point.Subtract(tabstrip_screen_point); 510 return screen_point.Subtract(tabstrip_screen_offset);
511 } 511 }
512 512
513 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds( 513 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds(
514 const gfx::Point& screen_point) { 514 const gfx::Point& screen_point) {
515 gfx::Point client_point = 515 gfx::Point client_point =
516 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point); 516 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point);
517 gfx::Size tab_size = dragged_view_->attached_tab_size(); 517 gfx::Size tab_size = dragged_view_->attached_tab_size();
518 return gfx::Rect(client_point.x(), client_point.y(), 518 return gfx::Rect(client_point.x(), client_point.y(),
519 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height()); 519 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height());
520 } 520 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // 810 //
811 // We use the requested bounds instead of the allocation because the 811 // We use the requested bounds instead of the allocation because the
812 // allocation is relative to the first windowed widget ancestor of the tab. 812 // 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. 813 // Because of this, we can't use the tabs allocation to get the screen bounds.
814 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents( 814 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents(
815 attached_tabstrip_); 815 attached_tabstrip_);
816 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back(); 816 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back();
817 gfx::Rect bounds = tab->GetRequisition(); 817 gfx::Rect bounds = tab->GetRequisition();
818 GtkWidget* widget = tab->widget(); 818 GtkWidget* widget = tab->widget();
819 GtkWidget* parent = gtk_widget_get_parent(widget); 819 GtkWidget* parent = gtk_widget_get_parent(widget);
820 gfx::Point point = ui::GetWidgetScreenPosition(parent); 820 gfx::Vector2d offset = ui::GetWidgetScreenOffset(parent);
danakj 2012/10/29 19:17:20 inlined
821 bounds.Offset(point); 821 bounds.Offset(offset);
822 822
823 return gfx::Rect(bounds.x(), bounds.y(), 823 return gfx::Rect(bounds.x(), bounds.y(),
824 dragged_view_->GetTotalWidthInTabStrip(), bounds.height()); 824 dragged_view_->GetTotalWidthInTabStrip(), bounds.height());
825 } 825 }
826 826
827 void DraggedTabControllerGtk::HideWindow() { 827 void DraggedTabControllerGtk::HideWindow() {
828 GtkWidget* tabstrip = source_tabstrip_->widget(); 828 GtkWidget* tabstrip = source_tabstrip_->widget();
829 GtkWindow* window = platform_util::GetTopLevel(tabstrip); 829 GtkWindow* window = platform_util::GetTopLevel(tabstrip);
830 gtk_widget_hide(GTK_WIDGET(window)); 830 gtk_widget_hide(GTK_WIDGET(window));
831 } 831 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 bool DraggedTabControllerGtk::AreTabsConsecutive() { 891 bool DraggedTabControllerGtk::AreTabsConsecutive() {
892 for (size_t i = 1; i < drag_data_->size(); ++i) { 892 for (size_t i = 1; i < drag_data_->size(); ++i) {
893 if (drag_data_->get(i - 1)->source_model_index_ + 1 != 893 if (drag_data_->get(i - 1)->source_model_index_ + 1 !=
894 drag_data_->get(i)->source_model_index_) { 894 drag_data_->get(i)->source_model_index_) {
895 return false; 895 return false;
896 } 896 }
897 } 897 }
898 return true; 898 return true;
899 } 899 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698