Commit 9f41c35e authored by yosin@chromium.org's avatar yosin@chromium.org
Browse files

New time input needs accessibility

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

Reviewed by Chris Fleizach.

Source/WebCore:

This patch adds accessibility support into multiple fields time input
UI by setting "role" HTML attribute of DateTimeFieldElement to "spinbutton"
and changing ARIA attributes to post value change notification.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

Tests: fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html
       fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification.html

* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::DateTimeFieldElement): Changed to set
"role" HTML attribute to "spinbutton".
(WebCore::DateTimeFieldElement::initialize): Changed to set new
parameter axHelpText to aria-help attribute and set aria-valuemax and
aria-valuemin attributes.
(WebCore::DateTimeFieldElement::updateVisibleValue): Changed to set
aria-valuetext and aria-valuenow attributes.
* html/shadow/DateTimeFieldElement.h:
(DateTimeFieldElement): Changed to add new parameter axHelpText to initialize().
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeAMPMFieldElement::create): Changed to add new argument.
(WebCore::DateTimeHourFieldElement::create): ditto.
(WebCore::DateTimeMillisecondFieldElement::create): ditto.
(WebCore::DateTimeMinuteFieldElement::create): ditto.
(WebCore::DateTimeSecondFieldElement::create): ditto.
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum): Added for DateTimeFieldElement::initialize().
(WebCore::DateTimeNumericFieldElement::minimum): ditto.
* html/shadow/DateTimeNumericFieldElement.h:
(DateTimeNumericFieldElement): Added maximum() and minimum() declarations.
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::maximum): Added for DateTimeFieldElement::initialize().
(WebCore::DateTimeSymbolicFieldElement::minimum): ditto.
* html/shadow/DateTimeSymbolicFieldElement.h:
(DateTimeSymbolicFieldElement): Added maximum() and minimum() declarations.

LayoutTests:

This patch adds two tests for checking accessibility functionalities
in multiple fields time input UI.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html: Added to check ARIA attributes used in multiple fields time input UI.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification.html: Added to check accessibility notification supports in multiple fields time input UI.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3f2c0096
2012-09-12 Yoshifumi Inoue <yosin@chromium.org>
New time input needs accessibility
https://bugs.webkit.org/show_bug.cgi?id=96032
Reviewed by Chris Fleizach.
This patch adds two tests for checking accessibility functionalities
in multiple fields time input UI.
This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html: Added to check ARIA attributes used in multiple fields time input UI.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification.html: Added to check accessibility notification supports in multiple fields time input UI.
2012-09-12 Kent Tamura <tkent@chromium.org>
 
