From 709573652ec5bec0af0a46b2bde8de7e8a8c4f78 Mon Sep 17 00:00:00 2001 From: James Teh Date: Mon, 11 Apr 2022 23:20:13 +0000 Subject: [PATCH] Bug 1760939 part 1: Move EmbeddedChildCount to Accessible. r=eeejay Differential Revision: https://phabricator.services.mozilla.com/D142027 --- accessible/atk/AccessibleWrap.cpp | 25 ++++--------------------- accessible/basetypes/Accessible.h | 5 +++++ accessible/generic/LocalAccessible.h | 5 +---- accessible/ipc/RemoteAccessibleBase.cpp | 2 +- accessible/ipc/RemoteAccessibleBase.h | 2 +- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index 94acc602f60f..3b90e7265d89 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -692,28 +692,11 @@ AtkObject* getParentCB(AtkObject* aAtkObj) { } gint getChildCountCB(AtkObject* aAtkObj) { - if (AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj)) { - if (nsAccUtils::MustPrune(accWrap)) { - return 0; - } - - uint32_t count = accWrap->EmbeddedChildCount(); - if (count) { - return static_cast(count); - } - - OuterDocAccessible* outerDoc = accWrap->AsOuterDoc(); - if (outerDoc && outerDoc->RemoteChildDoc()) { - return 1; - } + Accessible* acc = GetInternalObj(aAtkObj); + if (!acc || nsAccUtils::MustPrune(acc)) { + return 0; } - - RemoteAccessible* proxy = GetProxy(aAtkObj); - if (proxy && !nsAccUtils::MustPrune(proxy)) { - return proxy->EmbeddedChildCount(); - } - - return 0; + return static_cast(acc->EmbeddedChildCount()); } AtkObject* refChildCB(AtkObject* aAtkObj, gint aChildIndex) { diff --git a/accessible/basetypes/Accessible.h b/accessible/basetypes/Accessible.h index b1c5eaa2e712..9ff91755bfdc 100644 --- a/accessible/basetypes/Accessible.h +++ b/accessible/basetypes/Accessible.h @@ -155,6 +155,11 @@ class Accessible { */ virtual GroupPos GroupPosition(); + /** + * Return embedded accessible children count. + */ + virtual uint32_t EmbeddedChildCount() = 0; + /** * Return embedded accessible child at the given index. */ diff --git a/accessible/generic/LocalAccessible.h b/accessible/generic/LocalAccessible.h index fc875bd52394..5d5ca3806ddb 100644 --- a/accessible/generic/LocalAccessible.h +++ b/accessible/generic/LocalAccessible.h @@ -361,10 +361,7 @@ class LocalAccessible : public nsISupports, public Accessible { return childCount != 0 ? LocalChildAt(childCount - 1) : nullptr; } - /** - * Return embedded accessible children count. - */ - uint32_t EmbeddedChildCount(); + virtual uint32_t EmbeddedChildCount() override; /** * Return embedded accessible child at the given index. diff --git a/accessible/ipc/RemoteAccessibleBase.cpp b/accessible/ipc/RemoteAccessibleBase.cpp index d7c85c135e5f..dabfb8e531e7 100644 --- a/accessible/ipc/RemoteAccessibleBase.cpp +++ b/accessible/ipc/RemoteAccessibleBase.cpp @@ -94,7 +94,7 @@ void RemoteAccessibleBase::ClearChildDoc( } template -uint32_t RemoteAccessibleBase::EmbeddedChildCount() const { +uint32_t RemoteAccessibleBase::EmbeddedChildCount() { size_t count = 0, kids = mChildren.Length(); for (size_t i = 0; i < kids; i++) { if (mChildren[i]->IsEmbeddedObject()) { diff --git a/accessible/ipc/RemoteAccessibleBase.h b/accessible/ipc/RemoteAccessibleBase.h index 412ad2859757..53467a0e849f 100644 --- a/accessible/ipc/RemoteAccessibleBase.h +++ b/accessible/ipc/RemoteAccessibleBase.h @@ -102,7 +102,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase { } return parent->mChildren.IndexOf(static_cast(this)); } - uint32_t EmbeddedChildCount() const; + virtual uint32_t EmbeddedChildCount() override; virtual int32_t IndexOfEmbeddedChild(Accessible* aChild) override; virtual Accessible* EmbeddedChildAt(uint32_t aChildIdx) override;