Bug 938772. Don't give the anonymous poster <img> an empty 'src' attribute if we don't have a 'poster' attribute. r=cpearce

--HG--
extra : rebase_source : dbd99829562f46185e82f530d81a2feb80d22c38
This commit is contained in:
Robert O'Callahan 2013-12-04 14:06:16 +13:00
Родитель 3f1a07e93b
Коммит 38b9c96ddb
4 изменённых файлов: 38 добавлений и 14 удалений

Просмотреть файл

@ -92,8 +92,7 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
// And now have it update its internal state
element->UpdateState(false);
nsresult res = UpdatePosterSource(false);
NS_ENSURE_SUCCESS(res,res);
UpdatePosterSource(false);
if (!aElements.AppendElement(mPosterImage))
return NS_ERROR_OUT_OF_MEMORY;
@ -592,20 +591,22 @@ nsVideoFrame::GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext)
nsPresContext::CSSPixelsToAppUnits(size.height));
}
nsresult
void
nsVideoFrame::UpdatePosterSource(bool aNotify)
{
NS_ASSERTION(HasVideoElement(), "Only call this on <video> elements.");
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::poster)) {
nsAutoString posterStr;
element->GetPoster(posterStr);
nsresult res = mPosterImage->SetAttr(kNameSpaceID_None,
mPosterImage->SetAttr(kNameSpaceID_None,
nsGkAtoms::src,
posterStr,
aNotify);
NS_ENSURE_SUCCESS(res,res);
return NS_OK;
} else {
mPosterImage->UnsetAttr(kNameSpaceID_None, nsGkAtoms::poster, aNotify);
}
}
NS_IMETHODIMP
@ -614,8 +615,7 @@ nsVideoFrame::AttributeChanged(int32_t aNameSpaceID,
int32_t aModType)
{
if (aAttribute == nsGkAtoms::poster && HasVideoElement()) {
nsresult res = UpdatePosterSource(true);
NS_ENSURE_SUCCESS(res,res);
UpdatePosterSource(true);
}
return nsContainerFrame::AttributeChanged(aNameSpaceID,
aAttribute,

Просмотреть файл

@ -112,7 +112,7 @@ protected:
// Sets the mPosterImage's src attribute to be the video's poster attribute,
// if we're the frame for a video element. Only call on frames for video
// elements, not for frames for audio elements.
nsresult UpdatePosterSource(bool aNotify);
void UpdatePosterSource(bool aNotify);
virtual ~nsVideoFrame();

Просмотреть файл

@ -79,6 +79,7 @@ support-files = bug633762_iframe.html
[test_bug831780.html]
[test_bug841361.html]
[test_bug904810.html]
[test_bug938772.html]
[test_contained_plugin_transplant.html]
[test_image_selection.html]
[test_image_selection_2.html]

Просмотреть файл

@ -0,0 +1,23 @@
<!doctype html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=938772
-->
<title>Test for Bug 938772</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938772">Mozilla Bug 938772</a>
<p id="display"></p>
<iframe id="i"
src="data:text/html,<base href='http://basetag/basetag'><video id='v' onerror='v.failed=true'></video>"></iframe>
<pre id="test">
<script>
SimpleTest.waitForExplicitFinish();
i.onload = function() {
ok(!i.contentDocument.getElementById("v").failed,
"Check whether an error was reported");
SimpleTest.finish();
};
</script>