зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625266: Add stepper subclass, support value changes. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D70772
This commit is contained in:
Родитель
bec0621315
Коммит
0f8bea4c9f
|
@ -182,9 +182,7 @@ Class a11y::GetTypeFromRole(roles::Role aRole) {
|
|||
switch (aRole) {
|
||||
case roles::COMBOBOX:
|
||||
case roles::PUSHBUTTON:
|
||||
case roles::SPLITBUTTON: {
|
||||
return [mozButtonAccessible class];
|
||||
}
|
||||
|
||||
case roles::PAGETAB:
|
||||
return [mozTabAccessible class];
|
||||
|
@ -194,8 +192,9 @@ Class a11y::GetTypeFromRole(roles::Role aRole) {
|
|||
case roles::RADIOBUTTON:
|
||||
return [mozCheckboxAccessible class];
|
||||
|
||||
case roles::SPINBUTTON:
|
||||
case roles::SLIDER:
|
||||
return [mozSliderAccessible class];
|
||||
return [mozIncrementableAccessible class];
|
||||
|
||||
case roles::HEADING:
|
||||
return [mozHeadingAccessible class];
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
@end
|
||||
|
||||
/**
|
||||
* Accessible for a slider
|
||||
* Base accessible for an incrementable
|
||||
*/
|
||||
@interface mozSliderAccessible : mozAccessible
|
||||
@interface mozIncrementableAccessible : mozAccessible
|
||||
|
||||
@end
|
||||
|
|
|
@ -162,7 +162,7 @@ enum CheckboxValue {
|
|||
|
||||
@end
|
||||
|
||||
@implementation mozSliderAccessible
|
||||
@implementation mozIncrementableAccessible
|
||||
|
||||
- (NSArray*)accessibilityActionNames {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
@ -207,12 +207,20 @@ enum CheckboxValue {
|
|||
|
||||
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
||||
double newVal = accWrap->CurValue() + (accWrap->Step() * factor);
|
||||
if (newVal >= accWrap->MinValue() && newVal <= accWrap->MaxValue()) {
|
||||
double min = accWrap->MinValue();
|
||||
double max = accWrap->MaxValue();
|
||||
if ((IsNaN(min) || newVal >= min) && (IsNaN(max) || newVal <= max)) {
|
||||
accWrap->SetCurValue(newVal);
|
||||
}
|
||||
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
||||
double newVal = proxy->CurValue() + (proxy->Step() * factor);
|
||||
if (newVal >= proxy->MinValue() && newVal <= proxy->MaxValue()) {
|
||||
double min = proxy->MinValue();
|
||||
double max = proxy->MaxValue();
|
||||
// Because min and max are not required attributes, we first check
|
||||
// if the value is undefined. If this check fails,
|
||||
// the value is defined, and we we verify our new value falls
|
||||
// within the bound (inclusive).
|
||||
if ((IsNaN(min) || newVal >= min) && (IsNaN(max) || newVal <= max)) {
|
||||
proxy->SetCurValue(newVal);
|
||||
}
|
||||
}
|
||||
|
@ -222,6 +230,7 @@ enum CheckboxValue {
|
|||
|
||||
- (void)handleAccessibleEvent:(uint32_t)eventType {
|
||||
switch (eventType) {
|
||||
case nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE:
|
||||
case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
|
||||
[self postNotification:NSAccessibilityValueChangedNotification];
|
||||
break;
|
||||
|
|
|
@ -48,3 +48,45 @@ addAccessibleTask(
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test input[type=range]
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`<input type="number" value="11" id="number">`,
|
||||
async (browser, accDoc) => {
|
||||
let number = getNativeInterface(accDoc, "number");
|
||||
is(
|
||||
number.getAttributeValue("AXRole"),
|
||||
"AXIncrementor",
|
||||
"Correct AXIncrementor role"
|
||||
);
|
||||
is(number.getAttributeValue("AXValue"), 11, "Correct initial value");
|
||||
|
||||
let actions = number.actionNames;
|
||||
ok(actions.includes("AXDecrement"), "Has decrement action");
|
||||
ok(actions.includes("AXIncrement"), "Has increment action");
|
||||
|
||||
let evt = waitForMacEvent("AXValueChanged");
|
||||
number.performAction("AXIncrement");
|
||||
await evt;
|
||||
is(number.getAttributeValue("AXValue"), 12, "Correct increment value");
|
||||
|
||||
evt = waitForMacEvent("AXValueChanged");
|
||||
number.performAction("AXDecrement");
|
||||
await evt;
|
||||
is(number.getAttributeValue("AXValue"), 11, "Correct decrement value");
|
||||
|
||||
evt = waitForMacEvent("AXValueChanged");
|
||||
// Adjust value via script in content
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.getElementById("number").value = 42;
|
||||
});
|
||||
await evt;
|
||||
is(
|
||||
number.getAttributeValue("AXValue"),
|
||||
42,
|
||||
"Correct value from content change"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче