mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 605626 - Prevent assertion when displaying an image that has no width or height r=dholbert a=roc
This commit is contained in:
parent
c6530ef70a
commit
33671ddf9d
@ -115,7 +115,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gfxMatrix GetImageTransform();
|
gfxMatrix GetImageTransform(PRInt32 aNativeWidth, PRInt32 aNativeHeight);
|
||||||
|
|
||||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||||
|
|
||||||
@ -193,20 +193,16 @@ nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfxMatrix
|
gfxMatrix
|
||||||
nsSVGImageFrame::GetImageTransform()
|
nsSVGImageFrame::GetImageTransform(PRInt32 aNativeWidth, PRInt32 aNativeHeight)
|
||||||
{
|
{
|
||||||
float x, y, width, height;
|
float x, y, width, height;
|
||||||
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
||||||
element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
||||||
|
|
||||||
PRInt32 nativeWidth, nativeHeight;
|
|
||||||
mImageContainer->GetWidth(&nativeWidth);
|
|
||||||
mImageContainer->GetHeight(&nativeHeight);
|
|
||||||
|
|
||||||
gfxMatrix viewBoxTM =
|
gfxMatrix viewBoxTM =
|
||||||
nsSVGUtils::GetViewBoxTransform(element,
|
nsSVGUtils::GetViewBoxTransform(element,
|
||||||
width, height,
|
width, height,
|
||||||
0, 0, nativeWidth, nativeHeight,
|
0, 0, aNativeWidth, aNativeHeight,
|
||||||
element->mPreserveAspectRatio);
|
element->mPreserveAspectRatio);
|
||||||
|
|
||||||
return viewBoxTM * gfxMatrix().Translate(gfxPoint(x, y)) * GetCanvasTM();
|
return viewBoxTM * gfxMatrix().Translate(gfxPoint(x, y)) * GetCanvasTM();
|
||||||
@ -241,6 +237,14 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mImageContainer) {
|
if (mImageContainer) {
|
||||||
|
PRInt32 nativeWidth, nativeHeight;
|
||||||
|
mImageContainer->GetWidth(&nativeWidth);
|
||||||
|
mImageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
|
if (nativeWidth == 0 || nativeHeight == 0) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
|
if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
|
||||||
// <svg:image> not supported for SVG images yet.
|
// <svg:image> not supported for SVG images yet.
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@ -261,7 +265,8 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||||||
|
|
||||||
// NOTE: We need to cancel out the effects of Full-Page-Zoom, or else
|
// NOTE: We need to cancel out the effects of Full-Page-Zoom, or else
|
||||||
// it'll get applied an extra time by DrawSingleUnscaledImage.
|
// it'll get applied an extra time by DrawSingleUnscaledImage.
|
||||||
ctx->Multiply(GetImageTransform().Scale(pageZoomFactor, pageZoomFactor));
|
ctx->Multiply(GetImageTransform(nativeWidth, nativeHeight).
|
||||||
|
Scale(pageZoomFactor, pageZoomFactor));
|
||||||
|
|
||||||
// fill-opacity doesn't affect <image>, so if we're allowed to
|
// fill-opacity doesn't affect <image>, so if we're allowed to
|
||||||
// optimize group opacity, the opacity used for compositing the
|
// optimize group opacity, the opacity used for compositing the
|
||||||
@ -313,7 +318,11 @@ nsSVGImageFrame::GetFrameForPoint(const nsPoint &aPoint)
|
|||||||
mImageContainer->GetWidth(&nativeWidth);
|
mImageContainer->GetWidth(&nativeWidth);
|
||||||
mImageContainer->GetHeight(&nativeHeight);
|
mImageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
if (!nsSVGUtils::HitTestRect(GetImageTransform(),
|
if (nativeWidth == 0 || nativeHeight == 0) {
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nsSVGUtils::HitTestRect(GetImageTransform(nativeWidth, nativeHeight),
|
||||||
0, 0, nativeWidth, nativeHeight,
|
0, 0, nativeWidth, nativeHeight,
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
||||||
|
3
layout/svg/crashtests/605626-1.svg
Normal file
3
layout/svg/crashtests/605626-1.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<image width="10" height="10" xlink:href="data:text/plain,g"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 154 B |
@ -92,3 +92,4 @@ load 522394-2.svg
|
|||||||
load 522394-3.svg
|
load 522394-3.svg
|
||||||
load extref-test-1.xhtml
|
load extref-test-1.xhtml
|
||||||
load 566216-1.svg
|
load 566216-1.svg
|
||||||
|
load 605626-1.svg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user