| Index: third_party/WebKit/Source/modules/accessibility/AccessibleNode.cpp
|
| diff --git a/third_party/WebKit/Source/modules/accessibility/AccessibleNode.cpp b/third_party/WebKit/Source/modules/accessibility/AccessibleNode.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2a9b29b7bf21c397854402e7baca10fd3d5d3c23
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/accessibility/AccessibleNode.cpp
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "modules/accessibility/AccessibleNode.h"
|
| +
|
| +#include "core/frame/Settings.h"
|
| +#include "modules/accessibility/AXObject.h"
|
| +#include "modules/accessibility/AXObjectCacheImpl.h"
|
| +
|
| +namespace blink {
|
| +
|
| +AccessibleNode::AccessibleNode(AXObject* axObject) : m_axObject(axObject) {
|
| + DCHECK(RuntimeEnabledFeatures::accessibilityObjectModelEnabled());
|
| +}
|
| +
|
| +AccessibleNode::~AccessibleNode() {}
|
| +
|
| +const AtomicString& AccessibleNode::getProperty(
|
| + AomStringProperty property) const {
|
| + const AtomicString& result = m_stringProperties.at(property);
|
| + if (result.isNull())
|
| + return nullAtom;
|
| +
|
| + switch (property) {
|
| + case AomStringProperty::Role:
|
| + if (AXObject::ariaRoleToWebCoreRole(result) == UnknownRole)
|
| + return nullAtom;
|
| + break;
|
| + case AomStringProperty::Label:
|
| + // No validation needed.
|
| + break;
|
| + case AomStringProperty::None:
|
| + NOTREACHED();
|
| + return nullAtom;
|
| + }
|
| +
|
| + return result;
|
| +}
|
| +
|
| +String AccessibleNode::role() const {
|
| + return getProperty(AomStringProperty::Role);
|
| +}
|
| +
|
| +void AccessibleNode::setRole(const String& role) {
|
| + m_stringProperties.set(AomStringProperty::Role, AtomicString(role));
|
| + if (m_axObject) {
|
| + m_axObject->updateAccessibilityRole();
|
| + m_axObject->notifyIfIgnoredValueChanged();
|
| + }
|
| +}
|
| +
|
| +String AccessibleNode::label() const {
|
| + return getProperty(AomStringProperty::Label);
|
| +}
|
| +
|
| +void AccessibleNode::setLabel(const String& label) {
|
| + m_stringProperties.set(AomStringProperty::Label, AtomicString(label));
|
| + if (m_axObject)
|
| + m_axObject->axObjectCache().textChanged(m_axObject);
|
| +}
|
| +
|
| +DEFINE_TRACE(AccessibleNode) {
|
| + visitor->trace(m_axObject);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|