| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 needs_layout_(true), | 138 needs_layout_(true), |
| 139 snap_layer_to_pixel_boundary_(false), | 139 snap_layer_to_pixel_boundary_(false), |
| 140 flip_canvas_on_paint_for_rtl_ui_(false), | 140 flip_canvas_on_paint_for_rtl_ui_(false), |
| 141 paint_to_layer_(false), | 141 paint_to_layer_(false), |
| 142 accelerator_focus_manager_(NULL), | 142 accelerator_focus_manager_(NULL), |
| 143 registered_accelerator_count_(0), | 143 registered_accelerator_count_(0), |
| 144 next_focusable_view_(NULL), | 144 next_focusable_view_(NULL), |
| 145 previous_focusable_view_(NULL), | 145 previous_focusable_view_(NULL), |
| 146 focus_behavior_(FocusBehavior::NEVER), | 146 focus_behavior_(FocusBehavior::NEVER), |
| 147 context_menu_controller_(NULL), | 147 context_menu_controller_(NULL), |
| 148 drag_controller_(NULL), | 148 drag_controller_(NULL) { |
| 149 native_view_accessibility_(NULL) { | |
| 150 SetTargetHandler(this); | 149 SetTargetHandler(this); |
| 151 } | 150 } |
| 152 | 151 |
| 153 View::~View() { | 152 View::~View() { |
| 154 if (parent_) | 153 if (parent_) |
| 155 parent_->RemoveChildView(this); | 154 parent_->RemoveChildView(this); |
| 156 | 155 |
| 157 ViewStorage::GetInstance()->ViewRemoved(this); | 156 ViewStorage::GetInstance()->ViewRemoved(this); |
| 158 | 157 |
| 159 { | 158 { |
| 160 internal::ScopedChildrenLock lock(this); | 159 internal::ScopedChildrenLock lock(this); |
| 161 for (auto* child : children_) { | 160 for (auto* child : children_) { |
| 162 child->parent_ = NULL; | 161 child->parent_ = NULL; |
| 163 if (!child->owned_by_client_) | 162 if (!child->owned_by_client_) |
| 164 delete child; | 163 delete child; |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 | |
| 168 // Release ownership of the native accessibility object, but it's | |
| 169 // reference-counted on some platforms, so it may not be deleted right away. | |
| 170 if (native_view_accessibility_) | |
| 171 native_view_accessibility_->Destroy(); | |
| 172 } | 166 } |
| 173 | 167 |
| 174 // Tree operations ------------------------------------------------------------- | 168 // Tree operations ------------------------------------------------------------- |
| 175 | 169 |
| 176 const Widget* View::GetWidget() const { | 170 const Widget* View::GetWidget() const { |
| 177 // The root view holds a reference to this view hierarchy's Widget. | 171 // The root view holds a reference to this view hierarchy's Widget. |
| 178 return parent_ ? parent_->GetWidget() : NULL; | 172 return parent_ ? parent_->GetWidget() : NULL; |
| 179 } | 173 } |
| 180 | 174 |
| 181 Widget* View::GetWidget() { | 175 Widget* View::GetWidget() { |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 } | 1409 } |
| 1416 | 1410 |
| 1417 // Accessibility---------------------------------------------------------------- | 1411 // Accessibility---------------------------------------------------------------- |
| 1418 | 1412 |
| 1419 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { | 1413 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { |
| 1420 return false; | 1414 return false; |
| 1421 } | 1415 } |
| 1422 | 1416 |
| 1423 gfx::NativeViewAccessible View::GetNativeViewAccessible() { | 1417 gfx::NativeViewAccessible View::GetNativeViewAccessible() { |
| 1424 if (!native_view_accessibility_) | 1418 if (!native_view_accessibility_) |
| 1425 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1419 native_view_accessibility_ = NativeViewAccessibility::CreateForView(this); |
| 1426 if (native_view_accessibility_) | 1420 if (native_view_accessibility_) |
| 1427 return native_view_accessibility_->GetNativeObject(); | 1421 return native_view_accessibility_->GetNativeObject(); |
| 1428 return NULL; | 1422 return nullptr; |
| 1429 } | 1423 } |
| 1430 | 1424 |
| 1431 void View::NotifyAccessibilityEvent( | 1425 void View::NotifyAccessibilityEvent( |
| 1432 ui::AXEvent event_type, | 1426 ui::AXEvent event_type, |
| 1433 bool send_native_event) { | 1427 bool send_native_event) { |
| 1434 if (ViewsDelegate::GetInstance()) | 1428 if (ViewsDelegate::GetInstance()) |
| 1435 ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(this, event_type); | 1429 ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(this, event_type); |
| 1436 | 1430 |
| 1437 if (send_native_event && GetWidget()) { | 1431 if (send_native_event && GetWidget()) { |
| 1438 if (!native_view_accessibility_) | 1432 if (!native_view_accessibility_) |
| 1439 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1433 native_view_accessibility_ = NativeViewAccessibility::CreateForView(this); |
| 1440 if (native_view_accessibility_) | 1434 if (native_view_accessibility_) |
| 1441 native_view_accessibility_->NotifyAccessibilityEvent(event_type); | 1435 native_view_accessibility_->NotifyAccessibilityEvent(event_type); |
| 1442 } | 1436 } |
| 1443 } | 1437 } |
| 1444 | 1438 |
| 1445 // Scrolling ------------------------------------------------------------------- | 1439 // Scrolling ------------------------------------------------------------------- |
| 1446 | 1440 |
| 1447 void View::ScrollRectToVisible(const gfx::Rect& rect) { | 1441 void View::ScrollRectToVisible(const gfx::Rect& rect) { |
| 1448 // We must take RTL UI mirroring into account when adjusting the position of | 1442 // We must take RTL UI mirroring into account when adjusting the position of |
| 1449 // the region. | 1443 // the region. |
| (...skipping 1101 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 | 2545 // 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. | 2546 // the RootView can detect it and avoid calling us back. |
| 2553 gfx::Point widget_location(event.location()); | 2547 gfx::Point widget_location(event.location()); |
| 2554 ConvertPointToWidget(this, &widget_location); | 2548 ConvertPointToWidget(this, &widget_location); |
| 2555 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2549 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2556 // WARNING: we may have been deleted. | 2550 // WARNING: we may have been deleted. |
| 2557 return true; | 2551 return true; |
| 2558 } | 2552 } |
| 2559 | 2553 |
| 2560 } // namespace views | 2554 } // namespace views |
| OLD | NEW |