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

Side by Side Diff: third_party/WebKit/Source/core/dom/AccessibleNode.cpp

Issue 2788523002: Finish all string attributes for Accessibility Object Model Phase 1. (Closed)
Patch Set: Rebase Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "core/dom/AccessibleNode.h" 5 #include "core/dom/AccessibleNode.h"
6 6
7 #include "core/dom/AXObjectCache.h" 7 #include "core/dom/AXObjectCache.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/QualifiedName.h" 9 #include "core/dom/QualifiedName.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void AccessibleNode::setRole(const AtomicString& role) { 49 void AccessibleNode::setRole(const AtomicString& role) {
50 setStringProperty(AOMStringProperty::kRole, role); 50 setStringProperty(AOMStringProperty::kRole, role);
51 51
52 // TODO(dmazzoni): Make a cleaner API for this rather than pretending 52 // TODO(dmazzoni): Make a cleaner API for this rather than pretending
53 // the DOM attribute changed. 53 // the DOM attribute changed.
54 if (AXObjectCache* cache = m_element->document().axObjectCache()) 54 if (AXObjectCache* cache = m_element->document().axObjectCache())
55 cache->handleAttributeChanged(HTMLNames::roleAttr, m_element); 55 cache->handleAttributeChanged(HTMLNames::roleAttr, m_element);
56 } 56 }
57 57
58 AtomicString AccessibleNode::label() const { 58 AtomicString AccessibleNode::roleDescription() const {
59 return getProperty(m_element, AOMStringProperty::kLabel); 59 return getProperty(m_element, AOMStringProperty::kRoleDescription);
60 }
61
62 void AccessibleNode::setRoleDescription(const AtomicString& roleDescription) {
63 setStringProperty(AOMStringProperty::kRoleDescription, roleDescription);
64
65 if (AXObjectCache* cache = m_element->document().axObjectCache()) {
66 cache->handleAttributeChanged(HTMLNames::aria_roledescriptionAttr,
67 m_element);
68 }
69 }
70
71 AtomicString AccessibleNode::sort() const {
72 return getProperty(m_element, AOMStringProperty::kSort);
73 }
74
75 void AccessibleNode::setSort(const AtomicString& sort) {
76 setStringProperty(AOMStringProperty::kSort, sort);
77
78 if (AXObjectCache* cache = m_element->document().axObjectCache())
79 cache->handleAttributeChanged(HTMLNames::aria_sortAttr, m_element);
80 }
81
82 AtomicString AccessibleNode::valueText() const {
83 return getProperty(m_element, AOMStringProperty::kValueText);
60 } 84 }
61 85
62 void AccessibleNode::setLabel(const AtomicString& label) { 86 void AccessibleNode::setLabel(const AtomicString& label) {
63 setStringProperty(AOMStringProperty::kLabel, label); 87 setStringProperty(AOMStringProperty::kLabel, label);
64 88
65 if (AXObjectCache* cache = m_element->document().axObjectCache()) 89 if (AXObjectCache* cache = m_element->document().axObjectCache())
66 cache->handleAttributeChanged(HTMLNames::aria_labelAttr, m_element); 90 cache->handleAttributeChanged(HTMLNames::aria_labelAttr, m_element);
67 } 91 }
68 92
69 void AccessibleNode::setStringProperty(AOMStringProperty property, 93 void AccessibleNode::setStringProperty(AOMStringProperty property,
70 const AtomicString& value) { 94 const AtomicString& value) {
71 for (auto& item : m_stringProperties) { 95 for (auto& item : m_stringProperties) {
72 if (item.first == property) { 96 if (item.first == property) {
73 item.second = value; 97 item.second = value;
74 return; 98 return;
75 } 99 }
76 } 100 }
77 101
78 m_stringProperties.push_back(std::make_pair(property, value)); 102 m_stringProperties.push_back(std::make_pair(property, value));
79 } 103 }
80 104
81 DEFINE_TRACE(AccessibleNode) { 105 DEFINE_TRACE(AccessibleNode) {
82 visitor->trace(m_element); 106 visitor->trace(m_element);
83 } 107 }
84 108
85 } // namespace blink 109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698