Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('print_preview', function() { | |
| 6 'use strict'; | |
| 7 | |
| 8 /** | |
| 9 * Creates a Margins object that holds four margin values in points. | |
| 10 * | |
| 11 * @param {number} top The top margin in pts. | |
| 12 * @param {number} right The right margin in pts. | |
| 13 * @param {number} bottom The bottom margin in pts. | |
| 14 * @param {number} left The left margin in pts. | |
| 15 * @constructor | |
| 16 */ | |
| 17 function Margins(top, right, bottom, left) { | |
| 18 /** | |
| 19 * Top margin in points. | |
| 20 * @type {number} | |
| 21 * @private | |
| 22 */ | |
| 23 this.top_ = top; | |
| 24 | |
| 25 /** | |
| 26 * Right margin in points. | |
| 27 * @type {number} | |
| 28 * @private | |
| 29 */ | |
| 30 this.right_ = right; | |
| 31 | |
| 32 /** | |
| 33 * Bottom margin in points. | |
| 34 * @type {number} | |
| 35 * @private | |
| 36 */ | |
| 37 this.bottom_ = bottom; | |
| 38 | |
| 39 /** | |
| 40 * Left margin in points. | |
| 41 * @type {number} | |
| 42 * @private | |
| 43 */ | |
| 44 this.left_ = left; | |
| 45 }; | |
| 46 | |
| 47 /** | |
| 48 * Enumeration of margin types. | |
| 49 * @enum {string} | |
| 50 */ | |
| 51 Margins.Type = { | |
| 52 DEFAULT: 'default', | |
|
dpapad
2012/04/24 01:24:56
Why changing these to strings?
Robert Toscano
2012/04/24 22:29:56
Good question. The only reason why numbers were us
dpapad
2012/04/24 22:50:19
Alternatively you could add one more enum constant
Robert Toscano
2012/04/28 01:41:37
Ok, I'll go with what you suggest except for the U
dpapad
2012/04/30 16:19:26
Ok, just make sure to initialize variables to null
| |
| 53 NO_MARGINS: 'no-margins', | |
| 54 MINIMUM: 'minimum', | |
| 55 CUSTOM: 'custom' | |
| 56 }, | |
| 57 | |
| 58 Margins.prototype = { | |
| 59 /** @return {number} Top margin in points. */ | |
| 60 get top() { | |
| 61 return this.top_; | |
| 62 }, | |
| 63 | |
| 64 /** @return {number} Right margin in points. */ | |
| 65 get right() { | |
| 66 return this.right_; | |
| 67 }, | |
| 68 | |
| 69 /** @return {number} Bottom margin in points. */ | |
| 70 get bottom() { | |
| 71 return this.bottom_; | |
| 72 }, | |
| 73 | |
| 74 /** @return {number} Left margin in points. */ | |
| 75 get left() { | |
| 76 return this.left_; | |
| 77 }, | |
| 78 | |
| 79 /** | |
| 80 * @param {print_preview.Margins} other The other margins object to compare | |
| 81 * against. | |
| 82 * @return {boolean} Whether this margins object is equal to another. | |
| 83 */ | |
| 84 equals: function(other) { | |
| 85 return other != null && | |
| 86 this.top_ == other.top_ && | |
| 87 this.right_ == other.right_ && | |
| 88 this.bottom_ == other.bottom_ && | |
| 89 this.left_ == other.left_; | |
| 90 } | |
| 91 }; | |
| 92 | |
| 93 // Export | |
| 94 return { | |
| 95 Margins: Margins | |
| 96 }; | |
| 97 }); | |
| OLD | NEW |