| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
| 15 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 15 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
| 16 #include "content/renderer/accessibility/render_accessibility_impl.h" | 16 #include "content/renderer/accessibility/render_accessibility_impl.h" |
| 17 #include "content/renderer/browser_plugin/browser_plugin.h" | 17 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 18 #include "content/renderer/render_frame_impl.h" | 18 #include "content/renderer/render_frame_impl.h" |
| 19 #include "content/renderer/render_frame_proxy.h" | 19 #include "content/renderer/render_frame_proxy.h" |
| 20 #include "content/renderer/render_view_impl.h" | 20 #include "content/renderer/render_view_impl.h" |
| 21 #include "content/renderer/web_frame_utils.h" | 21 #include "content/renderer/web_frame_utils.h" |
| 22 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 22 #include "third_party/WebKit/public/platform/WebRect.h" | 23 #include "third_party/WebKit/public/platform/WebRect.h" |
| 23 #include "third_party/WebKit/public/platform/WebSize.h" | 24 #include "third_party/WebKit/public/platform/WebSize.h" |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/public/platform/WebVector.h" | 26 #include "third_party/WebKit/public/platform/WebVector.h" |
| 26 #include "third_party/WebKit/public/web/WebAXEnums.h" | 27 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 27 #include "third_party/WebKit/public/web/WebAXObject.h" | 28 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 28 #include "third_party/WebKit/public/web/WebDocument.h" | 29 #include "third_party/WebKit/public/web/WebDocument.h" |
| 29 #include "third_party/WebKit/public/web/WebElement.h" | 30 #include "third_party/WebKit/public/web/WebElement.h" |
| 30 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 31 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 31 #include "third_party/WebKit/public/web/WebFrame.h" | 32 #include "third_party/WebKit/public/web/WebFrame.h" |
| 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 33 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 33 #include "third_party/WebKit/public/web/WebNode.h" | 34 #include "third_party/WebKit/public/web/WebNode.h" |
| 34 #include "third_party/WebKit/public/web/WebPlugin.h" | 35 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 35 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 36 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 36 #include "third_party/WebKit/public/web/WebView.h" | 37 #include "third_party/WebKit/public/web/WebView.h" |
| 37 | 38 |
| 38 using base::ASCIIToUTF16; | 39 using base::ASCIIToUTF16; |
| 39 using base::UTF16ToUTF8; | 40 using base::UTF16ToUTF8; |
| 40 using blink::WebAXObject; | 41 using blink::WebAXObject; |
| 41 using blink::WebDocument; | 42 using blink::WebDocument; |
| 42 using blink::WebElement; | 43 using blink::WebElement; |
| 44 using blink::WebFloatRect; |
| 43 using blink::WebFrame; | 45 using blink::WebFrame; |
| 44 using blink::WebLocalFrame; | 46 using blink::WebLocalFrame; |
| 45 using blink::WebNode; | 47 using blink::WebNode; |
| 46 using blink::WebPlugin; | 48 using blink::WebPlugin; |
| 47 using blink::WebPluginContainer; | 49 using blink::WebPluginContainer; |
| 48 using blink::WebVector; | 50 using blink::WebVector; |
| 49 using blink::WebView; | 51 using blink::WebView; |
| 50 | 52 |
| 51 namespace content { | 53 namespace content { |
| 52 | 54 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 260 } |
| 259 | 261 |
| 260 blink::WebAXObject BlinkAXTreeSource::GetNull() const { | 262 blink::WebAXObject BlinkAXTreeSource::GetNull() const { |
| 261 return blink::WebAXObject(); | 263 return blink::WebAXObject(); |
| 262 } | 264 } |
| 263 | 265 |
| 264 void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, | 266 void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, |
| 265 AXContentNodeData* dst) const { | 267 AXContentNodeData* dst) const { |
| 266 dst->role = AXRoleFromBlink(src.role()); | 268 dst->role = AXRoleFromBlink(src.role()); |
| 267 dst->state = AXStateFromBlink(src); | 269 dst->state = AXStateFromBlink(src); |
| 268 dst->location = gfx::RectF(src.boundingBoxRect()); | |
| 269 dst->id = src.axID(); | 270 dst->id = src.axID(); |
| 270 | 271 |
| 272 WebAXObject offset_container; |
| 273 WebFloatRect bounds_in_container; |
| 274 SkMatrix44 container_transform; |
| 275 src.getRelativeBounds( |
| 276 offset_container, bounds_in_container, container_transform); |
| 277 dst->location = bounds_in_container; |
| 278 if (!container_transform.isIdentity()) |
| 279 dst->transform = base::WrapUnique(new gfx::Transform(container_transform)); |
| 280 if (!offset_container.isDetached()) |
| 281 dst->offset_container_id = offset_container.axID(); |
| 282 |
| 271 blink::WebAXNameFrom nameFrom; | 283 blink::WebAXNameFrom nameFrom; |
| 272 blink::WebVector<blink::WebAXObject> nameObjects; | 284 blink::WebVector<blink::WebAXObject> nameObjects; |
| 273 blink::WebString web_name = src.name(nameFrom, nameObjects); | 285 blink::WebString web_name = src.name(nameFrom, nameObjects); |
| 274 if (!web_name.isEmpty()) { | 286 if (!web_name.isEmpty()) { |
| 275 dst->AddStringAttribute(ui::AX_ATTR_NAME, web_name.utf8()); | 287 dst->AddStringAttribute(ui::AX_ATTR_NAME, web_name.utf8()); |
| 276 dst->AddIntAttribute(ui::AX_ATTR_NAME_FROM, AXNameFromFromBlink(nameFrom)); | 288 dst->AddIntAttribute(ui::AX_ATTR_NAME_FROM, AXNameFromFromBlink(nameFrom)); |
| 277 AddIntListAttributeFromWebObjects( | 289 AddIntListAttributeFromWebObjects( |
| 278 ui::AX_ATTR_LABELLEDBY_IDS, nameObjects, dst); | 290 ui::AX_ATTR_LABELLEDBY_IDS, nameObjects, dst); |
| 279 } | 291 } |
| 280 | 292 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 dst->role == ui::AX_ROLE_SCROLL_BAR || | 586 dst->role == ui::AX_ROLE_SCROLL_BAR || |
| 575 dst->role == ui::AX_ROLE_SLIDER || | 587 dst->role == ui::AX_ROLE_SLIDER || |
| 576 dst->role == ui::AX_ROLE_SPIN_BUTTON) { | 588 dst->role == ui::AX_ROLE_SPIN_BUTTON) { |
| 577 dst->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, src.valueForRange()); | 589 dst->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, src.valueForRange()); |
| 578 dst->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, | 590 dst->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, |
| 579 src.maxValueForRange()); | 591 src.maxValueForRange()); |
| 580 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, | 592 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, |
| 581 src.minValueForRange()); | 593 src.minValueForRange()); |
| 582 } | 594 } |
| 583 | 595 |
| 584 if (dst->role == ui::AX_ROLE_ROOT_WEB_AREA) { | 596 if (dst->role == ui::AX_ROLE_ROOT_WEB_AREA) |
| 585 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); | 597 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); |
| 586 dst->transform.reset( | |
| 587 new gfx::Transform(src.transformFromLocalParentFrame())); | |
| 588 } | |
| 589 | 598 |
| 590 if (dst->role == ui::AX_ROLE_TABLE) { | 599 if (dst->role == ui::AX_ROLE_TABLE) { |
| 591 int column_count = src.columnCount(); | 600 int column_count = src.columnCount(); |
| 592 int row_count = src.rowCount(); | 601 int row_count = src.rowCount(); |
| 593 if (column_count > 0 && row_count > 0) { | 602 if (column_count > 0 && row_count > 0) { |
| 594 std::set<int32_t> unique_cell_id_set; | 603 std::set<int32_t> unique_cell_id_set; |
| 595 std::vector<int32_t> cell_ids; | 604 std::vector<int32_t> cell_ids; |
| 596 std::vector<int32_t> unique_cell_ids; | 605 std::vector<int32_t> unique_cell_ids; |
| 597 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); | 606 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); |
| 598 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); | 607 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 697 } |
| 689 } | 698 } |
| 690 | 699 |
| 691 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 700 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 692 if (render_frame_ && render_frame_->GetWebFrame()) | 701 if (render_frame_ && render_frame_->GetWebFrame()) |
| 693 return render_frame_->GetWebFrame()->document(); | 702 return render_frame_->GetWebFrame()->document(); |
| 694 return WebDocument(); | 703 return WebDocument(); |
| 695 } | 704 } |
| 696 | 705 |
| 697 } // namespace content | 706 } // namespace content |
| OLD | NEW |