dom/smil/nsSMILCSSValueType.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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 /* representation of a value for a SMIL-animated CSS property */
michael@0 7
michael@0 8 #ifndef NS_SMILCSSVALUETYPE_H_
michael@0 9 #define NS_SMILCSSVALUETYPE_H_
michael@0 10
michael@0 11 #include "nsISMILType.h"
michael@0 12 #include "nsCSSProperty.h"
michael@0 13 #include "mozilla/Attributes.h"
michael@0 14
michael@0 15 class nsAString;
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace dom {
michael@0 19 class Element;
michael@0 20 } // namespace dom
michael@0 21 } // namespace mozilla
michael@0 22
michael@0 23 /*
michael@0 24 * nsSMILCSSValueType: Represents a SMIL-animated CSS value.
michael@0 25 */
michael@0 26 class nsSMILCSSValueType : public nsISMILType
michael@0 27 {
michael@0 28 public:
michael@0 29 typedef mozilla::dom::Element Element;
michael@0 30
michael@0 31 // Singleton for nsSMILValue objects to hold onto.
michael@0 32 static nsSMILCSSValueType sSingleton;
michael@0 33
michael@0 34 protected:
michael@0 35 // nsISMILType Methods
michael@0 36 // -------------------
michael@0 37 virtual void Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
michael@0 38 virtual void Destroy(nsSMILValue&) const MOZ_OVERRIDE;
michael@0 39 virtual nsresult Assign(nsSMILValue& aDest,
michael@0 40 const nsSMILValue& aSrc) const MOZ_OVERRIDE;
michael@0 41 virtual bool IsEqual(const nsSMILValue& aLeft,
michael@0 42 const nsSMILValue& aRight) const MOZ_OVERRIDE;
michael@0 43 virtual nsresult Add(nsSMILValue& aDest,
michael@0 44 const nsSMILValue& aValueToAdd,
michael@0 45 uint32_t aCount) const MOZ_OVERRIDE;
michael@0 46 virtual nsresult ComputeDistance(const nsSMILValue& aFrom,
michael@0 47 const nsSMILValue& aTo,
michael@0 48 double& aDistance) const MOZ_OVERRIDE;
michael@0 49 virtual nsresult Interpolate(const nsSMILValue& aStartVal,
michael@0 50 const nsSMILValue& aEndVal,
michael@0 51 double aUnitDistance,
michael@0 52 nsSMILValue& aResult) const MOZ_OVERRIDE;
michael@0 53
michael@0 54 public:
michael@0 55 // Helper Methods
michael@0 56 // --------------
michael@0 57 /**
michael@0 58 * Sets up the given nsSMILValue to represent the given string value. The
michael@0 59 * string is interpreted as a value for the given property on the given
michael@0 60 * element.
michael@0 61 *
michael@0 62 * On failure, this method leaves aValue.mType == nsSMILNullType::sSingleton.
michael@0 63 * Otherwise, this method leaves aValue.mType == this class's singleton.
michael@0 64 *
michael@0 65 * @param aPropID The property for which we're parsing a value.
michael@0 66 * @param aTargetElement The target element to whom the property/value
michael@0 67 * setting applies.
michael@0 68 * @param aString The string to be parsed as a CSS value.
michael@0 69 * @param [out] aValue The nsSMILValue to be populated. Should
michael@0 70 * initially be null-typed.
michael@0 71 * @param [out] aIsContextSensitive Set to true if |aString| may produce
michael@0 72 * a different |aValue| depending on other
michael@0 73 * CSS properties on |aTargetElement|
michael@0 74 * or its ancestors (e.g. 'inherit).
michael@0 75 * false otherwise. May be nullptr.
michael@0 76 * Not set if the method fails.
michael@0 77 * @pre aValue.IsNull()
michael@0 78 * @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
michael@0 79 */
michael@0 80 static void ValueFromString(nsCSSProperty aPropID,
michael@0 81 Element* aTargetElement,
michael@0 82 const nsAString& aString,
michael@0 83 nsSMILValue& aValue,
michael@0 84 bool* aIsContextSensitive);
michael@0 85
michael@0 86 /**
michael@0 87 * Creates a string representation of the given nsSMILValue.
michael@0 88 *
michael@0 89 * Note: aValue is expected to be of this type (that is, it's expected to
michael@0 90 * have been initialized by nsSMILCSSValueType::sSingleton). If aValue is a
michael@0 91 * freshly-initialized value, this method will succeed, though the resulting
michael@0 92 * string will be empty.
michael@0 93 *
michael@0 94 * @param aValue The nsSMILValue to be converted into a string.
michael@0 95 * @param [out] aString The string to be populated with the given value.
michael@0 96 * @return true on success, false on failure.
michael@0 97 */
michael@0 98 static bool ValueToString(const nsSMILValue& aValue, nsAString& aString);
michael@0 99
michael@0 100 private:
michael@0 101 // Private constructor: prevent instances beyond my singleton.
michael@0 102 MOZ_CONSTEXPR nsSMILCSSValueType() {}
michael@0 103 };
michael@0 104
michael@0 105 #endif // NS_SMILCSSVALUETYPE_H_

mercurial