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-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
#ifndef NS_SMILVALUE_H_
|
|
|
|
#define NS_SMILVALUE_H_
|
|
|
|
|
|
|
|
#include "nsISMILType.h"
|
|
|
|
#include "nsSMILNullType.h"
|
|
|
|
|
2010-07-17 01:42:12 +04:00
|
|
|
/**
|
|
|
|
* Although objects of this type are generally only created on the stack and
|
|
|
|
* only exist during the taking of a new time sample, that's not always the
|
|
|
|
* case. The nsSMILValue objects obtained from attributes' base values are
|
|
|
|
* cached so that the SMIL engine can make certain optimizations during a
|
|
|
|
* sample if the base value has not changed since the last sample (potentially
|
|
|
|
* avoiding recomposing). These nsSMILValue objects typically live much longer
|
|
|
|
* than a single sample.
|
|
|
|
*/
|
2009-01-15 07:38:07 +03:00
|
|
|
class nsSMILValue
|
|
|
|
{
|
|
|
|
public:
|
2013-05-31 02:34:53 +04:00
|
|
|
nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
|
2010-02-11 22:40:50 +03:00
|
|
|
explicit nsSMILValue(const nsISMILType* aType);
|
2009-01-15 07:38:07 +03:00
|
|
|
nsSMILValue(const nsSMILValue& aVal);
|
|
|
|
|
|
|
|
~nsSMILValue()
|
|
|
|
{
|
|
|
|
mType->Destroy(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsSMILValue& operator=(const nsSMILValue& aVal);
|
|
|
|
|
2015-05-29 23:10:39 +03:00
|
|
|
// Move constructor / reassignment operator:
|
|
|
|
nsSMILValue(nsSMILValue&& aVal);
|
|
|
|
nsSMILValue& operator=(nsSMILValue&& aVal);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Equality operators. These are allowed to be conservative (return false
|
2010-02-21 00:13:11 +03:00
|
|
|
// more than you'd expect) - see comment above nsISMILType::IsEqual.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool operator==(const nsSMILValue& aVal) const;
|
|
|
|
bool operator!=(const nsSMILValue& aVal) const {
|
2010-02-21 00:13:11 +03:00
|
|
|
return !(*this == aVal);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsNull() const
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2013-05-31 02:34:53 +04:00
|
|
|
return (mType == nsSMILNullType::Singleton());
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult Add(const nsSMILValue& aValueToAdd, uint32_t aCount = 1);
|
2009-01-19 12:14:16 +03:00
|
|
|
nsresult SandwichAdd(const nsSMILValue& aValueToAdd);
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult ComputeDistance(const nsSMILValue& aTo, double& aDistance) const;
|
|
|
|
nsresult Interpolate(const nsSMILValue& aEndVal,
|
|
|
|
double aUnitDistance,
|
|
|
|
nsSMILValue& aResult) const;
|
|
|
|
|
|
|
|
union {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mBool;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mUint;
|
|
|
|
int64_t mInt;
|
2009-01-15 07:38:07 +03:00
|
|
|
double mDouble;
|
2010-02-19 00:50:59 +03:00
|
|
|
struct {
|
|
|
|
float mAngle;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mUnit;
|
|
|
|
uint16_t mOrientType;
|
2010-02-19 00:50:59 +03:00
|
|
|
} mOrient;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mIntPair[2];
|
2011-07-01 11:19:52 +04:00
|
|
|
float mNumberPair[2];
|
2009-01-15 07:38:07 +03:00
|
|
|
void* mPtr;
|
|
|
|
} mU;
|
|
|
|
const nsISMILType* mType;
|
2010-01-29 23:18:50 +03:00
|
|
|
|
|
|
|
protected:
|
2010-03-22 21:57:36 +03:00
|
|
|
void InitAndCheckPostcondition(const nsISMILType* aNewType);
|
|
|
|
void DestroyAndCheckPostcondition();
|
|
|
|
void DestroyAndReinit(const nsISMILType* aNewType);
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILVALUE_H_
|