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