Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 }, | 
| 91 | 91 | 
| 92 /** | 92 /** | 
| 93 * @param {number} scalar | |
| 94 */ | |
| 95 scale: function(scalar) | |
| 96 { | |
| 97 this.x *= scalar; | |
| 
 
lushnikov
2016/08/31 00:48:03
let's return a new object instead of mutating
 
flandy
2016/08/31 01:35:05
Done.
 
 | |
| 98 this.y *= scalar; | |
| 99 }, | |
| 100 | |
| 101 /** | |
| 93 * @override | 102 * @override | 
| 94 * @return {string} | 103 * @return {string} | 
| 95 */ | 104 */ | 
| 96 toString: function() | 105 toString: function() | 
| 97 { | 106 { | 
| 98 return Math.round(this.x * 100) / 100 + ", " + Math.round(this.y * 100) / 100; | 107 return Math.round(this.x * 100) / 100 + ", " + Math.round(this.y * 100) / 100; | 
| 99 } | 108 } | 
| 100 } | 109 } | 
| 101 | 110 | 
| 102 /** | 111 /** | 
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 /** | 533 /** | 
| 525 * @param {!Constraints|number} value | 534 * @param {!Constraints|number} value | 
| 526 * @return {!Constraints} | 535 * @return {!Constraints} | 
| 527 */ | 536 */ | 
| 528 Constraints.prototype.addHeight = function(value) | 537 Constraints.prototype.addHeight = function(value) | 
| 529 { | 538 { | 
| 530 if (typeof value === "number") | 539 if (typeof value === "number") | 
| 531 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value)); | 540 return new Constraints(this.minimum.addHeight(value), this.preferred.add Height(value)); | 
| 532 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred)); | 541 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred .addHeight(value.preferred)); | 
| 533 } | 542 } | 
| OLD | NEW |