Bug 1826854 - Put IsLinkValid() is base Accessible. r=Jamie

If caching is enabled it will use the cached state, if it isn't it will
do a sync State IPDL call. Also removed the specialized sync IsLinkValid
call because it essentially just did a State() check in the child.

Differential Revision: https://phabricator.services.mozilla.com/D175270
This commit is contained in:
Eitan Isaacson 2023-04-17 17:54:34 +00:00
parent 94d5b44f4c
commit 55dcdc4250
12 changed files with 21 additions and 67 deletions

View File

@ -198,11 +198,12 @@ gboolean isValidCB(AtkHyperlink* aLink) {
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return false;
if (LocalAccessible* hyperlink = maiLink->GetAccHyperlink()) {
return static_cast<gboolean>(hyperlink->IsLinkValid());
Accessible* acc = maiLink->Acc();
if (!acc) {
return false;
}
return static_cast<gboolean>(maiLink->Proxy()->IsLinkValid());
return static_cast<gboolean>(acc->IsLinkValid());
}
gint getAnchorCountCB(AtkHyperlink* aLink) {

View File

@ -363,6 +363,16 @@ void Accessible::GetPositionAndSetSize(int32_t* aPosInSet, int32_t* aSetSize) {
}
}
bool Accessible::IsLinkValid() {
MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!");
// XXX In order to implement this we would need to follow every link
// Perhaps we can get information about invalid links from the cache
// In the mean time authors can use role="link" aria-invalid="true"
// to force it for links they internally know to be invalid
return (0 == (State() & mozilla::a11y::states::INVALID));
}
#ifdef A11Y_LOG
void Accessible::DebugDescription(nsCString& aDesc) const {
aDesc.Truncate();

View File

@ -560,6 +560,11 @@ class Accessible {
virtual bool HasNumericValue() const = 0;
/**
* Return true if the link is valid (e. g. points to a valid URL).
*/
bool IsLinkValid();
// Remote/Local types
virtual bool IsRemote() const = 0;

View File

@ -515,19 +515,6 @@ class LocalAccessible : public nsISupports, public Accessible {
*/
virtual bool IsLink() const override;
/**
* Return true if the link is valid (e. g. points to a valid URL).
*/
inline bool IsLinkValid() {
MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!");
// XXX In order to implement this we would need to follow every link
// Perhaps we can get information about invalid links from the cache
// In the mean time authors can use role="link" aria-invalid="true"
// to force it for links they internally know to be invalid
return (0 == (State() & mozilla::a11y::states::INVALID));
}
/**
* Return the number of anchors within the link.
*/

View File

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

View File

@ -613,18 +613,6 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvEndOffset(const uint64_t& aID,
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvIsLinkValid(const uint64_t& aID,
bool* aRetVal) {
LocalAccessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->IsLinkValid();
} else {
*aRetVal = false;
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) {

View File

@ -220,8 +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 RecvIsLinkValid(const uint64_t& aID,
bool* aRetVal) override;
virtual mozilla::ipc::IPCResult RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) override;

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 IsLinkValid(uint64_t aID) returns(bool aRetVal);
[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;
}
bool RemoteAccessible::IsLinkValid() {
bool retVal = false;
Unused << mDoc->SendIsLinkValid(mID, &retVal);
return retVal;
}
uint32_t RemoteAccessible::AnchorCount(bool* aOk) {
uint32_t retVal = 0;
Unused << mDoc->SendAnchorCount(mID, &retVal, aOk);

View File

@ -781,24 +781,6 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
static_cast<long>(aX), static_cast<long>(aY));
}
bool RemoteAccessible::IsLinkValid() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
// Not yet supported by the cache.
return false;
}
RefPtr<IAccessibleHyperlink> acc = QueryInterface<IAccessibleHyperlink>(this);
if (!acc) {
return false;
}
boolean valid;
if (FAILED(acc->get_valid(&valid))) {
return false;
}
return valid;
}
uint32_t RemoteAccessible::AnchorCount(bool* aOk) {
*aOk = false;
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {

View File

@ -154,7 +154,7 @@ ia2AccessibleHyperlink::get_valid(boolean* aValid) {
*aValid = false;
LocalAccessible* thisObj = LocalAcc();
Accessible* thisObj = Acc();
if (!thisObj) {
return CO_E_OBJNOTCONNECTED;
}

View File

@ -140,15 +140,7 @@ xpcAccessibleHyperLink::GetValid(bool* aValid) {
if (!Intl()) return NS_ERROR_FAILURE;
if (Intl()->IsLocal()) {
*aValid = Intl()->AsLocal()->IsLinkValid();
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
*aValid = Intl()->AsRemote()->IsLinkValid();
#endif
}
*aValid = Intl()->IsLinkValid();
return NS_OK;
}