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/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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 499 |
500 // Detaching resets the delegate, but we still want to be the delegate. | 500 // Detaching resets the delegate, but we still want to be the delegate. |
501 for (size_t i = 0; i < drag_data_->size(); ++i) | 501 for (size_t i = 0; i < drag_data_->size(); ++i) |
502 drag_data_->get(i)->contents_->web_contents()->SetDelegate(this); | 502 drag_data_->get(i)->contents_->web_contents()->SetDelegate(this); |
503 | 503 |
504 attached_tabstrip_ = NULL; | 504 attached_tabstrip_ = NULL; |
505 } | 505 } |
506 | 506 |
507 gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint( | 507 gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint( |
508 TabStripGtk* tabstrip, const gfx::Point& screen_point) { | 508 TabStripGtk* tabstrip, const gfx::Point& screen_point) { |
509 gfx::Point tabstrip_screen_point = | 509 return screen_point - ui::GetWidgetScreenOffset(tabstrip->tabstrip_.get()); |
510 ui::GetWidgetScreenPosition(tabstrip->tabstrip_.get()); | |
511 return screen_point.Subtract(tabstrip_screen_point); | |
512 } | 510 } |
513 | 511 |
514 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds( | 512 gfx::Rect DraggedTabControllerGtk::GetDraggedViewTabStripBounds( |
515 const gfx::Point& screen_point) { | 513 const gfx::Point& screen_point) { |
516 gfx::Point client_point = | 514 gfx::Point client_point = |
517 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point); | 515 ConvertScreenPointToTabStripPoint(attached_tabstrip_, screen_point); |
518 gfx::Size tab_size = dragged_view_->attached_tab_size(); | 516 gfx::Size tab_size = dragged_view_->attached_tab_size(); |
519 return gfx::Rect(client_point.x(), client_point.y(), | 517 return gfx::Rect(client_point.x(), client_point.y(), |
520 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height()); | 518 dragged_view_->GetTotalWidthInTabStrip(), tab_size.height()); |
521 } | 519 } |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 // | 809 // |
812 // We use the requested bounds instead of the allocation because the | 810 // We use the requested bounds instead of the allocation because the |
813 // allocation is relative to the first windowed widget ancestor of the tab. | 811 // allocation is relative to the first windowed widget ancestor of the tab. |
814 // Because of this, we can't use the tabs allocation to get the screen bounds. | 812 // Because of this, we can't use the tabs allocation to get the screen bounds. |
815 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents( | 813 std::vector<TabGtk*> tabs = GetTabsMatchingDraggedContents( |
816 attached_tabstrip_); | 814 attached_tabstrip_); |
817 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back(); | 815 TabGtk* tab = !base::i18n::IsRTL() ? tabs.front() : tabs.back(); |
818 gfx::Rect bounds = tab->GetRequisition(); | 816 gfx::Rect bounds = tab->GetRequisition(); |
819 GtkWidget* widget = tab->widget(); | 817 GtkWidget* widget = tab->widget(); |
820 GtkWidget* parent = gtk_widget_get_parent(widget); | 818 GtkWidget* parent = gtk_widget_get_parent(widget); |
821 gfx::Point point = ui::GetWidgetScreenPosition(parent); | 819 bounds.Offset(ui::GetWidgetScreenOffset(parent)); |
822 bounds.Offset(point); | |
823 | 820 |
824 return gfx::Rect(bounds.x(), bounds.y(), | 821 return gfx::Rect(bounds.x(), bounds.y(), |
825 dragged_view_->GetTotalWidthInTabStrip(), bounds.height()); | 822 dragged_view_->GetTotalWidthInTabStrip(), bounds.height()); |
826 } | 823 } |
827 | 824 |
828 void DraggedTabControllerGtk::HideWindow() { | 825 void DraggedTabControllerGtk::HideWindow() { |
829 GtkWidget* tabstrip = source_tabstrip_->widget(); | 826 GtkWidget* tabstrip = source_tabstrip_->widget(); |
830 GtkWindow* window = platform_util::GetTopLevel(tabstrip); | 827 GtkWindow* window = platform_util::GetTopLevel(tabstrip); |
831 gtk_widget_hide(GTK_WIDGET(window)); | 828 gtk_widget_hide(GTK_WIDGET(window)); |
832 } | 829 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 | 889 |
893 bool DraggedTabControllerGtk::AreTabsConsecutive() { | 890 bool DraggedTabControllerGtk::AreTabsConsecutive() { |
894 for (size_t i = 1; i < drag_data_->size(); ++i) { | 891 for (size_t i = 1; i < drag_data_->size(); ++i) { |
895 if (drag_data_->get(i - 1)->source_model_index_ + 1 != | 892 if (drag_data_->get(i - 1)->source_model_index_ + 1 != |
896 drag_data_->get(i)->source_model_index_) { | 893 drag_data_->get(i)->source_model_index_) { |
897 return false; | 894 return false; |
898 } | 895 } |
899 } | 896 } |
900 return true; | 897 return true; |
901 } | 898 } |
OLD | NEW |