summaryrefslogtreecommitdiffstats
path: root/views/view.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 08:19:05 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 08:19:05 +0000
commit9ea053e87d2141867ee3429d8917809fe2e33c80 (patch)
tree1e3131c3d6ed6bc867973089241546f8fa179a72 /views/view.cc
parent5643766f0fed86c472d22827c41e5b436a70e1e0 (diff)
downloadchromium_src-9ea053e87d2141867ee3429d8917809fe2e33c80.zip
chromium_src-9ea053e87d2141867ee3429d8917809fe2e33c80.tar.gz
chromium_src-9ea053e87d2141867ee3429d8917809fe2e33c80.tar.bz2
Relayout content pref page properly upon sync status changes.
This fixes a layouting problem that resulted in the "Stop syncing this account" button not being sized properly after setting up sync. BUG=48807 TEST=Open options dialog in non-synced state, configure sync, check "Stop syncing this account" button after setup. Review URL: http://codereview.chromium.org/2980005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view.cc')
-rw-r--r--views/view.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/views/view.cc b/views/view.cc
index 69cf67f..4ae7bef 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -56,6 +56,7 @@ View::View()
focusable_(false),
accessibility_focusable_(false),
bounds_(0, 0, 0, 0),
+ needs_layout_(true),
parent_(NULL),
is_visible_(true),
is_parent_owned_(true),
@@ -165,6 +166,7 @@ void View::SizeToPreferredSize() {
}
void View::PreferredSizeChanged() {
+ InvalidateLayout();
if (parent_)
parent_->ChildPreferredSizeChanged(this);
}
@@ -181,6 +183,7 @@ int View::GetHeightForWidth(int w) {
void View::DidChangeBounds(const gfx::Rect& previous,
const gfx::Rect& current) {
+ needs_layout_ = false;
Layout();
}
@@ -203,20 +206,37 @@ void View::ScrollRectToVisible(const gfx::Rect& rect) {
/////////////////////////////////////////////////////////////////////////////
void View::Layout() {
+ needs_layout_ = false;
+
// If we have a layout manager, let it handle the layout for us.
if (layout_manager_.get()) {
layout_manager_->Layout(this);
SchedulePaint();
- return;
}
- // Otherwise, just pass on to the child views.
+ // Make sure to propagate the Layout() call to any children that haven't
+ // received it yet through the layout manager and need to be laid out. This
+ // is needed for the case when the child requires a layout but its bounds
+ // weren't changed by the layout manager. If there is no layout manager, we
+ // just propagate the Layout() call down the hierarchy, so whoever receives
+ // the call can take appropriate action.
for (int i = 0, count = GetChildViewCount(); i < count; ++i) {
View* child = GetChildViewAt(i);
- child->Layout();
+ if (child->needs_layout_ || !layout_manager_.get()) {
+ child->needs_layout_ = false;
+ child->Layout();
+ }
}
}
+void View::InvalidateLayout() {
+ if (needs_layout_)
+ return;
+ needs_layout_ = true;
+ if (parent_)
+ parent_->InvalidateLayout();
+}
+
LayoutManager* View::GetLayoutManager() const {
return layout_manager_.get();
}
@@ -705,6 +725,7 @@ void View::ViewHierarchyChangedImpl(bool register_accelerators,
}
ViewHierarchyChanged(is_add, parent, child);
+ parent->needs_layout_ = true;
}
void View::PropagateVisibilityNotifications(View* start, bool is_visible) {