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

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

Issue 1162263008: Exposes datetime attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: re-upload due to browser_accessibility_cocoa.mm Created 5 years, 6 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // TODO(ctguil): The tagName in WebKit is lower cased but 375 // TODO(ctguil): The tagName in WebKit is lower cased but
376 // HTMLElement::nodeName calls localNameUpper. Consider adding 376 // HTMLElement::nodeName calls localNameUpper. Consider adding
377 // a WebElement method that returns the original lower cased tagName. 377 // a WebElement method that returns the original lower cased tagName.
378 dst->AddStringAttribute( 378 dst->AddStringAttribute(
379 ui::AX_ATTR_HTML_TAG, 379 ui::AX_ATTR_HTML_TAG,
380 base::StringToLowerASCII(UTF16ToUTF8(element.tagName()))); 380 base::StringToLowerASCII(UTF16ToUTF8(element.tagName())));
381 for (unsigned i = 0; i < element.attributeCount(); ++i) { 381 for (unsigned i = 0; i < element.attributeCount(); ++i) {
382 std::string name = base::StringToLowerASCII(UTF16ToUTF8( 382 std::string name = base::StringToLowerASCII(UTF16ToUTF8(
383 element.attributeLocalName(i))); 383 element.attributeLocalName(i)));
384 std::string value = UTF16ToUTF8(element.attributeValue(i)); 384 std::string value = UTF16ToUTF8(element.attributeValue(i));
385 dst->html_attributes.push_back(std::make_pair(name, value)); 385 dst->html_attributes.push_back(std::make_pair(name, value));
je_julie(Not used) 2015/06/10 02:16:31 We copied all html attributes to html_attributes f
dmazzoni 2015/06/10 06:43:48 Absolutely true. I think we could save even more
386 } 386 }
387 387
388 if (!src.isReadOnly() || dst->role == ui::AX_ROLE_TEXT_FIELD) { 388 if (!src.isReadOnly() || dst->role == ui::AX_ROLE_TEXT_FIELD) {
389 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart()); 389 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart());
390 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd()); 390 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd());
391 391
392 WebVector<int> src_line_breaks; 392 WebVector<int> src_line_breaks;
393 src.lineBreaks(src_line_breaks); 393 src.lineBreaks(src_line_breaks);
394 if (src_line_breaks.size() > 0) { 394 if (src_line_breaks.size() > 0) {
395 std::vector<int32> line_breaks; 395 std::vector<int32> line_breaks;
396 line_breaks.reserve(src_line_breaks.size()); 396 line_breaks.reserve(src_line_breaks.size());
397 for (size_t i = 0; i < src_line_breaks.size(); ++i) 397 for (size_t i = 0; i < src_line_breaks.size(); ++i)
398 line_breaks.push_back(src_line_breaks[i]); 398 line_breaks.push_back(src_line_breaks[i]);
399 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); 399 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks);
400 } 400 }
401
402 if (dst->role == ui::AX_ROLE_TEXT_FIELD &&
403 src.textInputType().length()) {
404 dst->AddStringAttribute(ui::AX_ATTR_TEXT_INPUT_TYPE,
405 UTF16ToUTF8(src.textInputType()));
406 }
407 } 401 }
408 402
409 blink::WebAXOptionalBool optionalBool = src.isAriaGrabbed();
410 if (optionalBool == blink::WebAXOptionalBoolFalse)
411 dst->AddBoolAttribute(ui::AX_ATTR_GRABBED, false);
412 else if (optionalBool == blink::WebAXOptionalBoolTrue)
413 dst->AddBoolAttribute(ui::AX_ATTR_GRABBED, true);
414
415 // ARIA role. 403 // ARIA role.
416 if (element.hasAttribute("role")) { 404 if (element.hasAttribute("role")) {
417 dst->AddStringAttribute(ui::AX_ATTR_ROLE, 405 dst->AddStringAttribute(ui::AX_ATTR_ROLE,
418 UTF16ToUTF8(element.getAttribute("role"))); 406 UTF16ToUTF8(element.getAttribute("role")));
419 } else { 407 } else {
420 std::string role = GetEquivalentAriaRoleString(dst->role); 408 std::string role = GetEquivalentAriaRoleString(dst->role);
421 if (!role.empty()) 409 if (!role.empty())
422 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); 410 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role);
411 else if (dst->role == ui::AX_ROLE_TIME)
412 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time");
423 } 413 }
424 414
425 // Browser plugin (used in a <webview>). 415 // Browser plugin (used in a <webview>).
426 if (node_to_browser_plugin_instance_id_map_) { 416 if (node_to_browser_plugin_instance_id_map_) {
427 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); 417 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element);
428 if (browser_plugin) { 418 if (browser_plugin) {
429 (*node_to_browser_plugin_instance_id_map_)[dst->id] = 419 (*node_to_browser_plugin_instance_id_map_)[dst->id] =
430 browser_plugin->browser_plugin_instance_id(); 420 browser_plugin->browser_plugin_instance_id();
431 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true); 421 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
432 } 422 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 WebVector<WebAXObject> controls; 591 WebVector<WebAXObject> controls;
602 if (src.ariaControls(controls)) 592 if (src.ariaControls(controls))
603 AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst); 593 AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst);
604 594
605 WebVector<WebAXObject> describedby; 595 WebVector<WebAXObject> describedby;
606 if (src.deprecatedAriaDescribedby(describedby)) { 596 if (src.deprecatedAriaDescribedby(describedby)) {
607 AddIntListAttributeFromWebObjects( 597 AddIntListAttributeFromWebObjects(
608 ui::AX_ATTR_DESCRIBEDBY_IDS, describedby, dst); 598 ui::AX_ATTR_DESCRIBEDBY_IDS, describedby, dst);
609 } 599 }
610 600
611 if (src.ariaDropEffect().length()) {
612 dst->AddStringAttribute(ui::AX_ATTR_DROPEFFECT,
613 UTF16ToUTF8(src.ariaDropEffect()));
614 }
615
616 WebVector<WebAXObject> flowTo; 601 WebVector<WebAXObject> flowTo;
617 if (src.ariaFlowTo(flowTo)) 602 if (src.ariaFlowTo(flowTo))
618 AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst); 603 AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst);
619 604
620 WebVector<WebAXObject> labelledby; 605 WebVector<WebAXObject> labelledby;
621 if (src.deprecatedAriaLabelledby(labelledby)) { 606 if (src.deprecatedAriaLabelledby(labelledby)) {
622 AddIntListAttributeFromWebObjects( 607 AddIntListAttributeFromWebObjects(
623 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); 608 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst);
624 } 609 }
625 610
626 WebVector<WebAXObject> owns; 611 WebVector<WebAXObject> owns;
627 if (src.ariaOwns(owns)) 612 if (src.ariaOwns(owns))
628 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); 613 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst);
629 } 614 }
630 615
631 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 616 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
632 if (render_frame_ && render_frame_->GetWebFrame()) 617 if (render_frame_ && render_frame_->GetWebFrame())
633 return render_frame_->GetWebFrame()->document(); 618 return render_frame_->GetWebFrame()->document();
634 return WebDocument(); 619 return WebDocument();
635 } 620 }
636 621
637 } // namespace content 622 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698