Commit 3529bb25 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Send accessibility notifications when an image loads.

Bug: 934145
Change-Id: I3d98f29a60bd8093b026c9f22d1c05964201b18c
Reviewed-on: https://chromium-review.googlesource.com/c/1481133
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634461}
parent e040790c
...@@ -68,6 +68,7 @@ class CORE_EXPORT AXObjectCache ...@@ -68,6 +68,7 @@ class CORE_EXPORT AXObjectCache
virtual void ListboxActiveIndexChanged(HTMLSelectElement*) = 0; virtual void ListboxActiveIndexChanged(HTMLSelectElement*) = 0;
virtual void LocationChanged(LayoutObject*) = 0; virtual void LocationChanged(LayoutObject*) = 0;
virtual void RadiobuttonRemovedFromGroup(HTMLInputElement*) = 0; virtual void RadiobuttonRemovedFromGroup(HTMLInputElement*) = 0;
virtual void ImageLoaded(LayoutObject*) = 0;
virtual void Remove(AccessibleNode*) = 0; virtual void Remove(AccessibleNode*) = 0;
virtual void Remove(LayoutObject*) = 0; virtual void Remove(LayoutObject*) = 0;
......
...@@ -240,6 +240,7 @@ void LayoutImage::InvalidatePaintAndMarkForLayoutIfNeeded( ...@@ -240,6 +240,7 @@ void LayoutImage::InvalidatePaintAndMarkForLayoutIfNeeded(
} }
void LayoutImage::ImageNotifyFinished(ImageResourceContent* new_image) { void LayoutImage::ImageNotifyFinished(ImageResourceContent* new_image) {
LayoutObject::ImageNotifyFinished(new_image);
if (!image_resource_) if (!image_resource_)
return; return;
......
...@@ -3815,6 +3815,11 @@ void LayoutObject::ImageChanged(ImageResourceContent* image, ...@@ -3815,6 +3815,11 @@ void LayoutObject::ImageChanged(ImageResourceContent* image,
ImageChanged(static_cast<WrappedImagePtr>(image), defer); ImageChanged(static_cast<WrappedImagePtr>(image), defer);
} }
void LayoutObject::ImageNotifyFinished(ImageResourceContent*) {
if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache())
cache->ImageLoaded(this);
}
Element* LayoutObject::OffsetParent(const Element* base) const { Element* LayoutObject::OffsetParent(const Element* base) const {
if (IsDocumentElement() || IsBody()) if (IsDocumentElement() || IsBody())
return nullptr; return nullptr;
......
...@@ -1723,6 +1723,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -1723,6 +1723,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
// ImageResourceObserver override. // ImageResourceObserver override.
void ImageChanged(ImageResourceContent*, CanDeferInvalidation) final; void ImageChanged(ImageResourceContent*, CanDeferInvalidation) final;
void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override {} void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override {}
void ImageNotifyFinished(ImageResourceContent*) override;
bool WillRenderImage() final; bool WillRenderImage() final;
bool GetImageAnimationPolicy(ImageAnimationPolicy&) final; bool GetImageAnimationPolicy(ImageAnimationPolicy&) final;
......
...@@ -962,6 +962,14 @@ void AXObjectCacheImpl::RadiobuttonRemovedFromGroup( ...@@ -962,6 +962,14 @@ void AXObjectCacheImpl::RadiobuttonRemovedFromGroup(
ToAXRadioInput(first_obj)->RequestUpdateToNextNode(true); ToAXRadioInput(first_obj)->RequestUpdateToNextNode(true);
} }
void AXObjectCacheImpl::ImageLoaded(LayoutObject* layout_object) {
AXObject* obj = GetOrCreate(layout_object);
if (!obj)
return;
MarkAXObjectDirty(obj, false);
}
void AXObjectCacheImpl::HandleLayoutComplete(LayoutObject* layout_object) { void AXObjectCacheImpl::HandleLayoutComplete(LayoutObject* layout_object) {
if (!layout_object) if (!layout_object)
return; return;
......
...@@ -85,6 +85,7 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -85,6 +85,7 @@ class MODULES_EXPORT AXObjectCacheImpl
void ListboxActiveIndexChanged(HTMLSelectElement*) override; void ListboxActiveIndexChanged(HTMLSelectElement*) override;
void LocationChanged(LayoutObject*) override; void LocationChanged(LayoutObject*) override;
void RadiobuttonRemovedFromGroup(HTMLInputElement*) override; void RadiobuttonRemovedFromGroup(HTMLInputElement*) override;
void ImageLoaded(LayoutObject*) override;
void Remove(AccessibleNode*) override; void Remove(AccessibleNode*) override;
void Remove(LayoutObject*) override; void Remove(LayoutObject*) override;
......
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<img id="img">
<script>
async_test(function(t) {
var img = document.getElementById("img");
var axImg = accessibilityController.accessibleElementById("img");
var count = 0;
axImg.addNotificationListener((notification) => {
if (notification == "MarkDirty") {
count++;
// We should only get at most one notification.
assert_equals(1, count);
}
});
img.src = "../images/resources/animated2.gif";
setTimeout(() => {
assert_equals(1, count);
t.done();
}, 300);
}, "When loading an animated image, a notification is only received once.");
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
.imgparent div {
width: 100px;
height: 100px;
background-image: url('resources/cake.png');
}
</style>
<div id="outer">
<div id="img"></div>
</div>
<script>
async_test(function(t) {
var outer = document.getElementById("outer");
var img = document.getElementById("img");
var axImg = accessibilityController.accessibleElementById("img");
axImg.addNotificationListener((notification) => {
if (notification == "MarkDirty")
t.done();
});
outer.className = "imgparent";
}, "A notification is received when a background image loads.");
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<img id="img">
<script>
async_test(function(t) {
var img = document.getElementById("img");
var axImg = accessibilityController.accessibleElementById("img");
axImg.addNotificationListener((notification) => {
if (notification == "MarkDirty")
t.done();
});
img.src = "resources/cake.png";
}, "A notification is received when an image is loaded on an img element.");
</script>
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