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

Unified Diff: chrome/browser/resources/print_preview/data/coordinate2d.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve conflicts Created 8 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/data/coordinate2d.js
diff --git a/chrome/browser/resources/print_preview/data/coordinate2d.js b/chrome/browser/resources/print_preview/data/coordinate2d.js
new file mode 100644
index 0000000000000000000000000000000000000000..4b10af63808508e18669be00dfaab9f0d1986602
--- /dev/null
+++ b/chrome/browser/resources/print_preview/data/coordinate2d.js
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('print_preview', function() {
+ 'use strict';
+
+ /**
+ * Immutable two dimensional point in space. The units of the dimensions are
+ * undefined.
+ * @param {number} x X-dimension of the point.
+ * @param {number} y Y-dimension of the point.
+ * @constructor
+ */
+ function Coordinate2d(x, y) {
+ /**
+ * X-dimension of the point.
+ * @type {number}
+ * @private
+ */
+ this.x_ = x;
+
+ /**
+ * Y-dimension of the point.
+ * @type {number}
+ * @private
+ */
+ this.y_ = y;
+ };
+
+ Coordinate2d.prototype = {
+ /** @return {number} X-dimension of the point. */
+ get x() {
+ return this.x_;
+ },
+
+ /** @return {number} Y-dimension of the point. */
+ get y() {
+ return this.y_;
+ },
+
+ /**
+ * @param {number} x Amount to translate in the X dimension.
+ * @param {number} y Amount to translate in the Y dimension.
+ * @return {!print_preview.Coordinate2d} A new two-dimensional point
+ * translated along the X and Y dimensions.
+ */
+ translate: function(x, y) {
+ return new Coordinate2d(this.x_ + x, this.y_ + y);
+ },
+
+ /**
+ * @param {number} factor Amount to scale the X and Y dimensions.
+ * @return {!print_preview.Coordinate2d} A new two-dimensional point scaled
+ * by the given factor.
+ */
+ scale: function(factor) {
+ return new Coordinate2d(this.x_ * factor, this.y_ * factor);
+ },
+
+ /**
+ * @param {print_preview.Coordinate2d} other The point to compare against.
+ * @return {boolean} Whether another point is equal to this one.
+ */
+ equals: function(other) {
+ return other != null &&
+ this.x_ == other.x_ &&
+ this.y_ == other.y_;
+ }
+ };
+
+ // Export
+ return {
+ Coordinate2d: Coordinate2d
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698