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