Commit 77925cfe authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Fire notification when virtual AccessibleNode attribute changes.

Previously firing a notification only worked when an AccessibleNode
had an element. Add a quick fix to ensure it works even when it
doesn't.

Bug: 761901
Change-Id: I0ec6723e748947d94f1207f72f38ec94f0f6b335
Reviewed-on: https://chromium-review.googlesource.com/962862
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573404}
parent 01cb1c86
......@@ -644,9 +644,7 @@ AtomicString AccessibleNode::current() const {
void AccessibleNode::setCurrent(const AtomicString& current) {
SetStringProperty(AOMStringProperty::kCurrent, current);
if (AXObjectCache* cache = GetAXObjectCache())
cache->HandleAttributeChanged(aria_currentAttr, element_);
NotifyAttributeChanged(aria_currentAttr);
}
AccessibleNodeList* AccessibleNode::describedBy() {
......@@ -1173,8 +1171,12 @@ void AccessibleNode::NotifyAttributeChanged(
const blink::QualifiedName& attribute) {
// TODO(dmazzoni): Make a cleaner API for this rather than pretending
// the DOM attribute changed.
if (AXObjectCache* cache = GetAXObjectCache())
cache->HandleAttributeChanged(attribute, element_);
if (AXObjectCache* cache = GetAXObjectCache()) {
if (element_)
cache->HandleAttributeChanged(attribute, element_);
else
cache->HandleAttributeChanged(attribute, this);
}
}
AXObjectCache* AccessibleNode::GetAXObjectCache() {
......
......@@ -103,6 +103,10 @@ class CORE_EXPORT AXObjectCache
virtual void HandleLayoutComplete(Document*) = 0;
virtual void HandleClicked(Node*) = 0;
// Changes to virtual Accessibility Object Model nodes.
virtual void HandleAttributeChanged(const QualifiedName& attr_name,
AccessibleNode*) = 0;
virtual void SetCanvasObjectBounds(HTMLCanvasElement*,
Element*,
const LayoutRect&) = 0;
......
......@@ -869,6 +869,14 @@ void AXObjectCacheImpl::HandleClicked(Node* node) {
PostNotification(obj, kAXClicked);
}
void AXObjectCacheImpl::HandleAttributeChanged(
const QualifiedName& attr_name,
AccessibleNode* accessible_node) {
modification_count_++;
if (AXObject* obj = Get(accessible_node))
PostNotification(obj, kAXAriaAttributeChanged);
}
void AXObjectCacheImpl::HandleAriaExpandedChange(Node* node) {
if (AXObject* obj = GetOrCreate(node))
obj->HandleAriaExpandedChanged();
......
......@@ -150,6 +150,8 @@ class MODULES_EXPORT AXObjectCacheImpl
void HandleLoadComplete(Document*) override;
void HandleLayoutComplete(Document*) override;
void HandleClicked(Node*) override;
void HandleAttributeChanged(const QualifiedName& attr_name,
AccessibleNode*) override;
void SetCanvasObjectBounds(HTMLCanvasElement*,
Element*,
......
......@@ -33,6 +33,11 @@ void AXVirtualObject::AddChildren() {
children_.push_back(AXObjectCache().GetOrCreate(child));
}
void AXVirtualObject::ChildrenChanged() {
ClearChildren();
AXObjectCache().PostNotification(this, AXObjectCacheImpl::kAXChildrenChanged);
}
const AtomicString& AXVirtualObject::GetAOMPropertyOrARIAAttribute(
AOMStringProperty property) const {
if (!accessible_node_)
......
......@@ -24,6 +24,7 @@ class MODULES_EXPORT AXVirtualObject : public AXObject {
AXObject* ComputeParent() const override { return parent_; }
bool IsVirtualObject() const override { return true; }
void AddChildren() override;
void ChildrenChanged() override;
const AtomicString& GetAOMPropertyOrARIAAttribute(
AOMStringProperty) const override;
bool HasAOMPropertyOrARIAAttribute(AOMBooleanProperty,
......
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