layout/style/nsCSSValue.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/nsCSSValue.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1557 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* representation of simple property values within CSS declarations */
    1.10 +
    1.11 +#ifndef nsCSSValue_h___
    1.12 +#define nsCSSValue_h___
    1.13 +
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "mozilla/FloatingPoint.h"
    1.16 +#include "mozilla/MemoryReporting.h"
    1.17 +
    1.18 +#include "nsIPrincipal.h"
    1.19 +#include "nsIURI.h"
    1.20 +#include "nsCOMPtr.h"
    1.21 +#include "nsCRTGlue.h"
    1.22 +#include "nsCSSKeywords.h"
    1.23 +#include "nsCSSProperty.h"
    1.24 +#include "nsColor.h"
    1.25 +#include "nsCoord.h"
    1.26 +#include "nsRefPtrHashtable.h"
    1.27 +#include "nsString.h"
    1.28 +#include "nsStringBuffer.h"
    1.29 +#include "nsTArray.h"
    1.30 +#include "nsStyleConsts.h"
    1.31 +
    1.32 +class imgRequestProxy;
    1.33 +class nsCSSStyleSheet;
    1.34 +class nsIDocument;
    1.35 +class nsIPrincipal;
    1.36 +class nsIURI;
    1.37 +class nsPresContext;
    1.38 +template <class T>
    1.39 +class nsPtrHashKey;
    1.40 +
    1.41 +// Deletes a linked list iteratively to avoid blowing up the stack (bug 456196).
    1.42 +#define NS_CSS_DELETE_LIST_MEMBER(type_, ptr_, member_)                        \
    1.43 +  {                                                                            \
    1.44 +    type_ *cur = (ptr_)->member_;                                              \
    1.45 +    (ptr_)->member_ = nullptr;                                                 \
    1.46 +    while (cur) {                                                              \
    1.47 +      type_ *dlm_next = cur->member_;                                          \
    1.48 +      cur->member_ = nullptr;                                                  \
    1.49 +      delete cur;                                                              \
    1.50 +      cur = dlm_next;                                                          \
    1.51 +    }                                                                          \
    1.52 +  }
    1.53 +
    1.54 +// Clones a linked list iteratively to avoid blowing up the stack.
    1.55 +// If it fails to clone the entire list then 'to_' is deleted and
    1.56 +// we return null.
    1.57 +#define NS_CSS_CLONE_LIST_MEMBER(type_, from_, member_, to_, args_)            \
    1.58 +  {                                                                            \
    1.59 +    type_ *dest = (to_);                                                       \
    1.60 +    (to_)->member_ = nullptr;                                                  \
    1.61 +    for (const type_ *src = (from_)->member_; src; src = src->member_) {       \
    1.62 +      type_ *clm_clone = src->Clone args_;                                     \
    1.63 +      if (!clm_clone) {                                                        \
    1.64 +        delete (to_);                                                          \
    1.65 +        return nullptr;                                                        \
    1.66 +      }                                                                        \
    1.67 +      dest->member_ = clm_clone;                                               \
    1.68 +      dest = clm_clone;                                                        \
    1.69 +    }                                                                          \
    1.70 +  }
    1.71 +
    1.72 +namespace mozilla {
    1.73 +namespace css {
    1.74 +
    1.75 +struct URLValue {
    1.76 +  // Methods are not inline because using an nsIPrincipal means requiring
    1.77 +  // caps, which leads to REQUIRES hell, since this header is included all
    1.78 +  // over.
    1.79 +
    1.80 +  // For both constructors aString must not be null.
    1.81 +  // For both constructors aOriginPrincipal must not be null.
    1.82 +  // Construct with a base URI; this will create the actual URI lazily from
    1.83 +  // aString and aBaseURI.
    1.84 +  URLValue(nsStringBuffer* aString, nsIURI* aBaseURI, nsIURI* aReferrer,
    1.85 +           nsIPrincipal* aOriginPrincipal);
    1.86 +  // Construct with the actual URI.
    1.87 +  URLValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
    1.88 +           nsIPrincipal* aOriginPrincipal);
    1.89 +
    1.90 +  ~URLValue();
    1.91 +
    1.92 +  bool operator==(const URLValue& aOther) const;
    1.93 +
    1.94 +  // URIEquals only compares URIs and principals (unlike operator==, which
    1.95 +  // also compares the original strings).  URIEquals also assumes that the
    1.96 +  // mURI member of both URL objects is non-null.  Do NOT call this method
    1.97 +  // unless you're sure this is the case.
    1.98 +  bool URIEquals(const URLValue& aOther) const;
    1.99 +
   1.100 +  nsIURI* GetURI() const;
   1.101 +
   1.102 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.103 +
   1.104 +private:
   1.105 +  // If mURIResolved is false, mURI stores the base URI.
   1.106 +  // If mURIResolved is true, mURI stores the URI we resolve to; this may be
   1.107 +  // null if the URI is invalid.
   1.108 +  mutable nsCOMPtr<nsIURI> mURI;
   1.109 +public:
   1.110 +  nsStringBuffer* mString; // Could use nsRefPtr, but it'd add useless
   1.111 +                           // null-checks; this is never null.
   1.112 +  nsCOMPtr<nsIURI> mReferrer;
   1.113 +  nsCOMPtr<nsIPrincipal> mOriginPrincipal;
   1.114 +
   1.115 +  NS_INLINE_DECL_REFCOUNTING(URLValue)
   1.116 +
   1.117 +private:
   1.118 +  mutable bool mURIResolved;
   1.119 +
   1.120 +  URLValue(const URLValue& aOther) MOZ_DELETE;
   1.121 +  URLValue& operator=(const URLValue& aOther) MOZ_DELETE;
   1.122 +};
   1.123 +
   1.124 +struct ImageValue : public URLValue {
   1.125 +  // Not making the constructor and destructor inline because that would
   1.126 +  // force us to include imgIRequest.h, which leads to REQUIRES hell, since
   1.127 +  // this header is included all over.
   1.128 +  // aString must not be null.
   1.129 +  ImageValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
   1.130 +             nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument);
   1.131 +  ~ImageValue();
   1.132 +
   1.133 +  // Inherit operator== from URLValue
   1.134 +
   1.135 +  nsRefPtrHashtable<nsPtrHashKey<nsISupports>, imgRequestProxy> mRequests; 
   1.136 +
   1.137 +  // Override AddRef and Release to not only log ourselves correctly, but
   1.138 +  // also so that we delete correctly without a virtual destructor
   1.139 +  NS_INLINE_DECL_REFCOUNTING(ImageValue)
   1.140 +};
   1.141 +
   1.142 +struct GridNamedArea {
   1.143 +  nsString mName;
   1.144 +  uint32_t mColumnStart;
   1.145 +  uint32_t mColumnEnd;
   1.146 +  uint32_t mRowStart;
   1.147 +  uint32_t mRowEnd;
   1.148 +};
   1.149 +
   1.150 +struct GridTemplateAreasValue MOZ_FINAL {
   1.151 +  // Parsed value
   1.152 +  nsTArray<GridNamedArea> mNamedAreas;
   1.153 +
   1.154 +  // Original <string> values. Length gives the number of rows,
   1.155 +  // content makes serialization easier.
   1.156 +  nsTArray<nsString> mTemplates;
   1.157 +
   1.158 +  // How many columns grid-template-areas contributes to the explicit grid.
   1.159 +  // http://dev.w3.org/csswg/css-grid/#explicit-grid
   1.160 +  uint32_t mNColumns;
   1.161 +
   1.162 +  // How many rows grid-template-areas contributes to the explicit grid.
   1.163 +  // http://dev.w3.org/csswg/css-grid/#explicit-grid
   1.164 +  uint32_t NRows() const {
   1.165 +    return mTemplates.Length();
   1.166 +  }
   1.167 +
   1.168 +  GridTemplateAreasValue()
   1.169 +    : mNColumns(0)
   1.170 +    // Default constructors for mNamedAreas and mTemplates: empty arrays.
   1.171 +  {
   1.172 +  }
   1.173 +
   1.174 +  bool operator==(const GridTemplateAreasValue& aOther) const
   1.175 +  {
   1.176 +    return mTemplates == aOther.mTemplates;
   1.177 +  }
   1.178 +
   1.179 +  bool operator!=(const GridTemplateAreasValue& aOther) const
   1.180 +  {
   1.181 +    return !(*this == aOther);
   1.182 +  }
   1.183 +
   1.184 +  NS_INLINE_DECL_REFCOUNTING(GridTemplateAreasValue)
   1.185 +
   1.186 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.187 +
   1.188 +private:
   1.189 +  // Private destructor to make sure this isn't used as a stack variable
   1.190 +  // or member variable.
   1.191 +  ~GridTemplateAreasValue()
   1.192 +  {
   1.193 +  }
   1.194 +
   1.195 +  GridTemplateAreasValue(const GridTemplateAreasValue& aOther) MOZ_DELETE;
   1.196 +  GridTemplateAreasValue&
   1.197 +  operator=(const GridTemplateAreasValue& aOther) MOZ_DELETE;
   1.198 +};
   1.199 +
   1.200 +}
   1.201 +}
   1.202 +
   1.203 +enum nsCSSUnit {
   1.204 +  eCSSUnit_Null         = 0,      // (n/a) null unit, value is not specified
   1.205 +  eCSSUnit_Auto         = 1,      // (n/a) value is algorithmic
   1.206 +  eCSSUnit_Inherit      = 2,      // (n/a) value is inherited
   1.207 +  eCSSUnit_Initial      = 3,      // (n/a) value is default UA value
   1.208 +  eCSSUnit_Unset        = 4,      // (n/a) value equivalent to 'initial' if on a reset property, 'inherit' otherwise
   1.209 +  eCSSUnit_None         = 5,      // (n/a) value is none
   1.210 +  eCSSUnit_Normal       = 6,      // (n/a) value is normal (algorithmic, different than auto)
   1.211 +  eCSSUnit_System_Font  = 7,      // (n/a) value is -moz-use-system-font
   1.212 +  eCSSUnit_All          = 8,      // (n/a) value is all
   1.213 +  eCSSUnit_Dummy        = 9,      // (n/a) a fake but specified value, used
   1.214 +                                  //       only in temporary values
   1.215 +  eCSSUnit_DummyInherit = 10,     // (n/a) a fake but specified value, used
   1.216 +                                  //       only in temporary values
   1.217 +
   1.218 +  eCSSUnit_String       = 11,     // (char16_t*) a string value
   1.219 +  eCSSUnit_Ident        = 12,     // (char16_t*) a string value
   1.220 +  eCSSUnit_Families     = 13,     // (char16_t*) a string value
   1.221 +  eCSSUnit_Attr         = 14,     // (char16_t*) a attr(string) value
   1.222 +  eCSSUnit_Local_Font   = 15,     // (char16_t*) a local font name
   1.223 +  eCSSUnit_Font_Format  = 16,     // (char16_t*) a font format name
   1.224 +  eCSSUnit_Element      = 17,     // (char16_t*) an element id
   1.225 +
   1.226 +  eCSSUnit_Array        = 20,     // (nsCSSValue::Array*) a list of values
   1.227 +  eCSSUnit_Counter      = 21,     // (nsCSSValue::Array*) a counter(string,[string]) value
   1.228 +  eCSSUnit_Counters     = 22,     // (nsCSSValue::Array*) a counters(string,string[,string]) value
   1.229 +  eCSSUnit_Cubic_Bezier = 23,     // (nsCSSValue::Array*) a list of float values
   1.230 +  eCSSUnit_Steps        = 24,     // (nsCSSValue::Array*) a list of (integer, enumerated)
   1.231 +  eCSSUnit_Function     = 25,     // (nsCSSValue::Array*) a function with
   1.232 +                                  //  parameters.  First elem of array is name,
   1.233 +                                  //  an nsCSSKeyword as eCSSUnit_Enumerated,
   1.234 +                                  //  the rest of the values are arguments.
   1.235 +
   1.236 +  // The top level of a calc() expression is eCSSUnit_Calc.  All
   1.237 +  // remaining eCSSUnit_Calc_* units only occur inside these toplevel
   1.238 +  // calc values.
   1.239 +
   1.240 +  // eCSSUnit_Calc has an array with exactly 1 element.  eCSSUnit_Calc
   1.241 +  // exists so we can distinguish calc(2em) from 2em as specified values
   1.242 +  // (but we drop this distinction for nsStyleCoord when we store
   1.243 +  // computed values).
   1.244 +  eCSSUnit_Calc         = 30,     // (nsCSSValue::Array*) calc() value
   1.245 +  // Plus, Minus, Times_* and Divided have arrays with exactly 2
   1.246 +  // elements.  a + b + c + d is grouped as ((a + b) + c) + d
   1.247 +  eCSSUnit_Calc_Plus    = 31,     // (nsCSSValue::Array*) + node within calc()
   1.248 +  eCSSUnit_Calc_Minus   = 32,     // (nsCSSValue::Array*) - within calc
   1.249 +  eCSSUnit_Calc_Times_L = 33,     // (nsCSSValue::Array*) num * val within calc
   1.250 +  eCSSUnit_Calc_Times_R = 34,     // (nsCSSValue::Array*) val * num within calc
   1.251 +  eCSSUnit_Calc_Divided = 35,     // (nsCSSValue::Array*) / within calc
   1.252 +
   1.253 +  eCSSUnit_URL          = 40,     // (nsCSSValue::URL*) value
   1.254 +  eCSSUnit_Image        = 41,     // (nsCSSValue::Image*) value
   1.255 +  eCSSUnit_Gradient     = 42,     // (nsCSSValueGradient*) value
   1.256 +  eCSSUnit_TokenStream  = 43,     // (nsCSSValueTokenStream*) value
   1.257 +  eCSSUnit_GridTemplateAreas   = 44,   // (GridTemplateAreasValue*)
   1.258 +                                       // for grid-template-areas
   1.259 +
   1.260 +  eCSSUnit_Pair         = 50,     // (nsCSSValuePair*) pair of values
   1.261 +  eCSSUnit_Triplet      = 51,     // (nsCSSValueTriplet*) triplet of values
   1.262 +  eCSSUnit_Rect         = 52,     // (nsCSSRect*) rectangle (four values)
   1.263 +  eCSSUnit_List         = 53,     // (nsCSSValueList*) list of values
   1.264 +  eCSSUnit_ListDep      = 54,     // (nsCSSValueList*) same as List
   1.265 +                                  //   but does not own the list
   1.266 +  eCSSUnit_SharedList   = 55,     // (nsCSSValueSharedList*) same as list
   1.267 +                                  //   but reference counted and shared
   1.268 +  eCSSUnit_PairList     = 56,     // (nsCSSValuePairList*) list of value pairs
   1.269 +  eCSSUnit_PairListDep  = 57,     // (nsCSSValuePairList*) same as PairList
   1.270 +                                  //   but does not own the list
   1.271 +
   1.272 +  eCSSUnit_Integer      = 70,     // (int) simple value
   1.273 +  eCSSUnit_Enumerated   = 71,     // (int) value has enumerated meaning
   1.274 +
   1.275 +  eCSSUnit_EnumColor           = 80,   // (int) enumerated color (kColorKTable)
   1.276 +  eCSSUnit_RGBColor            = 81,   // (nscolor) an opaque RGBA value specified as rgb()
   1.277 +  eCSSUnit_RGBAColor           = 82,   // (nscolor) an RGBA value specified as rgba()
   1.278 +  eCSSUnit_HexColor            = 83,   // (nscolor) an opaque RGBA value specified as #rrggbb
   1.279 +  eCSSUnit_ShortHexColor       = 84,   // (nscolor) an opaque RGBA value specified as #rgb
   1.280 +  eCSSUnit_PercentageRGBColor  = 85,   // (nsCSSValueFloatColor*)
   1.281 +  eCSSUnit_PercentageRGBAColor = 86,   // (nsCSSValueFloatColor*)
   1.282 +  eCSSUnit_HSLColor            = 87,   // (nsCSSValueFloatColor*)
   1.283 +  eCSSUnit_HSLAColor           = 88,   // (nsCSSValueFloatColor*)
   1.284 +
   1.285 +  eCSSUnit_Percent      = 90,     // (float) 1.0 == 100%) value is percentage of something
   1.286 +  eCSSUnit_Number       = 91,     // (float) value is numeric (usually multiplier, different behavior that percent)
   1.287 +
   1.288 +  // Physical length units
   1.289 +  eCSSUnit_PhysicalMillimeter = 200,   // (float) 1/25.4 inch
   1.290 +
   1.291 +  // Length units - relative
   1.292 +  // Viewport relative measure
   1.293 +  eCSSUnit_ViewportWidth  = 700,    // (float) 1% of the width of the initial containing block
   1.294 +  eCSSUnit_ViewportHeight = 701,    // (float) 1% of the height of the initial containing block
   1.295 +  eCSSUnit_ViewportMin    = 702,    // (float) smaller of ViewportWidth and ViewportHeight
   1.296 +  eCSSUnit_ViewportMax    = 703,    // (float) larger of ViewportWidth and ViewportHeight
   1.297 +
   1.298 +  // Font relative measure
   1.299 +  eCSSUnit_EM           = 800,    // (float) == current font size
   1.300 +  eCSSUnit_XHeight      = 801,    // (float) distance from top of lower case x to baseline
   1.301 +  eCSSUnit_Char         = 802,    // (float) number of characters, used for width with monospace font
   1.302 +  eCSSUnit_RootEM       = 803,    // (float) == root element font size
   1.303 +
   1.304 +  // Screen relative measure
   1.305 +  eCSSUnit_Point        = 900,    // (float) 4/3 of a CSS pixel
   1.306 +  eCSSUnit_Inch         = 901,    // (float) 96 CSS pixels
   1.307 +  eCSSUnit_Millimeter   = 902,    // (float) 96/25.4 CSS pixels
   1.308 +  eCSSUnit_Centimeter   = 903,    // (float) 96/2.54 CSS pixels
   1.309 +  eCSSUnit_Pica         = 904,    // (float) 12 points == 16 CSS pixls
   1.310 +  eCSSUnit_Pixel        = 905,    // (float) CSS pixel unit
   1.311 +
   1.312 +  // Angular units
   1.313 +  eCSSUnit_Degree       = 1000,    // (float) 360 per circle
   1.314 +  eCSSUnit_Grad         = 1001,    // (float) 400 per circle
   1.315 +  eCSSUnit_Radian       = 1002,    // (float) 2*pi per circle
   1.316 +  eCSSUnit_Turn         = 1003,    // (float) 1 per circle
   1.317 +
   1.318 +  // Frequency units
   1.319 +  eCSSUnit_Hertz        = 2000,    // (float) 1/seconds
   1.320 +  eCSSUnit_Kilohertz    = 2001,    // (float) 1000 Hertz
   1.321 +
   1.322 +  // Time units
   1.323 +  eCSSUnit_Seconds      = 3000,    // (float) Standard time
   1.324 +  eCSSUnit_Milliseconds = 3001,    // (float) 1/1000 second
   1.325 +
   1.326 +  // Flexible fraction (CSS Grid)
   1.327 +  eCSSUnit_FlexFraction = 4000     // (float) Fraction of free space
   1.328 +};
   1.329 +
   1.330 +struct nsCSSValueGradient;
   1.331 +struct nsCSSValuePair;
   1.332 +struct nsCSSValuePair_heap;
   1.333 +struct nsCSSValueTokenStream;
   1.334 +struct nsCSSRect;
   1.335 +struct nsCSSRect_heap;
   1.336 +struct nsCSSValueList;
   1.337 +struct nsCSSValueList_heap;
   1.338 +struct nsCSSValueSharedList;
   1.339 +struct nsCSSValuePairList;
   1.340 +struct nsCSSValuePairList_heap;
   1.341 +struct nsCSSValueTriplet;
   1.342 +struct nsCSSValueTriplet_heap;
   1.343 +class nsCSSValueFloatColor;
   1.344 +
   1.345 +class nsCSSValue {
   1.346 +public:
   1.347 +  struct Array;
   1.348 +  friend struct Array;
   1.349 +
   1.350 +  friend struct mozilla::css::URLValue;
   1.351 +
   1.352 +  friend struct mozilla::css::ImageValue;
   1.353 +
   1.354 +  // for valueless units only (null, auto, inherit, none, all, normal)
   1.355 +  explicit nsCSSValue(nsCSSUnit aUnit = eCSSUnit_Null)
   1.356 +    : mUnit(aUnit)
   1.357 +  {
   1.358 +    NS_ABORT_IF_FALSE(aUnit <= eCSSUnit_DummyInherit, "not a valueless unit");
   1.359 +  }
   1.360 +
   1.361 +  nsCSSValue(int32_t aValue, nsCSSUnit aUnit);
   1.362 +  nsCSSValue(float aValue, nsCSSUnit aUnit);
   1.363 +  nsCSSValue(const nsString& aValue, nsCSSUnit aUnit);
   1.364 +  nsCSSValue(Array* aArray, nsCSSUnit aUnit);
   1.365 +  explicit nsCSSValue(mozilla::css::URLValue* aValue);
   1.366 +  explicit nsCSSValue(mozilla::css::ImageValue* aValue);
   1.367 +  explicit nsCSSValue(nsCSSValueGradient* aValue);
   1.368 +  explicit nsCSSValue(nsCSSValueTokenStream* aValue);
   1.369 +  explicit nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue);
   1.370 +  nsCSSValue(const nsCSSValue& aCopy);
   1.371 +  ~nsCSSValue() { Reset(); }
   1.372 +
   1.373 +  nsCSSValue&  operator=(const nsCSSValue& aCopy);
   1.374 +  bool        operator==(const nsCSSValue& aOther) const;
   1.375 +
   1.376 +  bool operator!=(const nsCSSValue& aOther) const
   1.377 +  {
   1.378 +    return !(*this == aOther);
   1.379 +  }
   1.380 +
   1.381 +  // Enum for AppendToString's aValueSerialization argument.
   1.382 +  enum Serialization { eNormalized, eAuthorSpecified };
   1.383 +
   1.384 +  /**
   1.385 +   * Serialize |this| as a specified value for |aProperty| and append
   1.386 +   * it to |aResult|.
   1.387 +   */
   1.388 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
   1.389 +                      Serialization aValueSerialization) const;
   1.390 +
   1.391 +  nsCSSUnit GetUnit() const { return mUnit; }
   1.392 +  bool      IsLengthUnit() const
   1.393 +    { return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; }
   1.394 +  /**
   1.395 +   * A "fixed" length unit is one that means a specific physical length
   1.396 +   * which we try to match based on the physical characteristics of an
   1.397 +   * output device.
   1.398 +   */
   1.399 +  bool      IsFixedLengthUnit() const  
   1.400 +    { return mUnit == eCSSUnit_PhysicalMillimeter; }
   1.401 +  /**
   1.402 +   * What the spec calls relative length units is, for us, split
   1.403 +   * between relative length units and pixel length units.
   1.404 +   * 
   1.405 +   * A "relative" length unit is a multiple of some derived metric,
   1.406 +   * such as a font em-size, which itself was controlled by an input CSS
   1.407 +   * length. Relative length units should not be scaled by zooming, since
   1.408 +   * the underlying CSS length would already have been scaled.
   1.409 +   */
   1.410 +  bool      IsRelativeLengthUnit() const  
   1.411 +    { return eCSSUnit_EM <= mUnit && mUnit <= eCSSUnit_RootEM; }
   1.412 +  /**
   1.413 +   * A "pixel" length unit is a some multiple of CSS pixels.
   1.414 +   */
   1.415 +  bool      IsPixelLengthUnit() const
   1.416 +    { return eCSSUnit_Point <= mUnit && mUnit <= eCSSUnit_Pixel; }
   1.417 +  bool      IsAngularUnit() const  
   1.418 +    { return eCSSUnit_Degree <= mUnit && mUnit <= eCSSUnit_Turn; }
   1.419 +  bool      IsFrequencyUnit() const  
   1.420 +    { return eCSSUnit_Hertz <= mUnit && mUnit <= eCSSUnit_Kilohertz; }
   1.421 +  bool      IsTimeUnit() const  
   1.422 +    { return eCSSUnit_Seconds <= mUnit && mUnit <= eCSSUnit_Milliseconds; }
   1.423 +  bool      IsCalcUnit() const
   1.424 +    { return eCSSUnit_Calc <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
   1.425 +
   1.426 +  bool      UnitHasStringValue() const
   1.427 +    { return eCSSUnit_String <= mUnit && mUnit <= eCSSUnit_Element; }
   1.428 +  bool      UnitHasArrayValue() const
   1.429 +    { return eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
   1.430 +
   1.431 +  // Checks for the nsCSSValue being of a particular type of color unit:
   1.432 +  //
   1.433 +  //   - IsIntegerColorUnit returns true for:
   1.434 +  //       eCSSUnit_RGBColor             -- rgb(int,int,int)
   1.435 +  //       eCSSUnit_RGBAColor            -- rgba(int,int,int,float)
   1.436 +  //       eCSSUnit_HexColor             -- #rrggbb
   1.437 +  //       eCSSUnit_ShortHexColor        -- #rgb
   1.438 +  //
   1.439 +  //   - IsFLoatColorUnit returns true for:
   1.440 +  //       eCSSUnit_PercentageRGBColor   -- rgb(%,%,%)
   1.441 +  //       eCSSUnit_PercentageRGBAColor  -- rgba(%,%,%,float)
   1.442 +  //       eCSSUnit_HSLColor             -- hsl(float,%,%)
   1.443 +  //       eCSSUnit_HSLAColor            -- hsla(float,%,%,float)
   1.444 +  //
   1.445 +  //   - IsNumericColorUnit returns true for any of the above units.
   1.446 +  //
   1.447 +  // Note that color keywords and system colors are represented by
   1.448 +  // eCSSUnit_EnumColor and eCSSUnit_Ident.
   1.449 +  bool IsIntegerColorUnit() const { return IsIntegerColorUnit(mUnit); }
   1.450 +  bool IsFloatColorUnit() const { return IsFloatColorUnit(mUnit); }
   1.451 +  bool IsNumericColorUnit() const { return IsNumericColorUnit(mUnit); }
   1.452 +  static bool IsIntegerColorUnit(nsCSSUnit aUnit)
   1.453 +  { return eCSSUnit_RGBColor <= aUnit && aUnit <= eCSSUnit_ShortHexColor; }
   1.454 +  static bool IsFloatColorUnit(nsCSSUnit aUnit)
   1.455 +  { return eCSSUnit_PercentageRGBColor <= aUnit &&
   1.456 +           aUnit <= eCSSUnit_HSLAColor; }
   1.457 +  static bool IsNumericColorUnit(nsCSSUnit aUnit)
   1.458 +  { return IsIntegerColorUnit(aUnit) || IsFloatColorUnit(aUnit); }
   1.459 +
   1.460 +  int32_t GetIntValue() const
   1.461 +  {
   1.462 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Integer ||
   1.463 +                      mUnit == eCSSUnit_Enumerated ||
   1.464 +                      mUnit == eCSSUnit_EnumColor,
   1.465 +                      "not an int value");
   1.466 +    return mValue.mInt;
   1.467 +  }
   1.468 +
   1.469 +  nsCSSKeyword GetKeywordValue() const
   1.470 +  {
   1.471 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Enumerated, "not a keyword value");
   1.472 +    return static_cast<nsCSSKeyword>(mValue.mInt);
   1.473 +  }
   1.474 +
   1.475 +  float GetPercentValue() const
   1.476 +  {
   1.477 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Percent, "not a percent value");
   1.478 +    return mValue.mFloat;
   1.479 +  }
   1.480 +
   1.481 +  float GetFloatValue() const
   1.482 +  {
   1.483 +    NS_ABORT_IF_FALSE(eCSSUnit_Number <= mUnit, "not a float value");
   1.484 +    MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
   1.485 +    return mValue.mFloat;
   1.486 +  }
   1.487 +
   1.488 +  float GetAngleValue() const
   1.489 +  {
   1.490 +    NS_ABORT_IF_FALSE(eCSSUnit_Degree <= mUnit &&
   1.491 +                 mUnit <= eCSSUnit_Turn, "not an angle value");
   1.492 +    return mValue.mFloat;
   1.493 +  }
   1.494 +
   1.495 +  // Converts any angle to radians.
   1.496 +  double GetAngleValueInRadians() const;
   1.497 +
   1.498 +  nsAString& GetStringValue(nsAString& aBuffer) const
   1.499 +  {
   1.500 +    NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
   1.501 +    aBuffer.Truncate();
   1.502 +    uint32_t len = NS_strlen(GetBufferValue(mValue.mString));
   1.503 +    mValue.mString->ToString(len, aBuffer);
   1.504 +    return aBuffer;
   1.505 +  }
   1.506 +
   1.507 +  const char16_t* GetStringBufferValue() const
   1.508 +  {
   1.509 +    NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
   1.510 +    return GetBufferValue(mValue.mString);
   1.511 +  }
   1.512 +
   1.513 +  nscolor GetColorValue() const;
   1.514 +  bool IsNonTransparentColor() const;
   1.515 +
   1.516 +  Array* GetArrayValue() const
   1.517 +  {
   1.518 +    NS_ABORT_IF_FALSE(UnitHasArrayValue(), "not an array value");
   1.519 +    return mValue.mArray;
   1.520 +  }
   1.521 +
   1.522 +  nsIURI* GetURLValue() const
   1.523 +  {
   1.524 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
   1.525 +                 "not a URL value");
   1.526 +    return mUnit == eCSSUnit_URL ?
   1.527 +      mValue.mURL->GetURI() : mValue.mImage->GetURI();
   1.528 +  }
   1.529 +
   1.530 +  nsCSSValueGradient* GetGradientValue() const
   1.531 +  {
   1.532 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Gradient, "not a gradient value");
   1.533 +    return mValue.mGradient;
   1.534 +  }
   1.535 +
   1.536 +  nsCSSValueTokenStream* GetTokenStreamValue() const
   1.537 +  {
   1.538 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_TokenStream, "not a token stream value");
   1.539 +    return mValue.mTokenStream;
   1.540 +  }
   1.541 +
   1.542 +  nsCSSValueSharedList* GetSharedListValue() const
   1.543 +  {
   1.544 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_SharedList, "not a shared list value");
   1.545 +    return mValue.mSharedList;
   1.546 +  }
   1.547 +
   1.548 +  // bodies of these are below
   1.549 +  inline nsCSSValuePair& GetPairValue();
   1.550 +  inline const nsCSSValuePair& GetPairValue() const;
   1.551 +
   1.552 +  inline nsCSSRect& GetRectValue();
   1.553 +  inline const nsCSSRect& GetRectValue() const;
   1.554 +
   1.555 +  inline nsCSSValueList* GetListValue();
   1.556 +  inline const nsCSSValueList* GetListValue() const;
   1.557 +
   1.558 +  inline nsCSSValuePairList* GetPairListValue();
   1.559 +  inline const nsCSSValuePairList* GetPairListValue() const;
   1.560 +
   1.561 +  inline nsCSSValueTriplet& GetTripletValue();
   1.562 +  inline const nsCSSValueTriplet& GetTripletValue() const;
   1.563 +
   1.564 +
   1.565 +  mozilla::css::URLValue* GetURLStructValue() const
   1.566 +  {
   1.567 +    // Not allowing this for Image values, because if the caller takes
   1.568 +    // a ref to them they won't be able to delete them properly.
   1.569 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL, "not a URL value");
   1.570 +    return mValue.mURL;
   1.571 +  }
   1.572 +
   1.573 +  mozilla::css::ImageValue* GetImageStructValue() const
   1.574 +  {
   1.575 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value");
   1.576 +    return mValue.mImage;
   1.577 +  }
   1.578 +
   1.579 +  mozilla::css::GridTemplateAreasValue* GetGridTemplateAreas() const
   1.580 +  {
   1.581 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_GridTemplateAreas,
   1.582 +                      "not a grid-template-areas value");
   1.583 +    return mValue.mGridTemplateAreas;
   1.584 +  }
   1.585 +
   1.586 +  const char16_t* GetOriginalURLValue() const
   1.587 +  {
   1.588 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
   1.589 +                      "not a URL value");
   1.590 +    return GetBufferValue(mUnit == eCSSUnit_URL ?
   1.591 +                            mValue.mURL->mString :
   1.592 +                            mValue.mImage->mString);
   1.593 +  }
   1.594 +
   1.595 +  // Not making this inline because that would force us to include
   1.596 +  // imgIRequest.h, which leads to REQUIRES hell, since this header is included
   1.597 +  // all over.
   1.598 +  imgRequestProxy* GetImageValue(nsIDocument* aDocument) const;
   1.599 +
   1.600 +  nscoord GetFixedLength(nsPresContext* aPresContext) const;
   1.601 +  nscoord GetPixelLength() const;
   1.602 +
   1.603 +  void Reset()  // sets to null
   1.604 +  {
   1.605 +    if (mUnit != eCSSUnit_Null)
   1.606 +      DoReset();
   1.607 +  }
   1.608 +private:
   1.609 +  void DoReset();
   1.610 +
   1.611 +public:
   1.612 +  void SetIntValue(int32_t aValue, nsCSSUnit aUnit);
   1.613 +  void SetPercentValue(float aValue);
   1.614 +  void SetFloatValue(float aValue, nsCSSUnit aUnit);
   1.615 +  void SetStringValue(const nsString& aValue, nsCSSUnit aUnit);
   1.616 +  void SetColorValue(nscolor aValue);
   1.617 +  void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit);
   1.618 +  void SetFloatColorValue(float aComponent1,
   1.619 +                          float aComponent2,
   1.620 +                          float aComponent3,
   1.621 +                          float aAlpha, nsCSSUnit aUnit);
   1.622 +  void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit);
   1.623 +  void SetURLValue(mozilla::css::URLValue* aURI);
   1.624 +  void SetImageValue(mozilla::css::ImageValue* aImage);
   1.625 +  void SetGradientValue(nsCSSValueGradient* aGradient);
   1.626 +  void SetTokenStreamValue(nsCSSValueTokenStream* aTokenStream);
   1.627 +  void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
   1.628 +  void SetPairValue(const nsCSSValuePair* aPair);
   1.629 +  void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
   1.630 +  void SetSharedListValue(nsCSSValueSharedList* aList);
   1.631 +  void SetDependentListValue(nsCSSValueList* aList);
   1.632 +  void SetDependentPairListValue(nsCSSValuePairList* aList);
   1.633 +  void SetTripletValue(const nsCSSValueTriplet* aTriplet);
   1.634 +  void SetTripletValue(const nsCSSValue& xValue, const nsCSSValue& yValue, const nsCSSValue& zValue);
   1.635 +  void SetAutoValue();
   1.636 +  void SetInheritValue();
   1.637 +  void SetInitialValue();
   1.638 +  void SetUnsetValue();
   1.639 +  void SetNoneValue();
   1.640 +  void SetAllValue();
   1.641 +  void SetNormalValue();
   1.642 +  void SetSystemFontValue();
   1.643 +  void SetDummyValue();
   1.644 +  void SetDummyInheritValue();
   1.645 +
   1.646 +  // These are a little different - they allocate storage for you and
   1.647 +  // return a handle.
   1.648 +  nsCSSRect& SetRectValue();
   1.649 +  nsCSSValueList* SetListValue();
   1.650 +  nsCSSValuePairList* SetPairListValue();
   1.651 +
   1.652 +  void StartImageLoad(nsIDocument* aDocument) const;  // Only pretend const
   1.653 +
   1.654 +  // Initializes as a function value with the specified function id.
   1.655 +  Array* InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs);
   1.656 +  // Checks if this is a function value with the specified function id.
   1.657 +  bool EqualsFunction(nsCSSKeyword aFunctionId) const;
   1.658 +
   1.659 +  // Returns an already addrefed buffer.  Guaranteed to return non-null.
   1.660 +  // (Will abort on allocation failure.)
   1.661 +  static already_AddRefed<nsStringBuffer>
   1.662 +    BufferFromString(const nsString& aValue);
   1.663 +
   1.664 +  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.665 +
   1.666 +private:
   1.667 +  static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) {
   1.668 +    return static_cast<char16_t*>(aBuffer->Data());
   1.669 +  }
   1.670 +
   1.671 +protected:
   1.672 +  nsCSSUnit mUnit;
   1.673 +  union {
   1.674 +    int32_t    mInt;
   1.675 +    float      mFloat;
   1.676 +    // Note: the capacity of the buffer may exceed the length of the string.
   1.677 +    // If we're of a string type, mString is not null.
   1.678 +    nsStringBuffer* mString;
   1.679 +    nscolor    mColor;
   1.680 +    Array*     mArray;
   1.681 +    mozilla::css::URLValue* mURL;
   1.682 +    mozilla::css::ImageValue* mImage;
   1.683 +    mozilla::css::GridTemplateAreasValue* mGridTemplateAreas;
   1.684 +    nsCSSValueGradient* mGradient;
   1.685 +    nsCSSValueTokenStream* mTokenStream;
   1.686 +    nsCSSValuePair_heap* mPair;
   1.687 +    nsCSSRect_heap* mRect;
   1.688 +    nsCSSValueTriplet_heap* mTriplet;
   1.689 +    nsCSSValueList_heap* mList;
   1.690 +    nsCSSValueList* mListDependent;
   1.691 +    nsCSSValueSharedList* mSharedList;
   1.692 +    nsCSSValuePairList_heap* mPairList;
   1.693 +    nsCSSValuePairList* mPairListDependent;
   1.694 +    nsCSSValueFloatColor* mFloatColor;
   1.695 +  } mValue;
   1.696 +};
   1.697 +
   1.698 +struct nsCSSValue::Array MOZ_FINAL {
   1.699 +
   1.700 +  // return |Array| with reference count of zero
   1.701 +  static Array* Create(size_t aItemCount) {
   1.702 +    return new (aItemCount) Array(aItemCount);
   1.703 +  }
   1.704 +
   1.705 +  nsCSSValue& operator[](size_t aIndex) {
   1.706 +    NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
   1.707 +    return mArray[aIndex];
   1.708 +  }
   1.709 +
   1.710 +  const nsCSSValue& operator[](size_t aIndex) const {
   1.711 +    NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
   1.712 +    return mArray[aIndex];
   1.713 +  }
   1.714 +
   1.715 +  nsCSSValue& Item(size_t aIndex) { return (*this)[aIndex]; }
   1.716 +  const nsCSSValue& Item(size_t aIndex) const { return (*this)[aIndex]; }
   1.717 +
   1.718 +  size_t Count() const { return mCount; }
   1.719 +
   1.720 +  bool operator==(const Array& aOther) const
   1.721 +  {
   1.722 +    if (mCount != aOther.mCount)
   1.723 +      return false;
   1.724 +    for (size_t i = 0; i < mCount; ++i)
   1.725 +      if ((*this)[i] != aOther[i])
   1.726 +        return false;
   1.727 +    return true;
   1.728 +  }
   1.729 +
   1.730 +  // XXXdholbert This uses a size_t ref count. Should we use a variant
   1.731 +  // of NS_INLINE_DECL_REFCOUNTING that takes a type as an argument?
   1.732 +  void AddRef() {
   1.733 +    if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
   1.734 +      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
   1.735 +      return;
   1.736 +    }
   1.737 +    ++mRefCnt;
   1.738 +    NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
   1.739 +  }
   1.740 +  void Release() {
   1.741 +    if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
   1.742 +      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
   1.743 +      return;
   1.744 +    }
   1.745 +    --mRefCnt;
   1.746 +    NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
   1.747 +    if (mRefCnt == 0)
   1.748 +      delete this;
   1.749 +  }
   1.750 +
   1.751 +private:
   1.752 +
   1.753 +  size_t mRefCnt;
   1.754 +  const size_t mCount;
   1.755 +  // This must be the last sub-object, since we extend this array to
   1.756 +  // be of size mCount; it needs to be a sub-object so it gets proper
   1.757 +  // alignment.
   1.758 +  nsCSSValue mArray[1];
   1.759 +
   1.760 +  void* operator new(size_t aSelfSize, size_t aItemCount) CPP_THROW_NEW {
   1.761 +    NS_ABORT_IF_FALSE(aItemCount > 0, "cannot have a 0 item count");
   1.762 +    return ::operator new(aSelfSize + sizeof(nsCSSValue) * (aItemCount - 1));
   1.763 +  }
   1.764 +
   1.765 +  void operator delete(void* aPtr) { ::operator delete(aPtr); }
   1.766 +
   1.767 +  nsCSSValue* First() { return mArray; }
   1.768 +
   1.769 +  const nsCSSValue* First() const { return mArray; }
   1.770 +
   1.771 +#define CSSVALUE_LIST_FOR_EXTRA_VALUES(var)                                   \
   1.772 +  for (nsCSSValue *var = First() + 1, *var##_end = First() + mCount;          \
   1.773 +       var != var##_end; ++var)
   1.774 +
   1.775 +  Array(size_t aItemCount)
   1.776 +    : mRefCnt(0)
   1.777 +    , mCount(aItemCount)
   1.778 +  {
   1.779 +    MOZ_COUNT_CTOR(nsCSSValue::Array);
   1.780 +    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
   1.781 +      new (val) nsCSSValue();
   1.782 +    }
   1.783 +  }
   1.784 +
   1.785 +  ~Array()
   1.786 +  {
   1.787 +    MOZ_COUNT_DTOR(nsCSSValue::Array);
   1.788 +    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
   1.789 +      val->~nsCSSValue();
   1.790 +    }
   1.791 +  }
   1.792 +
   1.793 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.794 +
   1.795 +#undef CSSVALUE_LIST_FOR_EXTRA_VALUES
   1.796 +
   1.797 +private:
   1.798 +  Array(const Array& aOther) MOZ_DELETE;
   1.799 +  Array& operator=(const Array& aOther) MOZ_DELETE;
   1.800 +};
   1.801 +
   1.802 +// Prefer nsCSSValue::Array for lists of fixed size.
   1.803 +struct nsCSSValueList {
   1.804 +  nsCSSValueList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValueList); }
   1.805 +  ~nsCSSValueList();
   1.806 +
   1.807 +  nsCSSValueList* Clone() const;  // makes a deep copy
   1.808 +  void CloneInto(nsCSSValueList* aList) const; // makes a deep copy into aList
   1.809 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
   1.810 +                      nsCSSValue::Serialization aValueSerialization) const;
   1.811 +
   1.812 +  bool operator==(nsCSSValueList const& aOther) const;
   1.813 +  bool operator!=(const nsCSSValueList& aOther) const
   1.814 +  { return !(*this == aOther); }
   1.815 +
   1.816 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.817 +
   1.818 +  nsCSSValue      mValue;
   1.819 +  nsCSSValueList* mNext;
   1.820 +
   1.821 +private:
   1.822 +  nsCSSValueList(const nsCSSValueList& aCopy) // makes a shallow copy
   1.823 +    : mValue(aCopy.mValue), mNext(nullptr)
   1.824 +  {
   1.825 +    MOZ_COUNT_CTOR(nsCSSValueList);
   1.826 +  }
   1.827 +};
   1.828 +
   1.829 +// nsCSSValueList_heap differs from nsCSSValueList only in being
   1.830 +// refcounted.  It should not be necessary to use this class directly;
   1.831 +// it's an implementation detail of nsCSSValue.
   1.832 +struct nsCSSValueList_heap MOZ_FINAL : public nsCSSValueList {
   1.833 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueList_heap)
   1.834 +
   1.835 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.836 +
   1.837 +private:
   1.838 +  // Private destructor, to discourage deletion outside of Release():
   1.839 +  ~nsCSSValueList_heap()
   1.840 +  {
   1.841 +  }
   1.842 +};
   1.843 +
   1.844 +// This is a reference counted list value.  Note that the object is
   1.845 +// a wrapper for the reference count and a pointer to the head of the
   1.846 +// list, whereas the other list types (such as nsCSSValueList) do
   1.847 +// not have such a wrapper.
   1.848 +struct nsCSSValueSharedList MOZ_FINAL {
   1.849 +  nsCSSValueSharedList()
   1.850 +    : mHead(nullptr)
   1.851 +  {
   1.852 +    MOZ_COUNT_CTOR(nsCSSValueSharedList);
   1.853 +  }
   1.854 +
   1.855 +  // Takes ownership of aList.
   1.856 +  nsCSSValueSharedList(nsCSSValueList* aList)
   1.857 +    : mHead(aList)
   1.858 +  {
   1.859 +    MOZ_COUNT_CTOR(nsCSSValueSharedList);
   1.860 +  }
   1.861 +
   1.862 +private:
   1.863 +  // Private destructor, to discourage deletion outside of Release():
   1.864 +  ~nsCSSValueSharedList();
   1.865 +
   1.866 +public:
   1.867 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueSharedList)
   1.868 +
   1.869 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
   1.870 +                      nsCSSValue::Serialization aValueSerialization) const;
   1.871 +
   1.872 +  bool operator==(nsCSSValueSharedList const& aOther) const;
   1.873 +  bool operator!=(const nsCSSValueSharedList& aOther) const
   1.874 +  { return !(*this == aOther); }
   1.875 +
   1.876 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.877 +
   1.878 +  nsCSSValueList* mHead;
   1.879 +};
   1.880 +
   1.881 +// This has to be here so that the relationship between nsCSSValueList
   1.882 +// and nsCSSValueList_heap is visible.
   1.883 +inline nsCSSValueList*
   1.884 +nsCSSValue::GetListValue()
   1.885 +{
   1.886 +  if (mUnit == eCSSUnit_List)
   1.887 +    return mValue.mList;
   1.888 +  else {
   1.889 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value");
   1.890 +    return mValue.mListDependent;
   1.891 +  }
   1.892 +}
   1.893 +
   1.894 +inline const nsCSSValueList*
   1.895 +nsCSSValue::GetListValue() const
   1.896 +{
   1.897 +  if (mUnit == eCSSUnit_List)
   1.898 +    return mValue.mList;
   1.899 +  else {
   1.900 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value");
   1.901 +    return mValue.mListDependent;
   1.902 +  }
   1.903 +}
   1.904 +
   1.905 +struct nsCSSRect {
   1.906 +  nsCSSRect(void);
   1.907 +  nsCSSRect(const nsCSSRect& aCopy);
   1.908 +  ~nsCSSRect();
   1.909 +
   1.910 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
   1.911 +                      nsCSSValue::Serialization aValueSerialization) const;
   1.912 +
   1.913 +  bool operator==(const nsCSSRect& aOther) const {
   1.914 +    return mTop == aOther.mTop &&
   1.915 +           mRight == aOther.mRight &&
   1.916 +           mBottom == aOther.mBottom &&
   1.917 +           mLeft == aOther.mLeft;
   1.918 +  }
   1.919 +
   1.920 +  bool operator!=(const nsCSSRect& aOther) const {
   1.921 +    return mTop != aOther.mTop ||
   1.922 +           mRight != aOther.mRight ||
   1.923 +           mBottom != aOther.mBottom ||
   1.924 +           mLeft != aOther.mLeft;
   1.925 +  }
   1.926 +
   1.927 +  void SetAllSidesTo(const nsCSSValue& aValue);
   1.928 +
   1.929 +  bool AllSidesEqualTo(const nsCSSValue& aValue) const {
   1.930 +    return mTop == aValue &&
   1.931 +           mRight == aValue &&
   1.932 +           mBottom == aValue &&
   1.933 +           mLeft == aValue;
   1.934 +  }
   1.935 +
   1.936 +  void Reset() {
   1.937 +    mTop.Reset();
   1.938 +    mRight.Reset();
   1.939 +    mBottom.Reset();
   1.940 +    mLeft.Reset();
   1.941 +  }
   1.942 +
   1.943 +  bool HasValue() const {
   1.944 +    return
   1.945 +      mTop.GetUnit() != eCSSUnit_Null ||
   1.946 +      mRight.GetUnit() != eCSSUnit_Null ||
   1.947 +      mBottom.GetUnit() != eCSSUnit_Null ||
   1.948 +      mLeft.GetUnit() != eCSSUnit_Null;
   1.949 +  }
   1.950 +
   1.951 +  nsCSSValue mTop;
   1.952 +  nsCSSValue mRight;
   1.953 +  nsCSSValue mBottom;
   1.954 +  nsCSSValue mLeft;
   1.955 +
   1.956 +  typedef nsCSSValue nsCSSRect::*side_type;
   1.957 +  static const side_type sides[4];
   1.958 +};
   1.959 +
   1.960 +// nsCSSRect_heap differs from nsCSSRect only in being
   1.961 +// refcounted.  It should not be necessary to use this class directly;
   1.962 +// it's an implementation detail of nsCSSValue.
   1.963 +struct nsCSSRect_heap MOZ_FINAL : public nsCSSRect {
   1.964 +  NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap)
   1.965 +
   1.966 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   1.967 +
   1.968 +private:
   1.969 +  // Private destructor, to discourage deletion outside of Release():
   1.970 +  ~nsCSSRect_heap()
   1.971 +  {
   1.972 +  }
   1.973 +};
   1.974 +
   1.975 +// This has to be here so that the relationship between nsCSSRect
   1.976 +// and nsCSSRect_heap is visible.
   1.977 +inline nsCSSRect&
   1.978 +nsCSSValue::GetRectValue()
   1.979 +{
   1.980 +  NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
   1.981 +  return *mValue.mRect;
   1.982 +}
   1.983 +
   1.984 +inline const nsCSSRect&
   1.985 +nsCSSValue::GetRectValue() const
   1.986 +{
   1.987 +  NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
   1.988 +  return *mValue.mRect;
   1.989 +}
   1.990 +
   1.991 +struct nsCSSValuePair {
   1.992 +  nsCSSValuePair()
   1.993 +  {
   1.994 +    MOZ_COUNT_CTOR(nsCSSValuePair);
   1.995 +  }
   1.996 +  nsCSSValuePair(nsCSSUnit aUnit)
   1.997 +    : mXValue(aUnit), mYValue(aUnit)
   1.998 +  {
   1.999 +    MOZ_COUNT_CTOR(nsCSSValuePair);
  1.1000 +  }
  1.1001 +  nsCSSValuePair(const nsCSSValue& aXValue, const nsCSSValue& aYValue)
  1.1002 +    : mXValue(aXValue), mYValue(aYValue)
  1.1003 +  {
  1.1004 +    MOZ_COUNT_CTOR(nsCSSValuePair);
  1.1005 +  }
  1.1006 +  nsCSSValuePair(const nsCSSValuePair& aCopy)
  1.1007 +    : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue)
  1.1008 +  {
  1.1009 +    MOZ_COUNT_CTOR(nsCSSValuePair);
  1.1010 +  }
  1.1011 +  ~nsCSSValuePair()
  1.1012 +  {
  1.1013 +    MOZ_COUNT_DTOR(nsCSSValuePair);
  1.1014 +  }
  1.1015 +
  1.1016 +  bool operator==(const nsCSSValuePair& aOther) const {
  1.1017 +    return mXValue == aOther.mXValue &&
  1.1018 +           mYValue == aOther.mYValue;
  1.1019 +  }
  1.1020 +
  1.1021 +  bool operator!=(const nsCSSValuePair& aOther) const {
  1.1022 +    return mXValue != aOther.mXValue ||
  1.1023 +           mYValue != aOther.mYValue;
  1.1024 +  }
  1.1025 +
  1.1026 +  bool BothValuesEqualTo(const nsCSSValue& aValue) const {
  1.1027 +    return mXValue == aValue &&
  1.1028 +           mYValue == aValue;
  1.1029 +  }
  1.1030 +
  1.1031 +  void SetBothValuesTo(const nsCSSValue& aValue) {
  1.1032 +    mXValue = aValue;
  1.1033 +    mYValue = aValue;
  1.1034 +  }
  1.1035 +
  1.1036 +  void Reset() {
  1.1037 +    mXValue.Reset();
  1.1038 +    mYValue.Reset();
  1.1039 +  }
  1.1040 +
  1.1041 +  bool HasValue() const {
  1.1042 +    return mXValue.GetUnit() != eCSSUnit_Null ||
  1.1043 +           mYValue.GetUnit() != eCSSUnit_Null;
  1.1044 +  }
  1.1045 +
  1.1046 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
  1.1047 +                      nsCSSValue::Serialization aValueSerialization) const;
  1.1048 +
  1.1049 +  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1050 +
  1.1051 +  nsCSSValue mXValue;
  1.1052 +  nsCSSValue mYValue;
  1.1053 +};
  1.1054 +
  1.1055 +// nsCSSValuePair_heap differs from nsCSSValuePair only in being
  1.1056 +// refcounted.  It should not be necessary to use this class directly;
  1.1057 +// it's an implementation detail of nsCSSValue.
  1.1058 +struct nsCSSValuePair_heap MOZ_FINAL : public nsCSSValuePair {
  1.1059 +  // forward constructor
  1.1060 +  nsCSSValuePair_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue)
  1.1061 +      : nsCSSValuePair(aXValue, aYValue)
  1.1062 +  {}
  1.1063 +
  1.1064 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValuePair_heap)
  1.1065 +
  1.1066 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1067 +
  1.1068 +private:
  1.1069 +  // Private destructor, to discourage deletion outside of Release():
  1.1070 +  ~nsCSSValuePair_heap()
  1.1071 +  {
  1.1072 +  }
  1.1073 +};
  1.1074 +
  1.1075 +struct nsCSSValueTriplet {
  1.1076 +    nsCSSValueTriplet()
  1.1077 +    {
  1.1078 +        MOZ_COUNT_CTOR(nsCSSValueTriplet);
  1.1079 +    }
  1.1080 +    nsCSSValueTriplet(nsCSSUnit aUnit)
  1.1081 +        : mXValue(aUnit), mYValue(aUnit), mZValue(aUnit)
  1.1082 +    {
  1.1083 +        MOZ_COUNT_CTOR(nsCSSValueTriplet);
  1.1084 +    }
  1.1085 +    nsCSSValueTriplet(const nsCSSValue& aXValue, 
  1.1086 +                      const nsCSSValue& aYValue, 
  1.1087 +                      const nsCSSValue& aZValue)
  1.1088 +        : mXValue(aXValue), mYValue(aYValue), mZValue(aZValue)
  1.1089 +    {
  1.1090 +        MOZ_COUNT_CTOR(nsCSSValueTriplet);
  1.1091 +    }
  1.1092 +    nsCSSValueTriplet(const nsCSSValueTriplet& aCopy)
  1.1093 +        : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mZValue(aCopy.mZValue)
  1.1094 +    {
  1.1095 +        MOZ_COUNT_CTOR(nsCSSValueTriplet);
  1.1096 +    }
  1.1097 +    ~nsCSSValueTriplet()
  1.1098 +    {
  1.1099 +        MOZ_COUNT_DTOR(nsCSSValueTriplet);
  1.1100 +    }
  1.1101 +
  1.1102 +    bool operator==(const nsCSSValueTriplet& aOther) const {
  1.1103 +        return mXValue == aOther.mXValue &&
  1.1104 +               mYValue == aOther.mYValue &&
  1.1105 +               mZValue == aOther.mZValue;
  1.1106 +    }
  1.1107 +
  1.1108 +    bool operator!=(const nsCSSValueTriplet& aOther) const {
  1.1109 +        return mXValue != aOther.mXValue ||
  1.1110 +               mYValue != aOther.mYValue ||
  1.1111 +               mZValue != aOther.mZValue;
  1.1112 +    }
  1.1113 +
  1.1114 +    bool AllValuesEqualTo(const nsCSSValue& aValue) const {
  1.1115 +        return mXValue == aValue &&
  1.1116 +               mYValue == aValue &&
  1.1117 +               mZValue == aValue;
  1.1118 +    }
  1.1119 +
  1.1120 +    void SetAllValuesTo(const nsCSSValue& aValue) {
  1.1121 +        mXValue = aValue;
  1.1122 +        mYValue = aValue;
  1.1123 +        mZValue = aValue;
  1.1124 +    }
  1.1125 +
  1.1126 +    void Reset() {
  1.1127 +        mXValue.Reset();
  1.1128 +        mYValue.Reset();
  1.1129 +        mZValue.Reset();
  1.1130 +    }
  1.1131 +
  1.1132 +    bool HasValue() const {
  1.1133 +        return mXValue.GetUnit() != eCSSUnit_Null ||
  1.1134 +               mYValue.GetUnit() != eCSSUnit_Null ||
  1.1135 +               mZValue.GetUnit() != eCSSUnit_Null;
  1.1136 +    }
  1.1137 +
  1.1138 +    void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
  1.1139 +                        nsCSSValue::Serialization aValueSerialization) const;
  1.1140 +
  1.1141 +    nsCSSValue mXValue;
  1.1142 +    nsCSSValue mYValue;
  1.1143 +    nsCSSValue mZValue;
  1.1144 +};
  1.1145 +
  1.1146 +// nsCSSValueTriplet_heap differs from nsCSSValueTriplet only in being
  1.1147 +// refcounted.  It should not be necessary to use this class directly;
  1.1148 +// it's an implementation detail of nsCSSValue.
  1.1149 +struct nsCSSValueTriplet_heap MOZ_FINAL : public nsCSSValueTriplet {
  1.1150 +  // forward constructor
  1.1151 +  nsCSSValueTriplet_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue, const nsCSSValue& aZValue)
  1.1152 +    : nsCSSValueTriplet(aXValue, aYValue, aZValue)
  1.1153 +  {}
  1.1154 +
  1.1155 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap)
  1.1156 +
  1.1157 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1158 +
  1.1159 +private:
  1.1160 +  // Private destructor, to discourage deletion outside of Release():
  1.1161 +  ~nsCSSValueTriplet_heap()
  1.1162 +  {
  1.1163 +  }
  1.1164 +};
  1.1165 +
  1.1166 +// This has to be here so that the relationship between nsCSSValuePair
  1.1167 +// and nsCSSValuePair_heap is visible.
  1.1168 +inline nsCSSValuePair&
  1.1169 +nsCSSValue::GetPairValue()
  1.1170 +{
  1.1171 +  NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
  1.1172 +  return *mValue.mPair;
  1.1173 +}
  1.1174 +
  1.1175 +inline const nsCSSValuePair&
  1.1176 +nsCSSValue::GetPairValue() const
  1.1177 +{
  1.1178 +  NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
  1.1179 +  return *mValue.mPair;
  1.1180 +}
  1.1181 +
  1.1182 +inline nsCSSValueTriplet&
  1.1183 +nsCSSValue::GetTripletValue()
  1.1184 +{
  1.1185 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value");
  1.1186 +    return *mValue.mTriplet;
  1.1187 +}
  1.1188 +
  1.1189 +inline const nsCSSValueTriplet&
  1.1190 +nsCSSValue::GetTripletValue() const
  1.1191 +{
  1.1192 +    NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value");
  1.1193 +    return *mValue.mTriplet;
  1.1194 +}
  1.1195 +
  1.1196 +// Maybe should be replaced with nsCSSValueList and nsCSSValue::Array?
  1.1197 +struct nsCSSValuePairList {
  1.1198 +  nsCSSValuePairList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValuePairList); }
  1.1199 +  ~nsCSSValuePairList();
  1.1200 +
  1.1201 +  nsCSSValuePairList* Clone() const; // makes a deep copy
  1.1202 +  void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
  1.1203 +                      nsCSSValue::Serialization aValueSerialization) const;
  1.1204 +
  1.1205 +  bool operator==(const nsCSSValuePairList& aOther) const;
  1.1206 +  bool operator!=(const nsCSSValuePairList& aOther) const
  1.1207 +  { return !(*this == aOther); }
  1.1208 +
  1.1209 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1210 +
  1.1211 +  nsCSSValue          mXValue;
  1.1212 +  nsCSSValue          mYValue;
  1.1213 +  nsCSSValuePairList* mNext;
  1.1214 +
  1.1215 +private:
  1.1216 +  nsCSSValuePairList(const nsCSSValuePairList& aCopy) // makes a shallow copy
  1.1217 +    : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mNext(nullptr)
  1.1218 +  {
  1.1219 +    MOZ_COUNT_CTOR(nsCSSValuePairList);
  1.1220 +  }
  1.1221 +};
  1.1222 +
  1.1223 +// nsCSSValuePairList_heap differs from nsCSSValuePairList only in being
  1.1224 +// refcounted.  It should not be necessary to use this class directly;
  1.1225 +// it's an implementation detail of nsCSSValue.
  1.1226 +struct nsCSSValuePairList_heap MOZ_FINAL : public nsCSSValuePairList {
  1.1227 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValuePairList_heap)
  1.1228 +
  1.1229 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1230 +
  1.1231 +private:
  1.1232 +  // Private destructor, to discourage deletion outside of Release():
  1.1233 +  ~nsCSSValuePairList_heap()
  1.1234 +  {
  1.1235 +  }
  1.1236 +};
  1.1237 +
  1.1238 +// This has to be here so that the relationship between nsCSSValuePairList
  1.1239 +// and nsCSSValuePairList_heap is visible.
  1.1240 +inline nsCSSValuePairList*
  1.1241 +nsCSSValue::GetPairListValue()
  1.1242 +{
  1.1243 +  if (mUnit == eCSSUnit_PairList)
  1.1244 +    return mValue.mPairList;
  1.1245 +  else {
  1.1246 +    NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value");
  1.1247 +    return mValue.mPairListDependent;
  1.1248 +  }
  1.1249 +}
  1.1250 +
  1.1251 +inline const nsCSSValuePairList*
  1.1252 +nsCSSValue::GetPairListValue() const
  1.1253 +{
  1.1254 +  if (mUnit == eCSSUnit_PairList)
  1.1255 +    return mValue.mPairList;
  1.1256 +  else {
  1.1257 +    NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value");
  1.1258 +    return mValue.mPairListDependent;
  1.1259 +  }
  1.1260 +}
  1.1261 +
  1.1262 +struct nsCSSValueGradientStop {
  1.1263 +public:
  1.1264 +  nsCSSValueGradientStop();
  1.1265 +  // needed to keep bloat logs happy when we use the TArray
  1.1266 +  // in nsCSSValueGradient
  1.1267 +  nsCSSValueGradientStop(const nsCSSValueGradientStop& aOther);
  1.1268 +  ~nsCSSValueGradientStop();
  1.1269 +
  1.1270 +  nsCSSValue mLocation;
  1.1271 +  nsCSSValue mColor;
  1.1272 +
  1.1273 +  bool operator==(const nsCSSValueGradientStop& aOther) const
  1.1274 +  {
  1.1275 +    return (mLocation == aOther.mLocation &&
  1.1276 +            mColor == aOther.mColor);
  1.1277 +  }
  1.1278 +
  1.1279 +  bool operator!=(const nsCSSValueGradientStop& aOther) const
  1.1280 +  {
  1.1281 +    return !(*this == aOther);
  1.1282 +  }
  1.1283 +
  1.1284 +  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1285 +};
  1.1286 +
  1.1287 +struct nsCSSValueGradient MOZ_FINAL {
  1.1288 +  nsCSSValueGradient(bool aIsRadial, bool aIsRepeating);
  1.1289 +
  1.1290 +  // true if gradient is radial, false if it is linear
  1.1291 +  bool mIsRadial;
  1.1292 +  bool mIsRepeating;
  1.1293 +  bool mIsLegacySyntax;
  1.1294 +  bool mIsExplicitSize;
  1.1295 +  // line position and angle
  1.1296 +  nsCSSValuePair mBgPos;
  1.1297 +  nsCSSValue mAngle;
  1.1298 +
  1.1299 +  // Only meaningful if mIsRadial is true
  1.1300 +private:
  1.1301 +  nsCSSValue mRadialValues[2];
  1.1302 +public:
  1.1303 +  nsCSSValue& GetRadialShape()
  1.1304 +  {
  1.1305 +    MOZ_ASSERT(!mIsExplicitSize);
  1.1306 +    return mRadialValues[0];
  1.1307 +  }
  1.1308 +  const nsCSSValue& GetRadialShape() const
  1.1309 +  {
  1.1310 +    MOZ_ASSERT(!mIsExplicitSize);
  1.1311 +    return mRadialValues[0];
  1.1312 +  }
  1.1313 +  nsCSSValue& GetRadialSize()
  1.1314 +  {
  1.1315 +    MOZ_ASSERT(!mIsExplicitSize);
  1.1316 +    return mRadialValues[1];
  1.1317 +  }
  1.1318 +  const nsCSSValue& GetRadialSize() const
  1.1319 +  {
  1.1320 +    MOZ_ASSERT(!mIsExplicitSize);
  1.1321 +    return mRadialValues[1];
  1.1322 +  }
  1.1323 +  nsCSSValue& GetRadiusX()
  1.1324 +  {
  1.1325 +    MOZ_ASSERT(mIsExplicitSize);
  1.1326 +    return mRadialValues[0];
  1.1327 +  }
  1.1328 +  const nsCSSValue& GetRadiusX() const
  1.1329 +  {
  1.1330 +    MOZ_ASSERT(mIsExplicitSize);
  1.1331 +    return mRadialValues[0];
  1.1332 +  }
  1.1333 +  nsCSSValue& GetRadiusY()
  1.1334 +  {
  1.1335 +    MOZ_ASSERT(mIsExplicitSize);
  1.1336 +    return mRadialValues[1];
  1.1337 +  }
  1.1338 +  const nsCSSValue& GetRadiusY() const
  1.1339 +  {
  1.1340 +    MOZ_ASSERT(mIsExplicitSize);
  1.1341 +    return mRadialValues[1];
  1.1342 +  }
  1.1343 +
  1.1344 +  InfallibleTArray<nsCSSValueGradientStop> mStops;
  1.1345 +
  1.1346 +  bool operator==(const nsCSSValueGradient& aOther) const
  1.1347 +  {
  1.1348 +    if (mIsRadial != aOther.mIsRadial ||
  1.1349 +        mIsRepeating != aOther.mIsRepeating ||
  1.1350 +        mIsLegacySyntax != aOther.mIsLegacySyntax ||
  1.1351 +        mIsExplicitSize != aOther.mIsExplicitSize ||
  1.1352 +        mBgPos != aOther.mBgPos ||
  1.1353 +        mAngle != aOther.mAngle ||
  1.1354 +        mRadialValues[0] != aOther.mRadialValues[0] ||
  1.1355 +        mRadialValues[1] != aOther.mRadialValues[1])
  1.1356 +      return false;
  1.1357 +
  1.1358 +    if (mStops.Length() != aOther.mStops.Length())
  1.1359 +      return false;
  1.1360 +
  1.1361 +    for (uint32_t i = 0; i < mStops.Length(); i++) {
  1.1362 +      if (mStops[i] != aOther.mStops[i])
  1.1363 +        return false;
  1.1364 +    }
  1.1365 +
  1.1366 +    return true;
  1.1367 +  }
  1.1368 +
  1.1369 +  bool operator!=(const nsCSSValueGradient& aOther) const
  1.1370 +  {
  1.1371 +    return !(*this == aOther);
  1.1372 +  }
  1.1373 +
  1.1374 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient)
  1.1375 +
  1.1376 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1377 +
  1.1378 +private:
  1.1379 +  // Private destructor, to discourage deletion outside of Release():
  1.1380 +  ~nsCSSValueGradient()
  1.1381 +  {
  1.1382 +  }
  1.1383 +
  1.1384 +  nsCSSValueGradient(const nsCSSValueGradient& aOther) MOZ_DELETE;
  1.1385 +  nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther) MOZ_DELETE;
  1.1386 +};
  1.1387 +
  1.1388 +struct nsCSSValueTokenStream MOZ_FINAL {
  1.1389 +  nsCSSValueTokenStream();
  1.1390 +
  1.1391 +private:
  1.1392 +  // Private destructor, to discourage deletion outside of Release():
  1.1393 +  ~nsCSSValueTokenStream();
  1.1394 +
  1.1395 +public:
  1.1396 +  bool operator==(const nsCSSValueTokenStream& aOther) const
  1.1397 +  {
  1.1398 +    bool eq;
  1.1399 +    return mPropertyID == aOther.mPropertyID &&
  1.1400 +           mShorthandPropertyID == aOther.mShorthandPropertyID &&
  1.1401 +           mTokenStream.Equals(aOther.mTokenStream) &&
  1.1402 +           (mBaseURI == aOther.mBaseURI ||
  1.1403 +            (mBaseURI && aOther.mBaseURI &&
  1.1404 +             NS_SUCCEEDED(mBaseURI->Equals(aOther.mBaseURI, &eq)) &&
  1.1405 +             eq)) &&
  1.1406 +           (mSheetURI == aOther.mSheetURI ||
  1.1407 +            (mSheetURI && aOther.mSheetURI &&
  1.1408 +             NS_SUCCEEDED(mSheetURI->Equals(aOther.mSheetURI, &eq)) &&
  1.1409 +             eq)) &&
  1.1410 +           (mSheetPrincipal == aOther.mSheetPrincipal ||
  1.1411 +            (mSheetPrincipal && aOther.mSheetPrincipal &&
  1.1412 +             NS_SUCCEEDED(mSheetPrincipal->Equals(aOther.mSheetPrincipal,
  1.1413 +                                                  &eq)) &&
  1.1414 +             eq));
  1.1415 +  }
  1.1416 +
  1.1417 +  bool operator!=(const nsCSSValueTokenStream& aOther) const
  1.1418 +  {
  1.1419 +    return !(*this == aOther);
  1.1420 +  }
  1.1421 +
  1.1422 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueTokenStream)
  1.1423 +
  1.1424 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1425 +
  1.1426 +  // The property that has mTokenStream as its unparsed specified value.
  1.1427 +  // When a variable reference is used in a shorthand property, a
  1.1428 +  // TokenStream value is stored as the specified value for each of its
  1.1429 +  // component longhand properties.
  1.1430 +  nsCSSProperty mPropertyID;
  1.1431 +
  1.1432 +  // The shorthand property that had a value with a variable reference,
  1.1433 +  // which caused the longhand property identified by mPropertyID to have
  1.1434 +  // a TokenStream value.
  1.1435 +  nsCSSProperty mShorthandPropertyID;
  1.1436 +
  1.1437 +  // The unparsed CSS corresponding to the specified value of the property.
  1.1438 +  // When the value of a shorthand property has a variable reference, the
  1.1439 +  // same mTokenStream value is used on each of the nsCSSValueTokenStream
  1.1440 +  // objects that will be set by parsing the shorthand.
  1.1441 +  nsString mTokenStream;
  1.1442 +
  1.1443 +  nsCOMPtr<nsIURI> mBaseURI;
  1.1444 +  nsCOMPtr<nsIURI> mSheetURI;
  1.1445 +  nsCOMPtr<nsIPrincipal> mSheetPrincipal;
  1.1446 +  nsCSSStyleSheet* mSheet;
  1.1447 +  uint32_t mLineNumber;
  1.1448 +  uint32_t mLineOffset;
  1.1449 +
  1.1450 +  // This table is used to hold a reference on to any ImageValue that results
  1.1451 +  // from re-parsing this token stream at computed value time.  When properties
  1.1452 +  // like background-image contain a normal url(), the Declaration's data block
  1.1453 +  // will hold a reference to the ImageValue.  When a token stream is used,
  1.1454 +  // the Declaration only holds on to this nsCSSValueTokenStream object, and
  1.1455 +  // the ImageValue would only exist for the duration of
  1.1456 +  // nsRuleNode::WalkRuleTree, in the AutoCSSValueArray.  So instead when
  1.1457 +  // we re-parse a token stream and get an ImageValue, we record it in this
  1.1458 +  // table so that the Declaration can be the object that keeps holding
  1.1459 +  // a reference to it.
  1.1460 +  nsTHashtable<nsRefPtrHashKey<mozilla::css::ImageValue> > mImageValues;
  1.1461 +
  1.1462 +private:
  1.1463 +  nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) MOZ_DELETE;
  1.1464 +  nsCSSValueTokenStream& operator=(const nsCSSValueTokenStream& aOther) MOZ_DELETE;
  1.1465 +};
  1.1466 +
  1.1467 +class nsCSSValueFloatColor MOZ_FINAL {
  1.1468 +public:
  1.1469 +  nsCSSValueFloatColor(float aComponent1, float aComponent2, float aComponent3,
  1.1470 +                       float aAlpha)
  1.1471 +    : mComponent1(aComponent1)
  1.1472 +    , mComponent2(aComponent2)
  1.1473 +    , mComponent3(aComponent3)
  1.1474 +    , mAlpha(aAlpha)
  1.1475 +  {
  1.1476 +    MOZ_COUNT_CTOR(nsCSSValueFloatColor);
  1.1477 +  }
  1.1478 +
  1.1479 +private:
  1.1480 +  // Private destructor, to discourage deletion outside of Release():
  1.1481 +  ~nsCSSValueFloatColor()
  1.1482 +  {
  1.1483 +    MOZ_COUNT_DTOR(nsCSSValueFloatColor);
  1.1484 +  }
  1.1485 +
  1.1486 +public:
  1.1487 +  bool operator==(nsCSSValueFloatColor& aOther) const;
  1.1488 +
  1.1489 +  nscolor GetColorValue(nsCSSUnit aUnit) const;
  1.1490 +  bool IsNonTransparentColor() const;
  1.1491 +
  1.1492 +  void AppendToString(nsCSSUnit aUnit, nsAString& aResult) const;
  1.1493 +
  1.1494 +  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
  1.1495 +
  1.1496 +  NS_INLINE_DECL_REFCOUNTING(nsCSSValueFloatColor)
  1.1497 +
  1.1498 +private:
  1.1499 +  // FIXME: We should not be clamping specified RGB color components.
  1.1500 +  float mComponent1;  // 0..1 for RGB, 0..360 for HSL
  1.1501 +  float mComponent2;  // 0..1
  1.1502 +  float mComponent3;  // 0..1
  1.1503 +  float mAlpha;       // 0..1
  1.1504 +
  1.1505 +  nsCSSValueFloatColor(const nsCSSValueFloatColor& aOther) MOZ_DELETE;
  1.1506 +  nsCSSValueFloatColor& operator=(const nsCSSValueFloatColor& aOther)
  1.1507 +                                                                   MOZ_DELETE;
  1.1508 +};
  1.1509 +
  1.1510 +struct nsCSSCornerSizes {
  1.1511 +  nsCSSCornerSizes(void);
  1.1512 +  nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
  1.1513 +  ~nsCSSCornerSizes();
  1.1514 +
  1.1515 +  // argument is a "full corner" constant from nsStyleConsts.h
  1.1516 +  nsCSSValue const & GetCorner(uint32_t aCorner) const {
  1.1517 +    return this->*corners[aCorner];
  1.1518 +  }
  1.1519 +  nsCSSValue & GetCorner(uint32_t aCorner) {
  1.1520 +    return this->*corners[aCorner];
  1.1521 +  }
  1.1522 +
  1.1523 +  bool operator==(const nsCSSCornerSizes& aOther) const {
  1.1524 +    NS_FOR_CSS_FULL_CORNERS(corner) {
  1.1525 +      if (this->GetCorner(corner) != aOther.GetCorner(corner))
  1.1526 +        return false;
  1.1527 +    }
  1.1528 +    return true;
  1.1529 +  }
  1.1530 +
  1.1531 +  bool operator!=(const nsCSSCornerSizes& aOther) const {
  1.1532 +    NS_FOR_CSS_FULL_CORNERS(corner) {
  1.1533 +      if (this->GetCorner(corner) != aOther.GetCorner(corner))
  1.1534 +        return true;
  1.1535 +    }
  1.1536 +    return false;
  1.1537 +  }
  1.1538 +
  1.1539 +  bool HasValue() const {
  1.1540 +    NS_FOR_CSS_FULL_CORNERS(corner) {
  1.1541 +      if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null)
  1.1542 +        return true;
  1.1543 +    }
  1.1544 +    return false;
  1.1545 +  }
  1.1546 +
  1.1547 +  void Reset();
  1.1548 +
  1.1549 +  nsCSSValue mTopLeft;
  1.1550 +  nsCSSValue mTopRight;
  1.1551 +  nsCSSValue mBottomRight;
  1.1552 +  nsCSSValue mBottomLeft;
  1.1553 +
  1.1554 +protected:
  1.1555 +  typedef nsCSSValue nsCSSCornerSizes::*corner_type;
  1.1556 +  static const corner_type corners[4];
  1.1557 +};
  1.1558 +
  1.1559 +#endif /* nsCSSValue_h___ */
  1.1560 +

mercurial