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

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: saved main size 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 | « no previous file | Source/devtools/front_end/SourcesPanel.js » ('j') | Source/devtools/front_end/SourcesView.js » ('J')
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..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);
};
/**
« no previous file with comments | « no previous file | Source/devtools/front_end/SourcesPanel.js » ('j') | Source/devtools/front_end/SourcesView.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698