Chromium Code Reviews| Index: ui/views/view.h |
| diff --git a/ui/views/view.h b/ui/views/view.h |
| index fcbee85c1bf2155eef7639c5b96e75c6980c1b4f..d4868e6092bedee91fd9913049deb1ca7f88cce5 100644 |
| --- a/ui/views/view.h |
| +++ b/ui/views/view.h |
| @@ -1116,6 +1116,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 |
| @@ -1308,7 +1316,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
| void PropagateNativeViewHierarchyChanged(); |
| // Takes care of registering/unregistering accelerators if |
| - // |register_accelerators| true and calls ViewHierarchyChanged(). |
| + // |register_accelerators| true, calls ViewHierarchyChanged() and |
| + // AddedToWidget() or RemovedFromWidget() if necessary. |
| void ViewHierarchyChangedImpl(bool register_accelerators, |
| const ViewHierarchyChangedDetails& details); |
| @@ -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_; |
|
sky
2017/02/24 18:26:14
We shouldn't need to cache the widget. This likely
msimonides
2017/02/27 09:52:28
Done.
|
| + |
| #if DCHECK_IS_ON() |
| // True while iterating over |children_|. Used to detect and DCHECK when |
| // |children_| is mutated during iteration. |