Bug 1357117 part 2: Add flag to distinguish between -moz & -webkit prefixed gradient expressions. r?xidorn draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 19 Apr 2017 14:51:20 -0700
changeset 565476 093e7a58572406546786180b8c8f43d590b8dcf9
parent 565446 5aba0c3118a4118c6a548124fd3b2c6efc8584e9
child 565477 bbb4f1865bfe1e21fd764118cb91f3f1f63042ba
child 565481 65918afde10695cf97fe7b359bb9c19102effa33
push id54868
push userdholbert@mozilla.com
push dateWed, 19 Apr 2017 21:51:46 +0000
reviewersxidorn
bugs1357117
milestone55.0a1
Bug 1357117 part 2: Add flag to distinguish between -moz & -webkit prefixed gradient expressions. r?xidorn This patch doesn't change our behavior -- we won't actually act on the new flag until the next patch in this series. MozReview-Commit-ID: EONsLM54eG1
layout/style/nsCSSParser.cpp
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -10218,16 +10218,17 @@ CSSParserImpl::ParseLinearGradient(nsCSS
   // back the first token (which we may have checked for "to" above) and try to
   // parse expression as <legacy-gradient-line>? <color-stop-list>
   bool haveGradientLine = IsLegacyGradientLine(mToken.mType, mToken.mIdent);
   UngetToken();
 
   if (haveGradientLine) {
     // Parse a <legacy-gradient-line>
     cssGradient->mIsLegacySyntax = true;
+    cssGradient->mIsMozLegacySyntax = (aFlags & eGradient_MozLegacy);
     // In -webkit-linear-gradient expressions (handled below), we need to accept
     // unitless 0 for angles, to match WebKit/Blink.
     int32_t angleFlags = (aFlags & eGradient_WebkitLegacy) ?
       VARIANT_ANGLE | VARIANT_ZERO_ANGLE :
       VARIANT_ANGLE;
 
     bool haveAngle =
       ParseSingleTokenVariant(cssGradient->mAngle, angleFlags, nullptr);
@@ -10405,16 +10406,17 @@ CSSParserImpl::ParseRadialGradient(nsCSS
            !ExpectSymbol(',', true))) {
         SkipUntil(')');
         return false;
       }
     }
 
     if (cssGradient->mAngle.GetUnit() != eCSSUnit_None) {
       cssGradient->mIsLegacySyntax = true;
+      cssGradient->mIsMozLegacySyntax = (aFlags & eGradient_MozLegacy);
     }
   }
 
   // radial gradients might have a shape and size here for legacy syntax
   if (!haveShape && !haveSize) {
     haveShape =
       ParseSingleTokenVariant(cssGradient->GetRadialShape(), VARIANT_KEYWORD,
                               nsCSSProps::kRadialGradientShapeKTable);
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -3131,16 +3131,17 @@ nsCSSValueGradientStop::SizeOfExcludingT
   return n;
 }
 
 nsCSSValueGradient::nsCSSValueGradient(bool aIsRadial,
                                        bool aIsRepeating)
   : mIsRadial(aIsRadial),
     mIsRepeating(aIsRepeating),
     mIsLegacySyntax(false),
