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

Unified Diff: ui/views/view.cc

Issue 2713643002: Add View::AddedToWidget and RemovedFromWidget. (Closed)
Patch Set: Review fixes. Created 3 years, 10 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
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 04c5f2fae25957c3ca3b706654e263fc8b3c6638..529867365d987c4c8bce6daa0c0734ef272aecf0 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -1516,6 +1516,10 @@ void View::NativeViewHierarchyChanged() {
}
}
+void View::AddedToWidget() {}
+
+void View::RemovedFromWidget() {}
+
// Painting --------------------------------------------------------------------
void View::PaintChildren(const ui::PaintContext& context) {
@@ -2012,6 +2016,20 @@ void View::ViewHierarchyChangedImpl(
}
ViewHierarchyChanged(details);
+
+ if (details.is_add) {
+ const auto widget = GetWidget();
+ if (widget != nullptr && widget != attached_widget_) {
+ attached_widget_ = widget;
+ AddedToWidget();
+ }
+ } else if (details.child == this) {
+ if (attached_widget_) {
+ RemovedFromWidget();
+ attached_widget_ = nullptr;
+ }
+ }
+
details.parent->needs_layout_ = true;
}
« ui/views/view.h ('K') | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698