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
3 // found in the LICENSE file.
5 #include "ui/views/accessibility/native_view_accessibility.h"
7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/views/view.h"
9 #include "ui/views/widget/widget.h"
15 NativeViewAccessibility
* NativeViewAccessibility::Create(View
* view
) {
17 NativeViewAccessibility
* instance
= new NativeViewAccessibility();
18 instance
->set_view(view
);
23 NativeViewAccessibility::NativeViewAccessibility()
24 : view_(NULL
), ax_node_(ui::AXPlatformNode::Create(this)) {
27 NativeViewAccessibility::~NativeViewAccessibility() {
32 gfx::NativeViewAccessible
NativeViewAccessibility::GetNativeObject() {
33 return ax_node_
? ax_node_
->GetNativeViewAccessible() : NULL
;
36 void NativeViewAccessibility::Destroy() {
42 void NativeViewAccessibility::RegisterWebView(View
* web_view
) {
46 void NativeViewAccessibility::UnregisterWebView(View
* web_view
) {
50 // ui::AXPlatformNodeDelegate
52 ui::AXNodeData
* NativeViewAccessibility::GetData() {
53 ui::AXViewState state
;
54 view_
->GetAccessibleState(&state
);
55 data_
.role
= state
.role
;
56 data_
.location
= view_
->GetBoundsInScreen();
60 int NativeViewAccessibility::GetChildCount() {
61 return view_
->child_count();
64 gfx::NativeViewAccessible
NativeViewAccessibility::ChildAtIndex(int index
) {
65 if (index
< 0 || index
>= view_
->child_count())
67 return view_
->child_at(index
)->GetNativeViewAccessible();
70 gfx::NativeViewAccessible
NativeViewAccessibility::GetParent() {
72 return view_
->parent()->GetNativeViewAccessible();
74 #if defined(OS_MACOSX)
75 if (view_
->GetWidget())
76 return view_
->GetWidget()->GetNativeView();
82 gfx::Vector2d
NativeViewAccessibility::GetGlobalCoordinateOffset() {
83 return gfx::Vector2d(0, 0); // location is already in screen coordinates.
86 void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type
) {