mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-18 04:44:17 +00:00
Bug 1821969 part 2: Remove Mac ApplyPostFilter. r=morgan
Now that we always have the parent process core cache enabled, this is always handled by the Pivot. Differential Revision: https://phabricator.services.mozilla.com/D178426
This commit is contained in:
parent
6cf954e1ce
commit
46b80585f4
@ -175,13 +175,6 @@ struct ParamTraits<mozilla::a11y::EWhichRange>
|
||||
mozilla::a11y::EWhichRange, mozilla::a11y::EWhichRange::eLeftWord,
|
||||
mozilla::a11y::EWhichRange::eStyle> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::a11y::EWhichPostFilter>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::a11y::EWhichPostFilter,
|
||||
mozilla::a11y::EWhichPostFilter::eContainsText,
|
||||
mozilla::a11y::EWhichPostFilter::eContainsText> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
# else
|
||||
|
@ -244,31 +244,6 @@ mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvSelectRange(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
DocAccessiblePlatformExtChild::RecvApplyPostSearchFilter(
|
||||
const nsTArray<uint64_t>& aAccessibles, const int32_t& aLimit,
|
||||
const EWhichPostFilter& aSearchKey, const nsString& aSearchText,
|
||||
nsTArray<uint64_t>* aMatches) {
|
||||
if (aSearchKey != EWhichPostFilter::eContainsText) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
DocAccessibleChild* ipcDoc = static_cast<DocAccessibleChild*>(Manager());
|
||||
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
||||
AccessibleWrap* acc = static_cast<AccessibleWrap*>(
|
||||
ipcDoc->IdToAccessible(aAccessibles.ElementAt(i)));
|
||||
if (!acc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (acc->ApplyPostFilter(aSearchKey, aSearchText)) {
|
||||
aMatches->AppendElement(UNIQUE_ID(acc));
|
||||
}
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
HyperTextAccessibleWrap*
|
||||
DocAccessiblePlatformExtChild::IdToHyperTextAccessibleWrap(
|
||||
const uint64_t& aID) const {
|
||||
|
@ -72,11 +72,6 @@ class DocAccessiblePlatformExtChild : public PDocAccessiblePlatformExtChild {
|
||||
const uint64_t& aID, const int32_t& aStartOffset,
|
||||
const uint64_t& aEndContainer, const int32_t& aEndOffset);
|
||||
|
||||
mozilla::ipc::IPCResult RecvApplyPostSearchFilter(
|
||||
const nsTArray<uint64_t>& aAccessibles, const int32_t& aLimit,
|
||||
const EWhichPostFilter& aSearchKey, const nsString& aSearchText,
|
||||
nsTArray<uint64_t>* aMatches);
|
||||
|
||||
private:
|
||||
HyperTextAccessibleWrap* IdToHyperTextAccessibleWrap(
|
||||
const uint64_t& aID) const;
|
||||
|
@ -9,7 +9,6 @@ include protocol PDocAccessible;
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using mozilla::a11y::EWhichRange from "mozilla/a11y/IPCTypes.h";
|
||||
using mozilla::a11y::EWhichPostFilter from "mozilla/a11y/IPCTypes.h";
|
||||
[RefCounted] using mozilla::a11y::AccAttributes from "mozilla/a11y/IPCTypes.h";
|
||||
using mozilla::LayoutDeviceIntRect from "Units.h";
|
||||
|
||||
@ -62,11 +61,6 @@ child:
|
||||
|
||||
async SelectRange(uint64_t aID, int32_t aStartOffset, uint64_t aEndContainer, int32_t aEndOffset);
|
||||
|
||||
// A filter that can be applied to search predicate results.
|
||||
[Nested=inside_sync] sync ApplyPostSearchFilter(uint64_t[] aAccessibles, int32_t aLimit,
|
||||
EWhichPostFilter aSearchKey, nsString aSearchText)
|
||||
returns(uint64_t[] aMatches);
|
||||
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -54,9 +54,6 @@ class AccessibleWrap : public LocalAccessible {
|
||||
|
||||
virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
|
||||
|
||||
bool ApplyPostFilter(const EWhichPostFilter& aSearchKey,
|
||||
const nsString& aSearchText);
|
||||
|
||||
protected:
|
||||
friend class xpcAccessibleMacInterface;
|
||||
|
||||
|
@ -286,16 +286,6 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
|
||||
NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
bool AccessibleWrap::ApplyPostFilter(const EWhichPostFilter& aSearchKey,
|
||||
const nsString& aSearchText) {
|
||||
// We currently only support the eContainsText post filter.
|
||||
MOZ_ASSERT(aSearchKey == EWhichPostFilter::eContainsText,
|
||||
"Only search text supported");
|
||||
nsAutoString name;
|
||||
Name(name);
|
||||
return CaseInsensitiveFindInReadable(aSearchText, name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// AccessibleWrap protected
|
||||
|
||||
|
@ -19,13 +19,9 @@ using namespace mozilla::a11y;
|
||||
@interface MOXSearchInfo ()
|
||||
- (NSArray*)getMatchesForRule:(PivotRule&)rule;
|
||||
|
||||
- (NSArray<mozAccessible*>*)applyPostFilter:(NSArray<mozAccessible*>*)matches;
|
||||
|
||||
- (Accessible*)rootGeckoAccessible;
|
||||
|
||||
- (Accessible*)startGeckoAccessible;
|
||||
|
||||
- (BOOL)shouldApplyPostFilter;
|
||||
@end
|
||||
|
||||
@implementation MOXSearchInfo
|
||||
@ -78,9 +74,7 @@ using namespace mozilla::a11y;
|
||||
}
|
||||
|
||||
- (NSArray*)getMatchesForRule:(PivotRule&)rule {
|
||||
// If we will apply a post-filter, don't limit search so we
|
||||
// don't come up short on the final result count.
|
||||
int resultLimit = [self shouldApplyPostFilter] ? -1 : mResultLimit;
|
||||
int resultLimit = mResultLimit;
|
||||
|
||||
NSMutableArray<mozAccessible*>* matches =
|
||||
[[[NSMutableArray alloc] init] autorelease];
|
||||
@ -120,100 +114,7 @@ using namespace mozilla::a11y;
|
||||
match = mSearchForward ? p.Next(match, rule) : p.Prev(match, rule);
|
||||
}
|
||||
|
||||
return [self applyPostFilter:matches];
|
||||
}
|
||||
|
||||
- (BOOL)shouldApplyPostFilter {
|
||||
// We currently only support AXSearchText as a post-search filter.
|
||||
// In some cases, VO passes a non-null, empty string for AXSearchText.
|
||||
// In that case, we should act as if no AXSearchText was given.
|
||||
// When caching is enabled we filter the tree in the pivot rule
|
||||
// and don't need to apply the post search filter.
|
||||
return !mozilla::a11y::IsCacheActive() && !!mSearchText &&
|
||||
[mSearchText length] > 0;
|
||||
}
|
||||
|
||||
- (NSArray<mozAccessible*>*)applyPostFilter:(NSArray<mozAccessible*>*)matches {
|
||||
if (![self shouldApplyPostFilter]) {
|
||||
return matches;
|
||||
}
|
||||
|
||||
NSMutableArray<mozAccessible*>* postMatches =
|
||||
[[[NSMutableArray alloc] init] autorelease];
|
||||
|
||||
nsString searchText;
|
||||
nsCocoaUtils::GetStringForNSString(mSearchText, searchText);
|
||||
|
||||
__block DocAccessibleParent* ipcDoc = nullptr;
|
||||
__block nsTArray<uint64_t> accIds;
|
||||
|
||||
[matches enumerateObjectsUsingBlock:^(mozAccessible* match, NSUInteger idx,
|
||||
BOOL* stop) {
|
||||
Accessible* geckoAcc = [match geckoAccessible];
|
||||
if (!geckoAcc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (geckoAcc->IsLocal()) {
|
||||
AccessibleWrap* acc = static_cast<AccessibleWrap*>(geckoAcc->AsLocal());
|
||||
if (acc->ApplyPostFilter(EWhichPostFilter::eContainsText, searchText)) {
|
||||
if (mozAccessible* nativePostMatch =
|
||||
GetNativeFromGeckoAccessible(acc)) {
|
||||
[postMatches addObject:nativePostMatch];
|
||||
if (mResultLimit > 0 &&
|
||||
[postMatches count] >= static_cast<NSUInteger>(mResultLimit)) {
|
||||
// If we reached the result limit, alter the `stop` pointer to YES
|
||||
// to stop iteration.
|
||||
*stop = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RemoteAccessible* proxy = geckoAcc->AsRemote();
|
||||
if (ipcDoc &&
|
||||
((ipcDoc != proxy->Document()) || (idx + 1 == [matches count]))) {
|
||||
// If the ipcDoc doesn't match the current proxy's doc, we crossed into a
|
||||
// new document. ..or this is the last match. Apply the filter on the list
|
||||
// of the current ipcDoc.
|
||||
nsTArray<uint64_t> matchIds;
|
||||
MOZ_ASSERT(
|
||||
!mozilla::a11y::IsCacheActive(),
|
||||
"Should call SendApplyPostSearchFilter when cache is enabled!");
|
||||
mozilla::Unused
|
||||
<< ipcDoc->GetPlatformExtension()->SendApplyPostSearchFilter(
|
||||
accIds, mResultLimit, EWhichPostFilter::eContainsText,
|
||||
searchText, &matchIds);
|
||||
for (size_t i = 0; i < matchIds.Length(); i++) {
|
||||
if (RemoteAccessible* postMatch =
|
||||
ipcDoc->GetAccessible(matchIds.ElementAt(i))) {
|
||||
if (mozAccessible* nativePostMatch =
|
||||
GetNativeFromGeckoAccessible(postMatch)) {
|
||||
[postMatches addObject:nativePostMatch];
|
||||
if (mResultLimit > 0 &&
|
||||
[postMatches count] >= static_cast<NSUInteger>(mResultLimit)) {
|
||||
// If we reached the result limit, alter the `stop` pointer to YES
|
||||
// to stop iteration.
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcDoc = nullptr;
|
||||
accIds.Clear();
|
||||
}
|
||||
|
||||
if (!ipcDoc) {
|
||||
ipcDoc = proxy->Document();
|
||||
}
|
||||
accIds.AppendElement(proxy->ID());
|
||||
}];
|
||||
|
||||
return postMatches;
|
||||
return matches;
|
||||
}
|
||||
|
||||
- (NSArray*)performSearch {
|
||||
|
@ -19,8 +19,6 @@ enum class EWhichRange {
|
||||
eStyle
|
||||
};
|
||||
|
||||
enum class EWhichPostFilter { eContainsText };
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -61,16 +61,10 @@ uint16_t RotorRule::Match(Accessible* aAcc) {
|
||||
result &= ~nsIAccessibleTraversalRule::FILTER_MATCH;
|
||||
break;
|
||||
default:
|
||||
if (a11y::IsCacheActive()) {
|
||||
// If caching is enabled and we have a non-empty search text,
|
||||
// we can query the cached name to do furhter filtering. If
|
||||
// the cache is disabled this will happen in the post-filter stage
|
||||
// where we send a sync message to content.
|
||||
nsAutoString name;
|
||||
aAcc->Name(name);
|
||||
if (!CaseInsensitiveFindInReadable(mSearchText, name)) {
|
||||
result &= ~nsIAccessibleTraversalRule::FILTER_MATCH;
|
||||
}
|
||||
nsAutoString name;
|
||||
aAcc->Name(name);
|
||||
if (!CaseInsensitiveFindInReadable(mSearchText, name)) {
|
||||
result &= ~nsIAccessibleTraversalRule::FILTER_MATCH;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user