diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:14:40 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:14:40 +0000 |
commit | 08f23881c6af14f034785bb6713b13d0898659e7 (patch) | |
tree | 96d6fe186415daa13c7913fd3fc07fc33b18e12e /chrome/browser/tab_contents | |
parent | 85da56ff2ecbb7806a1de8edcc2c76a9461b378d (diff) | |
download | chromium_src-08f23881c6af14f034785bb6713b13d0898659e7.zip chromium_src-08f23881c6af14f034785bb6713b13d0898659e7.tar.gz chromium_src-08f23881c6af14f034785bb6713b13d0898659e7.tar.bz2 |
[GTK] adjust GtkFloatingContainer child allocation calculation.
Offset the floating child position coordinates by the container's allocation. This prevents floating children from attempting to position themselves outside the floating container.
BUG=52595
TEST=see bug
Review URL: http://codereview.chromium.org/3424009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59658 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.cc | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index e3f5a65..d195ca8 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -383,28 +383,27 @@ void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget, void TabContentsViewGtk::OnSetFloatingPosition( GtkWidget* floating_container, GtkAllocation* allocation) { + if (!constrained_window_) + return; + // Place each ConstrainedWindow in the center of the view. - int half_view_width = std::max((allocation->x + allocation->width) / 2, 0); - int half_view_height = std::max((allocation->y + allocation->height) / 2, 0); - if (constrained_window_) { - GtkWidget* widget = constrained_window_->widget(); - DCHECK(widget->parent == floating_.get()); + GtkWidget* widget = constrained_window_->widget(); + DCHECK(widget->parent == floating_.get()); - GtkRequisition requisition; - gtk_widget_size_request(widget, &requisition); + GtkRequisition requisition; + gtk_widget_size_request(widget, &requisition); - GValue value = { 0, }; - g_value_init(&value, G_TYPE_INT); + GValue value = { 0, }; + g_value_init(&value, G_TYPE_INT); - int child_x = std::max(half_view_width - (requisition.width / 2), 0); - g_value_set_int(&value, child_x); - gtk_container_child_set_property(GTK_CONTAINER(floating_container), - widget, "x", &value); + int child_x = std::max((allocation->width - requisition.width) / 2, 0); + g_value_set_int(&value, child_x); + gtk_container_child_set_property(GTK_CONTAINER(floating_container), + widget, "x", &value); - int child_y = std::max(half_view_height - (requisition.height / 2), 0); - g_value_set_int(&value, child_y); - gtk_container_child_set_property(GTK_CONTAINER(floating_container), - widget, "y", &value); - g_value_unset(&value); - } + int child_y = std::max((allocation->height - requisition.height) / 2, 0); + g_value_set_int(&value, child_y); + gtk_container_child_set_property(GTK_CONTAINER(floating_container), + widget, "y", &value); + g_value_unset(&value); } |