dom/smil/nsSMILValue.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef NS_SMILVALUE_H_
     7 #define NS_SMILVALUE_H_
     9 #include "nsISMILType.h"
    10 #include "nsSMILNullType.h"
    12 /**
    13  * Although objects of this type are generally only created on the stack and
    14  * only exist during the taking of a new time sample, that's not always the
    15  * case. The nsSMILValue objects obtained from attributes' base values are
    16  * cached so that the SMIL engine can make certain optimizations during a
    17  * sample if the base value has not changed since the last sample (potentially
    18  * avoiding recomposing). These nsSMILValue objects typically live much longer
    19  * than a single sample.
    20  */
    21 class nsSMILValue
    22 {
    23 public:
    24   nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
    25   explicit nsSMILValue(const nsISMILType* aType);
    26   nsSMILValue(const nsSMILValue& aVal);
    28   ~nsSMILValue()
    29   {
    30     mType->Destroy(*this);
    31   }
    33   const nsSMILValue& operator=(const nsSMILValue& aVal);
    35   // Equality operators. These are allowed to be conservative (return false
    36   // more than you'd expect) - see comment above nsISMILType::IsEqual.
    37   bool operator==(const nsSMILValue& aVal) const;
    38   bool operator!=(const nsSMILValue& aVal) const {
    39     return !(*this == aVal);
    40   }
    42   bool IsNull() const
    43   {
    44     return (mType == nsSMILNullType::Singleton());
    45   }
    47   // Swaps the member data (mU & mPtr) of |this| with |aOther|
    48   void     Swap(nsSMILValue& aOther);
    50   nsresult Add(const nsSMILValue& aValueToAdd, uint32_t aCount = 1);
    51   nsresult SandwichAdd(const nsSMILValue& aValueToAdd);
    52   nsresult ComputeDistance(const nsSMILValue& aTo, double& aDistance) const;
    53   nsresult Interpolate(const nsSMILValue& aEndVal,
    54                        double aUnitDistance,
    55                        nsSMILValue& aResult) const;
    57   union {
    58     bool mBool;
    59     uint64_t mUint;
    60     int64_t mInt;
    61     double mDouble;
    62     struct {
    63       float mAngle;
    64       uint16_t mUnit;
    65       uint16_t mOrientType;
    66     } mOrient;
    67     int32_t mIntPair[2];
    68     float mNumberPair[2];
    69     void* mPtr;
    70   } mU;
    71   const nsISMILType* mType;
    73 protected:
    74   void InitAndCheckPostcondition(const nsISMILType* aNewType);
    75   void DestroyAndCheckPostcondition();
    76   void DestroyAndReinit(const nsISMILType* aNewType);
    77 };
    79 #endif  // NS_SMILVALUE_H_

mercurial