From b9c9fe80076c31fdc982e9e052037cb27a76aff3 Mon Sep 17 00:00:00 2001 From: James Teh Date: Wed, 14 Apr 2021 04:11:17 +0000 Subject: [PATCH] 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 --- accessible/base/nsAccessibilityService.cpp | 5 ++--- accessible/base/nsAccessibilityService.h | 15 +++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 7b09f0cbc22a..88328a06a530 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -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 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++) { diff --git a/accessible/base/nsAccessibilityService.h b/accessible/base/nsAccessibilityService.h index 07981229cd3c..8967c450d83c 100644 --- a/accessible/base/nsAccessibilityService.h +++ b/accessible/base/nsAccessibilityService.h @@ -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, const mozilla::a11y::MarkupMapInfo*> - mHTMLMarkupMap; + using MarkupMap = nsTHashMap, + 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, const mozilla::a11y::XULMarkupMapInfo*> mXULMarkupMap;