diff --git a/accessible/src/generic/HyperTextAccessible.cpp b/accessible/src/generic/HyperTextAccessible.cpp index 94d55192526..28b0c91dd65 100644 --- a/accessible/src/generic/HyperTextAccessible.cpp +++ b/accessible/src/generic/HyperTextAccessible.cpp @@ -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 diff --git a/accessible/tests/mochitest/name/test_general.html b/accessible/tests/mochitest/name/test_general.html index d28626ae321..737e523bb6b 100644 --- a/accessible/tests/mochitest/name/test_general.html +++ b/accessible/tests/mochitest/name/test_general.html @@ -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 @@
Image: +
Text: diff --git a/accessible/tests/mochitest/tree/Makefile.in b/accessible/tests/mochitest/tree/Makefile.in index 9631b3db8f9..900615a966d 100644 --- a/accessible/tests/mochitest/tree/Makefile.in +++ b/accessible/tests/mochitest/tree/Makefile.in @@ -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 \ diff --git a/accessible/tests/mochitest/tree/test_invalid_img.xhtml b/accessible/tests/mochitest/tree/test_invalid_img.xhtml new file mode 100644 index 00000000000..14ada63224e --- /dev/null +++ b/accessible/tests/mochitest/tree/test_invalid_img.xhtml @@ -0,0 +1,50 @@ + +
+++ + 1 + + diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index c6f905d9e0b..755478efe1a 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -918,7 +918,7 @@ nsInlineFrame::AccessibleType() if (tagAtom == nsGkAtoms::input) // Broken return a11y::eHTMLButtonType; if (tagAtom == nsGkAtoms::img) // Create accessible for broken - return a11y::eImageType; + return a11y::eHyperTextType; if (tagAtom == nsGkAtoms::label) // Creat accessible for