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
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SMIL_SMILVALUE_H_
|
|
|
|
#define DOM_SMIL_SMILVALUE_H_
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-09 03:34:14 +03:00
|
|
|
#include "mozilla/SMILNullType.h"
|
|
|
|
#include "mozilla/SMILType.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
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
|
2019-01-23 16:48:08 +03:00
|
|
|
* case. The SMILValue objects obtained from attributes' base values are
|
2010-07-17 01:42:12 +04:00
|
|
|
* 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
|
2019-01-23 16:48:08 +03:00
|
|
|
* avoiding recomposing). These SMILValue objects typically live much longer
|
2010-07-17 01:42:12 +04:00
|
|
|
* than a single sample.
|
|
|
|
*/
|
2019-01-23 16:48:08 +03:00
|
|
|
class SMILValue {
|
2009-01-15 07:38:07 +03:00
|
|
|
public:
|
2019-01-23 16:48:08 +03:00
|
|
|
SMILValue() : mU(), mType(SMILNullType::Singleton()) {}
|
|
|
|
explicit SMILValue(const SMILType* aType);
|
|
|
|
SMILValue(const SMILValue& aVal);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
~SMILValue() { mType->Destroy(*this); }
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
const SMILValue& operator=(const SMILValue& aVal);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2015-05-29 23:10:39 +03:00
|
|
|
// Move constructor / reassignment operator:
|
2019-04-24 23:39:47 +03:00
|
|
|
SMILValue(SMILValue&& aVal) noexcept;
|
|
|
|
SMILValue& operator=(SMILValue&& aVal) noexcept;
|
2015-05-29 23:10:39 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Equality operators. These are allowed to be conservative (return false
|
2018-12-28 13:34:35 +03:00
|
|
|
// more than you'd expect) - see comment above SMILType::IsEqual.
|
2019-01-23 16:48:08 +03:00
|
|
|
bool operator==(const SMILValue& aVal) const;
|
|
|
|
bool operator!=(const SMILValue& aVal) const { return !(*this == aVal); }
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2018-12-27 13:21:40 +03:00
|
|
|
bool IsNull() const { return (mType == SMILNullType::Singleton()); }
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
nsresult Add(const SMILValue& aValueToAdd, uint32_t aCount = 1);
|
|
|
|
nsresult SandwichAdd(const SMILValue& aValueToAdd);
|
|
|
|
nsresult ComputeDistance(const SMILValue& aTo, double& aDistance) const;
|
|
|
|
nsresult Interpolate(const SMILValue& aEndVal, double aUnitDistance,
|
|
|
|
SMILValue& aResult) const;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
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;
|
2018-12-28 13:34:35 +03:00
|
|
|
const SMILType* mType;
|
2010-01-29 23:18:50 +03:00
|
|
|
|
|
|
|
protected:
|
2018-12-28 13:34:35 +03:00
|
|
|
void InitAndCheckPostcondition(const SMILType* aNewType);
|
2010-03-22 21:57:36 +03:00
|
|
|
void DestroyAndCheckPostcondition();
|
2018-12-28 13:34:35 +03:00
|
|
|
void DestroyAndReinit(const SMILType* aNewType);
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SMIL_SMILVALUE_H_
|