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

Unified Diff: ui/views/view.cc

Issue 15912007: WIP - loop in LayoutManager for preferred size changes (2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix LabelTest Created 7 years, 7 months 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
« ui/views/controls/label_unittest.cc ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 0e12e14f494eed0172f426d2ca2986b44a24d97f..5931f77aa88ec3377238b0fd1392e5c723a8dd2a 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -163,6 +163,7 @@ const char View::kViewClassName[] = "views/View";
View::View()
: owned_by_client_(false),
+ weak_ptr_factory_(this),
id_(0),
group_(-1),
parent_(NULL),
@@ -596,8 +597,11 @@ 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();
+ // Schedule a layout
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&View::LayoutIfNeeded,
+ weak_ptr_factory_.GetWeakPtr()));
}
LayoutManager* View::GetLayoutManager() const {
@@ -1251,7 +1255,9 @@ 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() {
@@ -1822,6 +1828,11 @@ void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
// Size and disposition --------------------------------------------------------
+void View::LayoutIfNeeded() {
+ if (needs_layout_)
+ Layout();
+}
+
void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
for (int i = 0, count = child_count(); i < count; ++i)
child_at(i)->PropagateVisibilityNotifications(start, is_visible);
« ui/views/controls/label_unittest.cc ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698