Commit 8ccd5aae authored by cfleizach@apple.com's avatar cfleizach@apple.com

WAI-ARIA: add support for ranges, including the progressbar, slider, and spinbutton roles

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

Reviewed by Beth Dakin.

WebCore: 

Allow certain ARIA roles to change value with AXIncrement and AXDecrement. 
Consolidate increment/decrement/changeValue methods. 

Test: accessibility/aria-slider-value-change.html

* accessibility/AccessibilityObject.cpp:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::increment):
(WebCore::AccessibilityRenderObject::decrement):
(WebCore::AccessibilityRenderObject::changeValueByPercent):
(WebCore::AccessibilityRenderObject::setValue):
(WebCore::AccessibilityRenderObject::canSetFocusAttribute):
* accessibility/AccessibilityRenderObject.h:
* accessibility/AccessibilitySlider.cpp:
* accessibility/AccessibilitySlider.h:
* dom/Element.cpp:
(WebCore::Element::updateAfterAttributeChanged):

LayoutTests: 

* accessibility/aria-slider-value-change-expected.txt: Added.
* accessibility/aria-slider-value-change.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 49eeefd5
2009-09-15 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
WAI-ARIA: add support for ranges, including the progressbar, slider, and spinbutton roles
https://bugs.webkit.org/show_bug.cgi?id=28841
* accessibility/aria-slider-value-change-expected.txt: Added.
* accessibility/aria-slider-value-change.html: Added.
2009-09-15 Brian Weinstein <bweinstein@apple.com>
Rubber-stamped by Steve Falkenburg.
......
slider
This tests that its possible to increment and decrement an aria slider and have the value updated correctly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS slider.intValue is 50
PASS slider.intValue > 50 is true
PASS slider.intValue < 50 is true
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">
<div tabindex=0 id="slider" role="slider" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">slider</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that its possible to increment and decrement an aria slider and have the value updated correctly.");
if (window.accessibilityController) {
var slider = document.getElementById("slider");
slider.focus();
slider = accessibilityController.focusedElement;
shouldBe("slider.intValue", "50");
slider.increment();
shouldBe("slider.intValue > 50", "true");
slider.decrement();
slider.decrement();
shouldBe("slider.intValue < 50", "true");
}
successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2009-09-15 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
WAI-ARIA: add support for ranges, including the progressbar, slider, and spinbutton roles
https://bugs.webkit.org/show_bug.cgi?id=28841
Allow certain ARIA roles to change value with AXIncrement and AXDecrement.
Consolidate increment/decrement/changeValue methods.
Test: accessibility/aria-slider-value-change.html
* accessibility/AccessibilityObject.cpp:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::increment):
(WebCore::AccessibilityRenderObject::decrement):
(WebCore::AccessibilityRenderObject::changeValueByPercent):
(WebCore::AccessibilityRenderObject::setValue):
(WebCore::AccessibilityRenderObject::canSetFocusAttribute):
* accessibility/AccessibilityRenderObject.h:
* accessibility/AccessibilitySlider.cpp:
* accessibility/AccessibilitySlider.h:
* dom/Element.cpp:
(WebCore::Element::updateAfterAttributeChanged):
2009-09-15 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
......@@ -606,6 +606,22 @@ Element* AccessibilityRenderObject::mouseButtonListener() const
return 0;
}
void AccessibilityRenderObject::increment()
{
if (roleValue() != SliderRole)
return;
changeValueByPercent(5);
}
void AccessibilityRenderObject::decrement()
{
if (roleValue() != SliderRole)
return;
changeValueByPercent(-5);
}
static Element* siblingWithAriaRole(String role, Node* node)
{
Node* sibling = node->parent()->firstChild();
......@@ -1581,8 +1597,22 @@ void AccessibilityRenderObject::setFocused(bool on)
}
}
void AccessibilityRenderObject::changeValueByPercent(float percentChange)
{
float range = maxValueForRange() - minValueForRange();
float value = valueForRange();
value += range * (percentChange / 100);
setValue(String::number(value));
axObjectCache()->postNotification(m_renderer, AXObjectCache::AXValueChanged, true);
}
void AccessibilityRenderObject::setValue(const String& string)
{
if (!m_renderer)
return;
// FIXME: Do we want to do anything here for ARIA textboxes?
if (m_renderer->isTextField()) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->node());
......@@ -1590,6 +1620,10 @@ void AccessibilityRenderObject::setValue(const String& string)
} else if (m_renderer->isTextArea()) {
HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(m_renderer->node());
textArea->setValue(string);
} else if (roleValue() == SliderRole) {
Node* element = m_renderer->node();
if (element && element->isElementNode())
static_cast<Element*>(element)->setAttribute(aria_valuenowAttr, string);
}
}
......@@ -2408,6 +2442,7 @@ bool AccessibilityRenderObject::canSetFocusAttribute() const
case PopUpButtonRole:
case CheckBoxRole:
case RadioButtonRole:
case SliderRole:
return true;
default:
return false;
......
......@@ -188,6 +188,9 @@ public:
virtual void setFocused(bool);
virtual void setSelectedTextRange(const PlainTextRange&);
virtual void setValue(const String&);
virtual void changeValueByPercent(float percentChange);
virtual void increment();
virtual void decrement();
virtual void detach();
virtual void childrenChanged();
......
......@@ -114,15 +114,6 @@ float AccessibilitySlider::minValueForRange() const
return getAttribute(minAttr).toFloat();
}
void AccessibilitySlider::changeValue(float percentChange)
{
float range = maxValueForRange() - minValueForRange();
float value = valueForRange();
value += range * (percentChange / 100);
setValue(String::number(value));
}
void AccessibilitySlider::setValue(const String& value)
{
HTMLInputElement* input = element();
......@@ -136,16 +127,6 @@ void AccessibilitySlider::setValue(const String& value)
input->dispatchFormControlChangeEvent();
}
void AccessibilitySlider::increment()
{
return changeValue(5);
}
void AccessibilitySlider::decrement()
{
return changeValue(-5);
}
HTMLInputElement* AccessibilitySlider::element() const
{
return static_cast<HTMLInputElement*>(m_renderer->node());
......
......@@ -58,14 +58,10 @@ namespace WebCore {
virtual float minValueForRange() const;
virtual AccessibilityOrientation orientation() const;
virtual void increment();
virtual void decrement();
protected:
AccessibilitySlider(RenderObject*);
private:
void changeValue(float /*percentChange*/);
HTMLInputElement* element() const;
};
......
......@@ -613,6 +613,9 @@ void Element::updateAfterAttributeChanged(Attribute* attr)
} else if (attrName == roleAttr) {
// the role attribute can change at any time, and the AccessibilityObject must pick up these changes
axObjectCache->handleAriaRoleChanged(renderer());
} else if (attrName == aria_valuenowAttr) {
// If the valuenow attribute changes, AX clients need to be notified.
axObjectCache->postNotification(renderer(), AXObjectCache::AXValueChanged, true);
}
}
......
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