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

Side by Side Diff: content/renderer/accessibility/blink_ax_tree_source.cc

Issue 1195223006: Reports the position of the caret and current selection in content editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests. Created 5 years, 5 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
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 "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"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 const WebDocumentType& doctype = document.doctype(); 474 const WebDocumentType& doctype = document.doctype();
475 if (!doctype.isNull()) { 475 if (!doctype.isNull()) {
476 dst->AddStringAttribute(ui::AX_ATTR_DOC_DOCTYPE, 476 dst->AddStringAttribute(ui::AX_ATTR_DOC_DOCTYPE,
477 UTF16ToUTF8(doctype.name())); 477 UTF16ToUTF8(doctype.name()));
478 } 478 }
479 479
480 if (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) { 480 if (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) {
481 WebLocalFrame* frame = document.frame(); 481 WebLocalFrame* frame = document.frame();
482 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); 482 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
483 RenderFrameProxy* render_frame_proxy = nullptr;
484
483 if (render_frame) { 485 if (render_frame) {
484 (*node_to_frame_routing_id_map_)[dst->id] = 486 (*node_to_frame_routing_id_map_)[dst->id] =
485 render_frame->GetRoutingID(); 487 render_frame->GetRoutingID();
486 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
487 } else { 488 } else {
488 RenderFrameProxy* render_frame_proxy = 489 render_frame_proxy = RenderFrameProxy::FromWebFrame(frame);
489 RenderFrameProxy::FromWebFrame(frame);
490 if (render_frame_proxy) { 490 if (render_frame_proxy) {
491 (*node_to_frame_routing_id_map_)[dst->id] = 491 (*node_to_frame_routing_id_map_)[dst->id] =
492 render_frame_proxy->routing_id(); 492 render_frame_proxy->routing_id();
493 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true); 493 }
494 }
495
496 if (render_frame || render_frame_proxy) {
497 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
498
499 WebAXObject anchorObject, focusObject;
dmazzoni 2015/07/16 19:50:23 This code doesn't make sense here - it's in a bloc
500 int anchorOffset, focusOffset;
501 src.selection(anchorObject, anchorOffset, focusObject, focusOffset);
502 if (!anchorObject.isNull() && !focusObject.isNull() &&
503 anchorOffset >= 0 && focusOffset >= 0) {
504 int anchorId = anchorObject.axID();
dmazzoni 2015/07/16 19:50:23 nit: anchor_id, etc.
505 int focusId = focusObject.axID();
506 dst->AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, anchorId);
507 dst->AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, anchorOffset);
508 dst->AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, focusId);
509 dst->AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, focusOffset);
494 } 510 }
495 } 511 }
496 } 512 }
497 } 513 }
498 514
499 if (dst->role == ui::AX_ROLE_TABLE) { 515 if (dst->role == ui::AX_ROLE_TABLE) {
500 int column_count = src.columnCount(); 516 int column_count = src.columnCount();
501 int row_count = src.rowCount(); 517 int row_count = src.rowCount();
502 if (column_count > 0 && row_count > 0) { 518 if (column_count > 0 && row_count > 0) {
503 std::set<int32> unique_cell_id_set; 519 std::set<int32> unique_cell_id_set;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 } 632 }
617 } 633 }
618 634
619 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 635 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
620 if (render_frame_ && render_frame_->GetWebFrame()) 636 if (render_frame_ && render_frame_->GetWebFrame())
621 return render_frame_->GetWebFrame()->document(); 637 return render_frame_->GetWebFrame()->document();
622 return WebDocument(); 638 return WebDocument();
623 } 639 }
624 640
625 } // namespace content 641 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698