mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 559761 - make <input type=number> accessible, r=tbsaunde, smaug
--HG-- rename : accessible/tests/mochitest/value/test_range.html => accessible/tests/mochitest/value/test_number.html
This commit is contained in:
parent
753f600245
commit
52991836e6
@ -34,6 +34,7 @@ enum AccType {
|
||||
eHTMLMediaType,
|
||||
eHTMLRadioButtonType,
|
||||
eHTMLRangeType,
|
||||
eHTMLSpinnerType,
|
||||
eHTMLTableType,
|
||||
eHTMLTableCellType,
|
||||
eHTMLTableRowType,
|
||||
|
@ -1534,6 +1534,9 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
|
||||
case eHTMLRangeType:
|
||||
newAcc = new HTMLRangeAccessible(aContent, document);
|
||||
break;
|
||||
case eHTMLSpinnerType:
|
||||
newAcc = new HTMLSpinnerAccessible(aContent, document);
|
||||
break;
|
||||
case eHTMLTableType:
|
||||
newAcc = new HTMLTableAccessibleWrap(aContent, document);
|
||||
break;
|
||||
|
@ -302,7 +302,7 @@ HTMLTextFieldAccessible::NativeRole()
|
||||
nsGkAtoms::password, eIgnoreCase)) {
|
||||
return roles::PASSWORD_TEXT;
|
||||
}
|
||||
|
||||
|
||||
return roles::ENTRY;
|
||||
}
|
||||
|
||||
@ -540,6 +540,76 @@ HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLSpinnerAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
role
|
||||
HTMLSpinnerAccessible::NativeRole()
|
||||
{
|
||||
return roles::SPINBUTTON;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSpinnerAccessible::Value(nsString& aValue)
|
||||
{
|
||||
AccessibleWrap::Value(aValue);
|
||||
if (!aValue.IsEmpty())
|
||||
return;
|
||||
|
||||
HTMLInputElement::FromContent(mContent)->GetValue(aValue);
|
||||
}
|
||||
|
||||
double
|
||||
HTMLSpinnerAccessible::MaxValue() const
|
||||
{
|
||||
double value = AccessibleWrap::MaxValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
HTMLSpinnerAccessible::MinValue() const
|
||||
{
|
||||
double value = AccessibleWrap::MinValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
return HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
||||
}
|
||||
|
||||
double
|
||||
HTMLSpinnerAccessible::Step() const
|
||||
{
|
||||
double value = AccessibleWrap::Step();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
return HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
||||
}
|
||||
|
||||
double
|
||||
HTMLSpinnerAccessible::CurValue() const
|
||||
{
|
||||
double value = AccessibleWrap::CurValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
return HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLSpinnerAccessible::SetCurValue(double aValue)
|
||||
{
|
||||
ErrorResult er;
|
||||
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
|
||||
return !er.Failed();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLRangeAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -576,7 +646,6 @@ HTMLRangeAccessible::MaxValue() const
|
||||
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
HTMLRangeAccessible::MinValue() const
|
||||
{
|
||||
|
@ -165,6 +165,30 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used for HTML input@type="number".
|
||||
*/
|
||||
class HTMLSpinnerAccessible : public AccessibleWrap
|
||||
{
|
||||
public:
|
||||
HTMLSpinnerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
AccessibleWrap(aContent, aDoc)
|
||||
{
|
||||
mStateFlags |= eHasNumericValue;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
|
||||
virtual void Value(nsString& aValue) MOZ_OVERRIDE;
|
||||
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
virtual double MinValue() const MOZ_OVERRIDE;
|
||||
virtual double CurValue() const MOZ_OVERRIDE;
|
||||
virtual double Step() const MOZ_OVERRIDE;
|
||||
virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used for input@type="range" element.
|
||||
*/
|
||||
|
@ -682,6 +682,34 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// HTML:input@type="number" and etc
|
||||
|
||||
obj = {
|
||||
role: ROLE_SPINBUTTON,
|
||||
interfaces: [ nsIAccessibleValue ],
|
||||
children: [
|
||||
{
|
||||
role: ROLE_ENTRY,
|
||||
extraStates: EXT_STATE_EDITABLE | EXT_STATE_SINGLE_LINE,
|
||||
actions: "activate",
|
||||
interfaces: [ nsIAccessibleText, nsIAccessibleEditableText ],
|
||||
children: [
|
||||
{ role: ROLE_TEXT_LEAF }
|
||||
]
|
||||
},
|
||||
{
|
||||
role: ROLE_PUSHBUTTON,
|
||||
actions: "press"
|
||||
},
|
||||
{
|
||||
role: ROLE_PUSHBUTTON,
|
||||
actions: "press"
|
||||
}
|
||||
]
|
||||
};
|
||||
testElm("input_number", obj);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// HTML:input@type="text" and etc
|
||||
|
||||
obj = {
|
||||
role: ROLE_ENTRY,
|
||||
extraStates: EXT_STATE_EDITABLE | EXT_STATE_SINGLE_LINE,
|
||||
@ -691,7 +719,6 @@
|
||||
{ role: ROLE_TEXT_LEAF }
|
||||
]
|
||||
};
|
||||
// TODO: re-enable in bug 559761 testElm("input_number", obj);
|
||||
testElm("input_email", obj);
|
||||
testElm("input_search", obj);
|
||||
testElm("input_tel", obj);
|
||||
|
@ -63,6 +63,15 @@
|
||||
accTree = { SLIDER: [ ] };
|
||||
testAccessibleTree("range", accTree);
|
||||
|
||||
// input@type="number"
|
||||
accTree =
|
||||
{ SPINBUTTON: [
|
||||
{ ENTRY: [ ] },
|
||||
{ PUSHBUTTON: [ ] },
|
||||
{ PUSHBUTTON: [ ] }
|
||||
] };
|
||||
testAccessibleTree("number", accTree);
|
||||
|
||||
// output
|
||||
accTree = {
|
||||
role: ROLE_SECTION,
|
||||
@ -116,6 +125,7 @@
|
||||
<input type="submit" id="submit">
|
||||
<input type="image" id="image_submit">
|
||||
<input type="range" id="range">
|
||||
<input type="number" id="number">
|
||||
<output id="output">1337</output>
|
||||
|
||||
</body>
|
||||
|
@ -1,6 +1,7 @@
|
||||
[DEFAULT]
|
||||
|
||||
[test_general.html]
|
||||
[test_number.html]
|
||||
[test_progress.html]
|
||||
[test_progress.xul]
|
||||
[test_range.html]
|
||||
|
59
accessible/tests/mochitest/value/test_number.html
Normal file
59
accessible/tests/mochitest/value/test_number.html
Normal file
@ -0,0 +1,59 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>nsIAccessible value testing for input@type=range element</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../value.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
// HTML5 number element tests
|
||||
testValue("number", "", 0, 0, 0, 1);
|
||||
testValue("number_value", "1", 1, 0, 0, 1);
|
||||
testValue("number_step", "", 0, 0, 0, 1);
|
||||
testValue("number_min42", "", 0, 42, 0, 1);
|
||||
testValue("number_max42", "", 0, 0, 42, 1);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=559761"
|
||||
title="make HTML5 input@type=number element accessible">
|
||||
Bug 559761
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<!-- HTML5 input@type=number element -->
|
||||
<input type="number" id="number">
|
||||
<input type="number" id="number_value" value="1">
|
||||
<input type="number" id="number_step" step="1">
|
||||
<input type="number" id="number_min42" min="42">
|
||||
<input type="number" id="number_max42" max="42">
|
||||
</body>
|
||||
</html>
|
@ -22,6 +22,10 @@
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "mozilla/a11y/AccTypes.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -224,6 +228,12 @@ nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown ||
|
||||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp) {
|
||||
resultElement->SetAttr(kNameSpaceID_None, nsGkAtoms::role,
|
||||
NS_LITERAL_STRING("button"), false);
|
||||
}
|
||||
|
||||
resultElement.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -560,3 +570,11 @@ nsNumberControlFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
|
||||
|
||||
return nsContainerFrame::GetPseudoElement(aType);
|
||||
}
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
a11y::AccType
|
||||
nsNumberControlFrame::AccessibleType()
|
||||
{
|
||||
return a11y::eHTMLSpinnerType;
|
||||
}
|
||||
#endif
|
||||
|
@ -46,6 +46,10 @@ public:
|
||||
virtual void ContentStatesChanged(nsEventStates aStates);
|
||||
virtual bool IsLeaf() const MOZ_OVERRIDE { return false; }
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
|
Loading…
Reference in New Issue
Block a user