Fixing bug 382325. SVG should fall back to 300px x 150px as per CSS 2.1 section 10.3.2. r=longsonr@gmail.com, sr=tor@acm.org, a1.9=beltzner@mozilla.com
authorjwatt@jwatt.org
Fri, 25 Jan 2008 10:53:24 -0800
changeset 10674 ac3216416288c61e40183791afcd4f6e9dee9258
parent 10673 540e24ed100a8353a7c635afe746982c04dcade2
child 10675 5865353f6eaa6480339493ba153b0c4ebb4e6766
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerslongsonr, tor
bugs382325
milestone1.9b3pre
Fixing bug 382325. SVG should fall back to 300px x 150px as per CSS 2.1 section 10.3.2. r=longsonr@gmail.com, sr=tor@acm.org, a1.9=beltzner@mozilla.com
layout/svg/base/src/nsSVGOuterSVGFrame.cpp
--- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
@@ -223,17 +223,19 @@ nsSVGOuterSVGFrame::GetPrefWidth(nsIRend
 {
   nscoord result;
   DISPLAY_PREF_WIDTH(this, result);
 
   nsSVGSVGElement *svg = static_cast<nsSVGSVGElement*>(mContent);
   nsSVGLength2 &width = svg->mLengthAttributes[nsSVGSVGElement::WIDTH];
 
   if (width.IsPercentage()) {
-    result = nscoord(0);
+    // If we're being called then our containing block's width depends on our
+    // width - fall back to 300px as required by CSS 2.1 section 10.3.2:
+    result = nsPresContext::CSSPixelsToAppUnits(300);
   } else {
     result = nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(svg));
     if (result < 0) {
       result = nscoord(0);
     }
   }
 
   return result;