[Chromium] Test expectation update
This test checks aria-help attribute of fields in multiple fields time input UI.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Non-empty value
PASS focusedFieldValueDescription() is "AXHelp: Hours, AXValueDescription: 12, 1, 12"
PASS focusedFieldValueDescription() is "AXHelp: Minutes, AXValueDescription: 34, 0, 59"
PASS focusedFieldValueDescription() is "AXHelp: Seconds, AXValueDescription: 56, 0, 59"
PASS focusedFieldValueDescription() is "AXHelp: Milliseconds, AXValueDescription: 789, 0, 999"
PASS focusedFieldValueDescription() is "AXHelp: AM/PM, AXValueDescription: PM, 1, 2"
Empty value
PASS focusedFieldValueDescription() is "AXHelp: AM/PM, AXValueDescription: blank, 1, 2"
PASS focusedFieldValueDescription() is "AXHelp: Milliseconds, AXValueDescription: blank, 0, 999"
PASS focusedFieldValueDescription() is "AXHelp: Seconds, AXValueDescription: blank, 0, 59"
PASS focusedFieldValueDescription() is "AXHelp: Minutes, AXValueDescription: blank, 0, 59"
PASS focusedFieldValueDescription() is "AXHelp: Hours, AXValueDescription: blank, 1, 12"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<input id=test type="time" value="12:34:56.789">
<script>
description('This test checks aria-help attribute of fields in multiple fields time input UI.');
function enableAccessibility()
{
if (!window.accessibilityController) {
debug("Please run inside DumpRenderTree.");
return;
}
}
function focusedFieldValueDescription()
{
if (!window.accessibilityController)
return;
var element = accessibilityController.focusedElement
return element.helpText + ", " + element.valueDescription + ", " + element.minValue + ", " + element.maxValue;
}
function keyDown(key, modifiers)
{
if (!window.eventSender)
return;
eventSender.keyDown(key, modifiers);
}
var testInput = document.getElementById("test");
enableAccessibility();
testInput.focus();
debug('Non-empty value');
testInput.focus();
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Hours, AXValueDescription: 12, 1, 12');
keyDown('\t');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Minutes, AXValueDescription: 34, 0, 59');
keyDown('\t');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Seconds, AXValueDescription: 56, 0, 59');
keyDown('\t');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Milliseconds, AXValueDescription: 789, 0, 999');
keyDown('\t');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: AM/PM, AXValueDescription: PM, 1, 2');
debug('Empty value');
keyDown('\b');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: AM/PM, AXValueDescription: blank, 1, 2');
keyDown('\t', ['shiftKey']);
keyDown('\b');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Milliseconds, AXValueDescription: blank, 0, 999');
keyDown('\t', ['shiftKey']);
keyDown('\b');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Seconds, AXValueDescription: blank, 0, 59');
keyDown('\t', ['shiftKey']);
keyDown('\b');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Minutes, AXValueDescription: blank, 0, 59');
keyDown('\t', ['shiftKey']);
keyDown('\b');
shouldBeEqualToString('focusedFieldValueDescription()', 'AXHelp: Hours, AXValueDescription: blank, 1, 12');
debug('');
testInput.parentNode.removeChild(testInput);
</script>
<script src="../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
This test checks value changed accessibility notifications.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FocusedUIElementChanged AXHelp: Hours=AXValueDescription: 12
FocusedUIElementChanged AXHelp: Minutes=AXValueDescription: 34
ValueChanged AXHelp: Minutes=AXValueDescription: 05
ValueChanged AXHelp: Minutes=AXValueDescription: 05
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<input id=test type="time" value="12:34:56.789">
<script>
description('This test checks value changed accessibility notifications.');
function enableAccessibility()
{
if (!window.accessibilityController) {
debug("Please run inside DumpRenderTree.");
return;
}
accessibilityController.addNotificationListener(function (element, notification) {
if (notification == 'FocusedUIElementChanged' || notification == 'ValueChanged') {
debug(notification + ' ' + element.helpText + '=' + element.valueDescription);
}
});
}
function keyDown(key, modifiers)
{
if (!window.eventSender)
return;
eventSender.keyDown(key, modifiers);
}
var testInput = document.getElementById("test");
enableAccessibility();
testInput.focus();
keyDown('\t');
keyDown('4');
keyDown('upArrow');
window.jsTestIsAsync = true;
window.setTimeout(function () {
debug('');
testInput.parentNode.removeChild(testInput);
finishJSTest();
}, 1);
</script>
<script src="../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2012-09-12 Yoshifumi Inoue <yosin@chromium.org>
New time input needs accessibility
https://bugs.webkit.org/show_bug.cgi?id=96032
Reviewed by Chris Fleizach.
This patch adds accessibility support into multiple fields time input
UI by setting "role" HTML attribute of DateTimeFieldElement to "spinbutton"
and changing ARIA attributes to post value change notification.
This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
Tests: fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html
fast/forms/time-multiple-fields/time-multiple-fields-ax-value-changed-notification.html
* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::DateTimeFieldElement): Changed to set
"role" HTML attribute to "spinbutton".
(WebCore::DateTimeFieldElement::initialize): Changed to set new
parameter axHelpText to aria-help attribute and set aria-valuemax and
aria-valuemin attributes.
(WebCore::DateTimeFieldElement::updateVisibleValue): Changed to set
aria-valuetext and aria-valuenow attributes.
* html/shadow/DateTimeFieldElement.h:
(DateTimeFieldElement): Changed to add new parameter axHelpText to initialize().
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeAMPMFieldElement::create): Changed to add new argument.
(WebCore::DateTimeHourFieldElement::create): ditto.
(WebCore::DateTimeMillisecondFieldElement::create): ditto.
(WebCore::DateTimeMinuteFieldElement::create): ditto.
(WebCore::DateTimeSecondFieldElement::create): ditto.
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::maximum): Added for DateTimeFieldElement::initialize().
(WebCore::DateTimeNumericFieldElement::minimum): ditto.
* html/shadow/DateTimeNumericFieldElement.h:
(DateTimeNumericFieldElement): Added maximum() and minimum() declarations.
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::maximum): Added for DateTimeFieldElement::initialize().
(WebCore::DateTimeSymbolicFieldElement::minimum): ditto.
* html/shadow/DateTimeSymbolicFieldElement.h:
(DateTimeSymbolicFieldElement): Added maximum() and minimum() declarations.
2012-09-12 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r127876.
......@@ -30,8 +30,10 @@
#include "DateComponents.h"
#include "HTMLNames.h"
#include "KeyboardEvent.h"
#include "LocalizedStrings.h"
#include "RenderObject.h"
#include "Text.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
......@@ -45,6 +47,8 @@ DateTimeFieldElement::DateTimeFieldElement(Document* document, FieldOwner& field
: HTMLElement(spanTag, document)
, m_fieldOwner(&fieldOwner)
{
// On accessibility, DateTimeFieldElement acts like spin button.
setAttribute(roleAttr, "spinbutton");
}
void DateTimeFieldElement::defaultEventHandler(Event* event)
......@@ -129,8 +133,11 @@ void DateTimeFieldElement::focusOnNextField()
m_fieldOwner->focusOnNextField(*this);
}
void DateTimeFieldElement::initialize(const AtomicString& shadowPseudoId)
void DateTimeFieldElement::initialize(const AtomicString& shadowPseudoId, const String& axHelpText)
{
setAttribute(aria_helpAttr, axHelpText);
setAttribute(aria_valueminAttr, String::number(minimum()));
setAttribute(aria_valuemaxAttr, String::number(maximum()));
setShadowPseudoId(shadowPseudoId);
appendChild(Text::create(document(), visibleValue()));
}
......@@ -172,6 +179,8 @@ void DateTimeFieldElement::updateVisibleValue(EventBehavior eventBehavior)
return;
textNode->replaceWholeText(newVisibleValue, ASSERT_NO_EXCEPTION);
setAttribute(aria_valuetextAttr, hasValue() ? newVisibleValue : AXDateTimeFieldEmptyValueText());
setAttribute(aria_valuenowAttr, newVisibleValue);
if (eventBehavior == DispatchEvent && m_fieldOwner)
m_fieldOwner->fieldValueChanged();
......
......@@ -77,7 +77,9 @@ protected:
virtual void didFocus();
void focusOnNextField();
virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
void initialize(const AtomicString&);
void initialize(const AtomicString& shadowPseudoId, const String& axHelpText);
virtual int maximum() const = 0;
virtual int minimum() const = 0;
virtual double unitInMillisecond() const = 0;
void updateVisibleValue(EventBehavior);
......
......@@ -28,6 +28,7 @@
#include "DateTimeFieldElements.h"
#include "DateComponents.h"
#include "LocalizedStrings.h"
#include <wtf/DateMath.h>
namespace WebCore {
......@@ -41,7 +42,7 @@ PassRefPtr<DateTimeAMPMFieldElement> DateTimeAMPMFieldElement::create(Document*
{
DEFINE_STATIC_LOCAL(AtomicString, ampmPsuedoId, ("-webkit-datetime-edit-ampm-field"));
RefPtr<DateTimeAMPMFieldElement> field = adoptRef(new DateTimeAMPMFieldElement(document, fieldOwner, ampmLabels));
field->initialize(ampmPsuedoId);
field->initialize(ampmPsuedoId, AXAMPMFieldText());
return field.release();
}
......@@ -68,7 +69,7 @@ PassRefPtr<DateTimeHourFieldElement> DateTimeHourFieldElement::create(Document*
{
DEFINE_STATIC_LOCAL(AtomicString, hourPsuedoId, ("-webkit-datetime-edit-hour-field"));
RefPtr<DateTimeHourFieldElement> field = adoptRef(new DateTimeHourFieldElement(document, fieldOwner, minimum, maximum));
field->initialize(hourPsuedoId);
field->initialize(hourPsuedoId, AXHourFieldText());
return field.release();
}
......@@ -104,7 +105,7 @@ PassRefPtr<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::cre
{
DEFINE_STATIC_LOCAL(AtomicString, millisecondPsuedoId, ("-webkit-datetime-edit-millisecond-field"));
RefPtr<DateTimeMillisecondFieldElement> field = adoptRef(new DateTimeMillisecondFieldElement(document, fieldOwner));
field->initialize(millisecondPsuedoId);
field->initialize(millisecondPsuedoId, AXMillisecondFieldText());
return field.release();
}
......@@ -129,7 +130,7 @@ PassRefPtr<DateTimeMinuteFieldElement> DateTimeMinuteFieldElement::create(Docume
{
DEFINE_STATIC_LOCAL(AtomicString, minutePsuedoId, ("-webkit-datetime-edit-minute-field"));
RefPtr<DateTimeMinuteFieldElement> field = adoptRef(new DateTimeMinuteFieldElement(document, fieldOwner));
field->initialize(minutePsuedoId);
field->initialize(minutePsuedoId, AXMinuteFieldText());
return field.release();
}
......@@ -154,7 +155,7 @@ PassRefPtr<DateTimeSecondFieldElement> DateTimeSecondFieldElement::create(Docume
{
DEFINE_STATIC_LOCAL(AtomicString, secondPsuedoId, ("-webkit-datetime-edit-second-field"));
RefPtr<DateTimeSecondFieldElement> field = adoptRef(new DateTimeSecondFieldElement(document, fieldOwner));
field->initialize(secondPsuedoId);
field->initialize(secondPsuedoId, AXSecondFieldText());
return field.release();
}
......
......@@ -111,6 +111,16 @@ bool DateTimeNumericFieldElement::hasValue() const
return m_hasValue;
}
int DateTimeNumericFieldElement::maximum() const
{
return m_range.maximum;
}
int DateTimeNumericFieldElement::minimum() const
{
return m_range.minimum;
}
void DateTimeNumericFieldElement::setEmptyValue(const DateComponents& dateForReadOnlyField, EventBehavior eventBehavior)
{
m_lastDigitCharTime = 0;
......
......@@ -65,6 +65,8 @@ private:
// DateTimeFieldElement functions.
virtual void didBlur() OVERRIDE FINAL;
virtual void handleKeyboardEvent(KeyboardEvent*) OVERRIDE FINAL;
virtual int maximum() const OVERRIDE FINAL;
virtual int minimum() const OVERRIDE FINAL;
virtual void setEmptyValue(const DateComponents& dateForReadOnlyField, EventBehavior) OVERRIDE FINAL;
virtual void stepDown() OVERRIDE FINAL;
virtual void stepUp() OVERRIDE FINAL;
......
......@@ -95,6 +95,16 @@ bool DateTimeSymbolicFieldElement::hasValue() const
return m_selectedIndex >= 0;
}
int DateTimeSymbolicFieldElement::maximum() const
{
return static_cast<int>(m_symbols.size());
}
int DateTimeSymbolicFieldElement::minimum() const
{
return 1;
}
void DateTimeSymbolicFieldElement::setEmptyValue(const DateComponents&, EventBehavior eventBehavior)
{
m_selectedIndex = invalidIndex;
......
......@@ -49,6 +49,8 @@ private:
// DateTimeFieldElement functions.
virtual void handleKeyboardEvent(KeyboardEvent*) OVERRIDE FINAL;
virtual bool hasValue() const OVERRIDE FINAL;
virtual int maximum() const OVERRIDE FINAL;
virtual int minimum() const OVERRIDE FINAL;
virtual void setEmptyValue(const DateComponents& dateForReadOnlyField, EventBehavior = DispatchNoEvent) OVERRIDE FINAL;
virtual void stepDown() OVERRIDE FINAL;
virtual void stepUp() OVERRIDE FINAL;
......
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