Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / accessibility / native_view_accessibility.cc
blob6ca7676e6344d0b6339a33f10cea69cf5f19da91
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"
11 namespace views {
13 #if !defined(OS_WIN)
14 // static
15 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) {
16 DCHECK(view);
17 NativeViewAccessibility* instance = new NativeViewAccessibility();
18 instance->set_view(view);
19 return instance;
21 #endif
23 NativeViewAccessibility::NativeViewAccessibility()
24 : view_(NULL), ax_node_(ui::AXPlatformNode::Create(this)) {
27 NativeViewAccessibility::~NativeViewAccessibility() {
28 if (ax_node_)
29 ax_node_->Destroy();
32 gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() {
33 return ax_node_ ? ax_node_->GetNativeViewAccessible() : NULL;
36 void NativeViewAccessibility::Destroy() {
37 delete this;
40 #if !defined(OS_WIN)
41 // static
42 void NativeViewAccessibility::RegisterWebView(View* web_view) {
45 // static
46 void NativeViewAccessibility::UnregisterWebView(View* web_view) {
48 #endif
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();
57 return &data_;
60 int NativeViewAccessibility::GetChildCount() {
61 return view_->child_count();
64 gfx::NativeViewAccessible NativeViewAccessibility::ChildAtIndex(int index) {
65 if (index < 0 || index >= view_->child_count())
66 return NULL;
67 return view_->child_at(index)->GetNativeViewAccessible();
70 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() {
71 if (view_->parent())
72 return view_->parent()->GetNativeViewAccessible();
74 #if defined(OS_MACOSX)
75 if (view_->GetWidget())
76 return view_->GetWidget()->GetNativeView();
77 #endif
79 return NULL;
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) {
89 } // namespace views