Bug 1954896 - Use weak reference in RemoteAccessible::GetCachedARIAAttributes. r=Jamie,geckoview-reviewers,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D242955
This commit is contained in:
@@ -182,6 +182,17 @@ class AccAttributes {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* GetAttributeWeakPtr(nsAtom* aAttrName) const {
|
||||
if (auto value = mData.Lookup(aAttrName)) {
|
||||
if (value->is<RefPtr<T>>()) {
|
||||
const T* ref = value->as<RefPtr<T>>();
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Maybe<T&> GetMutableAttribute(nsAtom* aAttrName) const {
|
||||
static_assert(std::is_same_v<nsTArray<int32_t>, T> ||
|
||||
|
||||
@@ -1544,10 +1544,10 @@ already_AddRefed<AccAttributes> RemoteAccessible::DefaultTextAttributes() {
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
RefPtr<const AccAttributes> RemoteAccessible::GetCachedARIAAttributes() const {
|
||||
const AccAttributes* RemoteAccessible::GetCachedARIAAttributes() const {
|
||||
ASSERT_DOMAINS_ACTIVE(CacheDomain::ARIA);
|
||||
if (mCachedFields) {
|
||||
auto attrs = mCachedFields->GetAttributeRefPtr<AccAttributes>(
|
||||
auto attrs = mCachedFields->GetAttributeWeakPtr<AccAttributes>(
|
||||
CacheKey::ARIAAttributes);
|
||||
VERIFY_CACHE(CacheDomain::ARIA);
|
||||
return attrs;
|
||||
@@ -1845,7 +1845,7 @@ void RemoteAccessible::LiveRegionAttributes(nsAString* aLive,
|
||||
if (!mCachedFields) {
|
||||
return;
|
||||
}
|
||||
RefPtr<const AccAttributes> attrs = GetCachedARIAAttributes();
|
||||
auto attrs = GetCachedARIAAttributes();
|
||||
if (!attrs) {
|
||||
return;
|
||||
}
|
||||
@@ -2329,7 +2329,7 @@ Maybe<int32_t> RemoteAccessible::GetIntARIAAttr(nsAtom* aAttrName) const {
|
||||
if (RequestDomainsIfInactive(CacheDomain::ARIA)) {
|
||||
return Nothing();
|
||||
}
|
||||
if (RefPtr<const AccAttributes> attrs = GetCachedARIAAttributes()) {
|
||||
if (auto attrs = GetCachedARIAAttributes()) {
|
||||
if (auto val = attrs->GetAttribute<int32_t>(aAttrName)) {
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ class RemoteAccessible : public Accessible, public HyperTextAccessibleBase {
|
||||
Maybe<const nsTArray<int32_t>&> GetCachedTextLines();
|
||||
nsRect GetCachedCharRect(int32_t aOffset);
|
||||
RefPtr<const AccAttributes> GetCachedTextAttributes();
|
||||
RefPtr<const AccAttributes> GetCachedARIAAttributes() const;
|
||||
const AccAttributes* GetCachedARIAAttributes() const;
|
||||
|
||||
nsString GetCachedHTMLNameAttribute() const;
|
||||
|
||||
|
||||
@@ -1109,6 +1109,12 @@ class AccessibilityTest : BaseSessionTest() {
|
||||
loadTestPage("test-live-region")
|
||||
waitForInitialFocus()
|
||||
|
||||
val rootNode = createNodeInfo(View.NO_ID)
|
||||
assertThat("Document has 1 child", rootNode.childCount, equalTo(1))
|
||||
|
||||
val liveRegion = createNodeInfo(rootNode.getChildId(0))
|
||||
assertThat("First node is a label", liveRegion.viewIdResourceName.toString(), equalTo("to_change"))
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('#to_change').textContent = 'Hello';")
|
||||
sessionRule.waitUntilCalled(object : EventDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
|
||||
Reference in New Issue
Block a user