Chromium Code Reviews| Index: ui/views/accessibility/native_view_accessibility.cc |
| diff --git a/ui/views/accessibility/native_view_accessibility.cc b/ui/views/accessibility/native_view_accessibility.cc |
| index 577ecfa41c22732485b5708f6786445d370e49a0..9fe0f01b2a2ae55313551d79479b6335a30e1a61 100644 |
| --- a/ui/views/accessibility/native_view_accessibility.cc |
| +++ b/ui/views/accessibility/native_view_accessibility.cc |
| @@ -4,26 +4,38 @@ |
| #include "ui/views/accessibility/native_view_accessibility.h" |
| +#include "ui/accessibility/ax_view_state.h" |
| +#include "ui/views/view.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| namespace views { |
| #if !defined(OS_WIN) |
| // static |
| NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { |
| - return NULL; |
| + DCHECK(view); |
| + NativeViewAccessibility* instance = new NativeViewAccessibility(); |
| + instance->set_view(view); |
| + return instance; |
| } |
| #endif |
| -NativeViewAccessibility::NativeViewAccessibility() { |
| +NativeViewAccessibility::NativeViewAccessibility() |
| + : view_(NULL) { |
| } |
| NativeViewAccessibility::~NativeViewAccessibility() { |
| } |
| gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() { |
| - return NULL; |
| + if (!ax_node_) |
| + ax_node_.reset(ui::AXPlatformNode::Create(this)); |
| + return ax_node_->GetNativeViewAccessible(); |
| } |
| void NativeViewAccessibility::Destroy() { |
| + if (ax_node_) |
| + ax_node_->Detach(); |
| delete this; |
| } |
| @@ -37,4 +49,44 @@ void NativeViewAccessibility::UnregisterWebView(View* web_view) { |
| } |
| #endif |
| +// ui::AXPlatformNodeDelegate |
| + |
| +ui::AXNodeData* NativeViewAccessibility::GetData() { |
| + ui::AXViewState state; |
| + view_->GetAccessibleState(&state); |
| + data_.role = state.role; |
| + data_.location = view_->GetBoundsInScreen(); |
| + return &data_; |
| +} |
| + |
| +int NativeViewAccessibility::GetChildCount() { |
| + return view_->child_count(); |
| +} |
| + |
| +gfx::NativeViewAccessible NativeViewAccessibility::ChildAtIndex(int index) { |
| + if (index >= view_->child_count()) |
| + return NULL; |
| + return view_->child_at(index)->GetNativeViewAccessible(); |
| +} |
| + |
| +gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { |
| + if (view_->parent()) |
| + return view_->parent()->GetNativeViewAccessible(); |
| + |
| +#if defined(OS_MACOSX) |
| + if (view_->GetWidget()) |
| + return view_->GetWidget()->GetNativeView(); |
|
Andre
2014/07/29 23:14:44
I went with this for now and deleted GetNativeView
|
| +#endif |
| + |
| + return NULL; |
| +} |
| + |
| +gfx::Vector2d NativeViewAccessibility::GetGlobalCoordinateOffset() { |
| + return gfx::Vector2d(0, 0); // location is already in screen coordinates. |
| +} |
| + |
| +void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| } // namespace views |