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

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

Issue 2745163003: Improve doc of ViewObserver and clarify arguments (Closed)
Patch Set: merge 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 | « ash/common/devtools/ash_devtools_dom_agent.cc ('k') | ui/views/view_observer.h » ('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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 RegisterChildrenForVisibleBoundsNotification(view); 248 RegisterChildrenForVisibleBoundsNotification(view);
249 249
250 if (view->visible()) 250 if (view->visible())
251 view->SchedulePaint(); 251 view->SchedulePaint();
252 } 252 }
253 253
254 if (layout_manager_.get()) 254 if (layout_manager_.get())
255 layout_manager_->ViewAdded(this, view); 255 layout_manager_->ViewAdded(this, view);
256 256
257 for (ViewObserver& observer : observers_) 257 for (ViewObserver& observer : observers_)
258 observer.OnChildViewAdded(view); 258 observer.OnChildViewAdded(this, view);
259 } 259 }
260 260
261 void View::ReorderChildView(View* view, int index) { 261 void View::ReorderChildView(View* view, int index) {
262 DCHECK_EQ(view->parent_, this); 262 DCHECK_EQ(view->parent_, this);
263 if (index < 0) 263 if (index < 0)
264 index = child_count() - 1; 264 index = child_count() - 1;
265 else if (index >= child_count()) 265 else if (index >= child_count())
266 return; 266 return;
267 if (children_[index] == view) 267 if (children_[index] == view)
268 return; 268 return;
(...skipping 11 matching lines...) Expand all
280 if (prev_focusable) 280 if (prev_focusable)
281 prev_focusable->next_focusable_view_ = next_focusable; 281 prev_focusable->next_focusable_view_ = next_focusable;
282 if (next_focusable) 282 if (next_focusable)
283 next_focusable->previous_focusable_view_ = prev_focusable; 283 next_focusable->previous_focusable_view_ = prev_focusable;
284 284
285 // Add it in the specified index now. 285 // Add it in the specified index now.
286 InitFocusSiblings(view, index); 286 InitFocusSiblings(view, index);
287 children_.insert(children_.begin() + index, view); 287 children_.insert(children_.begin() + index, view);
288 288
289 for (ViewObserver& observer : observers_) 289 for (ViewObserver& observer : observers_)
290 observer.OnChildViewReordered(view); 290 observer.OnChildViewReordered(this, view);
291 291
292 ReorderLayers(); 292 ReorderLayers();
293 } 293 }
294 294
295 void View::RemoveChildView(View* view) { 295 void View::RemoveChildView(View* view) {
296 DoRemoveChildView(view, true, true, false, NULL); 296 DoRemoveChildView(view, true, true, false, NULL);
297 } 297 }
298 298
299 void View::RemoveAllChildViews(bool delete_children) { 299 void View::RemoveAllChildViews(bool delete_children) {
300 while (!children_.empty()) 300 while (!children_.empty())
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 #endif 1960 #endif
1961 children_.erase(i); 1961 children_.erase(i);
1962 1962
1963 if (update_tool_tip) 1963 if (update_tool_tip)
1964 UpdateTooltip(); 1964 UpdateTooltip();
1965 1965
1966 if (layout_manager_) 1966 if (layout_manager_)
1967 layout_manager_->ViewRemoved(this, view); 1967 layout_manager_->ViewRemoved(this, view);
1968 1968
1969 for (ViewObserver& observer : observers_) 1969 for (ViewObserver& observer : observers_)
1970 observer.OnChildViewRemoved(view, this); 1970 observer.OnChildViewRemoved(this, view);
1971 } 1971 }
1972 1972
1973 void View::PropagateRemoveNotifications(View* old_parent, 1973 void View::PropagateRemoveNotifications(View* old_parent,
1974 View* new_parent, 1974 View* new_parent,
1975 bool is_removed_from_widget) { 1975 bool is_removed_from_widget) {
1976 { 1976 {
1977 internal::ScopedChildrenLock lock(this); 1977 internal::ScopedChildrenLock lock(this);
1978 for (auto* child : children_) { 1978 for (auto* child : children_) {
1979 child->PropagateRemoveNotifications(old_parent, new_parent, 1979 child->PropagateRemoveNotifications(old_parent, new_parent,
1980 is_removed_from_widget); 1980 is_removed_from_widget);
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 // Message the RootView to do the drag and drop. That way if we're removed 2565 // Message the RootView to do the drag and drop. That way if we're removed
2566 // the RootView can detect it and avoid calling us back. 2566 // the RootView can detect it and avoid calling us back.
2567 gfx::Point widget_location(event.location()); 2567 gfx::Point widget_location(event.location());
2568 ConvertPointToWidget(this, &widget_location); 2568 ConvertPointToWidget(this, &widget_location);
2569 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2569 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2570 // WARNING: we may have been deleted. 2570 // WARNING: we may have been deleted.
2571 return true; 2571 return true;
2572 } 2572 }
2573 2573
2574 } // namespace views 2574 } // namespace views
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.cc ('k') | ui/views/view_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698