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

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: 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 8a88e5bd7292ccf2123863be45506261732a9125..1ba56df6f7838b867bfe2bae9e421d68856fbf3b 100644
--- a/Source/devtools/front_end/View.js
+++ b/Source/devtools/front_end/View.js
@@ -276,6 +276,9 @@ WebInspector.View.prototype = {
this._processWasShown();
this._cacheSize();
}
+
+ if (this._parentView)
+ this._parentView.invalidateMinimumSize();
},
/**
@@ -297,6 +300,8 @@ WebInspector.View.prototype = {
this._visible = false;
if (this._parentIsShowing())
this._processWasHidden();
+ if (this._parentView)
+ this._parentView.invalidateMinimumSize();
return;
}
@@ -313,7 +318,9 @@ 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;
+ parent.invalidateMinimumSize();
} else
WebInspector.View._assert(this._isRoot, "Removing non-root view from DOM");
},
@@ -500,6 +507,58 @@ 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 {!Size} size
+ */
+ setMinimumSize: function(size)
+ {
+ this._minimumSize = size;
+ this.invalidateMinimumSize();
+ },
+
+ invalidateMinimumSize: function()
+ {
+ if (!this._isShowing) {
pfeldman 2014/03/14 06:23:10 Are you sure it needs caching? Not caching would m
+ delete this._cachedMinimumSize;
+ if (this._parentView && !this._parentView._isShowing)
+ this._parentView.invalidateMinimumSize();
+ return;
+ }
+
+ var cached = this._cachedMinimumSize;
+ delete this._cachedMinimumSize;
+ var actual = this.minimumSize();
+ if (actual && cached && actual.isEqual(cached)) {
+ this.doResize();
+ return;
+ }
+
+ if (this._parentView)
+ this._parentView.invalidateMinimumSize();
+ else
+ this.doResize();
+ },
+
__proto__: WebInspector.Object.prototype
}
@@ -551,6 +610,33 @@ WebInspector.VBox = function()
};
WebInspector.VBox.prototype = {
+ /**
+ * @return {!Size}
+ */
+ calculateMinimumSize: function()
+ {
+ var width = 0;
+ var height = 0;
+
+ /**
+ * @param {!WebInspector.View} child
+ */
+ function updateForChild(child)
+ {
+ var size = child.minimumSize();
+ width = Math.max(width, size.width);
+ height += size.height;
+ }
+
+ var childViews = this._children.slice();
+ for (var i = 0; i < childViews.length; ++i) {
+ if (childViews[i]._parentView === this && childViews[i]._visible)
pfeldman 2014/03/14 06:23:10 there is a _callOnVisibleChildren that you could u
dgozman 2014/03/14 15:55:15 Done.
+ updateForChild(childViews[i]);
+ }
+
+ return new Size(width, height);
+ },
+
__proto__: WebInspector.View.prototype
};
@@ -565,6 +651,33 @@ WebInspector.HBox = function()
};
WebInspector.HBox.prototype = {
+ /**
+ * @return {!Size}
+ */
+ calculateMinimumSize: function()
+ {
+ var width = 0;
+ var height = 0;
+
+ /**
+ * @param {!WebInspector.View} child
+ */
+ function updateForChild(child)
+ {
+ var size = child.minimumSize();
+ width += size.width;
+ height = Math.max(height, size.height);
+ }
+
+ var childViews = this._children.slice();
+ for (var i = 0; i < childViews.length; ++i) {
+ if (childViews[i]._parentView === this && childViews[i]._visible)
+ updateForChild(childViews[i]);
+ }
+
+ return new Size(width, height);
+ },
+
__proto__: WebInspector.View.prototype
};

Powered by Google App Engine
This is Rietveld 408576698