зеркало из https://github.com/mozilla/gecko-dev.git
bug 852129 - use HyperTextAccessible for invalid img r=surkov, bz
If the img is not valid then its children will be rendered, and the sensible way to handle that is by giving the img a HyperTextAccessible instead of an ImageAccessible. Since the accessible name of such an img should be the value of the alt attribute we add similar logic as ImageAccessible::NativeName() to HyperTextAccessible::NativeName() conditioned on the tag being img.
This commit is contained in:
Родитель
f31d4e7e40
Коммит
1ca578aba7
|
@ -2112,6 +2112,14 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
|
||||||
ENameValueFlag
|
ENameValueFlag
|
||||||
HyperTextAccessible::NativeName(nsString& aName)
|
HyperTextAccessible::NativeName(nsString& aName)
|
||||||
{
|
{
|
||||||
|
// Check @alt attribute for invalid img elements.
|
||||||
|
bool hasImgAlt = false;
|
||||||
|
if (mContent->IsHTML(nsGkAtoms::img)) {
|
||||||
|
hasImgAlt = mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName);
|
||||||
|
if (!aName.IsEmpty())
|
||||||
|
return eNameOK;
|
||||||
|
}
|
||||||
|
|
||||||
ENameValueFlag nameFlag = AccessibleWrap::NativeName(aName);
|
ENameValueFlag nameFlag = AccessibleWrap::NativeName(aName);
|
||||||
if (!aName.IsEmpty())
|
if (!aName.IsEmpty())
|
||||||
return nameFlag;
|
return nameFlag;
|
||||||
|
@ -2123,7 +2131,7 @@ HyperTextAccessible::NativeName(nsString& aName)
|
||||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
|
||||||
aName.CompressWhitespace();
|
aName.CompressWhitespace();
|
||||||
|
|
||||||
return eNameOK;
|
return hasImgAlt ? eNoNameOnPurpose : eNameOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -208,6 +208,7 @@
|
||||||
|
|
||||||
// Test equation image
|
// Test equation image
|
||||||
testName("img_eq", "x^2 + y^2 + z^2")
|
testName("img_eq", "x^2 + y^2 + z^2")
|
||||||
|
testName("input_img_eq", "x^2 + y^2 + z^2")
|
||||||
testName("txt_eq", "x^2 + y^2 + z^2")
|
testName("txt_eq", "x^2 + y^2 + z^2")
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -606,6 +607,7 @@
|
||||||
|
|
||||||
<p>Image:
|
<p>Image:
|
||||||
<img id="img_eq" role="math" src="foo" alt="x^2 + y^2 + z^2">
|
<img id="img_eq" role="math" src="foo" alt="x^2 + y^2 + z^2">
|
||||||
|
<input type="image" id="input_img_eq" src="foo" alt="x^2 + y^2 + z^2">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>Text:
|
<p>Text:
|
||||||
|
|
|
@ -34,6 +34,7 @@ MOCHITEST_A11Y_FILES =\
|
||||||
test_groupbox.xul \
|
test_groupbox.xul \
|
||||||
test_iframe.html \
|
test_iframe.html \
|
||||||
test_img.html \
|
test_img.html \
|
||||||
|
test_invalid_img.xhtml \
|
||||||
test_invalidationlist.html \
|
test_invalidationlist.html \
|
||||||
test_list.html \
|
test_list.html \
|
||||||
test_map.html \
|
test_map.html \
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>invalid html img</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="../common.js"></script>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="../role.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
<![CDATA[
|
||||||
|
function doTest()
|
||||||
|
{
|
||||||
|
document.getElementsByTagName("img")[0].firstChild.data = "2";
|
||||||
|
|
||||||
|
var accTree = {
|
||||||
|
role: ROLE_TEXT_CONTAINER,
|
||||||
|
children: [ { role: ROLE_TEXT_LEAF } ]
|
||||||
|
};
|
||||||
|
testAccessibleTree("the_img", accTree);
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
addA11yLoadEvent(doTest);
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<a target="_blank"
|
||||||
|
title="use HyperTextAccessible for invalid img"
|
||||||
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=852129">
|
||||||
|
Mozilla Bug 852129
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test">
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<img id="the_img">1</img>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -918,7 +918,7 @@ nsInlineFrame::AccessibleType()
|
||||||
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
|
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
|
||||||
return a11y::eHTMLButtonType;
|
return a11y::eHTMLButtonType;
|
||||||
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
||||||
return a11y::eImageType;
|
return a11y::eHyperTextType;
|
||||||
if (tagAtom == nsGkAtoms::label) // Creat accessible for <label>
|
if (tagAtom == nsGkAtoms::label) // Creat accessible for <label>
|
||||||
return a11y::eHTMLLabelType;
|
return a11y::eHTMLLabelType;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче