diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index e969a2510224f8db2e0d6a76add479e15d69cfdb..5965707d42751899da330bcb80f7f8c966d70a58 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2009-09-15 Chris Fleizach + + 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 Rubber-stamped by Steve Falkenburg. diff --git a/LayoutTests/accessibility/aria-slider-value-change-expected.txt b/LayoutTests/accessibility/aria-slider-value-change-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..544029b95e939eff14bb9582255e43d14428e85b --- /dev/null +++ b/LayoutTests/accessibility/aria-slider-value-change-expected.txt @@ -0,0 +1,13 @@ +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 + diff --git a/LayoutTests/accessibility/aria-slider-value-change.html b/LayoutTests/accessibility/aria-slider-value-change.html new file mode 100644 index 0000000000000000000000000000000000000000..75c76f6a34ce1d3dca9cdd1250ff997d8182c7e4 --- /dev/null +++ b/LayoutTests/accessibility/aria-slider-value-change.html @@ -0,0 +1,43 @@ + + + + + + + + + +
slider
+ +

+
+ + + + + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 1045ddd24c56c3c3b2e5cae82dd6ca3c30d20edc..e419d579bff60522599584b7c3bbc38ff052fdb5 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2009-09-15 Chris Fleizach + + 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 Reviewed by Sam Weinig. diff --git a/WebCore/accessibility/AccessibilityRenderObject.cpp b/WebCore/accessibility/AccessibilityRenderObject.cpp index ecb8673ab302bfa15aaac0a59d40f0dcf2c83b5b..b7dd6013be5f8eb482284074a3903516f0b35069 100644 --- a/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -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(m_renderer->node()); @@ -1590,6 +1620,10 @@ void AccessibilityRenderObject::setValue(const String& string) } else if (m_renderer->isTextArea()) { HTMLTextAreaElement* textArea = static_cast(m_renderer->node()); textArea->setValue(string); + } else if (roleValue() == SliderRole) { + Node* element = m_renderer->node(); + if (element && element->isElementNode()) + static_cast(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; diff --git a/WebCore/accessibility/AccessibilityRenderObject.h b/WebCore/accessibility/AccessibilityRenderObject.h index 2b29f4acbf16f54ad30247c1bf66e6109aabe0e2..e600b616a377dfe8784105c7ef852d29c2a8d997 100644 --- a/WebCore/accessibility/AccessibilityRenderObject.h +++ b/WebCore/accessibility/AccessibilityRenderObject.h @@ -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(); diff --git a/WebCore/accessibility/AccessibilitySlider.cpp b/WebCore/accessibility/AccessibilitySlider.cpp index ede9dcf60b1f5dde785acbf2dcdba4f91ee0fbb7..5aca672580dc165f41ea0f7824fb02733a699995 100644 --- a/WebCore/accessibility/AccessibilitySlider.cpp +++ b/WebCore/accessibility/AccessibilitySlider.cpp @@ -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(m_renderer->node()); diff --git a/WebCore/accessibility/AccessibilitySlider.h b/WebCore/accessibility/AccessibilitySlider.h index 3a7e65ffb3b704e64f49a239bdd90ee0be8f113a..254ebdd51286dea6e19a6fd9b02cab732f4ac669 100644 --- a/WebCore/accessibility/AccessibilitySlider.h +++ b/WebCore/accessibility/AccessibilitySlider.h @@ -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; }; diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 218d6bf96f7089dffca8bb83c32cdf0965a888ab..f04723fcaa25e3efc8e474ba358ffbbef979e569 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -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); } }