Bug 585867 part 3. Make AppendCSSValue infallible. r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Fri, 04 Mar 2011 12:28:57 -0500
changeset 63581 47487a9c4b111e6a41cb31695f2990b889ad5b16
parent 63580 a4b02f48bd0e570c3533c98ef132848bf2f33765
child 63582 f1762e209d6c9e3e7616217e6c16ad5c879571fd
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs585867
milestone2.0b13pre
Bug 585867 part 3. Make AppendCSSValue infallible. r=bzbarsky
layout/style/nsComputedDOMStyle.cpp
layout/style/nsDOMCSSValueList.cpp
layout/style/nsDOMCSSValueList.h
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -828,21 +828,17 @@ nsComputedDOMStyle::DoGetContent(nsIDOMC
     NS_ADDREF(*aValue = val);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   for (PRUint32 i = 0, i_end = content->ContentCount(); i < i_end; ++i) {
     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(val)) {
-      delete valueList;
-      delete val;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(val);
 
     const nsStyleContentData &data = content->ContentAt(i);
     switch (data.mType) {
       case eStyleContentType_String:
         {
           nsString str;
           nsStyleUtil::AppendEscapedCSSString(
             nsDependentString(data.mContent.mString), str);
@@ -937,28 +933,20 @@ nsComputedDOMStyle::DoGetCounterIncremen
     NS_ADDREF(*aValue = val);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   for (PRUint32 i = 0, i_end = content->CounterIncrementCount(); i < i_end; ++i) {
     nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(name)) {
-      delete valueList;
-      delete name;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(name);
 
     nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(value)) {
-      delete valueList;
-      delete value;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(value);
 
     const nsStyleCounterData *data = content->GetCounterIncrementAt(i);
     nsAutoString escaped;
     nsStyleUtil::AppendEscapedCSSIdent(data->mCounter, escaped);
     name->SetString(escaped);
     value->SetNumber(data->mValue); // XXX This should really be integer
   }
 
@@ -984,20 +972,18 @@ nsComputedDOMStyle::DoGetMozTransformOri
                   &nsComputedDOMStyle::GetFrameBoundsWidthForTransform);
   SetValueToCoord(height, display->mTransformOrigin[1], PR_FALSE,
                   &nsComputedDOMStyle::GetFrameBoundsHeightForTransform);
 
   /* Store things as a value list, fail if we can't get one. */
   nsRefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(PR_FALSE);
 
   /* Chain on width and height, fail if we can't. */
-  if (!valueList->AppendCSSValue(width))
-    return NS_ERROR_OUT_OF_MEMORY;
-  if (!valueList->AppendCSSValue(height))
-    return NS_ERROR_OUT_OF_MEMORY;
+  valueList->AppendCSSValue(width);
+  valueList->AppendCSSValue(height);
 
   valueList.forget(aValue);
   return NS_OK;
 }
 
 /* If the property is "none", hand back "none" wrapped in a value.
  * Otherwise, compute the aggregate transform matrix and hands it back in a
  * "matrix" wrapper.
@@ -1084,28 +1070,20 @@ nsComputedDOMStyle::DoGetCounterReset(ns
     NS_ADDREF(*aValue = val);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   for (PRUint32 i = 0, i_end = content->CounterResetCount(); i < i_end; ++i) {
     nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(name)) {
-      delete valueList;
-      delete name;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(name);
 
     nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(value)) {
-      delete valueList;
-      delete value;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(value);
 
     const nsStyleCounterData *data = content->GetCounterResetAt(i);
     nsAutoString escaped;
     nsStyleUtil::AppendEscapedCSSIdent(data->mCounter, escaped);
     name->SetString(escaped);
     value->SetNumber(data->mValue); // XXX This should really be integer
   }
 
@@ -1124,28 +1102,20 @@ nsComputedDOMStyle::DoGetQuotes(nsIDOMCS
     NS_ADDREF(*aValue = val);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   for (PRUint32 i = 0, i_end = quotes->QuotesCount(); i < i_end; ++i) {
     nsROCSSPrimitiveValue* openVal = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(openVal)) {
-      delete valueList;
-      delete openVal;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(openVal);
 
     nsROCSSPrimitiveValue* closeVal = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(closeVal)) {
-      delete valueList;
-      delete closeVal;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(closeVal);
 
     nsString s;
     nsStyleUtil::AppendEscapedCSSString(*quotes->OpenQuoteAt(i), s);
     openVal->SetString(s);
     s.Truncate();
     nsStyleUtil::AppendEscapedCSSString(*quotes->CloseQuoteAt(i), s);
     closeVal->SetString(s);
   }
@@ -1317,21 +1287,17 @@ nsComputedDOMStyle::GetBackgroundList(PR
                                       nsIDOMCSSValue** aResult)
 {
   const nsStyleBackground* bg = GetStyleBackground();
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   for (PRUint32 i = 0, i_end = bg->*aCount; i < i_end; ++i) {
     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(val)) {
-      delete val;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(val);
     val->SetIdent(nsCSSProps::ValueToKeywordEnum(bg->mLayers[i].*aMember,
                                                  aTable));
   }
 
   NS_ADDREF(*aResult = valueList);
   return NS_OK;
 }
 
@@ -1498,31 +1464,23 @@ nsresult
 nsComputedDOMStyle::GetImageRectString(nsIURI* aURI,
                                        const nsStyleSides& aCropRect,
                                        nsString& aString)
 {
   nsDOMCSSValueList* valueList = GetROCSSValueList(PR_TRUE);
 
   // <uri>
   nsROCSSPrimitiveValue *valURI = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(valURI)) {
-    delete valURI;
-    delete valueList;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(valURI);
   valURI->SetURI(aURI);
 
   // <top>, <right>, <bottom>, <left>
   NS_FOR_CSS_SIDES(side) {
     nsROCSSPrimitiveValue *valSide = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(valSide)) {
-      delete valSide;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(valSide);
     SetValueToCoord(valSide, aCropRect.Get(side), PR_FALSE);
   }
 
   nsAutoString argumentString;
   valueList->GetCssText(argumentString);
   delete valueList;
 
   aString = NS_LITERAL_STRING("-moz-image-rect(") +
@@ -1588,21 +1546,17 @@ nsresult
 nsComputedDOMStyle::DoGetBackgroundImage(nsIDOMCSSValue** aValue)
 {
   const nsStyleBackground* bg = GetStyleBackground();
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   for (PRUint32 i = 0, i_end = bg->mImageCount; i < i_end; ++i) {
     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(val)) {
-      delete val;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(val);
 
     const nsStyleImage& image = bg->mLayers[i].mImage;
     nsresult rv = SetValueToStyleImage(image, val);
     if (NS_FAILED(rv)) {
       delete valueList;
       return rv;
     }
   }
@@ -1637,35 +1591,23 @@ nsresult
 nsComputedDOMStyle::DoGetBackgroundPosition(nsIDOMCSSValue** aValue)
 {
   const nsStyleBackground* bg = GetStyleBackground();
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   for (PRUint32 i = 0, i_end = bg->mPositionCount; i < i_end; ++i) {
     nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
-    if (!valueList->AppendCSSValue(itemList)) {
-      delete valueList;
-      delete itemList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(itemList);
 
     nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
-    if (!itemList->AppendCSSValue(valX)) {
-      delete valueList;
-      delete valX;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    itemList->AppendCSSValue(valX);
 
     nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
-    if (!itemList->AppendCSSValue(valY)) {
-      delete valueList;
-      delete valY;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    itemList->AppendCSSValue(valY);
 
     const nsStyleBackground::Position &pos = bg->mLayers[i].mPosition;
 
     if (pos.mXPosition.mLength == 0) {
       valX->SetPercent(pos.mXPosition.mPercent);
     } else if (pos.mXPosition.mPercent == 0.0f) {
       valX->SetAppUnits(pos.mXPosition.mLength);
     } else {
@@ -1716,44 +1658,28 @@ nsComputedDOMStyle::DoGetMozBackgroundSi
       case nsStyleBackground::Size::eContain:
       case nsStyleBackground::Size::eCover: {
         NS_ABORT_IF_FALSE(size.mWidthType == size.mHeightType,
                           "unsynced types");
         nsCSSKeyword keyword = size.mWidthType == nsStyleBackground::Size::eContain
                              ? eCSSKeyword_contain
                              : eCSSKeyword_cover;
         nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
-        if (!valueList->AppendCSSValue(val)) {
-          delete valueList;
-          delete val;
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+        valueList->AppendCSSValue(val);
         val->SetIdent(keyword);
         break;
       }
       default: {
         nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
-        if (!valueList->AppendCSSValue(itemList)) {
-          delete valueList;
-          delete itemList;
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+        valueList->AppendCSSValue(itemList);
 
         nsROCSSPrimitiveValue* valX = GetROCSSPrimitiveValue();
-        if (!itemList->AppendCSSValue(valX)) {
-          delete valueList;
-          delete valX;
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+        itemList->AppendCSSValue(valX);
         nsROCSSPrimitiveValue* valY = GetROCSSPrimitiveValue();
-        if (!itemList->AppendCSSValue(valY)) {
-          delete valueList;
-          delete valY;
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+        itemList->AppendCSSValue(valY);
 
         if (size.mWidthType == nsStyleBackground::Size::eAuto) {
           valX->SetIdent(eCSSKeyword_auto);
         } else {
           NS_ABORT_IF_FALSE(size.mWidthType ==
                               nsStyleBackground::Size::eLengthPercentage,
                             "bad mWidthType");
           if (size.mWidth.mLength == 0 &&
@@ -1851,28 +1777,20 @@ nsComputedDOMStyle::DoGetBorderCollapse(
 }
 
 nsresult
 nsComputedDOMStyle::DoGetBorderSpacing(nsIDOMCSSValue** aValue)
 {
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   nsROCSSPrimitiveValue* xSpacing = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(xSpacing)) {
-    delete valueList;
-    delete xSpacing;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(xSpacing);
 
   nsROCSSPrimitiveValue* ySpacing = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(ySpacing)) {
-    delete valueList;
-    delete ySpacing;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(ySpacing);
 
   const nsStyleTableBorder *border = GetStyleTableBorder();
   xSpacing->SetAppUnits(border->mBorderSpacingX);
   ySpacing->SetAppUnits(border->mBorderSpacingY);
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
@@ -2246,29 +2164,20 @@ nsComputedDOMStyle::GetEllipseRadii(cons
     SetValueToCoord(val, radiusX, PR_TRUE);
 
     NS_ADDREF(*aValue = val);
     return NS_OK;
   } else {
     nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
     nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(valX)) {
-      delete valX;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(valX);
 
     nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(valY)) {
-      delete valY;
-      // valX deleted by valueList destructor
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(valY);
 
     SetValueToCoord(valX, radiusX, PR_TRUE);
     SetValueToCoord(valY, radiusY, PR_TRUE);
 
     NS_ADDREF(*aValue = valueList);
     return NS_OK;
   }
 }
@@ -2310,56 +2219,40 @@ nsComputedDOMStyle::GetCSSShadowArray(ns
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   for (nsCSSShadowItem *item = aArray->ShadowAt(0),
                    *item_end = item + aArray->Length();
        item < item_end; ++item) {
     nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
-    if (!valueList->AppendCSSValue(itemList)) {
-      delete itemList;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(itemList);
 
     // Color is either the specified shadow color or the foreground color
     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
-    if (!itemList->AppendCSSValue(val)) {
-      delete val;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    itemList->AppendCSSValue(val);
     nscolor shadowColor;
     if (item->mHasColor) {
       shadowColor = item->mColor;
     } else {
       shadowColor = aDefaultColor;
     }
     SetToRGBAColor(val, shadowColor);
 
     // Set the offsets, blur radius, and spread if available
     for (PRUint32 i = 0; i < shadowValuesLength; ++i) {
       val = GetROCSSPrimitiveValue();
-      if (!itemList->AppendCSSValue(val)) {
-        delete val;
-        delete valueList;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+      itemList->AppendCSSValue(val);
       val->SetAppUnits(item->*(shadowValues[i]));
     }
 
     if (item->mInset && aIsBoxShadow) {
       // This is an inset box-shadow
       val = GetROCSSPrimitiveValue();
-      if (!itemList->AppendCSSValue(val)) {
-        delete val;
-        delete valueList;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+      itemList->AppendCSSValue(val);
       val->SetIdent(
         nsCSSProps::ValueToKeywordEnum(NS_STYLE_BOX_SHADOW_INSET,
                                        nsCSSProps::kBoxShadowTypeKTable));
     }
   }
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
@@ -2694,61 +2587,40 @@ nsComputedDOMStyle::DoGetCursor(nsIDOMCS
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   const nsStyleUserInterface *ui = GetStyleUserInterface();
 
   for (nsCursorImage *item = ui->mCursorArray,
          *item_end = ui->mCursorArray + ui->mCursorArrayLength;
        item < item_end; ++item) {
     nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
-    if (!valueList->AppendCSSValue(itemList)) {
-      delete itemList;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(itemList);
 
     nsCOMPtr<nsIURI> uri;
     item->GetImage()->GetURI(getter_AddRefs(uri));
 
     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
-    if (!itemList->AppendCSSValue(val)) {
-      delete val;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    itemList->AppendCSSValue(val);
     val->SetURI(uri);
 
     if (item->mHaveHotspot) {
       nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
-      if (!itemList->AppendCSSValue(valX)) {
-        delete valX;
-        delete valueList;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-
+      itemList->AppendCSSValue(valX);
       nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
-      if (!itemList->AppendCSSValue(valY)) {
-        delete valY;
-        delete valueList;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+      itemList->AppendCSSValue(valY);
 
       valX->SetNumber(item->mHotspotX);
       valY->SetNumber(item->mHotspotY);
     }
   }
 
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
   val->SetIdent(nsCSSProps::ValueToKeywordEnum(ui->mCursor,
                                                nsCSSProps::kCursorKTable));
-  if (!valueList->AppendCSSValue(val)) {
-    delete valueList;
-    delete val;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(val);
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
 
 nsresult
 nsComputedDOMStyle::DoGetAppearance(nsIDOMCSSValue** aValue)
 {
@@ -2859,75 +2731,51 @@ nsComputedDOMStyle::DoGetBorderImage(nsI
     NS_ADDREF(*aValue = valNone);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
   // uri
   nsROCSSPrimitiveValue *valURI = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(valURI)) {
-    delete valURI;
-    delete valueList;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(valURI);
   nsCOMPtr<nsIURI> uri;
   border->GetBorderImage()->GetURI(getter_AddRefs(uri));
   valURI->SetURI(uri);
 
   // four split numbers
   NS_FOR_CSS_SIDES(side) {
     nsROCSSPrimitiveValue *valSplit = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(valSplit)) {
-      delete valSplit;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(valSplit);
     SetValueToCoord(valSplit, border->mBorderImageSplit.Get(side), PR_TRUE);
   }
 
   // copy of border-width
   if (border->mHaveBorderImageWidth) {
     nsROCSSPrimitiveValue *slash = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(slash)) {
-      delete slash;
-      delete valueList;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(slash);
     slash->SetString(NS_LITERAL_STRING("/"));
     NS_FOR_CSS_SIDES(side) {
       nsROCSSPrimitiveValue *borderWidth = GetROCSSPrimitiveValue();
-      if (!valueList->AppendCSSValue(borderWidth)) {
-        delete borderWidth;
-        delete valueList;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+      valueList->AppendCSSValue(borderWidth);
       nscoord width = GetStyleBorder()->mBorderImageWidth.side(side);
       borderWidth->SetAppUnits(width);
     }
   }
 
   // first keyword
   nsROCSSPrimitiveValue *keyword = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(keyword)) {
-    delete keyword;
-    delete valueList;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(keyword);
   keyword->SetIdent(
     nsCSSProps::ValueToKeywordEnum(GetStyleBorder()->mBorderImageHFill,
                                    nsCSSProps::kBorderImageKTable));
 
   // second keyword
   nsROCSSPrimitiveValue *keyword2 = GetROCSSPrimitiveValue();
-  if (!valueList->AppendCSSValue(keyword2)) {
-    delete keyword2;
-    delete valueList;
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  valueList->AppendCSSValue(keyword2);
   keyword2->SetIdent(
     nsCSSProps::ValueToKeywordEnum(GetStyleBorder()->mBorderImageVFill,
                                    nsCSSProps::kBorderImageKTable));
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
 
@@ -3564,23 +3412,17 @@ nsComputedDOMStyle::GetBorderColorsFor(m
     if (borderColors) {
       nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
       do {
         nsROCSSPrimitiveValue *primitive = GetROCSSPrimitiveValue();
 
         SetToRGBAColor(primitive, borderColors->mColor);
 
-        PRBool success = valueList->AppendCSSValue(primitive);
-        if (!success) {
-          delete valueList;
-          delete primitive;
-
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+        valueList->AppendCSSValue(primitive);
         borderColors = borderColors->mNext;
       } while (borderColors);
 
       NS_ADDREF(*aValue = valueList);
       return NS_OK;
     }
   }
 
@@ -3899,28 +3741,20 @@ nsComputedDOMStyle::GetSVGPaintFor(PRBoo
   {
     SetToRGBAColor(val, paint->mPaint.mColor);
     break;
   }
   case eStyleSVGPaintType_Server:
   {
     nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
 
-    if (!valueList->AppendCSSValue(val)) {
-      delete valueList;
-      delete val;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(val);
 
     nsROCSSPrimitiveValue* fallback = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(fallback)) {
-      delete valueList;
-      delete fallback;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(fallback);
 
     val->SetURI(paint->mPaint.mPaintServer);
     SetToRGBAColor(fallback, paint->mFallbackColor);
 
     NS_ADDREF(*aValue = valueList);
     return NS_OK;
   }
   }
@@ -4000,21 +3834,17 @@ nsComputedDOMStyle::DoGetStrokeDasharray
     NS_ADDREF(*aValue = val);
     return NS_OK;
   }
 
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   for (PRUint32 i = 0; i < svg->mStrokeDasharrayLength; i++) {
     nsROCSSPrimitiveValue* dash = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(dash)) {
-      delete valueList;
-      delete dash;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(dash);
 
     SetValueToCoord(dash, svg->mStrokeDasharray[i], PR_TRUE);
   }
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
 
@@ -4322,21 +4152,17 @@ nsComputedDOMStyle::DoGetTransitionDelay
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   NS_ABORT_IF_FALSE(display->mTransitionDelayCount > 0,
                     "first item must be explicit");
   PRUint32 i = 0;
   do {
     const nsTransition *transition = &display->mTransitions[i];
     nsROCSSPrimitiveValue* delay = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(delay)) {
-      delete valueList;
-      delete delay;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(delay);
     delay->SetTime((float)transition->GetDelay() / (float)PR_MSEC_PER_SEC);
   } while (++i < display->mTransitionDelayCount);
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
 
 nsresult
@@ -4347,21 +4173,17 @@ nsComputedDOMStyle::DoGetTransitionDurat
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   NS_ABORT_IF_FALSE(display->mTransitionDurationCount > 0,
                     "first item must be explicit");
   PRUint32 i = 0;
   do {
     const nsTransition *transition = &display->mTransitions[i];
     nsROCSSPrimitiveValue* duration = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(duration)) {
-      delete valueList;
-      delete duration;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(duration);
 
     duration->SetTime((float)transition->GetDuration() / (float)PR_MSEC_PER_SEC);
   } while (++i < display->mTransitionDurationCount);
 
   NS_ADDREF(*aValue = valueList);
   return NS_OK;
 }
 
@@ -4373,21 +4195,17 @@ nsComputedDOMStyle::DoGetTransitionPrope
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   NS_ABORT_IF_FALSE(display->mTransitionPropertyCount > 0,
                     "first item must be explicit");
   PRUint32 i = 0;
   do {
     const nsTransition *transition = &display->mTransitions[i];
     nsROCSSPrimitiveValue* property = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(property)) {
-      delete valueList;
-      delete property;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(property);
     nsCSSProperty cssprop = transition->GetProperty();
     if (cssprop == eCSSPropertyExtra_all_properties)
       property->SetIdent(eCSSKeyword_all);
     else if (cssprop == eCSSPropertyExtra_no_properties)
       property->SetIdent(eCSSKeyword_none);
     else if (cssprop == eCSSProperty_UNKNOWN)
     {
       nsAutoString escaped;
@@ -4411,21 +4229,17 @@ nsComputedDOMStyle::DoGetTransitionTimin
   nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
 
   NS_ABORT_IF_FALSE(display->mTransitionTimingFunctionCount > 0,
                     "first item must be explicit");
   PRUint32 i = 0;
   do {
     const nsTransition *transition = &display->mTransitions[i];
     nsROCSSPrimitiveValue* timingFunction = GetROCSSPrimitiveValue();
-    if (!valueList->AppendCSSValue(timingFunction)) {
-      delete valueList;
-      delete timingFunction;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    valueList->AppendCSSValue(timingFunction);
 
     // set the value from the cubic-bezier control points
     // (We could try to regenerate the keywords if we want.)
     const nsTimingFunction& tf = transition->GetTimingFunction();
     timingFunction->SetString(
       nsPrintfCString(64, "cubic-bezier(%f, %f, %f, %f)",
                           tf.mX1, tf.mY1, tf.mX2, tf.mY2));
   } while (++i < display->mTransitionTimingFunctionCount);
--- a/layout/style/nsDOMCSSValueList.cpp
+++ b/layout/style/nsDOMCSSValueList.cpp
@@ -60,28 +60,28 @@ DOMCI_DATA(CSSValueList, nsDOMCSSValueLi
 // QueryInterface implementation for nsDOMCSSValueList
 NS_INTERFACE_MAP_BEGIN(nsDOMCSSValueList)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSValueList)
 NS_INTERFACE_MAP_END
 
-PRBool
+void
 nsDOMCSSValueList::AppendCSSValue(nsIDOMCSSValue* aValue)
 {
-  return mCSSValues.AppendObject(aValue);
+  mCSSValues.AppendElement(aValue);
 }
 
 // nsIDOMCSSValueList
 
 NS_IMETHODIMP
 nsDOMCSSValueList::GetLength(PRUint32* aLength)
 {
-  *aLength = mCSSValues.Count();
+  *aLength = mCSSValues.Length();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMCSSValueList::Item(PRUint32 aIndex, nsIDOMCSSValue **aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
@@ -93,17 +93,17 @@ nsDOMCSSValueList::Item(PRUint32 aIndex,
 
 // nsIDOMCSSValue
 
 NS_IMETHODIMP
 nsDOMCSSValueList::GetCssText(nsAString& aCssText)
 {
   aCssText.Truncate();
 
-  PRUint32 count = mCSSValues.Count();
+  PRUint32 count = mCSSValues.Length();
 
   nsAutoString separator;
   if (mCommaDelimited) {
     separator.AssignLiteral(", ");
   }
   else {
     separator.Assign(PRUnichar(' '));
   }
--- a/layout/style/nsDOMCSSValueList.h
+++ b/layout/style/nsDOMCSSValueList.h
@@ -58,24 +58,22 @@ public:
   NS_DECL_NSIDOMCSSVALUE
 
   // nsDOMCSSValueList
   nsDOMCSSValueList(PRBool aCommaDelimited, PRBool aReadonly);
   virtual ~nsDOMCSSValueList();
 
   /**
    * Adds a value to this list.
-   * @retval PR_TRUE Adding the value succeeded
-   * @retval PR_FALSE The value could not be added (Out of memory)
    */
-  PRBool AppendCSSValue(nsIDOMCSSValue* aValue);
+  void AppendCSSValue(nsIDOMCSSValue* aValue);
 
   nsIDOMCSSValue* GetItemAt(PRUint32 aIndex)
   {
-    return mCSSValues.SafeObjectAt(aIndex);
+    return mCSSValues.SafeElementAt(aIndex, nsnull);
   }
 
   static nsDOMCSSValueList* FromSupports(nsISupports* aSupports)
   {
 #ifdef DEBUG
     {
       nsCOMPtr<nsIDOMCSSValueList> list_qi = do_QueryInterface(aSupports);
 
@@ -92,13 +90,13 @@ public:
 
 private:
   PRPackedBool                mCommaDelimited;  // some value lists use a comma
                                                 // as the delimiter, some just use
                                                 // spaces.
 
   PRPackedBool                mReadonly;    // Are we read-only?
 
-  nsCOMArray<nsIDOMCSSValue>  mCSSValues;
+  InfallibleTArray<nsCOMPtr<nsIDOMCSSValue> > mCSSValues;
 };
 
 
 #endif /* nsDOMCSSValueList_h___ */