Index: ui/views/view.h |
diff --git a/ui/views/view.h b/ui/views/view.h |
index fcbee85c1bf2155eef7639c5b96e75c6980c1b4f..2b8c67a42c42094e4c7989b558ab6104ab3a733c 100644 |
--- a/ui/views/view.h |
+++ b/ui/views/view.h |
@@ -1096,10 +1096,11 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
// view and all parents. |
// |
// When a view is added, a notification is sent to the view, all its |
- // parents, and all its children (and grand children) |
+ // parents, and all its children (and grand children). |
// |
- // Default implementation does nothing. Override to perform operations |
- // required when a view is added or removed from a view hierarchy |
+ // Default implementation calls AddedToWidget and RemovedFromWidget. |
+ // Override to perform operations required when a view is added or |
+ // removed from a view hierarchy. |
// |
// Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. |
virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); |
@@ -1116,6 +1117,14 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
// FocusManager manages this view. |
virtual void NativeViewHierarchyChanged(); |
+ // This method is invoked for a view when it is attached to a hierarchy with |
+ // a widget, i.e. GetWidget() starts returning a non-null result. |
+ virtual void AddedToWidget(); |
+ |
+ // This method is invoked for a view when it is removed from a hierarchy with |
+ // a widget. |
+ virtual void RemovedFromWidget(); |
+ |
// Painting ------------------------------------------------------------------ |
// Responsible for calling Paint() on child Views. Override to control the |
@@ -1491,6 +1500,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
// This view's children. |
Views children_; |
+ // The widget this view is (possibily indirectly) attached to. |
+ Widget* attached_widget_; |
+ |
#if DCHECK_IS_ON() |
// True while iterating over |children_|. Used to detect and DCHECK when |
// |children_| is mutated during iteration. |