Bug 1875629 - Add AXContents to outer docs (scroll areas). r=morgan

Without this attribute VoiceOver gets into an unstable state when the cursor or focus
leaves the document.

Differential Revision: https://phabricator.services.mozilla.com/D211617
This commit is contained in:
Eitan Isaacson
2024-05-28 20:52:51 +00:00
parent 29a4ea8178
commit 36187c9cbf
6 changed files with 71 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
#import "MOXLandmarkAccessibles.h"
#import "MOXMathAccessibles.h"
#import "MOXOuterDoc.h"
#import "MOXTextMarkerDelegate.h"
#import "MOXWebAreaAccessible.h"
#import "mozAccessible.h"
@@ -118,6 +119,10 @@ Class AccessibleWrap::GetNativeType() {
return [MOXWebAreaAccessible class];
}
if (IsOuterDoc()) {
return [MOXOuterDoc class];
}
return GetTypeFromRole(Role());
NS_OBJC_END_TRY_BLOCK_RETURN(nil);

View File

@@ -0,0 +1,16 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset:
* 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import "mozAccessible.h"
@interface MOXOuterDoc : mozAccessible
// overrides
- (NSString*)moxContents;
@end

View File

@@ -0,0 +1,15 @@
/* -*- (Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil;
* c-basic-offset:) 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import "MOXOuterDoc.h"
@implementation MOXOuterDoc
- (NSArray* _Nullable)moxContents {
return [self moxUnignoredChildren];
}
@end

View File

@@ -14,6 +14,7 @@
#include "DocAccessibleParent.h"
#include "mozTableAccessible.h"
#include "mozTextAccessible.h"
#include "MOXOuterDoc.h"
#include "MOXWebAreaAccessible.h"
#include "nsAccUtils.h"
#include "TextRange.h"
@@ -65,6 +66,8 @@ void ProxyCreated(RemoteAccessible* aProxy) {
type = [mozTableCellAccessible class];
} else if (aProxy->IsDoc()) {
type = [MOXWebAreaAccessible class];
} else if (aProxy->IsOuterDoc()) {
type = [MOXOuterDoc class];
} else {
type = GetTypeFromRole(aProxy->Role());
}

View File

@@ -21,6 +21,7 @@ UNIFIED_SOURCES += [
"MOXAccessibleBase.mm",
"MOXLandmarkAccessibles.mm",
"MOXMathAccessibles.mm",
"MOXOuterDoc.mm",
"MOXSearchInfo.mm",
"MOXTextMarkerDelegate.mm",
"MOXWebAreaAccessible.mm",

View File

@@ -75,3 +75,34 @@ addAccessibleTask(`<title>webarea test</title>`, async browser => {
"iframe document has finished loading"
);
});
// Test AXContents in outer doc (AXScrollArea)
addAccessibleTask(
`<p id="p">Hello</p>`,
async (browser, accDoc) => {
const doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
const outerDoc = doc.getAttributeValue("AXParent");
const p = getNativeInterface(accDoc, "p");
let contents = outerDoc.getAttributeValue("AXContents");
is(contents.length, 1, "outer doc has single AXContents member");
is(
contents[0].getAttributeValue("AXRole"),
"AXWebArea",
"AXContents member is a web area"
);
ok(
!doc.attributeNames.includes("AXContents"),
"Web area does not have XContents"
);
ok(
!p.attributeNames.includes("AXContents"),
"Web content does not hace XContents"
);
},
{ iframe: true, remoteIframe: true }
);