Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Unified Diff: chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc

Issue 8568026: GTK: Always relayout the tab strip when the tab strip bounds change. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: coalesce calls Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
index 9692b73e517065a1b9720d1d3d5a6b6c6b2db8c4..fe528fef364598594296f9de0959bf6235d1bc11 100644
--- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
@@ -55,6 +55,10 @@ const int kNewTabButtonVOffset = 5;
// is started.
const int kResizeTabsTimeMs = 300;
+// A very short time just to make sure we don't clump up our Layout() calls
+// during slow window resizes.
+const int kLayoutAfterSizeAllocateMs = 10;
+
// The range outside of the tabstrip where the pointer must enter/leave to
// start/stop the resize animation.
const int kTabStripAnimationVSlop = 40;
@@ -706,6 +710,7 @@ TabStripGtk::TabStripGtk(TabStripModel* model, BrowserWindowGtk* window)
window_(window),
theme_service_(GtkThemeService::GetFrom(model->profile())),
weak_factory_(this),
+ layout_factory_(this),
added_as_message_loop_observer_(false),
hover_tab_selector_(model) {
}
@@ -1556,6 +1561,7 @@ int TabStripGtk::tab_start_x() const {
bool TabStripGtk::ResizeLayoutTabs() {
weak_factory_.InvalidateWeakPtrs();
+ layout_factory_.InvalidateWeakPtrs();
// It is critically important that this is unhooked here, otherwise we will
// keep spying on messages forever.
@@ -1623,7 +1629,6 @@ void TabStripGtk::ReStack() {
active_tab->Raise();
}
-
void TabStripGtk::AddMessageLoopObserver() {
if (!added_as_message_loop_observer_) {
MessageLoopForUI::current()->AddObserver(this);
@@ -2081,10 +2086,16 @@ void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
return;
// When there is only one tab, Layout() so we don't animate it. With more
- // tabs, do ResizeLayoutTabs(). In RTL(), we will also need to manually
- // Layout() when ResizeLayoutTabs() is a no-op.
- if ((GetTabCount() == 1) || (!ResizeLayoutTabs() && base::i18n::IsRTL()))
+ // tabs, we should always attempt a resize unless we already have one coming
+ // up in our message loop.
+ if (GetTabCount() == 1) {
Layout();
+ } else if (!layout_factory_.HasWeakPtrs()) {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&TabStripGtk::Layout, layout_factory_.GetWeakPtr()),
+ kLayoutAfterSizeAllocateMs);
+ }
}
gboolean TabStripGtk::OnDragMotion(GtkWidget* widget, GdkDragContext* context,
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698