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