mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
4f07f79b3b
commit
9ee7f78167
@ -2112,6 +2112,14 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
|
||||
ENameValueFlag
|
||||
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);
|
||||
if (!aName.IsEmpty())
|
||||
return nameFlag;
|
||||
@ -2123,7 +2131,7 @@ HyperTextAccessible::NativeName(nsString& aName)
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
|
||||
aName.CompressWhitespace();
|
||||
|
||||
return eNameOK;
|
||||
return hasImgAlt ? eNoNameOnPurpose : eNameOK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -208,6 +208,7 @@
|
||||
|
||||
// Test equation image
|
||||
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")
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -606,6 +607,7 @@
|
||||
|
||||
<p>Image:
|
||||
<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>Text:
|
||||
|
@ -34,6 +34,7 @@ MOCHITEST_A11Y_FILES =\
|
||||
test_groupbox.xul \
|
||||
test_iframe.html \
|
||||
test_img.html \
|
||||
test_invalid_img.xhtml \
|
||||
test_invalidationlist.html \
|
||||
test_list.html \
|
||||
test_map.html \
|
||||
|
50
accessible/tests/mochitest/tree/test_invalid_img.xhtml
Normal file
50
accessible/tests/mochitest/tree/test_invalid_img.xhtml
Normal file
@ -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 ... />
|
||||
return a11y::eHTMLButtonType;
|
||||
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
||||
return a11y::eImageType;
|
||||
return a11y::eHyperTextType;
|
||||
if (tagAtom == nsGkAtoms::label) // Creat accessible for <label>
|
||||
return a11y::eHTMLLabelType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user