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

Side by Side Diff: chrome/browser/gtk/tabs/tab_strip_gtk.cc

Issue 372068: Removes TabStrip::CanUpdateDisplay as it lead to crashes on the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/gtk_dnd_util.h" 9 #include "app/gtk_dnd_util.h"
10 #include "app/gfx/canvas_paint.h" 10 #include "app/gfx/canvas_paint.h"
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 // We added the tab at 0x0, we need to force an animation step otherwise 957 // We added the tab at 0x0, we need to force an animation step otherwise
958 // if GTK paints before the animation event the tab is painted at 0x0 958 // if GTK paints before the animation event the tab is painted at 0x0
959 // which is most likely not where it should be positioned. 959 // which is most likely not where it should be positioned.
960 active_animation_->AnimationProgressed(NULL); 960 active_animation_->AnimationProgressed(NULL);
961 } else { 961 } else {
962 Layout(); 962 Layout();
963 } 963 }
964 } 964 }
965 965
966 void TabStripGtk::TabDetachedAt(TabContents* contents, int index) { 966 void TabStripGtk::TabDetachedAt(TabContents* contents, int index) {
967 if (CanUpdateDisplay()) { 967 GenerateIdealBounds();
968 GenerateIdealBounds(); 968 StartRemoveTabAnimation(index, contents);
969 StartRemoveTabAnimation(index, contents); 969 // Have to do this _after_ calling StartRemoveTabAnimation, so that any
970 // Have to do this _after_ calling StartRemoveTabAnimation, so that any 970 // previous remove is completed fully and index is valid in sync with the
971 // previous remove is completed fully and index is valid in sync with the 971 // model index.
972 // model index. 972 GetTabAt(index)->set_closing(true);
973 GetTabAt(index)->set_closing(true);
974 }
975 } 973 }
976 974
977 void TabStripGtk::TabSelectedAt(TabContents* old_contents, 975 void TabStripGtk::TabSelectedAt(TabContents* old_contents,
978 TabContents* new_contents, 976 TabContents* new_contents,
979 int index, 977 int index,
980 bool user_gesture) { 978 bool user_gesture) {
981 DCHECK(index >= 0 && index < static_cast<int>(GetTabCount())); 979 DCHECK(index >= 0 && index < static_cast<int>(GetTabCount()));
982 980
983 if (CanUpdateDisplay()) { 981 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are
984 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are 982 // a different size to the selected ones.
985 // a different size to the selected ones. 983 bool tiny_tabs = current_unselected_width_ != current_selected_width_;
986 bool tiny_tabs = current_unselected_width_ != current_selected_width_; 984 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs))
987 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) 985 Layout();
988 Layout();
989 986
990 GetTabAt(index)->SchedulePaint(); 987 GetTabAt(index)->SchedulePaint();
991 988
992 int old_index = model_->GetIndexOfTabContents(old_contents); 989 int old_index = model_->GetIndexOfTabContents(old_contents);
993 if (old_index >= 0) { 990 if (old_index >= 0) {
994 GetTabAt(old_index)->SchedulePaint(); 991 GetTabAt(old_index)->SchedulePaint();
995 GetTabAt(old_index)->StopPinnedTabTitleAnimation(); 992 GetTabAt(old_index)->StopPinnedTabTitleAnimation();
996 }
997 } 993 }
998 } 994 }
999 995
1000 void TabStripGtk::TabMoved(TabContents* contents, 996 void TabStripGtk::TabMoved(TabContents* contents,
1001 int from_index, 997 int from_index,
1002 int to_index, 998 int to_index,
1003 bool pinned_state_changed) { 999 bool pinned_state_changed) {
1004 gfx::Rect start_bounds = GetIdealBounds(from_index); 1000 gfx::Rect start_bounds = GetIdealBounds(from_index);
1005 TabGtk* tab = GetTabAt(from_index); 1001 TabGtk* tab = GetTabAt(from_index);
1006 tab_data_.erase(tab_data_.begin() + from_index); 1002 tab_data_.erase(tab_data_.begin() + from_index);
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 void TabStripGtk::StartPinAndMoveTabAnimation(int from_index, 1767 void TabStripGtk::StartPinAndMoveTabAnimation(int from_index,
1772 int to_index, 1768 int to_index,
1773 const gfx::Rect& start_bounds) { 1769 const gfx::Rect& start_bounds) {
1774 if (active_animation_.get()) 1770 if (active_animation_.get())
1775 active_animation_->Stop(); 1771 active_animation_->Stop();
1776 active_animation_.reset( 1772 active_animation_.reset(
1777 new PinAndMoveAnimation(this, from_index, to_index, start_bounds)); 1773 new PinAndMoveAnimation(this, from_index, to_index, start_bounds));
1778 active_animation_->Start(); 1774 active_animation_->Start();
1779 } 1775 }
1780 1776
1781 bool TabStripGtk::CanUpdateDisplay() {
1782 // Don't bother laying out/painting when we're closing all tabs.
1783 if (model_->closing_all()) {
1784 // Make sure any active animation is ended, too.
1785 if (active_animation_.get())
1786 active_animation_->Stop();
1787 return false;
1788 }
1789 return true;
1790 }
1791
1792 void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation, 1777 void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation,
1793 bool layout) { 1778 bool layout) {
1794 active_animation_.reset(NULL); 1779 active_animation_.reset(NULL);
1795 1780
1796 // Reset the animation state of each tab. 1781 // Reset the animation state of each tab.
1797 for (int i = 0, count = GetTabCount(); i < count; ++i) 1782 for (int i = 0, count = GetTabCount(); i < count; ++i)
1798 GetTabAt(i)->set_animating_pinned_change(false); 1783 GetTabAt(i)->set_animating_pinned_change(false);
1799 1784
1800 if (layout) 1785 if (layout)
1801 Layout(); 1786 Layout();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2025
2041 // Let the middle mouse button initiate clicks as well. 2026 // Let the middle mouse button initiate clicks as well.
2042 gtk_util::SetButtonTriggersNavigation(button->widget()); 2027 gtk_util::SetButtonTriggersNavigation(button->widget());
2043 g_signal_connect(G_OBJECT(button->widget()), "clicked", 2028 g_signal_connect(G_OBJECT(button->widget()), "clicked",
2044 G_CALLBACK(OnNewTabClicked), this); 2029 G_CALLBACK(OnNewTabClicked), this);
2045 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); 2030 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS);
2046 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); 2031 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0);
2047 2032
2048 return button; 2033 return button;
2049 } 2034 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698