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: 20; 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 #include "Matrix.h"
7 #include "Tools.h"
8 #include <math.h>
10 namespace mozilla {
11 namespace gfx {
13 Matrix
14 Matrix::Rotation(Float aAngle)
15 {
16 Matrix newMatrix;
18 Float s = sin(aAngle);
19 Float c = cos(aAngle);
21 newMatrix._11 = c;
22 newMatrix._12 = s;
23 newMatrix._21 = -s;
24 newMatrix._22 = c;
26 return newMatrix;
27 }
29 Rect
30 Matrix::TransformBounds(const Rect &aRect) const
31 {
32 int i;
33 Point quad[4];
34 Float min_x, max_x;
35 Float min_y, max_y;
37 quad[0] = *this * aRect.TopLeft();
38 quad[1] = *this * aRect.TopRight();
39 quad[2] = *this * aRect.BottomLeft();
40 quad[3] = *this * aRect.BottomRight();
42 min_x = max_x = quad[0].x;
43 min_y = max_y = quad[0].y;
45 for (i = 1; i < 4; i++) {
46 if (quad[i].x < min_x)
47 min_x = quad[i].x;
48 if (quad[i].x > max_x)
49 max_x = quad[i].x;
51 if (quad[i].y < min_y)
52 min_y = quad[i].y;
53 if (quad[i].y > max_y)
54 max_y = quad[i].y;
55 }
57 return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
58 }
60 void
61 Matrix::NudgeToIntegers()
62 {
63 NudgeToInteger(&_11);
64 NudgeToInteger(&_12);
65 NudgeToInteger(&_21);
66 NudgeToInteger(&_22);
67 NudgeToInteger(&_31);
68 NudgeToInteger(&_32);
69 }
71 Rect
72 Matrix4x4::TransformBounds(const Rect& aRect) const
73 {
74 Point quad[4];
75 Float min_x, max_x;
76 Float min_y, max_y;
78 quad[0] = *this * aRect.TopLeft();
79 quad[1] = *this * aRect.TopRight();
80 quad[2] = *this * aRect.BottomLeft();
81 quad[3] = *this * aRect.BottomRight();
83 min_x = max_x = quad[0].x;
84 min_y = max_y = quad[0].y;
86 for (int i = 1; i < 4; i++) {
87 if (quad[i].x < min_x) {
88 min_x = quad[i].x;
89 }
90 if (quad[i].x > max_x) {
91 max_x = quad[i].x;
92 }
94 if (quad[i].y < min_y) {
95 min_y = quad[i].y;
96 }
97 if (quad[i].y > max_y) {
98 max_y = quad[i].y;
99 }
100 }
102 return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
103 }
105 }
106 }