| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace html_viewer { | 21 namespace html_viewer { |
| 22 | 22 |
| 23 AxProviderImpl::AxProviderImpl(WebView* web_view) : web_view_(web_view) { | 23 AxProviderImpl::AxProviderImpl(WebView* web_view) : web_view_(web_view) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 void AxProviderImpl::GetTree( | 26 void AxProviderImpl::GetTree( |
| 27 const mojo::Callback<void(Array<AxNodePtr> nodes)>& callback) { | 27 const mojo::Callback<void(Array<AxNodePtr> nodes)>& callback) { |
| 28 web_view_->settings()->setAccessibilityEnabled(true); | 28 web_view_->settings()->setAccessibilityEnabled(true); |
| 29 web_view_->settings()->setInlineTextBoxAccessibilityEnabled(true); | 29 web_view_->settings()->setInlineTextBoxAccessibilityEnabled(true); |
| 30 | 30 |
| 31 Array<AxNodePtr> result; | 31 // TODO(msw): Is this a deep copy? |
| 32 Populate(web_view_->accessibilityObject(), 0, 0, &result); | 32 WebAXObject web_ax_object = web_view_->accessibilityObject(); |
| 33 callback.Run(result.Pass()); | 33 DCHECK(!web_ax_object.isDetached()); |
| 34 if (web_ax_object.updateLayoutAndCheckValidity()) { |
| 35 Array<AxNodePtr> result; |
| 36 Populate(web_ax_object, 0, 0, &result); |
| 37 callback.Run(result.Pass()); |
| 38 } |
| 34 } | 39 } |
| 35 | 40 |
| 36 int AxProviderImpl::Populate(const WebAXObject& ax_object, | 41 int AxProviderImpl::Populate(const WebAXObject& ax_object, |
| 37 int parent_id, | 42 int parent_id, |
| 38 int next_sibling_id, | 43 int next_sibling_id, |
| 39 Array<AxNodePtr>* result) { | 44 Array<AxNodePtr>* result) { |
| 40 AxNodePtr ax_node(ConvertAxNode(ax_object, parent_id, next_sibling_id)); | 45 AxNodePtr ax_node(ConvertAxNode(ax_object, parent_id, next_sibling_id)); |
| 41 int ax_node_id = ax_node->id; | 46 int ax_node_id = ax_node->id; |
| 42 if (ax_node.is_null()) | 47 if (ax_node.is_null()) |
| 43 return 0; | 48 return 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } else if (ax_object.childCount() == 0 && | 82 } else if (ax_object.childCount() == 0 && |
| 78 !ax_object.stringValue().isEmpty()) { | 83 !ax_object.stringValue().isEmpty()) { |
| 79 result->text = mojo::AxText::New(); | 84 result->text = mojo::AxText::New(); |
| 80 result->text->content = String::From(ax_object.stringValue()); | 85 result->text->content = String::From(ax_object.stringValue()); |
| 81 } | 86 } |
| 82 | 87 |
| 83 return result.Pass(); | 88 return result.Pass(); |
| 84 } | 89 } |
| 85 | 90 |
| 86 } // namespace html_viewer | 91 } // namespace html_viewer |
| OLD | NEW |