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

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: Constraints 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
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}
*/

Powered by Google App Engine
This is Rietveld 408576698