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

Unified Diff: third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 years, 5 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: third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js
diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js
index 1b3841baf08dd94728f7cd04de1bd556b837e6f4..f5c379b72b02c098a84f7dd83659d20962238da6 100644
--- a/third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js
+++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/math/size.js
@@ -14,6 +14,7 @@
/**
* @fileoverview A utility class for representing two-dimensional sizes.
+ * @author brenneman@google.com (Shawn Brenneman)
*/
@@ -26,6 +27,7 @@ goog.provide('goog.math.Size');
* width and height support is deprecated and results in compiler warning.
* @param {number} width Width.
* @param {number} height Height.
+ * @struct
* @constructor
*/
goog.math.Size = function(width, height) {
@@ -190,6 +192,25 @@ goog.math.Size.prototype.scale = function(sx, opt_sy) {
/**
+ * Uniformly scales the size to perfectly cover the dimensions of a given size.
+ * If the size is already larger than the target, it will be scaled down to the
+ * minimum size at which it still covers the entire target. The original aspect
+ * ratio will be preserved.
+ *
+ * This function assumes that both Sizes contain strictly positive dimensions.
+ * @param {!goog.math.Size} target The target size.
+ * @return {!goog.math.Size} This Size object, after optional scaling.
+ */
+goog.math.Size.prototype.scaleToCover = function(target) {
+ var s = this.aspectRatio() <= target.aspectRatio() ?
+ target.width / this.width :
+ target.height / this.height;
+
+ return this.scale(s);
+};
+
+
+/**
* Uniformly scales the size to fit inside the dimensions of a given size. The
* original aspect ratio will be preserved.
*

Powered by Google App Engine
This is Rietveld 408576698