Bug 895023: Null-check SVG image document's root frame, before dereferencing it. r=seth

This commit is contained in:
Daniel Holbert 2013-07-22 13:42:05 -07:00
parent 23f4dd7760
commit e6a283f714
5 changed files with 42 additions and 1 deletions

View File

@ -510,6 +510,9 @@ VectorImage::GetIntrinsicSize(nsSize* aSize)
return NS_ERROR_FAILURE;
nsIFrame* rootFrame = mSVGDocumentWrapper->GetRootLayoutFrame();
if (!rootFrame)
return NS_ERROR_FAILURE;
*aSize = nsSize(-1, -1);
nsIFrame::IntrinsicSize rfSize = rootFrame->GetIntrinsicSize();
if (rfSize.width.GetUnit() == eStyleUnit_Coord)
@ -529,6 +532,9 @@ VectorImage::GetIntrinsicRatio(nsSize* aRatio)
return NS_ERROR_FAILURE;
nsIFrame* rootFrame = mSVGDocumentWrapper->GetRootLayoutFrame();
if (!rootFrame)
return NS_ERROR_FAILURE;
*aRatio = rootFrame->GetIntrinsicRatio();
return NS_OK;
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!-- Test for a CSS background pointing to an SVG image that has "display:none"
on the root node. -->
<html>
<body>
<div style="width: 100px; height: 100px;
background-image: url('display-none.svg')">
</body>
</html>

View File

@ -0,0 +1,8 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
width="100" height="100" style="display: none">
<rect width="100%" height="100%" fill="red"/>
</svg>

After

Width:  |  Height:  |  Size: 280 B

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!-- Test for an <img> tag pointing to an SVG image that has "display:none"
on the root node. -->
<html>
<body>
<img src="display-none.svg">
</body>
</html>

View File

@ -3,7 +3,8 @@
# zoom/
include zoom/reftest.list
# Trivial background-image tests
# Background-image tests
== background-display-none-1.html about:blank
skip-if(B2G) == background-simple-1.html lime100x100-ref.html # bug 773482
== background-simple-2.html lime100x100-ref.html
@ -67,6 +68,7 @@ random == img-and-image-1.html img-and-image-1-ref.svg # bug 645267
== img-blobURI-1.html lime100x100-ref.html
random-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == img-blobURI-2.html lime100x100-ref.html
== img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html
== img-display-none-1.html about:blank
== img-dyn-1.html img-dyn-1-ref.html
== img-foreignObject-1.html lime100x100-ref.html