mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1139900 - make tag name based roles faster, r=marcoz
This commit is contained in:
parent
0f61f58788
commit
a92de680c2
@ -6,106 +6,145 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
MARKUPMAP(a,
|
||||
New_HTMLLink)
|
||||
New_HTMLLink,
|
||||
0)
|
||||
|
||||
MARKUPMAP(abbr,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
0)
|
||||
|
||||
MARKUPMAP(acronym,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
0)
|
||||
|
||||
MARKUPMAP(article,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::DOCUMENT)
|
||||
|
||||
MARKUPMAP(aside,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::NOTE)
|
||||
|
||||
MARKUPMAP(blockquote,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::SECTION)
|
||||
|
||||
MARKUPMAP(dd,
|
||||
New_HTMLDefinition)
|
||||
New_HTMLDefinition,
|
||||
roles::DEFINITION)
|
||||
|
||||
MARKUPMAP(div,
|
||||
nullptr,
|
||||
roles::SECTION)
|
||||
|
||||
MARKUPMAP(dl,
|
||||
New_HTMLList)
|
||||
New_HTMLList,
|
||||
roles::DEFINITION_LIST)
|
||||
|
||||
MARKUPMAP(dt,
|
||||
New_HTMLListitem)
|
||||
New_HTMLListitem,
|
||||
roles::TERM)
|
||||
|
||||
MARKUPMAP(figcaption,
|
||||
New_HTMLFigcaption)
|
||||
New_HTMLFigcaption,
|
||||
0)
|
||||
|
||||
MARKUPMAP(figure,
|
||||
New_HTMLFigure)
|
||||
New_HTMLFigure,
|
||||
0)
|
||||
|
||||
MARKUPMAP(form,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::FORM)
|
||||
|
||||
MARKUPMAP(footer,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::FOOTER)
|
||||
|
||||
MARKUPMAP(header,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADER)
|
||||
|
||||
MARKUPMAP(h1,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(h2,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(h3,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(h4,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(h5,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(h6,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::HEADING)
|
||||
|
||||
MARKUPMAP(label,
|
||||
New_HTMLLabel)
|
||||
New_HTMLLabel,
|
||||
0)
|
||||
|
||||
MARKUPMAP(legend,
|
||||
New_HTMLLegend)
|
||||
New_HTMLLegend,
|
||||
0)
|
||||
|
||||
MARKUPMAP(li,
|
||||
New_HTMLListitem)
|
||||
New_HTMLListitem,
|
||||
0)
|
||||
|
||||
MARKUPMAP(nav,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::SECTION)
|
||||
|
||||
MARKUPMAP(ol,
|
||||
New_HTMLList)
|
||||
New_HTMLList,
|
||||
0)
|
||||
|
||||
MARKUPMAP(option,
|
||||
New_HTMLOption)
|
||||
New_HTMLOption,
|
||||
0)
|
||||
|
||||
MARKUPMAP(optgroup,
|
||||
New_HTMLOptgroup)
|
||||
New_HTMLOptgroup,
|
||||
0)
|
||||
|
||||
MARKUPMAP(output,
|
||||
New_HTMLOutput)
|
||||
New_HTMLOutput,
|
||||
0)
|
||||
|
||||
MARKUPMAP(progress,
|
||||
New_HTMLProgress)
|
||||
New_HTMLProgress,
|
||||
0)
|
||||
|
||||
MARKUPMAP(q,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
0)
|
||||
|
||||
MARKUPMAP(section,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
roles::SECTION)
|
||||
|
||||
MARKUPMAP(time,
|
||||
New_HyperText)
|
||||
New_HyperText,
|
||||
0)
|
||||
|
||||
MARKUPMAP(td,
|
||||
New_HTMLTableHeaderCellIfScope)
|
||||
New_HTMLTableHeaderCellIfScope,
|
||||
0)
|
||||
|
||||
MARKUPMAP(th,
|
||||
New_HTMLTableHeaderCell)
|
||||
New_HTMLTableHeaderCell,
|
||||
0)
|
||||
|
||||
MARKUPMAP(ul,
|
||||
New_HTMLList)
|
||||
New_HTMLList,
|
||||
0)
|
||||
|
@ -220,13 +220,8 @@ New_HTMLTableHeaderCellIfScope(nsIContent* aContent, Accessible* aContext)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Markup maps array.
|
||||
|
||||
struct MarkupMapInfo {
|
||||
nsIAtom** tag;
|
||||
New_Accessible* new_func;
|
||||
};
|
||||
|
||||
#define MARKUPMAP(atom, new_func) \
|
||||
{ &nsGkAtoms::atom, new_func },
|
||||
#define MARKUPMAP(atom, new_func, r) \
|
||||
{ &nsGkAtoms::atom, new_func, static_cast<a11y::role>(r) },
|
||||
|
||||
static const MarkupMapInfo sMarkupMapList[] = {
|
||||
#include "MarkupMap.h"
|
||||
@ -244,7 +239,7 @@ xpcAccessibleApplication* nsAccessibilityService::gXPCApplicationAccessible = nu
|
||||
bool nsAccessibilityService::gIsShutdown = true;
|
||||
|
||||
nsAccessibilityService::nsAccessibilityService() :
|
||||
DocManager(), FocusManager(), mMarkupMap(ArrayLength(sMarkupMapList))
|
||||
DocManager(), FocusManager(), mMarkupMaps(ArrayLength(sMarkupMapList))
|
||||
{
|
||||
}
|
||||
|
||||
@ -1079,9 +1074,10 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
frame->AccessibleType() == eHTMLTableCellType ||
|
||||
frame->AccessibleType() == eHTMLTableType) {
|
||||
// Prefer to use markup to decide if and what kind of accessible to create,
|
||||
New_Accessible* new_func = mMarkupMap.Get(content->NodeInfo()->NameAtom());
|
||||
if (new_func)
|
||||
newAcc = new_func(content, aContext);
|
||||
const MarkupMapInfo* markupMap =
|
||||
mMarkupMaps.Get(content->NodeInfo()->NameAtom());
|
||||
if (markupMap && markupMap->new_func)
|
||||
newAcc = markupMap->new_func(content, aContext);
|
||||
|
||||
if (!newAcc) // try by frame accessible type.
|
||||
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
|
||||
@ -1220,7 +1216,7 @@ nsAccessibilityService::Init()
|
||||
observerService->NotifyObservers(nullptr, "a11y-init-or-shutdown", kInitIndicator);
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(sMarkupMapList); i++)
|
||||
mMarkupMap.Put(*sMarkupMapList[i].tag, sMarkupMapList[i].new_func);
|
||||
mMarkupMaps.Put(*sMarkupMapList[i].tag, &sMarkupMapList[i]);
|
||||
|
||||
#ifdef A11Y_LOG
|
||||
logging::CheckEnv();
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
#include "mozilla/a11y/FocusManager.h"
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "mozilla/a11y/SelectionManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
@ -43,6 +44,12 @@ xpcAccessibleApplication* XPCApplicationAcc();
|
||||
|
||||
typedef Accessible* (New_Accessible)(nsIContent* aContent, Accessible* aContext);
|
||||
|
||||
struct MarkupMapInfo {
|
||||
nsIAtom** tag;
|
||||
New_Accessible* new_func;
|
||||
a11y::role role;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
@ -168,6 +175,13 @@ public:
|
||||
Accessible* GetOrCreateAccessible(nsINode* aNode, Accessible* aContext,
|
||||
bool* aIsSubtreeHidden = nullptr);
|
||||
|
||||
mozilla::a11y::role MarkupRole(const nsIContent* aContent) const
|
||||
{
|
||||
const mozilla::a11y::MarkupMapInfo* markupMap =
|
||||
mMarkupMaps.Get(aContent->NodeInfo()->NameAtom());
|
||||
return markupMap ? markupMap->role : mozilla::a11y::roles::NOTHING;
|
||||
}
|
||||
|
||||
private:
|
||||
// nsAccessibilityService creation is controlled by friend
|
||||
// NS_GetAccessibilityService, keep constructors private.
|
||||
@ -223,7 +237,7 @@ private:
|
||||
*/
|
||||
static bool gIsShutdown;
|
||||
|
||||
nsDataHashtable<nsPtrHashKey<const nsIAtom>, mozilla::a11y::New_Accessible*> mMarkupMap;
|
||||
nsDataHashtable<nsPtrHashKey<const nsIAtom>, const mozilla::a11y::MarkupMapInfo*> mMarkupMaps;
|
||||
|
||||
friend nsAccessibilityService* GetAccService();
|
||||
friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
|
||||
|
@ -59,35 +59,9 @@ NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessible, Accessible)
|
||||
role
|
||||
HyperTextAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::dd))
|
||||
return roles::DEFINITION;
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::form))
|
||||
return roles::FORM;
|
||||
|
||||
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::blockquote,
|
||||
nsGkAtoms::div,
|
||||
nsGkAtoms::section,
|
||||
nsGkAtoms::nav))
|
||||
return roles::SECTION;
|
||||
|
||||
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::h1, nsGkAtoms::h2,
|
||||
nsGkAtoms::h3, nsGkAtoms::h4,
|
||||
nsGkAtoms::h5, nsGkAtoms::h6))
|
||||
return roles::HEADING;
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::article))
|
||||
return roles::DOCUMENT;
|
||||
|
||||
// Deal with html landmark elements
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::header))
|
||||
return roles::HEADER;
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::footer))
|
||||
return roles::FOOTER;
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::aside))
|
||||
return roles::NOTE;
|
||||
a11y::role r = GetAccService()->MarkupRole(mContent);
|
||||
if (r != roles::NOTHING)
|
||||
return r;
|
||||
|
||||
// Treat block frames as paragraphs
|
||||
nsIFrame *frame = GetFrame();
|
||||
|
@ -26,10 +26,8 @@ NS_IMPL_ISUPPORTS_INHERITED0(HTMLListAccessible, HyperTextAccessible)
|
||||
role
|
||||
HTMLListAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::dl))
|
||||
return roles::DEFINITION_LIST;
|
||||
|
||||
return roles::LIST;
|
||||
a11y::role r = GetAccService()->MarkupRole(mContent);
|
||||
return r != roles::NOTHING ? r : roles::LIST;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -69,10 +67,8 @@ HTMLLIAccessible::Shutdown()
|
||||
role
|
||||
HTMLLIAccessible::NativeRole()
|
||||
{
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::dt))
|
||||
return roles::TERM;
|
||||
|
||||
return roles::LISTITEM;
|
||||
a11y::role r = GetAccService()->MarkupRole(mContent);
|
||||
return r != roles::NOTHING ? r : roles::LISTITEM;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
Loading…
Reference in New Issue
Block a user