Bug 1826855 - Remove AnchorCount sync IPC message and implement in Accessible. r=Jamie

AnchorCount only needs the accessible type and child count. We already
cache that with or without CtW.

Differential Revision: https://phabricator.services.mozilla.com/D175273
This commit is contained in:
Eitan Isaacson 2023-04-17 17:54:34 +00:00
parent 55dcdc4250
commit 4a2d824c2a
14 changed files with 19 additions and 78 deletions

View File

@ -210,11 +210,10 @@ gint getAnchorCountCB(AtkHyperlink* aLink) {
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return -1;
if (LocalAccessible* hyperlink = maiLink->GetAccHyperlink()) {
return static_cast<gint>(hyperlink->AnchorCount());
Accessible* acc = maiLink->Acc();
if (!acc) {
return -1;
}
bool valid = false;
uint32_t anchorCount = maiLink->Proxy()->AnchorCount(&valid);
return valid ? static_cast<gint>(anchorCount) : -1;
return static_cast<gint>(acc->AnchorCount());
}

View File

@ -373,6 +373,15 @@ bool Accessible::IsLinkValid() {
return (0 == (State() & mozilla::a11y::states::INVALID));
}
uint32_t Accessible::AnchorCount() {
if (IsImageMap()) {
return ChildCount();
}
MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
return 1;
}
#ifdef A11Y_LOG
void Accessible::DebugDescription(nsCString& aDesc) const {
aDesc.Truncate();

View File

@ -565,6 +565,11 @@ class Accessible {
*/
bool IsLinkValid();
/**
* Return the number of anchors within the link.
*/
uint32_t AnchorCount();
// Remote/Local types
virtual bool IsRemote() const = 0;

View File

@ -2776,11 +2776,6 @@ bool LocalAccessible::IsLink() const {
return mParent && mParent->IsHyperText() && !IsText();
}
uint32_t LocalAccessible::AnchorCount() {
MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
return 1;
}
LocalAccessible* LocalAccessible::AnchorAt(uint32_t aAnchorIndex) {
MOZ_ASSERT(IsLink(), "GetAnchor is called on not hyper link!");
return aAnchorIndex == 0 ? this : nullptr;

View File

@ -515,11 +515,6 @@ class LocalAccessible : public nsISupports, public Accessible {
*/
virtual bool IsLink() const override;
/**
* Return the number of anchors within the link.
*/
virtual uint32_t AnchorCount();
/**
* Returns an anchor accessible at the given index.
*/

View File

@ -40,8 +40,6 @@ role HTMLImageMapAccessible::NativeRole() const { return roles::IMAGE_MAP; }
////////////////////////////////////////////////////////////////////////////////
// HTMLImageMapAccessible: HyperLinkAccessible
uint32_t HTMLImageMapAccessible::AnchorCount() { return ChildCount(); }
LocalAccessible* HTMLImageMapAccessible::AnchorAt(uint32_t aAnchorIndex) {
return LocalChildAt(aAnchorIndex);
}

View File

@ -26,7 +26,6 @@ class HTMLImageMapAccessible final : public ImageAccessible {
virtual a11y::role NativeRole() const override;
// HyperLinkAccessible
virtual uint32_t AnchorCount() override;
virtual LocalAccessible* AnchorAt(uint32_t aAnchorIndex) override;
virtual already_AddRefed<nsIURI> AnchorURIAt(
uint32_t aAnchorIndex) const override;

View File

@ -109,8 +109,6 @@ LayoutDeviceIntPoint ImagePosition(uint32_t aCoordType);
LayoutDeviceIntSize ImageSize();
uint32_t AnchorCount(bool* aOk);
void AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk);
RemoteAccessible* AnchorAt(uint32_t aIndex);

View File

@ -613,21 +613,6 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvEndOffset(const uint64_t& aID,
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) {
LocalAccessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->AnchorCount();
*aOk = true;
} else {
*aRetVal = 0;
*aOk = false;
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvAnchorURIAt(
const uint64_t& aID, const uint32_t& aIndex, nsCString* aURI, bool* aOk) {
LocalAccessible* acc = IdToAccessibleLink(aID);

View File

@ -220,9 +220,6 @@ class DocAccessibleChild : public DocAccessibleChildBase {
virtual mozilla::ipc::IPCResult RecvEndOffset(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) override;
virtual mozilla::ipc::IPCResult RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) override;
virtual mozilla::ipc::IPCResult RecvAnchorURIAt(const uint64_t& aID,
const uint32_t& aIndex,
nsCString* aURI,

View File

@ -240,7 +240,6 @@ child:
[Nested=inside_sync] sync StartOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
[Nested=inside_sync] sync EndOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
[Nested=inside_sync] sync AnchorCount(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
[Nested=inside_sync] sync AnchorURIAt(uint64_t aID, uint32_t aIndex) returns(nsCString aURI, bool aOk);
[Nested=inside_sync] sync AnchorAt(uint64_t aID, uint32_t aIndex) returns(uint64_t aIDOfAnchor, bool aOk);

View File

@ -428,12 +428,6 @@ uint32_t RemoteAccessible::EndOffset() {
return retVal;
}
uint32_t RemoteAccessible::AnchorCount(bool* aOk) {
uint32_t retVal = 0;
Unused << mDoc->SendAnchorCount(mID, &retVal, aOk);
return retVal;
}
void RemoteAccessible::AnchorURIAt(uint32_t aIndex, nsCString& aURI,
bool* aOk) {
Unused << mDoc->SendAnchorURIAt(mID, aIndex, &aURI, aOk);

View File

@ -781,26 +781,6 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
static_cast<long>(aX), static_cast<long>(aY));
}
uint32_t RemoteAccessible::AnchorCount(bool* aOk) {
*aOk = false;
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
// Not yet supported by the cache.
return 0;
}
RefPtr<IGeckoCustom> custom = QueryInterface<IGeckoCustom>(this);
if (!custom) {
return 0;
}
long count;
if (FAILED(custom->get_anchorCount(&count))) {
return 0;
}
*aOk = true;
return count;
}
RemoteAccessible* RemoteAccessible::AnchorAt(uint32_t aIdx) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
// Not yet supported by the cache.

View File

@ -56,19 +56,7 @@ xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount) {
if (!Intl()) return NS_ERROR_FAILURE;
if (Intl()->IsLocal()) {
*aAnchorCount = Intl()->AsLocal()->AnchorCount();
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
bool isCountValid = false;
uint32_t anchorCount = Intl()->AsRemote()->AnchorCount(&isCountValid);
if (!isCountValid) return NS_ERROR_FAILURE;
*aAnchorCount = anchorCount;
#endif
}
*aAnchorCount = Intl()->AnchorCount();
return NS_OK;
}