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..24e659272fabeda5b554f54d778bf5a3a3de5c44 100644 |
--- a/Source/devtools/front_end/DOMExtension.js |
+++ b/Source/devtools/front_end/DOMExtension.js |
@@ -198,11 +198,19 @@ function removeSubsequentNodes(fromNode, toNode) |
* @constructor |
* @param {number} width |
* @param {number} height |
+ * @param {number=} preferredWidth |
+ * @param {number=} preferredHeight |
*/ |
-function Size(width, height) |
+function Size(width, height, preferredWidth, preferredHeight) |
vsevik
2014/03/28 16:13:26
I don't think we should merge them, it's confusing
dgozman
2014/03/28 18:05:02
Created a Constraints object.
|
{ |
this.width = width; |
this.height = height; |
+ this.preferredWidth = preferredWidth; |
+ if (typeof preferredWidth === "undefined") |
+ this.preferredWidth = width; |
+ this.preferredHeight = preferredHeight; |
+ if (typeof preferredHeight === "undefined") |
+ this.preferredHeight = height; |
} |
/** |
@@ -211,7 +219,39 @@ function Size(width, height) |
*/ |
Size.prototype.isEqual = function(size) |
{ |
- return !!size && this.width === size.width && this.height === size.height; |
+ return !!size && this.width === size.width && this.height === size.height && this.preferredWidth == size.preferredWidth && this.preferredHeight == size.preferredHeight; |
+}; |
+ |
+/** |
+ * @return {!Size} |
+ */ |
+Size.prototype.widthToMax = function(size) |
vsevik
2014/03/28 16:13:26
Size.prototype.constrainWidth = function(minWidth,
dgozman
2014/03/28 18:05:02
But I need a Size with width to be a maximum of tw
vsevik
2014/03/28 18:24:50
size.widthToMax(new Size(w, 0)) would be equivalen
|
+{ |
+ return new Size(Math.max(this.width, size.width), this.height, Math.max(this.preferredWidth, size.preferredWidth), this.preferredHeight); |
+}; |
+ |
+/** |
+ * @return {!Size} |
+ */ |
+Size.prototype.addWidth = function(size) |
vsevik
2014/03/28 16:13:26
Size.prototype.addWidth = function(width)
|
+{ |
+ return new Size(this.width + size.width, this.height, this.preferredWidth + size.preferredWidth, this.preferredHeight); |
+}; |
+ |
+/** |
+ * @return {!Size} |
+ */ |
+Size.prototype.heightToMax = function(size) |
+{ |
+ return new Size(this.width, Math.max(this.height, size.height), this.preferredWidth, Math.max(this.preferredHeight, size.preferredHeight)); |
+}; |
+ |
+/** |
+ * @return {!Size} |
+ */ |
+Size.prototype.addHeight = function(size) |
+{ |
+ return new Size(this.width, this.height + size.height, this.preferredWidth, this.preferredHeight + size.preferredHeight); |
}; |
/** |