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

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

Issue 2745163003: Improve doc of ViewObserver and clarify arguments (Closed)
Patch Set: moar 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
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 RegisterChildrenForVisibleBoundsNotification(view); 245 RegisterChildrenForVisibleBoundsNotification(view);
246 246
247 if (view->visible()) 247 if (view->visible())
248 view->SchedulePaint(); 248 view->SchedulePaint();
249 } 249 }
250 250
251 if (layout_manager_.get()) 251 if (layout_manager_.get())
252 layout_manager_->ViewAdded(this, view); 252 layout_manager_->ViewAdded(this, view);
253 253
254 for (ViewObserver& observer : observers_) 254 for (ViewObserver& observer : observers_)
255 observer.OnChildViewAdded(view); 255 observer.OnChildViewAdded(this, view);
256 } 256 }
257 257
258 void View::ReorderChildView(View* view, int index) { 258 void View::ReorderChildView(View* view, int index) {
259 DCHECK_EQ(view->parent_, this); 259 DCHECK_EQ(view->parent_, this);
260 if (index < 0) 260 if (index < 0)
261 index = child_count() - 1; 261 index = child_count() - 1;
262 else if (index >= child_count()) 262 else if (index >= child_count())
263 return; 263 return;
264 if (children_[index] == view) 264 if (children_[index] == view)
265 return; 265 return;
(...skipping 11 matching lines...) Expand all
277 if (prev_focusable) 277 if (prev_focusable)
278 prev_focusable->next_focusable_view_ = next_focusable; 278 prev_focusable->next_focusable_view_ = next_focusable;
279 if (next_focusable) 279 if (next_focusable)
280 next_focusable->previous_focusable_view_ = prev_focusable; 280 next_focusable->previous_focusable_view_ = prev_focusable;
281 281
282 // Add it in the specified index now. 282 // Add it in the specified index now.
283 InitFocusSiblings(view, index); 283 InitFocusSiblings(view, index);
284 children_.insert(children_.begin() + index, view); 284 children_.insert(children_.begin() + index, view);
285 285
286 for (ViewObserver& observer : observers_) 286 for (ViewObserver& observer : observers_)
287 observer.OnChildViewReordered(view); 287 observer.OnChildViewReordered(this, view);
288 288
289 ReorderLayers(); 289 ReorderLayers();
290 } 290 }
291 291
292 void View::RemoveChildView(View* view) { 292 void View::RemoveChildView(View* view) {
293 DoRemoveChildView(view, true, true, false, NULL); 293 DoRemoveChildView(view, true, true, false, NULL);
294 } 294 }
295 295
296 void View::RemoveAllChildViews(bool delete_children) { 296 void View::RemoveAllChildViews(bool delete_children) {
297 while (!children_.empty()) 297 while (!children_.empty())
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 #endif 1957 #endif
1958 children_.erase(i); 1958 children_.erase(i);
1959 1959
1960 if (update_tool_tip) 1960 if (update_tool_tip)
1961 UpdateTooltip(); 1961 UpdateTooltip();
1962 1962
1963 if (layout_manager_) 1963 if (layout_manager_)
1964 layout_manager_->ViewRemoved(this, view); 1964 layout_manager_->ViewRemoved(this, view);
1965 1965
1966 for (ViewObserver& observer : observers_) 1966 for (ViewObserver& observer : observers_)
1967 observer.OnChildViewRemoved(view, this); 1967 observer.OnChildViewRemoved(this, view);
1968 } 1968 }
1969 1969
1970 void View::PropagateRemoveNotifications(View* old_parent, 1970 void View::PropagateRemoveNotifications(View* old_parent,
1971 View* new_parent, 1971 View* new_parent,
1972 bool is_removed_from_widget) { 1972 bool is_removed_from_widget) {
1973 { 1973 {
1974 internal::ScopedChildrenLock lock(this); 1974 internal::ScopedChildrenLock lock(this);
1975 for (auto* child : children_) { 1975 for (auto* child : children_) {
1976 child->PropagateRemoveNotifications(old_parent, new_parent, 1976 child->PropagateRemoveNotifications(old_parent, new_parent,
1977 is_removed_from_widget); 1977 is_removed_from_widget);
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 // Message the RootView to do the drag and drop. That way if we're removed 2562 // Message the RootView to do the drag and drop. That way if we're removed
2563 // the RootView can detect it and avoid calling us back. 2563 // the RootView can detect it and avoid calling us back.
2564 gfx::Point widget_location(event.location()); 2564 gfx::Point widget_location(event.location());
2565 ConvertPointToWidget(this, &widget_location); 2565 ConvertPointToWidget(this, &widget_location);
2566 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2566 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2567 // WARNING: we may have been deleted. 2567 // WARNING: we may have been deleted.
2568 return true; 2568 return true;
2569 } 2569 }
2570 2570
2571 } // namespace views 2571 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698