dom/smil/nsSMILKeySpline.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial