зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551684 part 2. Stop using [array] in nsIAccessiblePivot. r=surkov
Differential Revision: https://phabricator.services.mozilla.com/D31180 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
51e40973fc
Коммит
f7d654e3b2
|
@ -10,8 +10,11 @@
|
||||||
#include "nsAccUtils.h"
|
#include "nsAccUtils.h"
|
||||||
#include "States.h"
|
#include "States.h"
|
||||||
#include "xpcAccessibleDocument.h"
|
#include "xpcAccessibleDocument.h"
|
||||||
|
#include "nsTArray.h"
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
using mozilla::Maybe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that stores a given traversal rule during the pivot movement.
|
* An object that stores a given traversal rule during the pivot movement.
|
||||||
|
@ -19,20 +22,14 @@ using namespace mozilla::a11y;
|
||||||
class RuleCache {
|
class RuleCache {
|
||||||
public:
|
public:
|
||||||
explicit RuleCache(nsIAccessibleTraversalRule* aRule)
|
explicit RuleCache(nsIAccessibleTraversalRule* aRule)
|
||||||
: mRule(aRule),
|
: mRule(aRule), mPreFilter{0} {}
|
||||||
mAcceptRoles(nullptr),
|
~RuleCache() {}
|
||||||
mAcceptRolesLength{0},
|
|
||||||
mPreFilter{0} {}
|
|
||||||
~RuleCache() {
|
|
||||||
if (mAcceptRoles) free(mAcceptRoles);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult ApplyFilter(Accessible* aAccessible, uint16_t* aResult);
|
nsresult ApplyFilter(Accessible* aAccessible, uint16_t* aResult);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIAccessibleTraversalRule> mRule;
|
nsCOMPtr<nsIAccessibleTraversalRule> mRule;
|
||||||
uint32_t* mAcceptRoles;
|
Maybe<nsTArray<uint32_t>> mAcceptRoles;
|
||||||
uint32_t mAcceptRolesLength;
|
|
||||||
uint32_t mPreFilter;
|
uint32_t mPreFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -822,7 +819,7 @@ bool nsAccessiblePivot::NotifyOfPivotChange(Accessible* aOldPosition,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessible> xpcOldPos = ToXPC(aOldPosition); // death grip
|
nsCOMPtr<nsIAccessible> xpcOldPos = ToXPC(aOldPosition); // death grip
|
||||||
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> >::ForwardIterator iter(
|
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver>>::ForwardIterator iter(
|
||||||
mObservers);
|
mObservers);
|
||||||
while (iter.HasMore()) {
|
while (iter.HasMore()) {
|
||||||
nsIAccessiblePivotObserver* obs = iter.GetNext();
|
nsIAccessiblePivotObserver* obs = iter.GetNext();
|
||||||
|
@ -838,7 +835,8 @@ nsresult RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult) {
|
||||||
*aResult = nsIAccessibleTraversalRule::FILTER_IGNORE;
|
*aResult = nsIAccessibleTraversalRule::FILTER_IGNORE;
|
||||||
|
|
||||||
if (!mAcceptRoles) {
|
if (!mAcceptRoles) {
|
||||||
nsresult rv = mRule->GetMatchRoles(&mAcceptRoles, &mAcceptRolesLength);
|
mAcceptRoles.emplace();
|
||||||
|
nsresult rv = mRule->GetMatchRoles(*mAcceptRoles);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = mRule->GetPreFilter(&mPreFilter);
|
rv = mRule->GetPreFilter(&mPreFilter);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
@ -874,11 +872,11 @@ nsresult RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAcceptRolesLength > 0) {
|
if (mAcceptRoles->Length() > 0) {
|
||||||
uint32_t accessibleRole = aAccessible->Role();
|
uint32_t accessibleRole = aAccessible->Role();
|
||||||
bool matchesRole = false;
|
bool matchesRole = false;
|
||||||
for (uint32_t idx = 0; idx < mAcceptRolesLength; idx++) {
|
for (uint32_t idx = 0; idx < mAcceptRoles->Length(); idx++) {
|
||||||
matchesRole = mAcceptRoles[idx] == accessibleRole;
|
matchesRole = mAcceptRoles->ElementAt(idx) == accessibleRole;
|
||||||
if (matchesRole) break;
|
if (matchesRole) break;
|
||||||
}
|
}
|
||||||
if (!matchesRole) return NS_OK;
|
if (!matchesRole) return NS_OK;
|
||||||
|
|
|
@ -245,11 +245,9 @@ interface nsIAccessibleTraversalRule : nsISupports
|
||||||
* at the start of a traversal, so changing the method's return result after
|
* at the start of a traversal, so changing the method's return result after
|
||||||
* that would have no affect.
|
* that would have no affect.
|
||||||
*
|
*
|
||||||
* @param aRoles [out] an array of the roles to match.
|
* @return an array of the roles to match.
|
||||||
* @param aCount [out] the length of the array.
|
|
||||||
*/
|
*/
|
||||||
void getMatchRoles([array, size_is(aCount)]out unsigned long aRoles,
|
Array<unsigned long> getMatchRoles();
|
||||||
[retval]out unsigned long aCount);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a given accessible is to be accepted in our traversal rule
|
* Determines if a given accessible is to be accepted in our traversal rule
|
||||||
|
|
|
@ -36,9 +36,8 @@ function BaseTraversalRule(aRoles, aMatchFunc, aPreFilter, aContainerRule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTraversalRule.prototype = {
|
BaseTraversalRule.prototype = {
|
||||||
getMatchRoles: function BaseTraversalRule_getmatchRoles(aRoles) {
|
getMatchRoles: function BaseTraversalRule_getmatchRoles() {
|
||||||
aRoles.value = this._matchRoles;
|
return this._matchRoles;
|
||||||
return aRoles.value.length;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
match: function BaseTraversalRule_match(aAccessible) {
|
match: function BaseTraversalRule_match(aAccessible) {
|
||||||
|
|
|
@ -23,9 +23,8 @@ const NS_ERROR_INVALID_ARG = 0x80070057;
|
||||||
*/
|
*/
|
||||||
var HeadersTraversalRule =
|
var HeadersTraversalRule =
|
||||||
{
|
{
|
||||||
getMatchRoles(aRules) {
|
getMatchRoles() {
|
||||||
aRules.value = [ROLE_HEADING];
|
return [ROLE_HEADING];
|
||||||
return aRules.value.length;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
preFilter: PREFILTER_INVISIBLE,
|
preFilter: PREFILTER_INVISIBLE,
|
||||||
|
@ -42,9 +41,8 @@ var HeadersTraversalRule =
|
||||||
*/
|
*/
|
||||||
var ObjectTraversalRule =
|
var ObjectTraversalRule =
|
||||||
{
|
{
|
||||||
getMatchRoles(aRules) {
|
getMatchRoles() {
|
||||||
aRules.value = [];
|
return [];
|
||||||
return 0;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
preFilter: PREFILTER_INVISIBLE | PREFILTER_TRANSPARENT,
|
preFilter: PREFILTER_INVISIBLE | PREFILTER_TRANSPARENT,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче