Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* representation of simple property values within CSS declarations */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsCSSValue_h___ |
michael@0 | 9 | #define nsCSSValue_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "mozilla/FloatingPoint.h" |
michael@0 | 13 | #include "mozilla/MemoryReporting.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "nsIPrincipal.h" |
michael@0 | 16 | #include "nsIURI.h" |
michael@0 | 17 | #include "nsCOMPtr.h" |
michael@0 | 18 | #include "nsCRTGlue.h" |
michael@0 | 19 | #include "nsCSSKeywords.h" |
michael@0 | 20 | #include "nsCSSProperty.h" |
michael@0 | 21 | #include "nsColor.h" |
michael@0 | 22 | #include "nsCoord.h" |
michael@0 | 23 | #include "nsRefPtrHashtable.h" |
michael@0 | 24 | #include "nsString.h" |
michael@0 | 25 | #include "nsStringBuffer.h" |
michael@0 | 26 | #include "nsTArray.h" |
michael@0 | 27 | #include "nsStyleConsts.h" |
michael@0 | 28 | |
michael@0 | 29 | class imgRequestProxy; |
michael@0 | 30 | class nsCSSStyleSheet; |
michael@0 | 31 | class nsIDocument; |
michael@0 | 32 | class nsIPrincipal; |
michael@0 | 33 | class nsIURI; |
michael@0 | 34 | class nsPresContext; |
michael@0 | 35 | template <class T> |
michael@0 | 36 | class nsPtrHashKey; |
michael@0 | 37 | |
michael@0 | 38 | // Deletes a linked list iteratively to avoid blowing up the stack (bug 456196). |
michael@0 | 39 | #define NS_CSS_DELETE_LIST_MEMBER(type_, ptr_, member_) \ |
michael@0 | 40 | { \ |
michael@0 | 41 | type_ *cur = (ptr_)->member_; \ |
michael@0 | 42 | (ptr_)->member_ = nullptr; \ |
michael@0 | 43 | while (cur) { \ |
michael@0 | 44 | type_ *dlm_next = cur->member_; \ |
michael@0 | 45 | cur->member_ = nullptr; \ |
michael@0 | 46 | delete cur; \ |
michael@0 | 47 | cur = dlm_next; \ |
michael@0 | 48 | } \ |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | // Clones a linked list iteratively to avoid blowing up the stack. |
michael@0 | 52 | // If it fails to clone the entire list then 'to_' is deleted and |
michael@0 | 53 | // we return null. |
michael@0 | 54 | #define NS_CSS_CLONE_LIST_MEMBER(type_, from_, member_, to_, args_) \ |
michael@0 | 55 | { \ |
michael@0 | 56 | type_ *dest = (to_); \ |
michael@0 | 57 | (to_)->member_ = nullptr; \ |
michael@0 | 58 | for (const type_ *src = (from_)->member_; src; src = src->member_) { \ |
michael@0 | 59 | type_ *clm_clone = src->Clone args_; \ |
michael@0 | 60 | if (!clm_clone) { \ |
michael@0 | 61 | delete (to_); \ |
michael@0 | 62 | return nullptr; \ |
michael@0 | 63 | } \ |
michael@0 | 64 | dest->member_ = clm_clone; \ |
michael@0 | 65 | dest = clm_clone; \ |
michael@0 | 66 | } \ |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | namespace mozilla { |
michael@0 | 70 | namespace css { |
michael@0 | 71 | |
michael@0 | 72 | struct URLValue { |
michael@0 | 73 | // Methods are not inline because using an nsIPrincipal means requiring |
michael@0 | 74 | // caps, which leads to REQUIRES hell, since this header is included all |
michael@0 | 75 | // over. |
michael@0 | 76 | |
michael@0 | 77 | // For both constructors aString must not be null. |
michael@0 | 78 | // For both constructors aOriginPrincipal must not be null. |
michael@0 | 79 | // Construct with a base URI; this will create the actual URI lazily from |
michael@0 | 80 | // aString and aBaseURI. |
michael@0 | 81 | URLValue(nsStringBuffer* aString, nsIURI* aBaseURI, nsIURI* aReferrer, |
michael@0 | 82 | nsIPrincipal* aOriginPrincipal); |
michael@0 | 83 | // Construct with the actual URI. |
michael@0 | 84 | URLValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer, |
michael@0 | 85 | nsIPrincipal* aOriginPrincipal); |
michael@0 | 86 | |
michael@0 | 87 | ~URLValue(); |
michael@0 | 88 | |
michael@0 | 89 | bool operator==(const URLValue& aOther) const; |
michael@0 | 90 | |
michael@0 | 91 | // URIEquals only compares URIs and principals (unlike operator==, which |
michael@0 | 92 | // also compares the original strings). URIEquals also assumes that the |
michael@0 | 93 | // mURI member of both URL objects is non-null. Do NOT call this method |
michael@0 | 94 | // unless you're sure this is the case. |
michael@0 | 95 | bool URIEquals(const URLValue& aOther) const; |
michael@0 | 96 | |
michael@0 | 97 | nsIURI* GetURI() const; |
michael@0 | 98 | |
michael@0 | 99 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 100 | |
michael@0 | 101 | private: |
michael@0 | 102 | // If mURIResolved is false, mURI stores the base URI. |
michael@0 | 103 | // If mURIResolved is true, mURI stores the URI we resolve to; this may be |
michael@0 | 104 | // null if the URI is invalid. |
michael@0 | 105 | mutable nsCOMPtr<nsIURI> mURI; |
michael@0 | 106 | public: |
michael@0 | 107 | nsStringBuffer* mString; // Could use nsRefPtr, but it'd add useless |
michael@0 | 108 | // null-checks; this is never null. |
michael@0 | 109 | nsCOMPtr<nsIURI> mReferrer; |
michael@0 | 110 | nsCOMPtr<nsIPrincipal> mOriginPrincipal; |
michael@0 | 111 | |
michael@0 | 112 | NS_INLINE_DECL_REFCOUNTING(URLValue) |
michael@0 | 113 | |
michael@0 | 114 | private: |
michael@0 | 115 | mutable bool mURIResolved; |
michael@0 | 116 | |
michael@0 | 117 | URLValue(const URLValue& aOther) MOZ_DELETE; |
michael@0 | 118 | URLValue& operator=(const URLValue& aOther) MOZ_DELETE; |
michael@0 | 119 | }; |
michael@0 | 120 | |
michael@0 | 121 | struct ImageValue : public URLValue { |
michael@0 | 122 | // Not making the constructor and destructor inline because that would |
michael@0 | 123 | // force us to include imgIRequest.h, which leads to REQUIRES hell, since |
michael@0 | 124 | // this header is included all over. |
michael@0 | 125 | // aString must not be null. |
michael@0 | 126 | ImageValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer, |
michael@0 | 127 | nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument); |
michael@0 | 128 | ~ImageValue(); |
michael@0 | 129 | |
michael@0 | 130 | // Inherit operator== from URLValue |
michael@0 | 131 | |
michael@0 | 132 | nsRefPtrHashtable<nsPtrHashKey<nsISupports>, imgRequestProxy> mRequests; |
michael@0 | 133 | |
michael@0 | 134 | // Override AddRef and Release to not only log ourselves correctly, but |
michael@0 | 135 | // also so that we delete correctly without a virtual destructor |
michael@0 | 136 | NS_INLINE_DECL_REFCOUNTING(ImageValue) |
michael@0 | 137 | }; |
michael@0 | 138 | |
michael@0 | 139 | struct GridNamedArea { |
michael@0 | 140 | nsString mName; |
michael@0 | 141 | uint32_t mColumnStart; |
michael@0 | 142 | uint32_t mColumnEnd; |
michael@0 | 143 | uint32_t mRowStart; |
michael@0 | 144 | uint32_t mRowEnd; |
michael@0 | 145 | }; |
michael@0 | 146 | |
michael@0 | 147 | struct GridTemplateAreasValue MOZ_FINAL { |
michael@0 | 148 | // Parsed value |
michael@0 | 149 | nsTArray<GridNamedArea> mNamedAreas; |
michael@0 | 150 | |
michael@0 | 151 | // Original <string> values. Length gives the number of rows, |
michael@0 | 152 | // content makes serialization easier. |
michael@0 | 153 | nsTArray<nsString> mTemplates; |
michael@0 | 154 | |
michael@0 | 155 | // How many columns grid-template-areas contributes to the explicit grid. |
michael@0 | 156 | // http://dev.w3.org/csswg/css-grid/#explicit-grid |
michael@0 | 157 | uint32_t mNColumns; |
michael@0 | 158 | |
michael@0 | 159 | // How many rows grid-template-areas contributes to the explicit grid. |
michael@0 | 160 | // http://dev.w3.org/csswg/css-grid/#explicit-grid |
michael@0 | 161 | uint32_t NRows() const { |
michael@0 | 162 | return mTemplates.Length(); |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | GridTemplateAreasValue() |
michael@0 | 166 | : mNColumns(0) |
michael@0 | 167 | // Default constructors for mNamedAreas and mTemplates: empty arrays. |
michael@0 | 168 | { |
michael@0 | 169 | } |
michael@0 | 170 | |
michael@0 | 171 | bool operator==(const GridTemplateAreasValue& aOther) const |
michael@0 | 172 | { |
michael@0 | 173 | return mTemplates == aOther.mTemplates; |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | bool operator!=(const GridTemplateAreasValue& aOther) const |
michael@0 | 177 | { |
michael@0 | 178 | return !(*this == aOther); |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | NS_INLINE_DECL_REFCOUNTING(GridTemplateAreasValue) |
michael@0 | 182 | |
michael@0 | 183 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 184 | |
michael@0 | 185 | private: |
michael@0 | 186 | // Private destructor to make sure this isn't used as a stack variable |
michael@0 | 187 | // or member variable. |
michael@0 | 188 | ~GridTemplateAreasValue() |
michael@0 | 189 | { |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | GridTemplateAreasValue(const GridTemplateAreasValue& aOther) MOZ_DELETE; |
michael@0 | 193 | GridTemplateAreasValue& |
michael@0 | 194 | operator=(const GridTemplateAreasValue& aOther) MOZ_DELETE; |
michael@0 | 195 | }; |
michael@0 | 196 | |
michael@0 | 197 | } |
michael@0 | 198 | } |
michael@0 | 199 | |
michael@0 | 200 | enum nsCSSUnit { |
michael@0 | 201 | eCSSUnit_Null = 0, // (n/a) null unit, value is not specified |
michael@0 | 202 | eCSSUnit_Auto = 1, // (n/a) value is algorithmic |
michael@0 | 203 | eCSSUnit_Inherit = 2, // (n/a) value is inherited |
michael@0 | 204 | eCSSUnit_Initial = 3, // (n/a) value is default UA value |
michael@0 | 205 | eCSSUnit_Unset = 4, // (n/a) value equivalent to 'initial' if on a reset property, 'inherit' otherwise |
michael@0 | 206 | eCSSUnit_None = 5, // (n/a) value is none |
michael@0 | 207 | eCSSUnit_Normal = 6, // (n/a) value is normal (algorithmic, different than auto) |
michael@0 | 208 | eCSSUnit_System_Font = 7, // (n/a) value is -moz-use-system-font |
michael@0 | 209 | eCSSUnit_All = 8, // (n/a) value is all |
michael@0 | 210 | eCSSUnit_Dummy = 9, // (n/a) a fake but specified value, used |
michael@0 | 211 | // only in temporary values |
michael@0 | 212 | eCSSUnit_DummyInherit = 10, // (n/a) a fake but specified value, used |
michael@0 | 213 | // only in temporary values |
michael@0 | 214 | |
michael@0 | 215 | eCSSUnit_String = 11, // (char16_t*) a string value |
michael@0 | 216 | eCSSUnit_Ident = 12, // (char16_t*) a string value |
michael@0 | 217 | eCSSUnit_Families = 13, // (char16_t*) a string value |
michael@0 | 218 | eCSSUnit_Attr = 14, // (char16_t*) a attr(string) value |
michael@0 | 219 | eCSSUnit_Local_Font = 15, // (char16_t*) a local font name |
michael@0 | 220 | eCSSUnit_Font_Format = 16, // (char16_t*) a font format name |
michael@0 | 221 | eCSSUnit_Element = 17, // (char16_t*) an element id |
michael@0 | 222 | |
michael@0 | 223 | eCSSUnit_Array = 20, // (nsCSSValue::Array*) a list of values |
michael@0 | 224 | eCSSUnit_Counter = 21, // (nsCSSValue::Array*) a counter(string,[string]) value |
michael@0 | 225 | eCSSUnit_Counters = 22, // (nsCSSValue::Array*) a counters(string,string[,string]) value |
michael@0 | 226 | eCSSUnit_Cubic_Bezier = 23, // (nsCSSValue::Array*) a list of float values |
michael@0 | 227 | eCSSUnit_Steps = 24, // (nsCSSValue::Array*) a list of (integer, enumerated) |
michael@0 | 228 | eCSSUnit_Function = 25, // (nsCSSValue::Array*) a function with |
michael@0 | 229 | // parameters. First elem of array is name, |
michael@0 | 230 | // an nsCSSKeyword as eCSSUnit_Enumerated, |
michael@0 | 231 | // the rest of the values are arguments. |
michael@0 | 232 | |
michael@0 | 233 | // The top level of a calc() expression is eCSSUnit_Calc. All |
michael@0 | 234 | // remaining eCSSUnit_Calc_* units only occur inside these toplevel |
michael@0 | 235 | // calc values. |
michael@0 | 236 | |
michael@0 | 237 | // eCSSUnit_Calc has an array with exactly 1 element. eCSSUnit_Calc |
michael@0 | 238 | // exists so we can distinguish calc(2em) from 2em as specified values |
michael@0 | 239 | // (but we drop this distinction for nsStyleCoord when we store |
michael@0 | 240 | // computed values). |
michael@0 | 241 | eCSSUnit_Calc = 30, // (nsCSSValue::Array*) calc() value |
michael@0 | 242 | // Plus, Minus, Times_* and Divided have arrays with exactly 2 |
michael@0 | 243 | // elements. a + b + c + d is grouped as ((a + b) + c) + d |
michael@0 | 244 | eCSSUnit_Calc_Plus = 31, // (nsCSSValue::Array*) + node within calc() |
michael@0 | 245 | eCSSUnit_Calc_Minus = 32, // (nsCSSValue::Array*) - within calc |
michael@0 | 246 | eCSSUnit_Calc_Times_L = 33, // (nsCSSValue::Array*) num * val within calc |
michael@0 | 247 | eCSSUnit_Calc_Times_R = 34, // (nsCSSValue::Array*) val * num within calc |
michael@0 | 248 | eCSSUnit_Calc_Divided = 35, // (nsCSSValue::Array*) / within calc |
michael@0 | 249 | |
michael@0 | 250 | eCSSUnit_URL = 40, // (nsCSSValue::URL*) value |
michael@0 | 251 | eCSSUnit_Image = 41, // (nsCSSValue::Image*) value |
michael@0 | 252 | eCSSUnit_Gradient = 42, // (nsCSSValueGradient*) value |
michael@0 | 253 | eCSSUnit_TokenStream = 43, // (nsCSSValueTokenStream*) value |
michael@0 | 254 | eCSSUnit_GridTemplateAreas = 44, // (GridTemplateAreasValue*) |
michael@0 | 255 | // for grid-template-areas |
michael@0 | 256 | |
michael@0 | 257 | eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values |
michael@0 | 258 | eCSSUnit_Triplet = 51, // (nsCSSValueTriplet*) triplet of values |
michael@0 | 259 | eCSSUnit_Rect = 52, // (nsCSSRect*) rectangle (four values) |
michael@0 | 260 | eCSSUnit_List = 53, // (nsCSSValueList*) list of values |
michael@0 | 261 | eCSSUnit_ListDep = 54, // (nsCSSValueList*) same as List |
michael@0 | 262 | // but does not own the list |
michael@0 | 263 | eCSSUnit_SharedList = 55, // (nsCSSValueSharedList*) same as list |
michael@0 | 264 | // but reference counted and shared |
michael@0 | 265 | eCSSUnit_PairList = 56, // (nsCSSValuePairList*) list of value pairs |
michael@0 | 266 | eCSSUnit_PairListDep = 57, // (nsCSSValuePairList*) same as PairList |
michael@0 | 267 | // but does not own the list |
michael@0 | 268 | |
michael@0 | 269 | eCSSUnit_Integer = 70, // (int) simple value |
michael@0 | 270 | eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning |
michael@0 | 271 | |
michael@0 | 272 | eCSSUnit_EnumColor = 80, // (int) enumerated color (kColorKTable) |
michael@0 | 273 | eCSSUnit_RGBColor = 81, // (nscolor) an opaque RGBA value specified as rgb() |
michael@0 | 274 | eCSSUnit_RGBAColor = 82, // (nscolor) an RGBA value specified as rgba() |
michael@0 | 275 | eCSSUnit_HexColor = 83, // (nscolor) an opaque RGBA value specified as #rrggbb |
michael@0 | 276 | eCSSUnit_ShortHexColor = 84, // (nscolor) an opaque RGBA value specified as #rgb |
michael@0 | 277 | eCSSUnit_PercentageRGBColor = 85, // (nsCSSValueFloatColor*) |
michael@0 | 278 | eCSSUnit_PercentageRGBAColor = 86, // (nsCSSValueFloatColor*) |
michael@0 | 279 | eCSSUnit_HSLColor = 87, // (nsCSSValueFloatColor*) |
michael@0 | 280 | eCSSUnit_HSLAColor = 88, // (nsCSSValueFloatColor*) |
michael@0 | 281 | |
michael@0 | 282 | eCSSUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something |
michael@0 | 283 | eCSSUnit_Number = 91, // (float) value is numeric (usually multiplier, different behavior that percent) |
michael@0 | 284 | |
michael@0 | 285 | // Physical length units |
michael@0 | 286 | eCSSUnit_PhysicalMillimeter = 200, // (float) 1/25.4 inch |
michael@0 | 287 | |
michael@0 | 288 | // Length units - relative |
michael@0 | 289 | // Viewport relative measure |
michael@0 | 290 | eCSSUnit_ViewportWidth = 700, // (float) 1% of the width of the initial containing block |
michael@0 | 291 | eCSSUnit_ViewportHeight = 701, // (float) 1% of the height of the initial containing block |
michael@0 | 292 | eCSSUnit_ViewportMin = 702, // (float) smaller of ViewportWidth and ViewportHeight |
michael@0 | 293 | eCSSUnit_ViewportMax = 703, // (float) larger of ViewportWidth and ViewportHeight |
michael@0 | 294 | |
michael@0 | 295 | // Font relative measure |
michael@0 | 296 | eCSSUnit_EM = 800, // (float) == current font size |
michael@0 | 297 | eCSSUnit_XHeight = 801, // (float) distance from top of lower case x to baseline |
michael@0 | 298 | eCSSUnit_Char = 802, // (float) number of characters, used for width with monospace font |
michael@0 | 299 | eCSSUnit_RootEM = 803, // (float) == root element font size |
michael@0 | 300 | |
michael@0 | 301 | // Screen relative measure |
michael@0 | 302 | eCSSUnit_Point = 900, // (float) 4/3 of a CSS pixel |
michael@0 | 303 | eCSSUnit_Inch = 901, // (float) 96 CSS pixels |
michael@0 | 304 | eCSSUnit_Millimeter = 902, // (float) 96/25.4 CSS pixels |
michael@0 | 305 | eCSSUnit_Centimeter = 903, // (float) 96/2.54 CSS pixels |
michael@0 | 306 | eCSSUnit_Pica = 904, // (float) 12 points == 16 CSS pixls |
michael@0 | 307 | eCSSUnit_Pixel = 905, // (float) CSS pixel unit |
michael@0 | 308 | |
michael@0 | 309 | // Angular units |
michael@0 | 310 | eCSSUnit_Degree = 1000, // (float) 360 per circle |
michael@0 | 311 | eCSSUnit_Grad = 1001, // (float) 400 per circle |
michael@0 | 312 | eCSSUnit_Radian = 1002, // (float) 2*pi per circle |
michael@0 | 313 | eCSSUnit_Turn = 1003, // (float) 1 per circle |
michael@0 | 314 | |
michael@0 | 315 | // Frequency units |
michael@0 | 316 | eCSSUnit_Hertz = 2000, // (float) 1/seconds |
michael@0 | 317 | eCSSUnit_Kilohertz = 2001, // (float) 1000 Hertz |
michael@0 | 318 | |
michael@0 | 319 | // Time units |
michael@0 | 320 | eCSSUnit_Seconds = 3000, // (float) Standard time |
michael@0 | 321 | eCSSUnit_Milliseconds = 3001, // (float) 1/1000 second |
michael@0 | 322 | |
michael@0 | 323 | // Flexible fraction (CSS Grid) |
michael@0 | 324 | eCSSUnit_FlexFraction = 4000 // (float) Fraction of free space |
michael@0 | 325 | }; |
michael@0 | 326 | |
michael@0 | 327 | struct nsCSSValueGradient; |
michael@0 | 328 | struct nsCSSValuePair; |
michael@0 | 329 | struct nsCSSValuePair_heap; |
michael@0 | 330 | struct nsCSSValueTokenStream; |
michael@0 | 331 | struct nsCSSRect; |
michael@0 | 332 | struct nsCSSRect_heap; |
michael@0 | 333 | struct nsCSSValueList; |
michael@0 | 334 | struct nsCSSValueList_heap; |
michael@0 | 335 | struct nsCSSValueSharedList; |
michael@0 | 336 | struct nsCSSValuePairList; |
michael@0 | 337 | struct nsCSSValuePairList_heap; |
michael@0 | 338 | struct nsCSSValueTriplet; |
michael@0 | 339 | struct nsCSSValueTriplet_heap; |
michael@0 | 340 | class nsCSSValueFloatColor; |
michael@0 | 341 | |
michael@0 | 342 | class nsCSSValue { |
michael@0 | 343 | public: |
michael@0 | 344 | struct Array; |
michael@0 | 345 | friend struct Array; |
michael@0 | 346 | |
michael@0 | 347 | friend struct mozilla::css::URLValue; |
michael@0 | 348 | |
michael@0 | 349 | friend struct mozilla::css::ImageValue; |
michael@0 | 350 | |
michael@0 | 351 | // for valueless units only (null, auto, inherit, none, all, normal) |
michael@0 | 352 | explicit nsCSSValue(nsCSSUnit aUnit = eCSSUnit_Null) |
michael@0 | 353 | : mUnit(aUnit) |
michael@0 | 354 | { |
michael@0 | 355 | NS_ABORT_IF_FALSE(aUnit <= eCSSUnit_DummyInherit, "not a valueless unit"); |
michael@0 | 356 | } |
michael@0 | 357 | |
michael@0 | 358 | nsCSSValue(int32_t aValue, nsCSSUnit aUnit); |
michael@0 | 359 | nsCSSValue(float aValue, nsCSSUnit aUnit); |
michael@0 | 360 | nsCSSValue(const nsString& aValue, nsCSSUnit aUnit); |
michael@0 | 361 | nsCSSValue(Array* aArray, nsCSSUnit aUnit); |
michael@0 | 362 | explicit nsCSSValue(mozilla::css::URLValue* aValue); |
michael@0 | 363 | explicit nsCSSValue(mozilla::css::ImageValue* aValue); |
michael@0 | 364 | explicit nsCSSValue(nsCSSValueGradient* aValue); |
michael@0 | 365 | explicit nsCSSValue(nsCSSValueTokenStream* aValue); |
michael@0 | 366 | explicit nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue); |
michael@0 | 367 | nsCSSValue(const nsCSSValue& aCopy); |
michael@0 | 368 | ~nsCSSValue() { Reset(); } |
michael@0 | 369 | |
michael@0 | 370 | nsCSSValue& operator=(const nsCSSValue& aCopy); |
michael@0 | 371 | bool operator==(const nsCSSValue& aOther) const; |
michael@0 | 372 | |
michael@0 | 373 | bool operator!=(const nsCSSValue& aOther) const |
michael@0 | 374 | { |
michael@0 | 375 | return !(*this == aOther); |
michael@0 | 376 | } |
michael@0 | 377 | |
michael@0 | 378 | // Enum for AppendToString's aValueSerialization argument. |
michael@0 | 379 | enum Serialization { eNormalized, eAuthorSpecified }; |
michael@0 | 380 | |
michael@0 | 381 | /** |
michael@0 | 382 | * Serialize |this| as a specified value for |aProperty| and append |
michael@0 | 383 | * it to |aResult|. |
michael@0 | 384 | */ |
michael@0 | 385 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 386 | Serialization aValueSerialization) const; |
michael@0 | 387 | |
michael@0 | 388 | nsCSSUnit GetUnit() const { return mUnit; } |
michael@0 | 389 | bool IsLengthUnit() const |
michael@0 | 390 | { return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; } |
michael@0 | 391 | /** |
michael@0 | 392 | * A "fixed" length unit is one that means a specific physical length |
michael@0 | 393 | * which we try to match based on the physical characteristics of an |
michael@0 | 394 | * output device. |
michael@0 | 395 | */ |
michael@0 | 396 | bool IsFixedLengthUnit() const |
michael@0 | 397 | { return mUnit == eCSSUnit_PhysicalMillimeter; } |
michael@0 | 398 | /** |
michael@0 | 399 | * What the spec calls relative length units is, for us, split |
michael@0 | 400 | * between relative length units and pixel length units. |
michael@0 | 401 | * |
michael@0 | 402 | * A "relative" length unit is a multiple of some derived metric, |
michael@0 | 403 | * such as a font em-size, which itself was controlled by an input CSS |
michael@0 | 404 | * length. Relative length units should not be scaled by zooming, since |
michael@0 | 405 | * the underlying CSS length would already have been scaled. |
michael@0 | 406 | */ |
michael@0 | 407 | bool IsRelativeLengthUnit() const |
michael@0 | 408 | { return eCSSUnit_EM <= mUnit && mUnit <= eCSSUnit_RootEM; } |
michael@0 | 409 | /** |
michael@0 | 410 | * A "pixel" length unit is a some multiple of CSS pixels. |
michael@0 | 411 | */ |
michael@0 | 412 | bool IsPixelLengthUnit() const |
michael@0 | 413 | { return eCSSUnit_Point <= mUnit && mUnit <= eCSSUnit_Pixel; } |
michael@0 | 414 | bool IsAngularUnit() const |
michael@0 | 415 | { return eCSSUnit_Degree <= mUnit && mUnit <= eCSSUnit_Turn; } |
michael@0 | 416 | bool IsFrequencyUnit() const |
michael@0 | 417 | { return eCSSUnit_Hertz <= mUnit && mUnit <= eCSSUnit_Kilohertz; } |
michael@0 | 418 | bool IsTimeUnit() const |
michael@0 | 419 | { return eCSSUnit_Seconds <= mUnit && mUnit <= eCSSUnit_Milliseconds; } |
michael@0 | 420 | bool IsCalcUnit() const |
michael@0 | 421 | { return eCSSUnit_Calc <= mUnit && mUnit <= eCSSUnit_Calc_Divided; } |
michael@0 | 422 | |
michael@0 | 423 | bool UnitHasStringValue() const |
michael@0 | 424 | { return eCSSUnit_String <= mUnit && mUnit <= eCSSUnit_Element; } |
michael@0 | 425 | bool UnitHasArrayValue() const |
michael@0 | 426 | { return eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Calc_Divided; } |
michael@0 | 427 | |
michael@0 | 428 | // Checks for the nsCSSValue being of a particular type of color unit: |
michael@0 | 429 | // |
michael@0 | 430 | // - IsIntegerColorUnit returns true for: |
michael@0 | 431 | // eCSSUnit_RGBColor -- rgb(int,int,int) |
michael@0 | 432 | // eCSSUnit_RGBAColor -- rgba(int,int,int,float) |
michael@0 | 433 | // eCSSUnit_HexColor -- #rrggbb |
michael@0 | 434 | // eCSSUnit_ShortHexColor -- #rgb |
michael@0 | 435 | // |
michael@0 | 436 | // - IsFLoatColorUnit returns true for: |
michael@0 | 437 | // eCSSUnit_PercentageRGBColor -- rgb(%,%,%) |
michael@0 | 438 | // eCSSUnit_PercentageRGBAColor -- rgba(%,%,%,float) |
michael@0 | 439 | // eCSSUnit_HSLColor -- hsl(float,%,%) |
michael@0 | 440 | // eCSSUnit_HSLAColor -- hsla(float,%,%,float) |
michael@0 | 441 | // |
michael@0 | 442 | // - IsNumericColorUnit returns true for any of the above units. |
michael@0 | 443 | // |
michael@0 | 444 | // Note that color keywords and system colors are represented by |
michael@0 | 445 | // eCSSUnit_EnumColor and eCSSUnit_Ident. |
michael@0 | 446 | bool IsIntegerColorUnit() const { return IsIntegerColorUnit(mUnit); } |
michael@0 | 447 | bool IsFloatColorUnit() const { return IsFloatColorUnit(mUnit); } |
michael@0 | 448 | bool IsNumericColorUnit() const { return IsNumericColorUnit(mUnit); } |
michael@0 | 449 | static bool IsIntegerColorUnit(nsCSSUnit aUnit) |
michael@0 | 450 | { return eCSSUnit_RGBColor <= aUnit && aUnit <= eCSSUnit_ShortHexColor; } |
michael@0 | 451 | static bool IsFloatColorUnit(nsCSSUnit aUnit) |
michael@0 | 452 | { return eCSSUnit_PercentageRGBColor <= aUnit && |
michael@0 | 453 | aUnit <= eCSSUnit_HSLAColor; } |
michael@0 | 454 | static bool IsNumericColorUnit(nsCSSUnit aUnit) |
michael@0 | 455 | { return IsIntegerColorUnit(aUnit) || IsFloatColorUnit(aUnit); } |
michael@0 | 456 | |
michael@0 | 457 | int32_t GetIntValue() const |
michael@0 | 458 | { |
michael@0 | 459 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Integer || |
michael@0 | 460 | mUnit == eCSSUnit_Enumerated || |
michael@0 | 461 | mUnit == eCSSUnit_EnumColor, |
michael@0 | 462 | "not an int value"); |
michael@0 | 463 | return mValue.mInt; |
michael@0 | 464 | } |
michael@0 | 465 | |
michael@0 | 466 | nsCSSKeyword GetKeywordValue() const |
michael@0 | 467 | { |
michael@0 | 468 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Enumerated, "not a keyword value"); |
michael@0 | 469 | return static_cast<nsCSSKeyword>(mValue.mInt); |
michael@0 | 470 | } |
michael@0 | 471 | |
michael@0 | 472 | float GetPercentValue() const |
michael@0 | 473 | { |
michael@0 | 474 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Percent, "not a percent value"); |
michael@0 | 475 | return mValue.mFloat; |
michael@0 | 476 | } |
michael@0 | 477 | |
michael@0 | 478 | float GetFloatValue() const |
michael@0 | 479 | { |
michael@0 | 480 | NS_ABORT_IF_FALSE(eCSSUnit_Number <= mUnit, "not a float value"); |
michael@0 | 481 | MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); |
michael@0 | 482 | return mValue.mFloat; |
michael@0 | 483 | } |
michael@0 | 484 | |
michael@0 | 485 | float GetAngleValue() const |
michael@0 | 486 | { |
michael@0 | 487 | NS_ABORT_IF_FALSE(eCSSUnit_Degree <= mUnit && |
michael@0 | 488 | mUnit <= eCSSUnit_Turn, "not an angle value"); |
michael@0 | 489 | return mValue.mFloat; |
michael@0 | 490 | } |
michael@0 | 491 | |
michael@0 | 492 | // Converts any angle to radians. |
michael@0 | 493 | double GetAngleValueInRadians() const; |
michael@0 | 494 | |
michael@0 | 495 | nsAString& GetStringValue(nsAString& aBuffer) const |
michael@0 | 496 | { |
michael@0 | 497 | NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value"); |
michael@0 | 498 | aBuffer.Truncate(); |
michael@0 | 499 | uint32_t len = NS_strlen(GetBufferValue(mValue.mString)); |
michael@0 | 500 | mValue.mString->ToString(len, aBuffer); |
michael@0 | 501 | return aBuffer; |
michael@0 | 502 | } |
michael@0 | 503 | |
michael@0 | 504 | const char16_t* GetStringBufferValue() const |
michael@0 | 505 | { |
michael@0 | 506 | NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value"); |
michael@0 | 507 | return GetBufferValue(mValue.mString); |
michael@0 | 508 | } |
michael@0 | 509 | |
michael@0 | 510 | nscolor GetColorValue() const; |
michael@0 | 511 | bool IsNonTransparentColor() const; |
michael@0 | 512 | |
michael@0 | 513 | Array* GetArrayValue() const |
michael@0 | 514 | { |
michael@0 | 515 | NS_ABORT_IF_FALSE(UnitHasArrayValue(), "not an array value"); |
michael@0 | 516 | return mValue.mArray; |
michael@0 | 517 | } |
michael@0 | 518 | |
michael@0 | 519 | nsIURI* GetURLValue() const |
michael@0 | 520 | { |
michael@0 | 521 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image, |
michael@0 | 522 | "not a URL value"); |
michael@0 | 523 | return mUnit == eCSSUnit_URL ? |
michael@0 | 524 | mValue.mURL->GetURI() : mValue.mImage->GetURI(); |
michael@0 | 525 | } |
michael@0 | 526 | |
michael@0 | 527 | nsCSSValueGradient* GetGradientValue() const |
michael@0 | 528 | { |
michael@0 | 529 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Gradient, "not a gradient value"); |
michael@0 | 530 | return mValue.mGradient; |
michael@0 | 531 | } |
michael@0 | 532 | |
michael@0 | 533 | nsCSSValueTokenStream* GetTokenStreamValue() const |
michael@0 | 534 | { |
michael@0 | 535 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_TokenStream, "not a token stream value"); |
michael@0 | 536 | return mValue.mTokenStream; |
michael@0 | 537 | } |
michael@0 | 538 | |
michael@0 | 539 | nsCSSValueSharedList* GetSharedListValue() const |
michael@0 | 540 | { |
michael@0 | 541 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_SharedList, "not a shared list value"); |
michael@0 | 542 | return mValue.mSharedList; |
michael@0 | 543 | } |
michael@0 | 544 | |
michael@0 | 545 | // bodies of these are below |
michael@0 | 546 | inline nsCSSValuePair& GetPairValue(); |
michael@0 | 547 | inline const nsCSSValuePair& GetPairValue() const; |
michael@0 | 548 | |
michael@0 | 549 | inline nsCSSRect& GetRectValue(); |
michael@0 | 550 | inline const nsCSSRect& GetRectValue() const; |
michael@0 | 551 | |
michael@0 | 552 | inline nsCSSValueList* GetListValue(); |
michael@0 | 553 | inline const nsCSSValueList* GetListValue() const; |
michael@0 | 554 | |
michael@0 | 555 | inline nsCSSValuePairList* GetPairListValue(); |
michael@0 | 556 | inline const nsCSSValuePairList* GetPairListValue() const; |
michael@0 | 557 | |
michael@0 | 558 | inline nsCSSValueTriplet& GetTripletValue(); |
michael@0 | 559 | inline const nsCSSValueTriplet& GetTripletValue() const; |
michael@0 | 560 | |
michael@0 | 561 | |
michael@0 | 562 | mozilla::css::URLValue* GetURLStructValue() const |
michael@0 | 563 | { |
michael@0 | 564 | // Not allowing this for Image values, because if the caller takes |
michael@0 | 565 | // a ref to them they won't be able to delete them properly. |
michael@0 | 566 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL, "not a URL value"); |
michael@0 | 567 | return mValue.mURL; |
michael@0 | 568 | } |
michael@0 | 569 | |
michael@0 | 570 | mozilla::css::ImageValue* GetImageStructValue() const |
michael@0 | 571 | { |
michael@0 | 572 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value"); |
michael@0 | 573 | return mValue.mImage; |
michael@0 | 574 | } |
michael@0 | 575 | |
michael@0 | 576 | mozilla::css::GridTemplateAreasValue* GetGridTemplateAreas() const |
michael@0 | 577 | { |
michael@0 | 578 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_GridTemplateAreas, |
michael@0 | 579 | "not a grid-template-areas value"); |
michael@0 | 580 | return mValue.mGridTemplateAreas; |
michael@0 | 581 | } |
michael@0 | 582 | |
michael@0 | 583 | const char16_t* GetOriginalURLValue() const |
michael@0 | 584 | { |
michael@0 | 585 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image, |
michael@0 | 586 | "not a URL value"); |
michael@0 | 587 | return GetBufferValue(mUnit == eCSSUnit_URL ? |
michael@0 | 588 | mValue.mURL->mString : |
michael@0 | 589 | mValue.mImage->mString); |
michael@0 | 590 | } |
michael@0 | 591 | |
michael@0 | 592 | // Not making this inline because that would force us to include |
michael@0 | 593 | // imgIRequest.h, which leads to REQUIRES hell, since this header is included |
michael@0 | 594 | // all over. |
michael@0 | 595 | imgRequestProxy* GetImageValue(nsIDocument* aDocument) const; |
michael@0 | 596 | |
michael@0 | 597 | nscoord GetFixedLength(nsPresContext* aPresContext) const; |
michael@0 | 598 | nscoord GetPixelLength() const; |
michael@0 | 599 | |
michael@0 | 600 | void Reset() // sets to null |
michael@0 | 601 | { |
michael@0 | 602 | if (mUnit != eCSSUnit_Null) |
michael@0 | 603 | DoReset(); |
michael@0 | 604 | } |
michael@0 | 605 | private: |
michael@0 | 606 | void DoReset(); |
michael@0 | 607 | |
michael@0 | 608 | public: |
michael@0 | 609 | void SetIntValue(int32_t aValue, nsCSSUnit aUnit); |
michael@0 | 610 | void SetPercentValue(float aValue); |
michael@0 | 611 | void SetFloatValue(float aValue, nsCSSUnit aUnit); |
michael@0 | 612 | void SetStringValue(const nsString& aValue, nsCSSUnit aUnit); |
michael@0 | 613 | void SetColorValue(nscolor aValue); |
michael@0 | 614 | void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit); |
michael@0 | 615 | void SetFloatColorValue(float aComponent1, |
michael@0 | 616 | float aComponent2, |
michael@0 | 617 | float aComponent3, |
michael@0 | 618 | float aAlpha, nsCSSUnit aUnit); |
michael@0 | 619 | void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit); |
michael@0 | 620 | void SetURLValue(mozilla::css::URLValue* aURI); |
michael@0 | 621 | void SetImageValue(mozilla::css::ImageValue* aImage); |
michael@0 | 622 | void SetGradientValue(nsCSSValueGradient* aGradient); |
michael@0 | 623 | void SetTokenStreamValue(nsCSSValueTokenStream* aTokenStream); |
michael@0 | 624 | void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue); |
michael@0 | 625 | void SetPairValue(const nsCSSValuePair* aPair); |
michael@0 | 626 | void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue); |
michael@0 | 627 | void SetSharedListValue(nsCSSValueSharedList* aList); |
michael@0 | 628 | void SetDependentListValue(nsCSSValueList* aList); |
michael@0 | 629 | void SetDependentPairListValue(nsCSSValuePairList* aList); |
michael@0 | 630 | void SetTripletValue(const nsCSSValueTriplet* aTriplet); |
michael@0 | 631 | void SetTripletValue(const nsCSSValue& xValue, const nsCSSValue& yValue, const nsCSSValue& zValue); |
michael@0 | 632 | void SetAutoValue(); |
michael@0 | 633 | void SetInheritValue(); |
michael@0 | 634 | void SetInitialValue(); |
michael@0 | 635 | void SetUnsetValue(); |
michael@0 | 636 | void SetNoneValue(); |
michael@0 | 637 | void SetAllValue(); |
michael@0 | 638 | void SetNormalValue(); |
michael@0 | 639 | void SetSystemFontValue(); |
michael@0 | 640 | void SetDummyValue(); |
michael@0 | 641 | void SetDummyInheritValue(); |
michael@0 | 642 | |
michael@0 | 643 | // These are a little different - they allocate storage for you and |
michael@0 | 644 | // return a handle. |
michael@0 | 645 | nsCSSRect& SetRectValue(); |
michael@0 | 646 | nsCSSValueList* SetListValue(); |
michael@0 | 647 | nsCSSValuePairList* SetPairListValue(); |
michael@0 | 648 | |
michael@0 | 649 | void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const |
michael@0 | 650 | |
michael@0 | 651 | // Initializes as a function value with the specified function id. |
michael@0 | 652 | Array* InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs); |
michael@0 | 653 | // Checks if this is a function value with the specified function id. |
michael@0 | 654 | bool EqualsFunction(nsCSSKeyword aFunctionId) const; |
michael@0 | 655 | |
michael@0 | 656 | // Returns an already addrefed buffer. Guaranteed to return non-null. |
michael@0 | 657 | // (Will abort on allocation failure.) |
michael@0 | 658 | static already_AddRefed<nsStringBuffer> |
michael@0 | 659 | BufferFromString(const nsString& aValue); |
michael@0 | 660 | |
michael@0 | 661 | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 662 | |
michael@0 | 663 | private: |
michael@0 | 664 | static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) { |
michael@0 | 665 | return static_cast<char16_t*>(aBuffer->Data()); |
michael@0 | 666 | } |
michael@0 | 667 | |
michael@0 | 668 | protected: |
michael@0 | 669 | nsCSSUnit mUnit; |
michael@0 | 670 | union { |
michael@0 | 671 | int32_t mInt; |
michael@0 | 672 | float mFloat; |
michael@0 | 673 | // Note: the capacity of the buffer may exceed the length of the string. |
michael@0 | 674 | // If we're of a string type, mString is not null. |
michael@0 | 675 | nsStringBuffer* mString; |
michael@0 | 676 | nscolor mColor; |
michael@0 | 677 | Array* mArray; |
michael@0 | 678 | mozilla::css::URLValue* mURL; |
michael@0 | 679 | mozilla::css::ImageValue* mImage; |
michael@0 | 680 | mozilla::css::GridTemplateAreasValue* mGridTemplateAreas; |
michael@0 | 681 | nsCSSValueGradient* mGradient; |
michael@0 | 682 | nsCSSValueTokenStream* mTokenStream; |
michael@0 | 683 | nsCSSValuePair_heap* mPair; |
michael@0 | 684 | nsCSSRect_heap* mRect; |
michael@0 | 685 | nsCSSValueTriplet_heap* mTriplet; |
michael@0 | 686 | nsCSSValueList_heap* mList; |
michael@0 | 687 | nsCSSValueList* mListDependent; |
michael@0 | 688 | nsCSSValueSharedList* mSharedList; |
michael@0 | 689 | nsCSSValuePairList_heap* mPairList; |
michael@0 | 690 | nsCSSValuePairList* mPairListDependent; |
michael@0 | 691 | nsCSSValueFloatColor* mFloatColor; |
michael@0 | 692 | } mValue; |
michael@0 | 693 | }; |
michael@0 | 694 | |
michael@0 | 695 | struct nsCSSValue::Array MOZ_FINAL { |
michael@0 | 696 | |
michael@0 | 697 | // return |Array| with reference count of zero |
michael@0 | 698 | static Array* Create(size_t aItemCount) { |
michael@0 | 699 | return new (aItemCount) Array(aItemCount); |
michael@0 | 700 | } |
michael@0 | 701 | |
michael@0 | 702 | nsCSSValue& operator[](size_t aIndex) { |
michael@0 | 703 | NS_ABORT_IF_FALSE(aIndex < mCount, "out of range"); |
michael@0 | 704 | return mArray[aIndex]; |
michael@0 | 705 | } |
michael@0 | 706 | |
michael@0 | 707 | const nsCSSValue& operator[](size_t aIndex) const { |
michael@0 | 708 | NS_ABORT_IF_FALSE(aIndex < mCount, "out of range"); |
michael@0 | 709 | return mArray[aIndex]; |
michael@0 | 710 | } |
michael@0 | 711 | |
michael@0 | 712 | nsCSSValue& Item(size_t aIndex) { return (*this)[aIndex]; } |
michael@0 | 713 | const nsCSSValue& Item(size_t aIndex) const { return (*this)[aIndex]; } |
michael@0 | 714 | |
michael@0 | 715 | size_t Count() const { return mCount; } |
michael@0 | 716 | |
michael@0 | 717 | bool operator==(const Array& aOther) const |
michael@0 | 718 | { |
michael@0 | 719 | if (mCount != aOther.mCount) |
michael@0 | 720 | return false; |
michael@0 | 721 | for (size_t i = 0; i < mCount; ++i) |
michael@0 | 722 | if ((*this)[i] != aOther[i]) |
michael@0 | 723 | return false; |
michael@0 | 724 | return true; |
michael@0 | 725 | } |
michael@0 | 726 | |
michael@0 | 727 | // XXXdholbert This uses a size_t ref count. Should we use a variant |
michael@0 | 728 | // of NS_INLINE_DECL_REFCOUNTING that takes a type as an argument? |
michael@0 | 729 | void AddRef() { |
michael@0 | 730 | if (mRefCnt == size_t(-1)) { // really want SIZE_MAX |
michael@0 | 731 | NS_WARNING("refcount overflow, leaking nsCSSValue::Array"); |
michael@0 | 732 | return; |
michael@0 | 733 | } |
michael@0 | 734 | ++mRefCnt; |
michael@0 | 735 | NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this)); |
michael@0 | 736 | } |
michael@0 | 737 | void Release() { |
michael@0 | 738 | if (mRefCnt == size_t(-1)) { // really want SIZE_MAX |
michael@0 | 739 | NS_WARNING("refcount overflow, leaking nsCSSValue::Array"); |
michael@0 | 740 | return; |
michael@0 | 741 | } |
michael@0 | 742 | --mRefCnt; |
michael@0 | 743 | NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array"); |
michael@0 | 744 | if (mRefCnt == 0) |
michael@0 | 745 | delete this; |
michael@0 | 746 | } |
michael@0 | 747 | |
michael@0 | 748 | private: |
michael@0 | 749 | |
michael@0 | 750 | size_t mRefCnt; |
michael@0 | 751 | const size_t mCount; |
michael@0 | 752 | // This must be the last sub-object, since we extend this array to |
michael@0 | 753 | // be of size mCount; it needs to be a sub-object so it gets proper |
michael@0 | 754 | // alignment. |
michael@0 | 755 | nsCSSValue mArray[1]; |
michael@0 | 756 | |
michael@0 | 757 | void* operator new(size_t aSelfSize, size_t aItemCount) CPP_THROW_NEW { |
michael@0 | 758 | NS_ABORT_IF_FALSE(aItemCount > 0, "cannot have a 0 item count"); |
michael@0 | 759 | return ::operator new(aSelfSize + sizeof(nsCSSValue) * (aItemCount - 1)); |
michael@0 | 760 | } |
michael@0 | 761 | |
michael@0 | 762 | void operator delete(void* aPtr) { ::operator delete(aPtr); } |
michael@0 | 763 | |
michael@0 | 764 | nsCSSValue* First() { return mArray; } |
michael@0 | 765 | |
michael@0 | 766 | const nsCSSValue* First() const { return mArray; } |
michael@0 | 767 | |
michael@0 | 768 | #define CSSVALUE_LIST_FOR_EXTRA_VALUES(var) \ |
michael@0 | 769 | for (nsCSSValue *var = First() + 1, *var##_end = First() + mCount; \ |
michael@0 | 770 | var != var##_end; ++var) |
michael@0 | 771 | |
michael@0 | 772 | Array(size_t aItemCount) |
michael@0 | 773 | : mRefCnt(0) |
michael@0 | 774 | , mCount(aItemCount) |
michael@0 | 775 | { |
michael@0 | 776 | MOZ_COUNT_CTOR(nsCSSValue::Array); |
michael@0 | 777 | CSSVALUE_LIST_FOR_EXTRA_VALUES(val) { |
michael@0 | 778 | new (val) nsCSSValue(); |
michael@0 | 779 | } |
michael@0 | 780 | } |
michael@0 | 781 | |
michael@0 | 782 | ~Array() |
michael@0 | 783 | { |
michael@0 | 784 | MOZ_COUNT_DTOR(nsCSSValue::Array); |
michael@0 | 785 | CSSVALUE_LIST_FOR_EXTRA_VALUES(val) { |
michael@0 | 786 | val->~nsCSSValue(); |
michael@0 | 787 | } |
michael@0 | 788 | } |
michael@0 | 789 | |
michael@0 | 790 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 791 | |
michael@0 | 792 | #undef CSSVALUE_LIST_FOR_EXTRA_VALUES |
michael@0 | 793 | |
michael@0 | 794 | private: |
michael@0 | 795 | Array(const Array& aOther) MOZ_DELETE; |
michael@0 | 796 | Array& operator=(const Array& aOther) MOZ_DELETE; |
michael@0 | 797 | }; |
michael@0 | 798 | |
michael@0 | 799 | // Prefer nsCSSValue::Array for lists of fixed size. |
michael@0 | 800 | struct nsCSSValueList { |
michael@0 | 801 | nsCSSValueList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValueList); } |
michael@0 | 802 | ~nsCSSValueList(); |
michael@0 | 803 | |
michael@0 | 804 | nsCSSValueList* Clone() const; // makes a deep copy |
michael@0 | 805 | void CloneInto(nsCSSValueList* aList) const; // makes a deep copy into aList |
michael@0 | 806 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 807 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 808 | |
michael@0 | 809 | bool operator==(nsCSSValueList const& aOther) const; |
michael@0 | 810 | bool operator!=(const nsCSSValueList& aOther) const |
michael@0 | 811 | { return !(*this == aOther); } |
michael@0 | 812 | |
michael@0 | 813 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 814 | |
michael@0 | 815 | nsCSSValue mValue; |
michael@0 | 816 | nsCSSValueList* mNext; |
michael@0 | 817 | |
michael@0 | 818 | private: |
michael@0 | 819 | nsCSSValueList(const nsCSSValueList& aCopy) // makes a shallow copy |
michael@0 | 820 | : mValue(aCopy.mValue), mNext(nullptr) |
michael@0 | 821 | { |
michael@0 | 822 | MOZ_COUNT_CTOR(nsCSSValueList); |
michael@0 | 823 | } |
michael@0 | 824 | }; |
michael@0 | 825 | |
michael@0 | 826 | // nsCSSValueList_heap differs from nsCSSValueList only in being |
michael@0 | 827 | // refcounted. It should not be necessary to use this class directly; |
michael@0 | 828 | // it's an implementation detail of nsCSSValue. |
michael@0 | 829 | struct nsCSSValueList_heap MOZ_FINAL : public nsCSSValueList { |
michael@0 | 830 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueList_heap) |
michael@0 | 831 | |
michael@0 | 832 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 833 | |
michael@0 | 834 | private: |
michael@0 | 835 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 836 | ~nsCSSValueList_heap() |
michael@0 | 837 | { |
michael@0 | 838 | } |
michael@0 | 839 | }; |
michael@0 | 840 | |
michael@0 | 841 | // This is a reference counted list value. Note that the object is |
michael@0 | 842 | // a wrapper for the reference count and a pointer to the head of the |
michael@0 | 843 | // list, whereas the other list types (such as nsCSSValueList) do |
michael@0 | 844 | // not have such a wrapper. |
michael@0 | 845 | struct nsCSSValueSharedList MOZ_FINAL { |
michael@0 | 846 | nsCSSValueSharedList() |
michael@0 | 847 | : mHead(nullptr) |
michael@0 | 848 | { |
michael@0 | 849 | MOZ_COUNT_CTOR(nsCSSValueSharedList); |
michael@0 | 850 | } |
michael@0 | 851 | |
michael@0 | 852 | // Takes ownership of aList. |
michael@0 | 853 | nsCSSValueSharedList(nsCSSValueList* aList) |
michael@0 | 854 | : mHead(aList) |
michael@0 | 855 | { |
michael@0 | 856 | MOZ_COUNT_CTOR(nsCSSValueSharedList); |
michael@0 | 857 | } |
michael@0 | 858 | |
michael@0 | 859 | private: |
michael@0 | 860 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 861 | ~nsCSSValueSharedList(); |
michael@0 | 862 | |
michael@0 | 863 | public: |
michael@0 | 864 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueSharedList) |
michael@0 | 865 | |
michael@0 | 866 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 867 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 868 | |
michael@0 | 869 | bool operator==(nsCSSValueSharedList const& aOther) const; |
michael@0 | 870 | bool operator!=(const nsCSSValueSharedList& aOther) const |
michael@0 | 871 | { return !(*this == aOther); } |
michael@0 | 872 | |
michael@0 | 873 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 874 | |
michael@0 | 875 | nsCSSValueList* mHead; |
michael@0 | 876 | }; |
michael@0 | 877 | |
michael@0 | 878 | // This has to be here so that the relationship between nsCSSValueList |
michael@0 | 879 | // and nsCSSValueList_heap is visible. |
michael@0 | 880 | inline nsCSSValueList* |
michael@0 | 881 | nsCSSValue::GetListValue() |
michael@0 | 882 | { |
michael@0 | 883 | if (mUnit == eCSSUnit_List) |
michael@0 | 884 | return mValue.mList; |
michael@0 | 885 | else { |
michael@0 | 886 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value"); |
michael@0 | 887 | return mValue.mListDependent; |
michael@0 | 888 | } |
michael@0 | 889 | } |
michael@0 | 890 | |
michael@0 | 891 | inline const nsCSSValueList* |
michael@0 | 892 | nsCSSValue::GetListValue() const |
michael@0 | 893 | { |
michael@0 | 894 | if (mUnit == eCSSUnit_List) |
michael@0 | 895 | return mValue.mList; |
michael@0 | 896 | else { |
michael@0 | 897 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value"); |
michael@0 | 898 | return mValue.mListDependent; |
michael@0 | 899 | } |
michael@0 | 900 | } |
michael@0 | 901 | |
michael@0 | 902 | struct nsCSSRect { |
michael@0 | 903 | nsCSSRect(void); |
michael@0 | 904 | nsCSSRect(const nsCSSRect& aCopy); |
michael@0 | 905 | ~nsCSSRect(); |
michael@0 | 906 | |
michael@0 | 907 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 908 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 909 | |
michael@0 | 910 | bool operator==(const nsCSSRect& aOther) const { |
michael@0 | 911 | return mTop == aOther.mTop && |
michael@0 | 912 | mRight == aOther.mRight && |
michael@0 | 913 | mBottom == aOther.mBottom && |
michael@0 | 914 | mLeft == aOther.mLeft; |
michael@0 | 915 | } |
michael@0 | 916 | |
michael@0 | 917 | bool operator!=(const nsCSSRect& aOther) const { |
michael@0 | 918 | return mTop != aOther.mTop || |
michael@0 | 919 | mRight != aOther.mRight || |
michael@0 | 920 | mBottom != aOther.mBottom || |
michael@0 | 921 | mLeft != aOther.mLeft; |
michael@0 | 922 | } |
michael@0 | 923 | |
michael@0 | 924 | void SetAllSidesTo(const nsCSSValue& aValue); |
michael@0 | 925 | |
michael@0 | 926 | bool AllSidesEqualTo(const nsCSSValue& aValue) const { |
michael@0 | 927 | return mTop == aValue && |
michael@0 | 928 | mRight == aValue && |
michael@0 | 929 | mBottom == aValue && |
michael@0 | 930 | mLeft == aValue; |
michael@0 | 931 | } |
michael@0 | 932 | |
michael@0 | 933 | void Reset() { |
michael@0 | 934 | mTop.Reset(); |
michael@0 | 935 | mRight.Reset(); |
michael@0 | 936 | mBottom.Reset(); |
michael@0 | 937 | mLeft.Reset(); |
michael@0 | 938 | } |
michael@0 | 939 | |
michael@0 | 940 | bool HasValue() const { |
michael@0 | 941 | return |
michael@0 | 942 | mTop.GetUnit() != eCSSUnit_Null || |
michael@0 | 943 | mRight.GetUnit() != eCSSUnit_Null || |
michael@0 | 944 | mBottom.GetUnit() != eCSSUnit_Null || |
michael@0 | 945 | mLeft.GetUnit() != eCSSUnit_Null; |
michael@0 | 946 | } |
michael@0 | 947 | |
michael@0 | 948 | nsCSSValue mTop; |
michael@0 | 949 | nsCSSValue mRight; |
michael@0 | 950 | nsCSSValue mBottom; |
michael@0 | 951 | nsCSSValue mLeft; |
michael@0 | 952 | |
michael@0 | 953 | typedef nsCSSValue nsCSSRect::*side_type; |
michael@0 | 954 | static const side_type sides[4]; |
michael@0 | 955 | }; |
michael@0 | 956 | |
michael@0 | 957 | // nsCSSRect_heap differs from nsCSSRect only in being |
michael@0 | 958 | // refcounted. It should not be necessary to use this class directly; |
michael@0 | 959 | // it's an implementation detail of nsCSSValue. |
michael@0 | 960 | struct nsCSSRect_heap MOZ_FINAL : public nsCSSRect { |
michael@0 | 961 | NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap) |
michael@0 | 962 | |
michael@0 | 963 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 964 | |
michael@0 | 965 | private: |
michael@0 | 966 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 967 | ~nsCSSRect_heap() |
michael@0 | 968 | { |
michael@0 | 969 | } |
michael@0 | 970 | }; |
michael@0 | 971 | |
michael@0 | 972 | // This has to be here so that the relationship between nsCSSRect |
michael@0 | 973 | // and nsCSSRect_heap is visible. |
michael@0 | 974 | inline nsCSSRect& |
michael@0 | 975 | nsCSSValue::GetRectValue() |
michael@0 | 976 | { |
michael@0 | 977 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value"); |
michael@0 | 978 | return *mValue.mRect; |
michael@0 | 979 | } |
michael@0 | 980 | |
michael@0 | 981 | inline const nsCSSRect& |
michael@0 | 982 | nsCSSValue::GetRectValue() const |
michael@0 | 983 | { |
michael@0 | 984 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value"); |
michael@0 | 985 | return *mValue.mRect; |
michael@0 | 986 | } |
michael@0 | 987 | |
michael@0 | 988 | struct nsCSSValuePair { |
michael@0 | 989 | nsCSSValuePair() |
michael@0 | 990 | { |
michael@0 | 991 | MOZ_COUNT_CTOR(nsCSSValuePair); |
michael@0 | 992 | } |
michael@0 | 993 | nsCSSValuePair(nsCSSUnit aUnit) |
michael@0 | 994 | : mXValue(aUnit), mYValue(aUnit) |
michael@0 | 995 | { |
michael@0 | 996 | MOZ_COUNT_CTOR(nsCSSValuePair); |
michael@0 | 997 | } |
michael@0 | 998 | nsCSSValuePair(const nsCSSValue& aXValue, const nsCSSValue& aYValue) |
michael@0 | 999 | : mXValue(aXValue), mYValue(aYValue) |
michael@0 | 1000 | { |
michael@0 | 1001 | MOZ_COUNT_CTOR(nsCSSValuePair); |
michael@0 | 1002 | } |
michael@0 | 1003 | nsCSSValuePair(const nsCSSValuePair& aCopy) |
michael@0 | 1004 | : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue) |
michael@0 | 1005 | { |
michael@0 | 1006 | MOZ_COUNT_CTOR(nsCSSValuePair); |
michael@0 | 1007 | } |
michael@0 | 1008 | ~nsCSSValuePair() |
michael@0 | 1009 | { |
michael@0 | 1010 | MOZ_COUNT_DTOR(nsCSSValuePair); |
michael@0 | 1011 | } |
michael@0 | 1012 | |
michael@0 | 1013 | bool operator==(const nsCSSValuePair& aOther) const { |
michael@0 | 1014 | return mXValue == aOther.mXValue && |
michael@0 | 1015 | mYValue == aOther.mYValue; |
michael@0 | 1016 | } |
michael@0 | 1017 | |
michael@0 | 1018 | bool operator!=(const nsCSSValuePair& aOther) const { |
michael@0 | 1019 | return mXValue != aOther.mXValue || |
michael@0 | 1020 | mYValue != aOther.mYValue; |
michael@0 | 1021 | } |
michael@0 | 1022 | |
michael@0 | 1023 | bool BothValuesEqualTo(const nsCSSValue& aValue) const { |
michael@0 | 1024 | return mXValue == aValue && |
michael@0 | 1025 | mYValue == aValue; |
michael@0 | 1026 | } |
michael@0 | 1027 | |
michael@0 | 1028 | void SetBothValuesTo(const nsCSSValue& aValue) { |
michael@0 | 1029 | mXValue = aValue; |
michael@0 | 1030 | mYValue = aValue; |
michael@0 | 1031 | } |
michael@0 | 1032 | |
michael@0 | 1033 | void Reset() { |
michael@0 | 1034 | mXValue.Reset(); |
michael@0 | 1035 | mYValue.Reset(); |
michael@0 | 1036 | } |
michael@0 | 1037 | |
michael@0 | 1038 | bool HasValue() const { |
michael@0 | 1039 | return mXValue.GetUnit() != eCSSUnit_Null || |
michael@0 | 1040 | mYValue.GetUnit() != eCSSUnit_Null; |
michael@0 | 1041 | } |
michael@0 | 1042 | |
michael@0 | 1043 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 1044 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 1045 | |
michael@0 | 1046 | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1047 | |
michael@0 | 1048 | nsCSSValue mXValue; |
michael@0 | 1049 | nsCSSValue mYValue; |
michael@0 | 1050 | }; |
michael@0 | 1051 | |
michael@0 | 1052 | // nsCSSValuePair_heap differs from nsCSSValuePair only in being |
michael@0 | 1053 | // refcounted. It should not be necessary to use this class directly; |
michael@0 | 1054 | // it's an implementation detail of nsCSSValue. |
michael@0 | 1055 | struct nsCSSValuePair_heap MOZ_FINAL : public nsCSSValuePair { |
michael@0 | 1056 | // forward constructor |
michael@0 | 1057 | nsCSSValuePair_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue) |
michael@0 | 1058 | : nsCSSValuePair(aXValue, aYValue) |
michael@0 | 1059 | {} |
michael@0 | 1060 | |
michael@0 | 1061 | NS_INLINE_DECL_REFCOUNTING(nsCSSValuePair_heap) |
michael@0 | 1062 | |
michael@0 | 1063 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1064 | |
michael@0 | 1065 | private: |
michael@0 | 1066 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1067 | ~nsCSSValuePair_heap() |
michael@0 | 1068 | { |
michael@0 | 1069 | } |
michael@0 | 1070 | }; |
michael@0 | 1071 | |
michael@0 | 1072 | struct nsCSSValueTriplet { |
michael@0 | 1073 | nsCSSValueTriplet() |
michael@0 | 1074 | { |
michael@0 | 1075 | MOZ_COUNT_CTOR(nsCSSValueTriplet); |
michael@0 | 1076 | } |
michael@0 | 1077 | nsCSSValueTriplet(nsCSSUnit aUnit) |
michael@0 | 1078 | : mXValue(aUnit), mYValue(aUnit), mZValue(aUnit) |
michael@0 | 1079 | { |
michael@0 | 1080 | MOZ_COUNT_CTOR(nsCSSValueTriplet); |
michael@0 | 1081 | } |
michael@0 | 1082 | nsCSSValueTriplet(const nsCSSValue& aXValue, |
michael@0 | 1083 | const nsCSSValue& aYValue, |
michael@0 | 1084 | const nsCSSValue& aZValue) |
michael@0 | 1085 | : mXValue(aXValue), mYValue(aYValue), mZValue(aZValue) |
michael@0 | 1086 | { |
michael@0 | 1087 | MOZ_COUNT_CTOR(nsCSSValueTriplet); |
michael@0 | 1088 | } |
michael@0 | 1089 | nsCSSValueTriplet(const nsCSSValueTriplet& aCopy) |
michael@0 | 1090 | : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mZValue(aCopy.mZValue) |
michael@0 | 1091 | { |
michael@0 | 1092 | MOZ_COUNT_CTOR(nsCSSValueTriplet); |
michael@0 | 1093 | } |
michael@0 | 1094 | ~nsCSSValueTriplet() |
michael@0 | 1095 | { |
michael@0 | 1096 | MOZ_COUNT_DTOR(nsCSSValueTriplet); |
michael@0 | 1097 | } |
michael@0 | 1098 | |
michael@0 | 1099 | bool operator==(const nsCSSValueTriplet& aOther) const { |
michael@0 | 1100 | return mXValue == aOther.mXValue && |
michael@0 | 1101 | mYValue == aOther.mYValue && |
michael@0 | 1102 | mZValue == aOther.mZValue; |
michael@0 | 1103 | } |
michael@0 | 1104 | |
michael@0 | 1105 | bool operator!=(const nsCSSValueTriplet& aOther) const { |
michael@0 | 1106 | return mXValue != aOther.mXValue || |
michael@0 | 1107 | mYValue != aOther.mYValue || |
michael@0 | 1108 | mZValue != aOther.mZValue; |
michael@0 | 1109 | } |
michael@0 | 1110 | |
michael@0 | 1111 | bool AllValuesEqualTo(const nsCSSValue& aValue) const { |
michael@0 | 1112 | return mXValue == aValue && |
michael@0 | 1113 | mYValue == aValue && |
michael@0 | 1114 | mZValue == aValue; |
michael@0 | 1115 | } |
michael@0 | 1116 | |
michael@0 | 1117 | void SetAllValuesTo(const nsCSSValue& aValue) { |
michael@0 | 1118 | mXValue = aValue; |
michael@0 | 1119 | mYValue = aValue; |
michael@0 | 1120 | mZValue = aValue; |
michael@0 | 1121 | } |
michael@0 | 1122 | |
michael@0 | 1123 | void Reset() { |
michael@0 | 1124 | mXValue.Reset(); |
michael@0 | 1125 | mYValue.Reset(); |
michael@0 | 1126 | mZValue.Reset(); |
michael@0 | 1127 | } |
michael@0 | 1128 | |
michael@0 | 1129 | bool HasValue() const { |
michael@0 | 1130 | return mXValue.GetUnit() != eCSSUnit_Null || |
michael@0 | 1131 | mYValue.GetUnit() != eCSSUnit_Null || |
michael@0 | 1132 | mZValue.GetUnit() != eCSSUnit_Null; |
michael@0 | 1133 | } |
michael@0 | 1134 | |
michael@0 | 1135 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 1136 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 1137 | |
michael@0 | 1138 | nsCSSValue mXValue; |
michael@0 | 1139 | nsCSSValue mYValue; |
michael@0 | 1140 | nsCSSValue mZValue; |
michael@0 | 1141 | }; |
michael@0 | 1142 | |
michael@0 | 1143 | // nsCSSValueTriplet_heap differs from nsCSSValueTriplet only in being |
michael@0 | 1144 | // refcounted. It should not be necessary to use this class directly; |
michael@0 | 1145 | // it's an implementation detail of nsCSSValue. |
michael@0 | 1146 | struct nsCSSValueTriplet_heap MOZ_FINAL : public nsCSSValueTriplet { |
michael@0 | 1147 | // forward constructor |
michael@0 | 1148 | nsCSSValueTriplet_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue, const nsCSSValue& aZValue) |
michael@0 | 1149 | : nsCSSValueTriplet(aXValue, aYValue, aZValue) |
michael@0 | 1150 | {} |
michael@0 | 1151 | |
michael@0 | 1152 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap) |
michael@0 | 1153 | |
michael@0 | 1154 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1155 | |
michael@0 | 1156 | private: |
michael@0 | 1157 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1158 | ~nsCSSValueTriplet_heap() |
michael@0 | 1159 | { |
michael@0 | 1160 | } |
michael@0 | 1161 | }; |
michael@0 | 1162 | |
michael@0 | 1163 | // This has to be here so that the relationship between nsCSSValuePair |
michael@0 | 1164 | // and nsCSSValuePair_heap is visible. |
michael@0 | 1165 | inline nsCSSValuePair& |
michael@0 | 1166 | nsCSSValue::GetPairValue() |
michael@0 | 1167 | { |
michael@0 | 1168 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value"); |
michael@0 | 1169 | return *mValue.mPair; |
michael@0 | 1170 | } |
michael@0 | 1171 | |
michael@0 | 1172 | inline const nsCSSValuePair& |
michael@0 | 1173 | nsCSSValue::GetPairValue() const |
michael@0 | 1174 | { |
michael@0 | 1175 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value"); |
michael@0 | 1176 | return *mValue.mPair; |
michael@0 | 1177 | } |
michael@0 | 1178 | |
michael@0 | 1179 | inline nsCSSValueTriplet& |
michael@0 | 1180 | nsCSSValue::GetTripletValue() |
michael@0 | 1181 | { |
michael@0 | 1182 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value"); |
michael@0 | 1183 | return *mValue.mTriplet; |
michael@0 | 1184 | } |
michael@0 | 1185 | |
michael@0 | 1186 | inline const nsCSSValueTriplet& |
michael@0 | 1187 | nsCSSValue::GetTripletValue() const |
michael@0 | 1188 | { |
michael@0 | 1189 | NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value"); |
michael@0 | 1190 | return *mValue.mTriplet; |
michael@0 | 1191 | } |
michael@0 | 1192 | |
michael@0 | 1193 | // Maybe should be replaced with nsCSSValueList and nsCSSValue::Array? |
michael@0 | 1194 | struct nsCSSValuePairList { |
michael@0 | 1195 | nsCSSValuePairList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValuePairList); } |
michael@0 | 1196 | ~nsCSSValuePairList(); |
michael@0 | 1197 | |
michael@0 | 1198 | nsCSSValuePairList* Clone() const; // makes a deep copy |
michael@0 | 1199 | void AppendToString(nsCSSProperty aProperty, nsAString& aResult, |
michael@0 | 1200 | nsCSSValue::Serialization aValueSerialization) const; |
michael@0 | 1201 | |
michael@0 | 1202 | bool operator==(const nsCSSValuePairList& aOther) const; |
michael@0 | 1203 | bool operator!=(const nsCSSValuePairList& aOther) const |
michael@0 | 1204 | { return !(*this == aOther); } |
michael@0 | 1205 | |
michael@0 | 1206 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1207 | |
michael@0 | 1208 | nsCSSValue mXValue; |
michael@0 | 1209 | nsCSSValue mYValue; |
michael@0 | 1210 | nsCSSValuePairList* mNext; |
michael@0 | 1211 | |
michael@0 | 1212 | private: |
michael@0 | 1213 | nsCSSValuePairList(const nsCSSValuePairList& aCopy) // makes a shallow copy |
michael@0 | 1214 | : mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mNext(nullptr) |
michael@0 | 1215 | { |
michael@0 | 1216 | MOZ_COUNT_CTOR(nsCSSValuePairList); |
michael@0 | 1217 | } |
michael@0 | 1218 | }; |
michael@0 | 1219 | |
michael@0 | 1220 | // nsCSSValuePairList_heap differs from nsCSSValuePairList only in being |
michael@0 | 1221 | // refcounted. It should not be necessary to use this class directly; |
michael@0 | 1222 | // it's an implementation detail of nsCSSValue. |
michael@0 | 1223 | struct nsCSSValuePairList_heap MOZ_FINAL : public nsCSSValuePairList { |
michael@0 | 1224 | NS_INLINE_DECL_REFCOUNTING(nsCSSValuePairList_heap) |
michael@0 | 1225 | |
michael@0 | 1226 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1227 | |
michael@0 | 1228 | private: |
michael@0 | 1229 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1230 | ~nsCSSValuePairList_heap() |
michael@0 | 1231 | { |
michael@0 | 1232 | } |
michael@0 | 1233 | }; |
michael@0 | 1234 | |
michael@0 | 1235 | // This has to be here so that the relationship between nsCSSValuePairList |
michael@0 | 1236 | // and nsCSSValuePairList_heap is visible. |
michael@0 | 1237 | inline nsCSSValuePairList* |
michael@0 | 1238 | nsCSSValue::GetPairListValue() |
michael@0 | 1239 | { |
michael@0 | 1240 | if (mUnit == eCSSUnit_PairList) |
michael@0 | 1241 | return mValue.mPairList; |
michael@0 | 1242 | else { |
michael@0 | 1243 | NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value"); |
michael@0 | 1244 | return mValue.mPairListDependent; |
michael@0 | 1245 | } |
michael@0 | 1246 | } |
michael@0 | 1247 | |
michael@0 | 1248 | inline const nsCSSValuePairList* |
michael@0 | 1249 | nsCSSValue::GetPairListValue() const |
michael@0 | 1250 | { |
michael@0 | 1251 | if (mUnit == eCSSUnit_PairList) |
michael@0 | 1252 | return mValue.mPairList; |
michael@0 | 1253 | else { |
michael@0 | 1254 | NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value"); |
michael@0 | 1255 | return mValue.mPairListDependent; |
michael@0 | 1256 | } |
michael@0 | 1257 | } |
michael@0 | 1258 | |
michael@0 | 1259 | struct nsCSSValueGradientStop { |
michael@0 | 1260 | public: |
michael@0 | 1261 | nsCSSValueGradientStop(); |
michael@0 | 1262 | // needed to keep bloat logs happy when we use the TArray |
michael@0 | 1263 | // in nsCSSValueGradient |
michael@0 | 1264 | nsCSSValueGradientStop(const nsCSSValueGradientStop& aOther); |
michael@0 | 1265 | ~nsCSSValueGradientStop(); |
michael@0 | 1266 | |
michael@0 | 1267 | nsCSSValue mLocation; |
michael@0 | 1268 | nsCSSValue mColor; |
michael@0 | 1269 | |
michael@0 | 1270 | bool operator==(const nsCSSValueGradientStop& aOther) const |
michael@0 | 1271 | { |
michael@0 | 1272 | return (mLocation == aOther.mLocation && |
michael@0 | 1273 | mColor == aOther.mColor); |
michael@0 | 1274 | } |
michael@0 | 1275 | |
michael@0 | 1276 | bool operator!=(const nsCSSValueGradientStop& aOther) const |
michael@0 | 1277 | { |
michael@0 | 1278 | return !(*this == aOther); |
michael@0 | 1279 | } |
michael@0 | 1280 | |
michael@0 | 1281 | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1282 | }; |
michael@0 | 1283 | |
michael@0 | 1284 | struct nsCSSValueGradient MOZ_FINAL { |
michael@0 | 1285 | nsCSSValueGradient(bool aIsRadial, bool aIsRepeating); |
michael@0 | 1286 | |
michael@0 | 1287 | // true if gradient is radial, false if it is linear |
michael@0 | 1288 | bool mIsRadial; |
michael@0 | 1289 | bool mIsRepeating; |
michael@0 | 1290 | bool mIsLegacySyntax; |
michael@0 | 1291 | bool mIsExplicitSize; |
michael@0 | 1292 | // line position and angle |
michael@0 | 1293 | nsCSSValuePair mBgPos; |
michael@0 | 1294 | nsCSSValue mAngle; |
michael@0 | 1295 | |
michael@0 | 1296 | // Only meaningful if mIsRadial is true |
michael@0 | 1297 | private: |
michael@0 | 1298 | nsCSSValue mRadialValues[2]; |
michael@0 | 1299 | public: |
michael@0 | 1300 | nsCSSValue& GetRadialShape() |
michael@0 | 1301 | { |
michael@0 | 1302 | MOZ_ASSERT(!mIsExplicitSize); |
michael@0 | 1303 | return mRadialValues[0]; |
michael@0 | 1304 | } |
michael@0 | 1305 | const nsCSSValue& GetRadialShape() const |
michael@0 | 1306 | { |
michael@0 | 1307 | MOZ_ASSERT(!mIsExplicitSize); |
michael@0 | 1308 | return mRadialValues[0]; |
michael@0 | 1309 | } |
michael@0 | 1310 | nsCSSValue& GetRadialSize() |
michael@0 | 1311 | { |
michael@0 | 1312 | MOZ_ASSERT(!mIsExplicitSize); |
michael@0 | 1313 | return mRadialValues[1]; |
michael@0 | 1314 | } |
michael@0 | 1315 | const nsCSSValue& GetRadialSize() const |
michael@0 | 1316 | { |
michael@0 | 1317 | MOZ_ASSERT(!mIsExplicitSize); |
michael@0 | 1318 | return mRadialValues[1]; |
michael@0 | 1319 | } |
michael@0 | 1320 | nsCSSValue& GetRadiusX() |
michael@0 | 1321 | { |
michael@0 | 1322 | MOZ_ASSERT(mIsExplicitSize); |
michael@0 | 1323 | return mRadialValues[0]; |
michael@0 | 1324 | } |
michael@0 | 1325 | const nsCSSValue& GetRadiusX() const |
michael@0 | 1326 | { |
michael@0 | 1327 | MOZ_ASSERT(mIsExplicitSize); |
michael@0 | 1328 | return mRadialValues[0]; |
michael@0 | 1329 | } |
michael@0 | 1330 | nsCSSValue& GetRadiusY() |
michael@0 | 1331 | { |
michael@0 | 1332 | MOZ_ASSERT(mIsExplicitSize); |
michael@0 | 1333 | return mRadialValues[1]; |
michael@0 | 1334 | } |
michael@0 | 1335 | const nsCSSValue& GetRadiusY() const |
michael@0 | 1336 | { |
michael@0 | 1337 | MOZ_ASSERT(mIsExplicitSize); |
michael@0 | 1338 | return mRadialValues[1]; |
michael@0 | 1339 | } |
michael@0 | 1340 | |
michael@0 | 1341 | InfallibleTArray<nsCSSValueGradientStop> mStops; |
michael@0 | 1342 | |
michael@0 | 1343 | bool operator==(const nsCSSValueGradient& aOther) const |
michael@0 | 1344 | { |
michael@0 | 1345 | if (mIsRadial != aOther.mIsRadial || |
michael@0 | 1346 | mIsRepeating != aOther.mIsRepeating || |
michael@0 | 1347 | mIsLegacySyntax != aOther.mIsLegacySyntax || |
michael@0 | 1348 | mIsExplicitSize != aOther.mIsExplicitSize || |
michael@0 | 1349 | mBgPos != aOther.mBgPos || |
michael@0 | 1350 | mAngle != aOther.mAngle || |
michael@0 | 1351 | mRadialValues[0] != aOther.mRadialValues[0] || |
michael@0 | 1352 | mRadialValues[1] != aOther.mRadialValues[1]) |
michael@0 | 1353 | return false; |
michael@0 | 1354 | |
michael@0 | 1355 | if (mStops.Length() != aOther.mStops.Length()) |
michael@0 | 1356 | return false; |
michael@0 | 1357 | |
michael@0 | 1358 | for (uint32_t i = 0; i < mStops.Length(); i++) { |
michael@0 | 1359 | if (mStops[i] != aOther.mStops[i]) |
michael@0 | 1360 | return false; |
michael@0 | 1361 | } |
michael@0 | 1362 | |
michael@0 | 1363 | return true; |
michael@0 | 1364 | } |
michael@0 | 1365 | |
michael@0 | 1366 | bool operator!=(const nsCSSValueGradient& aOther) const |
michael@0 | 1367 | { |
michael@0 | 1368 | return !(*this == aOther); |
michael@0 | 1369 | } |
michael@0 | 1370 | |
michael@0 | 1371 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient) |
michael@0 | 1372 | |
michael@0 | 1373 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1374 | |
michael@0 | 1375 | private: |
michael@0 | 1376 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1377 | ~nsCSSValueGradient() |
michael@0 | 1378 | { |
michael@0 | 1379 | } |
michael@0 | 1380 | |
michael@0 | 1381 | nsCSSValueGradient(const nsCSSValueGradient& aOther) MOZ_DELETE; |
michael@0 | 1382 | nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther) MOZ_DELETE; |
michael@0 | 1383 | }; |
michael@0 | 1384 | |
michael@0 | 1385 | struct nsCSSValueTokenStream MOZ_FINAL { |
michael@0 | 1386 | nsCSSValueTokenStream(); |
michael@0 | 1387 | |
michael@0 | 1388 | private: |
michael@0 | 1389 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1390 | ~nsCSSValueTokenStream(); |
michael@0 | 1391 | |
michael@0 | 1392 | public: |
michael@0 | 1393 | bool operator==(const nsCSSValueTokenStream& aOther) const |
michael@0 | 1394 | { |
michael@0 | 1395 | bool eq; |
michael@0 | 1396 | return mPropertyID == aOther.mPropertyID && |
michael@0 | 1397 | mShorthandPropertyID == aOther.mShorthandPropertyID && |
michael@0 | 1398 | mTokenStream.Equals(aOther.mTokenStream) && |
michael@0 | 1399 | (mBaseURI == aOther.mBaseURI || |
michael@0 | 1400 | (mBaseURI && aOther.mBaseURI && |
michael@0 | 1401 | NS_SUCCEEDED(mBaseURI->Equals(aOther.mBaseURI, &eq)) && |
michael@0 | 1402 | eq)) && |
michael@0 | 1403 | (mSheetURI == aOther.mSheetURI || |
michael@0 | 1404 | (mSheetURI && aOther.mSheetURI && |
michael@0 | 1405 | NS_SUCCEEDED(mSheetURI->Equals(aOther.mSheetURI, &eq)) && |
michael@0 | 1406 | eq)) && |
michael@0 | 1407 | (mSheetPrincipal == aOther.mSheetPrincipal || |
michael@0 | 1408 | (mSheetPrincipal && aOther.mSheetPrincipal && |
michael@0 | 1409 | NS_SUCCEEDED(mSheetPrincipal->Equals(aOther.mSheetPrincipal, |
michael@0 | 1410 | &eq)) && |
michael@0 | 1411 | eq)); |
michael@0 | 1412 | } |
michael@0 | 1413 | |
michael@0 | 1414 | bool operator!=(const nsCSSValueTokenStream& aOther) const |
michael@0 | 1415 | { |
michael@0 | 1416 | return !(*this == aOther); |
michael@0 | 1417 | } |
michael@0 | 1418 | |
michael@0 | 1419 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueTokenStream) |
michael@0 | 1420 | |
michael@0 | 1421 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1422 | |
michael@0 | 1423 | // The property that has mTokenStream as its unparsed specified value. |
michael@0 | 1424 | // When a variable reference is used in a shorthand property, a |
michael@0 | 1425 | // TokenStream value is stored as the specified value for each of its |
michael@0 | 1426 | // component longhand properties. |
michael@0 | 1427 | nsCSSProperty mPropertyID; |
michael@0 | 1428 | |
michael@0 | 1429 | // The shorthand property that had a value with a variable reference, |
michael@0 | 1430 | // which caused the longhand property identified by mPropertyID to have |
michael@0 | 1431 | // a TokenStream value. |
michael@0 | 1432 | nsCSSProperty mShorthandPropertyID; |
michael@0 | 1433 | |
michael@0 | 1434 | // The unparsed CSS corresponding to the specified value of the property. |
michael@0 | 1435 | // When the value of a shorthand property has a variable reference, the |
michael@0 | 1436 | // same mTokenStream value is used on each of the nsCSSValueTokenStream |
michael@0 | 1437 | // objects that will be set by parsing the shorthand. |
michael@0 | 1438 | nsString mTokenStream; |
michael@0 | 1439 | |
michael@0 | 1440 | nsCOMPtr<nsIURI> mBaseURI; |
michael@0 | 1441 | nsCOMPtr<nsIURI> mSheetURI; |
michael@0 | 1442 | nsCOMPtr<nsIPrincipal> mSheetPrincipal; |
michael@0 | 1443 | nsCSSStyleSheet* mSheet; |
michael@0 | 1444 | uint32_t mLineNumber; |
michael@0 | 1445 | uint32_t mLineOffset; |
michael@0 | 1446 | |
michael@0 | 1447 | // This table is used to hold a reference on to any ImageValue that results |
michael@0 | 1448 | // from re-parsing this token stream at computed value time. When properties |
michael@0 | 1449 | // like background-image contain a normal url(), the Declaration's data block |
michael@0 | 1450 | // will hold a reference to the ImageValue. When a token stream is used, |
michael@0 | 1451 | // the Declaration only holds on to this nsCSSValueTokenStream object, and |
michael@0 | 1452 | // the ImageValue would only exist for the duration of |
michael@0 | 1453 | // nsRuleNode::WalkRuleTree, in the AutoCSSValueArray. So instead when |
michael@0 | 1454 | // we re-parse a token stream and get an ImageValue, we record it in this |
michael@0 | 1455 | // table so that the Declaration can be the object that keeps holding |
michael@0 | 1456 | // a reference to it. |
michael@0 | 1457 | nsTHashtable<nsRefPtrHashKey<mozilla::css::ImageValue> > mImageValues; |
michael@0 | 1458 | |
michael@0 | 1459 | private: |
michael@0 | 1460 | nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) MOZ_DELETE; |
michael@0 | 1461 | nsCSSValueTokenStream& operator=(const nsCSSValueTokenStream& aOther) MOZ_DELETE; |
michael@0 | 1462 | }; |
michael@0 | 1463 | |
michael@0 | 1464 | class nsCSSValueFloatColor MOZ_FINAL { |
michael@0 | 1465 | public: |
michael@0 | 1466 | nsCSSValueFloatColor(float aComponent1, float aComponent2, float aComponent3, |
michael@0 | 1467 | float aAlpha) |
michael@0 | 1468 | : mComponent1(aComponent1) |
michael@0 | 1469 | , mComponent2(aComponent2) |
michael@0 | 1470 | , mComponent3(aComponent3) |
michael@0 | 1471 | , mAlpha(aAlpha) |
michael@0 | 1472 | { |
michael@0 | 1473 | MOZ_COUNT_CTOR(nsCSSValueFloatColor); |
michael@0 | 1474 | } |
michael@0 | 1475 | |
michael@0 | 1476 | private: |
michael@0 | 1477 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 1478 | ~nsCSSValueFloatColor() |
michael@0 | 1479 | { |
michael@0 | 1480 | MOZ_COUNT_DTOR(nsCSSValueFloatColor); |
michael@0 | 1481 | } |
michael@0 | 1482 | |
michael@0 | 1483 | public: |
michael@0 | 1484 | bool operator==(nsCSSValueFloatColor& aOther) const; |
michael@0 | 1485 | |
michael@0 | 1486 | nscolor GetColorValue(nsCSSUnit aUnit) const; |
michael@0 | 1487 | bool IsNonTransparentColor() const; |
michael@0 | 1488 | |
michael@0 | 1489 | void AppendToString(nsCSSUnit aUnit, nsAString& aResult) const; |
michael@0 | 1490 | |
michael@0 | 1491 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 1492 | |
michael@0 | 1493 | NS_INLINE_DECL_REFCOUNTING(nsCSSValueFloatColor) |
michael@0 | 1494 | |
michael@0 | 1495 | private: |
michael@0 | 1496 | // FIXME: We should not be clamping specified RGB color components. |
michael@0 | 1497 | float mComponent1; // 0..1 for RGB, 0..360 for HSL |
michael@0 | 1498 | float mComponent2; // 0..1 |
michael@0 | 1499 | float mComponent3; // 0..1 |
michael@0 | 1500 | float mAlpha; // 0..1 |
michael@0 | 1501 | |
michael@0 | 1502 | nsCSSValueFloatColor(const nsCSSValueFloatColor& aOther) MOZ_DELETE; |
michael@0 | 1503 | nsCSSValueFloatColor& operator=(const nsCSSValueFloatColor& aOther) |
michael@0 | 1504 | MOZ_DELETE; |
michael@0 | 1505 | }; |
michael@0 | 1506 | |
michael@0 | 1507 | struct nsCSSCornerSizes { |
michael@0 | 1508 | nsCSSCornerSizes(void); |
michael@0 | 1509 | nsCSSCornerSizes(const nsCSSCornerSizes& aCopy); |
michael@0 | 1510 | ~nsCSSCornerSizes(); |
michael@0 | 1511 | |
michael@0 | 1512 | // argument is a "full corner" constant from nsStyleConsts.h |
michael@0 | 1513 | nsCSSValue const & GetCorner(uint32_t aCorner) const { |
michael@0 | 1514 | return this->*corners[aCorner]; |
michael@0 | 1515 | } |
michael@0 | 1516 | nsCSSValue & GetCorner(uint32_t aCorner) { |
michael@0 | 1517 | return this->*corners[aCorner]; |
michael@0 | 1518 | } |
michael@0 | 1519 | |
michael@0 | 1520 | bool operator==(const nsCSSCornerSizes& aOther) const { |
michael@0 | 1521 | NS_FOR_CSS_FULL_CORNERS(corner) { |
michael@0 | 1522 | if (this->GetCorner(corner) != aOther.GetCorner(corner)) |
michael@0 | 1523 | return false; |
michael@0 | 1524 | } |
michael@0 | 1525 | return true; |
michael@0 | 1526 | } |
michael@0 | 1527 | |
michael@0 | 1528 | bool operator!=(const nsCSSCornerSizes& aOther) const { |
michael@0 | 1529 | NS_FOR_CSS_FULL_CORNERS(corner) { |
michael@0 | 1530 | if (this->GetCorner(corner) != aOther.GetCorner(corner)) |
michael@0 | 1531 | return true; |
michael@0 | 1532 | } |
michael@0 | 1533 | return false; |
michael@0 | 1534 | } |
michael@0 | 1535 | |
michael@0 | 1536 | bool HasValue() const { |
michael@0 | 1537 | NS_FOR_CSS_FULL_CORNERS(corner) { |
michael@0 | 1538 | if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null) |
michael@0 | 1539 | return true; |
michael@0 | 1540 | } |
michael@0 | 1541 | return false; |
michael@0 | 1542 | } |
michael@0 | 1543 | |
michael@0 | 1544 | void Reset(); |
michael@0 | 1545 | |
michael@0 | 1546 | nsCSSValue mTopLeft; |
michael@0 | 1547 | nsCSSValue mTopRight; |
michael@0 | 1548 | nsCSSValue mBottomRight; |
michael@0 | 1549 | nsCSSValue mBottomLeft; |
michael@0 | 1550 | |
michael@0 | 1551 | protected: |
michael@0 | 1552 | typedef nsCSSValue nsCSSCornerSizes::*corner_type; |
michael@0 | 1553 | static const corner_type corners[4]; |
michael@0 | 1554 | }; |
michael@0 | 1555 | |
michael@0 | 1556 | #endif /* nsCSSValue_h___ */ |
michael@0 | 1557 |