OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/html_viewer/ax_provider_impl.h" | 5 #include "mojo/services/html_viewer/ax_provider_impl.h" |
6 | 6 |
7 #include "mojo/services/html_viewer/blink_basic_type_converters.h" | 7 #include "mojo/services/html_viewer/blink_basic_type_converters.h" |
8 #include "third_party/WebKit/public/platform/WebURL.h" | 8 #include "third_party/WebKit/public/platform/WebURL.h" |
9 #include "third_party/WebKit/public/web/WebAXObject.h" | 9 #include "third_party/WebKit/public/web/WebAXObject.h" |
10 #include "third_party/WebKit/public/web/WebSettings.h" | 10 #include "third_party/WebKit/public/web/WebSettings.h" |
11 #include "third_party/WebKit/public/web/WebView.h" | 11 #include "third_party/WebKit/public/web/WebView.h" |
12 | 12 |
13 using blink::WebAXObject; | 13 using blink::WebAXObject; |
14 using blink::WebURL; | 14 using blink::WebURL; |
15 using blink::WebView; | 15 using blink::WebView; |
16 | 16 |
17 namespace mojo { | 17 using mojo::Array; |
| 18 using mojo::AxNodePtr; |
| 19 using mojo::String; |
| 20 |
| 21 namespace html_viewer { |
18 | 22 |
19 AxProviderImpl::AxProviderImpl(WebView* web_view) : web_view_(web_view) { | 23 AxProviderImpl::AxProviderImpl(WebView* web_view) : web_view_(web_view) { |
20 } | 24 } |
21 | 25 |
22 void AxProviderImpl::GetTree( | 26 void AxProviderImpl::GetTree( |
23 const Callback<void(Array<AxNodePtr> nodes)>& callback) { | 27 const mojo::Callback<void(Array<AxNodePtr> nodes)>& callback) { |
24 web_view_->settings()->setAccessibilityEnabled(true); | 28 web_view_->settings()->setAccessibilityEnabled(true); |
25 web_view_->settings()->setInlineTextBoxAccessibilityEnabled(true); | 29 web_view_->settings()->setInlineTextBoxAccessibilityEnabled(true); |
26 | 30 |
27 Array<AxNodePtr> result; | 31 Array<AxNodePtr> result; |
28 Populate(web_view_->accessibilityObject(), 0, 0, &result); | 32 Populate(web_view_->accessibilityObject(), 0, 0, &result); |
29 callback.Run(result.Pass()); | 33 callback.Run(result.Pass()); |
30 } | 34 } |
31 | 35 |
32 int AxProviderImpl::Populate(const WebAXObject& ax_object, | 36 int AxProviderImpl::Populate(const WebAXObject& ax_object, |
33 int parent_id, | 37 int parent_id, |
(...skipping 20 matching lines...) Expand all Loading... |
54 return ax_node_id; | 58 return ax_node_id; |
55 } | 59 } |
56 | 60 |
57 AxNodePtr AxProviderImpl::ConvertAxNode(const WebAXObject& ax_object, | 61 AxNodePtr AxProviderImpl::ConvertAxNode(const WebAXObject& ax_object, |
58 int parent_id, | 62 int parent_id, |
59 int next_sibling_id) { | 63 int next_sibling_id) { |
60 AxNodePtr result; | 64 AxNodePtr result; |
61 if (!const_cast<WebAXObject&>(ax_object).updateLayoutAndCheckValidity()) | 65 if (!const_cast<WebAXObject&>(ax_object).updateLayoutAndCheckValidity()) |
62 return result.Pass(); | 66 return result.Pass(); |
63 | 67 |
64 result = AxNode::New(); | 68 result = mojo::AxNode::New(); |
65 result->id = static_cast<int>(ax_object.axID()); | 69 result->id = static_cast<int>(ax_object.axID()); |
66 result->parent_id = parent_id; | 70 result->parent_id = parent_id; |
67 result->next_sibling_id = next_sibling_id; | 71 result->next_sibling_id = next_sibling_id; |
68 result->bounds = Rect::From(ax_object.boundingBoxRect()); | 72 result->bounds = mojo::Rect::From(ax_object.boundingBoxRect()); |
69 | 73 |
70 if (ax_object.isAnchor()) { | 74 if (ax_object.isAnchor()) { |
71 result->link = AxLink::New(); | 75 result->link = mojo::AxLink::New(); |
72 result->link->url = String::From(ax_object.url().string()); | 76 result->link->url = String::From(ax_object.url().string()); |
73 } else if (ax_object.childCount() == 0 && | 77 } else if (ax_object.childCount() == 0 && |
74 !ax_object.stringValue().isEmpty()) { | 78 !ax_object.stringValue().isEmpty()) { |
75 result->text = AxText::New(); | 79 result->text = mojo::AxText::New(); |
76 result->text->content = String::From(ax_object.stringValue()); | 80 result->text->content = String::From(ax_object.stringValue()); |
77 } | 81 } |
78 | 82 |
79 return result.Pass(); | 83 return result.Pass(); |
80 } | 84 } |
81 | 85 |
82 } // namespace mojo | 86 } // namespace html_viewer |
OLD | NEW |