Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Geometry.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 * @constructor 39 * @constructor
40 * @param {number} x 40 * @param {number} x
41 * @param {number} y 41 * @param {number} y
42 * @param {number} z 42 * @param {number} z
43 */ 43 */
44 WebInspector.Geometry.Vector = function(x, y, z) 44 WebInspector.Geometry.Vector = function(x, y, z)
45 { 45 {
46 this.x = x; 46 this.x = x;
47 this.y = y; 47 this.y = y;
48 this.z = z; 48 this.z = z;
49 } 49 };
50 50
51 WebInspector.Geometry.Vector.prototype = { 51 WebInspector.Geometry.Vector.prototype = {
52 /** 52 /**
53 * @return {number} 53 * @return {number}
54 */ 54 */
55 length: function() 55 length: function()
56 { 56 {
57 return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); 57 return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
58 }, 58 },
59 59
60 normalize: function() 60 normalize: function()
61 { 61 {
62 var length = this.length(); 62 var length = this.length();
63 if (length <= WebInspector.Geometry._Eps) 63 if (length <= WebInspector.Geometry._Eps)
64 return; 64 return;
65 65
66 this.x /= length; 66 this.x /= length;
67 this.y /= length; 67 this.y /= length;
68 this.z /= length; 68 this.z /= length;
69 } 69 }
70 } 70 };
71 71
72 /** 72 /**
73 * @constructor 73 * @constructor
74 * @param {number} x 74 * @param {number} x
75 * @param {number} y 75 * @param {number} y
76 */ 76 */
77 WebInspector.Geometry.Point = function(x, y) { 77 WebInspector.Geometry.Point = function(x, y) {
78 this.x = x; 78 this.x = x;
79 this.y = y; 79 this.y = y;
80 } 80 };
81 81
82 WebInspector.Geometry.Point.prototype = { 82 WebInspector.Geometry.Point.prototype = {
83 /** 83 /**
84 * @param {!WebInspector.Geometry.Point} p 84 * @param {!WebInspector.Geometry.Point} p
85 * @return {number} 85 * @return {number}
86 */ 86 */
87 distanceTo: function(p) 87 distanceTo: function(p)
88 { 88 {
89 return Math.sqrt(Math.pow(p.x - this.x, 2) + Math.pow(p.y - this.y, 2)); 89 return Math.sqrt(Math.pow(p.x - this.x, 2) + Math.pow(p.y - this.y, 2));
90 }, 90 },
(...skipping 19 matching lines...) Expand all
110 }, 110 },
111 111
112 /** 112 /**
113 * @override 113 * @override
114 * @return {string} 114 * @return {string}
115 */ 115 */
116 toString: function() 116 toString: function()
117 { 117 {
118 return Math.round(this.x * 100) / 100 + ", " + Math.round(this.y * 100) / 100; 118 return Math.round(this.x * 100) / 100 + ", " + Math.round(this.y * 100) / 100;
119 } 119 }
120 } 120 };
121 121
122 /** 122 /**
123 * @constructor 123 * @constructor
124 * @param {!WebInspector.Geometry.Point} point1 124 * @param {!WebInspector.Geometry.Point} point1
125 * @param {!WebInspector.Geometry.Point} point2 125 * @param {!WebInspector.Geometry.Point} point2
126 */ 126 */
127 WebInspector.Geometry.CubicBezier = function(point1, point2) 127 WebInspector.Geometry.CubicBezier = function(point1, point2)
128 { 128 {
129 this.controlPoints = [point1, point2]; 129 this.controlPoints = [point1, point2];
130 } 130 };
131 131
132 /** @type {!RegExp} */ 132 /** @type {!RegExp} */
133 WebInspector.Geometry.CubicBezier.Regex = /((cubic-bezier\([^)]+\))|\b(linear|ea se-in-out|ease-in|ease-out|ease)\b)/g; 133 WebInspector.Geometry.CubicBezier.Regex = /((cubic-bezier\([^)]+\))|\b(linear|ea se-in-out|ease-in|ease-out|ease)\b)/g;
134 134
135 WebInspector.Geometry.CubicBezier.KeywordValues = { 135 WebInspector.Geometry.CubicBezier.KeywordValues = {
136 "linear": "cubic-bezier(0, 0, 1, 1)", 136 "linear": "cubic-bezier(0, 0, 1, 1)",
137 "ease": "cubic-bezier(0.25, 0.1, 0.25, 1)", 137 "ease": "cubic-bezier(0.25, 0.1, 0.25, 1)",
138 "ease-in": "cubic-bezier(0.42, 0, 1, 1)", 138 "ease-in": "cubic-bezier(0.42, 0, 1, 1)",
139 "ease-in-out": "cubic-bezier(0.42, 0, 0.58, 1)", 139 "ease-in-out": "cubic-bezier(0.42, 0, 0.58, 1)",
140 "ease-out": "cubic-bezier(0, 0, 0.58, 1)" 140 "ease-out": "cubic-bezier(0, 0, 0.58, 1)"
141 } 141 };
142 142
143 /** 143 /**
144 * @param {string} text 144 * @param {string} text
145 * @return {?WebInspector.Geometry.CubicBezier} 145 * @return {?WebInspector.Geometry.CubicBezier}
146 */ 146 */
147 WebInspector.Geometry.CubicBezier.parse = function(text) 147 WebInspector.Geometry.CubicBezier.parse = function(text)
148 { 148 {
149 var keywordValues = WebInspector.Geometry.CubicBezier.KeywordValues; 149 var keywordValues = WebInspector.Geometry.CubicBezier.KeywordValues;
150 var value = text.toLowerCase().replace(/\s+/g, ""); 150 var value = text.toLowerCase().replace(/\s+/g, "");
151 if (Object.keys(keywordValues).indexOf(value) !== -1) 151 if (Object.keys(keywordValues).indexOf(value) !== -1)
152 return WebInspector.Geometry.CubicBezier.parse(keywordValues[value]); 152 return WebInspector.Geometry.CubicBezier.parse(keywordValues[value]);
153 var bezierRegex = /^cubic-bezier\(([^,]+),([^,]+),([^,]+),([^,]+)\)$/; 153 var bezierRegex = /^cubic-bezier\(([^,]+),([^,]+),([^,]+),([^,]+)\)$/;
154 var match = value.match(bezierRegex); 154 var match = value.match(bezierRegex);
155 if (match) { 155 if (match) {
156 var control1 = new WebInspector.Geometry.Point(parseFloat(match[1]), par seFloat(match[2])); 156 var control1 = new WebInspector.Geometry.Point(parseFloat(match[1]), par seFloat(match[2]));
157 var control2 = new WebInspector.Geometry.Point(parseFloat(match[3]), par seFloat(match[4])); 157 var control2 = new WebInspector.Geometry.Point(parseFloat(match[3]), par seFloat(match[4]));
158 return new WebInspector.Geometry.CubicBezier(control1, control2); 158 return new WebInspector.Geometry.CubicBezier(control1, control2);
159 } 159 }
160 return null; 160 return null;
161 } 161 };
162 162
163 163
164 WebInspector.Geometry.CubicBezier.prototype = { 164 WebInspector.Geometry.CubicBezier.prototype = {
165 /** 165 /**
166 * @param {number} t 166 * @param {number} t
167 * @return {!WebInspector.Geometry.Point} 167 * @return {!WebInspector.Geometry.Point}
168 */ 168 */
169 evaluateAt: function(t) 169 evaluateAt: function(t)
170 { 170 {
171 /** 171 /**
(...skipping 17 matching lines...) Expand all
189 asCSSText: function() 189 asCSSText: function()
190 { 190 {
191 var raw = "cubic-bezier(" + this.controlPoints.join(", ") + ")"; 191 var raw = "cubic-bezier(" + this.controlPoints.join(", ") + ")";
192 var keywordValues = WebInspector.Geometry.CubicBezier.KeywordValues; 192 var keywordValues = WebInspector.Geometry.CubicBezier.KeywordValues;
193 for (var keyword in keywordValues) { 193 for (var keyword in keywordValues) {
194 if (raw === keywordValues[keyword]) 194 if (raw === keywordValues[keyword])
195 return keyword; 195 return keyword;
196 } 196 }
197 return raw; 197 return raw;
198 } 198 }
199 } 199 };
200 200
201 /** 201 /**
202 * @constructor 202 * @constructor
203 * @param {number} alpha 203 * @param {number} alpha
204 * @param {number} beta 204 * @param {number} beta
205 * @param {number} gamma 205 * @param {number} gamma
206 */ 206 */
207 WebInspector.Geometry.EulerAngles = function(alpha, beta, gamma) 207 WebInspector.Geometry.EulerAngles = function(alpha, beta, gamma)
208 { 208 {
209 this.alpha = alpha; 209 this.alpha = alpha;
210 this.beta = beta; 210 this.beta = beta;
211 this.gamma = gamma; 211 this.gamma = gamma;
212 } 212 };
213 213
214 /** 214 /**
215 * @param {!CSSMatrix} rotationMatrix 215 * @param {!CSSMatrix} rotationMatrix
216 * @return {!WebInspector.Geometry.EulerAngles} 216 * @return {!WebInspector.Geometry.EulerAngles}
217 */ 217 */
218 WebInspector.Geometry.EulerAngles.fromRotationMatrix = function(rotationMatrix) 218 WebInspector.Geometry.EulerAngles.fromRotationMatrix = function(rotationMatrix)
219 { 219 {
220 var beta = Math.atan2(rotationMatrix.m23, rotationMatrix.m33); 220 var beta = Math.atan2(rotationMatrix.m23, rotationMatrix.m33);
221 var gamma = Math.atan2(-rotationMatrix.m13, Math.sqrt(rotationMatrix.m11 * r otationMatrix.m11 + rotationMatrix.m12 * rotationMatrix.m12)); 221 var gamma = Math.atan2(-rotationMatrix.m13, Math.sqrt(rotationMatrix.m11 * r otationMatrix.m11 + rotationMatrix.m12 * rotationMatrix.m12));
222 var alpha = Math.atan2(rotationMatrix.m12, rotationMatrix.m11); 222 var alpha = Math.atan2(rotationMatrix.m12, rotationMatrix.m11);
223 return new WebInspector.Geometry.EulerAngles(WebInspector.Geometry.radiansTo Degrees(alpha), WebInspector.Geometry.radiansToDegrees(beta), WebInspector.Geome try.radiansToDegrees(gamma)); 223 return new WebInspector.Geometry.EulerAngles(WebInspector.Geometry.radiansTo Degrees(alpha), WebInspector.Geometry.radiansToDegrees(beta), WebInspector.Geome try.radiansToDegrees(gamma));
224 } 224 };
225 225
226 WebInspector.Geometry.EulerAngles.prototype = { 226 WebInspector.Geometry.EulerAngles.prototype = {
227 /** 227 /**
228 * @return {string} 228 * @return {string}
229 */ 229 */
230 toRotate3DString: function() 230 toRotate3DString: function()
231 { 231 {
232 var gammaAxisY = -Math.sin(WebInspector.Geometry.degreesToRadians(this.b eta)); 232 var gammaAxisY = -Math.sin(WebInspector.Geometry.degreesToRadians(this.b eta));
233 var gammaAxisZ = Math.cos(WebInspector.Geometry.degreesToRadians(this.be ta)); 233 var gammaAxisZ = Math.cos(WebInspector.Geometry.degreesToRadians(this.be ta));
234 var axis = { 234 var axis = {
235 alpha: [0, 1, 0], 235 alpha: [0, 1, 0],
236 beta: [-1, 0, 0], 236 beta: [-1, 0, 0],
237 gamma: [0, gammaAxisY, gammaAxisZ] 237 gamma: [0, gammaAxisY, gammaAxisZ]
238 }; 238 };
239 return "rotate3d(" + axis.alpha.join(",") + "," + this.alpha + "deg) " 239 return "rotate3d(" + axis.alpha.join(",") + "," + this.alpha + "deg) "
240 + "rotate3d(" + axis.beta.join(",") + "," + this.beta + "deg) " 240 + "rotate3d(" + axis.beta.join(",") + "," + this.beta + "deg) "
241 + "rotate3d(" + axis.gamma.join(",") + "," + this.gamma + "deg)"; 241 + "rotate3d(" + axis.gamma.join(",") + "," + this.gamma + "deg)";
242 } 242 }
243 } 243 };
244 244
245 /** 245 /**
246 * @param {!WebInspector.Geometry.Vector} u 246 * @param {!WebInspector.Geometry.Vector} u
247 * @param {!WebInspector.Geometry.Vector} v 247 * @param {!WebInspector.Geometry.Vector} v
248 * @return {number} 248 * @return {number}
249 */ 249 */
250 WebInspector.Geometry.scalarProduct = function(u, v) 250 WebInspector.Geometry.scalarProduct = function(u, v)
251 { 251 {
252 return u.x * v.x + u.y * v.y + u.z * v.z; 252 return u.x * v.x + u.y * v.y + u.z * v.z;
253 } 253 };
254 254
255 /** 255 /**
256 * @param {!WebInspector.Geometry.Vector} u 256 * @param {!WebInspector.Geometry.Vector} u
257 * @param {!WebInspector.Geometry.Vector} v 257 * @param {!WebInspector.Geometry.Vector} v
258 * @return {!WebInspector.Geometry.Vector} 258 * @return {!WebInspector.Geometry.Vector}
259 */ 259 */
260 WebInspector.Geometry.crossProduct = function(u, v) 260 WebInspector.Geometry.crossProduct = function(u, v)
261 { 261 {
262 var x = u.y * v.z - u.z * v.y; 262 var x = u.y * v.z - u.z * v.y;
263 var y = u.z * v.x - u.x * v.z; 263 var y = u.z * v.x - u.x * v.z;
264 var z = u.x * v.y - u.y * v.x; 264 var z = u.x * v.y - u.y * v.x;
265 return new WebInspector.Geometry.Vector(x, y, z); 265 return new WebInspector.Geometry.Vector(x, y, z);
266 } 266 };
267 267
268 /** 268 /**
269 * @param {!WebInspector.Geometry.Vector} u 269 * @param {!WebInspector.Geometry.Vector} u
270 * @param {!WebInspector.Geometry.Vector} v 270 * @param {!WebInspector.Geometry.Vector} v
271 * @return {!WebInspector.Geometry.Vector} 271 * @return {!WebInspector.Geometry.Vector}
272 */ 272 */
273 WebInspector.Geometry.subtract = function(u, v) 273 WebInspector.Geometry.subtract = function(u, v)
274 { 274 {
275 var x = u.x - v.x; 275 var x = u.x - v.x;
276 var y = u.y - v.y; 276 var y = u.y - v.y;
277 var z = u.z - v.z; 277 var z = u.z - v.z;
278 return new WebInspector.Geometry.Vector(x, y, z); 278 return new WebInspector.Geometry.Vector(x, y, z);
279 } 279 };
280 280
281 /** 281 /**
282 * @param {!WebInspector.Geometry.Vector} v 282 * @param {!WebInspector.Geometry.Vector} v
283 * @param {!CSSMatrix} m 283 * @param {!CSSMatrix} m
284 * @return {!WebInspector.Geometry.Vector} 284 * @return {!WebInspector.Geometry.Vector}
285 */ 285 */
286 WebInspector.Geometry.multiplyVectorByMatrixAndNormalize = function(v, m) 286 WebInspector.Geometry.multiplyVectorByMatrixAndNormalize = function(v, m)
287 { 287 {
288 var t = v.x * m.m14 + v.y * m.m24 + v.z * m.m34 + m.m44; 288 var t = v.x * m.m14 + v.y * m.m24 + v.z * m.m34 + m.m44;
289 var x = (v.x * m.m11 + v.y * m.m21 + v.z * m.m31 + m.m41) / t; 289 var x = (v.x * m.m11 + v.y * m.m21 + v.z * m.m31 + m.m41) / t;
290 var y = (v.x * m.m12 + v.y * m.m22 + v.z * m.m32 + m.m42) / t; 290 var y = (v.x * m.m12 + v.y * m.m22 + v.z * m.m32 + m.m42) / t;
291 var z = (v.x * m.m13 + v.y * m.m23 + v.z * m.m33 + m.m43) / t; 291 var z = (v.x * m.m13 + v.y * m.m23 + v.z * m.m33 + m.m43) / t;
292 return new WebInspector.Geometry.Vector(x, y, z); 292 return new WebInspector.Geometry.Vector(x, y, z);
293 } 293 };
294 294
295 /** 295 /**
296 * @param {!WebInspector.Geometry.Vector} u 296 * @param {!WebInspector.Geometry.Vector} u
297 * @param {!WebInspector.Geometry.Vector} v 297 * @param {!WebInspector.Geometry.Vector} v
298 * @return {number} 298 * @return {number}
299 */ 299 */
300 WebInspector.Geometry.calculateAngle = function(u, v) 300 WebInspector.Geometry.calculateAngle = function(u, v)
301 { 301 {
302 var uLength = u.length(); 302 var uLength = u.length();
303 var vLength = v.length(); 303 var vLength = v.length();
304 if (uLength <= WebInspector.Geometry._Eps || vLength <= WebInspector.Geometr y._Eps) 304 if (uLength <= WebInspector.Geometry._Eps || vLength <= WebInspector.Geometr y._Eps)
305 return 0; 305 return 0;
306 var cos = WebInspector.Geometry.scalarProduct(u, v) / uLength / vLength; 306 var cos = WebInspector.Geometry.scalarProduct(u, v) / uLength / vLength;
307 if (Math.abs(cos) > 1) 307 if (Math.abs(cos) > 1)
308 return 0; 308 return 0;
309 return WebInspector.Geometry.radiansToDegrees(Math.acos(cos)); 309 return WebInspector.Geometry.radiansToDegrees(Math.acos(cos));
310 } 310 };
311 311
312 /** 312 /**
313 * @param {number} deg 313 * @param {number} deg
314 * @return {number} 314 * @return {number}
315 */ 315 */
316 WebInspector.Geometry.degreesToRadians = function(deg) 316 WebInspector.Geometry.degreesToRadians = function(deg)
317 { 317 {
318 return deg * Math.PI / 180; 318 return deg * Math.PI / 180;
319 } 319 };
320 320
321 /** 321 /**
322 * @param {number} rad 322 * @param {number} rad
323 * @return {number} 323 * @return {number}
324 */ 324 */
325 WebInspector.Geometry.radiansToDegrees = function(rad) 325 WebInspector.Geometry.radiansToDegrees = function(rad)
326 { 326 {
327 return rad * 180 / Math.PI; 327 return rad * 180 / Math.PI;
328 } 328 };
329 329
330 /** 330 /**
331 * @param {!CSSMatrix} matrix 331 * @param {!CSSMatrix} matrix
332 * @param {!Array.<number>} points 332 * @param {!Array.<number>} points
333 * @param {{minX: number, maxX: number, minY: number, maxY: number}=} aggregateB ounds 333 * @param {{minX: number, maxX: number, minY: number, maxY: number}=} aggregateB ounds
334 * @return {!{minX: number, maxX: number, minY: number, maxY: number}} 334 * @return {!{minX: number, maxX: number, minY: number, maxY: number}}
335 */ 335 */
336 WebInspector.Geometry.boundsForTransformedPoints = function(matrix, points, aggr egateBounds) 336 WebInspector.Geometry.boundsForTransformedPoints = function(matrix, points, aggr egateBounds)
337 { 337 {
338 if (!aggregateBounds) 338 if (!aggregateBounds)
339 aggregateBounds = {minX: Infinity, maxX: -Infinity, minY: Infinity, maxY : -Infinity}; 339 aggregateBounds = {minX: Infinity, maxX: -Infinity, minY: Infinity, maxY : -Infinity};
340 if (points.length % 3) 340 if (points.length % 3)
341 console.assert("Invalid size of points array"); 341 console.assert("Invalid size of points array");
342 for (var p = 0; p < points.length; p += 3) { 342 for (var p = 0; p < points.length; p += 3) {
343 var vector = new WebInspector.Geometry.Vector(points[p], points[p + 1], points[p + 2]); 343 var vector = new WebInspector.Geometry.Vector(points[p], points[p + 1], points[p + 2]);
344 vector = WebInspector.Geometry.multiplyVectorByMatrixAndNormalize(vector , matrix); 344 vector = WebInspector.Geometry.multiplyVectorByMatrixAndNormalize(vector , matrix);
345 aggregateBounds.minX = Math.min(aggregateBounds.minX, vector.x); 345 aggregateBounds.minX = Math.min(aggregateBounds.minX, vector.x);
346 aggregateBounds.maxX = Math.max(aggregateBounds.maxX, vector.x); 346 aggregateBounds.maxX = Math.max(aggregateBounds.maxX, vector.x);
347 aggregateBounds.minY = Math.min(aggregateBounds.minY, vector.y); 347 aggregateBounds.minY = Math.min(aggregateBounds.minY, vector.y);
348 aggregateBounds.maxY = Math.max(aggregateBounds.maxY, vector.y); 348 aggregateBounds.maxY = Math.max(aggregateBounds.maxY, vector.y);
349 } 349 }
350 return aggregateBounds; 350 return aggregateBounds;
351 } 351 };
352 352
353 /** 353 /**
354 * @constructor 354 * @constructor
355 * @param {number} width 355 * @param {number} width
356 * @param {number} height 356 * @param {number} height
357 */ 357 */
358 function Size(width, height) 358 function Size(width, height)
359 { 359 {
360 this.width = width; 360 this.width = width;
361 this.height = height; 361 this.height = height;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 Insets.prototype = { 425 Insets.prototype = {
426 /** 426 /**
427 * @param {?Insets} insets 427 * @param {?Insets} insets
428 * @return {boolean} 428 * @return {boolean}
429 */ 429 */
430 isEqual: function(insets) 430 isEqual: function(insets)
431 { 431 {
432 return !!insets && this.left === insets.left && this.top === insets.top && this.right === insets.right && this.bottom === insets.bottom; 432 return !!insets && this.left === insets.left && this.top === insets.top && this.right === insets.right && this.bottom === insets.bottom;
433 } 433 }
434 } 434 };
435 435
436 436
437 /** 437 /**
438 * @constructor 438 * @constructor
439 * @param {number} left 439 * @param {number} left
440 * @param {number} top 440 * @param {number} top
441 * @param {number} width 441 * @param {number} width
442 * @param {number} height 442 * @param {number} height
443 */ 443 */
444 WebInspector.Rect = function(left, top, width, height) 444 WebInspector.Rect = function(left, top, width, height)
445 { 445 {
446 this.left = left; 446 this.left = left;
447 this.top = top; 447 this.top = top;
448 this.width = width; 448 this.width = width;
449 this.height = height; 449 this.height = height;
450 } 450 };
451 451
452 WebInspector.Rect.prototype = { 452 WebInspector.Rect.prototype = {
453 /** 453 /**
454 * @param {?WebInspector.Rect} rect 454 * @param {?WebInspector.Rect} rect
455 * @return {boolean} 455 * @return {boolean}
456 */ 456 */
457 isEqual: function(rect) 457 isEqual: function(rect)
458 { 458 {
459 return !!rect && this.left === rect.left && this.top === rect.top && thi s.width === rect.width && this.height === rect.height; 459 return !!rect && this.left === rect.left && this.top === rect.top && thi s.width === rect.width && this.height === rect.height;
460 }, 460 },
461 461
462 /** 462 /**
463 * @param {number} scale 463 * @param {number} scale
464 * @return {!WebInspector.Rect} 464 * @return {!WebInspector.Rect}
465 */ 465 */
466 scale: function(scale) 466 scale: function(scale)
467 { 467 {
468 return new WebInspector.Rect(this.left * scale, this.top * scale, this.w idth * scale, this.height * scale); 468 return new WebInspector.Rect(this.left * scale, this.top * scale, this.w idth * scale, this.height * scale);
469 }, 469 },
470 470
471 /** 471 /**
472 * @return {!Size} 472 * @return {!Size}
473 */ 473 */
474 size: function() 474 size: function()
475 { 475 {
476 return new Size(this.width, this.height); 476 return new Size(this.width, this.height);
477 } 477 }
478 } 478 };
479 479
480 480
481 /** 481 /**
482 * @constructor 482 * @constructor
483 * @param {!Size=} minimum 483 * @param {!Size=} minimum
484 * @param {?Size=} preferred 484 * @param {?Size=} preferred
485 */ 485 */
486 function Constraints(minimum, preferred) 486 function Constraints(minimum, preferred)
487 { 487 {
488 /** 488 /**
(...skipping 10 matching lines...) Expand all
499 throw new Error("Minimum size is greater than preferred."); 499 throw new Error("Minimum size is greater than preferred.");
500 } 500 }
501 501
502 /** 502 /**
503 * @param {?Constraints} constraints 503 * @param {?Constraints} constraints
504 * @return {boolean} 504 * @return {boolean}
505 */ 505 */
506 Constraints.prototype.isEqual = function(constraints) 506 Constraints.prototype.isEqual = function(constraints)
507 { 507 {
508 return !!constraints && this.minimum.isEqual(constraints.minimum) && this.pr eferred.isEqual(constraints.preferred); 508 return !!constraints && this.minimum.isEqual(constraints.minimum) && this.pr eferred.isEqual(constraints.preferred);
509 } 509 };
510 510
511 /** 511 /**
512 * @param {!Constraints|number} value 512 * @param {!Constraints|number} value
513 * @return {!Constraints} 513 * @return {!Constraints}
514 */ 514 */
515 Constraints.prototype.widthToMax = function(value) 515 Constraints.prototype.widthToMax = function(value)
516 { 516 {
517 if (typeof value === "number") 517 if (typeof value === "number")
518 return new Constraints(this.minimum.widthToMax(value), this.preferred.wi dthToMax(value)); 518 return new Constraints(this.minimum.widthToMax(value), this.preferred.wi dthToMax(value));
519 return new Constraints(this.minimum.widthToMax(value.minimum), this.preferre d.widthToMax(value.preferred)); 519 return new Constraints(this.minimum.widthToMax(value.minimum), this.preferre d.widthToMax(value.preferred));
520 } 520 };
521 521
522 /** 522 /**
523 * @param {!Constraints|number} value 523 * @param {!Constraints|number} value
524 * @return {!Constraints} 524 * @return {!Constraints}
525 */ 525 */
526 Constraints.prototype.addWidth = function(value) 526 Constraints.prototype.addWidth = function(value)
527 { 527 {
528 if (typeof value === "number") 528 if (typeof value === "number")
529 return new Constraints(this.minimum.addWidth(value), this.preferred.addW idth(value)); 529 return new Constraints(this.minimum.addWidth(value), this.preferred.addW idth(value));
530 return new Constraints(this.minimum.addWidth(value.minimum), this.preferred. addWidth(value.preferred)); 530 return new Constraints(this.minimum.addWidth(value.minimum), this.preferred. addWidth(value.preferred));
531 } 531 };
532 532
533 /** 533 /**
534 * @param {!Constraints|number} value 534 * @param {!Constraints|number} value
535 * @return {!Constraints} 535 * @return {!Constraints}
536 */ 536 */
537 Constraints.prototype.heightToMax = function(value) 537 Constraints.prototype.heightToMax = function(value)
538 { 538 {
539 if (typeof value === "number") 539 if (typeof value === "number")
540 return new Constraints(this.minimum.heightToMax(value), this.preferred.h eightToMax(value)); 540 return new Constraints(this.minimum.heightToMax(value), this.preferred.h eightToMax(value));
541 return new Constraints(this.minimum.heightToMax(value.minimum), this.preferr ed.heightToMax(value.preferred)); 541 return new Constraints(this.minimum.heightToMax(value.minimum), this.preferr ed.heightToMax(value.preferred));
542 } 542 };
543 543
544 /** 544 /**
545 * @param {!Constraints|number} value 545 * @param {!Constraints|number} value
546 * @return {!Constraints} 546 * @return {!Constraints}
547 */ 547 */
548 Constraints.prototype.addHeight = function(value) 548 Constraints.prototype.addHeight = function(value)
549 { 549 {
550 if (typeof value === "number") 550 if (typeof value === "number")
551 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value)); 551 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value));
552 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred)); 552 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred));
553 } 553 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698