summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 21:17:56 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 21:17:56 +0000
commit27c0d1e50248e9073671f5422ecc3feac306ca12 (patch)
tree75299691336ba0f5f4d5598b146fa5409c84b71d /chrome/browser
parent02830ae4bde4c83da26412e4d1d99ec57f78f8f5 (diff)
downloadchromium_src-27c0d1e50248e9073671f5422ecc3feac306ca12.zip
chromium_src-27c0d1e50248e9073671f5422ecc3feac306ca12.tar.gz
chromium_src-27c0d1e50248e9073671f5422ecc3feac306ca12.tar.bz2
gtk: Keep track of the tab bounds using the size-allocate signal. Previously we assumed that the tab was immediately sized as requested, which was not always happening. This fixes a problem seen in RTL layout where the close button would be incorrectly positioned.
BUG=16756 TEST=Open the browser in a RTL language. Notice that the close buttons on tabs are positioned correctly. Review URL: http://codereview.chromium.org/155942 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc28
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h8
2 files changed, 29 insertions, 7 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index a2d0d7f..5aacce4 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/gtk/tabs/tab_renderer_gtk.h"
+#include <algorithm>
+
#include "app/gfx/canvas_paint.h"
#include "app/gfx/favicon_size.h"
#include "app/l10n_util.h"
@@ -223,7 +225,9 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider)
tab_.Own(gtk_fixed_new());
gtk_widget_set_app_paintable(tab_.get(), TRUE);
g_signal_connect(G_OBJECT(tab_.get()), "expose-event",
- G_CALLBACK(OnExpose), this);
+ G_CALLBACK(OnExposeEvent), this);
+ g_signal_connect(G_OBJECT(tab_.get()), "size-allocate",
+ G_CALLBACK(OnSizeAllocate), this);
close_button_.reset(MakeCloseButton());
gtk_widget_show(tab_.get());
@@ -371,8 +375,6 @@ void TabRendererGtk::SetUnselectedTitleColor(SkColor color) {
void TabRendererGtk::SetBounds(const gfx::Rect& bounds) {
gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height());
- bounds_ = bounds;
- Layout();
}
////////////////////////////////////////////////////////////////////////////////
@@ -793,14 +795,30 @@ gboolean TabRendererGtk::OnCloseButtonMouseRelease(GtkWidget* widget,
}
// static
-gboolean TabRendererGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
- TabRendererGtk* tab) {
+gboolean TabRendererGtk::OnExposeEvent(GtkWidget* widget, GdkEventExpose* event,
+ TabRendererGtk* tab) {
tab->PaintTab(event);
gtk_container_propagate_expose(GTK_CONTAINER(tab->tab_.get()),
tab->close_button_->widget(), event);
return TRUE;
}
+// static
+void TabRendererGtk::OnSizeAllocate(GtkWidget* widget,
+ GtkAllocation* allocation,
+ TabRendererGtk* tab) {
+ gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y,
+ allocation->width, allocation->height);
+
+ // Nothing to do if the bounds are the same. If we don't catch this, we'll
+ // get an infinite loop of size-allocate signals.
+ if (tab->bounds_ == bounds)
+ return;
+
+ tab->bounds_ = bounds;
+ tab->Layout();
+}
+
void TabRendererGtk::OnMouseEntered() {
hover_animation_->SetTweenType(SlideAnimation::EASE_OUT);
hover_animation_->Show();
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 1e49259..c34a439 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -268,8 +268,12 @@ class TabRendererGtk : public AnimationDelegate {
TabRendererGtk* tab);
// expose-event handler that redraws the tab.
- static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e,
- TabRendererGtk* tab);
+ static gboolean OnExposeEvent(GtkWidget* widget, GdkEventExpose* event,
+ TabRendererGtk* tab);
+
+ // size-allocate handler used to update the current bounds of the tab.
+ static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation,
+ TabRendererGtk* tab);
// TODO(jhawkins): Move to TabResources.
static void InitResources();