зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1666380: Add support for AXTextFieldSearchKey to VO rotor r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D90941
This commit is contained in:
Родитель
b137e2e549
Коммит
bff9a869c8
|
@ -304,6 +304,14 @@ using namespace mozilla::a11y;
|
|||
: RotorRoleRule(roles::BLOCKQUOTE);
|
||||
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
|
||||
}
|
||||
|
||||
if ([key isEqualToString:@"AXTextFieldSearchKey"]) {
|
||||
RotorMacRoleRule rule =
|
||||
mImmediateDescendantsOnly
|
||||
? RotorMacRoleRule(@"AXTextField", geckoRootAcc)
|
||||
: RotorMacRoleRule(@"AXTextField");
|
||||
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
|
|
|
@ -37,6 +37,18 @@ class RotorRoleRule : public RotorRule {
|
|||
role mRole;
|
||||
};
|
||||
|
||||
class RotorMacRoleRule : public RotorRule {
|
||||
public:
|
||||
explicit RotorMacRoleRule(NSString* aRole);
|
||||
explicit RotorMacRoleRule(NSString* aRole,
|
||||
AccessibleOrProxy& aDirectDescendantsFrom);
|
||||
~RotorMacRoleRule();
|
||||
virtual uint16_t Match(const AccessibleOrProxy& aAccOrProxy) override;
|
||||
|
||||
private:
|
||||
NSString* mMacRole;
|
||||
};
|
||||
|
||||
class RotorControlRule final : public RotorRule {
|
||||
public:
|
||||
explicit RotorControlRule(AccessibleOrProxy& aDirectDescendantsFrom);
|
||||
|
|
|
@ -61,6 +61,38 @@ uint16_t RotorRoleRule::Match(const AccessibleOrProxy& aAccOrProxy) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// Rotor Mac Role Rule
|
||||
|
||||
RotorMacRoleRule::RotorMacRoleRule(NSString* aMacRole,
|
||||
AccessibleOrProxy& aDirectDescendantsFrom)
|
||||
: RotorRule(aDirectDescendantsFrom), mMacRole(aMacRole) {
|
||||
[mMacRole retain];
|
||||
};
|
||||
|
||||
RotorMacRoleRule::RotorMacRoleRule(NSString* aMacRole)
|
||||
: RotorRule(), mMacRole(aMacRole) {
|
||||
[mMacRole retain];
|
||||
};
|
||||
|
||||
RotorMacRoleRule::~RotorMacRoleRule() { [mMacRole release]; }
|
||||
|
||||
uint16_t RotorMacRoleRule::Match(const AccessibleOrProxy& aAccOrProxy) {
|
||||
uint16_t result = RotorRule::Match(aAccOrProxy);
|
||||
|
||||
// if a match was found in the base-class's Match function,
|
||||
// it is valid to consider that match again here. if it is
|
||||
// not of the desired role, we flip the match bit to "unmatch"
|
||||
// otherwise, the match persists.
|
||||
if ((result & nsIAccessibleTraversalRule::FILTER_MATCH)) {
|
||||
mozAccessible* nativeMatch = GetNativeFromGeckoAccessible(aAccOrProxy);
|
||||
if (![[nativeMatch moxRole] isEqualToString:mMacRole]) {
|
||||
result &= ~nsIAccessibleTraversalRule::FILTER_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Rotor Control Rule
|
||||
|
||||
RotorControlRule::RotorControlRule(AccessibleOrProxy& aDirectDescendantsFrom)
|
||||
|
|
|
@ -1167,6 +1167,82 @@ addAccessibleTask(
|
|||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* Test rotor with inputs
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<input type="text" value="I'm a text field." id="text"><br>
|
||||
<input type="text" value="me too" id="implText"><br>
|
||||
<textarea id="textarea">this is some text in a text area</textarea><br>
|
||||
<input type="tel" value="0000000000" id="tel"><br>
|
||||
<input type="url" value="https://example.com" id="url"><br>
|
||||
<input type="email" value="hi@example.com" id="email"><br>
|
||||
<input type="password" value="blah" id="password"><br>
|
||||
<input type="month" value="2020-01" id="month"><br>
|
||||
<input type="week" value="2020-W01" id="week"><br>
|
||||
`,
|
||||
async (browser, accDoc) => {
|
||||
const searchPred = {
|
||||
AXSearchKey: "AXTextFieldSearchKey",
|
||||
AXImmediateDescendants: 1,
|
||||
AXResultsLimit: -1,
|
||||
AXDirection: "AXDirectionNext",
|
||||
};
|
||||
|
||||
const webArea = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
is(
|
||||
webArea.getAttributeValue("AXRole"),
|
||||
"AXWebArea",
|
||||
"Got web area accessible"
|
||||
);
|
||||
|
||||
const textfieldCount = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementCountForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
|
||||
is(9, textfieldCount, "Found 9 fields");
|
||||
|
||||
const fields = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementsForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
|
||||
const text = getNativeInterface(accDoc, "text");
|
||||
const implText = getNativeInterface(accDoc, "implText");
|
||||
const textarea = getNativeInterface(accDoc, "textarea");
|
||||
const tel = getNativeInterface(accDoc, "tel");
|
||||
const url = getNativeInterface(accDoc, "url");
|
||||
const email = getNativeInterface(accDoc, "email");
|
||||
const password = getNativeInterface(accDoc, "password");
|
||||
const month = getNativeInterface(accDoc, "month");
|
||||
const week = getNativeInterface(accDoc, "week");
|
||||
|
||||
const toCheck = [
|
||||
text,
|
||||
implText,
|
||||
textarea,
|
||||
tel,
|
||||
url,
|
||||
email,
|
||||
password,
|
||||
month,
|
||||
week,
|
||||
];
|
||||
|
||||
for (let i = 0; i < toCheck.length; i++) {
|
||||
is(
|
||||
toCheck[i].getAttributeValue("AXValue"),
|
||||
fields[i].getAttributeValue("AXValue"),
|
||||
"Found correct input control"
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test rotor with static text
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче