OLD | NEW |
---|---|
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 "ui/accessibility/ax_view_state.h" | |
8 #include "ui/views/view.h" | |
9 #include "ui/views/widget/widget.h" | |
10 | |
7 namespace views { | 11 namespace views { |
8 | 12 |
9 #if !defined(OS_WIN) | 13 #if !defined(OS_WIN) |
10 // static | 14 // static |
11 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { | 15 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { |
12 return NULL; | 16 return new NativeViewAccessibility(view); |
13 } | 17 } |
14 #endif | 18 #endif |
15 | 19 |
16 NativeViewAccessibility::NativeViewAccessibility() { | 20 NativeViewAccessibility::NativeViewAccessibility(View* view) : view_(view) { |
17 } | 21 } |
18 | 22 |
19 NativeViewAccessibility::~NativeViewAccessibility() { | 23 NativeViewAccessibility::~NativeViewAccessibility() { |
20 } | 24 } |
21 | 25 |
22 gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() { | 26 gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() { |
23 return NULL; | 27 if (!ax_node_) |
28 ax_node_.reset(ui::AXPlatformNode::Create(this)); | |
29 return ax_node_->GetNativeViewAccessible(); | |
24 } | 30 } |
25 | 31 |
26 void NativeViewAccessibility::Destroy() { | 32 void NativeViewAccessibility::Destroy() { |
33 if (ax_node_) | |
34 ax_node_->Detach(); | |
27 delete this; | 35 delete this; |
28 } | 36 } |
29 | 37 |
30 #if !defined(OS_WIN) | 38 #if !defined(OS_WIN) |
31 // static | 39 // static |
32 void NativeViewAccessibility::RegisterWebView(View* web_view) { | 40 void NativeViewAccessibility::RegisterWebView(View* web_view) { |
33 } | 41 } |
34 | 42 |
35 // static | 43 // static |
36 void NativeViewAccessibility::UnregisterWebView(View* web_view) { | 44 void NativeViewAccessibility::UnregisterWebView(View* web_view) { |
37 } | 45 } |
38 #endif | 46 #endif |
39 | 47 |
48 // ui::AXPlatformNodeDelegate | |
49 | |
50 ui::AXNodeData* NativeViewAccessibility::GetData() { | |
51 ui::AXViewState state; | |
52 view_->GetAccessibleState(&state); | |
53 data_.role = state.role; | |
54 data_.location = view_->GetBoundsInScreen(); | |
55 return &data_; | |
56 } | |
57 | |
58 int NativeViewAccessibility::GetChildCount() { | |
59 return view_->child_count(); | |
60 } | |
61 | |
62 gfx::NativeViewAccessible NativeViewAccessibility::ChildAtIndex(int index) { | |
63 return view_->child_at(index)->GetNativeViewAccessible(); | |
dmazzoni
2014/07/29 06:35:15
Sanity-check this and return NULL if it's out of b
Andre
2014/07/29 21:58:56
Done.
| |
64 } | |
65 | |
66 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { | |
67 if (view_->parent()) | |
68 return view_->parent()->GetNativeViewAccessible(); | |
69 else if (view_->GetWidget()) | |
70 return view_->GetWidget()->GetNativeViewAccessible(); | |
71 else | |
72 return NULL; | |
73 } | |
74 | |
75 gfx::Vector2d NativeViewAccessibility::GetGlobalCoordinateOffset() { | |
76 return gfx::Vector2d(0, 0); // location is already in screen coordinates. | |
77 } | |
78 | |
79 void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type) { | |
80 NOTIMPLEMENTED(); | |
81 } | |
82 | |
40 } // namespace views | 83 } // namespace views |
OLD | NEW |