2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* representation of simple property values within CSS declarations */
|
|
|
|
|
|
|
|
#ifndef nsCSSValue_h___
|
|
|
|
#define nsCSSValue_h___
|
|
|
|
|
2011-12-16 11:42:07 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2011-12-16 11:42:07 -08:00
|
|
|
|
2013-12-11 18:09:42 -08:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIURI.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2010-08-19 12:33:43 -07:00
|
|
|
#include "nsCSSKeywords.h"
|
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCoord.h"
|
2012-10-12 05:43:01 -07:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2010-08-19 12:33:43 -07:00
|
|
|
#include "nsString.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStringBuffer.h"
|
2009-08-01 08:53:40 -07:00
|
|
|
#include "nsTArray.h"
|
2011-03-28 16:07:26 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2014-06-05 23:09:23 -07:00
|
|
|
#include "gfxFontFamilyList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-12 05:43:01 -07:00
|
|
|
class imgRequestProxy;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIDocument;
|
2007-05-02 18:15:53 -07:00
|
|
|
class nsIPrincipal;
|
2010-08-19 12:33:43 -07:00
|
|
|
class nsIURI;
|
2013-12-11 18:09:44 -08:00
|
|
|
class nsPresContext;
|
|
|
|
template <class T>
|
|
|
|
class nsPtrHashKey;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-20 03:32:49 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class CSSStyleSheet;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-10-17 01:13:16 -07:00
|
|
|
// Deletes a linked list iteratively to avoid blowing up the stack (bug 456196).
|
|
|
|
#define NS_CSS_DELETE_LIST_MEMBER(type_, ptr_, member_) \
|
|
|
|
{ \
|
|
|
|
type_ *cur = (ptr_)->member_; \
|
2013-02-17 22:56:32 -08:00
|
|
|
(ptr_)->member_ = nullptr; \
|
2008-10-17 01:13:16 -07:00
|
|
|
while (cur) { \
|
2013-02-17 22:56:32 -08:00
|
|
|
type_ *dlm_next = cur->member_; \
|
|
|
|
cur->member_ = nullptr; \
|
2008-10-17 01:13:16 -07:00
|
|
|
delete cur; \
|
2013-02-17 22:56:32 -08:00
|
|
|
cur = dlm_next; \
|
2008-10-17 01:13:16 -07:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clones a linked list iteratively to avoid blowing up the stack.
|
|
|
|
// If it fails to clone the entire list then 'to_' is deleted and
|
|
|
|
// we return null.
|
|
|
|
#define NS_CSS_CLONE_LIST_MEMBER(type_, from_, member_, to_, args_) \
|
|
|
|
{ \
|
|
|
|
type_ *dest = (to_); \
|
2013-02-17 22:56:32 -08:00
|
|
|
(to_)->member_ = nullptr; \
|
2008-10-17 01:13:16 -07:00
|
|
|
for (const type_ *src = (from_)->member_; src; src = src->member_) { \
|
2013-02-17 22:56:32 -08:00
|
|
|
type_ *clm_clone = src->Clone args_; \
|
|
|
|
if (!clm_clone) { \
|
2008-10-17 01:13:16 -07:00
|
|
|
delete (to_); \
|
2013-02-17 22:56:32 -08:00
|
|
|
return nullptr; \
|
2008-10-17 01:13:16 -07:00
|
|
|
} \
|
2013-02-17 22:56:32 -08:00
|
|
|
dest->member_ = clm_clone; \
|
|
|
|
dest = clm_clone; \
|
2008-10-17 01:13:16 -07:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
|
|
|
|
struct URLValue {
|
|
|
|
// Methods are not inline because using an nsIPrincipal means requiring
|
|
|
|
// caps, which leads to REQUIRES hell, since this header is included all
|
|
|
|
// over.
|
|
|
|
|
|
|
|
// For both constructors aString must not be null.
|
|
|
|
// For both constructors aOriginPrincipal must not be null.
|
|
|
|
// Construct with a base URI; this will create the actual URI lazily from
|
|
|
|
// aString and aBaseURI.
|
|
|
|
URLValue(nsStringBuffer* aString, nsIURI* aBaseURI, nsIURI* aReferrer,
|
|
|
|
nsIPrincipal* aOriginPrincipal);
|
|
|
|
// Construct with the actual URI.
|
|
|
|
URLValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
|
|
|
|
nsIPrincipal* aOriginPrincipal);
|
|
|
|
|
2014-06-18 19:28:59 -07:00
|
|
|
protected:
|
2012-08-24 10:50:49 -07:00
|
|
|
~URLValue();
|
|
|
|
|
2014-06-18 19:28:59 -07:00
|
|
|
public:
|
2012-08-24 10:50:49 -07:00
|
|
|
bool operator==(const URLValue& aOther) const;
|
|
|
|
|
|
|
|
// URIEquals only compares URIs and principals (unlike operator==, which
|
|
|
|
// also compares the original strings). URIEquals also assumes that the
|
|
|
|
// mURI member of both URL objects is non-null. Do NOT call this method
|
|
|
|
// unless you're sure this is the case.
|
|
|
|
bool URIEquals(const URLValue& aOther) const;
|
|
|
|
|
|
|
|
nsIURI* GetURI() const;
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-08-24 10:50:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// If mURIResolved is false, mURI stores the base URI.
|
|
|
|
// If mURIResolved is true, mURI stores the URI we resolve to; this may be
|
|
|
|
// null if the URI is invalid.
|
|
|
|
mutable nsCOMPtr<nsIURI> mURI;
|
|
|
|
public:
|
|
|
|
nsStringBuffer* mString; // Could use nsRefPtr, but it'd add useless
|
|
|
|
// null-checks; this is never null.
|
|
|
|
nsCOMPtr<nsIURI> mReferrer;
|
|
|
|
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(URLValue)
|
|
|
|
|
|
|
|
private:
|
|
|
|
mutable bool mURIResolved;
|
|
|
|
|
|
|
|
URLValue(const URLValue& aOther) MOZ_DELETE;
|
|
|
|
URLValue& operator=(const URLValue& aOther) MOZ_DELETE;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ImageValue : public URLValue {
|
|
|
|
// Not making the constructor and destructor inline because that would
|
|
|
|
// force us to include imgIRequest.h, which leads to REQUIRES hell, since
|
|
|
|
// this header is included all over.
|
|
|
|
// aString must not be null.
|
|
|
|
ImageValue(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
|
|
|
|
nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument);
|
2014-06-18 19:28:59 -07:00
|
|
|
private:
|
2012-08-24 10:50:49 -07:00
|
|
|
~ImageValue();
|
|
|
|
|
2014-06-18 19:28:59 -07:00
|
|
|
public:
|
2012-08-24 10:50:49 -07:00
|
|
|
// Inherit operator== from URLValue
|
|
|
|
|
2013-02-23 06:59:43 -08:00
|
|
|
nsRefPtrHashtable<nsPtrHashKey<nsISupports>, imgRequestProxy> mRequests;
|
2012-08-24 10:50:49 -07:00
|
|
|
|
|
|
|
// Override AddRef and Release to not only log ourselves correctly, but
|
|
|
|
// also so that we delete correctly without a virtual destructor
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(ImageValue)
|
|
|
|
};
|
|
|
|
|
2014-03-21 08:06:13 -07:00
|
|
|
struct GridNamedArea {
|
|
|
|
nsString mName;
|
|
|
|
uint32_t mColumnStart;
|
|
|
|
uint32_t mColumnEnd;
|
|
|
|
uint32_t mRowStart;
|
|
|
|
uint32_t mRowEnd;
|
|
|
|
};
|
|
|
|
|
2014-03-21 08:06:16 -07:00
|
|
|
struct GridTemplateAreasValue MOZ_FINAL {
|
2014-03-21 08:06:13 -07:00
|
|
|
// Parsed value
|
|
|
|
nsTArray<GridNamedArea> mNamedAreas;
|
|
|
|
|
|
|
|
// Original <string> values. Length gives the number of rows,
|
|
|
|
// content makes serialization easier.
|
|
|
|
nsTArray<nsString> mTemplates;
|
|
|
|
|
|
|
|
// How many columns grid-template-areas contributes to the explicit grid.
|
|
|
|
// http://dev.w3.org/csswg/css-grid/#explicit-grid
|
|
|
|
uint32_t mNColumns;
|
|
|
|
|
|
|
|
// How many rows grid-template-areas contributes to the explicit grid.
|
|
|
|
// http://dev.w3.org/csswg/css-grid/#explicit-grid
|
|
|
|
uint32_t NRows() const {
|
|
|
|
return mTemplates.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
GridTemplateAreasValue()
|
|
|
|
: mNColumns(0)
|
|
|
|
// Default constructors for mNamedAreas and mTemplates: empty arrays.
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const GridTemplateAreasValue& aOther) const
|
|
|
|
{
|
|
|
|
return mTemplates == aOther.mTemplates;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const GridTemplateAreasValue& aOther) const
|
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(GridTemplateAreasValue)
|
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-21 08:06:16 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor to make sure this isn't used as a stack variable
|
|
|
|
// or member variable.
|
|
|
|
~GridTemplateAreasValue()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GridTemplateAreasValue(const GridTemplateAreasValue& aOther) MOZ_DELETE;
|
|
|
|
GridTemplateAreasValue&
|
|
|
|
operator=(const GridTemplateAreasValue& aOther) MOZ_DELETE;
|
2014-03-21 08:06:13 -07:00
|
|
|
};
|
|
|
|
|
2014-07-30 01:15:00 -07:00
|
|
|
class FontFamilyListRefCnt MOZ_FINAL : public FontFamilyList {
|
|
|
|
public:
|
|
|
|
FontFamilyListRefCnt()
|
|
|
|
: FontFamilyList()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(FontFamilyListRefCnt);
|
|
|
|
}
|
|
|
|
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit FontFamilyListRefCnt(FontFamilyType aGenericType)
|
2014-07-30 01:15:00 -07:00
|
|
|
: FontFamilyList(aGenericType)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(FontFamilyListRefCnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
FontFamilyListRefCnt(const nsAString& aFamilyName,
|
|
|
|
QuotedName aQuoted)
|
|
|
|
: FontFamilyList(aFamilyName, aQuoted)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(FontFamilyListRefCnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
FontFamilyListRefCnt(const FontFamilyListRefCnt& aOther)
|
|
|
|
: FontFamilyList(aOther)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(FontFamilyListRefCnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(FontFamilyListRefCnt);
|
|
|
|
|
|
|
|
private:
|
|
|
|
~FontFamilyListRefCnt() {
|
|
|
|
MOZ_COUNT_DTOR(FontFamilyListRefCnt);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
enum nsCSSUnit {
|
|
|
|
eCSSUnit_Null = 0, // (n/a) null unit, value is not specified
|
|
|
|
eCSSUnit_Auto = 1, // (n/a) value is algorithmic
|
|
|
|
eCSSUnit_Inherit = 2, // (n/a) value is inherited
|
|
|
|
eCSSUnit_Initial = 3, // (n/a) value is default UA value
|
2013-10-03 11:49:17 -07:00
|
|
|
eCSSUnit_Unset = 4, // (n/a) value equivalent to 'initial' if on a reset property, 'inherit' otherwise
|
|
|
|
eCSSUnit_None = 5, // (n/a) value is none
|
|
|
|
eCSSUnit_Normal = 6, // (n/a) value is normal (algorithmic, different than auto)
|
|
|
|
eCSSUnit_System_Font = 7, // (n/a) value is -moz-use-system-font
|
|
|
|
eCSSUnit_All = 8, // (n/a) value is all
|
|
|
|
eCSSUnit_Dummy = 9, // (n/a) a fake but specified value, used
|
2007-10-08 16:11:01 -07:00
|
|
|
// only in temporary values
|
2013-10-03 11:49:17 -07:00
|
|
|
eCSSUnit_DummyInherit = 10, // (n/a) a fake but specified value, used
|
2008-10-07 11:53:22 -07:00
|
|
|
// only in temporary values
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
eCSSUnit_String = 11, // (char16_t*) a string value
|
|
|
|
eCSSUnit_Ident = 12, // (char16_t*) a string value
|
|
|
|
eCSSUnit_Attr = 14, // (char16_t*) a attr(string) value
|
|
|
|
eCSSUnit_Local_Font = 15, // (char16_t*) a local font name
|
|
|
|
eCSSUnit_Font_Format = 16, // (char16_t*) a font format name
|
|
|
|
eCSSUnit_Element = 17, // (char16_t*) an element id
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
eCSSUnit_Array = 20, // (nsCSSValue::Array*) a list of values
|
|
|
|
eCSSUnit_Counter = 21, // (nsCSSValue::Array*) a counter(string,[string]) value
|
|
|
|
eCSSUnit_Counters = 22, // (nsCSSValue::Array*) a counters(string,string[,string]) value
|
2009-08-20 14:52:47 -07:00
|
|
|
eCSSUnit_Cubic_Bezier = 23, // (nsCSSValue::Array*) a list of float values
|
2011-04-11 23:18:42 -07:00
|
|
|
eCSSUnit_Steps = 24, // (nsCSSValue::Array*) a list of (integer, enumerated)
|
|
|
|
eCSSUnit_Function = 25, // (nsCSSValue::Array*) a function with
|
2010-08-19 12:33:44 -07:00
|
|
|
// parameters. First elem of array is name,
|
2013-05-22 18:08:29 -07:00
|
|
|
// an nsCSSKeyword as eCSSUnit_Enumerated,
|
2008-09-13 02:42:11 -07:00
|
|
|
// the rest of the values are arguments.
|
|
|
|
|
2010-09-11 09:27:12 -07:00
|
|
|
// The top level of a calc() expression is eCSSUnit_Calc. All
|
|
|
|
// remaining eCSSUnit_Calc_* units only occur inside these toplevel
|
|
|
|
// calc values.
|
2010-05-11 08:49:43 -07:00
|
|
|
|
|
|
|
// eCSSUnit_Calc has an array with exactly 1 element. eCSSUnit_Calc
|
|
|
|
// exists so we can distinguish calc(2em) from 2em as specified values
|
|
|
|
// (but we drop this distinction for nsStyleCoord when we store
|
|
|
|
// computed values).
|
2011-04-11 23:18:42 -07:00
|
|
|
eCSSUnit_Calc = 30, // (nsCSSValue::Array*) calc() value
|
2010-05-11 08:49:43 -07:00
|
|
|
// Plus, Minus, Times_* and Divided have arrays with exactly 2
|
|
|
|
// elements. a + b + c + d is grouped as ((a + b) + c) + d
|
2011-04-11 23:18:42 -07:00
|
|
|
eCSSUnit_Calc_Plus = 31, // (nsCSSValue::Array*) + node within calc()
|
|
|
|
eCSSUnit_Calc_Minus = 32, // (nsCSSValue::Array*) - within calc
|
|
|
|
eCSSUnit_Calc_Times_L = 33, // (nsCSSValue::Array*) num * val within calc
|
|
|
|
eCSSUnit_Calc_Times_R = 34, // (nsCSSValue::Array*) val * num within calc
|
|
|
|
eCSSUnit_Calc_Divided = 35, // (nsCSSValue::Array*) / within calc
|
2010-05-11 08:49:43 -07:00
|
|
|
|
|
|
|
eCSSUnit_URL = 40, // (nsCSSValue::URL*) value
|
|
|
|
eCSSUnit_Image = 41, // (nsCSSValue::Image*) value
|
|
|
|
eCSSUnit_Gradient = 42, // (nsCSSValueGradient*) value
|
2013-12-11 18:09:42 -08:00
|
|
|
eCSSUnit_TokenStream = 43, // (nsCSSValueTokenStream*) value
|
2014-03-21 08:06:16 -07:00
|
|
|
eCSSUnit_GridTemplateAreas = 44, // (GridTemplateAreasValue*)
|
|
|
|
// for grid-template-areas
|
2010-08-19 12:33:44 -07:00
|
|
|
|
|
|
|
eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values
|
2011-08-02 20:04:23 -07:00
|
|
|
eCSSUnit_Triplet = 51, // (nsCSSValueTriplet*) triplet of values
|
|
|
|
eCSSUnit_Rect = 52, // (nsCSSRect*) rectangle (four values)
|
|
|
|
eCSSUnit_List = 53, // (nsCSSValueList*) list of values
|
|
|
|
eCSSUnit_ListDep = 54, // (nsCSSValueList*) same as List
|
2010-08-19 12:33:44 -07:00
|
|
|
// but does not own the list
|
2013-12-11 18:09:44 -08:00
|
|
|
eCSSUnit_SharedList = 55, // (nsCSSValueSharedList*) same as list
|
|
|
|
// but reference counted and shared
|
|
|
|
eCSSUnit_PairList = 56, // (nsCSSValuePairList*) list of value pairs
|
|
|
|
eCSSUnit_PairListDep = 57, // (nsCSSValuePairList*) same as PairList
|
2010-08-19 12:33:44 -07:00
|
|
|
// but does not own the list
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2014-06-05 23:09:23 -07:00
|
|
|
eCSSUnit_FontFamilyList = 58, // (FontFamilyList*) value
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
eCSSUnit_Integer = 70, // (int) simple value
|
|
|
|
eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning
|
|
|
|
|
2013-09-15 16:35:48 -07:00
|
|
|
eCSSUnit_EnumColor = 80, // (int) enumerated color (kColorKTable)
|
|
|
|
eCSSUnit_RGBColor = 81, // (nscolor) an opaque RGBA value specified as rgb()
|
|
|
|
eCSSUnit_RGBAColor = 82, // (nscolor) an RGBA value specified as rgba()
|
|
|
|
eCSSUnit_HexColor = 83, // (nscolor) an opaque RGBA value specified as #rrggbb
|
|
|
|
eCSSUnit_ShortHexColor = 84, // (nscolor) an opaque RGBA value specified as #rgb
|
|
|
|
eCSSUnit_PercentageRGBColor = 85, // (nsCSSValueFloatColor*)
|
|
|
|
eCSSUnit_PercentageRGBAColor = 86, // (nsCSSValueFloatColor*)
|
|
|
|
eCSSUnit_HSLColor = 87, // (nsCSSValueFloatColor*)
|
|
|
|
eCSSUnit_HSLAColor = 88, // (nsCSSValueFloatColor*)
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
eCSSUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
|
|
|
|
eCSSUnit_Number = 91, // (float) value is numeric (usually multiplier, different behavior that percent)
|
|
|
|
|
2010-08-13 02:58:02 -07:00
|
|
|
// Physical length units
|
|
|
|
eCSSUnit_PhysicalMillimeter = 200, // (float) 1/25.4 inch
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Length units - relative
|
2012-10-19 16:21:06 -07:00
|
|
|
// Viewport relative measure
|
|
|
|
eCSSUnit_ViewportWidth = 700, // (float) 1% of the width of the initial containing block
|
|
|
|
eCSSUnit_ViewportHeight = 701, // (float) 1% of the height of the initial containing block
|
|
|
|
eCSSUnit_ViewportMin = 702, // (float) smaller of ViewportWidth and ViewportHeight
|
|
|
|
eCSSUnit_ViewportMax = 703, // (float) larger of ViewportWidth and ViewportHeight
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Font relative measure
|
|
|
|
eCSSUnit_EM = 800, // (float) == current font size
|
2008-12-04 08:09:53 -08:00
|
|
|
eCSSUnit_XHeight = 801, // (float) distance from top of lower case x to baseline
|
|
|
|
eCSSUnit_Char = 802, // (float) number of characters, used for width with monospace font
|
2009-01-20 13:58:48 -08:00
|
|
|
eCSSUnit_RootEM = 803, // (float) == root element font size
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Screen relative measure
|
2010-08-13 02:58:01 -07:00
|
|
|
eCSSUnit_Point = 900, // (float) 4/3 of a CSS pixel
|
2010-08-13 02:58:02 -07:00
|
|
|
eCSSUnit_Inch = 901, // (float) 96 CSS pixels
|
|
|
|
eCSSUnit_Millimeter = 902, // (float) 96/25.4 CSS pixels
|
|
|
|
eCSSUnit_Centimeter = 903, // (float) 96/2.54 CSS pixels
|
|
|
|
eCSSUnit_Pica = 904, // (float) 12 points == 16 CSS pixls
|
|
|
|
eCSSUnit_Pixel = 905, // (float) CSS pixel unit
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Angular units
|
|
|
|
eCSSUnit_Degree = 1000, // (float) 360 per circle
|
|
|
|
eCSSUnit_Grad = 1001, // (float) 400 per circle
|
|
|
|
eCSSUnit_Radian = 1002, // (float) 2*pi per circle
|
2012-02-03 21:01:23 -08:00
|
|
|
eCSSUnit_Turn = 1003, // (float) 1 per circle
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Frequency units
|
|
|
|
eCSSUnit_Hertz = 2000, // (float) 1/seconds
|
|
|
|
eCSSUnit_Kilohertz = 2001, // (float) 1000 Hertz
|
|
|
|
|
|
|
|
// Time units
|
|
|
|
eCSSUnit_Seconds = 3000, // (float) Standard time
|
2014-03-10 15:54:13 -07:00
|
|
|
eCSSUnit_Milliseconds = 3001, // (float) 1/1000 second
|
|
|
|
|
|
|
|
// Flexible fraction (CSS Grid)
|
|
|
|
eCSSUnit_FlexFraction = 4000 // (float) Fraction of free space
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2009-08-01 08:53:40 -07:00
|
|
|
struct nsCSSValueGradient;
|
2010-08-19 12:33:44 -07:00
|
|
|
struct nsCSSValuePair;
|
|
|
|
struct nsCSSValuePair_heap;
|
2013-12-11 18:09:42 -08:00
|
|
|
struct nsCSSValueTokenStream;
|
2010-08-19 12:33:44 -07:00
|
|
|
struct nsCSSRect;
|
|
|
|
struct nsCSSRect_heap;
|
2010-08-19 12:33:44 -07:00
|
|
|
struct nsCSSValueList;
|
|
|
|
struct nsCSSValueList_heap;
|
2013-12-11 18:09:44 -08:00
|
|
|
struct nsCSSValueSharedList;
|
2010-08-19 12:33:44 -07:00
|
|
|
struct nsCSSValuePairList;
|
|
|
|
struct nsCSSValuePairList_heap;
|
2011-08-02 20:04:23 -07:00
|
|
|
struct nsCSSValueTriplet;
|
|
|
|
struct nsCSSValueTriplet_heap;
|
2013-09-15 16:35:48 -07:00
|
|
|
class nsCSSValueFloatColor;
|
2009-08-01 08:53:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsCSSValue {
|
|
|
|
public:
|
|
|
|
struct Array;
|
|
|
|
friend struct Array;
|
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
friend struct mozilla::css::URLValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
friend struct mozilla::css::ImageValue;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2009-08-20 14:52:47 -07:00
|
|
|
// for valueless units only (null, auto, inherit, none, all, normal)
|
2007-03-22 10:30:00 -07:00
|
|
|
explicit nsCSSValue(nsCSSUnit aUnit = eCSSUnit_Null)
|
|
|
|
: mUnit(aUnit)
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(aUnit <= eCSSUnit_DummyInherit, "not a valueless unit");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsCSSValue(int32_t aValue, nsCSSUnit aUnit);
|
2010-04-06 14:52:17 -07:00
|
|
|
nsCSSValue(float aValue, nsCSSUnit aUnit);
|
|
|
|
nsCSSValue(const nsString& aValue, nsCSSUnit aUnit);
|
|
|
|
nsCSSValue(Array* aArray, nsCSSUnit aUnit);
|
2012-08-24 10:50:49 -07:00
|
|
|
explicit nsCSSValue(mozilla::css::URLValue* aValue);
|
|
|
|
explicit nsCSSValue(mozilla::css::ImageValue* aValue);
|
2010-04-06 14:52:17 -07:00
|
|
|
explicit nsCSSValue(nsCSSValueGradient* aValue);
|
2013-12-11 18:09:42 -08:00
|
|
|
explicit nsCSSValue(nsCSSValueTokenStream* aValue);
|
2014-03-21 08:06:16 -07:00
|
|
|
explicit nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue);
|
2014-07-30 01:15:00 -07:00
|
|
|
explicit nsCSSValue(mozilla::css::FontFamilyListRefCnt* aValue);
|
2010-04-06 14:52:17 -07:00
|
|
|
nsCSSValue(const nsCSSValue& aCopy);
|
2007-08-27 23:47:32 -07:00
|
|
|
~nsCSSValue() { Reset(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-06 14:52:17 -07:00
|
|
|
nsCSSValue& operator=(const nsCSSValue& aCopy);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSValue& aOther) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSValue& aOther) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
// Enum for AppendToString's aValueSerialization argument.
|
|
|
|
enum Serialization { eNormalized, eAuthorSpecified };
|
|
|
|
|
2010-07-23 11:00:27 -07:00
|
|
|
/**
|
|
|
|
* Serialize |this| as a specified value for |aProperty| and append
|
|
|
|
* it to |aResult|.
|
|
|
|
*/
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
Serialization aValueSerialization) const;
|
2010-07-23 11:00:27 -07:00
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
nsCSSUnit GetUnit() const { return mUnit; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsLengthUnit() const
|
2010-08-13 02:58:02 -07:00
|
|
|
{ return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
2010-08-13 02:58:01 -07:00
|
|
|
/**
|
|
|
|
* A "fixed" length unit is one that means a specific physical length
|
|
|
|
* which we try to match based on the physical characteristics of an
|
|
|
|
* output device.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsFixedLengthUnit() const
|
2010-08-13 02:58:02 -07:00
|
|
|
{ return mUnit == eCSSUnit_PhysicalMillimeter; }
|
2010-08-13 02:58:01 -07:00
|
|
|
/**
|
|
|
|
* What the spec calls relative length units is, for us, split
|
|
|
|
* between relative length units and pixel length units.
|
|
|
|
*
|
|
|
|
* A "relative" length unit is a multiple of some derived metric,
|
|
|
|
* such as a font em-size, which itself was controlled by an input CSS
|
|
|
|
* length. Relative length units should not be scaled by zooming, since
|
|
|
|
* the underlying CSS length would already have been scaled.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRelativeLengthUnit() const
|
2010-08-13 02:58:01 -07:00
|
|
|
{ return eCSSUnit_EM <= mUnit && mUnit <= eCSSUnit_RootEM; }
|
|
|
|
/**
|
|
|
|
* A "pixel" length unit is a some multiple of CSS pixels.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPixelLengthUnit() const
|
2010-08-13 02:58:01 -07:00
|
|
|
{ return eCSSUnit_Point <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAngularUnit() const
|
2012-02-03 21:01:23 -08:00
|
|
|
{ return eCSSUnit_Degree <= mUnit && mUnit <= eCSSUnit_Turn; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsFrequencyUnit() const
|
2008-08-07 16:15:40 -07:00
|
|
|
{ return eCSSUnit_Hertz <= mUnit && mUnit <= eCSSUnit_Kilohertz; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTimeUnit() const
|
2008-08-07 16:15:40 -07:00
|
|
|
{ return eCSSUnit_Seconds <= mUnit && mUnit <= eCSSUnit_Milliseconds; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsCalcUnit() const
|
2010-09-11 09:27:12 -07:00
|
|
|
{ return eCSSUnit_Calc <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
|
2008-08-07 16:15:40 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool UnitHasStringValue() const
|
2010-08-13 06:33:37 -07:00
|
|
|
{ return eCSSUnit_String <= mUnit && mUnit <= eCSSUnit_Element; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool UnitHasArrayValue() const
|
2010-09-11 09:27:12 -07:00
|
|
|
{ return eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-15 16:35:48 -07:00
|
|
|
// Checks for the nsCSSValue being of a particular type of color unit:
|
|
|
|
//
|
|
|
|
// - IsIntegerColorUnit returns true for:
|
|
|
|
// eCSSUnit_RGBColor -- rgb(int,int,int)
|
|
|
|
// eCSSUnit_RGBAColor -- rgba(int,int,int,float)
|
|
|
|
// eCSSUnit_HexColor -- #rrggbb
|
|
|
|
// eCSSUnit_ShortHexColor -- #rgb
|
|
|
|
//
|
|
|
|
// - IsFLoatColorUnit returns true for:
|
|
|
|
// eCSSUnit_PercentageRGBColor -- rgb(%,%,%)
|
|
|
|
// eCSSUnit_PercentageRGBAColor -- rgba(%,%,%,float)
|
|
|
|
// eCSSUnit_HSLColor -- hsl(float,%,%)
|
|
|
|
// eCSSUnit_HSLAColor -- hsla(float,%,%,float)
|
|
|
|
//
|
|
|
|
// - IsNumericColorUnit returns true for any of the above units.
|
|
|
|
//
|
|
|
|
// Note that color keywords and system colors are represented by
|
|
|
|
// eCSSUnit_EnumColor and eCSSUnit_Ident.
|
|
|
|
bool IsIntegerColorUnit() const { return IsIntegerColorUnit(mUnit); }
|
|
|
|
bool IsFloatColorUnit() const { return IsFloatColorUnit(mUnit); }
|
|
|
|
bool IsNumericColorUnit() const { return IsNumericColorUnit(mUnit); }
|
|
|
|
static bool IsIntegerColorUnit(nsCSSUnit aUnit)
|
|
|
|
{ return eCSSUnit_RGBColor <= aUnit && aUnit <= eCSSUnit_ShortHexColor; }
|
|
|
|
static bool IsFloatColorUnit(nsCSSUnit aUnit)
|
|
|
|
{ return eCSSUnit_PercentageRGBColor <= aUnit &&
|
|
|
|
aUnit <= eCSSUnit_HSLAColor; }
|
|
|
|
static bool IsNumericColorUnit(nsCSSUnit aUnit)
|
|
|
|
{ return IsIntegerColorUnit(aUnit) || IsFloatColorUnit(aUnit); }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetIntValue() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Integer ||
|
|
|
|
mUnit == eCSSUnit_Enumerated ||
|
|
|
|
mUnit == eCSSUnit_EnumColor,
|
|
|
|
"not an int value");
|
2007-03-22 10:30:00 -07:00
|
|
|
return mValue.mInt;
|
|
|
|
}
|
|
|
|
|
2013-05-22 18:08:29 -07:00
|
|
|
nsCSSKeyword GetKeywordValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Enumerated, "not a keyword value");
|
|
|
|
return static_cast<nsCSSKeyword>(mValue.mInt);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
float GetPercentValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Percent, "not a percent value");
|
2007-03-22 10:30:00 -07:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetFloatValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(eCSSUnit_Number <= mUnit, "not a float value");
|
2013-05-01 13:55:13 -07:00
|
|
|
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
|
2007-03-22 10:30:00 -07:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
2009-11-02 11:36:43 -08:00
|
|
|
float GetAngleValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(eCSSUnit_Degree <= mUnit &&
|
2012-02-03 21:01:23 -08:00
|
|
|
mUnit <= eCSSUnit_Turn, "not an angle value");
|
2009-11-02 11:36:43 -08:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Converts any angle to radians.
|
|
|
|
double GetAngleValueInRadians() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAString& GetStringValue(nsAString& aBuffer) const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
|
2007-03-22 10:30:00 -07:00
|
|
|
aBuffer.Truncate();
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t len = NS_strlen(GetBufferValue(mValue.mString));
|
2007-03-22 10:30:00 -07:00
|
|
|
mValue.mString->ToString(len, aBuffer);
|
|
|
|
return aBuffer;
|
|
|
|
}
|
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* GetStringBufferValue() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
|
2007-03-22 10:30:00 -07:00
|
|
|
return GetBufferValue(mValue.mString);
|
|
|
|
}
|
|
|
|
|
2013-09-15 16:35:48 -07:00
|
|
|
nscolor GetColorValue() const;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsNonTransparentColor() const;
|
2009-06-16 15:05:12 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
Array* GetArrayValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasArrayValue(), "not an array value");
|
2007-03-22 10:30:00 -07:00
|
|
|
return mValue.mArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI* GetURLValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
2007-03-22 10:30:00 -07:00
|
|
|
"not a URL value");
|
|
|
|
return mUnit == eCSSUnit_URL ?
|
2011-05-11 08:28:53 -07:00
|
|
|
mValue.mURL->GetURI() : mValue.mImage->GetURI();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-08-01 08:53:40 -07:00
|
|
|
nsCSSValueGradient* GetGradientValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Gradient, "not a gradient value");
|
2009-08-01 08:53:40 -07:00
|
|
|
return mValue.mGradient;
|
|
|
|
}
|
|
|
|
|
2013-12-11 18:09:42 -08:00
|
|
|
nsCSSValueTokenStream* GetTokenStreamValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_TokenStream, "not a token stream value");
|
|
|
|
return mValue.mTokenStream;
|
|
|
|
}
|
|
|
|
|
2013-12-11 18:09:44 -08:00
|
|
|
nsCSSValueSharedList* GetSharedListValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_SharedList, "not a shared list value");
|
|
|
|
return mValue.mSharedList;
|
|
|
|
}
|
|
|
|
|
2014-06-05 23:09:23 -07:00
|
|
|
mozilla::FontFamilyList* GetFontFamilyListValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_FontFamilyList,
|
|
|
|
"not a font family list value");
|
2014-06-05 23:09:23 -07:00
|
|
|
NS_ASSERTION(mValue.mFontFamilyList != nullptr,
|
|
|
|
"font family list value should never be null");
|
2014-06-05 23:09:23 -07:00
|
|
|
return mValue.mFontFamilyList;
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// bodies of these are below
|
|
|
|
inline nsCSSValuePair& GetPairValue();
|
|
|
|
inline const nsCSSValuePair& GetPairValue() const;
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
inline nsCSSRect& GetRectValue();
|
|
|
|
inline const nsCSSRect& GetRectValue() const;
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
inline nsCSSValueList* GetListValue();
|
|
|
|
inline const nsCSSValueList* GetListValue() const;
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
inline nsCSSValuePairList* GetPairListValue();
|
|
|
|
inline const nsCSSValuePairList* GetPairListValue() const;
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2011-08-02 20:04:23 -07:00
|
|
|
inline nsCSSValueTriplet& GetTripletValue();
|
|
|
|
inline const nsCSSValueTriplet& GetTripletValue() const;
|
|
|
|
|
2014-03-10 15:54:14 -07:00
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
mozilla::css::URLValue* GetURLStructValue() const
|
2007-07-18 14:56:57 -07:00
|
|
|
{
|
|
|
|
// Not allowing this for Image values, because if the caller takes
|
|
|
|
// a ref to them they won't be able to delete them properly.
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL, "not a URL value");
|
2007-07-18 14:56:57 -07:00
|
|
|
return mValue.mURL;
|
|
|
|
}
|
|
|
|
|
2012-08-24 10:50:49 -07:00
|
|
|
mozilla::css::ImageValue* GetImageStructValue() const
|
2012-08-13 15:04:19 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value");
|
|
|
|
return mValue.mImage;
|
|
|
|
}
|
|
|
|
|
2014-03-21 08:06:16 -07:00
|
|
|
mozilla::css::GridTemplateAreasValue* GetGridTemplateAreas() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_GridTemplateAreas,
|
|
|
|
"not a grid-template-areas value");
|
|
|
|
return mValue.mGridTemplateAreas;
|
|
|
|
}
|
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* GetOriginalURLValue() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
|
|
|
"not a URL value");
|
2007-03-22 10:30:00 -07:00
|
|
|
return GetBufferValue(mUnit == eCSSUnit_URL ?
|
|
|
|
mValue.mURL->mString :
|
|
|
|
mValue.mImage->mString);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not making this inline because that would force us to include
|
|
|
|
// imgIRequest.h, which leads to REQUIRES hell, since this header is included
|
|
|
|
// all over.
|
2012-10-12 05:43:01 -07:00
|
|
|
imgRequestProxy* GetImageValue(nsIDocument* aDocument) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-13 02:58:01 -07:00
|
|
|
nscoord GetFixedLength(nsPresContext* aPresContext) const;
|
|
|
|
nscoord GetPixelLength() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-06 14:52:17 -07:00
|
|
|
void Reset() // sets to null
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-08-27 23:47:32 -07:00
|
|
|
if (mUnit != eCSSUnit_Null)
|
|
|
|
DoReset();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-27 23:47:32 -07:00
|
|
|
private:
|
2010-04-06 14:52:17 -07:00
|
|
|
void DoReset();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-27 23:47:32 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetIntValue(int32_t aValue, nsCSSUnit aUnit);
|
2010-04-06 14:52:17 -07:00
|
|
|
void SetPercentValue(float aValue);
|
|
|
|
void SetFloatValue(float aValue, nsCSSUnit aUnit);
|
|
|
|
void SetStringValue(const nsString& aValue, nsCSSUnit aUnit);
|
|
|
|
void SetColorValue(nscolor aValue);
|
2013-09-15 16:35:48 -07:00
|
|
|
void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit);
|
|
|
|
void SetFloatColorValue(float aComponent1,
|
|
|
|
float aComponent2,
|
|
|
|
float aComponent3,
|
|
|
|
float aAlpha, nsCSSUnit aUnit);
|
2010-04-06 14:52:17 -07:00
|
|
|
void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit);
|
2012-08-24 10:50:49 -07:00
|
|
|
void SetURLValue(mozilla::css::URLValue* aURI);
|
|
|
|
void SetImageValue(mozilla::css::ImageValue* aImage);
|
2010-04-06 14:52:17 -07:00
|
|
|
void SetGradientValue(nsCSSValueGradient* aGradient);
|
2013-12-11 18:09:42 -08:00
|
|
|
void SetTokenStreamValue(nsCSSValueTokenStream* aTokenStream);
|
2014-03-21 08:06:16 -07:00
|
|
|
void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
|
2014-07-30 01:15:00 -07:00
|
|
|
void SetFontFamilyListValue(mozilla::css::FontFamilyListRefCnt* aFontListValue);
|
2010-08-19 12:33:44 -07:00
|
|
|
void SetPairValue(const nsCSSValuePair* aPair);
|
|
|
|
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
|
2013-12-11 18:09:44 -08:00
|
|
|
void SetSharedListValue(nsCSSValueSharedList* aList);
|
2010-08-19 12:33:44 -07:00
|
|
|
void SetDependentListValue(nsCSSValueList* aList);
|
2010-08-19 12:33:44 -07:00
|
|
|
void SetDependentPairListValue(nsCSSValuePairList* aList);
|
2011-08-02 20:04:23 -07:00
|
|
|
void SetTripletValue(const nsCSSValueTriplet* aTriplet);
|
|
|
|
void SetTripletValue(const nsCSSValue& xValue, const nsCSSValue& yValue, const nsCSSValue& zValue);
|
2010-04-06 14:52:17 -07:00
|
|
|
void SetAutoValue();
|
|
|
|
void SetInheritValue();
|
|
|
|
void SetInitialValue();
|
2013-10-03 11:49:17 -07:00
|
|
|
void SetUnsetValue();
|
2010-04-06 14:52:17 -07:00
|
|
|
void SetNoneValue();
|
|
|
|
void SetAllValue();
|
|
|
|
void SetNormalValue();
|
|
|
|
void SetSystemFontValue();
|
|
|
|
void SetDummyValue();
|
|
|
|
void SetDummyInheritValue();
|
2010-08-19 12:33:44 -07:00
|
|
|
|
|
|
|
// These are a little different - they allocate storage for you and
|
|
|
|
// return a handle.
|
|
|
|
nsCSSRect& SetRectValue();
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValueList* SetListValue();
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValuePairList* SetPairListValue();
|
2010-08-19 12:33:44 -07:00
|
|
|
|
2010-04-06 14:52:17 -07:00
|
|
|
void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-21 13:39:25 -07:00
|
|
|
// Initializes as a function value with the specified function id.
|
2012-08-22 08:56:38 -07:00
|
|
|
Array* InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs);
|
2009-08-21 13:39:25 -07:00
|
|
|
// Checks if this is a function value with the specified function id.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool EqualsFunction(nsCSSKeyword aFunctionId) const;
|
2009-08-21 13:39:25 -07:00
|
|
|
|
2013-08-21 12:31:38 -07:00
|
|
|
// Returns an already addrefed buffer. Guaranteed to return non-null.
|
|
|
|
// (Will abort on allocation failure.)
|
2010-12-05 05:17:29 -08:00
|
|
|
static already_AddRefed<nsStringBuffer>
|
|
|
|
BufferFromString(const nsString& aValue);
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2014-01-04 07:02:17 -08:00
|
|
|
static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) {
|
|
|
|
return static_cast<char16_t*>(aBuffer->Data());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsCSSUnit mUnit;
|
|
|
|
union {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mInt;
|
2007-03-22 10:30:00 -07:00
|
|
|
float mFloat;
|
|
|
|
// Note: the capacity of the buffer may exceed the length of the string.
|
|
|
|
// If we're of a string type, mString is not null.
|
|
|
|
nsStringBuffer* mString;
|
|
|
|
nscolor mColor;
|
|
|
|
Array* mArray;
|
2012-08-24 10:50:49 -07:00
|
|
|
mozilla::css::URLValue* mURL;
|
|
|
|
mozilla::css::ImageValue* mImage;
|
2014-03-21 08:06:13 -07:00
|
|
|
mozilla::css::GridTemplateAreasValue* mGridTemplateAreas;
|
2009-08-01 08:53:40 -07:00
|
|
|
nsCSSValueGradient* mGradient;
|
2013-12-11 18:09:42 -08:00
|
|
|
nsCSSValueTokenStream* mTokenStream;
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValuePair_heap* mPair;
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSRect_heap* mRect;
|
2011-08-02 20:04:23 -07:00
|
|
|
nsCSSValueTriplet_heap* mTriplet;
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValueList_heap* mList;
|
|
|
|
nsCSSValueList* mListDependent;
|
2013-12-11 18:09:44 -08:00
|
|
|
nsCSSValueSharedList* mSharedList;
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValuePairList_heap* mPairList;
|
|
|
|
nsCSSValuePairList* mPairListDependent;
|
2013-09-15 16:35:48 -07:00
|
|
|
nsCSSValueFloatColor* mFloatColor;
|
2014-07-30 01:15:00 -07:00
|
|
|
mozilla::css::FontFamilyListRefCnt* mFontFamilyList;
|
2012-01-02 18:19:14 -08:00
|
|
|
} mValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValue::Array MOZ_FINAL {
|
2009-02-04 21:15:52 -08:00
|
|
|
|
|
|
|
// return |Array| with reference count of zero
|
2010-06-24 14:53:44 -07:00
|
|
|
static Array* Create(size_t aItemCount) {
|
2009-02-04 21:15:52 -08:00
|
|
|
return new (aItemCount) Array(aItemCount);
|
|
|
|
}
|
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
nsCSSValue& operator[](size_t aIndex) {
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
|
2009-02-04 21:15:52 -08:00
|
|
|
return mArray[aIndex];
|
|
|
|
}
|
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
const nsCSSValue& operator[](size_t aIndex) const {
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
|
2009-02-04 21:15:52 -08:00
|
|
|
return mArray[aIndex];
|
|
|
|
}
|
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
nsCSSValue& Item(size_t aIndex) { return (*this)[aIndex]; }
|
|
|
|
const nsCSSValue& Item(size_t aIndex) const { return (*this)[aIndex]; }
|
2009-02-04 21:15:52 -08:00
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
size_t Count() const { return mCount; }
|
2009-02-04 21:15:52 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const Array& aOther) const
|
2009-02-04 21:15:52 -08:00
|
|
|
{
|
|
|
|
if (mCount != aOther.mCount)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-06-24 14:53:44 -07:00
|
|
|
for (size_t i = 0; i < mCount; ++i)
|
2009-02-04 21:15:52 -08:00
|
|
|
if ((*this)[i] != aOther[i])
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
|
|
|
return true;
|
2009-02-04 21:15:52 -08:00
|
|
|
}
|
|
|
|
|
2010-06-26 11:58:06 -07:00
|
|
|
// XXXdholbert This uses a size_t ref count. Should we use a variant
|
|
|
|
// of NS_INLINE_DECL_REFCOUNTING that takes a type as an argument?
|
2009-02-04 21:15:52 -08:00
|
|
|
void AddRef() {
|
2010-06-24 14:53:44 -07:00
|
|
|
if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
|
2009-02-04 21:15:52 -08:00
|
|
|
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++mRefCnt;
|
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
|
|
|
|
}
|
|
|
|
void Release() {
|
2010-06-24 14:53:44 -07:00
|
|
|
if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
|
2009-02-04 21:15:52 -08:00
|
|
|
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
--mRefCnt;
|
|
|
|
NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
|
|
|
|
if (mRefCnt == 0)
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
size_t mRefCnt;
|
|
|
|
const size_t mCount;
|
2009-02-04 21:15:52 -08:00
|
|
|
// This must be the last sub-object, since we extend this array to
|
|
|
|
// be of size mCount; it needs to be a sub-object so it gets proper
|
|
|
|
// alignment.
|
|
|
|
nsCSSValue mArray[1];
|
|
|
|
|
2010-06-24 14:53:44 -07:00
|
|
|
void* operator new(size_t aSelfSize, size_t aItemCount) CPP_THROW_NEW {
|
2009-02-04 21:15:52 -08:00
|
|
|
NS_ABORT_IF_FALSE(aItemCount > 0, "cannot have a 0 item count");
|
|
|
|
return ::operator new(aSelfSize + sizeof(nsCSSValue) * (aItemCount - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator delete(void* aPtr) { ::operator delete(aPtr); }
|
|
|
|
|
|
|
|
nsCSSValue* First() { return mArray; }
|
|
|
|
|
|
|
|
const nsCSSValue* First() const { return mArray; }
|
|
|
|
|
|
|
|
#define CSSVALUE_LIST_FOR_EXTRA_VALUES(var) \
|
|
|
|
for (nsCSSValue *var = First() + 1, *var##_end = First() + mCount; \
|
|
|
|
var != var##_end; ++var)
|
|
|
|
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit Array(size_t aItemCount)
|
2009-02-04 21:15:52 -08:00
|
|
|
: mRefCnt(0)
|
|
|
|
, mCount(aItemCount)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValue::Array);
|
|
|
|
CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
|
|
|
|
new (val) nsCSSValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~Array()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsCSSValue::Array);
|
|
|
|
CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
|
|
|
|
val->~nsCSSValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2009-02-04 21:15:52 -08:00
|
|
|
#undef CSSVALUE_LIST_FOR_EXTRA_VALUES
|
|
|
|
|
|
|
|
private:
|
2011-12-16 11:42:07 -08:00
|
|
|
Array(const Array& aOther) MOZ_DELETE;
|
|
|
|
Array& operator=(const Array& aOther) MOZ_DELETE;
|
2009-02-04 21:15:52 -08:00
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
// Prefer nsCSSValue::Array for lists of fixed size.
|
|
|
|
struct nsCSSValueList {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsCSSValueList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValueList); }
|
2010-08-19 12:33:43 -07:00
|
|
|
~nsCSSValueList();
|
|
|
|
|
|
|
|
nsCSSValueList* Clone() const; // makes a deep copy
|
2011-07-22 15:28:07 -07:00
|
|
|
void CloneInto(nsCSSValueList* aList) const; // makes a deep copy into aList
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
|
|
|
bool operator==(nsCSSValueList const& aOther) const;
|
|
|
|
bool operator!=(const nsCSSValueList& aOther) const
|
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
nsCSSValue mValue;
|
|
|
|
nsCSSValueList* mNext;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCSSValueList(const nsCSSValueList& aCopy) // makes a shallow copy
|
2012-07-30 07:20:58 -07:00
|
|
|
: mValue(aCopy.mValue), mNext(nullptr)
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueList);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// nsCSSValueList_heap differs from nsCSSValueList only in being
|
|
|
|
// refcounted. It should not be necessary to use this class directly;
|
|
|
|
// it's an implementation detail of nsCSSValue.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValueList_heap MOZ_FINAL : public nsCSSValueList {
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueList_heap)
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSValueList_heap()
|
|
|
|
{
|
|
|
|
}
|
2010-08-19 12:33:44 -07:00
|
|
|
};
|
|
|
|
|
2013-12-11 18:09:44 -08:00
|
|
|
// This is a reference counted list value. Note that the object is
|
|
|
|
// a wrapper for the reference count and a pointer to the head of the
|
|
|
|
// list, whereas the other list types (such as nsCSSValueList) do
|
|
|
|
// not have such a wrapper.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValueSharedList MOZ_FINAL {
|
2013-12-11 18:09:44 -08:00
|
|
|
nsCSSValueSharedList()
|
2013-12-11 18:09:44 -08:00
|
|
|
: mHead(nullptr)
|
2013-12-11 18:09:44 -08:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueSharedList);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Takes ownership of aList.
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit nsCSSValueSharedList(nsCSSValueList* aList)
|
2013-12-11 18:09:44 -08:00
|
|
|
: mHead(aList)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueSharedList);
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2013-12-11 18:09:44 -08:00
|
|
|
~nsCSSValueSharedList();
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
public:
|
2013-12-11 18:09:44 -08:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueSharedList)
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2013-12-11 18:09:44 -08:00
|
|
|
|
|
|
|
bool operator==(nsCSSValueSharedList const& aOther) const;
|
|
|
|
bool operator!=(const nsCSSValueSharedList& aOther) const
|
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
|
|
|
nsCSSValueList* mHead;
|
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// This has to be here so that the relationship between nsCSSValueList
|
|
|
|
// and nsCSSValueList_heap is visible.
|
|
|
|
inline nsCSSValueList*
|
|
|
|
nsCSSValue::GetListValue()
|
|
|
|
{
|
|
|
|
if (mUnit == eCSSUnit_List)
|
|
|
|
return mValue.mList;
|
|
|
|
else {
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value");
|
|
|
|
return mValue.mListDependent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSValueList*
|
|
|
|
nsCSSValue::GetListValue() const
|
|
|
|
{
|
|
|
|
if (mUnit == eCSSUnit_List)
|
|
|
|
return mValue.mList;
|
|
|
|
else {
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_ListDep, "not a pairlist value");
|
|
|
|
return mValue.mListDependent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
struct nsCSSRect {
|
|
|
|
nsCSSRect(void);
|
|
|
|
nsCSSRect(const nsCSSRect& aCopy);
|
|
|
|
~nsCSSRect();
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSRect& aOther) const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return mTop == aOther.mTop &&
|
|
|
|
mRight == aOther.mRight &&
|
|
|
|
mBottom == aOther.mBottom &&
|
|
|
|
mLeft == aOther.mLeft;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSRect& aOther) const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return mTop != aOther.mTop ||
|
|
|
|
mRight != aOther.mRight ||
|
|
|
|
mBottom != aOther.mBottom ||
|
|
|
|
mLeft != aOther.mLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAllSidesTo(const nsCSSValue& aValue);
|
|
|
|
|
2012-05-30 22:19:49 -07:00
|
|
|
bool AllSidesEqualTo(const nsCSSValue& aValue) const {
|
|
|
|
return mTop == aValue &&
|
|
|
|
mRight == aValue &&
|
|
|
|
mBottom == aValue &&
|
|
|
|
mLeft == aValue;
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
void Reset() {
|
|
|
|
mTop.Reset();
|
|
|
|
mRight.Reset();
|
|
|
|
mBottom.Reset();
|
|
|
|
mLeft.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasValue() const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return
|
|
|
|
mTop.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mRight.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mBottom.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mLeft.GetUnit() != eCSSUnit_Null;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSValue mTop;
|
|
|
|
nsCSSValue mRight;
|
|
|
|
nsCSSValue mBottom;
|
|
|
|
nsCSSValue mLeft;
|
|
|
|
|
|
|
|
typedef nsCSSValue nsCSSRect::*side_type;
|
|
|
|
static const side_type sides[4];
|
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// nsCSSRect_heap differs from nsCSSRect only in being
|
|
|
|
// refcounted. It should not be necessary to use this class directly;
|
|
|
|
// it's an implementation detail of nsCSSValue.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSRect_heap MOZ_FINAL : public nsCSSRect {
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap)
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSRect_heap()
|
|
|
|
{
|
|
|
|
}
|
2010-08-19 12:33:44 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// This has to be here so that the relationship between nsCSSRect
|
|
|
|
// and nsCSSRect_heap is visible.
|
|
|
|
inline nsCSSRect&
|
|
|
|
nsCSSValue::GetRectValue()
|
|
|
|
{
|
2011-12-22 15:34:45 -08:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
|
2010-08-19 12:33:44 -07:00
|
|
|
return *mValue.mRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSRect&
|
|
|
|
nsCSSValue::GetRectValue() const
|
|
|
|
{
|
2011-12-22 15:34:45 -08:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
|
2010-08-19 12:33:44 -07:00
|
|
|
return *mValue.mRect;
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
struct nsCSSValuePair {
|
|
|
|
nsCSSValuePair()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePair);
|
|
|
|
}
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit nsCSSValuePair(nsCSSUnit aUnit)
|
2010-08-19 12:33:43 -07:00
|
|
|
: mXValue(aUnit), mYValue(aUnit)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePair);
|
|
|
|
}
|
|
|
|
nsCSSValuePair(const nsCSSValue& aXValue, const nsCSSValue& aYValue)
|
|
|
|
: mXValue(aXValue), mYValue(aYValue)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePair);
|
|
|
|
}
|
|
|
|
nsCSSValuePair(const nsCSSValuePair& aCopy)
|
|
|
|
: mXValue(aCopy.mXValue), mYValue(aCopy.mYValue)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePair);
|
|
|
|
}
|
|
|
|
~nsCSSValuePair()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsCSSValuePair);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSValuePair& aOther) const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return mXValue == aOther.mXValue &&
|
|
|
|
mYValue == aOther.mYValue;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSValuePair& aOther) const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return mXValue != aOther.mXValue ||
|
|
|
|
mYValue != aOther.mYValue;
|
|
|
|
}
|
|
|
|
|
2012-05-30 22:19:49 -07:00
|
|
|
bool BothValuesEqualTo(const nsCSSValue& aValue) const {
|
|
|
|
return mXValue == aValue &&
|
|
|
|
mYValue == aValue;
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
void SetBothValuesTo(const nsCSSValue& aValue) {
|
|
|
|
mXValue = aValue;
|
|
|
|
mYValue = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
mXValue.Reset();
|
|
|
|
mYValue.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasValue() const {
|
2010-08-19 12:33:43 -07:00
|
|
|
return mXValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mYValue.GetUnit() != eCSSUnit_Null;
|
|
|
|
}
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
nsCSSValue mXValue;
|
|
|
|
nsCSSValue mYValue;
|
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// nsCSSValuePair_heap differs from nsCSSValuePair only in being
|
|
|
|
// refcounted. It should not be necessary to use this class directly;
|
|
|
|
// it's an implementation detail of nsCSSValue.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValuePair_heap MOZ_FINAL : public nsCSSValuePair {
|
2012-01-02 18:19:14 -08:00
|
|
|
// forward constructor
|
|
|
|
nsCSSValuePair_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue)
|
|
|
|
: nsCSSValuePair(aXValue, aYValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValuePair_heap)
|
2011-08-02 20:04:23 -07:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSValuePair_heap()
|
|
|
|
{
|
|
|
|
}
|
2011-08-02 20:04:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsCSSValueTriplet {
|
|
|
|
nsCSSValueTriplet()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueTriplet);
|
|
|
|
}
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit nsCSSValueTriplet(nsCSSUnit aUnit)
|
2011-08-02 20:04:23 -07:00
|
|
|
: mXValue(aUnit), mYValue(aUnit), mZValue(aUnit)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueTriplet);
|
|
|
|
}
|
|
|
|
nsCSSValueTriplet(const nsCSSValue& aXValue,
|
|
|
|
const nsCSSValue& aYValue,
|
|
|
|
const nsCSSValue& aZValue)
|
|
|
|
: mXValue(aXValue), mYValue(aYValue), mZValue(aZValue)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueTriplet);
|
|
|
|
}
|
|
|
|
nsCSSValueTriplet(const nsCSSValueTriplet& aCopy)
|
|
|
|
: mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mZValue(aCopy.mZValue)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueTriplet);
|
|
|
|
}
|
|
|
|
~nsCSSValueTriplet()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsCSSValueTriplet);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSValueTriplet& aOther) const {
|
2011-08-02 20:04:23 -07:00
|
|
|
return mXValue == aOther.mXValue &&
|
|
|
|
mYValue == aOther.mYValue &&
|
|
|
|
mZValue == aOther.mZValue;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSValueTriplet& aOther) const {
|
2011-08-02 20:04:23 -07:00
|
|
|
return mXValue != aOther.mXValue ||
|
|
|
|
mYValue != aOther.mYValue ||
|
|
|
|
mZValue != aOther.mZValue;
|
|
|
|
}
|
|
|
|
|
2012-05-30 22:19:49 -07:00
|
|
|
bool AllValuesEqualTo(const nsCSSValue& aValue) const {
|
|
|
|
return mXValue == aValue &&
|
|
|
|
mYValue == aValue &&
|
|
|
|
mZValue == aValue;
|
|
|
|
}
|
|
|
|
|
2011-08-02 20:04:23 -07:00
|
|
|
void SetAllValuesTo(const nsCSSValue& aValue) {
|
|
|
|
mXValue = aValue;
|
|
|
|
mYValue = aValue;
|
|
|
|
mZValue = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
mXValue.Reset();
|
|
|
|
mYValue.Reset();
|
|
|
|
mZValue.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasValue() const {
|
2011-08-02 20:04:23 -07:00
|
|
|
return mXValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mYValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mZValue.GetUnit() != eCSSUnit_Null;
|
|
|
|
}
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2011-08-02 20:04:23 -07:00
|
|
|
|
|
|
|
nsCSSValue mXValue;
|
|
|
|
nsCSSValue mYValue;
|
|
|
|
nsCSSValue mZValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
// nsCSSValueTriplet_heap differs from nsCSSValueTriplet only in being
|
|
|
|
// refcounted. It should not be necessary to use this class directly;
|
|
|
|
// it's an implementation detail of nsCSSValue.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValueTriplet_heap MOZ_FINAL : public nsCSSValueTriplet {
|
2010-08-19 12:33:44 -07:00
|
|
|
// forward constructor
|
2011-08-02 20:04:23 -07:00
|
|
|
nsCSSValueTriplet_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue, const nsCSSValue& aZValue)
|
|
|
|
: nsCSSValueTriplet(aXValue, aYValue, aZValue)
|
2010-08-19 12:33:44 -07:00
|
|
|
{}
|
|
|
|
|
2011-08-02 20:04:23 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap)
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSValueTriplet_heap()
|
|
|
|
{
|
|
|
|
}
|
2010-08-19 12:33:44 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// This has to be here so that the relationship between nsCSSValuePair
|
|
|
|
// and nsCSSValuePair_heap is visible.
|
|
|
|
inline nsCSSValuePair&
|
|
|
|
nsCSSValue::GetPairValue()
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
|
2010-08-19 12:33:44 -07:00
|
|
|
return *mValue.mPair;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSValuePair&
|
|
|
|
nsCSSValue::GetPairValue() const
|
|
|
|
{
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
|
2010-08-19 12:33:44 -07:00
|
|
|
return *mValue.mPair;
|
|
|
|
}
|
|
|
|
|
2011-08-02 20:04:23 -07:00
|
|
|
inline nsCSSValueTriplet&
|
|
|
|
nsCSSValue::GetTripletValue()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value");
|
|
|
|
return *mValue.mTriplet;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSValueTriplet&
|
|
|
|
nsCSSValue::GetTripletValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Triplet, "not a triplet value");
|
|
|
|
return *mValue.mTriplet;
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
// Maybe should be replaced with nsCSSValueList and nsCSSValue::Array?
|
|
|
|
struct nsCSSValuePairList {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsCSSValuePairList() : mNext(nullptr) { MOZ_COUNT_CTOR(nsCSSValuePairList); }
|
2010-08-19 12:33:43 -07:00
|
|
|
~nsCSSValuePairList();
|
|
|
|
|
|
|
|
nsCSSValuePairList* Clone() const; // makes a deep copy
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
|
|
|
bool operator==(const nsCSSValuePairList& aOther) const;
|
|
|
|
bool operator!=(const nsCSSValuePairList& aOther) const
|
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
nsCSSValue mXValue;
|
|
|
|
nsCSSValue mYValue;
|
|
|
|
nsCSSValuePairList* mNext;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCSSValuePairList(const nsCSSValuePairList& aCopy) // makes a shallow copy
|
2012-07-30 07:20:58 -07:00
|
|
|
: mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mNext(nullptr)
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePairList);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-19 12:33:44 -07:00
|
|
|
// nsCSSValuePairList_heap differs from nsCSSValuePairList only in being
|
|
|
|
// refcounted. It should not be necessary to use this class directly;
|
|
|
|
// it's an implementation detail of nsCSSValue.
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValuePairList_heap MOZ_FINAL : public nsCSSValuePairList {
|
2010-08-19 12:33:44 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValuePairList_heap)
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSValuePairList_heap()
|
|
|
|
{
|
|
|
|
}
|
2010-08-19 12:33:44 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// This has to be here so that the relationship between nsCSSValuePairList
|
|
|
|
// and nsCSSValuePairList_heap is visible.
|
|
|
|
inline nsCSSValuePairList*
|
|
|
|
nsCSSValue::GetPairListValue()
|
|
|
|
{
|
|
|
|
if (mUnit == eCSSUnit_PairList)
|
|
|
|
return mValue.mPairList;
|
|
|
|
else {
|
|
|
|
NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value");
|
|
|
|
return mValue.mPairListDependent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSValuePairList*
|
|
|
|
nsCSSValue::GetPairListValue() const
|
|
|
|
{
|
|
|
|
if (mUnit == eCSSUnit_PairList)
|
|
|
|
return mValue.mPairList;
|
|
|
|
else {
|
|
|
|
NS_ABORT_IF_FALSE (mUnit == eCSSUnit_PairListDep, "not a pairlist value");
|
|
|
|
return mValue.mPairListDependent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
struct nsCSSValueGradientStop {
|
|
|
|
public:
|
|
|
|
nsCSSValueGradientStop();
|
2011-05-28 15:38:48 -07:00
|
|
|
// needed to keep bloat logs happy when we use the TArray
|
|
|
|
// in nsCSSValueGradient
|
2010-08-19 12:33:43 -07:00
|
|
|
nsCSSValueGradientStop(const nsCSSValueGradientStop& aOther);
|
|
|
|
~nsCSSValueGradientStop();
|
|
|
|
|
|
|
|
nsCSSValue mLocation;
|
|
|
|
nsCSSValue mColor;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSValueGradientStop& aOther) const
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
return (mLocation == aOther.mLocation &&
|
|
|
|
mColor == aOther.mColor);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSValueGradientStop& aOther) const
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2010-08-19 12:33:43 -07:00
|
|
|
};
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValueGradient MOZ_FINAL {
|
2011-09-28 23:19:26 -07:00
|
|
|
nsCSSValueGradient(bool aIsRadial, bool aIsRepeating);
|
2010-08-19 12:33:43 -07:00
|
|
|
|
|
|
|
// true if gradient is radial, false if it is linear
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsRadial;
|
|
|
|
bool mIsRepeating;
|
2012-07-07 07:27:08 -07:00
|
|
|
bool mIsLegacySyntax;
|
2012-07-07 07:27:08 -07:00
|
|
|
bool mIsExplicitSize;
|
2010-08-19 12:33:43 -07:00
|
|
|
// line position and angle
|
|
|
|
nsCSSValuePair mBgPos;
|
|
|
|
nsCSSValue mAngle;
|
|
|
|
|
|
|
|
// Only meaningful if mIsRadial is true
|
2012-07-07 07:27:08 -07:00
|
|
|
private:
|
|
|
|
nsCSSValue mRadialValues[2];
|
|
|
|
public:
|
2013-12-13 20:22:48 -08:00
|
|
|
nsCSSValue& GetRadialShape()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsExplicitSize);
|
|
|
|
return mRadialValues[0];
|
|
|
|
}
|
|
|
|
const nsCSSValue& GetRadialShape() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsExplicitSize);
|
|
|
|
return mRadialValues[0];
|
|
|
|
}
|
|
|
|
nsCSSValue& GetRadialSize()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsExplicitSize);
|
|
|
|
return mRadialValues[1];
|
|
|
|
}
|
|
|
|
const nsCSSValue& GetRadialSize() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsExplicitSize);
|
|
|
|
return mRadialValues[1];
|
|
|
|
}
|
|
|
|
nsCSSValue& GetRadiusX()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsExplicitSize);
|
|
|
|
return mRadialValues[0];
|
|
|
|
}
|
|
|
|
const nsCSSValue& GetRadiusX() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsExplicitSize);
|
|
|
|
return mRadialValues[0];
|
|
|
|
}
|
|
|
|
nsCSSValue& GetRadiusY()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsExplicitSize);
|
|
|
|
return mRadialValues[1];
|
|
|
|
}
|
|
|
|
const nsCSSValue& GetRadiusY() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsExplicitSize);
|
|
|
|
return mRadialValues[1];
|
|
|
|
}
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2011-05-28 15:38:48 -07:00
|
|
|
InfallibleTArray<nsCSSValueGradientStop> mStops;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSValueGradient& aOther) const
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
if (mIsRadial != aOther.mIsRadial ||
|
|
|
|
mIsRepeating != aOther.mIsRepeating ||
|
2012-07-07 07:27:08 -07:00
|
|
|
mIsLegacySyntax != aOther.mIsLegacySyntax ||
|
2012-07-07 07:27:08 -07:00
|
|
|
mIsExplicitSize != aOther.mIsExplicitSize ||
|
2010-08-19 12:33:43 -07:00
|
|
|
mBgPos != aOther.mBgPos ||
|
|
|
|
mAngle != aOther.mAngle ||
|
2012-07-07 07:27:08 -07:00
|
|
|
mRadialValues[0] != aOther.mRadialValues[0] ||
|
|
|
|
mRadialValues[1] != aOther.mRadialValues[1])
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
|
|
|
if (mStops.Length() != aOther.mStops.Length())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-19 12:33:43 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2010-08-19 12:33:43 -07:00
|
|
|
if (mStops[i] != aOther.mStops[i])
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-19 12:33:43 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-08-19 12:33:43 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSValueGradient& aOther) const
|
2010-08-19 12:33:43 -07:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient)
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-02 18:19:14 -08:00
|
|
|
|
2010-08-19 12:33:43 -07:00
|
|
|
private:
|
2014-03-20 18:16:20 -07:00
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~nsCSSValueGradient()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-12-16 11:42:07 -08:00
|
|
|
nsCSSValueGradient(const nsCSSValueGradient& aOther) MOZ_DELETE;
|
|
|
|
nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther) MOZ_DELETE;
|
2010-08-19 12:33:43 -07:00
|
|
|
};
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
struct nsCSSValueTokenStream MOZ_FINAL {
|
2013-12-11 18:09:42 -08:00
|
|
|
nsCSSValueTokenStream();
|
2014-03-20 18:16:20 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2013-12-11 18:09:42 -08:00
|
|
|
~nsCSSValueTokenStream();
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
public:
|
2013-12-11 18:09:42 -08:00
|
|
|
bool operator==(const nsCSSValueTokenStream& aOther) const
|
|
|
|
{
|
|
|
|
bool eq;
|
|
|
|
return mPropertyID == aOther.mPropertyID &&
|
|
|
|
mShorthandPropertyID == aOther.mShorthandPropertyID &&
|
|
|
|
mTokenStream.Equals(aOther.mTokenStream) &&
|
|
|
|
(mBaseURI == aOther.mBaseURI ||
|
|
|
|
(mBaseURI && aOther.mBaseURI &&
|
|
|
|
NS_SUCCEEDED(mBaseURI->Equals(aOther.mBaseURI, &eq)) &&
|
|
|
|
eq)) &&
|
|
|
|
(mSheetURI == aOther.mSheetURI ||
|
|
|
|
(mSheetURI && aOther.mSheetURI &&
|
|
|
|
NS_SUCCEEDED(mSheetURI->Equals(aOther.mSheetURI, &eq)) &&
|
|
|
|
eq)) &&
|
|
|
|
(mSheetPrincipal == aOther.mSheetPrincipal ||
|
|
|
|
(mSheetPrincipal && aOther.mSheetPrincipal &&
|
|
|
|
NS_SUCCEEDED(mSheetPrincipal->Equals(aOther.mSheetPrincipal,
|
|
|
|
&eq)) &&
|
|
|
|
eq));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const nsCSSValueTokenStream& aOther) const
|
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueTokenStream)
|
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
|
|
|
// The property that has mTokenStream as its unparsed specified value.
|
|
|
|
// When a variable reference is used in a shorthand property, a
|
|
|
|
// TokenStream value is stored as the specified value for each of its
|
|
|
|
// component longhand properties.
|
|
|
|
nsCSSProperty mPropertyID;
|
|
|
|
|
|
|
|
// The shorthand property that had a value with a variable reference,
|
|
|
|
// which caused the longhand property identified by mPropertyID to have
|
|
|
|
// a TokenStream value.
|
|
|
|
nsCSSProperty mShorthandPropertyID;
|
|
|
|
|
|
|
|
// The unparsed CSS corresponding to the specified value of the property.
|
|
|
|
// When the value of a shorthand property has a variable reference, the
|
|
|
|
// same mTokenStream value is used on each of the nsCSSValueTokenStream
|
|
|
|
// objects that will be set by parsing the shorthand.
|
|
|
|
nsString mTokenStream;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
nsCOMPtr<nsIURI> mSheetURI;
|
|
|
|
nsCOMPtr<nsIPrincipal> mSheetPrincipal;
|
2014-06-20 03:32:49 -07:00
|
|
|
mozilla::CSSStyleSheet* mSheet;
|
2013-12-11 18:09:44 -08:00
|
|
|
uint32_t mLineNumber;
|
|
|
|
uint32_t mLineOffset;
|
2013-12-11 18:09:42 -08:00
|
|
|
|
2014-03-18 02:11:14 -07:00
|
|
|
// This table is used to hold a reference on to any ImageValue that results
|
|
|
|
// from re-parsing this token stream at computed value time. When properties
|
|
|
|
// like background-image contain a normal url(), the Declaration's data block
|
|
|
|
// will hold a reference to the ImageValue. When a token stream is used,
|
|
|
|
// the Declaration only holds on to this nsCSSValueTokenStream object, and
|
|
|
|
// the ImageValue would only exist for the duration of
|
|
|
|
// nsRuleNode::WalkRuleTree, in the AutoCSSValueArray. So instead when
|
|
|
|
// we re-parse a token stream and get an ImageValue, we record it in this
|
|
|
|
// table so that the Declaration can be the object that keeps holding
|
|
|
|
// a reference to it.
|
|
|
|
nsTHashtable<nsRefPtrHashKey<mozilla::css::ImageValue> > mImageValues;
|
|
|
|
|
2013-12-11 18:09:42 -08:00
|
|
|
private:
|
|
|
|
nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) MOZ_DELETE;
|
|
|
|
nsCSSValueTokenStream& operator=(const nsCSSValueTokenStream& aOther) MOZ_DELETE;
|
|
|
|
};
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
class nsCSSValueFloatColor MOZ_FINAL {
|
2013-09-15 16:35:48 -07:00
|
|
|
public:
|
|
|
|
nsCSSValueFloatColor(float aComponent1, float aComponent2, float aComponent3,
|
|
|
|
float aAlpha)
|
|
|
|
: mComponent1(aComponent1)
|
|
|
|
, mComponent2(aComponent2)
|
|
|
|
, mComponent3(aComponent3)
|
|
|
|
, mAlpha(aAlpha)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueFloatColor);
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2013-09-15 16:35:48 -07:00
|
|
|
~nsCSSValueFloatColor()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsCSSValueFloatColor);
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:16:20 -07:00
|
|
|
public:
|
2013-09-15 16:35:48 -07:00
|
|
|
bool operator==(nsCSSValueFloatColor& aOther) const;
|
|
|
|
|
|
|
|
nscolor GetColorValue(nsCSSUnit aUnit) const;
|
|
|
|
bool IsNonTransparentColor() const;
|
|
|
|
|
2013-09-15 16:35:49 -07:00
|
|
|
void AppendToString(nsCSSUnit aUnit, nsAString& aResult) const;
|
|
|
|
|
2013-09-15 16:35:48 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueFloatColor)
|
|
|
|
|
|
|
|
private:
|
|
|
|
// FIXME: We should not be clamping specified RGB color components.
|
|
|
|
float mComponent1; // 0..1 for RGB, 0..360 for HSL
|
|
|
|
float mComponent2; // 0..1
|
|
|
|
float mComponent3; // 0..1
|
|
|
|
float mAlpha; // 0..1
|
|
|
|
|
|
|
|
nsCSSValueFloatColor(const nsCSSValueFloatColor& aOther) MOZ_DELETE;
|
|
|
|
nsCSSValueFloatColor& operator=(const nsCSSValueFloatColor& aOther)
|
|
|
|
MOZ_DELETE;
|
|
|
|
};
|
|
|
|
|
2011-03-28 16:07:26 -07:00
|
|
|
struct nsCSSCornerSizes {
|
|
|
|
nsCSSCornerSizes(void);
|
|
|
|
nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
|
|
|
|
~nsCSSCornerSizes();
|
|
|
|
|
|
|
|
// argument is a "full corner" constant from nsStyleConsts.h
|
2012-08-22 08:56:38 -07:00
|
|
|
nsCSSValue const & GetCorner(uint32_t aCorner) const {
|
2011-03-28 16:07:26 -07:00
|
|
|
return this->*corners[aCorner];
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
nsCSSValue & GetCorner(uint32_t aCorner) {
|
2011-03-28 16:07:26 -07:00
|
|
|
return this->*corners[aCorner];
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const nsCSSCornerSizes& aOther) const {
|
2011-03-28 16:07:26 -07:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner) != aOther.GetCorner(corner))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator!=(const nsCSSCornerSizes& aOther) const {
|
2011-03-28 16:07:26 -07:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner) != aOther.GetCorner(corner))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasValue() const {
|
2011-03-28 16:07:26 -07:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-03-28 16:07:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
nsCSSValue mTopLeft;
|
|
|
|
nsCSSValue mTopRight;
|
|
|
|
nsCSSValue mBottomRight;
|
|
|
|
nsCSSValue mBottomLeft;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef nsCSSValue nsCSSCornerSizes::*corner_type;
|
|
|
|
static const corner_type corners[4];
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsCSSValue_h___ */
|
|
|
|
|