mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1140500 - add object attributes declaration into markup map, r=marcoz
This commit is contained in:
parent
016fb5802e
commit
da2f7bc6c1
@ -19,7 +19,8 @@ MARKUPMAP(acronym,
|
||||
|
||||
MARKUPMAP(article,
|
||||
New_HyperText,
|
||||
roles::DOCUMENT)
|
||||
roles::DOCUMENT,
|
||||
Attr(xmlroles, article))
|
||||
|
||||
MARKUPMAP(aside,
|
||||
New_HyperText,
|
||||
@ -51,7 +52,8 @@ MARKUPMAP(figcaption,
|
||||
|
||||
MARKUPMAP(figure,
|
||||
New_HTMLFigure,
|
||||
roles::FIGURE)
|
||||
roles::FIGURE,
|
||||
Attr(xmlroles, figure))
|
||||
|
||||
MARKUPMAP(form,
|
||||
New_HyperText,
|
||||
@ -119,7 +121,8 @@ MARKUPMAP(optgroup,
|
||||
|
||||
MARKUPMAP(output,
|
||||
New_HTMLOutput,
|
||||
roles::SECTION)
|
||||
roles::SECTION,
|
||||
Attr(live, polite))
|
||||
|
||||
MARKUPMAP(progress,
|
||||
New_HTMLProgress,
|
||||
@ -131,11 +134,14 @@ MARKUPMAP(q,
|
||||
|
||||
MARKUPMAP(section,
|
||||
New_HyperText,
|
||||
roles::SECTION)
|
||||
roles::SECTION,
|
||||
Attr(xmlroles, region))
|
||||
|
||||
MARKUPMAP(time,
|
||||
New_HyperText,
|
||||
0)
|
||||
0,
|
||||
Attr(xmlroles, time),
|
||||
AttrFromDOM(datetime, datetime))
|
||||
|
||||
MARKUPMAP(td,
|
||||
New_HTMLTableHeaderCellIfScope,
|
||||
|
@ -220,13 +220,25 @@ New_HTMLTableHeaderCellIfScope(nsIContent* aContent, Accessible* aContext)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Markup maps array.
|
||||
|
||||
#define MARKUPMAP(atom, new_func, r) \
|
||||
{ &nsGkAtoms::atom, new_func, static_cast<a11y::role>(r) },
|
||||
#define Attr(name, value) \
|
||||
{ &nsGkAtoms::name, &nsGkAtoms::value }
|
||||
|
||||
#define AttrFromDOM(name, DOMAttrName) \
|
||||
{ &nsGkAtoms::name, nullptr, &nsGkAtoms::DOMAttrName }
|
||||
|
||||
#define AttrFromDOMIf(name, DOMAttrName, DOMAttrValue) \
|
||||
{ &nsGkAtoms::name, nullptr, &nsGkAtoms::DOMAttrName, &nsGkAtoms::DOMAttrValue }
|
||||
|
||||
#define MARKUPMAP(atom, new_func, r, ... ) \
|
||||
{ &nsGkAtoms::atom, new_func, static_cast<a11y::role>(r), { __VA_ARGS__ } },
|
||||
|
||||
static const MarkupMapInfo sMarkupMapList[] = {
|
||||
#include "MarkupMap.h"
|
||||
};
|
||||
|
||||
#undef Attr
|
||||
#undef AttrFromDOM
|
||||
#undef AttrFromDOMIf
|
||||
#undef MARKUPMAP
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1610,6 +1622,41 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
|
||||
return newAcc.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsAccessibilityService::MarkupAttributes(const nsIContent* aContent,
|
||||
nsIPersistentProperties* aAttributes) const
|
||||
{
|
||||
const mozilla::a11y::MarkupMapInfo* markupMap =
|
||||
mMarkupMaps.Get(aContent->NodeInfo()->NameAtom());
|
||||
if (!markupMap)
|
||||
return;
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(markupMap->attrs); i++) {
|
||||
const MarkupAttrInfo* info = markupMap->attrs + i;
|
||||
if (!info->name)
|
||||
break;
|
||||
|
||||
if (info->DOMAttrName) {
|
||||
if (info->DOMAttrValue) {
|
||||
if (aContent->AttrValueIs(kNameSpaceID_None, *info->DOMAttrName,
|
||||
*info->DOMAttrValue, eCaseMatters)) {
|
||||
nsAccUtils::SetAccAttr(aAttributes, *info->name, *info->DOMAttrValue);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
aContent->GetAttr(kNameSpaceID_None, *info->DOMAttrName, value);
|
||||
if (!value.IsEmpty())
|
||||
nsAccUtils::SetAccAttr(aAttributes, *info->name, value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAccUtils::SetAccAttr(aAttributes, *info->name, *info->value);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAccessibilityService (DON'T put methods here)
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "nsIObserver.h"
|
||||
|
||||
class nsImageFrame;
|
||||
class nsIPersistentProperties;
|
||||
class nsPluginFrame;
|
||||
class nsITreeView;
|
||||
|
||||
@ -44,10 +45,19 @@ xpcAccessibleApplication* XPCApplicationAcc();
|
||||
|
||||
typedef Accessible* (New_Accessible)(nsIContent* aContent, Accessible* aContext);
|
||||
|
||||
struct MarkupAttrInfo {
|
||||
nsIAtom** name;
|
||||
nsIAtom** value;
|
||||
|
||||
nsIAtom** DOMAttrName;
|
||||
nsIAtom** DOMAttrValue;
|
||||
};
|
||||
|
||||
struct MarkupMapInfo {
|
||||
nsIAtom** tag;
|
||||
New_Accessible* new_func;
|
||||
a11y::role role;
|
||||
MarkupAttrInfo attrs[2];
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
@ -182,6 +192,12 @@ public:
|
||||
return markupMap ? markupMap->role : mozilla::a11y::roles::NOTHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object attribute defined by markup for the given element.
|
||||
*/
|
||||
void MarkupAttributes(const nsIContent* aContent,
|
||||
nsIPersistentProperties* aAttributes) const;
|
||||
|
||||
private:
|
||||
// nsAccessibilityService creation is controlled by friend
|
||||
// NS_GetAccessibilityService, keep constructors private.
|
||||
|
@ -977,25 +977,8 @@ HyperTextAccessible::NativeAttributes()
|
||||
}
|
||||
}
|
||||
|
||||
if (!HasOwnContent())
|
||||
return attributes.forget();
|
||||
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::section)) {
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
||||
NS_LITERAL_STRING("region"));
|
||||
} else if (mContent->IsHTMLElement(nsGkAtoms::article)) {
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
||||
NS_LITERAL_STRING("article"));
|
||||
} else if (mContent->IsHTMLElement(nsGkAtoms::time)) {
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
||||
NS_LITERAL_STRING("time"));
|
||||
|
||||
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::datetime)) {
|
||||
nsAutoString datetime;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::datetime, datetime);
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::datetime, datetime);
|
||||
}
|
||||
}
|
||||
if (HasOwnContent())
|
||||
GetAccService()->MarkupAttributes(mContent, attributes);
|
||||
|
||||
return attributes.forget();
|
||||
}
|
||||
|
@ -90,15 +90,3 @@ HTMLOutputAccessible::RelationByType(RelationType aType)
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIPersistentProperties>
|
||||
HTMLOutputAccessible::NativeAttributes()
|
||||
{
|
||||
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||
AccessibleWrap::NativeAttributes();
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live,
|
||||
NS_LITERAL_STRING("polite"));
|
||||
|
||||
return attributes.forget();
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Accessible
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
@ -89,7 +89,7 @@ HTMLCheckboxAccessible::NativeState()
|
||||
|
||||
if (input->Checked())
|
||||
return state | states::CHECKED;
|
||||
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -772,18 +772,6 @@ HTMLFigureAccessible::
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<nsIPersistentProperties>
|
||||
HTMLFigureAccessible::NativeAttributes()
|
||||
{
|
||||
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||
HyperTextAccessibleWrap::NativeAttributes();
|
||||
|
||||
// Expose figure xml-role.
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
||||
NS_LITERAL_STRING("figure"));
|
||||
return attributes.forget();
|
||||
}
|
||||
|
||||
ENameValueFlag
|
||||
HTMLFigureAccessible::NativeName(nsString& aName)
|
||||
{
|
||||
|
@ -255,7 +255,6 @@ public:
|
||||
HTMLFigureAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// Accessible
|
||||
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
||||
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
@ -2289,6 +2289,7 @@ GK_ATOM(mixed, "mixed")
|
||||
GK_ATOM(multiline, "multiline")
|
||||
GK_ATOM(navigation, "navigation")
|
||||
GK_ATOM(password, "password")
|
||||
GK_ATOM(polite, "polite")
|
||||
GK_ATOM(posinset, "posinset")
|
||||
GK_ATOM(presentation, "presentation")
|
||||
GK_ATOM(progressbar, "progressbar")
|
||||
|
Loading…
Reference in New Issue
Block a user