Bug 1681909 - P1: Add IPC stubs for ApplyPostSearchFilter. r=morgan,ipc-reviewers,mccr8

Applying a bulk filter on accessibles in content process allows us to avoid a potentially large (and variable) number of IPC sync calls to retrieve the accessible names. I chose to implement this as a "post filter" and not to actually do the entire search in content because it would cause a lot of duplication of code for non-IPC searching, and we wouldn't have the flexibility to combine a text search with any arbitrary search key as the API requires.

I also generalized the RangeTypes.h header to PlatformExtTypes so it can be used to define filter types as well.

Differential Revision: https://phabricator.services.mozilla.com/D100730
This commit is contained in:
Eitan Isaacson 2021-01-05 20:35:22 +00:00
Родитель d4475808af
Коммит ca8fda7434
8 изменённых файлов: 38 добавлений и 6 удалений

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

@ -73,7 +73,7 @@ typedef uint32_t IHandlerControlHolder;
#if defined(MOZ_WIDGET_COCOA)
# if defined(ACCESSIBILITY)
# include "mozilla/a11y/RangeTypes.h"
# include "mozilla/a11y/PlatformExtTypes.h"
namespace IPC {
template <>
@ -82,6 +82,13 @@ 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

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

@ -211,6 +211,14 @@ 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) {
return IPC_OK();
}
HyperTextAccessibleWrap*
DocAccessiblePlatformExtChild::IdToHyperTextAccessibleWrap(
const uint64_t& aID) const {

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

@ -67,6 +67,11 @@ 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,6 +9,7 @@ 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";
using nsIntRect from "nsRect.h";
namespace mozilla {
@ -49,6 +50,12 @@ child:
returns(uint64_t aLeaf);
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

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

@ -7,7 +7,7 @@
#define mozilla_a11y_HyperTextAccessibleWrap_h__
#include "HyperTextAccessible.h"
#include "RangeTypes.h"
#include "PlatformExtTypes.h"
namespace mozilla {
namespace a11y {

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

@ -3,8 +3,8 @@
* 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/. */
#ifndef mozilla_a11y_RangeTypes_h__
#define mozilla_a11y_RangeTypes_h__
#ifndef mozilla_a11y_PlatformExtTypes_h__
#define mozilla_a11y_PlatformExtTypes_h__
namespace mozilla {
namespace a11y {
@ -19,7 +19,9 @@ enum class EWhichRange {
eStyle
};
enum class EWhichPostFilter { eContainsText };
} // namespace a11y
} // namespace mozilla
#endif
#endif // mozilla_a11y_PlatformExtTypes_h__

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

@ -11,7 +11,7 @@ EXPORTS += [
EXPORTS.mozilla.a11y += [
"AccessibleWrap.h",
"HyperTextAccessibleWrap.h",
"RangeTypes.h",
"PlatformExtTypes.h",
]
UNIFIED_SOURCES += [

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

@ -641,6 +641,9 @@ platform = mac
[PDocAccessiblePlatformExt::LeafAtOffset]
description = Retrieve text leaf at given offset. Platform API is synchronous, so this needs to be too.
platform = mac
[PDocAccessiblePlatformExt::ApplyPostSearchFilter]
description = Filter a preliminary list of accessibles that match a predicate. Platform API is synchronous, so this needs to be too.
platform = mac
# Plugins
[PPluginWidget::Create]