Bug 1703600 part 2: Add GetMarkupMapInfoForNode and use it wherever we aren't explicitly dealing with a specific type of element. r=eeejay

For now, this just uses mHTMlMarkupMap, but it might choose the MathML map in future.
In some places, we're already inside a block which explicitly checks IsHTMlElement.
In those cases, we still use mHTMlMarkupMap directly, since using GetMarkupMapInfoForNode would redundantly check the element type.

Differential Revision: https://phabricator.services.mozilla.com/D111362
This commit is contained in:
James Teh 2021-04-14 04:11:17 +00:00
Родитель 0e15fa6e17
Коммит b9c9fe8007
2 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -887,8 +887,7 @@ LocalAccessible* nsAccessibilityService::CreateAccessible(
// display:contents element doesn't have a frame, but retains the semantics.
// All its children are unaffected.
if (nsCoreUtils::IsDisplayContents(content)) {
const MarkupMapInfo* markupMap =
mHTMLMarkupMap.Get(content->NodeInfo()->NameAtom());
const MarkupMapInfo* markupMap = GetMarkupMapInfoForNode(content);
if (markupMap && markupMap->new_func) {
RefPtr<LocalAccessible> newAcc =
markupMap->new_func(content->AsElement(), aContext);
@ -1445,7 +1444,7 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
void nsAccessibilityService::MarkupAttributes(
const nsIContent* aContent, nsIPersistentProperties* aAttributes) const {
const mozilla::a11y::MarkupMapInfo* markupMap =
mHTMLMarkupMap.Get(aContent->NodeInfo()->NameAtom());
GetMarkupMapInfoForNode(aContent);
if (!markupMap) return;
for (uint32_t i = 0; i < ArrayLength(markupMap->attrs); i++) {

Просмотреть файл

@ -256,7 +256,7 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
mozilla::a11y::role MarkupRole(const nsIContent* aContent) const {
const mozilla::a11y::MarkupMapInfo* markupMap =
mHTMLMarkupMap.Get(aContent->NodeInfo()->NameAtom());
GetMarkupMapInfoForNode(aContent);
return markupMap ? markupMap->role : mozilla::a11y::roles::NOTHING;
}
@ -267,7 +267,7 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
nsStaticAtom* MarkupAttribute(const nsIContent* aContent,
nsStaticAtom* aAtom) const {
const mozilla::a11y::MarkupMapInfo* markupMap =
mHTMLMarkupMap.Get(aContent->NodeInfo()->NameAtom());
GetMarkupMapInfoForNode(aContent);
if (markupMap) {
for (size_t i = 0; i < mozilla::ArrayLength(markupMap->attrs); i++) {
const mozilla::a11y::MarkupAttrInfo* info = markupMap->attrs + i;
@ -363,8 +363,15 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
*/
static uint32_t gConsumers;
nsTHashMap<nsPtrHashKey<const nsAtom>, const mozilla::a11y::MarkupMapInfo*>
mHTMLMarkupMap;
using MarkupMap = nsTHashMap<nsPtrHashKey<const nsAtom>,
const mozilla::a11y::MarkupMapInfo*>;
MarkupMap mHTMLMarkupMap;
const mozilla::a11y::MarkupMapInfo* GetMarkupMapInfoForNode(
const nsIContent* aContent) const {
return mHTMLMarkupMap.Get(aContent->NodeInfo()->NameAtom());
}
#ifdef MOZ_XUL
nsTHashMap<nsPtrHashKey<const nsAtom>, const mozilla::a11y::XULMarkupMapInfo*>
mXULMarkupMap;