Commit 3b920269 authored by cfleizach@apple.com's avatar cfleizach@apple.com

AX: labels of checkboxes should, when hit-tested, return the checkbox

https://bugs.webkit.org/show_bug.cgi?id=29335

Reviewed by Beth Dakin.

WebCore: 

When an accessibility hit test is done and it hits the label of a control element,
the control element should be returned instead of nothing, since the label
itself is usually ignored.

Test: accessibility/label-for-control-hittest.html

* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::correspondingControlForLabelElement):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::doAccessibilityHitTest):
(WebCore::AccessibilityRenderObject::correspondingControlForLabelElement):
* accessibility/AccessibilityRenderObject.h:

LayoutTests: 

* accessibility/label-for-control-hittest-expected.txt: Added.
* accessibility/label-for-control-hittest.html: Added.
* platform/gtk/Skipped:
* platform/win/Skipped:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1b42b7eb
2009-09-17 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
AX: labels of checkboxes should, when hit-tested, return the checkbox
https://bugs.webkit.org/show_bug.cgi?id=29335
* accessibility/label-for-control-hittest-expected.txt: Added.
* accessibility/label-for-control-hittest.html: Added.
* platform/gtk/Skipped:
* platform/win/Skipped:
2009-09-17 Brian Weinstein <bweinstein@apple.com>
Rubber-stamped by Adam Roben.
......
This is a lot of repeated text that when a hit test is performed, will return the corresponding checkbox control, because this text is only a label. This is a lot of repeated text that when a hit test is performed, will return the corresponding checkbox control, because this text is only a label. This is a lot of repeated text that when a hit test is performed, will return the corresponding checkbox control, because this text is only a label. This is a lot of repeated text that when a hit test is performed, will return the corresponding checkbox control, because this text is only a label. This is a lot of repeated text that when a hit test is performed, will return the corresponding checkbox control, because this text is only a label.
This tests that a hit test on a label of a control will return the control (instead of nothing).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS control.role is 'AXRole: AXCheckBox'
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
<script>
var successfullyParsed = false;
</script>
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body id="body">
<input type="checkbox" id="item"><label for="item">
This is a lot of repeated text that when a hit test is performed, will
return the corresponding checkbox control, because this text is only a label.
This is a lot of repeated text that when a hit test is performed, will
return the corresponding checkbox control, because this text is only a label.
This is a lot of repeated text that when a hit test is performed, will
return the corresponding checkbox control, because this text is only a label.
This is a lot of repeated text that when a hit test is performed, will
return the corresponding checkbox control, because this text is only a label.
This is a lot of repeated text that when a hit test is performed, will
return the corresponding checkbox control, because this text is only a label.
</label>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that a hit test on a label of a control will return the control (instead of nothing).");
if (window.accessibilityController) {
var body = document.getElementById("body");
body.focus();
var control = accessibilityController.focusedElement.elementAtPoint(30, 100);
shouldBe("control.role", "'AXRole: AXCheckBox'");
}
successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -76,6 +76,7 @@ accessibility/aria-tables.html
accessibility/image-map1.html
accessibility/image-map2.html
accessibility/internal-link-anchors2.html
accessibility/label-for-control-hittest.html
accessibility/legend.html
accessibility/lists.html
accessibility/plugin.html
......
......@@ -370,6 +370,7 @@ accessibility/img-aria-button-alt-tag.html
accessibility/input-image-alt.html
accessibility/input-slider.html
accessibility/internal-link-anchors2.html
accessibility/label-for-control-hittest.html
accessibility/language-attribute.html
accessibility/legend.html
accessibility/lists.html
......
2009-09-17 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
AX: labels of checkboxes should, when hit-tested, return the checkbox
https://bugs.webkit.org/show_bug.cgi?id=29335
When an accessibility hit test is done and it hits the label of a control element,
the control element should be returned instead of nothing, since the label
itself is usually ignored.
Test: accessibility/label-for-control-hittest.html
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::correspondingControlForLabelElement):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::doAccessibilityHitTest):
(WebCore::AccessibilityRenderObject::correspondingControlForLabelElement):
* accessibility/AccessibilityRenderObject.h:
2009-09-17 Avi Drissman <avi@chromium.org>
Reviewed by Dimitri Glazkov, build fix.
......@@ -316,6 +316,7 @@ public:
virtual void linkedUIElements(AccessibilityChildrenVector&) const { }
virtual AccessibilityObject* titleUIElement() const { return 0; }
virtual bool exposesTitleUIElement() const { return true; }
virtual AccessibilityObject* correspondingControlForLabelElement() const { return 0; }
virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; }
virtual bool isPresentationalChildOfAriaRole() const { return false; }
......
......@@ -1276,15 +1276,9 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
// find out if this element is inside of a label element.
// if so, it may be ignored because it's the label for a checkbox or radio button
HTMLLabelElement* labelElement = labelElementContainer();
if (labelElement) {
HTMLElement* correspondingControl = labelElement->correspondingControl();
if (correspondingControl && correspondingControl->renderer()) {
AccessibilityObject* controlObject = axObjectCache()->getOrCreate(correspondingControl->renderer());
if (!controlObject->exposesTitleUIElement())
return true;
}
}
AccessibilityObject* controlObject = correspondingControlForLabelElement();
if (controlObject && !controlObject->exposesTitleUIElement())
return true;
AccessibilityRole ariaRole = ariaRoleAttribute();
if (ariaRole == TextAreaRole || ariaRole == StaticTextRole) {
......@@ -2119,8 +2113,14 @@ AccessibilityObject* AccessibilityRenderObject::doAccessibilityHitTest(const Int
if (obj->isListBox())
return static_cast<AccessibilityListBox*>(result)->doAccessibilityHitTest(point);
if (result->accessibilityIsIgnored())
if (result->accessibilityIsIgnored()) {
// If this element is the label of a control, a hit test should return the control.
AccessibilityObject* controlObject = result->correspondingControlForLabelElement();
if (controlObject && !controlObject->exposesTitleUIElement())
return controlObject;
result = result->parentObjectUnignored();
}
return result;
}
......@@ -2199,6 +2199,18 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
doc->axObjectCache()->postNotification(activedescendant->renderer(), AXObjectCache::AXFocusedUIElementChanged, true);
}
AccessibilityObject* AccessibilityRenderObject::correspondingControlForLabelElement() const
{
HTMLLabelElement* labelElement = labelElementContainer();
if (!labelElement)
return 0;
HTMLElement* correspondingControl = labelElement->correspondingControl();
if (!correspondingControl)
return 0;
return axObjectCache()->getOrCreate(correspondingControl->renderer());
}
AccessibilityObject* AccessibilityRenderObject::observableObject() const
{
......
......@@ -133,6 +133,8 @@ public:
virtual void linkedUIElements(AccessibilityChildrenVector&) const;
virtual bool exposesTitleUIElement() const;
virtual AccessibilityObject* titleUIElement() const;
virtual AccessibilityObject* correspondingControlForLabelElement() const;
virtual AccessibilityRole ariaRoleAttribute() const;
virtual bool isPresentationalChildOfAriaRole() const;
virtual bool ariaRoleHasPresentationalChildren() 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