2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-08 05:29:29 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-10-08 05:29:29 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-10-08 05:29:29 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/* representation of simple property values within CSS declarations */
|
|
|
|
|
1998-10-08 05:29:29 +04:00
|
|
|
#ifndef nsCSSValue_h___
|
|
|
|
#define nsCSSValue_h___
|
|
|
|
|
2011-12-16 23:42:07 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2003-10-30 04:45:37 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2006-08-25 07:27:47 +04:00
|
|
|
#include "nsCRTGlue.h"
|
2010-08-19 23:33:43 +04:00
|
|
|
#include "nsCSSKeywords.h"
|
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCoord.h"
|
2012-04-07 19:58:41 +04:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2010-08-19 23:33:43 +04:00
|
|
|
#include "nsString.h"
|
2006-12-13 18:49:36 +03:00
|
|
|
#include "nsStringBuffer.h"
|
2009-08-01 19:53:40 +04:00
|
|
|
#include "nsTArray.h"
|
2011-03-29 03:07:26 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-03-09 06:57:51 +03:00
|
|
|
|
|
|
|
class imgIRequest;
|
|
|
|
class nsIDocument;
|
2007-05-03 05:15:53 +04:00
|
|
|
class nsIPrincipal;
|
2010-08-13 13:58:01 +04:00
|
|
|
class nsPresContext;
|
2010-08-19 23:33:43 +04:00
|
|
|
class nsIURI;
|
2012-04-07 19:58:41 +04:00
|
|
|
template <class T>
|
|
|
|
class nsPtrHashKey;
|
1998-10-08 05:29:29 +04:00
|
|
|
|
2008-10-17 12:13:16 +04: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_; \
|
|
|
|
(ptr_)->member_ = nsnull; \
|
|
|
|
while (cur) { \
|
|
|
|
type_ *next = cur->member_; \
|
|
|
|
cur->member_ = nsnull; \
|
|
|
|
delete cur; \
|
|
|
|
cur = next; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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_); \
|
|
|
|
(to_)->member_ = nsnull; \
|
|
|
|
for (const type_ *src = (from_)->member_; src; src = src->member_) { \
|
|
|
|
type_ *clone = src->Clone args_; \
|
|
|
|
if (!clone) { \
|
|
|
|
delete (to_); \
|
|
|
|
return nsnull; \
|
|
|
|
} \
|
|
|
|
dest->member_ = clone; \
|
|
|
|
dest = clone; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
1998-10-08 05:29:29 +04:00
|
|
|
enum nsCSSUnit {
|
1998-10-27 02:19:59 +03:00
|
|
|
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
|
2001-06-01 02:19:43 +04:00
|
|
|
eCSSUnit_Initial = 3, // (n/a) value is default UA value
|
|
|
|
eCSSUnit_None = 4, // (n/a) value is none
|
|
|
|
eCSSUnit_Normal = 5, // (n/a) value is normal (algorithmic, different than auto)
|
2007-06-12 22:28:56 +04:00
|
|
|
eCSSUnit_System_Font = 6, // (n/a) value is -moz-use-system-font
|
2009-08-21 01:52:47 +04:00
|
|
|
eCSSUnit_All = 7, // (n/a) value is all
|
|
|
|
eCSSUnit_Dummy = 8, // (n/a) a fake but specified value, used
|
2007-10-09 03:11:01 +04:00
|
|
|
// only in temporary values
|
2009-08-21 01:52:47 +04:00
|
|
|
eCSSUnit_DummyInherit = 9, // (n/a) a fake but specified value, used
|
2008-10-07 22:53:22 +04:00
|
|
|
// only in temporary values
|
2010-08-19 23:33:44 +04:00
|
|
|
|
2009-08-21 01:52:47 +04:00
|
|
|
eCSSUnit_String = 11, // (PRUnichar*) a string value
|
|
|
|
eCSSUnit_Ident = 12, // (PRUnichar*) a string value
|
|
|
|
eCSSUnit_Families = 13, // (PRUnichar*) a string value
|
|
|
|
eCSSUnit_Attr = 14, // (PRUnichar*) a attr(string) value
|
|
|
|
eCSSUnit_Local_Font = 15, // (PRUnichar*) a local font name
|
|
|
|
eCSSUnit_Font_Format = 16, // (PRUnichar*) a font format name
|
2010-08-13 17:33:37 +04:00
|
|
|
eCSSUnit_Element = 17, // (PRUnichar*) an element id
|
2010-08-19 23:33:44 +04:00
|
|
|
|
2005-04-02 03:07:00 +04: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-21 01:52:47 +04:00
|
|
|
eCSSUnit_Cubic_Bezier = 23, // (nsCSSValue::Array*) a list of float values
|
2011-04-12 10:18:42 +04:00
|
|
|
eCSSUnit_Steps = 24, // (nsCSSValue::Array*) a list of (integer, enumerated)
|
|
|
|
eCSSUnit_Function = 25, // (nsCSSValue::Array*) a function with
|
2010-08-19 23:33:44 +04:00
|
|
|
// parameters. First elem of array is name,
|
2008-09-13 13:42:11 +04:00
|
|
|
// the rest of the values are arguments.
|
|
|
|
|
2010-09-11 20:27:12 +04: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 19:49:43 +04: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-12 10:18:42 +04:00
|
|
|
eCSSUnit_Calc = 30, // (nsCSSValue::Array*) calc() value
|
2010-05-11 19:49:43 +04: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-12 10:18:42 +04: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 19:49:43 +04:00
|
|
|
|
|
|
|
eCSSUnit_URL = 40, // (nsCSSValue::URL*) value
|
|
|
|
eCSSUnit_Image = 41, // (nsCSSValue::Image*) value
|
|
|
|
eCSSUnit_Gradient = 42, // (nsCSSValueGradient*) value
|
2010-08-19 23:33:44 +04:00
|
|
|
|
|
|
|
eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values
|
2011-08-03 07:04:23 +04: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 23:33:44 +04:00
|
|
|
// but does not own the list
|
2011-08-03 07:04:23 +04:00
|
|
|
eCSSUnit_PairList = 55, // (nsCSSValuePairList*) list of value pairs
|
|
|
|
eCSSUnit_PairListDep = 56, // (nsCSSValuePairList*) same as PairList
|
2010-08-19 23:33:44 +04:00
|
|
|
// but does not own the list
|
2010-08-19 23:33:44 +04:00
|
|
|
|
|
|
|
eCSSUnit_Integer = 70, // (int) simple value
|
|
|
|
eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning
|
|
|
|
|
2008-02-08 22:51:41 +03:00
|
|
|
eCSSUnit_EnumColor = 80, // (int) enumerated color (kColorKTable)
|
|
|
|
eCSSUnit_Color = 81, // (nscolor) an RGBA value
|
2010-08-19 23:33:44 +04:00
|
|
|
|
1998-10-27 02:19:59 +03: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 13:58:02 +04:00
|
|
|
// Physical length units
|
|
|
|
eCSSUnit_PhysicalMillimeter = 200, // (float) 1/25.4 inch
|
1998-10-08 05:29:29 +04:00
|
|
|
|
1998-10-27 02:19:59 +03:00
|
|
|
// Length units - relative
|
1998-10-08 05:29:29 +04:00
|
|
|
// Font relative measure
|
1998-10-27 02:19:59 +03:00
|
|
|
eCSSUnit_EM = 800, // (float) == current font size
|
2008-12-04 19:09:53 +03: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-21 00:58:48 +03:00
|
|
|
eCSSUnit_RootEM = 803, // (float) == root element font size
|
1998-10-08 05:29:29 +04:00
|
|
|
|
|
|
|
// Screen relative measure
|
2010-08-13 13:58:01 +04:00
|
|
|
eCSSUnit_Point = 900, // (float) 4/3 of a CSS pixel
|
2010-08-13 13:58:02 +04: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
|
1998-10-27 02:19:59 +03:00
|
|
|
|
|
|
|
// Angular units
|
|
|
|
eCSSUnit_Degree = 1000, // (float) 360 per circle
|
|
|
|
eCSSUnit_Grad = 1001, // (float) 400 per circle
|
2005-04-02 03:07:00 +04:00
|
|
|
eCSSUnit_Radian = 1002, // (float) 2*pi per circle
|
2012-02-04 09:01:23 +04:00
|
|
|
eCSSUnit_Turn = 1003, // (float) 1 per circle
|
1998-10-27 02:19:59 +03:00
|
|
|
|
|
|
|
// Frequency units
|
2005-04-02 03:07:00 +04:00
|
|
|
eCSSUnit_Hertz = 2000, // (float) 1/seconds
|
|
|
|
eCSSUnit_Kilohertz = 2001, // (float) 1000 Hertz
|
1998-10-27 02:19:59 +03:00
|
|
|
|
|
|
|
// Time units
|
2005-04-02 03:07:00 +04:00
|
|
|
eCSSUnit_Seconds = 3000, // (float) Standard time
|
|
|
|
eCSSUnit_Milliseconds = 3001 // (float) 1/1000 second
|
1998-10-08 05:29:29 +04:00
|
|
|
};
|
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
struct nsCSSValueGradient;
|
2010-08-19 23:33:44 +04:00
|
|
|
struct nsCSSValuePair;
|
|
|
|
struct nsCSSValuePair_heap;
|
2010-08-19 23:33:44 +04:00
|
|
|
struct nsCSSRect;
|
|
|
|
struct nsCSSRect_heap;
|
2010-08-19 23:33:44 +04:00
|
|
|
struct nsCSSValueList;
|
|
|
|
struct nsCSSValueList_heap;
|
2010-08-19 23:33:44 +04:00
|
|
|
struct nsCSSValuePairList;
|
|
|
|
struct nsCSSValuePairList_heap;
|
2011-08-03 07:04:23 +04:00
|
|
|
struct nsCSSValueTriplet;
|
|
|
|
struct nsCSSValueTriplet_heap;
|
2009-08-01 19:53:40 +04:00
|
|
|
|
1998-10-08 05:29:29 +04:00
|
|
|
class nsCSSValue {
|
|
|
|
public:
|
2005-04-02 03:07:00 +04:00
|
|
|
struct Array;
|
|
|
|
friend struct Array;
|
|
|
|
|
2003-10-30 04:45:37 +03:00
|
|
|
struct URL;
|
|
|
|
friend struct URL;
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
struct Image;
|
|
|
|
friend struct Image;
|
2010-08-19 23:33:43 +04:00
|
|
|
|
2009-08-21 01:52:47 +04:00
|
|
|
// for valueless units only (null, auto, inherit, none, all, normal)
|
2004-08-21 00:55:17 +04:00
|
|
|
explicit nsCSSValue(nsCSSUnit aUnit = eCSSUnit_Null)
|
2001-02-19 15:55:42 +03:00
|
|
|
: mUnit(aUnit)
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(aUnit <= eCSSUnit_DummyInherit, "not a valueless unit");
|
2001-02-19 15:55:42 +03:00
|
|
|
}
|
|
|
|
|
2010-04-07 01:52:17 +04:00
|
|
|
nsCSSValue(PRInt32 aValue, nsCSSUnit aUnit);
|
|
|
|
nsCSSValue(float aValue, nsCSSUnit aUnit);
|
|
|
|
nsCSSValue(const nsString& aValue, nsCSSUnit aUnit);
|
|
|
|
nsCSSValue(Array* aArray, nsCSSUnit aUnit);
|
|
|
|
explicit nsCSSValue(URL* aValue);
|
|
|
|
explicit nsCSSValue(Image* aValue);
|
|
|
|
explicit nsCSSValue(nsCSSValueGradient* aValue);
|
|
|
|
nsCSSValue(const nsCSSValue& aCopy);
|
2007-08-28 10:47:32 +04:00
|
|
|
~nsCSSValue() { Reset(); }
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2010-04-07 01:52:17 +04:00
|
|
|
nsCSSValue& operator=(const nsCSSValue& aCopy);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSValue& aOther) const;
|
2003-10-02 02:53:56 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSValue& aOther) const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
1998-10-08 05:29:29 +04:00
|
|
|
|
2010-07-23 22:00:27 +04:00
|
|
|
/**
|
|
|
|
* Serialize |this| as a specified value for |aProperty| and append
|
|
|
|
* it to |aResult|.
|
|
|
|
*/
|
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
2007-04-23 18:21:53 +04:00
|
|
|
nsCSSUnit GetUnit() const { return mUnit; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsLengthUnit() const
|
2010-08-13 13:58:02 +04:00
|
|
|
{ return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
2010-08-13 13:58:01 +04: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-29 10:19:26 +04:00
|
|
|
bool IsFixedLengthUnit() const
|
2010-08-13 13:58:02 +04:00
|
|
|
{ return mUnit == eCSSUnit_PhysicalMillimeter; }
|
2010-08-13 13:58:01 +04: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-29 10:19:26 +04:00
|
|
|
bool IsRelativeLengthUnit() const
|
2010-08-13 13:58:01 +04:00
|
|
|
{ return eCSSUnit_EM <= mUnit && mUnit <= eCSSUnit_RootEM; }
|
|
|
|
/**
|
|
|
|
* A "pixel" length unit is a some multiple of CSS pixels.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsPixelLengthUnit() const
|
2010-08-13 13:58:01 +04:00
|
|
|
{ return eCSSUnit_Point <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAngularUnit() const
|
2012-02-04 09:01:23 +04:00
|
|
|
{ return eCSSUnit_Degree <= mUnit && mUnit <= eCSSUnit_Turn; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsFrequencyUnit() const
|
2008-08-08 03:15:40 +04:00
|
|
|
{ return eCSSUnit_Hertz <= mUnit && mUnit <= eCSSUnit_Kilohertz; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsTimeUnit() const
|
2008-08-08 03:15:40 +04:00
|
|
|
{ return eCSSUnit_Seconds <= mUnit && mUnit <= eCSSUnit_Milliseconds; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsCalcUnit() const
|
2010-09-11 20:27:12 +04:00
|
|
|
{ return eCSSUnit_Calc <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
|
2008-08-08 03:15:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool UnitHasStringValue() const
|
2010-08-13 17:33:37 +04:00
|
|
|
{ return eCSSUnit_String <= mUnit && mUnit <= eCSSUnit_Element; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool UnitHasArrayValue() const
|
2010-09-11 20:27:12 +04:00
|
|
|
{ return eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
|
1998-10-08 05:29:29 +04:00
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
PRInt32 GetIntValue() const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Integer ||
|
|
|
|
mUnit == eCSSUnit_Enumerated ||
|
|
|
|
mUnit == eCSSUnit_EnumColor,
|
|
|
|
"not an int value");
|
2003-10-02 02:53:56 +04:00
|
|
|
return mValue.mInt;
|
|
|
|
}
|
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
float GetPercentValue() const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Percent, "not a percent value");
|
2003-10-02 02:53:56 +04:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
float GetFloatValue() const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(eCSSUnit_Number <= mUnit, "not a float value");
|
2003-10-02 02:53:56 +04:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
2009-11-02 22:36:43 +03:00
|
|
|
float GetAngleValue() const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(eCSSUnit_Degree <= mUnit &&
|
2012-02-04 09:01:23 +04:00
|
|
|
mUnit <= eCSSUnit_Turn, "not an angle value");
|
2009-11-02 22:36:43 +03:00
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Converts any angle to radians.
|
|
|
|
double GetAngleValueInRadians() const;
|
|
|
|
|
2003-10-02 02:53:56 +04:00
|
|
|
nsAString& GetStringValue(nsAString& aBuffer) const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
|
2003-10-02 02:53:56 +04:00
|
|
|
aBuffer.Truncate();
|
2006-12-13 18:49:36 +03:00
|
|
|
PRUint32 len = NS_strlen(GetBufferValue(mValue.mString));
|
|
|
|
mValue.mString->ToString(len, aBuffer);
|
2003-10-02 02:53:56 +04:00
|
|
|
return aBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PRUnichar* GetStringBufferValue() const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
|
2006-12-13 18:49:36 +03:00
|
|
|
return GetBufferValue(mValue.mString);
|
2003-10-02 02:53:56 +04:00
|
|
|
}
|
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
nscolor GetColorValue() const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE((mUnit == eCSSUnit_Color), "not a color value");
|
2003-10-02 02:53:56 +04:00
|
|
|
return mValue.mColor;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsNonTransparentColor() const;
|
2009-06-17 02:05:12 +04:00
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
Array* GetArrayValue() const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(UnitHasArrayValue(), "not an array value");
|
2005-04-02 03:07:00 +04:00
|
|
|
return mValue.mArray;
|
|
|
|
}
|
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
nsIURI* GetURLValue() const
|
2003-10-02 02:53:56 +04:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
2004-03-09 06:57:51 +03:00
|
|
|
"not a URL value");
|
|
|
|
return mUnit == eCSSUnit_URL ?
|
2011-05-11 19:28:53 +04:00
|
|
|
mValue.mURL->GetURI() : mValue.mImage->GetURI();
|
2003-10-30 04:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
nsCSSValueGradient* GetGradientValue() const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Gradient, "not a gradient value");
|
2009-08-01 19:53:40 +04:00
|
|
|
return mValue.mGradient;
|
|
|
|
}
|
|
|
|
|
2010-08-19 23:33:44 +04:00
|
|
|
// bodies of these are below
|
|
|
|
inline nsCSSValuePair& GetPairValue();
|
|
|
|
inline const nsCSSValuePair& GetPairValue() const;
|
2010-08-19 23:33:44 +04:00
|
|
|
|
2010-08-19 23:33:44 +04:00
|
|
|
inline nsCSSRect& GetRectValue();
|
|
|
|
inline const nsCSSRect& GetRectValue() const;
|
|
|
|
|
2010-08-19 23:33:44 +04:00
|
|
|
inline nsCSSValueList* GetListValue();
|
|
|
|
inline const nsCSSValueList* GetListValue() const;
|
|
|
|
|
2010-08-19 23:33:44 +04:00
|
|
|
inline nsCSSValuePairList* GetPairListValue();
|
|
|
|
inline const nsCSSValuePairList* GetPairListValue() const;
|
2010-08-19 23:33:44 +04:00
|
|
|
|
2011-08-03 07:04:23 +04:00
|
|
|
inline nsCSSValueTriplet& GetTripletValue();
|
|
|
|
inline const nsCSSValueTriplet& GetTripletValue() const;
|
|
|
|
|
2007-07-19 01:56:57 +04:00
|
|
|
URL* GetURLStructValue() const
|
|
|
|
{
|
|
|
|
// 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 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL, "not a URL value");
|
2007-07-19 01:56:57 +04:00
|
|
|
return mValue.mURL;
|
|
|
|
}
|
|
|
|
|
2012-04-07 19:58:41 +04:00
|
|
|
Image* GetImageStructValue() const
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value");
|
|
|
|
return mValue.mImage;
|
|
|
|
}
|
|
|
|
|
2003-12-29 22:07:53 +03:00
|
|
|
const PRUnichar* GetOriginalURLValue() const
|
2003-10-30 04:45:37 +03:00
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
|
|
|
"not a URL value");
|
2006-12-13 18:49:36 +03:00
|
|
|
return GetBufferValue(mUnit == eCSSUnit_URL ?
|
|
|
|
mValue.mURL->mString :
|
|
|
|
mValue.mImage->mString);
|
2003-10-02 02:53:56 +04:00
|
|
|
}
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
// 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-04-07 19:58:41 +04:00
|
|
|
imgIRequest* GetImageValue(nsIDocument* aDocument) const;
|
2005-04-02 03:07:00 +04:00
|
|
|
|
2010-08-13 13:58:01 +04:00
|
|
|
nscoord GetFixedLength(nsPresContext* aPresContext) const;
|
|
|
|
nscoord GetPixelLength() const;
|
2003-10-02 02:53:56 +04:00
|
|
|
|
2010-04-07 01:52:17 +04:00
|
|
|
void Reset() // sets to null
|
2001-02-19 15:55:42 +03:00
|
|
|
{
|
2007-08-28 10:47:32 +04:00
|
|
|
if (mUnit != eCSSUnit_Null)
|
|
|
|
DoReset();
|
2001-02-19 15:55:42 +03:00
|
|
|
}
|
2007-08-28 10:47:32 +04:00
|
|
|
private:
|
2010-04-07 01:52:17 +04:00
|
|
|
void DoReset();
|
1998-10-08 05:29:29 +04:00
|
|
|
|
2007-08-28 10:47:32 +04:00
|
|
|
public:
|
2010-04-07 01:52:17 +04:00
|
|
|
void SetIntValue(PRInt32 aValue, nsCSSUnit aUnit);
|
|
|
|
void SetPercentValue(float aValue);
|
|
|
|
void SetFloatValue(float aValue, nsCSSUnit aUnit);
|
|
|
|
void SetStringValue(const nsString& aValue, nsCSSUnit aUnit);
|
|
|
|
void SetColorValue(nscolor aValue);
|
|
|
|
void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit);
|
|
|
|
void SetURLValue(nsCSSValue::URL* aURI);
|
|
|
|
void SetImageValue(nsCSSValue::Image* aImage);
|
|
|
|
void SetGradientValue(nsCSSValueGradient* aGradient);
|
2010-08-19 23:33:44 +04:00
|
|
|
void SetPairValue(const nsCSSValuePair* aPair);
|
|
|
|
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
|
2010-08-19 23:33:44 +04:00
|
|
|
void SetDependentListValue(nsCSSValueList* aList);
|
2010-08-19 23:33:44 +04:00
|
|
|
void SetDependentPairListValue(nsCSSValuePairList* aList);
|
2011-08-03 07:04:23 +04:00
|
|
|
void SetTripletValue(const nsCSSValueTriplet* aTriplet);
|
|
|
|
void SetTripletValue(const nsCSSValue& xValue, const nsCSSValue& yValue, const nsCSSValue& zValue);
|
2010-04-07 01:52:17 +04:00
|
|
|
void SetAutoValue();
|
|
|
|
void SetInheritValue();
|
|
|
|
void SetInitialValue();
|
|
|
|
void SetNoneValue();
|
|
|
|
void SetAllValue();
|
|
|
|
void SetNormalValue();
|
|
|
|
void SetSystemFontValue();
|
|
|
|
void SetDummyValue();
|
|
|
|
void SetDummyInheritValue();
|
2010-08-19 23:33:44 +04:00
|
|
|
|
|
|
|
// These are a little different - they allocate storage for you and
|
|
|
|
// return a handle.
|
|
|
|
nsCSSRect& SetRectValue();
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSValueList* SetListValue();
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSValuePairList* SetPairListValue();
|
2010-08-19 23:33:44 +04:00
|
|
|
|
2010-04-07 01:52:17 +04:00
|
|
|
void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const
|
2003-12-29 22:07:53 +03:00
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
// Initializes as a function value with the specified function id.
|
2010-04-07 01:52:17 +04:00
|
|
|
Array* InitFunction(nsCSSKeyword aFunctionId, PRUint32 aNumArgs);
|
2009-08-22 00:39:25 +04:00
|
|
|
// Checks if this is a function value with the specified function id.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool EqualsFunction(nsCSSKeyword aFunctionId) const;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2006-12-13 18:49:36 +03:00
|
|
|
// Returns an already addrefed buffer. Can return null on allocation
|
|
|
|
// failure.
|
2010-12-05 16:17:29 +03:00
|
|
|
static already_AddRefed<nsStringBuffer>
|
|
|
|
BufferFromString(const nsString& aValue);
|
2010-08-19 23:33:43 +04:00
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2003-10-30 04:45:37 +03:00
|
|
|
struct URL {
|
2007-05-03 05:15:53 +04:00
|
|
|
// Methods are not inline because using an nsIPrincipal means requiring
|
|
|
|
// caps, which leads to REQUIRES hell, since this header is included all
|
2010-08-19 23:33:43 +04:00
|
|
|
// over.
|
2007-05-03 05:15:53 +04:00
|
|
|
|
2011-05-11 19:28:53 +04:00
|
|
|
// 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.
|
|
|
|
URL(nsStringBuffer* aString, nsIURI* aBaseURI, nsIURI* aReferrer,
|
|
|
|
nsIPrincipal* aOriginPrincipal);
|
|
|
|
// Construct with the actual URI.
|
2007-05-03 05:15:53 +04:00
|
|
|
URL(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
|
2010-04-07 01:52:17 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal);
|
2003-10-30 04:45:37 +03:00
|
|
|
|
2010-04-07 01:52:17 +04:00
|
|
|
~URL();
|
2003-10-30 04:45:37 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const URL& aOther) const;
|
2007-07-19 01:56:58 +04:00
|
|
|
|
2007-07-19 01:56:57 +04:00
|
|
|
// 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.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool URIEquals(const URL& aOther) const;
|
2007-07-19 01:56:57 +04:00
|
|
|
|
2011-05-11 19:28:53 +04:00
|
|
|
nsIURI* GetURI() const;
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2011-05-11 19:28:53 +04: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:
|
2006-12-13 18:49:36 +03:00
|
|
|
nsStringBuffer* mString; // Could use nsRefPtr, but it'd add useless
|
|
|
|
// null-checks; this is never null.
|
2004-07-15 01:56:23 +04:00
|
|
|
nsCOMPtr<nsIURI> mReferrer;
|
2007-05-03 05:15:53 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
2003-10-30 04:45:37 +03:00
|
|
|
|
2010-04-01 22:05:40 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValue::URL)
|
2010-04-01 22:05:40 +04:00
|
|
|
|
2011-05-11 19:28:53 +04:00
|
|
|
private:
|
2011-09-29 10:19:26 +04:00
|
|
|
mutable bool mURIResolved;
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2011-12-16 23:42:07 +04:00
|
|
|
URL(const URL& aOther) MOZ_DELETE;
|
|
|
|
URL& operator=(const URL& aOther) MOZ_DELETE;
|
2003-10-30 04:45:37 +03:00
|
|
|
};
|
|
|
|
|
2004-03-09 07:28:14 +03:00
|
|
|
struct Image : public URL {
|
2004-03-09 06:57:51 +03:00
|
|
|
// 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.
|
2006-12-13 18:49:36 +03:00
|
|
|
// aString must not be null.
|
|
|
|
Image(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
|
2010-04-07 01:52:17 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument);
|
|
|
|
~Image();
|
2004-03-09 06:57:51 +03:00
|
|
|
|
|
|
|
// Inherit operator== from nsCSSValue::URL
|
|
|
|
|
2012-04-07 19:58:41 +04:00
|
|
|
nsInterfaceHashtable<nsISupportsHashKey, imgIRequest> mRequests;
|
2004-03-09 06:57:51 +03:00
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
// Override AddRef and Release to not only log ourselves correctly, but
|
|
|
|
// also so that we delete correctly without a virtual destructor
|
2010-04-01 22:05:40 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValue::Image)
|
2004-03-09 06:57:51 +03:00
|
|
|
};
|
|
|
|
|
2006-12-13 18:49:36 +03:00
|
|
|
private:
|
|
|
|
static const PRUnichar* GetBufferValue(nsStringBuffer* aBuffer) {
|
2007-07-08 11:08:04 +04:00
|
|
|
return static_cast<PRUnichar*>(aBuffer->Data());
|
2006-12-13 18:49:36 +03:00
|
|
|
}
|
|
|
|
|
1998-10-08 05:29:29 +04:00
|
|
|
protected:
|
|
|
|
nsCSSUnit mUnit;
|
|
|
|
union {
|
2000-06-06 13:36:12 +04:00
|
|
|
PRInt32 mInt;
|
|
|
|
float mFloat;
|
2006-12-13 18:49:36 +03:00
|
|
|
// 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;
|
2000-06-06 13:36:12 +04:00
|
|
|
nscolor mColor;
|
2005-04-02 03:07:00 +04:00
|
|
|
Array* mArray;
|
2003-10-30 04:45:37 +03:00
|
|
|
URL* mURL;
|
2004-03-09 06:57:51 +03:00
|
|
|
Image* mImage;
|
2009-08-01 19:53:40 +04:00
|
|
|
nsCSSValueGradient* mGradient;
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSValuePair_heap* mPair;
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSRect_heap* mRect;
|
2011-08-03 07:04:23 +04:00
|
|
|
nsCSSValueTriplet_heap* mTriplet;
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSValueList_heap* mList;
|
|
|
|
nsCSSValueList* mListDependent;
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSValuePairList_heap* mPairList;
|
|
|
|
nsCSSValuePairList* mPairListDependent;
|
2012-01-03 06:19:14 +04:00
|
|
|
} mValue;
|
1998-10-08 05:29:29 +04:00
|
|
|
};
|
|
|
|
|
2009-02-05 08:15:52 +03:00
|
|
|
struct nsCSSValue::Array {
|
|
|
|
|
|
|
|
// return |Array| with reference count of zero
|
2010-06-25 01:53:44 +04:00
|
|
|
static Array* Create(size_t aItemCount) {
|
2009-02-05 08:15:52 +03:00
|
|
|
return new (aItemCount) Array(aItemCount);
|
|
|
|
}
|
|
|
|
|
2010-06-25 01:53:44 +04:00
|
|
|
nsCSSValue& operator[](size_t aIndex) {
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
|
2009-02-05 08:15:52 +03:00
|
|
|
return mArray[aIndex];
|
|
|
|
}
|
|
|
|
|
2010-06-25 01:53:44 +04:00
|
|
|
const nsCSSValue& operator[](size_t aIndex) const {
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(aIndex < mCount, "out of range");
|
2009-02-05 08:15:52 +03:00
|
|
|
return mArray[aIndex];
|
|
|
|
}
|
|
|
|
|
2010-06-25 01:53:44 +04:00
|
|
|
nsCSSValue& Item(size_t aIndex) { return (*this)[aIndex]; }
|
|
|
|
const nsCSSValue& Item(size_t aIndex) const { return (*this)[aIndex]; }
|
2009-02-05 08:15:52 +03:00
|
|
|
|
2010-06-25 01:53:44 +04:00
|
|
|
size_t Count() const { return mCount; }
|
2009-02-05 08:15:52 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const Array& aOther) const
|
2009-02-05 08:15:52 +03:00
|
|
|
{
|
|
|
|
if (mCount != aOther.mCount)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-25 01:53:44 +04:00
|
|
|
for (size_t i = 0; i < mCount; ++i)
|
2009-02-05 08:15:52 +03:00
|
|
|
if ((*this)[i] != aOther[i])
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
|
|
|
return true;
|
2009-02-05 08:15:52 +03:00
|
|
|
}
|
|
|
|
|
2010-06-26 22:58:06 +04: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-05 08:15:52 +03:00
|
|
|
void AddRef() {
|
2010-06-25 01:53:44 +04:00
|
|
|
if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
|
2009-02-05 08:15:52 +03:00
|
|
|
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++mRefCnt;
|
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
|
|
|
|
}
|
|
|
|
void Release() {
|
2010-06-25 01:53:44 +04:00
|
|
|
if (mRefCnt == size_t(-1)) { // really want SIZE_MAX
|
2009-02-05 08:15:52 +03: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-25 01:53:44 +04:00
|
|
|
size_t mRefCnt;
|
|
|
|
const size_t mCount;
|
2009-02-05 08:15:52 +03: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-25 01:53:44 +04:00
|
|
|
void* operator new(size_t aSelfSize, size_t aItemCount) CPP_THROW_NEW {
|
2009-02-05 08:15:52 +03: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)
|
|
|
|
|
2010-06-25 01:53:44 +04:00
|
|
|
Array(size_t aItemCount)
|
2009-02-05 08:15:52 +03: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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2009-02-05 08:15:52 +03:00
|
|
|
#undef CSSVALUE_LIST_FOR_EXTRA_VALUES
|
|
|
|
|
|
|
|
private:
|
2011-12-16 23:42:07 +04:00
|
|
|
Array(const Array& aOther) MOZ_DELETE;
|
|
|
|
Array& operator=(const Array& aOther) MOZ_DELETE;
|
2009-02-05 08:15:52 +03:00
|
|
|
};
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
// Prefer nsCSSValue::Array for lists of fixed size.
|
|
|
|
struct nsCSSValueList {
|
|
|
|
nsCSSValueList() : mNext(nsnull) { MOZ_COUNT_CTOR(nsCSSValueList); }
|
|
|
|
~nsCSSValueList();
|
|
|
|
|
|
|
|
nsCSSValueList* Clone() const; // makes a deep copy
|
2011-07-23 02:28:07 +04:00
|
|
|
void CloneInto(nsCSSValueList* aList) const; // makes a deep copy into aList
|
2010-08-19 23:33:43 +04:00
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
|
|
|
bool operator==(nsCSSValueList const& aOther) const;
|
|
|
|
bool operator!=(const nsCSSValueList& aOther) const
|
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
nsCSSValue mValue;
|
|
|
|
nsCSSValueList* mNext;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCSSValueList(const nsCSSValueList& aCopy) // makes a shallow copy
|
|
|
|
: mValue(aCopy.mValue), mNext(nsnull)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueList);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-19 23:33:44 +04: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.
|
|
|
|
struct nsCSSValueList_heap : public nsCSSValueList {
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueList_heap)
|
2012-01-03 06:19:14 +04:00
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2010-08-19 23:33:44 +04: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 23:33:43 +04:00
|
|
|
struct nsCSSRect {
|
|
|
|
nsCSSRect(void);
|
|
|
|
nsCSSRect(const nsCSSRect& aCopy);
|
|
|
|
~nsCSSRect();
|
|
|
|
|
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSRect& aOther) const {
|
2010-08-19 23:33:43 +04:00
|
|
|
return mTop == aOther.mTop &&
|
|
|
|
mRight == aOther.mRight &&
|
|
|
|
mBottom == aOther.mBottom &&
|
|
|
|
mLeft == aOther.mLeft;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSRect& aOther) const {
|
2010-08-19 23:33:43 +04:00
|
|
|
return mTop != aOther.mTop ||
|
|
|
|
mRight != aOther.mRight ||
|
|
|
|
mBottom != aOther.mBottom ||
|
|
|
|
mLeft != aOther.mLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAllSidesTo(const nsCSSValue& aValue);
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
mTop.Reset();
|
|
|
|
mRight.Reset();
|
|
|
|
mBottom.Reset();
|
|
|
|
mLeft.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasValue() const {
|
2010-08-19 23:33:43 +04: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 23:33:44 +04: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.
|
|
|
|
struct nsCSSRect_heap : public nsCSSRect {
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap)
|
2012-01-03 06:19:14 +04:00
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2010-08-19 23:33:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// This has to be here so that the relationship between nsCSSRect
|
|
|
|
// and nsCSSRect_heap is visible.
|
|
|
|
inline nsCSSRect&
|
|
|
|
nsCSSValue::GetRectValue()
|
|
|
|
{
|
2011-12-23 03:34:45 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
|
2010-08-19 23:33:44 +04:00
|
|
|
return *mValue.mRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSRect&
|
|
|
|
nsCSSValue::GetRectValue() const
|
|
|
|
{
|
2011-12-23 03:34:45 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Rect, "not a rect value");
|
2010-08-19 23:33:44 +04:00
|
|
|
return *mValue.mRect;
|
|
|
|
}
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
struct nsCSSValuePair {
|
|
|
|
nsCSSValuePair()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePair);
|
|
|
|
}
|
|
|
|
nsCSSValuePair(nsCSSUnit aUnit)
|
|
|
|
: 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-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSValuePair& aOther) const {
|
2010-08-19 23:33:43 +04:00
|
|
|
return mXValue == aOther.mXValue &&
|
|
|
|
mYValue == aOther.mYValue;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSValuePair& aOther) const {
|
2010-08-19 23:33:43 +04:00
|
|
|
return mXValue != aOther.mXValue ||
|
|
|
|
mYValue != aOther.mYValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBothValuesTo(const nsCSSValue& aValue) {
|
|
|
|
mXValue = aValue;
|
|
|
|
mYValue = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
mXValue.Reset();
|
|
|
|
mYValue.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasValue() const {
|
2010-08-19 23:33:43 +04:00
|
|
|
return mXValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mYValue.GetUnit() != eCSSUnit_Null;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
nsCSSValue mXValue;
|
|
|
|
nsCSSValue mYValue;
|
|
|
|
};
|
|
|
|
|
2010-08-19 23:33:44 +04: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.
|
|
|
|
struct nsCSSValuePair_heap : public nsCSSValuePair {
|
2012-01-03 06:19:14 +04:00
|
|
|
// forward constructor
|
|
|
|
nsCSSValuePair_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue)
|
|
|
|
: nsCSSValuePair(aXValue, aYValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValuePair_heap)
|
2011-08-03 07:04:23 +04:00
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2011-08-03 07:04:23 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsCSSValueTriplet {
|
|
|
|
nsCSSValueTriplet()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValueTriplet);
|
|
|
|
}
|
|
|
|
nsCSSValueTriplet(nsCSSUnit aUnit)
|
|
|
|
: 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-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSValueTriplet& aOther) const {
|
2011-08-03 07:04:23 +04:00
|
|
|
return mXValue == aOther.mXValue &&
|
|
|
|
mYValue == aOther.mYValue &&
|
|
|
|
mZValue == aOther.mZValue;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSValueTriplet& aOther) const {
|
2011-08-03 07:04:23 +04:00
|
|
|
return mXValue != aOther.mXValue ||
|
|
|
|
mYValue != aOther.mYValue ||
|
|
|
|
mZValue != aOther.mZValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAllValuesTo(const nsCSSValue& aValue) {
|
|
|
|
mXValue = aValue;
|
|
|
|
mYValue = aValue;
|
|
|
|
mZValue = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
mXValue.Reset();
|
|
|
|
mYValue.Reset();
|
|
|
|
mZValue.Reset();
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasValue() const {
|
2011-08-03 07:04:23 +04:00
|
|
|
return mXValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mYValue.GetUnit() != eCSSUnit_Null ||
|
|
|
|
mZValue.GetUnit() != eCSSUnit_Null;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
|
|
|
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.
|
|
|
|
struct nsCSSValueTriplet_heap : public nsCSSValueTriplet {
|
2010-08-19 23:33:44 +04:00
|
|
|
// forward constructor
|
2011-08-03 07:04:23 +04:00
|
|
|
nsCSSValueTriplet_heap(const nsCSSValue& aXValue, const nsCSSValue& aYValue, const nsCSSValue& aZValue)
|
|
|
|
: nsCSSValueTriplet(aXValue, aYValue, aZValue)
|
2010-08-19 23:33:44 +04:00
|
|
|
{}
|
|
|
|
|
2011-08-03 07:04:23 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap)
|
2012-01-03 06:19:14 +04:00
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2010-08-19 23:33:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// This has to be here so that the relationship between nsCSSValuePair
|
|
|
|
// and nsCSSValuePair_heap is visible.
|
|
|
|
inline nsCSSValuePair&
|
|
|
|
nsCSSValue::GetPairValue()
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
|
2010-08-19 23:33:44 +04:00
|
|
|
return *mValue.mPair;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const nsCSSValuePair&
|
|
|
|
nsCSSValue::GetPairValue() const
|
|
|
|
{
|
2010-08-19 23:33:44 +04:00
|
|
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Pair, "not a pair value");
|
2010-08-19 23:33:44 +04:00
|
|
|
return *mValue.mPair;
|
|
|
|
}
|
|
|
|
|
2011-08-03 07:04:23 +04: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 23:33:43 +04:00
|
|
|
// Maybe should be replaced with nsCSSValueList and nsCSSValue::Array?
|
|
|
|
struct nsCSSValuePairList {
|
|
|
|
nsCSSValuePairList() : mNext(nsnull) { MOZ_COUNT_CTOR(nsCSSValuePairList); }
|
|
|
|
~nsCSSValuePairList();
|
|
|
|
|
|
|
|
nsCSSValuePairList* Clone() const; // makes a deep copy
|
|
|
|
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
|
|
|
|
|
|
|
bool operator==(const nsCSSValuePairList& aOther) const;
|
|
|
|
bool operator!=(const nsCSSValuePairList& aOther) const
|
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
nsCSSValue mXValue;
|
|
|
|
nsCSSValue mYValue;
|
|
|
|
nsCSSValuePairList* mNext;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCSSValuePairList(const nsCSSValuePairList& aCopy) // makes a shallow copy
|
|
|
|
: mXValue(aCopy.mXValue), mYValue(aCopy.mYValue), mNext(nsnull)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsCSSValuePairList);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-19 23:33:44 +04: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.
|
|
|
|
struct nsCSSValuePairList_heap : public nsCSSValuePairList {
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValuePairList_heap)
|
2012-01-03 06:19:14 +04:00
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2010-08-19 23:33:44 +04: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 23:33:43 +04:00
|
|
|
struct nsCSSValueGradientStop {
|
|
|
|
public:
|
|
|
|
nsCSSValueGradientStop();
|
2011-05-29 02:38:48 +04:00
|
|
|
// needed to keep bloat logs happy when we use the TArray
|
|
|
|
// in nsCSSValueGradient
|
2010-08-19 23:33:43 +04:00
|
|
|
nsCSSValueGradientStop(const nsCSSValueGradientStop& aOther);
|
|
|
|
~nsCSSValueGradientStop();
|
|
|
|
|
|
|
|
nsCSSValue mLocation;
|
|
|
|
nsCSSValue mColor;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSValueGradientStop& aOther) const
|
2010-08-19 23:33:43 +04:00
|
|
|
{
|
|
|
|
return (mLocation == aOther.mLocation &&
|
|
|
|
mColor == aOther.mColor);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSValueGradientStop& aOther) const
|
2010-08-19 23:33:43 +04:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2012-01-03 06:19:14 +04:00
|
|
|
|
|
|
|
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2010-08-19 23:33:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsCSSValueGradient {
|
2011-09-29 10:19:26 +04:00
|
|
|
nsCSSValueGradient(bool aIsRadial, bool aIsRepeating);
|
2010-08-19 23:33:43 +04:00
|
|
|
|
|
|
|
// true if gradient is radial, false if it is linear
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsRadial;
|
|
|
|
bool mIsRepeating;
|
2011-10-22 23:41:11 +04:00
|
|
|
bool mIsToCorner;
|
2010-08-19 23:33:43 +04:00
|
|
|
// line position and angle
|
|
|
|
nsCSSValuePair mBgPos;
|
|
|
|
nsCSSValue mAngle;
|
|
|
|
|
|
|
|
// Only meaningful if mIsRadial is true
|
|
|
|
nsCSSValue mRadialShape;
|
|
|
|
nsCSSValue mRadialSize;
|
|
|
|
|
2011-05-29 02:38:48 +04:00
|
|
|
InfallibleTArray<nsCSSValueGradientStop> mStops;
|
2010-08-19 23:33:43 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSValueGradient& aOther) const
|
2010-08-19 23:33:43 +04:00
|
|
|
{
|
|
|
|
if (mIsRadial != aOther.mIsRadial ||
|
|
|
|
mIsRepeating != aOther.mIsRepeating ||
|
2011-10-22 23:41:11 +04:00
|
|
|
mIsToCorner != aOther.mIsToCorner ||
|
2010-08-19 23:33:43 +04:00
|
|
|
mBgPos != aOther.mBgPos ||
|
|
|
|
mAngle != aOther.mAngle ||
|
|
|
|
mRadialShape != aOther.mRadialShape ||
|
|
|
|
mRadialSize != aOther.mRadialSize)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-19 23:33:43 +04:00
|
|
|
|
|
|
|
if (mStops.Length() != aOther.mStops.Length())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-19 23:33:43 +04:00
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < mStops.Length(); i++) {
|
|
|
|
if (mStops[i] != aOther.mStops[i])
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-19 23:33:43 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-08-19 23:33:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSValueGradient& aOther) const
|
2010-08-19 23:33:43 +04:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient)
|
|
|
|
|
2012-01-03 06:19:14 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2010-08-19 23:33:43 +04:00
|
|
|
private:
|
2011-12-16 23:42:07 +04:00
|
|
|
nsCSSValueGradient(const nsCSSValueGradient& aOther) MOZ_DELETE;
|
|
|
|
nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther) MOZ_DELETE;
|
2010-08-19 23:33:43 +04:00
|
|
|
};
|
|
|
|
|
2011-03-29 03:07:26 +04:00
|
|
|
struct nsCSSCornerSizes {
|
|
|
|
nsCSSCornerSizes(void);
|
|
|
|
nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
|
|
|
|
~nsCSSCornerSizes();
|
|
|
|
|
|
|
|
// argument is a "full corner" constant from nsStyleConsts.h
|
|
|
|
nsCSSValue const & GetCorner(PRUint32 aCorner) const {
|
|
|
|
return this->*corners[aCorner];
|
|
|
|
}
|
|
|
|
nsCSSValue & GetCorner(PRUint32 aCorner) {
|
|
|
|
return this->*corners[aCorner];
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsCSSCornerSizes& aOther) const {
|
2011-03-29 03:07:26 +04:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner) != aOther.GetCorner(corner))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator!=(const nsCSSCornerSizes& aOther) const {
|
2011-03-29 03:07:26 +04:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner) != aOther.GetCorner(corner))
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasValue() const {
|
2011-03-29 03:07:26 +04:00
|
|
|
NS_FOR_CSS_FULL_CORNERS(corner) {
|
|
|
|
if (this->GetCorner(corner).GetUnit() != eCSSUnit_Null)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-03-29 03:07:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
nsCSSValue mTopLeft;
|
|
|
|
nsCSSValue mTopRight;
|
|
|
|
nsCSSValue mBottomRight;
|
|
|
|
nsCSSValue mBottomLeft;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef nsCSSValue nsCSSCornerSizes::*corner_type;
|
|
|
|
static const corner_type corners[4];
|
|
|
|
};
|
|
|
|
|
1998-10-08 05:29:29 +04:00
|
|
|
#endif /* nsCSSValue_h___ */
|
|
|
|
|