Bug 799207: Reduce severity of assertion that checks baseline of flex item against sentinel value. r=dbaron
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 16 Oct 2012 19:04:33 -0700
changeset 110634 16adea14324fcb0ee3f255cbec28e01565a39026
parent 110633 a70b58fcf0597681afbe11dce919efbe1851e632
child 110635 f8e8868022316daaebb834879d01f78061710894
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdbaron
bugs799207
milestone19.0a1
Bug 799207: Reduce severity of assertion that checks baseline of flex item against sentinel value. r=dbaron
layout/generic/crashtests/799207-1.html
layout/generic/crashtests/799207-2.html
layout/generic/crashtests/crashtests.list
layout/generic/nsFlexContainerFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/799207-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="display: flex;"><div style="margin-top: 17179869184em; min-height: 17179869184em; align-self: baseline;"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/799207-2.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="display: flex;"><div style="margin-top: -9999999999999px; height: 0; font-size: 0; align-self: baseline;"></div></div>
+</body>
+</html>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -390,8 +390,10 @@ load first-letter-638937.html
 load first-letter-638937-2.html
 test-pref(layout.css.flexbox.enabled,true) load 737313-1.html
 test-pref(layout.css.flexbox.enabled,true) load 737313-2.html
 test-pref(layout.css.flexbox.enabled,true) load 737313-3.html
 load 762764-1.html
 load 786740-1.html
 asserts(8) test-pref(layout.css.flexbox.enabled,true) load 798020-1.html
 test-pref(layout.css.flexbox.enabled,true) load 798235-1.html
+test-pref(layout.css.flexbox.enabled,true) load 799207-1.html
+asserts(12) test-pref(layout.css.flexbox.enabled,true) load 799207-2.html
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1550,17 +1550,18 @@ nscoord
 SingleLineCrossAxisPositionTracker::
   GetBaselineOffsetFromCrossStart(const FlexItem& aItem) const
 {
   Side crossStartSide = kAxisOrientationToSidesMap[mAxis][eAxisEdge_Start];
 
   // XXXdholbert This assumes cross axis is Top-To-Bottom.
   // For bottom-to-top support, probably want to make this depend on
   //   AxisGrowsInPositiveDirection(mAxis)
-  return aItem.GetAscent() + aItem.GetMarginComponentForSide(crossStartSide);
+  return NSCoordSaturatingAdd(aItem.GetAscent(),
+                              aItem.GetMarginComponentForSide(crossStartSide));
 }
 
 void
 SingleLineCrossAxisPositionTracker::
   ResolveStretchedCrossSize(FlexItem& aItem)
 {
   // We stretch IFF we are align-self:stretch, have no auto margins in
   // cross axis, and have cross-axis size property == "auto". If any of those
@@ -1651,18 +1652,19 @@ SingleLineCrossAxisPositionTracker::
     case NS_STYLE_ALIGN_ITEMS_CENTER:
       // Note: If cross-size is odd, the "after" space will get the extra unit.
       mPosition +=
         (mLineCrossSize -
          (aItem.GetCrossSize() +
           aItem.GetMarginBorderPaddingSizeInAxis(mAxis))) / 2;
       break;
     case NS_STYLE_ALIGN_ITEMS_BASELINE:
-      MOZ_ASSERT(mCrossStartToFurthestBaseline != nscoord_MIN,
-                 "using uninitialized baseline offset");
+      NS_WARN_IF_FALSE(mCrossStartToFurthestBaseline != nscoord_MIN,
+                       "using uninitialized baseline offset (or working with "
+                       "content that has bogus huge values)");
       MOZ_ASSERT(mCrossStartToFurthestBaseline >=
                  GetBaselineOffsetFromCrossStart(aItem),
                  "failed at finding largest ascent");
 
       // Advance so that aItem's baseline is aligned with
       // largest baseline offset.
       mPosition += (mCrossStartToFurthestBaseline -
                     GetBaselineOffsetFromCrossStart(aItem));