Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/dom/AccessibleNode.h" | |
| 6 | |
| 7 #include "core/dom/AXObjectCache.h" | |
| 8 #include "core/dom/AXUtils.h" | |
| 9 #include "core/dom/Element.h" | |
| 10 #include "core/frame/Settings.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 AccessibleNode::AccessibleNode(Element* element) : m_element(element) { | |
| 15 DCHECK(RuntimeEnabledFeatures::accessibilityObjectModelEnabled()); | |
| 16 } | |
| 17 | |
| 18 AccessibleNode::~AccessibleNode() {} | |
| 19 | |
| 20 const AtomicString& AccessibleNode::getProperty( | |
| 21 AOMStringProperty property) const { | |
| 22 if (!m_element) | |
| 23 return nullAtom; | |
| 24 | |
| 25 const AtomicString& result = m_stringProperties.at(property); | |
|
esprehn
2017/03/22 03:40:31
I'd suggest using a vector instead, you probably w
dmazzoni
2017/03/23 03:36:40
The reason I did this was memory. There are 48 pro
| |
| 26 if (result.isNull()) | |
| 27 return nullAtom; | |
| 28 | |
| 29 switch (property) { | |
| 30 case AOMStringProperty::Role: | |
| 31 if (!AXUtils::getInstance()->isValidRoleAttribute(result)) | |
|
esprehn
2017/03/22 03:40:31
This feels like over abstraction going through a s
dmazzoni
2017/03/23 03:36:40
Removed, we're not doing validation for now.
| |
| 32 return nullAtom; | |
| 33 break; | |
| 34 case AOMStringProperty::Label: | |
| 35 // No validation needed. | |
| 36 break; | |
| 37 case AOMStringProperty::None: | |
| 38 NOTREACHED(); | |
| 39 return nullAtom; | |
| 40 } | |
| 41 | |
| 42 return result; | |
| 43 } | |
| 44 | |
| 45 String AccessibleNode::role() const { | |
|
esprehn
2017/03/22 03:40:31
return AtomicString
dmazzoni
2017/03/23 03:36:40
Done throughout.
| |
| 46 return getProperty(AOMStringProperty::Role); | |
| 47 } | |
| 48 | |
| 49 void AccessibleNode::setRole(const String& role) { | |
|
esprehn
2017/03/22 03:40:31
Take an AtomicString here instead
| |
| 50 if (!m_element) | |
| 51 return; | |
| 52 | |
| 53 m_stringProperties.set(AOMStringProperty::Role, AtomicString(role)); | |
| 54 | |
| 55 // TODO(dmazzoni): Make a cleaner API for this rather than pretending | |
| 56 // the DOM attribute changed. | |
| 57 if (AXObjectCache* cache = m_element->document().axObjectCache()) | |
| 58 cache->handleAttributeChanged(HTMLNames::roleAttr, m_element); | |
| 59 } | |
| 60 | |
| 61 String AccessibleNode::label() const { | |
|
esprehn
2017/03/22 03:40:31
ditto
| |
| 62 return getProperty(AOMStringProperty::Label); | |
| 63 } | |
| 64 | |
| 65 void AccessibleNode::setLabel(const String& label) { | |
|
esprehn
2017/03/22 03:40:31
ditto
| |
| 66 m_stringProperties.set(AOMStringProperty::Label, AtomicString(label)); | |
| 67 if (AXObjectCache* cache = m_element->document().axObjectCache()) | |
| 68 cache->handleAttributeChanged(HTMLNames::aria_labelAttr, m_element); | |
| 69 } | |
| 70 | |
| 71 DEFINE_TRACE(AccessibleNode) { | |
| 72 visitor->trace(m_element); | |
| 73 } | |
| 74 | |
| 75 } // namespace blink | |
| OLD | NEW |