2009-09-10 19:03:36 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2009-09-10 19:03:36 +00:00
|
|
|
|
|
|
|
/* Utilities for animation of computed style values */
|
|
|
|
|
|
|
|
#ifndef nsStyleAnimation_h_
|
|
|
|
#define nsStyleAnimation_h_
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsAString.h"
|
2009-12-10 17:26:27 +00:00
|
|
|
#include "nsCRTGlue.h"
|
|
|
|
#include "nsStringBuffer.h"
|
2009-09-10 19:03:36 +00:00
|
|
|
#include "nsCSSProperty.h"
|
2009-10-20 11:46:16 +00:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsColor.h"
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
class nsPresContext;
|
2009-09-10 19:03:36 +00:00
|
|
|
class nsStyleContext;
|
2010-08-19 19:33:44 +00:00
|
|
|
class nsCSSValue;
|
2009-10-21 10:53:46 +00:00
|
|
|
struct nsCSSValueList;
|
2009-10-29 03:22:27 +00:00
|
|
|
struct nsCSSValuePair;
|
2011-08-03 03:04:23 +00:00
|
|
|
struct nsCSSValueTriplet;
|
2009-12-21 21:46:25 +00:00
|
|
|
struct nsCSSValuePairList;
|
2009-12-21 21:46:25 +00:00
|
|
|
struct nsCSSRect;
|
2011-09-26 21:53:33 +00:00
|
|
|
class gfx3DMatrix;
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2011-03-28 16:51:59 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-10 19:03:36 +00:00
|
|
|
/**
|
|
|
|
* Utility class to handle animated style values
|
|
|
|
*/
|
|
|
|
class nsStyleAnimation {
|
|
|
|
public:
|
2009-10-20 11:46:16 +00:00
|
|
|
class Value;
|
2009-09-10 19:03:36 +00:00
|
|
|
|
|
|
|
// Mathematical methods
|
|
|
|
// --------------------
|
|
|
|
/**
|
|
|
|
* Adds |aCount| copies of |aValueToAdd| to |aDest|. The result of this
|
|
|
|
* addition is stored in aDest.
|
|
|
|
*
|
|
|
|
* Note that if |aCount| is 0, then |aDest| will be unchanged. Also, if
|
|
|
|
* this method fails, then |aDest| will be unchanged.
|
|
|
|
*
|
|
|
|
* @param aDest The value to add to.
|
|
|
|
* @param aValueToAdd The value to add.
|
|
|
|
* @param aCount The number of times to add aValueToAdd.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 19:03:36 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool Add(nsCSSProperty aProperty, Value& aDest,
|
2009-11-15 03:16:58 +00:00
|
|
|
const Value& aValueToAdd, PRUint32 aCount) {
|
|
|
|
return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest);
|
2009-10-20 11:46:16 +00:00
|
|
|
}
|
2009-09-10 19:03:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates a measure of 'distance' between two values.
|
|
|
|
*
|
2009-10-21 14:17:40 +00:00
|
|
|
* This measure of Distance is guaranteed to be proportional to
|
|
|
|
* portions passed to Interpolate, Add, or AddWeighted. However, for
|
|
|
|
* some types of Value it may not produce sensible results for paced
|
|
|
|
* animation.
|
|
|
|
*
|
2009-09-10 19:03:36 +00:00
|
|
|
* If this method succeeds, the returned distance value is guaranteed to be
|
|
|
|
* non-negative.
|
|
|
|
*
|
|
|
|
* @param aStartValue The start of the interval for which the distance
|
|
|
|
* should be calculated.
|
|
|
|
* @param aEndValue The end of the interval for which the distance
|
|
|
|
* should be calculated.
|
|
|
|
* @param aDistance The result of the calculation.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 19:03:36 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ComputeDistance(nsCSSProperty aProperty,
|
2009-11-15 03:16:58 +00:00
|
|
|
const Value& aStartValue,
|
2009-10-20 11:46:16 +00:00
|
|
|
const Value& aEndValue,
|
2009-09-10 19:03:36 +00:00
|
|
|
double& aDistance);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates an interpolated value that is the specified |aPortion| between
|
|
|
|
* the two given values.
|
|
|
|
*
|
|
|
|
* This really just does the following calculation:
|
|
|
|
* aResultValue = (1.0 - aPortion) * aStartValue + aPortion * aEndValue
|
|
|
|
*
|
|
|
|
* @param aStartValue The value defining the start of the interval of
|
|
|
|
* interpolation.
|
|
|
|
* @param aEndValue The value defining the end of the interval of
|
|
|
|
* interpolation.
|
|
|
|
* @param aPortion A number in the range [0.0, 1.0] defining the
|
|
|
|
* distance of the interpolated value in the interval.
|
|
|
|
* @param [out] aResultValue The resulting interpolated value.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 19:03:36 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool Interpolate(nsCSSProperty aProperty,
|
2009-11-15 03:16:58 +00:00
|
|
|
const Value& aStartValue,
|
2009-10-20 11:46:16 +00:00
|
|
|
const Value& aEndValue,
|
2009-09-10 19:03:36 +00:00
|
|
|
double aPortion,
|
2009-10-20 11:46:16 +00:00
|
|
|
Value& aResultValue) {
|
2009-11-15 03:16:58 +00:00
|
|
|
return AddWeighted(aProperty, 1.0 - aPortion, aStartValue,
|
|
|
|
aPortion, aEndValue, aResultValue);
|
2009-10-20 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does the calculation:
|
|
|
|
* aResultValue = aCoeff1 * aValue1 + aCoeff2 * aValue2
|
|
|
|
*
|
|
|
|
* @param [out] aResultValue The resulting interpolated value. May be
|
|
|
|
* the same as aValue1 or aValue2.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-10-20 11:46:16 +00:00
|
|
|
*
|
|
|
|
* NOTE: Current callers always pass aCoeff1 and aCoeff2 >= 0. They
|
|
|
|
* are currently permitted to be negative; however, if, as we add
|
|
|
|
* support more value types types, we find that this causes
|
|
|
|
* difficulty, we might change this to restrict them to being
|
|
|
|
* positive.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool AddWeighted(nsCSSProperty aProperty,
|
2009-11-15 03:16:58 +00:00
|
|
|
double aCoeff1, const Value& aValue1,
|
2009-10-20 11:46:16 +00:00
|
|
|
double aCoeff2, const Value& aValue2,
|
2009-10-20 11:46:16 +00:00
|
|
|
Value& aResultValue);
|
2009-09-10 19:03:36 +00:00
|
|
|
|
|
|
|
// Type-conversion methods
|
|
|
|
// -----------------------
|
|
|
|
/**
|
2009-10-20 11:46:16 +00:00
|
|
|
* Creates a computed value for the given specified value
|
2009-09-10 19:03:36 +00:00
|
|
|
* (property ID + string). A style context is needed in case the
|
|
|
|
* specified value depends on inherited style or on the values of other
|
|
|
|
* properties.
|
|
|
|
*
|
|
|
|
* @param aProperty The property whose value we're computing.
|
|
|
|
* @param aTargetElement The content node to which our computed value is
|
|
|
|
* applicable.
|
|
|
|
* @param aSpecifiedValue The specified value, from which we'll build our
|
|
|
|
* computed value.
|
2010-04-02 16:34:31 +00:00
|
|
|
* @param aUseSVGMode A flag to indicate whether we should parse
|
|
|
|
* |aSpecifiedValue| in SVG mode.
|
2009-09-10 19:03:36 +00:00
|
|
|
* @param [out] aComputedValue The resulting computed value.
|
2011-08-22 23:34:12 +00:00
|
|
|
* @param [out] aIsContextSensitive
|
2011-10-17 14:59:28 +00:00
|
|
|
* Set to true if |aSpecifiedValue| may produce
|
2011-08-22 23:34:12 +00:00
|
|
|
* a different |aComputedValue| depending on other CSS
|
|
|
|
* properties on |aTargetElement| or its ancestors.
|
2011-10-17 14:59:28 +00:00
|
|
|
* false otherwise.
|
2011-08-22 23:34:12 +00:00
|
|
|
* Note that the operation of this method is
|
|
|
|
* significantly faster when |aIsContextSensitive| is
|
|
|
|
* nsnull.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 19:03:36 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ComputeValue(nsCSSProperty aProperty,
|
2011-08-22 23:34:12 +00:00
|
|
|
mozilla::dom::Element* aTargetElement,
|
2009-09-10 19:03:36 +00:00
|
|
|
const nsAString& aSpecifiedValue,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aUseSVGMode,
|
2011-08-22 23:34:12 +00:00
|
|
|
Value& aComputedValue,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aIsContextSensitive = nsnull);
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2009-09-11 16:29:23 +00:00
|
|
|
/**
|
2009-10-20 11:46:16 +00:00
|
|
|
* Creates a specified value for the given computed value.
|
2009-09-11 16:29:23 +00:00
|
|
|
*
|
2010-08-19 19:33:44 +00:00
|
|
|
* The first overload fills in an nsCSSValue object; the second
|
|
|
|
* produces a string. The nsCSSValue result may depend on objects
|
|
|
|
* owned by the |aComputedValue| object, so users of that variant
|
|
|
|
* must keep |aComputedValue| alive longer than |aSpecifiedValue|.
|
2009-10-08 03:22:42 +00:00
|
|
|
*
|
2009-09-11 16:29:23 +00:00
|
|
|
* @param aProperty The property whose value we're uncomputing.
|
|
|
|
* @param aPresContext The presentation context for the document in
|
|
|
|
* which we're working.
|
|
|
|
* @param aComputedValue The computed value to be converted.
|
|
|
|
* @param [out] aSpecifiedValue The resulting specified value.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-11 16:29:23 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool UncomputeValue(nsCSSProperty aProperty,
|
2009-10-08 03:22:42 +00:00
|
|
|
nsPresContext* aPresContext,
|
2009-10-20 11:46:16 +00:00
|
|
|
const Value& aComputedValue,
|
2010-08-19 19:33:44 +00:00
|
|
|
nsCSSValue& aSpecifiedValue);
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool UncomputeValue(nsCSSProperty aProperty,
|
2009-09-11 16:29:23 +00:00
|
|
|
nsPresContext* aPresContext,
|
2009-10-20 11:46:16 +00:00
|
|
|
const Value& aComputedValue,
|
2009-09-11 16:29:23 +00:00
|
|
|
nsAString& aSpecifiedValue);
|
|
|
|
|
2009-09-10 19:03:36 +00:00
|
|
|
/**
|
|
|
|
* Gets the computed value for the given property from the given style
|
|
|
|
* context.
|
|
|
|
*
|
|
|
|
* @param aProperty The property whose value we're looking up.
|
|
|
|
* @param aStyleContext The style context to check for the computed value.
|
|
|
|
* @param [out] aComputedValue The resulting computed value.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 19:03:36 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ExtractComputedValue(nsCSSProperty aProperty,
|
2009-09-10 19:03:36 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
2009-10-20 11:46:16 +00:00
|
|
|
Value& aComputedValue);
|
|
|
|
|
2011-07-22 22:28:07 +00:00
|
|
|
/**
|
|
|
|
* Interpolates between 2 matrices by decomposing them.
|
|
|
|
*
|
|
|
|
* @param aMatrix1 First matrix, using CSS pixel units.
|
|
|
|
* @param aMatrix2 Second matrix, using CSS pixel units.
|
2011-09-26 21:53:33 +00:00
|
|
|
* @param aProgress Interpolation value in the range [0.0, 1.0]
|
2011-07-22 22:28:07 +00:00
|
|
|
*/
|
2011-09-26 21:53:33 +00:00
|
|
|
static gfx3DMatrix InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1,
|
|
|
|
const gfx3DMatrix &aMatrix2,
|
|
|
|
double aProgress);
|
2011-07-22 22:28:07 +00:00
|
|
|
|
2009-10-20 11:46:16 +00:00
|
|
|
/**
|
|
|
|
* The types and values for the values that we extract and animate.
|
|
|
|
*/
|
|
|
|
enum Unit {
|
|
|
|
eUnit_Null, // not initialized
|
|
|
|
eUnit_Normal,
|
|
|
|
eUnit_Auto,
|
|
|
|
eUnit_None,
|
2009-10-21 21:57:57 +00:00
|
|
|
eUnit_Enumerated,
|
2009-12-21 21:46:25 +00:00
|
|
|
eUnit_Visibility, // special case for transitions (which converts
|
|
|
|
// Enumerated to Visibility as needed)
|
2009-11-13 01:40:05 +00:00
|
|
|
eUnit_Integer,
|
2009-10-20 11:46:16 +00:00
|
|
|
eUnit_Coord,
|
|
|
|
eUnit_Percent,
|
|
|
|
eUnit_Float,
|
2009-10-21 10:53:46 +00:00
|
|
|
eUnit_Color,
|
2010-09-15 15:11:26 +00:00
|
|
|
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
|
|
|
// calc() expression that's either length or length+percent
|
2009-10-29 03:22:27 +00:00
|
|
|
eUnit_CSSValuePair, // nsCSSValuePair* (never null)
|
2011-08-03 03:04:23 +00:00
|
|
|
eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null)
|
2009-12-21 21:46:25 +00:00
|
|
|
eUnit_CSSRect, // nsCSSRect* (never null)
|
2009-10-21 14:17:40 +00:00
|
|
|
eUnit_Dasharray, // nsCSSValueList* (never null)
|
2009-12-10 17:26:27 +00:00
|
|
|
eUnit_Shadow, // nsCSSValueList* (may be null)
|
2010-07-03 04:18:56 +00:00
|
|
|
eUnit_Transform, // nsCSSValueList* (never null)
|
2012-02-20 00:14:42 +00:00
|
|
|
eUnit_BackgroundPosition, // nsCSSValueList* (never null)
|
2009-12-21 21:46:25 +00:00
|
|
|
eUnit_CSSValuePairList, // nsCSSValuePairList* (never null)
|
2009-12-10 17:26:27 +00:00
|
|
|
eUnit_UnparsedString // nsStringBuffer* (never null)
|
2009-10-20 11:46:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Value {
|
|
|
|
private:
|
|
|
|
Unit mUnit;
|
|
|
|
union {
|
2009-10-21 21:57:57 +00:00
|
|
|
PRInt32 mInt;
|
2009-10-20 11:46:16 +00:00
|
|
|
nscoord mCoord;
|
|
|
|
float mFloat;
|
|
|
|
nscolor mColor;
|
2010-09-15 15:11:26 +00:00
|
|
|
nsCSSValue* mCSSValue;
|
2009-10-29 03:22:27 +00:00
|
|
|
nsCSSValuePair* mCSSValuePair;
|
2011-08-03 03:04:23 +00:00
|
|
|
nsCSSValueTriplet* mCSSValueTriplet;
|
2009-12-21 21:46:25 +00:00
|
|
|
nsCSSRect* mCSSRect;
|
2009-10-21 10:53:46 +00:00
|
|
|
nsCSSValueList* mCSSValueList;
|
2009-12-21 21:46:25 +00:00
|
|
|
nsCSSValuePairList* mCSSValuePairList;
|
2009-12-10 17:26:27 +00:00
|
|
|
nsStringBuffer* mString;
|
2009-10-20 11:46:16 +00:00
|
|
|
} mValue;
|
|
|
|
public:
|
|
|
|
Unit GetUnit() const {
|
|
|
|
NS_ASSERTION(mUnit != eUnit_Null, "uninitialized");
|
|
|
|
return mUnit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Accessor to let us verify assumptions about presence of null unit,
|
|
|
|
// without tripping the assertion in GetUnit().
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsNull() const {
|
2009-10-20 11:46:16 +00:00
|
|
|
return mUnit == eUnit_Null;
|
|
|
|
}
|
|
|
|
|
2009-10-21 21:57:57 +00:00
|
|
|
PRInt32 GetIntValue() const {
|
2009-11-13 01:40:05 +00:00
|
|
|
NS_ASSERTION(IsIntUnit(mUnit), "unit mismatch");
|
2009-10-21 21:57:57 +00:00
|
|
|
return mValue.mInt;
|
|
|
|
}
|
2009-10-20 11:46:16 +00:00
|
|
|
nscoord GetCoordValue() const {
|
|
|
|
NS_ASSERTION(mUnit == eUnit_Coord, "unit mismatch");
|
|
|
|
return mValue.mCoord;
|
|
|
|
}
|
|
|
|
float GetPercentValue() const {
|
|
|
|
NS_ASSERTION(mUnit == eUnit_Percent, "unit mismatch");
|
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
float GetFloatValue() const {
|
|
|
|
NS_ASSERTION(mUnit == eUnit_Float, "unit mismatch");
|
|
|
|
return mValue.mFloat;
|
|
|
|
}
|
|
|
|
nscolor GetColorValue() const {
|
|
|
|
NS_ASSERTION(mUnit == eUnit_Color, "unit mismatch");
|
|
|
|
return mValue.mColor;
|
|
|
|
}
|
2010-09-15 15:11:26 +00:00
|
|
|
nsCSSValue* GetCSSValueValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValue;
|
|
|
|
}
|
2009-10-29 03:22:27 +00:00
|
|
|
nsCSSValuePair* GetCSSValuePairValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValuePairUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValuePair;
|
|
|
|
}
|
2011-08-03 03:04:23 +00:00
|
|
|
nsCSSValueTriplet* GetCSSValueTripletValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueTripletUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValueTriplet;
|
|
|
|
}
|
2009-12-21 21:46:25 +00:00
|
|
|
nsCSSRect* GetCSSRectValue() const {
|
|
|
|
NS_ASSERTION(IsCSSRectUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSRect;
|
|
|
|
}
|
2009-10-21 10:53:46 +00:00
|
|
|
nsCSSValueList* GetCSSValueListValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueListUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValueList;
|
|
|
|
}
|
2009-12-21 21:46:25 +00:00
|
|
|
nsCSSValuePairList* GetCSSValuePairListValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValuePairListUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValuePairList;
|
|
|
|
}
|
2009-12-10 17:26:27 +00:00
|
|
|
const PRUnichar* GetStringBufferValue() const {
|
|
|
|
NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch");
|
|
|
|
return GetBufferValue(mValue.mString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetStringValue(nsAString& aBuffer) const {
|
|
|
|
NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch");
|
|
|
|
aBuffer.Truncate();
|
|
|
|
PRUint32 len = NS_strlen(GetBufferValue(mValue.mString));
|
|
|
|
mValue.mString->ToString(len, aBuffer);
|
|
|
|
}
|
2009-10-20 11:46:16 +00:00
|
|
|
|
|
|
|
explicit Value(Unit aUnit = eUnit_Null) : mUnit(aUnit) {
|
|
|
|
NS_ASSERTION(aUnit == eUnit_Null || aUnit == eUnit_Normal ||
|
|
|
|
aUnit == eUnit_Auto || aUnit == eUnit_None,
|
|
|
|
"must be valueless unit");
|
|
|
|
}
|
|
|
|
Value(const Value& aOther) : mUnit(eUnit_Null) { *this = aOther; }
|
2009-11-13 01:40:05 +00:00
|
|
|
enum IntegerConstructorType { IntegerConstructor };
|
|
|
|
Value(PRInt32 aInt, Unit aUnit, IntegerConstructorType);
|
2009-10-20 11:46:16 +00:00
|
|
|
enum CoordConstructorType { CoordConstructor };
|
|
|
|
Value(nscoord aLength, CoordConstructorType);
|
|
|
|
enum PercentConstructorType { PercentConstructor };
|
|
|
|
Value(float aPercent, PercentConstructorType);
|
|
|
|
enum FloatConstructorType { FloatConstructor };
|
|
|
|
Value(float aFloat, FloatConstructorType);
|
|
|
|
enum ColorConstructorType { ColorConstructor };
|
|
|
|
Value(nscolor aColor, ColorConstructorType);
|
|
|
|
|
|
|
|
~Value() { FreeValue(); }
|
|
|
|
|
|
|
|
void SetNormalValue();
|
|
|
|
void SetAutoValue();
|
|
|
|
void SetNoneValue();
|
2009-10-21 21:57:57 +00:00
|
|
|
void SetIntValue(PRInt32 aInt, Unit aUnit);
|
2009-10-20 11:46:16 +00:00
|
|
|
void SetCoordValue(nscoord aCoord);
|
|
|
|
void SetPercentValue(float aPercent);
|
|
|
|
void SetFloatValue(float aFloat);
|
|
|
|
void SetColorValue(nscolor aColor);
|
2009-12-10 17:26:27 +00:00
|
|
|
void SetUnparsedStringValue(const nsString& aString);
|
|
|
|
|
2009-10-29 03:22:27 +00:00
|
|
|
// These setters take ownership of |aValue|, and are therefore named
|
|
|
|
// "SetAndAdopt*".
|
2010-09-15 15:11:26 +00:00
|
|
|
void SetAndAdoptCSSValueValue(nsCSSValue *aValue, Unit aUnit);
|
2009-10-29 03:22:27 +00:00
|
|
|
void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit);
|
2011-08-03 03:04:23 +00:00
|
|
|
void SetAndAdoptCSSValueTripletValue(nsCSSValueTriplet *aValue, Unit aUnit);
|
2009-12-21 21:46:25 +00:00
|
|
|
void SetAndAdoptCSSRectValue(nsCSSRect *aValue, Unit aUnit);
|
2009-12-21 21:46:25 +00:00
|
|
|
void SetAndAdoptCSSValueListValue(nsCSSValueList *aValue, Unit aUnit);
|
|
|
|
void SetAndAdoptCSSValuePairListValue(nsCSSValuePairList *aValue);
|
2009-10-20 11:46:16 +00:00
|
|
|
|
|
|
|
Value& operator=(const Value& aOther);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool operator==(const Value& aOther) const;
|
|
|
|
bool operator!=(const Value& aOther) const
|
2009-10-20 11:46:16 +00:00
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void FreeValue();
|
2009-10-21 10:53:46 +00:00
|
|
|
|
2009-12-10 17:26:27 +00:00
|
|
|
static const PRUnichar* GetBufferValue(nsStringBuffer* aBuffer) {
|
|
|
|
return static_cast<PRUnichar*>(aBuffer->Data());
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsIntUnit(Unit aUnit) {
|
2009-12-21 21:46:25 +00:00
|
|
|
return aUnit == eUnit_Enumerated || aUnit == eUnit_Visibility ||
|
|
|
|
aUnit == eUnit_Integer;
|
2009-11-13 01:40:05 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSValueUnit(Unit aUnit) {
|
2010-09-15 15:11:26 +00:00
|
|
|
return aUnit == eUnit_Calc;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSValuePairUnit(Unit aUnit) {
|
2009-10-29 03:22:27 +00:00
|
|
|
return aUnit == eUnit_CSSValuePair;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSValueTripletUnit(Unit aUnit) {
|
2011-08-03 03:04:23 +00:00
|
|
|
return aUnit == eUnit_CSSValueTriplet;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSRectUnit(Unit aUnit) {
|
2009-12-21 21:46:25 +00:00
|
|
|
return aUnit == eUnit_CSSRect;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSValueListUnit(Unit aUnit) {
|
2010-07-03 04:18:56 +00:00
|
|
|
return aUnit == eUnit_Dasharray || aUnit == eUnit_Shadow ||
|
2012-02-20 00:14:42 +00:00
|
|
|
aUnit == eUnit_Transform || aUnit == eUnit_BackgroundPosition;
|
2009-10-21 10:53:46 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsCSSValuePairListUnit(Unit aUnit) {
|
2009-12-21 21:46:25 +00:00
|
|
|
return aUnit == eUnit_CSSValuePairList;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsStringUnit(Unit aUnit) {
|
2009-12-10 17:26:27 +00:00
|
|
|
return aUnit == eUnit_UnparsedString;
|
|
|
|
}
|
2009-10-20 11:46:16 +00:00
|
|
|
};
|
2009-09-10 19:03:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|