mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1419131 - adding a11y force disabled pref observer when accessibility service is being created. r=surkov
MozReview-Commit-ID: G2pG3PcUMrE
This commit is contained in:
parent
d33cebae08
commit
77e0097f7a
@ -30,8 +30,12 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(AccessibleNode)
|
||||
|
||||
AccessibleNode::AccessibleNode(nsINode* aNode) : mDOMNode(aNode)
|
||||
{
|
||||
DocAccessible* doc =
|
||||
GetOrCreateAccService()->GetDocAccessible(mDOMNode->OwnerDoc());
|
||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||
if (!accService) {
|
||||
return;
|
||||
}
|
||||
|
||||
DocAccessible* doc = accService->GetDocAccessible(mDOMNode->OwnerDoc());
|
||||
if (doc) {
|
||||
mIntl = doc->GetAccessible(mDOMNode);
|
||||
}
|
||||
@ -57,8 +61,11 @@ void
|
||||
AccessibleNode::GetRole(nsAString& aRole)
|
||||
{
|
||||
if (mIntl) {
|
||||
GetOrCreateAccService()->GetStringRole(mIntl->Role(), aRole);
|
||||
return;
|
||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||
if (accService) {
|
||||
accService->GetStringRole(mIntl->Role(), aRole);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aRole.AssignLiteral("unknown");
|
||||
@ -67,15 +74,19 @@ AccessibleNode::GetRole(nsAString& aRole)
|
||||
void
|
||||
AccessibleNode::GetStates(nsTArray<nsString>& aStates)
|
||||
{
|
||||
if (mIntl) {
|
||||
if (!mStates) {
|
||||
mStates = GetOrCreateAccService()->GetStringStates(mIntl->State());
|
||||
}
|
||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||
if (!mIntl || !accService) {
|
||||
aStates.AppendElement(NS_LITERAL_STRING("defunct"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStates) {
|
||||
aStates = mStates->StringArray();
|
||||
return;
|
||||
}
|
||||
|
||||
aStates.AppendElement(NS_LITERAL_STRING("defunct"));
|
||||
mStates = accService->GetStringStates(mIntl->State());
|
||||
aStates = mStates->StringArray();
|
||||
}
|
||||
|
||||
void
|
||||
@ -106,7 +117,8 @@ AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes)
|
||||
bool
|
||||
AccessibleNode::Is(const Sequence<nsString>& aFlavors)
|
||||
{
|
||||
if (!mIntl) {
|
||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||
if (!mIntl || !accService) {
|
||||
for (const auto& flavor : aFlavors) {
|
||||
if (!flavor.EqualsLiteral("unknown") && !flavor.EqualsLiteral("defunct")) {
|
||||
return false;
|
||||
@ -116,10 +128,10 @@ AccessibleNode::Is(const Sequence<nsString>& aFlavors)
|
||||
}
|
||||
|
||||
nsAutoString role;
|
||||
GetOrCreateAccService()->GetStringRole(mIntl->Role(), role);
|
||||
accService->GetStringRole(mIntl->Role(), role);
|
||||
|
||||
if (!mStates) {
|
||||
mStates = GetOrCreateAccService()->GetStringStates(mIntl->State());
|
||||
mStates = accService->GetStringStates(mIntl->State());
|
||||
}
|
||||
|
||||
for (const auto& flavor : aFlavors) {
|
||||
|
@ -1904,6 +1904,11 @@ nsAccessibilityService::NotifyOfConsumersChange()
|
||||
nsAccessibilityService*
|
||||
GetOrCreateAccService(uint32_t aNewConsumer)
|
||||
{
|
||||
// Do not initialize accessibility if it is force disabled.
|
||||
if (PlatformDisabledState() == ePlatformIsDisabled) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!nsAccessibilityService::gAccessibilityService) {
|
||||
RefPtr<nsAccessibilityService> service = new nsAccessibilityService();
|
||||
if (!service->Init()) {
|
||||
|
@ -46,7 +46,7 @@ xpcAccessibilityService::AddRef(void)
|
||||
|
||||
// We want refcount to be > 1 because one reference is added in the XPCOM
|
||||
// accessibility service getter.
|
||||
if (mRefCnt > 1 && PlatformDisabledState() != ePlatformIsDisabled) {
|
||||
if (mRefCnt > 1) {
|
||||
GetOrCreateAccService(nsAccessibilityService::eXPCOM);
|
||||
}
|
||||
|
||||
@ -280,13 +280,10 @@ NS_GetAccessibilityService(nsIAccessibilityService** aResult)
|
||||
NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER);
|
||||
*aResult = nullptr;
|
||||
|
||||
// Do not initialize accessibility if it is force disabled.
|
||||
if (PlatformDisabledState() == ePlatformIsDisabled) {
|
||||
if (!GetOrCreateAccService(nsAccessibilityService::eXPCOM)) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
GetOrCreateAccService(nsAccessibilityService::eXPCOM);
|
||||
|
||||
xpcAccessibilityService* service = new xpcAccessibilityService();
|
||||
NS_ENSURE_TRUE(service, NS_ERROR_OUT_OF_MEMORY);
|
||||
xpcAccessibilityService::gXPCAccessibilityService = service;
|
||||
|
Loading…
Reference in New Issue
Block a user