Index: Source/devtools/front_end/DOMExtension.js |
diff --git a/Source/devtools/front_end/DOMExtension.js b/Source/devtools/front_end/DOMExtension.js |
index 70df32c8ae5f936aaa3d253a21bf13b910cceac1..66ad897472a895947b9c07cad44d8c1f70e5a0bf 100644 |
--- a/Source/devtools/front_end/DOMExtension.js |
+++ b/Source/devtools/front_end/DOMExtension.js |
@@ -215,6 +215,108 @@ Size.prototype.isEqual = function(size) |
}; |
/** |
+ * @param {!Size} size |
+ * @return {!Size} |
+ */ |
+Size.prototype.widthToMax = function(size) |
+{ |
+ if (typeof size === "undefined") { |
+ console.error(new Error().stack); |
+ } |
+ return new Size(Math.max(this.width, size.width), this.height); |
+}; |
+ |
+/** |
+ * @param {!Size} size |
+ * @return {!Size} |
+ */ |
+Size.prototype.addWidth = function(size) |
+{ |
+ return new Size(this.width + size.width, this.height); |
+}; |
+ |
+/** |
+ * @param {!Size} size |
+ * @return {!Size} |
+ */ |
+Size.prototype.heightToMax = function(size) |
+{ |
+ return new Size(this.width, Math.max(this.height, size.height)); |
+}; |
+ |
+/** |
+ * @param {!Size} size |
+ * @return {!Size} |
+ */ |
+Size.prototype.addHeight = function(size) |
+{ |
+ return new Size(this.width, this.height + size.height); |
+}; |
+ |
+/** |
+ * @constructor |
+ * @param {!Size} minimum |
+ * @param {?Size=} preferred |
+ */ |
+function Constraints(minimum, preferred) |
+{ |
+ /** |
+ * @type {!Size} |
+ */ |
+ this.minimum = minimum; |
+ |
+ /** |
+ * @type {!Size} |
+ */ |
+ this.preferred = preferred || minimum; |
+} |
+ |
+/** |
+ * @param {?Constraints} constraints |
+ * @return {boolean} |
+ */ |
+Constraints.prototype.isEqual = function(constraints) |
+{ |
+ return !!constraints && this.minimum.isEqual(constraints.minimum) && this.preferred.isEqual(constraints.preferred); |
+}; |
+ |
+/** |
+ * @param {!Constraints} constraints |
+ * @return {!Constraints} |
+ */ |
+Constraints.prototype.widthToMax = function(constraints) |
+{ |
+ return new Constraints(this.minimum.widthToMax(constraints.minimum), this.preferred.widthToMax(constraints.preferred)); |
+}; |
+ |
+/** |
+ * @param {!Constraints} constraints |
+ * @return {!Constraints} |
+ */ |
+Constraints.prototype.addWidth = function(constraints) |
+{ |
+ return new Constraints(this.minimum.addWidth(constraints.minimum), this.preferred.addWidth(constraints.preferred)); |
+}; |
+ |
+/** |
+ * @param {!Constraints} constraints |
+ * @return {!Constraints} |
+ */ |
+Constraints.prototype.heightToMax = function(constraints) |
+{ |
+ return new Constraints(this.minimum.heightToMax(constraints.minimum), this.preferred.heightToMax(constraints.preferred)); |
+}; |
+ |
+/** |
+ * @param {!Constraints} constraints |
+ * @return {!Constraints} |
+ */ |
+Constraints.prototype.addHeight = function(constraints) |
+{ |
+ return new Constraints(this.minimum.addHeight(constraints.minimum), this.preferred.addHeight(constraints.preferred)); |
+}; |
+ |
+/** |
* @param {?Element=} containerElement |
* @return {!Size} |
*/ |