From 99d5f339101b38d3f0cd921768e24029882d4f17 Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Tue, 3 Nov 2009 19:19:27 +0000 Subject: Convert tabcontentscontainer to use a vbox instead of a fixed. The comment in the code mentions that a vbox would cause a split screen, but looking at the code, it seems like that's not possible because we hide the old TCVG before adding new ones. These days the vbox contains all TCVGs and only shows one at a time (I think in the past we tried to remove them, but we don't have that problem now). This simplifies the code by not having to use our own size-allocate handler. Review URL: http://codereview.chromium.org/354018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30843 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/tab_contents_container_gtk.cc | 45 +++++------------------- chrome/browser/gtk/tab_contents_container_gtk.h | 17 ++------- 2 files changed, 11 insertions(+), 51 deletions(-) (limited to 'chrome/browser/gtk') diff --git a/chrome/browser/gtk/tab_contents_container_gtk.cc b/chrome/browser/gtk/tab_contents_container_gtk.cc index 9425194..c106ace 100644 --- a/chrome/browser/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/gtk/tab_contents_container_gtk.cc @@ -12,24 +12,6 @@ #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/common/notification_service.h" -namespace { - -// Allocates all normal tab contents views to the size of the passed in -// |allocation|. -void ResizeChildren(GtkWidget* widget, void* param) { - GtkAllocation* allocation = reinterpret_cast(param); - if (!GTK_WIDGET_VISIBLE(widget)) - return; - - if (widget->allocation.width != allocation->width || - widget->allocation.height != allocation->height) { - gtk_widget_set_size_request(widget, allocation->width, - allocation->height); - } -} - -} // namespace - TabContentsContainerGtk::TabContentsContainerGtk(StatusBubbleGtk* status_bubble) : tab_contents_(NULL), status_bubble_(status_bubble) { @@ -44,7 +26,7 @@ void TabContentsContainerGtk::Init() { // A high level overview of the TabContentsContainer: // // +- GtkFloatingContainer |floating_| -------------------------------+ - // |+- GtkFixedContainer |fixed_| -----------------------------------+| + // |+- GtkVBox |container_| -----------------------------------------+| // || || // || || // || || @@ -57,10 +39,8 @@ void TabContentsContainerGtk::Init() { floating_.Own(gtk_floating_container_new()); gtk_widget_set_name(floating_.get(), "chrome-tab-contents-container"); - fixed_ = gtk_fixed_new(); - g_signal_connect(fixed_, "size-allocate", - G_CALLBACK(OnFixedSizeAllocate), this); - gtk_container_add(GTK_CONTAINER(floating_.get()), fixed_); + container_ = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(floating_.get()), container_); if (status_bubble_) { gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()), @@ -69,7 +49,7 @@ void TabContentsContainerGtk::Init() { G_CALLBACK(OnSetFloatingPosition), this); } - gtk_widget_show(fixed_); + gtk_widget_show(container_); gtk_widget_show(floating_.get()); ViewIDUtil::SetDelegateForWidget(widget(), this); @@ -105,8 +85,8 @@ void TabContentsContainerGtk::SetTabContents(TabContents* tab_contents) { gfx::NativeView widget = tab_contents_->GetNativeView(); if (widget) { - if (widget->parent != fixed_) - gtk_fixed_put(GTK_FIXED(fixed_), widget, 0, 0); + if (widget->parent != container_) + gtk_container_add(GTK_CONTAINER(container_), widget); gtk_widget_show(widget); } @@ -127,8 +107,8 @@ void TabContentsContainerGtk::DetachTabContents(TabContents* tab_contents) { // It is possible to detach an unrealized, unparented TabContents if you // slow things down enough in valgrind. Might happen in the real world, too. if (widget && widget->parent) { - DCHECK_EQ(widget->parent, fixed_); - gtk_container_remove(GTK_CONTAINER(fixed_), widget); + DCHECK_EQ(widget->parent, container_); + gtk_container_remove(GTK_CONTAINER(container_), widget); } } @@ -176,15 +156,6 @@ GtkWidget* TabContentsContainerGtk::GetWidgetForViewID(ViewID view_id) { // ----------------------------------------------------------------------------- // static -void TabContentsContainerGtk::OnFixedSizeAllocate( - GtkWidget* fixed, - GtkAllocation* allocation, - TabContentsContainerGtk* container) { - // Set all the tab contents GtkWidgets to the size of the allocation. - gtk_container_foreach(GTK_CONTAINER(fixed), ResizeChildren, allocation); -} - -// static void TabContentsContainerGtk::OnSetFloatingPosition( GtkFloatingContainer* floating_container, GtkAllocation* allocation, TabContentsContainerGtk* tab_contents_container) { diff --git a/chrome/browser/gtk/tab_contents_container_gtk.h b/chrome/browser/gtk/tab_contents_container_gtk.h index 8a7a8c7..6e1ad2a 100644 --- a/chrome/browser/gtk/tab_contents_container_gtk.h +++ b/chrome/browser/gtk/tab_contents_container_gtk.h @@ -58,15 +58,6 @@ class TabContentsContainerGtk : public NotificationObserver, // get notified. void TabContentsDestroyed(TabContents* contents); - // Implements our hack around a GtkFixed. The entire size of the GtkFixed is - // allocated to normal tab contents views, while the status bubble is - // informed of its parent and its parent's allocation (it makes a decision - // about layout later.) - static void OnFixedSizeAllocate( - GtkWidget* fixed, - GtkAllocation* allocation, - TabContentsContainerGtk* container); - // Handler for |floating_|'s "set-floating-position" signal. During this // callback, we manually set the position of the status bubble. static void OnSetFloatingPosition( @@ -87,11 +78,9 @@ class TabContentsContainerGtk : public NotificationObserver, // their positions manually set in OnSetFloatingPosition. OwnedWidgetGtk floating_; - // We insert and remove TabContents GtkWidgets into this fixed_. This should - // not be a GtkVBox since there were errors with timing where the vbox was - // horizontally split with the top half displaying the current TabContents - // and bottom half displaying the loading page. - GtkWidget* fixed_; + // We insert TabContentsViewGtks into this container_. We only show one + // TabVontentsViewGtk at a time, so we can use a vbox or an hbox. + GtkWidget* container_; DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); }; -- cgit v1.1