mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 445510 - Support ARIA-based text attributes, r=tbsaunde
--HG-- rename : accessible/tests/mochitest/attributes/test_text.html => accessible/tests/mochitest/textattrs/test_general.html
This commit is contained in:
parent
9622013d21
commit
176065e86a
@ -83,6 +83,9 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
||||
// "language" text attribute
|
||||
LangTextAttr langTextAttr(mHyperTextAcc, hyperTextElm, offsetNode);
|
||||
|
||||
// "aria-invalid" text attribute
|
||||
InvalidTextAttr invalidTextAttr(hyperTextElm, offsetNode);
|
||||
|
||||
// "background-color" text attribute
|
||||
BGColorTextAttr bgColorTextAttr(rootFrame, frame);
|
||||
|
||||
@ -113,6 +116,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
||||
TextAttr* attrArray[] =
|
||||
{
|
||||
&langTextAttr,
|
||||
&invalidTextAttr,
|
||||
&bgColorTextAttr,
|
||||
&colorTextAttr,
|
||||
&fontFamilyTextAttr,
|
||||
@ -226,6 +230,88 @@ TextAttrsMgr::LangTextAttr::
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// InvalidTextAttr
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TextAttrsMgr::InvalidTextAttr::
|
||||
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm) :
|
||||
TTextAttr<uint32_t>(!aElm), mRootElm(aRootElm)
|
||||
{
|
||||
mIsRootDefined = GetValue(mRootElm, &mRootNativeValue);
|
||||
if (aElm)
|
||||
mIsDefined = GetValue(aElm, &mNativeValue);
|
||||
}
|
||||
|
||||
bool
|
||||
TextAttrsMgr::InvalidTextAttr::
|
||||
GetValueFor(Accessible* aAccessible, uint32_t* aValue)
|
||||
{
|
||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||
return elm ? GetValue(elm, aValue) : false;
|
||||
}
|
||||
|
||||
void
|
||||
TextAttrsMgr::InvalidTextAttr::
|
||||
ExposeValue(nsIPersistentProperties* aAttributes, const uint32_t& aValue)
|
||||
{
|
||||
switch (aValue) {
|
||||
case eFalse:
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
||||
NS_LITERAL_STRING("false"));
|
||||
break;
|
||||
|
||||
case eGrammar:
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
||||
NS_LITERAL_STRING("grammar"));
|
||||
break;
|
||||
|
||||
case eSpelling:
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
||||
NS_LITERAL_STRING("spelling"));
|
||||
break;
|
||||
|
||||
case eTrue:
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
||||
NS_LITERAL_STRING("true"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TextAttrsMgr::InvalidTextAttr::
|
||||
GetValue(nsIContent* aElm, uint32_t* aValue)
|
||||
{
|
||||
nsIContent* elm = aElm;
|
||||
do {
|
||||
if (nsAccUtils::HasDefinedARIAToken(elm, nsGkAtoms::aria_invalid)) {
|
||||
static nsIContent::AttrValuesArray tokens[] =
|
||||
{ &nsGkAtoms::_false, &nsGkAtoms::grammar, &nsGkAtoms::spelling,
|
||||
nullptr };
|
||||
|
||||
int32_t idx = elm->FindAttrValueIn(kNameSpaceID_None,
|
||||
nsGkAtoms::aria_invalid, tokens,
|
||||
eCaseMatters);
|
||||
switch (idx) {
|
||||
case 0:
|
||||
*aValue = eFalse;
|
||||
return true;
|
||||
case 1:
|
||||
*aValue = eGrammar;
|
||||
return true;
|
||||
case 2:
|
||||
*aValue = eSpelling;
|
||||
return true;
|
||||
default:
|
||||
*aValue = eTrue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} while ((elm = elm->GetParent()) && elm != mRootElm);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// BGColorTextAttr
|
||||
|
@ -212,6 +212,38 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class is used for the 'invalid' text attribute. Note, it calculated
|
||||
* the attribute from aria-invalid attribute only; invalid:spelling attribute
|
||||
* calculated from misspelled text in the editor is managed by
|
||||
* HyperTextAccessible and applied on top of the value from aria-invalid.
|
||||
*/
|
||||
class InvalidTextAttr : public TTextAttr<uint32_t>
|
||||
{
|
||||
public:
|
||||
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm);
|
||||
virtual ~InvalidTextAttr() { };
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
eFalse,
|
||||
eGrammar,
|
||||
eSpelling,
|
||||
eTrue
|
||||
};
|
||||
|
||||
// TextAttr
|
||||
virtual bool GetValueFor(Accessible* aAccessible, uint32_t* aValue);
|
||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||
const uint32_t& aValue);
|
||||
|
||||
private:
|
||||
bool GetValue(nsIContent* aElm, uint32_t* aValue);
|
||||
nsIContent* mRootElm;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class is used for the work with 'background-color' text attribute.
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@ DIRS = \
|
||||
states \
|
||||
table \
|
||||
text \
|
||||
textattrs \
|
||||
textcaret \
|
||||
textselection \
|
||||
tree \
|
||||
|
@ -19,7 +19,6 @@ MOCHITEST_A11Y_FILES =\
|
||||
test_obj_group.xul \
|
||||
test_obj_group_tree.xul \
|
||||
test_tag.html \
|
||||
test_text.html \
|
||||
test_xml-roles.html \
|
||||
$(NULL)
|
||||
|
||||
|
19
accessible/tests/mochitest/textattrs/Makefile.in
Normal file
19
accessible/tests/mochitest/textattrs/Makefile.in
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = accessible/textattrs
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOCHITEST_A11Y_FILES =\
|
||||
test_general.html \
|
||||
test_invalid.html \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
62
accessible/tests/mochitest/textattrs/test_invalid.html
Normal file
62
accessible/tests/mochitest/textattrs/test_invalid.html
Normal file
@ -0,0 +1,62 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Invalid text attribute</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../states.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../events.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../attributes.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTests()
|
||||
{
|
||||
testDefaultTextAttrs("aria_invalid_empty", {}, true);
|
||||
testDefaultTextAttrs("aria_invalid_true", { "invalid": "true" }, true);
|
||||
testDefaultTextAttrs("aria_invalid_false", { "invalid": "false" }, true);
|
||||
testDefaultTextAttrs("aria_invalid_grammar", { "invalid": "grammar" }, true);
|
||||
testDefaultTextAttrs("aria_invalid_spelling", { "invalid": "spelling" }, true);
|
||||
testDefaultTextAttrs("aria_invalid_erroneous", { "invalid": "true" }, true);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=445510"
|
||||
title="Support ARIA-based text attributes">
|
||||
Mozilla Bug 445510
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<div id="aria_invalid_empty" aria-invalid="">no invalid</div>
|
||||
<div id="aria_invalid_true" aria-invalid="true">invalid:true</div>
|
||||
<div id="aria_invalid_false" aria-invalid="false">invalid:false</div>
|
||||
<div id="aria_invalid_grammar" aria-invalid="grammar">invalid:grammar</div>
|
||||
<div id="aria_invalid_spelling" aria-invalid="spelling">invalid:spelling</div>
|
||||
<div id="aria_invalid_erroneous" aria-invalid="erroneous">invalid:true</div>
|
||||
</body>
|
||||
</html>
|
@ -2100,6 +2100,7 @@ GK_ATOM(datatable, "datatable")
|
||||
GK_ATOM(directory, "directory")
|
||||
GK_ATOM(droppable, "droppable")
|
||||
GK_ATOM(eventFromInput, "event-from-input")
|
||||
GK_ATOM(grammar, "grammar")
|
||||
GK_ATOM(gridcell, "gridcell")
|
||||
GK_ATOM(heading, "heading")
|
||||
GK_ATOM(InlineBlockFrame, "InlineBlockFrame")
|
||||
@ -2127,6 +2128,7 @@ GK_ATOM(rowgroup, "rowgroup")
|
||||
GK_ATOM(rowheader, "rowheader")
|
||||
GK_ATOM(select1, "select1")
|
||||
GK_ATOM(setsize, "setsize")
|
||||
GK_ATOM(spelling, "spelling")
|
||||
GK_ATOM(spinbutton, "spinbutton")
|
||||
GK_ATOM(status, "status")
|
||||
GK_ATOM(tableCellIndex, "table-cell-index")
|
||||
|
Loading…
Reference in New Issue
Block a user