mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1754360: Move EndOffset to base Accessible. r=eeejay
Similar to StartOffset: 1. There was a Windows non-cached RemoteAccessible implementation, but it was never actually called, so I removed it. 2. The sync IPDL RemoteAccessible implementation previously provided a boolean indicating success. I removed this because the LocalAccessible implementation doesn't have this and it doesn't seem like remote is special in this respect. Differential Revision: https://phabricator.services.mozilla.com/D138243
This commit is contained in:
parent
3934c7d529
commit
f5a04369df
@ -184,13 +184,7 @@ gint getEndIndexCB(AtkHyperlink* aLink) {
|
|||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
||||||
if (!maiLink) return false;
|
if (!maiLink) return false;
|
||||||
|
|
||||||
if (LocalAccessible* hyperlink = maiLink->GetAccHyperlink()) {
|
return static_cast<gint>(maiLink->Acc()->EndOffset());
|
||||||
return static_cast<gint>(hyperlink->EndOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool valid = false;
|
|
||||||
uint32_t endIdx = maiLink->Proxy()->EndOffset(&valid);
|
|
||||||
return valid ? static_cast<gint>(endIdx) : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint getStartIndexCB(AtkHyperlink* aLink) {
|
gint getStartIndexCB(AtkHyperlink* aLink) {
|
||||||
|
@ -82,6 +82,14 @@ uint32_t Accessible::StartOffset() {
|
|||||||
return hyperText ? hyperText->GetChildOffset(this) : 0;
|
return hyperText ? hyperText->GetChildOffset(this) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Accessible::EndOffset() {
|
||||||
|
MOZ_ASSERT(IsLink(), "EndOffset is called on not hyper link!");
|
||||||
|
Accessible* parent = Parent();
|
||||||
|
HyperTextAccessibleBase* hyperText =
|
||||||
|
parent ? parent->AsHyperTextBase() : nullptr;
|
||||||
|
return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
GroupPos Accessible::GroupPosition() {
|
GroupPos Accessible::GroupPosition() {
|
||||||
GroupPos groupPos;
|
GroupPos groupPos;
|
||||||
|
|
||||||
|
@ -187,6 +187,12 @@ class Accessible {
|
|||||||
*/
|
*/
|
||||||
virtual uint32_t StartOffset();
|
virtual uint32_t StartOffset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the end offset of the link within the parent
|
||||||
|
* HyperTextAccessibleBase.
|
||||||
|
*/
|
||||||
|
virtual uint32_t EndOffset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return object attributes for the accessible.
|
* Return object attributes for the accessible.
|
||||||
*/
|
*/
|
||||||
|
@ -2732,13 +2732,6 @@ bool LocalAccessible::IsLink() const {
|
|||||||
return mParent && mParent->IsHyperText() && !IsText();
|
return mParent && mParent->IsHyperText() && !IsText();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t LocalAccessible::EndOffset() {
|
|
||||||
MOZ_ASSERT(IsLink(), "EndOffset is called on not hyper link!");
|
|
||||||
|
|
||||||
HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr;
|
|
||||||
return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t LocalAccessible::AnchorCount() {
|
uint32_t LocalAccessible::AnchorCount() {
|
||||||
MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
|
MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -531,11 +531,6 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||||||
*/
|
*/
|
||||||
virtual bool IsLink() const override;
|
virtual bool IsLink() const override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the end offset of the link within the parent accessible.
|
|
||||||
*/
|
|
||||||
virtual uint32_t EndOffset();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the link is valid (e. g. points to a valid URL).
|
* Return true if the link is valid (e. g. points to a valid URL).
|
||||||
*/
|
*/
|
||||||
|
@ -139,8 +139,6 @@ LayoutDeviceIntPoint ImagePosition(uint32_t aCoordType);
|
|||||||
|
|
||||||
LayoutDeviceIntSize ImageSize();
|
LayoutDeviceIntSize ImageSize();
|
||||||
|
|
||||||
uint32_t EndOffset(bool* aOk);
|
|
||||||
|
|
||||||
bool IsLinkValid();
|
bool IsLinkValid();
|
||||||
|
|
||||||
uint32_t AnchorCount(bool* aOk);
|
uint32_t AnchorCount(bool* aOk);
|
||||||
|
@ -399,9 +399,13 @@ uint32_t RemoteAccessible::StartOffset() {
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RemoteAccessible::EndOffset(bool* aOk) {
|
uint32_t RemoteAccessible::EndOffset() {
|
||||||
|
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||||
|
return RemoteAccessibleBase<RemoteAccessible>::EndOffset();
|
||||||
|
}
|
||||||
|
bool ok;
|
||||||
uint32_t retVal = 0;
|
uint32_t retVal = 0;
|
||||||
Unused << mDoc->SendEndOffset(mID, &retVal, aOk);
|
Unused << mDoc->SendEndOffset(mID, &retVal, &ok);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ class RemoteAccessible : public RemoteAccessibleBase<RemoteAccessible> {
|
|||||||
virtual already_AddRefed<AccAttributes> DefaultTextAttributes() override;
|
virtual already_AddRefed<AccAttributes> DefaultTextAttributes() override;
|
||||||
|
|
||||||
virtual uint32_t StartOffset() override;
|
virtual uint32_t StartOffset() override;
|
||||||
|
virtual uint32_t EndOffset() override;
|
||||||
|
|
||||||
virtual int32_t LinkIndexAtOffset(uint32_t aOffset) override;
|
virtual int32_t LinkIndexAtOffset(uint32_t aOffset) override;
|
||||||
|
|
||||||
|
@ -730,18 +730,6 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
|
|||||||
static_cast<long>(aX), static_cast<long>(aY));
|
static_cast<long>(aX), static_cast<long>(aY));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RemoteAccessible::EndOffset(bool* aOk) {
|
|
||||||
RefPtr<IAccessibleHyperlink> acc = QueryInterface<IAccessibleHyperlink>(this);
|
|
||||||
if (!acc) {
|
|
||||||
*aOk = false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
long endOffset;
|
|
||||||
*aOk = SUCCEEDED(acc->get_endIndex(&endOffset));
|
|
||||||
return static_cast<uint32_t>(endOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RemoteAccessible::IsLinkValid() {
|
bool RemoteAccessible::IsLinkValid() {
|
||||||
RefPtr<IAccessibleHyperlink> acc = QueryInterface<IAccessibleHyperlink>(this);
|
RefPtr<IAccessibleHyperlink> acc = QueryInterface<IAccessibleHyperlink>(this);
|
||||||
if (!acc) {
|
if (!acc) {
|
||||||
|
@ -166,10 +166,7 @@ bool GeckoTextMarker::operator<(const GeckoTextMarker& aPoint) const {
|
|||||||
// We compare its end offset in aPoint.mContainer with aPoint.mOffset.
|
// We compare its end offset in aPoint.mContainer with aPoint.mOffset.
|
||||||
Accessible* child = parents1.ElementAt(pos1 - 1);
|
Accessible* child = parents1.ElementAt(pos1 - 1);
|
||||||
MOZ_ASSERT(child->Parent() == aPoint.mContainer);
|
MOZ_ASSERT(child->Parent() == aPoint.mContainer);
|
||||||
bool unused;
|
uint32_t endOffset = child->EndOffset();
|
||||||
uint32_t endOffset = child->IsRemote()
|
|
||||||
? child->AsRemote()->EndOffset(&unused)
|
|
||||||
: child->AsLocal()->EndOffset();
|
|
||||||
return endOffset < static_cast<uint32_t>(aPoint.mOffset);
|
return endOffset < static_cast<uint32_t>(aPoint.mOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +172,7 @@ addAccessibleTask(
|
|||||||
is(getAccessibleDOMNodeID(link), "link", "LinkAt 0 is the link");
|
is(getAccessibleDOMNodeID(link), "link", "LinkAt 0 is the link");
|
||||||
is(container.getLinkIndex(link), 0, "getLinkIndex for link is 0");
|
is(container.getLinkIndex(link), 0, "getLinkIndex for link is 0");
|
||||||
is(link.startIndex, 1, "link's startIndex is 1");
|
is(link.startIndex, 1, "link's startIndex is 1");
|
||||||
|
is(link.endIndex, 2, "link's endIndex is 2");
|
||||||
is(container.getLinkIndexAtOffset(1), 0, "getLinkIndexAtOffset(1) is 0");
|
is(container.getLinkIndexAtOffset(1), 0, "getLinkIndexAtOffset(1) is 0");
|
||||||
is(container.getLinkIndexAtOffset(0), -1, "getLinkIndexAtOffset(0) is -1");
|
is(container.getLinkIndexAtOffset(0), -1, "getLinkIndexAtOffset(0) is -1");
|
||||||
},
|
},
|
||||||
|
@ -137,7 +137,7 @@ ia2AccessibleHyperlink::get_endIndex(long* aIndex) {
|
|||||||
|
|
||||||
*aIndex = 0;
|
*aIndex = 0;
|
||||||
|
|
||||||
LocalAccessible* thisObj = LocalAcc();
|
Accessible* thisObj = Acc();
|
||||||
if (!thisObj) {
|
if (!thisObj) {
|
||||||
return CO_E_OBJNOTCONNECTED;
|
return CO_E_OBJNOTCONNECTED;
|
||||||
}
|
}
|
||||||
|
@ -38,20 +38,14 @@ xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex) {
|
|||||||
|
|
||||||
if (!Intl()) return NS_ERROR_FAILURE;
|
if (!Intl()) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if (Intl()->IsLocal()) {
|
|
||||||
*aEndIndex = Intl()->AsLocal()->EndOffset();
|
|
||||||
} else {
|
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
|
if (Intl()->IsRemote() &&
|
||||||
|
!StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
#else
|
|
||||||
bool isIndexValid = false;
|
|
||||||
uint32_t endOffset = Intl()->AsRemote()->EndOffset(&isIndexValid);
|
|
||||||
if (!isIndexValid) return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
*aEndIndex = endOffset;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
*aEndIndex = static_cast<int32_t>(Intl()->EndOffset());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user