diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 21:27:23 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 21:27:23 +0000 |
commit | 48af406a5dc13be98bfef6c902843875399f1033 (patch) | |
tree | b676b12697276f11f9de767bf19174f30b27740a /chrome/browser | |
parent | 5318be8f3c27813755e08f759ed19809bc965a86 (diff) | |
download | chromium_src-48af406a5dc13be98bfef6c902843875399f1033.zip chromium_src-48af406a5dc13be98bfef6c902843875399f1033.tar.gz chromium_src-48af406a5dc13be98bfef6c902843875399f1033.tar.bz2 |
Revert "Convert tabcontentscontainer to use a vbox instead of a fixed. The"
This reverts commit r30843.
This broke the findbar/download shelf animation optimization. I
originally was doing this as part of fixing issue 26495, but I
found a different way.
TBR=estade
Review URL: http://codereview.chromium.org/366009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/tab_contents_container_gtk.cc | 45 | ||||
-rw-r--r-- | chrome/browser/gtk/tab_contents_container_gtk.h | 17 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.cc | 2 |
3 files changed, 53 insertions, 11 deletions
diff --git a/chrome/browser/gtk/tab_contents_container_gtk.cc b/chrome/browser/gtk/tab_contents_container_gtk.cc index c106ace..9425194 100644 --- a/chrome/browser/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/gtk/tab_contents_container_gtk.cc @@ -12,6 +12,24 @@ #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<GtkAllocation*>(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) { @@ -26,7 +44,7 @@ void TabContentsContainerGtk::Init() { // A high level overview of the TabContentsContainer: // // +- GtkFloatingContainer |floating_| -------------------------------+ - // |+- GtkVBox |container_| -----------------------------------------+| + // |+- GtkFixedContainer |fixed_| -----------------------------------+| // || || // || || // || || @@ -39,8 +57,10 @@ void TabContentsContainerGtk::Init() { floating_.Own(gtk_floating_container_new()); gtk_widget_set_name(floating_.get(), "chrome-tab-contents-container"); - container_ = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(floating_.get()), container_); + fixed_ = gtk_fixed_new(); + g_signal_connect(fixed_, "size-allocate", + G_CALLBACK(OnFixedSizeAllocate), this); + gtk_container_add(GTK_CONTAINER(floating_.get()), fixed_); if (status_bubble_) { gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()), @@ -49,7 +69,7 @@ void TabContentsContainerGtk::Init() { G_CALLBACK(OnSetFloatingPosition), this); } - gtk_widget_show(container_); + gtk_widget_show(fixed_); gtk_widget_show(floating_.get()); ViewIDUtil::SetDelegateForWidget(widget(), this); @@ -85,8 +105,8 @@ void TabContentsContainerGtk::SetTabContents(TabContents* tab_contents) { gfx::NativeView widget = tab_contents_->GetNativeView(); if (widget) { - if (widget->parent != container_) - gtk_container_add(GTK_CONTAINER(container_), widget); + if (widget->parent != fixed_) + gtk_fixed_put(GTK_FIXED(fixed_), widget, 0, 0); gtk_widget_show(widget); } @@ -107,8 +127,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, container_); - gtk_container_remove(GTK_CONTAINER(container_), widget); + DCHECK_EQ(widget->parent, fixed_); + gtk_container_remove(GTK_CONTAINER(fixed_), widget); } } @@ -156,6 +176,15 @@ 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 6e1ad2a..8a7a8c7 100644 --- a/chrome/browser/gtk/tab_contents_container_gtk.h +++ b/chrome/browser/gtk/tab_contents_container_gtk.h @@ -58,6 +58,15 @@ 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( @@ -78,9 +87,11 @@ class TabContentsContainerGtk : public NotificationObserver, // their positions manually set in OnSetFloatingPosition. OwnedWidgetGtk floating_; - // 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_; + // 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_; DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); }; diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index 715d573..a51aa10 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -398,6 +398,8 @@ gboolean TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget, TabContentsViewGtk* view) { int width = allocation->width; int height = allocation->height; + view->requested_size_.set_width(width); + view->requested_size_.set_height(height); // |delegate()| can be NULL here during browser teardown. if (view->tab_contents()->delegate()) height += view->tab_contents()->delegate()->GetExtraRenderViewHeight(); |