зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1671049 - Invalidate cached ARIA role and role in mozAccessible when role changes. r=morgan
Besides the ARIA role invalidation, this fixes an issue where the mozAccessible's role is also incorrect when the aria role changes on a body tag. Depends on D93439 Differential Revision: https://phabricator.services.mozilla.com/D93440
This commit is contained in:
Родитель
c548ecd683
Коммит
2e476d423a
|
@ -15,6 +15,10 @@
|
|||
# include "nsRect.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
# include "mozilla/a11y/Role.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
|
@ -142,6 +146,8 @@ bool LocalizeString(
|
|||
class TextRangeData;
|
||||
void ProxyTextSelectionChangeEvent(ProxyAccessible* aTarget,
|
||||
const nsTArray<TextRangeData>& aSelection);
|
||||
|
||||
void ProxyRoleChangedEvent(ProxyAccessible* aTarget, const a11y::role& aRole);
|
||||
#endif
|
||||
|
||||
} // namespace a11y
|
||||
|
|
|
@ -530,6 +530,11 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvRoleChangedEvent(
|
|||
}
|
||||
|
||||
mRole = aRole;
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
ProxyRoleChangedEvent(this, aRole);
|
||||
#endif
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,12 @@ void ProxyTextSelectionChangeEvent(ProxyAccessible* aTarget,
|
|||
}
|
||||
}
|
||||
|
||||
void ProxyRoleChangedEvent(ProxyAccessible* aTarget, const a11y::role& aRole) {
|
||||
if (mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget)) {
|
||||
[wrapper handleRoleChanged:aRole];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -106,6 +106,9 @@ inline mozAccessible* GetNativeFromGeckoAccessible(
|
|||
// Get top level (tab) web area.
|
||||
- (mozAccessible*)topWebArea;
|
||||
|
||||
// Handle a role change
|
||||
- (void)handleRoleChanged:(mozilla::a11y::role)newRole;
|
||||
|
||||
#pragma mark - mozAccessible protocol / widget
|
||||
|
||||
// override
|
||||
|
|
|
@ -779,6 +779,14 @@ struct RoleDescrComparator {
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void)handleRoleChanged:(mozilla::a11y::role)newRole {
|
||||
mRole = newRole;
|
||||
mARIARole = nullptr;
|
||||
|
||||
// For testing purposes
|
||||
[self moxPostNotification:@"AXMozRoleChanged"];
|
||||
}
|
||||
|
||||
- (id)moxEditableAncestor {
|
||||
for (id element = self; [element conformsToProtocol:@protocol(MOXAccessible)];
|
||||
element = [element moxUnignoredParent]) {
|
||||
|
|
|
@ -202,3 +202,21 @@ addAccessibleTask(
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
addAccessibleTask(`<button>hello world</button>`, async (browser, accDoc) => {
|
||||
const webArea = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
|
||||
is(webArea.getAttributeValue("AXRole"), "AXWebArea");
|
||||
is(webArea.getAttributeValue("AXSubrole"), "AXUnknown");
|
||||
|
||||
let roleChanged = waitForMacEvent("AXMozRoleChanged");
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.body.setAttribute("role", "application");
|
||||
});
|
||||
await roleChanged;
|
||||
|
||||
is(webArea.getAttributeValue("AXRole"), "AXGroup");
|
||||
is(webArea.getAttributeValue("AXSubrole"), "AXLandmarkApplication");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче