Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1494 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { | 1494 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { |
| 1495 return false; | 1495 return false; |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 void View::OnVisibleBoundsChanged() { | 1498 void View::OnVisibleBoundsChanged() { |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 // Tree operations ------------------------------------------------------------- | 1501 // Tree operations ------------------------------------------------------------- |
| 1502 | 1502 |
| 1503 void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) { | 1503 void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) { |
| 1504 if (details.is_add) { | |
| 1505 const auto widget = GetWidget(); | |
| 1506 if (widget != nullptr && widget != attached_widget_) { | |
| 1507 attached_widget_ = widget; | |
| 1508 AddedToWidget(); | |
| 1509 } | |
| 1510 } else if (details.child == this) { | |
| 1511 if (attached_widget_) { | |
| 1512 RemovedFromWidget(); | |
| 1513 attached_widget_ = nullptr; | |
| 1514 } | |
| 1515 } | |
| 1504 } | 1516 } |
| 1505 | 1517 |
| 1506 void View::VisibilityChanged(View* starting_from, bool is_visible) { | 1518 void View::VisibilityChanged(View* starting_from, bool is_visible) { |
| 1507 } | 1519 } |
| 1508 | 1520 |
| 1509 void View::NativeViewHierarchyChanged() { | 1521 void View::NativeViewHierarchyChanged() { |
| 1510 FocusManager* focus_manager = GetFocusManager(); | 1522 FocusManager* focus_manager = GetFocusManager(); |
| 1511 if (accelerator_focus_manager_ != focus_manager) { | 1523 if (accelerator_focus_manager_ != focus_manager) { |
| 1512 UnregisterAccelerators(true); | 1524 UnregisterAccelerators(true); |
| 1513 | 1525 |
| 1514 if (focus_manager) | 1526 if (focus_manager) |
| 1515 RegisterPendingAccelerators(); | 1527 RegisterPendingAccelerators(); |
| 1516 } | 1528 } |
| 1517 } | 1529 } |
| 1518 | 1530 |
| 1531 void View::AddedToWidget() {} | |
| 1532 | |
| 1533 void View::RemovedFromWidget() {} | |
| 1534 | |
| 1519 // Painting -------------------------------------------------------------------- | 1535 // Painting -------------------------------------------------------------------- |
| 1520 | 1536 |
| 1521 void View::PaintChildren(const ui::PaintContext& context) { | 1537 void View::PaintChildren(const ui::PaintContext& context) { |
| 1522 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); | 1538 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); |
| 1523 View::Views children = GetChildrenInZOrder(); | 1539 View::Views children = GetChildrenInZOrder(); |
| 1524 DCHECK_EQ(child_count(), static_cast<int>(children.size())); | 1540 DCHECK_EQ(child_count(), static_cast<int>(children.size())); |
| 1525 for (auto* child : children) { | 1541 for (auto* child : children) { |
| 1526 if (!child->layer()) | 1542 if (!child->layer()) |
| 1527 child->Paint(context); | 1543 child->Paint(context); |
| 1528 } | 1544 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2004 // If you get this registration, you are part of a subtree that has been | 2020 // If you get this registration, you are part of a subtree that has been |
| 2005 // added to the view hierarchy. | 2021 // added to the view hierarchy. |
| 2006 if (GetFocusManager()) | 2022 if (GetFocusManager()) |
| 2007 RegisterPendingAccelerators(); | 2023 RegisterPendingAccelerators(); |
| 2008 } else { | 2024 } else { |
| 2009 if (details.child == this) | 2025 if (details.child == this) |
| 2010 UnregisterAccelerators(true); | 2026 UnregisterAccelerators(true); |
| 2011 } | 2027 } |
| 2012 } | 2028 } |
| 2013 | 2029 |
| 2014 ViewHierarchyChanged(details); | 2030 ViewHierarchyChanged(details); |
|
sky
2017/02/22 17:21:33
Please call the new functions from here. That way
| |
| 2015 details.parent->needs_layout_ = true; | 2031 details.parent->needs_layout_ = true; |
| 2016 } | 2032 } |
| 2017 | 2033 |
| 2018 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { | 2034 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { |
| 2019 if (native_theme_ && native_theme_ != theme) | 2035 if (native_theme_ && native_theme_ != theme) |
| 2020 return; | 2036 return; |
| 2021 | 2037 |
| 2022 { | 2038 { |
| 2023 internal::ScopedChildrenLock lock(this); | 2039 internal::ScopedChildrenLock lock(this); |
| 2024 for (auto* child : children_) | 2040 for (auto* child : children_) |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2551 // Message the RootView to do the drag and drop. That way if we're removed | 2567 // 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. | 2568 // the RootView can detect it and avoid calling us back. |
| 2553 gfx::Point widget_location(event.location()); | 2569 gfx::Point widget_location(event.location()); |
| 2554 ConvertPointToWidget(this, &widget_location); | 2570 ConvertPointToWidget(this, &widget_location); |
| 2555 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2571 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2556 // WARNING: we may have been deleted. | 2572 // WARNING: we may have been deleted. |
| 2557 return true; | 2573 return true; |
| 2558 } | 2574 } |
| 2559 | 2575 |
| 2560 } // namespace views | 2576 } // namespace views |
| OLD | NEW |