Bug 773500 Part 1:Store z-component of transform-origin as 0 rather than null when it is omitted. r=dbaron
authorDavid Zbarsky <dzbarsky@gmail.com>
Sat, 21 Jul 2012 19:48:19 -0400
changeset 100041 292c6ef7188f3275f7411197ead78aed118825de
parent 100040 defbe00ca0916c2f2488c641190c547c84603d72
child 100042 52471266a6575a98576ee154bf406c9434e7a80c
push id12308
push userdzbarsky@gmail.com
push dateSat, 21 Jul 2012 23:48:41 +0000
treeherdermozilla-inbound@52471266a657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs773500
milestone17.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
Bug 773500 Part 1:Store z-component of transform-origin as 0 rather than null when it is omitted. r=dbaron
layout/style/nsCSSParser.cpp
layout/style/nsCSSValue.cpp
layout/style/nsStyleAnimation.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -8357,17 +8357,17 @@ bool CSSParserImpl::ParseTransformOrigin
   } else {
     nsCSSValue value;
     if (aPerspective) {
       value.SetPairValue(position.mXValue, position.mYValue);
     } else {
       nsCSSValue depth;
       if (!ParseVariant(depth, VARIANT_LENGTH | VARIANT_CALC, nsnull) ||
           !nsLayoutUtils::Are3DTransformsEnabled()) {
-        depth.Reset();
+        depth.SetFloatValue(0.0f, eCSSUnit_Pixel);
       }
       value.SetTripletValue(position.mXValue, position.mYValue, depth);
     }
 
     AppendValue(prop, value);
   }
   return true;
 }
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -418,20 +418,20 @@ void nsCSSValue::SetPairValue(const nsCS
   mUnit = eCSSUnit_Pair;
   mValue.mPair = new nsCSSValuePair_heap(xValue, yValue);
   mValue.mPair->AddRef();
 }
 
 void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
 {
     // triplet should not be used for null/inherit/initial values
-    // Only allow Null for the z component
     NS_ABORT_IF_FALSE(aValue &&
                       aValue->mXValue.GetUnit() != eCSSUnit_Null &&
                       aValue->mYValue.GetUnit() != eCSSUnit_Null &&
+                      aValue->mZValue.GetUnit() != eCSSUnit_Null &&
                       aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
                       aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
                       aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
                       aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
                       aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
                       aValue->mZValue.GetUnit() != eCSSUnit_Initial,
                       "missing or inappropriate triplet value");
     Reset();
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -1776,23 +1776,16 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
       aResultValue.SetAndAdoptCSSValuePairValue(result.forget(),
                                                 eUnit_CSSValuePair);
       return true;
     }
     case eUnit_CSSValueTriplet: {
       nsCSSValueTriplet triplet1(*aValue1.GetCSSValueTripletValue());
       nsCSSValueTriplet triplet2(*aValue2.GetCSSValueTripletValue());
 
-      if (triplet1.mZValue.GetUnit() == eCSSUnit_Null) {
-        triplet1.mZValue.SetFloatValue(0.0, eCSSUnit_Pixel);
-      }
-      if (triplet2.mZValue.GetUnit() == eCSSUnit_Null) {
-          triplet2.mZValue.SetFloatValue(0.0, eCSSUnit_Pixel);
-      }
-
       nsCSSUnit unit[3];
       unit[0] = GetCommonUnit(aProperty, triplet1.mXValue.GetUnit(),
                               triplet2.mXValue.GetUnit());
       unit[1] = GetCommonUnit(aProperty, triplet1.mYValue.GetUnit(),
                                triplet2.mYValue.GetUnit());
       unit[2] = GetCommonUnit(aProperty, triplet1.mZValue.GetUnit(),
                               triplet2.mZValue.GetUnit());
       if (unit[0] == eCSSUnit_Null || unit[1] == eCSSUnit_Null ||
@@ -1811,21 +1804,16 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
                                          aCoeff1, &triplet1->*member,
                                          aCoeff2, &triplet2->*member,
                                          result->*member) ) {
           NS_ABORT_IF_FALSE(false, "unexpected unit");
           return false;
         }
       }
 
-      if (result->mZValue.GetUnit() == eCSSUnit_Pixel &&
-          result->mZValue.GetFloatValue() == 0.0f) {
-        result->mZValue.Reset();
-      }
-
       aResultValue.SetAndAdoptCSSValueTripletValue(result.forget(),
                                                    eUnit_CSSValueTriplet);
       return true;
     }
     case eUnit_CSSRect: {
       NS_ABORT_IF_FALSE(nsCSSProps::ValueRestrictions(aProperty) == 0,
                         "must add code for handling value restrictions");
       const nsCSSRect *rect1 = aValue1.GetCSSRectValue();
@@ -2668,20 +2656,16 @@ nsStyleAnimation::ExtractComputedValue(n
               !StyleCoordToCSSValue(styleDisplay->mTransformOrigin[0],
                                     triplet->mXValue) ||
               !StyleCoordToCSSValue(styleDisplay->mTransformOrigin[1],
                                     triplet->mYValue) ||
               !StyleCoordToCSSValue(styleDisplay->mTransformOrigin[2],
                                     triplet->mZValue)) {
             return false;
           }
-          if (triplet->mZValue.GetUnit() == eCSSUnit_Pixel &&
-              triplet->mZValue.GetFloatValue() == 0.0f) {
-            triplet->mZValue.Reset();
-          }
           aComputedValue.SetAndAdoptCSSValueTripletValue(triplet.forget(),
                                                          eUnit_CSSValueTriplet);
           break;
         }
 
         case eCSSProperty_perspective_origin: {
           const nsStyleDisplay *styleDisplay =
             static_cast<const nsStyleDisplay*>(styleStruct);