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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 needs_layout_(true), | 137 needs_layout_(true), |
138 snap_layer_to_pixel_boundary_(false), | 138 snap_layer_to_pixel_boundary_(false), |
139 flip_canvas_on_paint_for_rtl_ui_(false), | 139 flip_canvas_on_paint_for_rtl_ui_(false), |
140 paint_to_layer_(false), | 140 paint_to_layer_(false), |
141 accelerator_focus_manager_(NULL), | 141 accelerator_focus_manager_(NULL), |
142 registered_accelerator_count_(0), | 142 registered_accelerator_count_(0), |
143 next_focusable_view_(NULL), | 143 next_focusable_view_(NULL), |
144 previous_focusable_view_(NULL), | 144 previous_focusable_view_(NULL), |
145 focus_behavior_(FocusBehavior::NEVER), | 145 focus_behavior_(FocusBehavior::NEVER), |
146 context_menu_controller_(NULL), | 146 context_menu_controller_(NULL), |
147 drag_controller_(NULL), | 147 drag_controller_(NULL) { |
148 native_view_accessibility_(NULL) { | |
149 SetTargetHandler(this); | 148 SetTargetHandler(this); |
150 } | 149 } |
151 | 150 |
152 View::~View() { | 151 View::~View() { |
153 if (parent_) | 152 if (parent_) |
154 parent_->RemoveChildView(this); | 153 parent_->RemoveChildView(this); |
155 | 154 |
156 ViewStorage::GetInstance()->ViewRemoved(this); | 155 ViewStorage::GetInstance()->ViewRemoved(this); |
157 | 156 |
158 { | 157 { |
159 internal::ScopedChildrenLock lock(this); | 158 internal::ScopedChildrenLock lock(this); |
160 for (auto* child : children_) { | 159 for (auto* child : children_) { |
161 child->parent_ = NULL; | 160 child->parent_ = NULL; |
162 if (!child->owned_by_client_) | 161 if (!child->owned_by_client_) |
163 delete child; | 162 delete child; |
164 } | 163 } |
165 } | 164 } |
166 | |
167 // Release ownership of the native accessibility object, but it's | |
168 // reference-counted on some platforms, so it may not be deleted right away. | |
169 if (native_view_accessibility_) | |
170 native_view_accessibility_->Destroy(); | |
171 } | 165 } |
172 | 166 |
173 // Tree operations ------------------------------------------------------------- | 167 // Tree operations ------------------------------------------------------------- |
174 | 168 |
175 const Widget* View::GetWidget() const { | 169 const Widget* View::GetWidget() const { |
176 // The root view holds a reference to this view hierarchy's Widget. | 170 // The root view holds a reference to this view hierarchy's Widget. |
177 return parent_ ? parent_->GetWidget() : NULL; | 171 return parent_ ? parent_->GetWidget() : NULL; |
178 } | 172 } |
179 | 173 |
180 Widget* View::GetWidget() { | 174 Widget* View::GetWidget() { |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 abs(delta.y()) > GetVerticalDragThreshold()); | 1380 abs(delta.y()) > GetVerticalDragThreshold()); |
1387 } | 1381 } |
1388 | 1382 |
1389 // Accessibility---------------------------------------------------------------- | 1383 // Accessibility---------------------------------------------------------------- |
1390 | 1384 |
1391 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { | 1385 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { |
1392 return false; | 1386 return false; |
1393 } | 1387 } |
1394 | 1388 |
1395 gfx::NativeViewAccessible View::GetNativeViewAccessible() { | 1389 gfx::NativeViewAccessible View::GetNativeViewAccessible() { |
1396 if (!native_view_accessibility_) | 1390 if (!native_view_accessibility_) { |
1397 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1391 native_view_accessibility_.reset( |
1392 NativeViewAccessibility::GetOrCreate(this)); | |
tapted
2017/01/11 18:27:40
it does seem a bit spooky that a call to GetOrCrea
Patti Lor
2017/02/21 03:29:17
So I now have
public:
- static NVA::CreateForVi
| |
1393 } | |
1398 if (native_view_accessibility_) | 1394 if (native_view_accessibility_) |
1399 return native_view_accessibility_->GetNativeObject(); | 1395 return native_view_accessibility_->GetNativeObject(); |
1400 return NULL; | 1396 return nullptr; |
1401 } | 1397 } |
1402 | 1398 |
1403 void View::NotifyAccessibilityEvent( | 1399 void View::NotifyAccessibilityEvent( |
1404 ui::AXEvent event_type, | 1400 ui::AXEvent event_type, |
1405 bool send_native_event) { | 1401 bool send_native_event) { |
1406 if (ViewsDelegate::GetInstance()) | 1402 if (ViewsDelegate::GetInstance()) |
1407 ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(this, event_type); | 1403 ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(this, event_type); |
1408 | 1404 |
1409 if (send_native_event && GetWidget()) { | 1405 if (send_native_event && GetWidget()) { |
1410 if (!native_view_accessibility_) | 1406 if (!native_view_accessibility_) { |
1411 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1407 native_view_accessibility_.reset( |
tapted
2017/01/11 18:27:40
= base::WrapUnique(..)
Or, better, NVA::CreateFor
Patti Lor
2017/02/21 03:29:17
Done.
| |
1408 NativeViewAccessibility::GetOrCreate(this)); | |
1409 } | |
1412 if (native_view_accessibility_) | 1410 if (native_view_accessibility_) |
1413 native_view_accessibility_->NotifyAccessibilityEvent(event_type); | 1411 native_view_accessibility_->NotifyAccessibilityEvent(event_type); |
1414 } | 1412 } |
1415 } | 1413 } |
1416 | 1414 |
1417 // Scrolling ------------------------------------------------------------------- | 1415 // Scrolling ------------------------------------------------------------------- |
1418 | 1416 |
1419 void View::ScrollRectToVisible(const gfx::Rect& rect) { | 1417 void View::ScrollRectToVisible(const gfx::Rect& rect) { |
1420 // We must take RTL UI mirroring into account when adjusting the position of | 1418 // We must take RTL UI mirroring into account when adjusting the position of |
1421 // the region. | 1419 // the region. |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 // Message the RootView to do the drag and drop. That way if we're removed | 2544 // Message the RootView to do the drag and drop. That way if we're removed |
2547 // the RootView can detect it and avoid calling us back. | 2545 // the RootView can detect it and avoid calling us back. |
2548 gfx::Point widget_location(event.location()); | 2546 gfx::Point widget_location(event.location()); |
2549 ConvertPointToWidget(this, &widget_location); | 2547 ConvertPointToWidget(this, &widget_location); |
2550 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2548 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2551 // WARNING: we may have been deleted. | 2549 // WARNING: we may have been deleted. |
2552 return true; | 2550 return true; |
2553 } | 2551 } |
2554 | 2552 |
2555 } // namespace views | 2553 } // namespace views |
OLD | NEW |