Index: ui/views/view.cc |
diff --git a/ui/views/view.cc b/ui/views/view.cc |
index 0e12e14f494eed0172f426d2ca2986b44a24d97f..48e1b1eb9372cc1571c69ff0b5fd828e44ef107a 100644 |
--- a/ui/views/view.cc |
+++ b/ui/views/view.cc |
@@ -156,6 +156,15 @@ ViewsDelegate* ViewsDelegate::views_delegate = NULL; |
// static |
const char View::kViewClassName[] = "views/View"; |
+ScopedMaybeLayout::ScopedMaybeLayout(views::View* view) : view_(view) { |
+ view_->InvalidateLayout(); |
+} |
+ |
+ScopedMaybeLayout::~ScopedMaybeLayout() { |
+ if (view_->needs_layout_) |
+ view_->Layout(); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// View, public: |
@@ -596,8 +605,8 @@ void View::InvalidateLayout() { |
// Always invalidate up. This is needed to handle the case of us already being |
// valid, but not our parent. |
needs_layout_ = true; |
- if (parent_) |
- parent_->InvalidateLayout(); |
+// if (parent_) |
+// parent_->InvalidateLayout(); |
} |
LayoutManager* View::GetLayoutManager() const { |
@@ -1251,13 +1260,18 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view, |
// Size and disposition -------------------------------------------------------- |
-void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
+void View::ChildPreferredSizeChanged(View* child) { |
+ if (layout_manager_) |
+ layout_manager_->OnChildPreferredSizeChanged(this, child); |
} |
void View::PreferredSizeChanged() { |
- InvalidateLayout(); |
+ ScopedMaybeLayout layout(this); |
+// InvalidateLayout(); |
if (parent_) |
parent_->ChildPreferredSizeChanged(this); |
+// if (needs_layout_) |
+// Layout(); |
} |
bool View::NeedsNotificationWhenVisibleBoundsChange() const { |