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

Unified Diff: Source/devtools/front_end/DOMExtension.js

Issue 214663005: [DevTools] Add preferred size to WebInspector.View. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Two methods Created 6 years, 9 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
« no previous file with comments | « LayoutTests/inspector/minimum-size-expected.txt ('k') | Source/devtools/front_end/InspectorView.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..875d8c90a34699de8fe3cd50043d901e86c60a8c 100644
--- a/Source/devtools/front_end/DOMExtension.js
+++ b/Source/devtools/front_end/DOMExtension.js
@@ -215,6 +215,116 @@ Size.prototype.isEqual = function(size)
};
/**
+ * @param {!Size|number} size
+ * @return {!Size}
+ */
+Size.prototype.widthToMax = function(size)
+{
+ return new Size(Math.max(this.width, (typeof size === "number" ? size : size.width)), this.height);
+};
+
+/**
+ * @param {!Size|number} size
+ * @return {!Size}
+ */
+Size.prototype.addWidth = function(size)
+{
+ return new Size(this.width + (typeof size === "number" ? size : size.width), this.height);
+};
+
+/**
+ * @param {!Size|number} size
+ * @return {!Size}
+ */
+Size.prototype.heightToMax = function(size)
+{
+ return new Size(this.width, Math.max(this.height, (typeof size === "number" ? size : size.height)));
+};
+
+/**
+ * @param {!Size|number} size
+ * @return {!Size}
+ */
+Size.prototype.addHeight = function(size)
+{
+ return new Size(this.width, this.height + (typeof size === "number" ? size : size.height));
+};
+
+/**
+ * @constructor
+ * @param {!Size} minimum
+ * @param {?Size=} preferred
+ */
+function Constraints(minimum, preferred)
+{
+ /**
+ * @type {!Size}
+ */
+ this.minimum = minimum;
+
+ /**
+ * @type {!Size}
+ */
+ this.preferred = preferred || minimum;
+
+ if (this.minimum.width > this.preferred.width || this.minimum.height > this.preferred.height)
+ throw new Error("Minimum size is greater than preferred.");
+}
+
+/**
+ * @param {?Constraints} constraints
+ * @return {boolean}
+ */
+Constraints.prototype.isEqual = function(constraints)
+{
+ return !!constraints && this.minimum.isEqual(constraints.minimum) && this.preferred.isEqual(constraints.preferred);
+};
+
+/**
+ * @param {!Constraints|number} value
+ * @return {!Constraints}
+ */
+Constraints.prototype.widthToMax = function(value)
+{
+ if (typeof value === "number")
+ return new Constraints(this.minimum.widthToMax(value), this.preferred.widthToMax(value));
+ return new Constraints(this.minimum.widthToMax(value.minimum), this.preferred.widthToMax(value.preferred));
+};
+
+/**
+ * @param {!Constraints|number} value
+ * @return {!Constraints}
+ */
+Constraints.prototype.addWidth = function(value)
+{
+ if (typeof value === "number")
+ return new Constraints(this.minimum.addWidth(value), this.preferred.addWidth(value));
+ return new Constraints(this.minimum.addWidth(value.minimum), this.preferred.addWidth(value.preferred));
+};
+
+/**
+ * @param {!Constraints|number} value
+ * @return {!Constraints}
+ */
+Constraints.prototype.heightToMax = function(value)
+{
+ if (typeof value === "number")
+ return new Constraints(this.minimum.heightToMax(value), this.preferred.heightToMax(value));
+ return new Constraints(this.minimum.heightToMax(value.minimum), this.preferred.heightToMax(value.preferred));
+};
+
+/**
+ * @param {!Constraints|number} value
+ * @return {!Constraints}
+ */
+Constraints.prototype.addHeight = function(value)
+{
+ if (typeof value === "number")
+ return new Constraints(this.minimum.addHeight(value), this.preferred.addHeight(value));
+ return new Constraints(this.minimum.addHeight(value.minimum), this.preferred.addHeight(value.preferred));
+};
+
+/**
* @param {?Element=} containerElement
* @return {!Size}
*/
« no previous file with comments | « LayoutTests/inspector/minimum-size-expected.txt ('k') | Source/devtools/front_end/InspectorView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698