2009-09-10 12:03:36 -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/. */
|
2009-09-10 12:03:36 -07:00
|
|
|
|
|
|
|
/* Utilities for animation of computed style values */
|
|
|
|
|
|
|
|
#ifndef nsStyleAnimation_h_
|
|
|
|
#define nsStyleAnimation_h_
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsAString.h"
|
2009-12-10 09:26:27 -08:00
|
|
|
#include "nsCRTGlue.h"
|
|
|
|
#include "nsStringBuffer.h"
|
2009-09-10 12:03:36 -07:00
|
|
|
#include "nsCSSProperty.h"
|
2009-10-20 04:46:16 -07:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsColor.h"
|
2012-07-31 10:28:21 -07:00
|
|
|
#include "nsCSSValue.h"
|
2009-09-10 12:03:36 -07:00
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
class nsPresContext;
|
2009-09-10 12:03:36 -07:00
|
|
|
class nsStyleContext;
|
2009-12-21 13:46:25 -08:00
|
|
|
struct nsCSSRect;
|
2011-09-26 14:53:33 -07:00
|
|
|
class gfx3DMatrix;
|
2009-09-10 12:03:36 -07:00
|
|
|
|
2011-03-28 09:51:59 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-10 12:03:36 -07:00
|
|
|
/**
|
|
|
|
* Utility class to handle animated style values
|
|
|
|
*/
|
|
|
|
class nsStyleAnimation {
|
|
|
|
public:
|
2009-10-20 04:46:16 -07:00
|
|
|
class Value;
|
2009-09-10 12:03:36 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 12:03:36 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool Add(nsCSSProperty aProperty, Value& aDest,
|
2012-08-22 08:56:38 -07:00
|
|
|
const Value& aValueToAdd, uint32_t aCount) {
|
2009-11-14 19:16:58 -08:00
|
|
|
return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest);
|
2009-10-20 04:46:16 -07:00
|
|
|
}
|
2009-09-10 12:03:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates a measure of 'distance' between two values.
|
|
|
|
*
|
2009-10-21 07:17:40 -07: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 12:03:36 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 12:03:36 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ComputeDistance(nsCSSProperty aProperty,
|
2009-11-14 19:16:58 -08:00
|
|
|
const Value& aStartValue,
|
2009-10-20 04:46:16 -07:00
|
|
|
const Value& aEndValue,
|
2009-09-10 12:03:36 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 12:03:36 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool Interpolate(nsCSSProperty aProperty,
|
2009-11-14 19:16:58 -08:00
|
|
|
const Value& aStartValue,
|
2009-10-20 04:46:16 -07:00
|
|
|
const Value& aEndValue,
|
2009-09-10 12:03:36 -07:00
|
|
|
double aPortion,
|
2009-10-20 04:46:16 -07:00
|
|
|
Value& aResultValue) {
|
2009-11-14 19:16:58 -08:00
|
|
|
return AddWeighted(aProperty, 1.0 - aPortion, aStartValue,
|
|
|
|
aPortion, aEndValue, aResultValue);
|
2009-10-20 04:46:16 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-10-20 04:46:16 -07: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-28 23:19:26 -07:00
|
|
|
static bool AddWeighted(nsCSSProperty aProperty,
|
2009-11-14 19:16:58 -08:00
|
|
|
double aCoeff1, const Value& aValue1,
|
2009-10-20 04:46:16 -07:00
|
|
|
double aCoeff2, const Value& aValue2,
|
2009-10-20 04:46:16 -07:00
|
|
|
Value& aResultValue);
|
2009-09-10 12:03:36 -07:00
|
|
|
|
|
|
|
// Type-conversion methods
|
|
|
|
// -----------------------
|
|
|
|
/**
|
2009-10-20 04:46:16 -07:00
|
|
|
* Creates a computed value for the given specified value
|
2009-09-10 12:03:36 -07: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.
|
2012-07-31 10:28:21 -07:00
|
|
|
*
|
2009-09-10 12:03:36 -07:00
|
|
|
* @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 09:34:31 -07:00
|
|
|
* @param aUseSVGMode A flag to indicate whether we should parse
|
|
|
|
* |aSpecifiedValue| in SVG mode.
|
2009-09-10 12:03:36 -07:00
|
|
|
* @param [out] aComputedValue The resulting computed value.
|
2011-08-22 16:34:12 -07:00
|
|
|
* @param [out] aIsContextSensitive
|
2011-10-17 07:59:28 -07:00
|
|
|
* Set to true if |aSpecifiedValue| may produce
|
2011-08-22 16:34:12 -07:00
|
|
|
* a different |aComputedValue| depending on other CSS
|
|
|
|
* properties on |aTargetElement| or its ancestors.
|
2011-10-17 07:59:28 -07:00
|
|
|
* false otherwise.
|
2011-08-22 16:34:12 -07:00
|
|
|
* Note that the operation of this method is
|
|
|
|
* significantly faster when |aIsContextSensitive| is
|
2012-07-30 07:20:58 -07:00
|
|
|
* nullptr.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 12:03:36 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ComputeValue(nsCSSProperty aProperty,
|
2011-08-22 16:34:12 -07:00
|
|
|
mozilla::dom::Element* aTargetElement,
|
2009-09-10 12:03:36 -07:00
|
|
|
const nsAString& aSpecifiedValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseSVGMode,
|
2011-08-22 16:34:12 -07:00
|
|
|
Value& aComputedValue,
|
2012-07-30 07:20:58 -07:00
|
|
|
bool* aIsContextSensitive = nullptr);
|
2009-09-10 12:03:36 -07:00
|
|
|
|
2009-09-11 09:29:23 -07:00
|
|
|
/**
|
2009-10-20 04:46:16 -07:00
|
|
|
* Creates a specified value for the given computed value.
|
2009-09-11 09:29:23 -07:00
|
|
|
*
|
2010-08-19 12:33:44 -07: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-07 20:22:42 -07:00
|
|
|
*
|
2009-09-11 09:29:23 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-11 09:29:23 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool UncomputeValue(nsCSSProperty aProperty,
|
2009-10-07 20:22:42 -07:00
|
|
|
nsPresContext* aPresContext,
|
2009-10-20 04:46:16 -07:00
|
|
|
const Value& aComputedValue,
|
2010-08-19 12:33:44 -07:00
|
|
|
nsCSSValue& aSpecifiedValue);
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool UncomputeValue(nsCSSProperty aProperty,
|
2009-09-11 09:29:23 -07:00
|
|
|
nsPresContext* aPresContext,
|
2009-10-20 04:46:16 -07:00
|
|
|
const Value& aComputedValue,
|
2009-09-11 09:29:23 -07:00
|
|
|
nsAString& aSpecifiedValue);
|
|
|
|
|
2009-09-10 12:03:36 -07: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 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-09-10 12:03:36 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ExtractComputedValue(nsCSSProperty aProperty,
|
2009-09-10 12:03:36 -07:00
|
|
|
nsStyleContext* aStyleContext,
|
2009-10-20 04:46:16 -07:00
|
|
|
Value& aComputedValue);
|
|
|
|
|
2011-07-22 15:28:07 -07: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 14:53:33 -07:00
|
|
|
* @param aProgress Interpolation value in the range [0.0, 1.0]
|
2011-07-22 15:28:07 -07:00
|
|
|
*/
|
2011-09-26 14:53:33 -07:00
|
|
|
static gfx3DMatrix InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1,
|
2012-07-31 10:28:21 -07:00
|
|
|
const gfx3DMatrix &aMatrix2,
|
2011-09-26 14:53:33 -07:00
|
|
|
double aProgress);
|
2011-07-22 15:28:07 -07:00
|
|
|
|
2012-07-31 10:28:21 -07:00
|
|
|
static already_AddRefed<nsCSSValue::Array>
|
|
|
|
AppendTransformFunction(nsCSSKeyword aTransformFunction,
|
|
|
|
nsCSSValueList**& aListTail);
|
|
|
|
|
2009-10-20 04:46:16 -07: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 14:57:57 -07:00
|
|
|
eUnit_Enumerated,
|
2009-12-21 13:46:25 -08:00
|
|
|
eUnit_Visibility, // special case for transitions (which converts
|
|
|
|
// Enumerated to Visibility as needed)
|
2009-11-12 17:40:05 -08:00
|
|
|
eUnit_Integer,
|
2009-10-20 04:46:16 -07:00
|
|
|
eUnit_Coord,
|
|
|
|
eUnit_Percent,
|
|
|
|
eUnit_Float,
|
2009-10-21 03:53:46 -07:00
|
|
|
eUnit_Color,
|
2010-09-15 08:11:26 -07:00
|
|
|
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
|
|
|
// calc() expression that's either length or length+percent
|
2009-10-28 20:22:27 -07:00
|
|
|
eUnit_CSSValuePair, // nsCSSValuePair* (never null)
|
2011-08-02 20:04:23 -07:00
|
|
|
eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null)
|
2009-12-21 13:46:25 -08:00
|
|
|
eUnit_CSSRect, // nsCSSRect* (never null)
|
2009-10-21 07:17:40 -07:00
|
|
|
eUnit_Dasharray, // nsCSSValueList* (never null)
|
2009-12-10 09:26:27 -08:00
|
|
|
eUnit_Shadow, // nsCSSValueList* (may be null)
|
2010-07-02 21:18:56 -07:00
|
|
|
eUnit_Transform, // nsCSSValueList* (never null)
|
2012-02-19 16:14:42 -08:00
|
|
|
eUnit_BackgroundPosition, // nsCSSValueList* (never null)
|
2009-12-21 13:46:25 -08:00
|
|
|
eUnit_CSSValuePairList, // nsCSSValuePairList* (never null)
|
2009-12-10 09:26:27 -08:00
|
|
|
eUnit_UnparsedString // nsStringBuffer* (never null)
|
2009-10-20 04:46:16 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class Value {
|
|
|
|
private:
|
|
|
|
Unit mUnit;
|
|
|
|
union {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mInt;
|
2009-10-20 04:46:16 -07:00
|
|
|
nscoord mCoord;
|
|
|
|
float mFloat;
|
|
|
|
nscolor mColor;
|
2010-09-15 08:11:26 -07:00
|
|
|
nsCSSValue* mCSSValue;
|
2009-10-28 20:22:27 -07:00
|
|
|
nsCSSValuePair* mCSSValuePair;
|
2011-08-02 20:04:23 -07:00
|
|
|
nsCSSValueTriplet* mCSSValueTriplet;
|
2009-12-21 13:46:25 -08:00
|
|
|
nsCSSRect* mCSSRect;
|
2009-10-21 03:53:46 -07:00
|
|
|
nsCSSValueList* mCSSValueList;
|
2009-12-21 13:46:25 -08:00
|
|
|
nsCSSValuePairList* mCSSValuePairList;
|
2009-12-10 09:26:27 -08:00
|
|
|
nsStringBuffer* mString;
|
2009-10-20 04:46:16 -07: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-28 23:19:26 -07:00
|
|
|
bool IsNull() const {
|
2009-10-20 04:46:16 -07:00
|
|
|
return mUnit == eUnit_Null;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetIntValue() const {
|
2009-11-12 17:40:05 -08:00
|
|
|
NS_ASSERTION(IsIntUnit(mUnit), "unit mismatch");
|
2009-10-21 14:57:57 -07:00
|
|
|
return mValue.mInt;
|
|
|
|
}
|
2009-10-20 04:46:16 -07: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 08:11:26 -07:00
|
|
|
nsCSSValue* GetCSSValueValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValue;
|
|
|
|
}
|
2009-10-28 20:22:27 -07:00
|
|
|
nsCSSValuePair* GetCSSValuePairValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValuePairUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValuePair;
|
|
|
|
}
|
2011-08-02 20:04:23 -07:00
|
|
|
nsCSSValueTriplet* GetCSSValueTripletValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueTripletUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValueTriplet;
|
|
|
|
}
|
2009-12-21 13:46:25 -08:00
|
|
|
nsCSSRect* GetCSSRectValue() const {
|
|
|
|
NS_ASSERTION(IsCSSRectUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSRect;
|
|
|
|
}
|
2009-10-21 03:53:46 -07:00
|
|
|
nsCSSValueList* GetCSSValueListValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValueListUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValueList;
|
|
|
|
}
|
2009-12-21 13:46:25 -08:00
|
|
|
nsCSSValuePairList* GetCSSValuePairListValue() const {
|
|
|
|
NS_ASSERTION(IsCSSValuePairListUnit(mUnit), "unit mismatch");
|
|
|
|
return mValue.mCSSValuePairList;
|
|
|
|
}
|
2009-12-10 09:26:27 -08: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();
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t len = NS_strlen(GetBufferValue(mValue.mString));
|
2009-12-10 09:26:27 -08:00
|
|
|
mValue.mString->ToString(len, aBuffer);
|
|
|
|
}
|
2009-10-20 04:46:16 -07: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-12 17:40:05 -08:00
|
|
|
enum IntegerConstructorType { IntegerConstructor };
|
2012-08-22 08:56:38 -07:00
|
|
|
Value(int32_t aInt, Unit aUnit, IntegerConstructorType);
|
2009-10-20 04:46:16 -07: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();
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetIntValue(int32_t aInt, Unit aUnit);
|
2009-10-20 04:46:16 -07:00
|
|
|
void SetCoordValue(nscoord aCoord);
|
|
|
|
void SetPercentValue(float aPercent);
|
|
|
|
void SetFloatValue(float aFloat);
|
|
|
|
void SetColorValue(nscolor aColor);
|
2009-12-10 09:26:27 -08:00
|
|
|
void SetUnparsedStringValue(const nsString& aString);
|
|
|
|
|
2009-10-28 20:22:27 -07:00
|
|
|
// These setters take ownership of |aValue|, and are therefore named
|
|
|
|
// "SetAndAdopt*".
|
2010-09-15 08:11:26 -07:00
|
|
|
void SetAndAdoptCSSValueValue(nsCSSValue *aValue, Unit aUnit);
|
2009-10-28 20:22:27 -07:00
|
|
|
void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit);
|
2011-08-02 20:04:23 -07:00
|
|
|
void SetAndAdoptCSSValueTripletValue(nsCSSValueTriplet *aValue, Unit aUnit);
|
2009-12-21 13:46:25 -08:00
|
|
|
void SetAndAdoptCSSRectValue(nsCSSRect *aValue, Unit aUnit);
|
2009-12-21 13:46:25 -08:00
|
|
|
void SetAndAdoptCSSValueListValue(nsCSSValueList *aValue, Unit aUnit);
|
|
|
|
void SetAndAdoptCSSValuePairListValue(nsCSSValuePairList *aValue);
|
2009-10-20 04:46:16 -07:00
|
|
|
|
|
|
|
Value& operator=(const Value& aOther);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const Value& aOther) const;
|
|
|
|
bool operator!=(const Value& aOther) const
|
2009-10-20 04:46:16 -07:00
|
|
|
{ return !(*this == aOther); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void FreeValue();
|
2009-10-21 03:53:46 -07:00
|
|
|
|
2009-12-10 09:26:27 -08:00
|
|
|
static const PRUnichar* GetBufferValue(nsStringBuffer* aBuffer) {
|
|
|
|
return static_cast<PRUnichar*>(aBuffer->Data());
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsIntUnit(Unit aUnit) {
|
2009-12-21 13:46:25 -08:00
|
|
|
return aUnit == eUnit_Enumerated || aUnit == eUnit_Visibility ||
|
|
|
|
aUnit == eUnit_Integer;
|
2009-11-12 17:40:05 -08:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSValueUnit(Unit aUnit) {
|
2010-09-15 08:11:26 -07:00
|
|
|
return aUnit == eUnit_Calc;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSValuePairUnit(Unit aUnit) {
|
2009-10-28 20:22:27 -07:00
|
|
|
return aUnit == eUnit_CSSValuePair;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSValueTripletUnit(Unit aUnit) {
|
2011-08-02 20:04:23 -07:00
|
|
|
return aUnit == eUnit_CSSValueTriplet;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSRectUnit(Unit aUnit) {
|
2009-12-21 13:46:25 -08:00
|
|
|
return aUnit == eUnit_CSSRect;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSValueListUnit(Unit aUnit) {
|
2010-07-02 21:18:56 -07:00
|
|
|
return aUnit == eUnit_Dasharray || aUnit == eUnit_Shadow ||
|
2012-02-19 16:14:42 -08:00
|
|
|
aUnit == eUnit_Transform || aUnit == eUnit_BackgroundPosition;
|
2009-10-21 03:53:46 -07:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCSSValuePairListUnit(Unit aUnit) {
|
2009-12-21 13:46:25 -08:00
|
|
|
return aUnit == eUnit_CSSValuePairList;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsStringUnit(Unit aUnit) {
|
2009-12-10 09:26:27 -08:00
|
|
|
return aUnit == eUnit_UnparsedString;
|
|
|
|
}
|
2009-10-20 04:46:16 -07:00
|
|
|
};
|
2009-09-10 12:03:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|