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:
Boris Zbarsky 2019-05-15 11:54:07 +00:00
Родитель 51e40973fc
Коммит f7d654e3b2
4 изменённых файлов: 20 добавлений и 27 удалений

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

@ -10,8 +10,11 @@
#include "nsAccUtils.h"
#include "States.h"
#include "xpcAccessibleDocument.h"
#include "nsTArray.h"
#include "mozilla/Maybe.h"
using namespace mozilla::a11y;
using mozilla::Maybe;
/**
* An object that stores a given traversal rule during the pivot movement.
@ -19,20 +22,14 @@ using namespace mozilla::a11y;
class RuleCache {
public:
explicit RuleCache(nsIAccessibleTraversalRule* aRule)
: mRule(aRule),
mAcceptRoles(nullptr),
mAcceptRolesLength{0},
mPreFilter{0} {}
~RuleCache() {
if (mAcceptRoles) free(mAcceptRoles);
}
: mRule(aRule), mPreFilter{0} {}
~RuleCache() {}
nsresult ApplyFilter(Accessible* aAccessible, uint16_t* aResult);
private:
nsCOMPtr<nsIAccessibleTraversalRule> mRule;
uint32_t* mAcceptRoles;
uint32_t mAcceptRolesLength;
Maybe<nsTArray<uint32_t>> mAcceptRoles;
uint32_t mPreFilter;
};
@ -822,7 +819,7 @@ bool nsAccessiblePivot::NotifyOfPivotChange(Accessible* aOldPosition,
return false;
nsCOMPtr<nsIAccessible> xpcOldPos = ToXPC(aOldPosition); // death grip
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> >::ForwardIterator iter(
nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver>>::ForwardIterator iter(
mObservers);
while (iter.HasMore()) {
nsIAccessiblePivotObserver* obs = iter.GetNext();
@ -838,7 +835,8 @@ nsresult RuleCache::ApplyFilter(Accessible* aAccessible, uint16_t* aResult) {
*aResult = nsIAccessibleTraversalRule::FILTER_IGNORE;
if (!mAcceptRoles) {
nsresult rv = mRule->GetMatchRoles(&mAcceptRoles, &mAcceptRolesLength);
mAcceptRoles.emplace();
nsresult rv = mRule->GetMatchRoles(*mAcceptRoles);
NS_ENSURE_SUCCESS(rv, rv);
rv = mRule->GetPreFilter(&mPreFilter);
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();
bool matchesRole = false;
for (uint32_t idx = 0; idx < mAcceptRolesLength; idx++) {
matchesRole = mAcceptRoles[idx] == accessibleRole;
for (uint32_t idx = 0; idx < mAcceptRoles->Length(); idx++) {
matchesRole = mAcceptRoles->ElementAt(idx) == accessibleRole;
if (matchesRole) break;
}
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
* that would have no affect.
*
* @param aRoles [out] an array of the roles to match.
* @param aCount [out] the length of the array.
* @return an array of the roles to match.
*/
void getMatchRoles([array, size_is(aCount)]out unsigned long aRoles,
[retval]out unsigned long aCount);
Array<unsigned long> getMatchRoles();
/**
* 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 = {
getMatchRoles: function BaseTraversalRule_getmatchRoles(aRoles) {
aRoles.value = this._matchRoles;
return aRoles.value.length;
getMatchRoles: function BaseTraversalRule_getmatchRoles() {
return this._matchRoles;
},
match: function BaseTraversalRule_match(aAccessible) {

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

@ -23,9 +23,8 @@ const NS_ERROR_INVALID_ARG = 0x80070057;
*/
var HeadersTraversalRule =
{
getMatchRoles(aRules) {
aRules.value = [ROLE_HEADING];
return aRules.value.length;
getMatchRoles() {
return [ROLE_HEADING];
},
preFilter: PREFILTER_INVISIBLE,
@ -42,9 +41,8 @@ var HeadersTraversalRule =
*/
var ObjectTraversalRule =
{
getMatchRoles(aRules) {
aRules.value = [];
return 0;
getMatchRoles() {
return [];
},
preFilter: PREFILTER_INVISIBLE | PREFILTER_TRANSPARENT,