зеркало из https://github.com/mozilla/pjs.git
Bug 475006 - Extend nsARIAMap or create hashtable to capture ARIA attribute characteristics, r=surkov, r=MarcoZ
This commit is contained in:
Родитель
5f1ed113ad
Коммит
da62b0bcb2
|
@ -540,3 +540,41 @@ nsStateMapEntry nsARIAMap::gWAIUnivStateMap[] = {
|
|||
kEndEntry
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* ARIA attribute map for attribute characteristics
|
||||
*
|
||||
* @note ARIA attributes that don't have any flags are not included here
|
||||
*/
|
||||
nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
|
||||
{&nsAccessibilityAtoms::aria_activedescendant, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_atomic, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_busy, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_checked, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_controls, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_describedby, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_disabled, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_dropeffect, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_expanded, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_flowto, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_grabbed, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_haspopup, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_invalid, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_labelledby, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_live, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_multiline, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_multiselectable, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_owns, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_pressed, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_readonly, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_relevant, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_required, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_selected, ATTR_EXPOSEOBJ | ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_sort, ATTR_VALTOKEN },
|
||||
{&nsAccessibilityAtoms::aria_valuenow, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_valuemin, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_valuemax, ATTR_EXPOSEOBJ },
|
||||
{&nsAccessibilityAtoms::aria_valuetext, ATTR_EXPOSEOBJ }
|
||||
};
|
||||
|
||||
PRUint32 nsARIAMap::gWAIUnivAttrMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIUnivAttrMap);
|
||||
|
|
|
@ -63,6 +63,21 @@ enum EActionRule
|
|||
eSwitchAction
|
||||
};
|
||||
|
||||
// ARIA attribute characteristic masks, grow as needed
|
||||
|
||||
/**
|
||||
* This mask indicates the attribute should be exposed as an object attribute,
|
||||
* used to expose semantics not traditionally found in a11y APIs.
|
||||
* (See for example usage in nsAccessible::GetAttributes)
|
||||
*/
|
||||
const PRUint8 ATTR_EXPOSEOBJ = 0x0001;
|
||||
|
||||
/**
|
||||
* This mask indicates the attribute is expected to have an NMTOKEN or bool value.
|
||||
* (See for example usage in nsAccessible::GetAttributes)
|
||||
*/
|
||||
const PRUint8 ATTR_VALTOKEN = 0x0010;
|
||||
|
||||
// Used for an nsStateMapEntry if a given state attribute supports "true" and "false"
|
||||
#define kBoolState 0
|
||||
|
||||
|
@ -78,6 +93,13 @@ struct nsStateMapEntry
|
|||
PRUint32 state; // If match, this is the nsIAccessibleStates to map to
|
||||
};
|
||||
|
||||
// Small footprint storage of persistent aria attribute characteristics
|
||||
struct nsAttributeCharacteristics
|
||||
{
|
||||
nsIAtom** attributeName;
|
||||
const PRUint8 characteristics;
|
||||
};
|
||||
|
||||
// For each ARIA role, this maps the nsIAccessible information
|
||||
struct nsRoleMapEntry
|
||||
{
|
||||
|
@ -142,6 +164,12 @@ struct nsARIAMap
|
|||
* the role.
|
||||
*/
|
||||
static nsStateMapEntry gWAIUnivStateMap[];
|
||||
|
||||
/**
|
||||
* Map of attribute to attribute characteristics.
|
||||
*/
|
||||
static nsAttributeCharacteristics gWAIUnivAttrMap[];
|
||||
static PRUint32 gWAIUnivAttrMapLength;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -301,33 +301,6 @@ nsAccUtils::SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
|
|||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::IsARIAPropForObjectAttr(nsIAtom *aAtom)
|
||||
{
|
||||
return aAtom != nsAccessibilityAtoms::aria_activedescendant &&
|
||||
aAtom != nsAccessibilityAtoms::aria_checked &&
|
||||
aAtom != nsAccessibilityAtoms::aria_controls &&
|
||||
aAtom != nsAccessibilityAtoms::aria_describedby &&
|
||||
aAtom != nsAccessibilityAtoms::aria_disabled &&
|
||||
aAtom != nsAccessibilityAtoms::aria_expanded &&
|
||||
aAtom != nsAccessibilityAtoms::aria_flowto &&
|
||||
aAtom != nsAccessibilityAtoms::aria_invalid &&
|
||||
aAtom != nsAccessibilityAtoms::aria_haspopup &&
|
||||
aAtom != nsAccessibilityAtoms::aria_labelledby &&
|
||||
aAtom != nsAccessibilityAtoms::aria_multiline &&
|
||||
aAtom != nsAccessibilityAtoms::aria_multiselectable &&
|
||||
aAtom != nsAccessibilityAtoms::aria_owns &&
|
||||
aAtom != nsAccessibilityAtoms::aria_pressed &&
|
||||
aAtom != nsAccessibilityAtoms::aria_readonly &&
|
||||
aAtom != nsAccessibilityAtoms::aria_relevant &&
|
||||
aAtom != nsAccessibilityAtoms::aria_required &&
|
||||
aAtom != nsAccessibilityAtoms::aria_selected &&
|
||||
aAtom != nsAccessibilityAtoms::aria_valuemax &&
|
||||
aAtom != nsAccessibilityAtoms::aria_valuemin &&
|
||||
aAtom != nsAccessibilityAtoms::aria_valuenow &&
|
||||
aAtom != nsAccessibilityAtoms::aria_valuetext;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom)
|
||||
{
|
||||
|
@ -686,6 +659,16 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
|
|||
return &nsARIAMap::gLandmarkRoleMap;
|
||||
}
|
||||
|
||||
PRUint8
|
||||
nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom)
|
||||
{
|
||||
for (PRUint32 i = 0; i < nsARIAMap::gWAIUnivAttrMapLength; i++)
|
||||
if (*nsARIAMap::gWAIUnivAttrMap[i].attributeName == aAtom)
|
||||
return nsARIAMap::gWAIUnivAttrMap[i].characteristics;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
|
||||
|
|
|
@ -130,12 +130,6 @@ public:
|
|||
nsIContent *aStartContent,
|
||||
nsIContent *aTopContent);
|
||||
|
||||
/**
|
||||
* Return PR_TRUE if the ARIA property should always be exposed as an object
|
||||
* attribute.
|
||||
*/
|
||||
static PRBool IsARIAPropForObjectAttr(nsIAtom *aAtom);
|
||||
|
||||
/**
|
||||
* Any ARIA property of type boolean or NMTOKEN is undefined if the ARIA
|
||||
* property is not present, or is "" or "undefined". Do not call
|
||||
|
@ -267,6 +261,15 @@ public:
|
|||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ARIA attribute characteristics for a given ARIA attribute.
|
||||
*
|
||||
* @param aAtom ARIA attribute
|
||||
* @return A bitflag representing the attribute characteristics
|
||||
* (see nsARIAMap.h for possible bit masks, prefixed "ARIA_")
|
||||
*/
|
||||
static PRUint8 GetAttributeCharacteristics(nsIAtom* aAtom);
|
||||
|
||||
/**
|
||||
* Query nsAccessNode from the given nsIAccessible.
|
||||
*/
|
||||
|
|
|
@ -2022,8 +2022,12 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
|||
attrAtom->GetUTF8String(&attrStr);
|
||||
if (PL_strncmp(attrStr, "aria-", 5))
|
||||
continue; // Not ARIA
|
||||
if (!nsAccUtils::IsARIAPropForObjectAttr(attrAtom))
|
||||
PRUint8 attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
|
||||
if (attrFlags & ATTR_EXPOSEOBJ)
|
||||
continue; // No need to expose obj attribute -- will be exposed some other way
|
||||
if ((attrFlags & ATTR_VALTOKEN) &&
|
||||
!nsAccUtils::HasDefinedARIAToken(content, attrAtom))
|
||||
continue; // only expose token based attributes if they are defined
|
||||
nsAutoString value;
|
||||
if (content->GetAttr(kNameSpaceID_None, attrAtom, value)) {
|
||||
attributes->SetStringProperty(nsDependentCString(attrStr + 5), value, oldValueUnused);
|
||||
|
|
|
@ -99,6 +99,7 @@ _TEST_FILES =\
|
|||
$(warning test_nsIAccessibleTable_listboxes.xul temporarily disabled) \
|
||||
test_nsIAccessNode_utils.html \
|
||||
test_nsOuterDocAccessible.html \
|
||||
test_objectattrs.html \
|
||||
test_relations.html \
|
||||
test_relations.xul \
|
||||
test_role_nsHyperTextAcc.html \
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=475006
|
||||
-->
|
||||
<head>
|
||||
<title>Group attributes tests</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/attributes.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
testAttrs("atomic", {"atomic" : "true"}, true);
|
||||
testAttrs("autocomplete", {"autocomplete" : "true"}, true);
|
||||
// bug 477876 testAttrs("checked", {"checkable" : "true"}, true);
|
||||
testAttrs("dropeffect", {"dropeffect" : "copy"}, true);
|
||||
testAttrs("live", {"live" : "polite"}, true);
|
||||
testAttrs("me", {"container-live" : "polite"}, true);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=475006"
|
||||
title="Extend nsARIAMap to capture ARIA attribute characteristics">
|
||||
Mozilla Bug 475006
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<div id="atomic" aria-atomic="true"></div>
|
||||
<div id="autocomplete" role="textbox" aria-autocomplete="true"></div>
|
||||
<div id="checked" aria-checked="true"></div>
|
||||
<div id="dropeffect" aria-dropeffect="copy"></div>
|
||||
<div id="live" aria-live="polite">excuse <div id="me">me</div></div>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче