2009-10-02 14:37:25 -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-10-02 14:37:25 -07:00
|
|
|
|
|
|
|
/* representation of a value for a SMIL-animated CSS property */
|
|
|
|
|
|
|
|
#ifndef NS_SMILCSSVALUETYPE_H_
|
|
|
|
#define NS_SMILCSSVALUETYPE_H_
|
|
|
|
|
2009-12-10 09:26:28 -08:00
|
|
|
#include "nsISMILType.h"
|
|
|
|
#include "nsCSSProperty.h"
|
2012-07-06 11:15:45 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-10-02 14:37:25 -07:00
|
|
|
|
2009-12-10 09:26:28 -08:00
|
|
|
class nsAString;
|
2009-10-02 14:37:25 -07:00
|
|
|
|
2011-03-28 09:49:11 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-10-02 14:37:25 -07:00
|
|
|
/*
|
2009-12-10 09:26:28 -08:00
|
|
|
* nsSMILCSSValueType: Represents a SMIL-animated CSS value.
|
2009-10-02 14:37:25 -07:00
|
|
|
*/
|
2009-12-10 09:26:28 -08:00
|
|
|
class nsSMILCSSValueType : public nsISMILType
|
2009-10-02 14:37:25 -07:00
|
|
|
{
|
|
|
|
public:
|
2011-03-28 09:49:11 -07:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2010-02-01 18:46:13 -08:00
|
|
|
// Singleton for nsSMILValue objects to hold onto.
|
|
|
|
static nsSMILCSSValueType sSingleton;
|
|
|
|
|
|
|
|
protected:
|
2010-02-01 18:46:13 -08:00
|
|
|
// nsISMILType Methods
|
|
|
|
// -------------------
|
2012-07-06 11:15:45 -07:00
|
|
|
virtual void Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
|
|
|
|
virtual void Destroy(nsSMILValue&) const MOZ_OVERRIDE;
|
|
|
|
virtual nsresult Assign(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aSrc) const MOZ_OVERRIDE;
|
|
|
|
virtual bool IsEqual(const nsSMILValue& aLeft,
|
|
|
|
const nsSMILValue& aRight) const MOZ_OVERRIDE;
|
|
|
|
virtual nsresult Add(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aValueToAdd,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aCount) const MOZ_OVERRIDE;
|
2012-07-06 11:15:45 -07:00
|
|
|
virtual nsresult ComputeDistance(const nsSMILValue& aFrom,
|
|
|
|
const nsSMILValue& aTo,
|
|
|
|
double& aDistance) const MOZ_OVERRIDE;
|
|
|
|
virtual nsresult Interpolate(const nsSMILValue& aStartVal,
|
|
|
|
const nsSMILValue& aEndVal,
|
|
|
|
double aUnitDistance,
|
|
|
|
nsSMILValue& aResult) const MOZ_OVERRIDE;
|
2009-10-02 14:37:25 -07:00
|
|
|
|
2010-02-01 18:46:13 -08:00
|
|
|
public:
|
|
|
|
// Helper Methods
|
|
|
|
// --------------
|
2009-12-10 09:26:28 -08:00
|
|
|
/**
|
|
|
|
* Sets up the given nsSMILValue to represent the given string value. The
|
|
|
|
* string is interpreted as a value for the given property on the given
|
|
|
|
* element.
|
|
|
|
*
|
2010-02-01 18:46:13 -08:00
|
|
|
* On failure, this method leaves aValue.mType == nsSMILNullType::sSingleton.
|
|
|
|
* Otherwise, this method leaves aValue.mType == this class's singleton.
|
2009-12-10 09:26:28 -08:00
|
|
|
*
|
|
|
|
* @param aPropID The property for which we're parsing a value.
|
|
|
|
* @param aTargetElement The target element to whom the property/value
|
|
|
|
* setting applies.
|
|
|
|
* @param aString The string to be parsed as a CSS value.
|
2010-02-01 18:46:13 -08:00
|
|
|
* @param [out] aValue The nsSMILValue to be populated. Should
|
|
|
|
* initially be null-typed.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param [out] aIsContextSensitive Set to true if |aString| may produce
|
2011-08-22 16:34:03 -07:00
|
|
|
* a different |aValue| depending on other
|
|
|
|
* CSS properties on |aTargetElement|
|
|
|
|
* or its ancestors (e.g. 'inherit).
|
2012-07-30 07:20:58 -07:00
|
|
|
* false otherwise. May be nullptr.
|
2011-08-22 16:34:03 -07:00
|
|
|
* Not set if the method fails.
|
2010-02-01 18:46:13 -08:00
|
|
|
* @pre aValue.IsNull()
|
|
|
|
* @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
|
2009-12-10 09:26:28 -08:00
|
|
|
*/
|
2010-02-01 18:46:13 -08:00
|
|
|
static void ValueFromString(nsCSSProperty aPropID,
|
2011-03-28 09:49:11 -07:00
|
|
|
Element* aTargetElement,
|
2010-04-02 09:34:31 -07:00
|
|
|
const nsAString& aString,
|
2011-08-22 16:34:03 -07:00
|
|
|
nsSMILValue& aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aIsContextSensitive);
|
2009-10-02 14:37:25 -07:00
|
|
|
|
2009-12-10 09:26:28 -08:00
|
|
|
/**
|
|
|
|
* Creates a string representation of the given nsSMILValue.
|
|
|
|
*
|
|
|
|
* Note: aValue is expected to be of this type (that is, it's expected to
|
|
|
|
* have been initialized by nsSMILCSSValueType::sSingleton). If aValue is a
|
|
|
|
* freshly-initialized value, this method will succeed, though the resulting
|
|
|
|
* string will be empty.
|
|
|
|
*
|
|
|
|
* @param aValue The nsSMILValue to be converted into a string.
|
|
|
|
* @param [out] aString The string to be populated with the given value.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true on success, false on failure.
|
2009-12-10 09:26:28 -08:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ValueToString(const nsSMILValue& aValue, nsAString& aString);
|
2009-10-02 14:37:25 -07:00
|
|
|
|
|
|
|
private:
|
2013-08-12 07:13:34 -07:00
|
|
|
// Private constructor: prevent instances beyond my singleton.
|
|
|
|
MOZ_CONSTEXPR nsSMILCSSValueType() {}
|
2009-10-02 14:37:25 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILCSSVALUETYPE_H_
|