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

Side by Side Diff: ui/views/view.h

Issue 2713643002: Add View::AddedToWidget and RemovedFromWidget. (Closed)
Patch Set: Review fixes. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_VIEW_H_ 5 #ifndef UI_VIEWS_VIEW_H_
6 #define UI_VIEWS_VIEW_H_ 6 #define UI_VIEWS_VIEW_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 virtual void VisibilityChanged(View* starting_from, bool is_visible); 1109 virtual void VisibilityChanged(View* starting_from, bool is_visible);
1110 1110
1111 // This method is invoked when the parent NativeView of the widget that the 1111 // This method is invoked when the parent NativeView of the widget that the
1112 // view is attached to has changed and the view hierarchy has not changed. 1112 // view is attached to has changed and the view hierarchy has not changed.
1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget 1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget
1114 // that the view is attached to is changed as a result of changing the view 1114 // that the view is attached to is changed as a result of changing the view
1115 // hierarchy. Overriding this method is useful for tracking which 1115 // hierarchy. Overriding this method is useful for tracking which
1116 // FocusManager manages this view. 1116 // FocusManager manages this view.
1117 virtual void NativeViewHierarchyChanged(); 1117 virtual void NativeViewHierarchyChanged();
1118 1118
1119 // This method is invoked for a view when it is attached to a hierarchy with
1120 // a widget, i.e. GetWidget() starts returning a non-null result.
1121 virtual void AddedToWidget();
1122
1123 // This method is invoked for a view when it is removed from a hierarchy with
1124 // a widget.
1125 virtual void RemovedFromWidget();
1126
1119 // Painting ------------------------------------------------------------------ 1127 // Painting ------------------------------------------------------------------
1120 1128
1121 // Responsible for calling Paint() on child Views. Override to control the 1129 // Responsible for calling Paint() on child Views. Override to control the
1122 // order child Views are painted. 1130 // order child Views are painted.
1123 virtual void PaintChildren(const ui::PaintContext& context); 1131 virtual void PaintChildren(const ui::PaintContext& context);
1124 1132
1125 // Override to provide rendering in any part of the View's bounds. Typically 1133 // Override to provide rendering in any part of the View's bounds. Typically
1126 // this is the "contents" of the view. If you override this method you will 1134 // this is the "contents" of the view. If you override this method you will
1127 // have to call the subsequent OnPaint*() methods manually. 1135 // have to call the subsequent OnPaint*() methods manually.
1128 virtual void OnPaint(gfx::Canvas* canvas); 1136 virtual void OnPaint(gfx::Canvas* canvas);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 void PropagateRemoveNotifications(View* old_parent, View* new_parent); 1309 void PropagateRemoveNotifications(View* old_parent, View* new_parent);
1302 1310
1303 // Call ViewHierarchyChanged() for all children. 1311 // Call ViewHierarchyChanged() for all children.
1304 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details); 1312 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details);
1305 1313
1306 // Propagates NativeViewHierarchyChanged() notification through all the 1314 // Propagates NativeViewHierarchyChanged() notification through all the
1307 // children. 1315 // children.
1308 void PropagateNativeViewHierarchyChanged(); 1316 void PropagateNativeViewHierarchyChanged();
1309 1317
1310 // Takes care of registering/unregistering accelerators if 1318 // Takes care of registering/unregistering accelerators if
1311 // |register_accelerators| true and calls ViewHierarchyChanged(). 1319 // |register_accelerators| true, calls ViewHierarchyChanged() and
1320 // AddedToWidget() or RemovedFromWidget() if necessary.
1312 void ViewHierarchyChangedImpl(bool register_accelerators, 1321 void ViewHierarchyChangedImpl(bool register_accelerators,
1313 const ViewHierarchyChangedDetails& details); 1322 const ViewHierarchyChangedDetails& details);
1314 1323
1315 // Invokes OnNativeThemeChanged() on this and all descendants. 1324 // Invokes OnNativeThemeChanged() on this and all descendants.
1316 void PropagateNativeThemeChanged(const ui::NativeTheme* theme); 1325 void PropagateNativeThemeChanged(const ui::NativeTheme* theme);
1317 1326
1318 // Size and disposition ------------------------------------------------------ 1327 // Size and disposition ------------------------------------------------------
1319 1328
1320 // Call VisibilityChanged() recursively for all children. 1329 // Call VisibilityChanged() recursively for all children.
1321 void PropagateVisibilityNotifications(View* from, bool is_visible); 1330 void PropagateVisibilityNotifications(View* from, bool is_visible);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 int group_; 1493 int group_;
1485 1494
1486 // Tree operations ----------------------------------------------------------- 1495 // Tree operations -----------------------------------------------------------
1487 1496
1488 // This view's parent. 1497 // This view's parent.
1489 View* parent_; 1498 View* parent_;
1490 1499
1491 // This view's children. 1500 // This view's children.
1492 Views children_; 1501 Views children_;
1493 1502
1503 // The widget this view is (possibily indirectly) attached to.
1504 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.
1505
1494 #if DCHECK_IS_ON() 1506 #if DCHECK_IS_ON()
1495 // True while iterating over |children_|. Used to detect and DCHECK when 1507 // True while iterating over |children_|. Used to detect and DCHECK when
1496 // |children_| is mutated during iteration. 1508 // |children_| is mutated during iteration.
1497 mutable bool iterating_; 1509 mutable bool iterating_;
1498 #endif 1510 #endif
1499 1511
1500 bool can_process_events_within_subtree_; 1512 bool can_process_events_within_subtree_;
1501 1513
1502 // Size and disposition ------------------------------------------------------ 1514 // Size and disposition ------------------------------------------------------
1503 1515
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 // Observers ------------------------------------------------------------- 1635 // Observers -------------------------------------------------------------
1624 1636
1625 base::ObserverList<ViewObserver> observers_; 1637 base::ObserverList<ViewObserver> observers_;
1626 1638
1627 DISALLOW_COPY_AND_ASSIGN(View); 1639 DISALLOW_COPY_AND_ASSIGN(View);
1628 }; 1640 };
1629 1641
1630 } // namespace views 1642 } // namespace views
1631 1643
1632 #endif // UI_VIEWS_VIEW_H_ 1644 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698