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

Unified Diff: ui/views/view.cc

Issue 2713643002: Add View::AddedToWidget and RemovedFromWidget. (Closed)
Patch Set: 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..dfe0cc98741cfe36f7ad893aff37f54def0a7170 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -1501,6 +1501,18 @@ void View::OnVisibleBoundsChanged() {
// Tree operations -------------------------------------------------------------
void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& 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;
+ }
+ }
}
void View::VisibilityChanged(View* starting_from, bool is_visible) {
@@ -1516,6 +1528,10 @@ void View::NativeViewHierarchyChanged() {
}
}
+void View::AddedToWidget() {}
+
+void View::RemovedFromWidget() {}
+
// Painting --------------------------------------------------------------------
void View::PaintChildren(const ui::PaintContext& context) {
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | ui/views/view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698