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

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

Issue 2713643002: Add View::AddedToWidget and RemovedFromWidget. (Closed)
Patch Set: Review fixes. Created 3 years, 10 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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 void View::NativeViewHierarchyChanged() { 1509 void View::NativeViewHierarchyChanged() {
1510 FocusManager* focus_manager = GetFocusManager(); 1510 FocusManager* focus_manager = GetFocusManager();
1511 if (accelerator_focus_manager_ != focus_manager) { 1511 if (accelerator_focus_manager_ != focus_manager) {
1512 UnregisterAccelerators(true); 1512 UnregisterAccelerators(true);
1513 1513
1514 if (focus_manager) 1514 if (focus_manager)
1515 RegisterPendingAccelerators(); 1515 RegisterPendingAccelerators();
1516 } 1516 }
1517 } 1517 }
1518 1518
1519 void View::AddedToWidget() {}
1520
1521 void View::RemovedFromWidget() {}
1522
1519 // Painting -------------------------------------------------------------------- 1523 // Painting --------------------------------------------------------------------
1520 1524
1521 void View::PaintChildren(const ui::PaintContext& context) { 1525 void View::PaintChildren(const ui::PaintContext& context) {
1522 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); 1526 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName());
1523 View::Views children = GetChildrenInZOrder(); 1527 View::Views children = GetChildrenInZOrder();
1524 DCHECK_EQ(child_count(), static_cast<int>(children.size())); 1528 DCHECK_EQ(child_count(), static_cast<int>(children.size()));
1525 for (auto* child : children) { 1529 for (auto* child : children) {
1526 if (!child->layer()) 1530 if (!child->layer())
1527 child->Paint(context); 1531 child->Paint(context);
1528 } 1532 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 // added to the view hierarchy. 2009 // added to the view hierarchy.
2006 if (GetFocusManager()) 2010 if (GetFocusManager())
2007 RegisterPendingAccelerators(); 2011 RegisterPendingAccelerators();
2008 } else { 2012 } else {
2009 if (details.child == this) 2013 if (details.child == this)
2010 UnregisterAccelerators(true); 2014 UnregisterAccelerators(true);
2011 } 2015 }
2012 } 2016 }
2013 2017
2014 ViewHierarchyChanged(details); 2018 ViewHierarchyChanged(details);
2019
2020 if (details.is_add) {
2021 const auto widget = GetWidget();
2022 if (widget != nullptr && widget != attached_widget_) {
2023 attached_widget_ = widget;
2024 AddedToWidget();
2025 }
2026 } else if (details.child == this) {
2027 if (attached_widget_) {
2028 RemovedFromWidget();
2029 attached_widget_ = nullptr;
2030 }
2031 }
2032
2015 details.parent->needs_layout_ = true; 2033 details.parent->needs_layout_ = true;
2016 } 2034 }
2017 2035
2018 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { 2036 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
2019 if (native_theme_ && native_theme_ != theme) 2037 if (native_theme_ && native_theme_ != theme)
2020 return; 2038 return;
2021 2039
2022 { 2040 {
2023 internal::ScopedChildrenLock lock(this); 2041 internal::ScopedChildrenLock lock(this);
2024 for (auto* child : children_) 2042 for (auto* child : children_)
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 // Message the RootView to do the drag and drop. That way if we're removed 2569 // Message the RootView to do the drag and drop. That way if we're removed
2552 // the RootView can detect it and avoid calling us back. 2570 // the RootView can detect it and avoid calling us back.
2553 gfx::Point widget_location(event.location()); 2571 gfx::Point widget_location(event.location());
2554 ConvertPointToWidget(this, &widget_location); 2572 ConvertPointToWidget(this, &widget_location);
2555 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2573 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2556 // WARNING: we may have been deleted. 2574 // WARNING: we may have been deleted.
2557 return true; 2575 return true;
2558 } 2576 }
2559 2577
2560 } // namespace views 2578 } // namespace views
OLDNEW
« ui/views/view.h ('K') | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698