mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1742915 part 2: Cache the tag attribute. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D132653
This commit is contained in:
parent
25f7ff3485
commit
09a73de6f5
@ -3256,6 +3256,14 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
||||
fields->SetAttribute(nsGkAtoms::state, state);
|
||||
}
|
||||
|
||||
if (aUpdateType == CacheUpdateType::Initial) {
|
||||
// Add fields which never change and thus only need to be included in the
|
||||
// initial cache push.
|
||||
if (mContent->IsElement()) {
|
||||
fields->SetAttribute(nsGkAtoms::tag, mContent->NodeInfo()->NameAtom());
|
||||
}
|
||||
}
|
||||
|
||||
return fields.forget();
|
||||
}
|
||||
|
||||
|
@ -470,6 +470,14 @@ uint64_t RemoteAccessibleBase<Derived>::State() {
|
||||
template <class Derived>
|
||||
already_AddRefed<AccAttributes> RemoteAccessibleBase<Derived>::Attributes() {
|
||||
RefPtr<AccAttributes> attributes = new AccAttributes();
|
||||
if (mCachedFields) {
|
||||
// We use GetAttribute instead of GetAttributeRefPtr because we need
|
||||
// nsAtom, not const nsAtom.
|
||||
if (auto tag =
|
||||
mCachedFields->GetAttribute<RefPtr<nsAtom>>(nsGkAtoms::tag)) {
|
||||
attributes->SetAttribute(nsGkAtoms::tag, *tag);
|
||||
}
|
||||
}
|
||||
return attributes.forget();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,11 @@
|
||||
/* import-globals-from ../../mochitest/attributes.js */
|
||||
loadScripts({ name: "attributes.js", dir: MOCHITESTS_DIR });
|
||||
|
||||
const isCacheEnabled = Services.prefs.getBoolPref(
|
||||
"accessibility.cache.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* Default textbox accessible attributes.
|
||||
*/
|
||||
@ -130,5 +135,30 @@ addAccessibleTask(
|
||||
testAbsentAttrs(textbox, unexpected);
|
||||
}
|
||||
},
|
||||
{ iframe: true, remoteIframe: true }
|
||||
{
|
||||
// These tests don't work yet with the parent process cache enabled.
|
||||
topLevel: !isCacheEnabled,
|
||||
iframe: !isCacheEnabled,
|
||||
remoteIframe: !isCacheEnabled,
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test caching of the tag attribute.
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<p id="p">text</p>
|
||||
<textarea id="textarea"></textarea>
|
||||
`,
|
||||
async function(browser, docAcc) {
|
||||
testAttrs(docAcc, { tag: "body" }, true);
|
||||
const p = findAccessibleChildByID(docAcc, "p");
|
||||
testAttrs(p, { tag: "p" }, true);
|
||||
const textLeaf = p.firstChild;
|
||||
testAbsentAttrs(textLeaf, { tag: "" });
|
||||
const textarea = findAccessibleChildByID(docAcc, "textarea");
|
||||
testAttrs(textarea, { tag: "textarea" }, true);
|
||||
},
|
||||
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user