Bug 897491 - Update the display when the alt attribute of an image is added or removed. r=bz

This commit is contained in:
Michael Harrison 2013-08-21 08:44:14 -04:00
parent e1a0ab9d61
commit a5fb538393
6 changed files with 52 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "nsMappedAttributes.h"
#include "nsSize.h"
#include "nsIDocument.h"
#include "nsIDOMMutationEvent.h"
#include "nsIScriptContext.h"
#include "nsIURL.h"
#include "nsIIOService.h"
@ -251,6 +252,11 @@ HTMLImageElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
if (aAttribute == nsGkAtoms::usemap ||
aAttribute == nsGkAtoms::ismap) {
NS_UpdateHint(retval, NS_STYLE_HINT_FRAMECHANGE);
} else if (aAttribute == nsGkAtoms::alt) {
if (aModType == nsIDOMMutationEvent::ADDITION ||
aModType == nsIDOMMutationEvent::REMOVAL) {
NS_UpdateHint(retval, NS_STYLE_HINT_FRAMECHANGE);
}
}
return retval;
}

View File

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html>
<body>
<img id="img1" src="about:blank" alt="alt1">
<img id="img2" src="about:blank">
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<body>
<img id="img1" src="about:blank">
<img id="img2" src="about:blank" alt="alt2">
<script>
function doTest() {
document.getElementById("img1").setAttribute("alt", "alt1");
document.getElementById("img2").removeAttribute("alt");
document.documentElement.removeAttribute("class");
}
window.addEventListener("load", doTest, false);
</script>
</body>
</html>

View File

@ -0,0 +1,7 @@
<!--quirks mode test-->
<html>
<body>
<img id="img1" src="about:blank" alt="alt1">
<img id="img2" src="about:blank">
</body>
</html>

View File

@ -0,0 +1,15 @@
<!--quirks mode test-->
<html class="reftest-wait">
<body>
<img id="img1" src="about:blank">
<img id="img2" src="about:blank" alt="alt2">
<script>
function doTest() {
document.getElementById("img1").setAttribute("alt", "alt1");
document.getElementById("img2").removeAttribute("alt");
document.documentElement.removeAttribute("class");
}
window.addEventListener("load", doTest, false);
</script>
</body>
</html>

View File

@ -1772,3 +1772,5 @@ test-pref(layout.css.flexbox.enabled,true) == 849407-1.html 849407-1-ref.html
== 883987-1f.html 883987-1-ref.html
== 890495-1.html 890495-1-ref.html
== 894931-1.html 894931-1-ref.html
== 897491-1.html 897491-1-ref.html
== 897491-2.html 897491-2-ref.html