+    mIsMozLegacySyntax(false),
     mIsExplicitSize(false),
     mBgPos(eCSSUnit_None),
     mAngle(eCSSUnit_None)
 {
   mRadialValues[0].SetNoneValue();
   mRadialValues[1].SetNoneValue();
 }
 
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -1626,17 +1626,21 @@ public:
 };
 
 struct nsCSSValueGradient final {
   nsCSSValueGradient(bool aIsRadial, bool aIsRepeating);
 
   // true if gradient is radial, false if it is linear
   bool mIsRadial;
   bool mIsRepeating;
-  bool mIsLegacySyntax;
+  bool mIsLegacySyntax; // If true, serialization should use a vendor prefix.
+  // XXXdholbert This will hopefully be going away soon, if bug 1337655 sticks:
+  bool mIsMozLegacySyntax; // (Only makes sense when mIsLegacySyntax is true.)
+                           // If true, serialization should use -moz prefix.
+                           // Else, serialization should use -webkit prefix.
   bool mIsExplicitSize;
   // line position and angle
   nsCSSValuePair mBgPos;
   nsCSSValue mAngle;
 
   // Only meaningful if mIsRadial is true
 private:
   nsCSSValue mRadialValues[2];
@@ -1684,16 +1688,17 @@ public:
 
   InfallibleTArray<nsCSSValueGradientStop> mStops;
 
   bool operator==(const nsCSSValueGradient& aOther) const
   {
     if (mIsRadial != aOther.mIsRadial ||
         mIsRepeating != aOther.mIsRepeating ||
         mIsLegacySyntax != aOther.mIsLegacySyntax ||
+        mIsMozLegacySyntax != aOther.mIsMozLegacySyntax ||
         mIsExplicitSize != aOther.mIsExplicitSize ||
         mBgPos != aOther.mBgPos ||
         mAngle != aOther.mAngle ||
         mRadialValues[0] != aOther.mRadialValues[0] ||
         mRadialValues[1] != aOther.mRadialValues[1])
       return false;
 
     if (mStops.Length() != aOther.mStops.Length())
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1268,16 +1268,17 @@ static void SetGradient(const nsCSSValue
                  "bad unit for linear shape");
     NS_ASSERTION(gradient->GetRadialSize().GetUnit() == eCSSUnit_None,
                  "bad unit for linear size");
     aResult.mShape = NS_STYLE_GRADIENT_SHAPE_LINEAR;
     aResult.mSize = NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER;
   }
 
   aResult.mLegacySyntax = gradient->mIsLegacySyntax;
+  aResult.mMozLegacySyntax = gradient->mIsMozLegacySyntax;
 
   // bg-position
   SetGradientCoord(gradient->mBgPos.mXValue, aPresContext, aContext,
                    aResult.mBgPosX, aConditions);
 
   SetGradientCoord(gradient->mBgPos.mYValue, aPresContext, aContext,
                    aResult.mBgPosY, aConditions);
 
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1841,16 +1841,17 @@ nsStyleGradient::operator==(const nsStyl
   MOZ_ASSERT(aOther.mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
              aOther.mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
              "incorrect combination of shape and size");
 
   if (mShape != aOther.mShape ||
       mSize != aOther.mSize ||
       mRepeating != aOther.mRepeating ||
       mLegacySyntax != aOther.mLegacySyntax ||
+      mMozLegacySyntax != aOther.mMozLegacySyntax ||
       mBgPosX != aOther.mBgPosX ||
       mBgPosY != aOther.mBgPosY ||
       mAngle != aOther.mAngle ||
       mRadiusX != aOther.mRadiusX ||
       mRadiusY != aOther.mRadiusY) {
     return false;
   }
 
@@ -1871,16 +1872,17 @@ nsStyleGradient::operator==(const nsStyl
   return true;
 }
 
 nsStyleGradient::nsStyleGradient()
   : mShape(NS_STYLE_GRADIENT_SHAPE_LINEAR)
   , mSize(NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER)
   , mRepeating(false)
   , mLegacySyntax(false)
+  , mMozLegacySyntax(false)
 {
 }
 
 bool
 nsStyleGradient::IsOpaque()
 {
   for (uint32_t i = 0; i < mStops.Length(); i++) {
     if (NS_GET_A(mStops[i].mColor) < 255) {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -237,17 +237,21 @@ struct nsStyleGradientStop
 class nsStyleGradient final
 {
 public:
   nsStyleGradient();
   uint8_t mShape;  // NS_STYLE_GRADIENT_SHAPE_*
   uint8_t mSize;   // NS_STYLE_GRADIENT_SIZE_*;
                    // not used (must be FARTHEST_CORNER) for linear shape
   bool mRepeating;
-  bool mLegacySyntax;
+  bool mLegacySyntax; // If true, serialization should use a vendor prefix.
+  // XXXdholbert This will hopefully be going away soon, if bug 1337655 sticks:
+  bool mMozLegacySyntax; // (Only makes sense when mLegacySyntax is true.)
+                         // If true, serialization should use -moz prefix.
+                         // Else, serialization should use -webkit prefix.
 
   nsStyleCoord mBgPosX; // percent, coord, calc, none
   nsStyleCoord mBgPosY; // percent, coord, calc, none
   nsStyleCoord mAngle;  // none, angle
 
   nsStyleCoord mRadiusX; // percent, coord, calc, none
   nsStyleCoord mRadiusY; // percent, coord, calc, none