| Index: third_party/WebKit/Source/core/dom/AccessibleNode.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/AccessibleNode.cpp b/third_party/WebKit/Source/core/dom/AccessibleNode.cpp
|
| index 8e5437aaf2d5c3c11e96f8e183cf8a849af7bbe3..bba81148d06cbc5a1899bb30cdc988d5ed9c3453 100644
|
| --- a/third_party/WebKit/Source/core/dom/AccessibleNode.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/AccessibleNode.cpp
|
| @@ -35,39 +35,107 @@ const AtomicString& AccessibleNode::GetProperty(Element* element,
|
| // Fall back on the equivalent ARIA attribute.
|
| switch (property) {
|
| case AOMStringProperty::kAutocomplete:
|
| - return element->getAttribute(aria_autocompleteAttr);
|
| + return element->FastGetAttribute(aria_autocompleteAttr);
|
| case AOMStringProperty::kChecked:
|
| - return element->getAttribute(aria_checkedAttr);
|
| + return element->FastGetAttribute(aria_checkedAttr);
|
| case AOMStringProperty::kCurrent:
|
| - return element->getAttribute(aria_currentAttr);
|
| + return element->FastGetAttribute(aria_currentAttr);
|
| case AOMStringProperty::kInvalid:
|
| - return element->getAttribute(aria_invalidAttr);
|
| + return element->FastGetAttribute(aria_invalidAttr);
|
| case AOMStringProperty::kKeyShortcuts:
|
| - return element->getAttribute(aria_keyshortcutsAttr);
|
| + return element->FastGetAttribute(aria_keyshortcutsAttr);
|
| case AOMStringProperty::kLabel:
|
| - return element->getAttribute(aria_labelAttr);
|
| + return element->FastGetAttribute(aria_labelAttr);
|
| case AOMStringProperty::kLive:
|
| - return element->getAttribute(aria_liveAttr);
|
| + return element->FastGetAttribute(aria_liveAttr);
|
| case AOMStringProperty::kOrientation:
|
| - return element->getAttribute(aria_orientationAttr);
|
| + return element->FastGetAttribute(aria_orientationAttr);
|
| case AOMStringProperty::kPlaceholder:
|
| - return element->getAttribute(aria_placeholderAttr);
|
| + return element->FastGetAttribute(aria_placeholderAttr);
|
| case AOMStringProperty::kRelevant:
|
| - return element->getAttribute(aria_relevantAttr);
|
| + return element->FastGetAttribute(aria_relevantAttr);
|
| case AOMStringProperty::kRole:
|
| - return element->getAttribute(roleAttr);
|
| + return element->FastGetAttribute(roleAttr);
|
| case AOMStringProperty::kRoleDescription:
|
| - return element->getAttribute(aria_roledescriptionAttr);
|
| + return element->FastGetAttribute(aria_roledescriptionAttr);
|
| case AOMStringProperty::kSort:
|
| - return element->getAttribute(aria_sortAttr);
|
| + return element->FastGetAttribute(aria_sortAttr);
|
| case AOMStringProperty::kValueText:
|
| - return element->getAttribute(aria_valuetextAttr);
|
| + return element->FastGetAttribute(aria_valuetextAttr);
|
| }
|
|
|
| NOTREACHED();
|
| return g_null_atom;
|
| }
|
|
|
| +// static
|
| +bool AccessibleNode::GetProperty(Element* element,
|
| + AOMBooleanProperty property,
|
| + bool& is_null) {
|
| + is_null = true;
|
| + if (!element)
|
| + return false;
|
| +
|
| + if (AccessibleNode* accessible_node = element->ExistingAccessibleNode()) {
|
| + for (const auto& item : accessible_node->boolean_properties_) {
|
| + if (item.first == property) {
|
| + is_null = false;
|
| + return item.second;
|
| + }
|
| + }
|
| + }
|
| +
|
| + // Fall back on the equivalent ARIA attribute.
|
| + AtomicString attr_value;
|
| + switch (property) {
|
| + case AOMBooleanProperty::kAtomic:
|
| + attr_value = element->FastGetAttribute(aria_atomicAttr);
|
| + break;
|
| + case AOMBooleanProperty::kBusy:
|
| + attr_value = element->FastGetAttribute(aria_busyAttr);
|
| + break;
|
| + case AOMBooleanProperty::kDisabled:
|
| + attr_value = element->FastGetAttribute(aria_disabledAttr);
|
| + break;
|
| + case AOMBooleanProperty::kExpanded:
|
| + attr_value = element->FastGetAttribute(aria_expandedAttr);
|
| + break;
|
| + case AOMBooleanProperty::kHidden:
|
| + attr_value = element->FastGetAttribute(aria_hiddenAttr);
|
| + break;
|
| + case AOMBooleanProperty::kModal:
|
| + attr_value = element->FastGetAttribute(aria_modalAttr);
|
| + break;
|
| + case AOMBooleanProperty::kMultiline:
|
| + attr_value = element->FastGetAttribute(aria_multilineAttr);
|
| + break;
|
| + case AOMBooleanProperty::kMultiselectable:
|
| + attr_value = element->FastGetAttribute(aria_multiselectableAttr);
|
| + break;
|
| + case AOMBooleanProperty::kReadOnly:
|
| + attr_value = element->FastGetAttribute(aria_readonlyAttr);
|
| + break;
|
| + case AOMBooleanProperty::kRequired:
|
| + attr_value = element->FastGetAttribute(aria_requiredAttr);
|
| + break;
|
| + case AOMBooleanProperty::kSelected:
|
| + attr_value = element->FastGetAttribute(aria_selectedAttr);
|
| + break;
|
| + }
|
| +
|
| + is_null = attr_value.IsNull();
|
| + return EqualIgnoringASCIICase(attr_value, "true");
|
| +}
|
| +
|
| +bool AccessibleNode::atomic(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kAtomic, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setAtomic(bool atomic, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kAtomic, atomic);
|
| + NotifyAttributeChanged(aria_atomicAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::autocomplete() const {
|
| return GetProperty(element_, AOMStringProperty::kAutocomplete);
|
| }
|
| @@ -77,6 +145,15 @@ void AccessibleNode::setAutocomplete(const AtomicString& autocomplete) {
|
| NotifyAttributeChanged(aria_autocompleteAttr);
|
| }
|
|
|
| +bool AccessibleNode::busy(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kBusy, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setBusy(bool busy, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kBusy, busy);
|
| + NotifyAttributeChanged(aria_busyAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::checked() const {
|
| return GetProperty(element_, AOMStringProperty::kChecked);
|
| }
|
| @@ -97,6 +174,33 @@ void AccessibleNode::setCurrent(const AtomicString& current) {
|
| cache->HandleAttributeChanged(aria_currentAttr, element_);
|
| }
|
|
|
| +bool AccessibleNode::disabled(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kDisabled, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setDisabled(bool disabled, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kDisabled, disabled);
|
| + NotifyAttributeChanged(aria_disabledAttr);
|
| +}
|
| +
|
| +bool AccessibleNode::expanded(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kExpanded, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setExpanded(bool expanded, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kExpanded, expanded);
|
| + NotifyAttributeChanged(aria_expandedAttr);
|
| +}
|
| +
|
| +bool AccessibleNode::hidden(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kHidden, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setHidden(bool hidden, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kHidden, hidden);
|
| + NotifyAttributeChanged(aria_hiddenAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::invalid() const {
|
| return GetProperty(element_, AOMStringProperty::kInvalid);
|
| }
|
| @@ -133,6 +237,33 @@ void AccessibleNode::setLive(const AtomicString& live) {
|
| NotifyAttributeChanged(aria_liveAttr);
|
| }
|
|
|
| +bool AccessibleNode::modal(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kModal, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setModal(bool modal, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kModal, modal);
|
| + NotifyAttributeChanged(aria_modalAttr);
|
| +}
|
| +
|
| +bool AccessibleNode::multiline(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kMultiline, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setMultiline(bool multiline, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kMultiline, multiline);
|
| + NotifyAttributeChanged(aria_multilineAttr);
|
| +}
|
| +
|
| +bool AccessibleNode::multiselectable(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kMultiselectable, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setMultiselectable(bool multiselectable, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kMultiselectable, multiselectable);
|
| + NotifyAttributeChanged(aria_multiselectableAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::orientation() const {
|
| return GetProperty(element_, AOMStringProperty::kOrientation);
|
| }
|
| @@ -151,6 +282,15 @@ void AccessibleNode::setPlaceholder(const AtomicString& placeholder) {
|
| NotifyAttributeChanged(aria_placeholderAttr);
|
| }
|
|
|
| +bool AccessibleNode::readOnly(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kReadOnly, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setReadOnly(bool read_only, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kReadOnly, read_only);
|
| + NotifyAttributeChanged(aria_readonlyAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::relevant() const {
|
| return GetProperty(element_, AOMStringProperty::kRelevant);
|
| }
|
| @@ -160,6 +300,15 @@ void AccessibleNode::setRelevant(const AtomicString& relevant) {
|
| NotifyAttributeChanged(aria_relevantAttr);
|
| }
|
|
|
| +bool AccessibleNode::required(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kRequired, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setRequired(bool required, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kRequired, required);
|
| + NotifyAttributeChanged(aria_requiredAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::role() const {
|
| return GetProperty(element_, AOMStringProperty::kRole);
|
| }
|
| @@ -178,6 +327,15 @@ void AccessibleNode::setRoleDescription(const AtomicString& role_description) {
|
| NotifyAttributeChanged(aria_roledescriptionAttr);
|
| }
|
|
|
| +bool AccessibleNode::selected(bool& is_null) const {
|
| + return GetProperty(element_, AOMBooleanProperty::kSelected, is_null);
|
| +}
|
| +
|
| +void AccessibleNode::setSelected(bool selected, bool is_null) {
|
| + SetBooleanProperty(AOMBooleanProperty::kSelected, selected);
|
| + NotifyAttributeChanged(aria_selectedAttr);
|
| +}
|
| +
|
| AtomicString AccessibleNode::sort() const {
|
| return GetProperty(element_, AOMStringProperty::kSort);
|
| }
|
| @@ -208,6 +366,18 @@ void AccessibleNode::SetStringProperty(AOMStringProperty property,
|
| string_properties_.push_back(std::make_pair(property, value));
|
| }
|
|
|
| +void AccessibleNode::SetBooleanProperty(AOMBooleanProperty property,
|
| + bool value) {
|
| + for (auto& item : boolean_properties_) {
|
| + if (item.first == property) {
|
| + item.second = value;
|
| + return;
|
| + }
|
| + }
|
| +
|
| + boolean_properties_.push_back(std::make_pair(property, value));
|
| +}
|
| +
|
| void AccessibleNode::NotifyAttributeChanged(
|
| const blink::QualifiedName& attribute) {
|
| // TODO(dmazzoni): Make a cleaner API for this rather than pretending
|
|
|