mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1661504: Introduce MOXLandmarkAccessible class and AXLandmarkSearchKey r=eeejay"
Differential Revision: https://phabricator.services.mozilla.com/D88445
This commit is contained in:
parent
9b11b259f9
commit
c5126eab79
@ -15,6 +15,7 @@
|
||||
#include "TextRange.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
#import "MOXLandmarkAccessibles.h"
|
||||
#import "MOXMathAccessibles.h"
|
||||
#import "MOXTextMarkerDelegate.h"
|
||||
#import "MOXWebAreaAccessible.h"
|
||||
@ -268,6 +269,9 @@ Class a11y::GetTypeFromRole(roles::Role aRole) {
|
||||
case roles::STATICTEXT:
|
||||
return [mozTextLeafAccessible class];
|
||||
|
||||
case roles::LANDMARK:
|
||||
return [MOXLandmarkAccessible class];
|
||||
|
||||
case roles::LINK:
|
||||
return [mozLinkAccessible class];
|
||||
|
||||
|
15
accessible/mac/MOXLandmarkAccessibles.h
Normal file
15
accessible/mac/MOXLandmarkAccessibles.h
Normal file
@ -0,0 +1,15 @@
|
||||
/* -*- 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 MOXLandmarkAccessible : mozAccessible
|
||||
// overrides
|
||||
- (NSString*)moxTitle;
|
||||
|
||||
@end
|
15
accessible/mac/MOXLandmarkAccessibles.mm
Normal file
15
accessible/mac/MOXLandmarkAccessibles.mm
Normal 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 "MOXLandmarkAccessibles.h"
|
||||
|
||||
@implementation MOXLandmarkAccessible
|
||||
|
||||
- (NSString*)moxTitle {
|
||||
return @"";
|
||||
}
|
||||
|
||||
@end
|
@ -193,6 +193,13 @@ using namespace mozilla::a11y;
|
||||
: PivotRoleRule(roles::ARTICLE);
|
||||
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
|
||||
}
|
||||
|
||||
if ([key isEqualToString:@"AXLandmarkSearchKey"]) {
|
||||
PivotRoleRule rule = mImmediateDescendantsOnly
|
||||
? PivotRoleRule(roles::LANDMARK, mStartElem)
|
||||
: PivotRoleRule(roles::LANDMARK);
|
||||
[matches addObjectsFromArray:[self getMatchesForRule:rule]];
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
|
@ -20,6 +20,7 @@ UNIFIED_SOURCES += [
|
||||
'HyperTextAccessibleWrap.mm',
|
||||
'MacUtils.mm',
|
||||
'MOXAccessibleBase.mm',
|
||||
'MOXLandmarkAccessibles.mm',
|
||||
'MOXMathAccessibles.mm',
|
||||
'MOXTextMarkerDelegate.mm',
|
||||
'MOXWebAreaAccessible.mm',
|
||||
|
@ -6,6 +6,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#import "mozSelectableElements.h"
|
||||
#import "nsCocoaUtils.h"
|
||||
#import "MacUtils.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
@implementation mozSelectableAccessible
|
||||
|
||||
|
@ -117,3 +117,155 @@ addAccessibleTask(
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test rotor with landmarks
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<header id="header">
|
||||
<h1>This is a heading within a header</h1>
|
||||
</header>
|
||||
|
||||
<nav id="nav">
|
||||
<a href="example.com">I am a link in a nav</a>
|
||||
</nav>
|
||||
|
||||
<main id="main">
|
||||
I am some text in a main element
|
||||
</main>
|
||||
|
||||
<footer id="footer">
|
||||
<h2>Heading in footer</h2>
|
||||
</footer>
|
||||
`,
|
||||
async (browser, accDoc) => {
|
||||
const searchPred = {
|
||||
AXSearchKey: "AXLandmarkSearchKey",
|
||||
AXImmediateDescendants: 1,
|
||||
AXResultsLimit: -1,
|
||||
AXDirection: "AXDirectionNext",
|
||||
};
|
||||
|
||||
const webArea = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
is(
|
||||
webArea.getAttributeValue("AXRole"),
|
||||
"AXWebArea",
|
||||
"Got web area accessible"
|
||||
);
|
||||
|
||||
const landmarkCount = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementCountForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
is(4, landmarkCount, "Found four landmarks");
|
||||
|
||||
const landmarks = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementsForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
const header = getNativeInterface(accDoc, "header");
|
||||
const nav = getNativeInterface(accDoc, "nav");
|
||||
const main = getNativeInterface(accDoc, "main");
|
||||
const footer = getNativeInterface(accDoc, "footer");
|
||||
|
||||
is(
|
||||
header.getAttributeValue("AXSubrole"),
|
||||
landmarks[0].getAttributeValue("AXSubrole"),
|
||||
"Found correct first landmark"
|
||||
);
|
||||
is(
|
||||
nav.getAttributeValue("AXSubrole"),
|
||||
landmarks[1].getAttributeValue("AXSubrole"),
|
||||
"Found correct second landmark"
|
||||
);
|
||||
is(
|
||||
main.getAttributeValue("AXSubrole"),
|
||||
landmarks[2].getAttributeValue("AXSubrole"),
|
||||
"Found correct third landmark"
|
||||
);
|
||||
is(
|
||||
footer.getAttributeValue("AXSubrole"),
|
||||
landmarks[3].getAttributeValue("AXSubrole"),
|
||||
"Found correct fourth landmark"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test rotor with aria landmarks
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<div id="banner" role="banner">
|
||||
<h1>This is a heading within a banner</h1>
|
||||
</div>
|
||||
|
||||
<div id="nav" role="navigation">
|
||||
<a href="example.com">I am a link in a nav</a>
|
||||
</div>
|
||||
|
||||
<div id="main" role="main">
|
||||
I am some text in a main element
|
||||
</div>
|
||||
|
||||
<div id="contentinfo" role="contentinfo">
|
||||
<h2>Heading in contentinfo</h2>
|
||||
</div>
|
||||
`,
|
||||
async (browser, accDoc) => {
|
||||
const searchPred = {
|
||||
AXSearchKey: "AXLandmarkSearchKey",
|
||||
AXImmediateDescendants: 1,
|
||||
AXResultsLimit: -1,
|
||||
AXDirection: "AXDirectionNext",
|
||||
};
|
||||
|
||||
const webArea = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
is(
|
||||
webArea.getAttributeValue("AXRole"),
|
||||
"AXWebArea",
|
||||
"Got web area accessible"
|
||||
);
|
||||
|
||||
const landmarkCount = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementCountForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
is(4, landmarkCount, "Found four landmarks");
|
||||
|
||||
const landmarks = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementsForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
const banner = getNativeInterface(accDoc, "banner");
|
||||
const nav = getNativeInterface(accDoc, "nav");
|
||||
const main = getNativeInterface(accDoc, "main");
|
||||
const contentinfo = getNativeInterface(accDoc, "contentinfo");
|
||||
|
||||
is(
|
||||
banner.getAttributeValue("AXSubrole"),
|
||||
landmarks[0].getAttributeValue("AXSubrole"),
|
||||
"Found correct first landmark"
|
||||
);
|
||||
is(
|
||||
nav.getAttributeValue("AXSubrole"),
|
||||
landmarks[1].getAttributeValue("AXSubrole"),
|
||||
"Found correct second landmark"
|
||||
);
|
||||
is(
|
||||
main.getAttributeValue("AXSubrole"),
|
||||
landmarks[2].getAttributeValue("AXSubrole"),
|
||||
"Found correct third landmark"
|
||||
);
|
||||
is(
|
||||
contentinfo.getAttributeValue("AXSubrole"),
|
||||
landmarks[3].getAttributeValue("AXSubrole"),
|
||||
"Found correct fourth landmark"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user