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

Side by Side Diff: ui/views/accessibility/native_view_accessibility.cc

Issue 2746813002: Hide AXPlatformNode on ChromeOS. (Closed)
Patch Set: fix stub Created 3 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/accessibility/native_view_accessibility.h" 5 #include "ui/views/accessibility/native_view_accessibility.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/views/controls/native/native_view_host.h" 11 #include "ui/views/controls/native/native_view_host.h"
12 #include "ui/views/view.h" 12 #include "ui/views/view.h"
13 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL)
18 // static
19 std::unique_ptr<NativeViewAccessibility> NativeViewAccessibility::Create(
20 View* view) {
21 // Use WrapUnique over MakeUnique to invoke the protected constructor.
22 return base::WrapUnique<NativeViewAccessibility>(
23 new NativeViewAccessibility(view));
24 }
25 #endif // !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL)
26
27 NativeViewAccessibility::NativeViewAccessibility(View* view) 17 NativeViewAccessibility::NativeViewAccessibility(View* view)
28 : view_(view), 18 : view_(view),
29 parent_widget_(nullptr), 19 parent_widget_(nullptr),
30 ax_node_(nullptr) { 20 ax_node_(ui::AXPlatformNode::Create(this)) {
31 ax_node_ = ui::AXPlatformNode::Create(this); 21 DCHECK(ax_node_);
32 } 22 }
33 23
34 NativeViewAccessibility::~NativeViewAccessibility() { 24 NativeViewAccessibility::~NativeViewAccessibility() {
35 if (ax_node_) 25 ax_node_->Destroy();
36 ax_node_->Destroy();
37 if (parent_widget_) 26 if (parent_widget_)
38 parent_widget_->RemoveObserver(this); 27 parent_widget_->RemoveObserver(this);
39 } 28 }
40 29
41 gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() { 30 gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() {
42 return ax_node_ ? ax_node_->GetNativeViewAccessible() : nullptr; 31 return ax_node_->GetNativeViewAccessible();
43 } 32 }
44 33
45 void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type) { 34 void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type) {
46 if (ax_node_) 35 ax_node_->NotifyAccessibilityEvent(event_type);
47 ax_node_->NotifyAccessibilityEvent(event_type);
48 } 36 }
49 37
50 bool NativeViewAccessibility::SetFocused(bool focused) { 38 bool NativeViewAccessibility::SetFocused(bool focused) {
51 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE)) 39 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE))
52 return false; 40 return false;
53 41
54 if (focused) 42 if (focused)
55 view_->RequestFocus(); 43 view_->RequestFocus();
56 else if (view_->HasFocus()) 44 else if (view_->HasFocus())
57 view_->GetFocusManager()->ClearFocus(); 45 view_->GetFocusManager()->ClearFocus();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 child_widget_platform_node->GetDelegate()); 260 child_widget_platform_node->GetDelegate());
273 if (child_widget_view_accessibility->parent_widget() != widget) 261 if (child_widget_view_accessibility->parent_widget() != widget)
274 child_widget_view_accessibility->SetParentWidget(widget); 262 child_widget_view_accessibility->SetParentWidget(widget);
275 } 263 }
276 264
277 result_child_widgets->push_back(child_widget); 265 result_child_widgets->push_back(child_widget);
278 } 266 }
279 } 267 }
280 268
281 } // namespace views 269 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698