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.
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_SMILKEYSPLINE_H_
7 #define NS_SMILKEYSPLINE_H_
9 /**
10 * Utility class to provide scaling defined in a keySplines element.
11 */
12 class nsSMILKeySpline
13 {
14 public:
15 nsSMILKeySpline() { /* caller must call Init later */ }
17 /**
18 * Creates a new key spline control point description.
19 *
20 * aX1, etc. are the x1, y1, x2, y2 cubic Bezier control points as defined by
21 * SMILANIM 3.2.3. They must each be in the range 0.0 <= x <= 1.0
22 */
23 nsSMILKeySpline(double aX1, double aY1,
24 double aX2, double aY2)
25 {
26 Init(aX1, aY1, aX2, aY2);
27 }
29 double X1() const { return mX1; }
30 double Y1() const { return mY1; }
31 double X2() const { return mX2; }
32 double Y2() const { return mY2; }
34 void Init(double aX1, double aY1,
35 double aX2, double aY2);
37 /**
38 * Gets the output (y) value for an input (x).
39 *
40 * @param aX The input x value. A floating-point number between 0 and
41 * 1 (inclusive).
42 */
43 double GetSplineValue(double aX) const;
45 void GetSplineDerivativeValues(double aX, double& aDX, double& aDY) const;
47 private:
48 void
49 CalcSampleValues();
51 /**
52 * Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
53 */
54 static double
55 CalcBezier(double aT, double aA1, double aA2);
57 /**
58 * Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
59 */
60 static double
61 GetSlope(double aT, double aA1, double aA2);
63 double
64 GetTForX(double aX) const;
66 double
67 NewtonRaphsonIterate(double aX, double aGuessT) const;
69 double
70 BinarySubdivide(double aX, double aA, double aB) const;
72 static double
73 A(double aA1, double aA2)
74 {
75 return 1.0 - 3.0 * aA2 + 3.0 * aA1;
76 }
78 static double
79 B(double aA1, double aA2)
80 {
81 return 3.0 * aA2 - 6.0 * aA1;
82 }
84 static double
85 C(double aA1)
86 {
87 return 3.0 * aA1;
88 }
90 double mX1;
91 double mY1;
92 double mX2;
93 double mY2;
95 enum { kSplineTableSize = 11 };
96 double mSampleValues[kSplineTableSize];
98 static const double kSampleStepSize;
99 };
101 #endif // NS_SMILKEYSPLINE_H_