Bug 1045532 - Part 1 - Drop <picture> sources with unsupported types. r=bz

This commit is contained in:
John Schoenick 2014-10-08 13:53:24 -07:00
parent 491a0b280e
commit c6ac48160b

View File

@ -28,6 +28,7 @@
#include "nsFocusManager.h"
#include "mozilla/dom/HTMLFormElement.h"
#include "nsAttrValueOrString.h"
#include "imgLoader.h"
// Responsive images!
#include "mozilla/dom/HTMLSourceElement.h"
@ -1095,10 +1096,17 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
MOZ_ASSERT(IsPreviousSibling(aSourceNode, this));
MOZ_ASSERT(pictureEnabled);
// Check media and type
HTMLSourceElement *src = static_cast<HTMLSourceElement*>(aSourceNode);
if (!src->MatchesCurrentMedia()) {
return false;
}
nsAutoString type;
if (aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type) &&
!imgLoader::SupportImageWithMimeType(NS_ConvertUTF16toUTF8(type).get())) {
return false;
}
} else if (aSourceNode->Tag() == nsGkAtoms::img) {
// Otherwise this is the <img> tag itself
MOZ_ASSERT(aSourceNode == this);