Change IsPercentageAware (which tests whether an inline box's width depends on the width of its container) to check the correct general statement of when the width of a replaced element depends on its container's width, and in doing so avoid depending on the notion of percentage intrinsic size. (Bug 611099) r=dholbert
authorL. David Baron <dbaron@dbaron.org>
Sun, 12 Jun 2011 18:52:32 -0700
changeset 70943 c07445f34e92
parent 70942 db0bcc6ab526
child 70944 58fe3ede72f8
push id20456
push userdbaron@mozilla.com
push dateMon, 13 Jun 2011 01:53:02 +0000
treeherdermozilla-central@eab02b0b7c7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs611099
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Change IsPercentageAware (which tests whether an inline box's width depends on the width of its container) to check the correct general statement of when the width of a replaced element depends on its container's width, and in doing so avoid depending on the notion of percentage intrinsic size. (Bug 611099) r=dholbert Needed to help CSS 2.1 meet Proposed Recommendation entrance criteria.
layout/generic/nsLineLayout.cpp
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -697,24 +697,32 @@ IsPercentageAware(const nsIFrame* aFrame
         disp->mDisplay == NS_STYLE_DISPLAY_INLINE_TABLE ||
         fType == nsGkAtoms::HTMLButtonControlFrame ||
         fType == nsGkAtoms::gfxButtonControlFrame ||
         fType == nsGkAtoms::fieldSetFrame ||
         fType == nsGkAtoms::comboboxDisplayFrame) {
       return PR_TRUE;
     }
 
-    // Handle SVG, which doesn't map width/height into style
-    if ((
-         fType == nsGkAtoms::svgOuterSVGFrame ||
-         fType == nsGkAtoms::imageFrame ||
-         fType == nsGkAtoms::subDocumentFrame) &&
-        const_cast<nsIFrame*>(aFrame)->GetIntrinsicSize().width.GetUnit() ==
-        eStyleUnit_Percent) {
-      return PR_TRUE;
+    // Per CSS 2.1, section 10.3.2:
+    //   If 'height' and 'width' both have computed values of 'auto' and
+    //   the element has an intrinsic ratio but no intrinsic height or
+    //   width and the containing block's width does not itself depend
+    //   on the replaced element's width, then the used value of 'width'
+    //   is calculated from the constraint equation used for
+    //   block-level, non-replaced elements in normal flow. 
+    nsIFrame *f = const_cast<nsIFrame*>(aFrame);
+    if (f->GetIntrinsicRatio() != nsSize(0, 0) &&
+        // Some percents are treated like 'auto', so check != coord
+        pos->mHeight.GetUnit() != eStyleUnit_Coord) {
+      const nsIFrame::IntrinsicSize &intrinsicSize = f->GetIntrinsicSize();
+      if (intrinsicSize.width.GetUnit() == eStyleUnit_None &&
+          intrinsicSize.height.GetUnit() == eStyleUnit_None) {
+        return PR_TRUE;
+      }
     }
   }
 
   return PR_FALSE;
 }
 
 nsresult
 nsLineLayout::ReflowFrame(nsIFrame* aFrame,