| 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 "modules/accessibility/AccessibleNode.h" |
| 6 |
| 7 #include "core/frame/Settings.h" |
| 8 #include "modules/accessibility/AXObject.h" |
| 9 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 AccessibleNode::AccessibleNode(AXObject* axObject) : m_axObject(axObject) { |
| 14 DCHECK(RuntimeEnabledFeatures::accessibilityObjectModelEnabled()); |
| 15 } |
| 16 |
| 17 AccessibleNode::~AccessibleNode() {} |
| 18 |
| 19 const AtomicString& AccessibleNode::getProperty( |
| 20 AomStringProperty property) const { |
| 21 const AtomicString& result = m_stringProperties.at(property); |
| 22 if (result.isNull()) |
| 23 return nullAtom; |
| 24 |
| 25 switch (property) { |
| 26 case AomStringProperty::Role: |
| 27 if (AXObject::ariaRoleToWebCoreRole(result) == UnknownRole) |
| 28 return nullAtom; |
| 29 break; |
| 30 case AomStringProperty::Label: |
| 31 // No validation needed. |
| 32 break; |
| 33 case AomStringProperty::None: |
| 34 NOTREACHED(); |
| 35 return nullAtom; |
| 36 } |
| 37 |
| 38 return result; |
| 39 } |
| 40 |
| 41 String AccessibleNode::role() const { |
| 42 return getProperty(AomStringProperty::Role); |
| 43 } |
| 44 |
| 45 void AccessibleNode::setRole(const String& role) { |
| 46 m_stringProperties.set(AomStringProperty::Role, AtomicString(role)); |
| 47 if (m_axObject) { |
| 48 m_axObject->updateAccessibilityRole(); |
| 49 m_axObject->notifyIfIgnoredValueChanged(); |
| 50 } |
| 51 } |
| 52 |
| 53 String AccessibleNode::label() const { |
| 54 return getProperty(AomStringProperty::Label); |
| 55 } |
| 56 |
| 57 void AccessibleNode::setLabel(const String& label) { |
| 58 m_stringProperties.set(AomStringProperty::Label, AtomicString(label)); |
| 59 if (m_axObject) |
| 60 m_axObject->axObjectCache().textChanged(m_axObject); |
| 61 } |
| 62 |
| 63 DEFINE_TRACE(AccessibleNode) { |
| 64 visitor->trace(m_axObject); |
| 65 } |
| 66 |
| 67 } // namespace blink |
| OLD | NEW |