Commit c3f2d3b1 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Increase depth to 3 when searching for images in links.

This is motivated by http://reddit.com/r/pics, where there are two levels
of divs in-between the link element and the img element. With this small
change Chrome provides image labels for pictures on Reddit again.

Bug: 1091538
Change-Id: I7a9775b7ff1febe4ae3b5f1741a624e0664b0582
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252801
Auto-Submit: Dominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781880}
parent b569790d
...@@ -253,12 +253,12 @@ bool SearchForExactlyOneInnerImage(WebAXObject obj, ...@@ -253,12 +253,12 @@ bool SearchForExactlyOneInnerImage(WebAXObject obj,
return !inner_image->IsDetached(); return !inner_image->IsDetached();
} }
// Return true if the subtree of |obj|, to a max depth of 2, contains // Return true if the subtree of |obj|, to a max depth of 3, contains
// exactly one image. Return that image in |inner_image|. // exactly one image. Return that image in |inner_image|.
bool FindExactlyOneInnerImageInMaxDepthTwo(WebAXObject obj, bool FindExactlyOneInnerImageInMaxDepthThree(WebAXObject obj,
WebAXObject* inner_image) { WebAXObject* inner_image) {
DCHECK(inner_image); DCHECK(inner_image);
return SearchForExactlyOneInnerImage(obj, inner_image, /* max_depth = */ 2); return SearchForExactlyOneInnerImage(obj, inner_image, /* max_depth = */ 3);
} }
std::string GetEquivalentAriaRoleString(const ax::mojom::Role role) { std::string GetEquivalentAriaRoleString(const ax::mojom::Role role) {
...@@ -1195,7 +1195,7 @@ void BlinkAXTreeSource::SerializeOtherScreenReaderAttributes( ...@@ -1195,7 +1195,7 @@ void BlinkAXTreeSource::SerializeOtherScreenReaderAttributes(
if ((ui::IsLink(dst->role) || ui::IsDocument(dst->role)) && if ((ui::IsLink(dst->role) || ui::IsDocument(dst->role)) &&
dst->GetNameFrom() != ax::mojom::NameFrom::kAttribute) { dst->GetNameFrom() != ax::mojom::NameFrom::kAttribute) {
WebAXObject inner_image; WebAXObject inner_image;
if (FindExactlyOneInnerImageInMaxDepthTwo(src, &inner_image)) if (FindExactlyOneInnerImageInMaxDepthThree(src, &inner_image))
AddImageAnnotations(inner_image, dst); AddImageAnnotations(inner_image, dst);
} }
......
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