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