Commit b474d37f authored by nektar's avatar nektar Committed by Commit bot

Make click targets inside links work.

There are pages that attach click handlers to elements that are found inside links, and screen readers might try to click such elements. Our existing doDefaultAction logic wasn't handling this possibility.
For example, there might be a graphic inside a link and the screen reader might invoke the default action on the graphic.
BUG=615904
TBR=dmazzoni@chromium.org

Review-Url: https://codereview.chromium.org/2043433002
Cr-Commit-Position: refs/heads/master@{#397882}
parent 82ed2a35
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id="wrapper1">
<a href="#"><img id="img1" alt="Delicious cake" src="resources/cake.png"></a>
</div>
<script>
async_test(function(t)
{
var axImg = accessibilityController.accessibleElementById("img1");
axImg.addNotificationListener(function(notification) {
if (notification == 'Clicked') {
document.getElementById("wrapper1").style.display = "none";
t.done();
}
});
var img = document.getElementById("img1");
img.addEventListener("click", function(e)
{
img.title = "clicked";
});
img.click();
}, "clicking an image via javascript sends an accessible click event");
</script>
<div id="wrapper2">
<a href="#"><img id="img2" alt="Delicious cake" src="resources/cake.png"></a>
</div>
<script>
async_test(function(t)
{
var axEvent = false;
var domEvent = false;
var clickEventHandler = function(e)
{
if (e == 'Clicked')
axEvent = true;
// "which" is a known property on MouseEvent objects.
if (e.which) {
img.title = "clicked";
domEvent = true;
}
if (axEvent && domEvent) {
document.getElementById("wrapper2").style.display = "none";
t.done();
}
};
var axImg = accessibilityController.accessibleElementById("img2");
axImg.addNotificationListener(clickEventHandler);
var img = document.getElementById("img2");
img.addEventListener("click", clickEventHandler);
axImg.press();
}, "clicking an image via accessibility sends both an accessible and a DOM click event");
</script>
...@@ -2009,10 +2009,11 @@ Element* AXNodeObject::actionElement() const ...@@ -2009,10 +2009,11 @@ Element* AXNodeObject::actionElement() const
break; break;
} }
Element* elt = anchorElement(); Element* anchor = anchorElement();
if (!elt) Element* clickElement = mouseButtonListener();
elt = mouseButtonListener(); if (!anchor || (clickElement && clickElement->isDescendantOf(anchor)))
return elt; return clickElement;
return anchor;
} }
Element* AXNodeObject::anchorElement() const Element* AXNodeObject::anchorElement() const
......
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