Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: mojo/services/html_viewer/ax_provider_impl.cc

Issue 1049013004: Add some simple HTMLViewer apptests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use net::SpawnedTestServer instead of mojo:http_server. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/services/html_viewer/DEPS ('k') | mojo/services/html_viewer/ax_provider_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/DEPS ('k') | mojo/services/html_viewer/ax_provider_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698