forked from mirrors/gecko-dev
Bug 1884258: Introduce mozRangeAccessible to support progress HTML element r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D204444
This commit is contained in:
parent
bcc3659b2a
commit
00e1715f0d
4 changed files with 100 additions and 29 deletions
|
|
@ -192,6 +192,9 @@ Class a11y::GetTypeFromRole(roles::Role aRole) {
|
|||
case roles::RADIO_MENU_ITEM:
|
||||
return [mozRadioButtonAccessible class];
|
||||
|
||||
case roles::PROGRESSBAR:
|
||||
return [mozRangeAccessible class];
|
||||
|
||||
case roles::SPINBUTTON:
|
||||
case roles::SLIDER:
|
||||
return [mozIncrementableAccessible class];
|
||||
|
|
|
|||
|
|
@ -65,22 +65,37 @@
|
|||
@end
|
||||
|
||||
/**
|
||||
* Base accessible for an incrementable
|
||||
* Base accessible for a range, an acc with a min, max that cannot
|
||||
* be modified by the user directly.
|
||||
*/
|
||||
@interface mozIncrementableAccessible : mozAccessible
|
||||
|
||||
@interface mozRangeAccessible : mozAccessible
|
||||
|
||||
// override
|
||||
- (id)moxValue;
|
||||
|
||||
// override
|
||||
- (NSString*)moxValueDescription;
|
||||
|
||||
// override
|
||||
- (id)moxMinValue;
|
||||
|
||||
// override
|
||||
- (id)moxMaxValue;
|
||||
|
||||
// override
|
||||
- (NSString*)moxOrientation;
|
||||
|
||||
// override
|
||||
- (void)handleAccessibleEvent:(uint32_t)eventType;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Base accessible for an incrementable, a settable range
|
||||
*/
|
||||
@interface mozIncrementableAccessible : mozRangeAccessible
|
||||
|
||||
// override
|
||||
- (NSString*)moxValueDescription;
|
||||
|
||||
// override
|
||||
- (void)moxSetValue:(id)value;
|
||||
|
||||
|
|
@ -90,12 +105,6 @@
|
|||
// override
|
||||
- (void)moxPerformDecrement;
|
||||
|
||||
// override
|
||||
- (NSString*)moxOrientation;
|
||||
|
||||
// override
|
||||
- (void)handleAccessibleEvent:(uint32_t)eventType;
|
||||
|
||||
- (void)changeValueBySteps:(int)factor;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -134,17 +134,12 @@ using namespace mozilla::a11y;
|
|||
|
||||
@end
|
||||
|
||||
@implementation mozIncrementableAccessible
|
||||
@implementation mozRangeAccessible
|
||||
|
||||
- (id)moxValue {
|
||||
return [NSNumber numberWithDouble:mGeckoAccessible->CurValue()];
|
||||
}
|
||||
|
||||
- (NSString*)moxValueDescription {
|
||||
nsAutoString valueDesc;
|
||||
mGeckoAccessible->Value(valueDesc);
|
||||
return nsCocoaUtils::ToNSString(valueDesc);
|
||||
}
|
||||
- (id)moxMinValue {
|
||||
return [NSNumber numberWithDouble:mGeckoAccessible->MinValue()];
|
||||
}
|
||||
|
|
@ -153,18 +148,6 @@ using namespace mozilla::a11y;
|
|||
return [NSNumber numberWithDouble:mGeckoAccessible->MaxValue()];
|
||||
}
|
||||
|
||||
- (void)moxSetValue:(id)value {
|
||||
[self setValue:([value doubleValue])];
|
||||
}
|
||||
|
||||
- (void)moxPerformIncrement {
|
||||
[self changeValueBySteps:1];
|
||||
}
|
||||
|
||||
- (void)moxPerformDecrement {
|
||||
[self changeValueBySteps:-1];
|
||||
}
|
||||
|
||||
- (NSString*)moxOrientation {
|
||||
RefPtr<AccAttributes> attributes = mGeckoAccessible->Attributes();
|
||||
if (attributes) {
|
||||
|
|
@ -192,6 +175,28 @@ using namespace mozilla::a11y;
|
|||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation mozIncrementableAccessible
|
||||
|
||||
- (NSString*)moxValueDescription {
|
||||
nsAutoString valueDesc;
|
||||
mGeckoAccessible->Value(valueDesc);
|
||||
return nsCocoaUtils::ToNSString(valueDesc);
|
||||
}
|
||||
|
||||
- (void)moxSetValue:(id)value {
|
||||
[self setValue:([value doubleValue])];
|
||||
}
|
||||
|
||||
- (void)moxPerformIncrement {
|
||||
[self changeValueBySteps:1];
|
||||
}
|
||||
|
||||
- (void)moxPerformDecrement {
|
||||
[self changeValueBySteps:-1];
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates the accessible's current value by factor and step.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -188,3 +188,57 @@ addAccessibleTask(
|
|||
is(slider.getAttributeValue("AXMaxValue"), 5, "Correct max value");
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Verify progress HTML elements expose their min, max, and value to VO.
|
||||
* Progress elements should not expose a value description, and should not
|
||||
* expose increment/decrement actions.
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`<progress id="progress" value="70" max="100"></progress>`,
|
||||
async (browser, accDoc) => {
|
||||
const progress = getNativeInterface(accDoc, "progress");
|
||||
is(progress.getAttributeValue("AXValue"), 70, "Correct value");
|
||||
is(progress.getAttributeValue("AXMaxValue"), 100, "Correct max value");
|
||||
is(progress.getAttributeValue("AXMinValue"), 0, "Correct min value");
|
||||
is(
|
||||
progress.getAttributeValue("AXValueDescription"),
|
||||
null,
|
||||
"Progress elements should not expose a value description"
|
||||
);
|
||||
for (let action of progress.actionNames) {
|
||||
isnot(
|
||||
action,
|
||||
"AXIncrement",
|
||||
"Progress elements should not expose increment action"
|
||||
);
|
||||
isnot(
|
||||
action,
|
||||
"AXDecrement",
|
||||
"Progress elements should not expose decrement action"
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Verify progress HTML elements expose changes to their value.
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`<progress id="progress" value="70" max="100"></progress>`,
|
||||
async (browser, accDoc) => {
|
||||
const progress = getNativeInterface(accDoc, "progress");
|
||||
is(progress.getAttributeValue("AXValue"), 70, "Correct value");
|
||||
is(progress.getAttributeValue("AXMaxValue"), 100, "Correct max value");
|
||||
is(progress.getAttributeValue("AXMinValue"), 0, "Correct min value");
|
||||
|
||||
const evt = waitForMacEvent("AXValueChanged");
|
||||
await invokeContentTask(browser, [], () => {
|
||||
const p = content.document.getElementById("progress");
|
||||
p.setAttribute("value", "90");
|
||||
});
|
||||
await evt;
|
||||
|
||||
is(progress.getAttributeValue("AXValue"), 90, "Correct updated value");
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue