Backed out changeset 2860943a09a3 (bug 1686164) for build bustages at mozSelectableElements.mm. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2021-01-21 10:58:18 +02:00
Родитель 7c97e0940d
Коммит ff8e5cb389
3 изменённых файлов: 33 добавлений и 96 удалений

Просмотреть файл

@ -87,10 +87,10 @@
- (NSString*)moxLabel;
// override
- (NSArray*)moxVisibleChildren;
- (NSArray*)moxChildren;
// override
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent;
- (NSArray*)moxVisibleChildren;
// override
- (id)moxTitleUIElement;
@ -101,8 +101,6 @@
// override
- (void)expire;
- (BOOL)isOpened;
@end
@interface mozMenuItemAccessible : mozSelectableChildAccessible
@ -110,9 +108,6 @@
// override
- (NSString*)moxLabel;
// override
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent;
// override
- (NSString*)moxMenuItemMarkChar;

Просмотреть файл

@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import "mozSelectableElements.h"
#import "MOXWebAreaAccessible.h"
#import "MacUtils.h"
#include "Accessible-inl.h"
#include "nsCocoaUtils.h"
@ -19,16 +18,7 @@ using namespace mozilla::a11y;
* Return the mozAccessibles that are selectable.
*/
- (NSArray*)selectableChildren {
NSArray* toFilter;
if ([self isKindOfClass:[mozMenuAccessible class]]) {
// If we are a menu, our children are only selectable if they are visible
// so we filter this array instead of our unignored children list, which may
// contain invisible items.
toFilter = [static_cast<mozMenuAccessible*>(self) moxVisibleChildren];
} else {
toFilter = [self moxUnignoredChildren];
}
return [toFilter
return [[self moxUnignoredChildren]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(
mozAccessible* child,
NSDictionary* bindings) {
@ -48,13 +38,14 @@ using namespace mozilla::a11y;
* Return the mozAccessibles that are actually selected.
*/
- (NSArray*)moxSelectedChildren {
return [[self selectableChildren]
return [[self moxUnignoredChildren]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(
mozAccessible* child,
NSDictionary* bindings) {
// Return mozSelectableChildAccessibles that have are selected (truthy
// value).
return [[(mozSelectableChildAccessible*)child moxSelected] boolValue];
return [child isKindOfClass:[mozSelectableChildAccessible class]] &&
[[(mozSelectableChildAccessible*)child moxSelected] boolValue];
}]];
}
@ -163,43 +154,25 @@ using namespace mozilla::a11y;
return @"";
}
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
// This helps us generate the correct moxChildren array for
// a sub menu -- that returned array should contain all
// menu items, regardless of if they are visible or not.
// Because moxChildren does ignore filtering, and because
// our base ignore method filters out invisible accessibles,
// we override this method.
if ([parent isKindOfClass:[MOXWebAreaAccessible class]] ||
[parent isKindOfClass:[MOXRootGroup class]]) {
// We are a top level menu. Check our visibility the normal way
return [super moxIgnoreWithParent:parent];
- (NSArray*)moxChildren {
// We differ from Webkit and Apple-native menus here; they expose
// all children regardless of whether or not the menu is open.
// In testing, VoiceOver doesn't seem to actually care what happens
// here as long as AXVisibleChildren is exposed correctly, so
// we expose children only when the menu is open to avoid
// changing ignoreWithParent/ignoreChild and/or isAccessibilityElement
if (mIsOpened) {
return [super moxChildren];
}
if ([parent isKindOfClass:[mozMenuItemAccessible class]] &&
[parent geckoAccessible].Role() == roles::PARENT_MENUITEM) {
// We are a submenu. If our parent menu item is in an open menu
// we should not be ignored
id grandparent = [parent moxUnignoredParent];
if ([grandparent isKindOfClass:[mozMenuAccessible class]]) {
mozMenuAccessible* parentMenu =
static_cast<mozMenuAccessible*>(grandparent);
return ![parentMenu isOpened];
}
}
// Otherwise, we call into our superclass's ignore method
// to handle menus that are not submenus
return [super moxIgnoreWithParent:parent];
return nil;
}
- (NSArray*)moxVisibleChildren {
// VO expects us to expose two lists of children on menus: all children
// (done in moxUnignoredChildren), and children which are visible (here).
// We implement ignoreWithParent for both menus and menu items
// to ensure moxUnignoredChildren returns a complete list of children
// regardless of visibility, see comments in those methods for additional
// info.
// (done above in moxChildren), and children which are visible (here).
// In our code, these are essentially the same list, since at the time of
// wiritng we filter for visibility in isAccessibilityElement before
// passing anything to VO.
return [[self moxChildren]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(
mozAccessible* child,
@ -215,7 +188,8 @@ using namespace mozilla::a11y;
- (id)moxTitleUIElement {
id parent = [self moxUnignoredParent];
if (parent && [parent isKindOfClass:[mozAccessible class]]) {
if ([parent isKindOfClass:[mozAccessible class]] &&
[parent geckoAccessible].Role() == roles::PARENT_MENUITEM) {
return parent;
}
@ -242,10 +216,6 @@ using namespace mozilla::a11y;
[super expire];
}
- (BOOL)isOpened {
return mIsOpened;
}
@end
@implementation mozMenuItemAccessible
@ -254,36 +224,6 @@ using namespace mozilla::a11y;
return @"";
}
- (BOOL)moxIgnoreWithParent:(mozAccessible*)parent {
// This helps us generate the correct moxChildren array for
// a mozMenuAccessible; the returned array should contain all
// menu items, regardless of if they are visible or not.
// Because moxChildren does ignore filtering, and because
// our base ignore method filters out invisible accessibles,
// we override this method.
mozAccessible* grandparent =
GetNativeFromGeckoAccessible([parent geckoAccessible].Parent());
if ([grandparent isKindOfClass:[MOXWebAreaAccessible class]]) {
return [parent moxIgnoreWithParent:grandparent];
}
grandparent = [parent moxUnignoredParent];
if ([grandparent isKindOfClass:[mozMenuItemAccessible class]]) {
mozMenuItemAccessible* acc =
static_cast<mozMenuItemAccessible*>(grandparent);
if ([acc geckoAccessible].Role() == roles::PARENT_MENUITEM) {
mozMenuAccessible* parentMenu = static_cast<mozMenuAccessible*>(parent);
// if we are a menu item in a submenu, display only when
// parent menu item is open
return ![parentMenu isOpened];
}
}
// Otherwise, we call into our superclass's method to handle
// menuitems that are not within submenus
return [super moxIgnoreWithParent:parent];
}
- (NSString*)moxMenuItemMarkChar {
Accessible* acc = mGeckoAccessible.AsAccessible();
if (acc && acc->IsContent() &&

Просмотреть файл

@ -206,8 +206,7 @@ add_task(async () => {
{ type: "contextmenu" },
browser
);
await waitForMacEvent("AXMenuOpened");
await BrowserTestUtils.waitForPopupEvent(menu, "shown");
menu = await getMacAccessible(menu);
const menuChildren = menu.getAttributeValue("AXChildren");
// menu contains 12 items and 3 splitters for 15 items total
@ -237,21 +236,24 @@ add_task(async () => {
// submenus are at indicies 1 and 10
// first check they have no children when hidden
is(
menuChildren[1].getAttributeValue("AXVisibleChildren"),
null,
"Submenu 1 has no visible chldren when hidden"
menuChildren[1].getAttributeValue("AXChildren").length,
0,
"Submenu 1 has no chldren when hidden"
);
is(
menuChildren[11].getAttributeValue("AXVisibleChildren"),
null,
"Submenu 2 has no visible chldren when hidden"
menuChildren[11].getAttributeValue("AXChildren").length,
0,
"Submenu 2 has no chldren when hidden"
);
// focus the first submenu
const contextMenu = document.getElementById(
"context-openlinkinusercontext-menu"
);
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_ArrowRight");
await waitForMacEvent("AXMenuOpened");
await BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
// verify submenu-menuitem's attributes
is(