| 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 #include "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // static | 90 // static |
| 91 const char View::kViewClassName[] = "views/View"; | 91 const char View::kViewClassName[] = "views/View"; |
| 92 | 92 |
| 93 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
| 94 // View, public: | 94 // View, public: |
| 95 | 95 |
| 96 // Creation and lifetime ------------------------------------------------------- | 96 // Creation and lifetime ------------------------------------------------------- |
| 97 | 97 |
| 98 View::View() | 98 View::View() |
| 99 : parent_owned_(true), | 99 : owned_by_client_(false), |
| 100 id_(0), | 100 id_(0), |
| 101 group_(-1), | 101 group_(-1), |
| 102 parent_(NULL), | 102 parent_(NULL), |
| 103 visible_(true), | 103 visible_(true), |
| 104 enabled_(true), | 104 enabled_(true), |
| 105 painting_enabled_(true), | 105 painting_enabled_(true), |
| 106 notify_enter_exit_on_child_(false), | 106 notify_enter_exit_on_child_(false), |
| 107 registered_for_visible_bounds_notification_(false), | 107 registered_for_visible_bounds_notification_(false), |
| 108 clip_insets_(0, 0, 0, 0), | 108 clip_insets_(0, 0, 0, 0), |
| 109 needs_layout_(true), | 109 needs_layout_(true), |
| 110 flip_canvas_on_paint_for_rtl_ui_(false), | 110 flip_canvas_on_paint_for_rtl_ui_(false), |
| 111 paint_to_layer_(false), | 111 paint_to_layer_(false), |
| 112 accelerator_registration_delayed_(false), | 112 accelerator_registration_delayed_(false), |
| 113 accelerator_focus_manager_(NULL), | 113 accelerator_focus_manager_(NULL), |
| 114 registered_accelerator_count_(0), | 114 registered_accelerator_count_(0), |
| 115 next_focusable_view_(NULL), | 115 next_focusable_view_(NULL), |
| 116 previous_focusable_view_(NULL), | 116 previous_focusable_view_(NULL), |
| 117 focusable_(false), | 117 focusable_(false), |
| 118 accessibility_focusable_(false), | 118 accessibility_focusable_(false), |
| 119 context_menu_controller_(NULL), | 119 context_menu_controller_(NULL), |
| 120 drag_controller_(NULL) { | 120 drag_controller_(NULL) { |
| 121 } | 121 } |
| 122 | 122 |
| 123 View::~View() { | 123 View::~View() { |
| 124 if (parent_) | 124 if (parent_) |
| 125 parent_->RemoveChildView(this); | 125 parent_->RemoveChildView(this); |
| 126 | 126 |
| 127 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) { | 127 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) { |
| 128 (*i)->parent_ = NULL; | 128 (*i)->parent_ = NULL; |
| 129 if ((*i)->parent_owned()) | 129 if (!(*i)->owned_by_client_) |
| 130 delete *i; | 130 delete *i; |
| 131 } | 131 } |
| 132 | 132 |
| 133 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 134 if (native_view_accessibility_win_.get()) | 134 if (native_view_accessibility_win_.get()) |
| 135 native_view_accessibility_win_->set_view(NULL); | 135 native_view_accessibility_win_->set_view(NULL); |
| 136 #endif | 136 #endif |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Tree operations ------------------------------------------------------------- | 139 // Tree operations ------------------------------------------------------------- |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 if (next_focusable) | 1531 if (next_focusable) |
| 1532 next_focusable->previous_focusable_view_ = prev_focusable; | 1532 next_focusable->previous_focusable_view_ = prev_focusable; |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 if (GetWidget()) | 1535 if (GetWidget()) |
| 1536 UnregisterChildrenForVisibleBoundsNotification(view); | 1536 UnregisterChildrenForVisibleBoundsNotification(view); |
| 1537 view->PropagateRemoveNotifications(this); | 1537 view->PropagateRemoveNotifications(this); |
| 1538 view->parent_ = NULL; | 1538 view->parent_ = NULL; |
| 1539 view->UpdateLayerVisibility(); | 1539 view->UpdateLayerVisibility(); |
| 1540 | 1540 |
| 1541 if (delete_removed_view && view->parent_owned()) | 1541 if (delete_removed_view && !view->owned_by_client_) |
| 1542 view_to_be_deleted.reset(view); | 1542 view_to_be_deleted.reset(view); |
| 1543 | 1543 |
| 1544 children_.erase(i); | 1544 children_.erase(i); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 if (update_tool_tip) | 1547 if (update_tool_tip) |
| 1548 UpdateTooltip(); | 1548 UpdateTooltip(); |
| 1549 | 1549 |
| 1550 if (layout_manager_.get()) | 1550 if (layout_manager_.get()) |
| 1551 layout_manager_->ViewRemoved(this, view); | 1551 layout_manager_->ViewRemoved(this, view); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 | 2063 |
| 2064 // Message the RootView to do the drag and drop. That way if we're removed | 2064 // Message the RootView to do the drag and drop. That way if we're removed |
| 2065 // the RootView can detect it and avoid calling us back. | 2065 // the RootView can detect it and avoid calling us back. |
| 2066 gfx::Point widget_location(event.location()); | 2066 gfx::Point widget_location(event.location()); |
| 2067 ConvertPointToWidget(this, &widget_location); | 2067 ConvertPointToWidget(this, &widget_location); |
| 2068 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2068 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
| 2069 #endif // !defined(OS_MACOSX) | 2069 #endif // !defined(OS_MACOSX) |
| 2070 } | 2070 } |
| 2071 | 2071 |
| 2072 } // namespace views | 2072 } // namespace views |
| OLD | NEW |