Commit de7ab7eb authored by Chris Hall's avatar Chris Hall Committed by Commit Bot

Moving Attribute Getters from AXObject to AXNodeObject.

On an AXObject these would always return their default value, as they
need a Node to get an Element to get the attribute.

AX-Relnotes: n/a.
Change-Id: Icb4a430a695e58fe70c7d7be1f6fc896ca38dc90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2520479Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: Chris Hall <chrishall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824710}
parent a460595f
...@@ -3668,6 +3668,41 @@ AtomicString AXNodeObject::Language() const { ...@@ -3668,6 +3668,41 @@ AtomicString AXNodeObject::Language() const {
return AtomicString(languages[0].StripWhiteSpace()); return AtomicString(languages[0].StripWhiteSpace());
} }
bool AXNodeObject::HasAttribute(const QualifiedName& attribute) const {
Element* element = GetElement();
if (!element)
return false;
if (element->FastHasAttribute(attribute))
return true;
return HasInternalsAttribute(*element, attribute);
}
const AtomicString& AXNodeObject::GetAttribute(
const QualifiedName& attribute) const {
Element* element = GetElement();
if (!element)
return g_null_atom;
const AtomicString& value = element->FastGetAttribute(attribute);
if (!value.IsNull())
return value;
return GetInternalsAttribute(*element, attribute);
}
bool AXNodeObject::HasInternalsAttribute(Element& element,
const QualifiedName& attribute) const {
if (!element.DidAttachInternals())
return false;
return element.EnsureElementInternals().HasAttribute(attribute);
}
const AtomicString& AXNodeObject::GetInternalsAttribute(
Element& element,
const QualifiedName& attribute) const {
if (!element.DidAttachInternals())
return g_null_atom;
return element.EnsureElementInternals().FastGetAttribute(attribute);
}
void AXNodeObject::SetNode(Node* node) { void AXNodeObject::SetNode(Node* node) {
node_ = node; node_ = node;
} }
......
...@@ -245,6 +245,8 @@ class MODULES_EXPORT AXNodeObject : public AXObject { ...@@ -245,6 +245,8 @@ class MODULES_EXPORT AXNodeObject : public AXObject {
// DOM and layout tree access. // DOM and layout tree access.
AtomicString Language() const override; AtomicString Language() const override;
bool HasAttribute(const QualifiedName&) const override;
const AtomicString& GetAttribute(const QualifiedName&) const override;
// Modify or take an action on an object. // Modify or take an action on an object.
bool OnNativeFocusAction() final; bool OnNativeFocusAction() final;
...@@ -294,6 +296,10 @@ class MODULES_EXPORT AXNodeObject : public AXObject { ...@@ -294,6 +296,10 @@ class MODULES_EXPORT AXNodeObject : public AXObject {
FRIEND_TEST_ALL_PREFIXES(AccessibilityTest, UpdateChildrenIfNecessary); FRIEND_TEST_ALL_PREFIXES(AccessibilityTest, UpdateChildrenIfNecessary);
private: private:
bool HasInternalsAttribute(Element&, const QualifiedName&) const;
const AtomicString& GetInternalsAttribute(Element&,
const QualifiedName&) const;
Member<Node> node_; Member<Node> node_;
bool IsNativeCheckboxInMixedState() const; bool IsNativeCheckboxInMixedState() const;
......
...@@ -3478,41 +3478,6 @@ AtomicString AXObject::Language() const { ...@@ -3478,41 +3478,6 @@ AtomicString AXObject::Language() const {
return default_language; return default_language;
} }
bool AXObject::HasAttribute(const QualifiedName& attribute) const {
Element* element = GetElement();
if (!element)
return false;
if (element->FastHasAttribute(attribute))
return true;
return HasInternalsAttribute(*element, attribute);
}
const AtomicString& AXObject::GetAttribute(
const QualifiedName& attribute) const {
Element* element = GetElement();
if (!element)
return g_null_atom;
const AtomicString& value = element->FastGetAttribute(attribute);
if (!value.IsNull())
return value;
return GetInternalsAttribute(*element, attribute);
}
bool AXObject::HasInternalsAttribute(Element& element,
const QualifiedName& attribute) const {
if (!element.DidAttachInternals())
return false;
return element.EnsureElementInternals().HasAttribute(attribute);
}
const AtomicString& AXObject::GetInternalsAttribute(
Element& element,
const QualifiedName& attribute) const {
if (!element.DidAttachInternals())
return g_null_atom;
return element.EnsureElementInternals().FastGetAttribute(attribute);
}
// //
// Scrollable containers. // Scrollable containers.
// //
......
...@@ -1113,8 +1113,10 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> { ...@@ -1113,8 +1113,10 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
virtual Element* AnchorElement() const { return nullptr; } virtual Element* AnchorElement() const { return nullptr; }
virtual Element* ActionElement() const { return nullptr; } virtual Element* ActionElement() const { return nullptr; }
virtual AtomicString Language() const; virtual AtomicString Language() const;
bool HasAttribute(const QualifiedName&) const; virtual bool HasAttribute(const QualifiedName&) const { return false; }
const AtomicString& GetAttribute(const QualifiedName&) const; virtual const AtomicString& GetAttribute(const QualifiedName&) const {
return g_null_atom;
}
// Scrollable containers. // Scrollable containers.
bool IsScrollableContainer() const; bool IsScrollableContainer() const;
...@@ -1353,9 +1355,6 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> { ...@@ -1353,9 +1355,6 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
ax::mojom::blink::Role RemapAriaRoleDueToParent(ax::mojom::blink::Role) const; ax::mojom::blink::Role RemapAriaRoleDueToParent(ax::mojom::blink::Role) const;
unsigned ComputeAriaColumnIndex() const; unsigned ComputeAriaColumnIndex() const;
unsigned ComputeAriaRowIndex() const; unsigned ComputeAriaRowIndex() const;
bool HasInternalsAttribute(Element&, const QualifiedName&) const;
const AtomicString& GetInternalsAttribute(Element&,
const QualifiedName&) const;
bool ComputeIsHiddenViaStyle() const; bool ComputeIsHiddenViaStyle() const;
// This returns true if the element associated with this AXObject is has // This returns true if the element associated with this AXObject is has
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment