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 "content/renderer/accessibility/blink_ax_tree_source.h" | 5 #include "content/renderer/accessibility/blink_ax_tree_source.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
13 #include "content/renderer/render_frame_impl.h" | |
14 #include "content/renderer/render_view_impl.h" | 13 #include "content/renderer/render_view_impl.h" |
15 #include "third_party/WebKit/public/platform/WebRect.h" | 14 #include "third_party/WebKit/public/platform/WebRect.h" |
16 #include "third_party/WebKit/public/platform/WebSize.h" | 15 #include "third_party/WebKit/public/platform/WebSize.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
19 #include "third_party/WebKit/public/web/WebAXEnums.h" | 18 #include "third_party/WebKit/public/web/WebAXEnums.h" |
20 #include "third_party/WebKit/public/web/WebAXObject.h" | 19 #include "third_party/WebKit/public/web/WebAXObject.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebDocumentType.h" | 21 #include "third_party/WebKit/public/web/WebDocumentType.h" |
23 #include "third_party/WebKit/public/web/WebElement.h" | 22 #include "third_party/WebKit/public/web/WebElement.h" |
24 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 23 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
25 #include "third_party/WebKit/public/web/WebInputElement.h" | 24 #include "third_party/WebKit/public/web/WebInputElement.h" |
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 25 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
27 #include "third_party/WebKit/public/web/WebNode.h" | 26 #include "third_party/WebKit/public/web/WebNode.h" |
28 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
29 | 28 |
30 using base::ASCIIToUTF16; | 29 using base::ASCIIToUTF16; |
31 using base::UTF16ToUTF8; | 30 using base::UTF16ToUTF8; |
32 using blink::WebAXObject; | 31 using blink::WebAXObject; |
33 using blink::WebDocument; | 32 using blink::WebDocument; |
34 using blink::WebDocumentType; | 33 using blink::WebDocumentType; |
35 using blink::WebElement; | 34 using blink::WebElement; |
36 using blink::WebFrame; | |
37 using blink::WebLocalFrame; | 35 using blink::WebLocalFrame; |
38 using blink::WebNode; | 36 using blink::WebNode; |
39 using blink::WebVector; | 37 using blink::WebVector; |
40 using blink::WebView; | 38 using blink::WebView; |
41 | 39 |
42 namespace content { | 40 namespace content { |
43 | 41 |
44 namespace { | 42 namespace { |
45 | 43 |
46 // Returns true if |ancestor| is the first unignored parent of |child|, | 44 // Returns true if |ancestor| is the first unignored parent of |child|, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ui::AXNodeData* dst) { | 86 ui::AXNodeData* dst) { |
89 std::vector<int32> ids; | 87 std::vector<int32> ids; |
90 for(size_t i = 0; i < objects.size(); i++) | 88 for(size_t i = 0; i < objects.size(); i++) |
91 ids.push_back(objects[i].axID()); | 89 ids.push_back(objects[i].axID()); |
92 if (ids.size() > 0) | 90 if (ids.size() > 0) |
93 dst->AddIntListAttribute(attr, ids); | 91 dst->AddIntListAttribute(attr, ids); |
94 } | 92 } |
95 | 93 |
96 } // Anonymous namespace | 94 } // Anonymous namespace |
97 | 95 |
98 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) | 96 BlinkAXTreeSource::BlinkAXTreeSource(RenderViewImpl* render_view) |
99 : render_frame_(render_frame) { | 97 : render_view_(render_view) { |
100 } | 98 } |
101 | 99 |
102 BlinkAXTreeSource::~BlinkAXTreeSource() { | 100 BlinkAXTreeSource::~BlinkAXTreeSource() { |
103 } | 101 } |
104 | 102 |
105 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { | 103 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { |
106 const blink::WebAXObject& root = GetRoot(); | 104 const blink::WebAXObject& root = GetRoot(); |
107 while (IsValid(node)) { | 105 while (IsValid(node)) { |
108 if (node.equals(root)) | 106 if (node.equals(root)) |
109 return true; | 107 return true; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 AddIntListAttributeFromWebObjects( | 543 AddIntListAttributeFromWebObjects( |
546 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); | 544 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); |
547 } | 545 } |
548 | 546 |
549 WebVector<WebAXObject> owns; | 547 WebVector<WebAXObject> owns; |
550 if (src.ariaOwns(owns)) | 548 if (src.ariaOwns(owns)) |
551 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | 549 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); |
552 } | 550 } |
553 | 551 |
554 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 552 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
555 WebView* view = render_frame_->render_view()->GetWebView(); | 553 WebView* view = render_view_->GetWebView(); |
556 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 554 WebLocalFrame* main_frame = |
| 555 view ? view->mainFrame()->toWebLocalFrame() : NULL; |
557 | 556 |
558 if (main_frame) | 557 if (main_frame) |
559 return main_frame->document(); | 558 return main_frame->document(); |
| 559 |
560 return WebDocument(); | 560 return WebDocument(); |
561 } | 561 } |
562 | 562 |
563 } // namespace content | 563 } // namespace content |
OLD | NEW |