2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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-03 01:37:25 +04:00
|
|
|
|
|
|
|
/* representation of a value for a SMIL-animated CSS property */
|
|
|
|
|
|
|
|
#ifndef NS_SMILCSSVALUETYPE_H_
|
|
|
|
#define NS_SMILCSSVALUETYPE_H_
|
|
|
|
|
2009-12-10 20:26:28 +03:00
|
|
|
#include "nsISMILType.h"
|
2016-08-17 04:37:48 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2012-07-06 22:15:45 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-10-03 01:37:25 +04:00
|
|
|
|
2011-03-28 20:49:11 +04:00
|
|
|
namespace mozilla {
|
2017-04-26 07:00:12 +03:00
|
|
|
struct AnimationValue;
|
2011-03-28 20:49:11 +04:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-10-03 01:37:25 +04:00
|
|
|
/*
|
2009-12-10 20:26:28 +03:00
|
|
|
* nsSMILCSSValueType: Represents a SMIL-animated CSS value.
|
2009-10-03 01:37:25 +04:00
|
|
|
*/
|
2009-12-10 20:26:28 +03:00
|
|
|
class nsSMILCSSValueType : public nsISMILType
|
2009-10-03 01:37:25 +04:00
|
|
|
{
|
|
|
|
public:
|
2011-03-28 20:49:11 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
2017-04-26 07:00:12 +03:00
|
|
|
typedef mozilla::AnimationValue AnimationValue;
|
2011-03-28 20:49:11 +04:00
|
|
|
|
2010-02-02 05:46:13 +03:00
|
|
|
// Singleton for nsSMILValue objects to hold onto.
|
|
|
|
static nsSMILCSSValueType sSingleton;
|
|
|
|
|
|
|
|
protected:
|
2010-02-02 05:46:13 +03:00
|
|
|
// nsISMILType Methods
|
|
|
|
// -------------------
|
2017-06-02 09:14:52 +03:00
|
|
|
void Init(nsSMILValue& aValue) const override;
|
|
|
|
void Destroy(nsSMILValue&) const override;
|
|
|
|
nsresult Assign(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aSrc) const override;
|
|
|
|
bool IsEqual(const nsSMILValue& aLeft,
|
|
|
|
const nsSMILValue& aRight) const override;
|
|
|
|
nsresult Add(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aValueToAdd,
|
|
|
|
uint32_t aCount) const override;
|
2017-06-02 09:18:47 +03:00
|
|
|
nsresult SandwichAdd(nsSMILValue& aDest,
|
|
|
|
const nsSMILValue& aValueToAdd) const override;
|
2017-06-02 09:14:52 +03:00
|
|
|
nsresult ComputeDistance(const nsSMILValue& aFrom,
|
|
|
|
const nsSMILValue& aTo,
|
|
|
|
double& aDistance) const override;
|
|
|
|
nsresult Interpolate(const nsSMILValue& aStartVal,
|
|
|
|
const nsSMILValue& aEndVal,
|
|
|
|
double aUnitDistance,
|
|
|
|
nsSMILValue& aResult) const override;
|
2009-10-03 01:37:25 +04:00
|
|
|
|
2010-02-02 05:46:13 +03:00
|
|
|
public:
|
|
|
|
// Helper Methods
|
|
|
|
// --------------
|
2009-12-10 20:26:28 +03: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-02 05:46:13 +03:00
|
|
|
* On failure, this method leaves aValue.mType == nsSMILNullType::sSingleton.
|
|
|
|
* Otherwise, this method leaves aValue.mType == this class's singleton.
|
2009-12-10 20:26:28 +03: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-02 05:46:13 +03:00
|
|
|
* @param [out] aValue The nsSMILValue to be populated. Should
|
|
|
|
* initially be null-typed.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param [out] aIsContextSensitive Set to true if |aString| may produce
|
2011-08-23 03:34:03 +04:00
|
|
|
* a different |aValue| depending on other
|
|
|
|
* CSS properties on |aTargetElement|
|
|
|
|
* or its ancestors (e.g. 'inherit).
|
2012-07-30 18:20:58 +04:00
|
|
|
* false otherwise. May be nullptr.
|
2011-08-23 03:34:03 +04:00
|
|
|
* Not set if the method fails.
|
2010-02-02 05:46:13 +03:00
|
|
|
* @pre aValue.IsNull()
|
|
|
|
* @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
|
2009-12-10 20:26:28 +03:00
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
static void ValueFromString(nsCSSPropertyID aPropID,
|
2011-03-28 20:49:11 +04:00
|
|
|
Element* aTargetElement,
|
2010-04-02 20:34:31 +04:00
|
|
|
const nsAString& aString,
|
2011-08-23 03:34:03 +04:00
|
|
|
nsSMILValue& aValue,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aIsContextSensitive);
|
2009-10-03 01:37:25 +04:00
|
|
|
|
2017-03-30 10:53:15 +03:00
|
|
|
/**
|
|
|
|
* Creates an nsSMILValue to wrap the given animation value.
|
|
|
|
*
|
|
|
|
* @param aPropID The property that |aValue| corresponds to.
|
|
|
|
* @param aTargetElement The target element to which the animation value
|
|
|
|
* applies.
|
|
|
|
* @param aValue The animation value to use.
|
|
|
|
* @return A new nsSMILValue. On failure, returns an
|
|
|
|
* nsSMILValue with the null type (i.e. rv.IsNull()
|
|
|
|
* returns true).
|
|
|
|
*/
|
|
|
|
static nsSMILValue ValueFromAnimationValue(nsCSSPropertyID aPropID,
|
|
|
|
Element* aTargetElement,
|
2017-04-26 07:00:12 +03:00
|
|
|
const AnimationValue& aValue);
|
2017-03-30 10:53:15 +03:00
|
|
|
|
2009-12-10 20:26:28 +03: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
|
2017-04-26 07:00:12 +03:00
|
|
|
* freshly-initialized value the resulting string will be empty.
|
2009-12-10 20:26:28 +03:00
|
|
|
*
|
|
|
|
* @param aValue The nsSMILValue to be converted into a string.
|
|
|
|
* @param [out] aString The string to be populated with the given value.
|
|
|
|
*/
|
2017-04-26 07:00:12 +03:00
|
|
|
static void ValueToString(const nsSMILValue& aValue, nsAString& aString);
|
2009-10-03 01:37:25 +04:00
|
|
|
|
2016-04-20 03:05:29 +03:00
|
|
|
/**
|
|
|
|
* Return the CSS property animated by the specified value.
|
|
|
|
*
|
|
|
|
* @param aValue The nsSMILValue to examine.
|
2016-08-17 04:37:48 +03:00
|
|
|
* @return The nsCSSPropertyID enum value of the property animated
|
2016-04-20 03:05:29 +03:00
|
|
|
* by |aValue|, or eCSSProperty_UNKNOWN if the type of
|
|
|
|
* |aValue| is not nsSMILCSSValueType.
|
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
static nsCSSPropertyID PropertyFromValue(const nsSMILValue& aValue);
|
2016-04-20 03:05:29 +03:00
|
|
|
|
2009-10-03 01:37:25 +04:00
|
|
|
private:
|
2013-08-12 18:13:34 +04:00
|
|
|
// Private constructor: prevent instances beyond my singleton.
|
2016-07-09 00:39:53 +03:00
|
|
|
constexpr nsSMILCSSValueType() {}
|
2009-10-03 01:37:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILCSSVALUETYPE_H_
|