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

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

Issue 197823010: [DevTools] Add minimum size to WebInspector.View. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@splitdip2
Patch Set: rebase 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/View.js
diff --git a/Source/devtools/front_end/View.js b/Source/devtools/front_end/View.js
index 833c20a972397a1889541df55fd6b19d8edc0708..628014ef822d389da600eb9b2156492cca66adbe 100644
--- a/Source/devtools/front_end/View.js
+++ b/Source/devtools/front_end/View.js
@@ -229,6 +229,10 @@ WebInspector.View.prototype = {
{
},
+ onLayout: function()
+ {
+ },
+
/**
* @param {?Element} parentElement
* @param {!Element=} insertBefore
@@ -276,6 +280,9 @@ WebInspector.View.prototype = {
this._processWasShown();
this._cacheSize();
}
+
+ if (this._parentView && this._hasNonZeroMinimumSize())
+ this._parentView.invalidateMinimumSize();
},
/**
@@ -297,6 +304,8 @@ WebInspector.View.prototype = {
this._visible = false;
if (this._parentIsShowing())
this._processWasHidden();
+ if (this._parentView && this._hasNonZeroMinimumSize())
+ this._parentView.invalidateMinimumSize();
return;
}
@@ -313,7 +322,10 @@ WebInspector.View.prototype = {
var childIndex = this._parentView._children.indexOf(this);
WebInspector.View._assert(childIndex >= 0, "Attempt to remove non-child view");
this._parentView._children.splice(childIndex, 1);
+ var parent = this._parentView;
this._parentView = null;
+ if (this._hasNonZeroMinimumSize())
+ parent.invalidateMinimumSize();
} else
WebInspector.View._assert(this._isRoot, "Removing non-root view from DOM");
},
@@ -366,6 +378,14 @@ WebInspector.View.prototype = {
this._cacheSize();
},
+ doLayout: function()
+ {
+ if (!this.isShowing())
+ return;
+ this._notify(this.onLayout);
+ this.doResize();
+ },
+
registerRequiredCSS: function(cssFile)
{
if (window.flattenImports)
@@ -484,6 +504,56 @@ WebInspector.View.prototype = {
return result;
},
+ /**
+ * @return {!Size}
+ */
+ calculateMinimumSize: function()
+ {
+ return new Size(0, 0);
+ },
+
+ /**
+ * @return {!Size}
+ */
+ minimumSize: function()
+ {
+ if (typeof this._minimumSize !== "undefined")
+ return this._minimumSize;
+ if (typeof this._cachedMinimumSize === "undefined")
+ this._cachedMinimumSize = this.calculateMinimumSize();
+ return this._cachedMinimumSize;
+ },
+
+ /**
+ * @param {number} width
+ * @param {number} height
+ */
+ setMinimumSize: function(width, height)
+ {
+ this._minimumSize = new Size(width, height);
+ this.invalidateMinimumSize();
+ },
+
+ /**
+ * @return {boolean}
+ */
+ _hasNonZeroMinimumSize: function()
+ {
+ var size = this.minimumSize();
+ return size.width || size.height;
+ },
+
+ invalidateMinimumSize: function()
+ {
+ var cached = this._cachedMinimumSize;
+ delete this._cachedMinimumSize;
+ var actual = this.minimumSize();
+ if (!actual.isEqual(cached) && this._parentView)
+ this._parentView.invalidateMinimumSize();
+ else
+ this.doLayout();
+ },
+
__proto__: WebInspector.Object.prototype
}
@@ -535,6 +605,29 @@ WebInspector.VBox = function()
};
WebInspector.VBox.prototype = {
+ /**
+ * @return {!Size}
+ */
+ calculateMinimumSize: function()
+ {
+ var width = 0;
+ var height = 0;
+
+ /**
+ * @this {!WebInspector.View}
+ * @suppressReceiverCheck
+ */
+ function updateForChild()
+ {
+ var size = this.minimumSize();
+ width = Math.max(width, size.width);
+ height += size.height;
+ }
+
+ this._callOnVisibleChildren(updateForChild);
+ return new Size(width, height);
+ },
+
__proto__: WebInspector.View.prototype
};
@@ -549,6 +642,29 @@ WebInspector.HBox = function()
};
WebInspector.HBox.prototype = {
+ /**
+ * @return {!Size}
+ */
+ calculateMinimumSize: function()
+ {
+ var width = 0;
+ var height = 0;
+
+ /**
+ * @this {!WebInspector.View}
+ * @suppressReceiverCheck
+ */
+ function updateForChild()
+ {
+ var size = this.minimumSize();
+ width += size.width;
+ height = Math.max(height, size.height);
+ }
+
+ this._callOnVisibleChildren(updateForChild);
+ return new Size(width, height);
+ },
+
__proto__: WebInspector.View.prototype
};

Powered by Google App Engine
This is Rietveld 408576698