this._isRoot = true;
},
+ makeLayoutBoundary: function()
+ {
+ this._isLayoutBoundary = true;
+ },
+
/**
* @return {?WebInspector.View}
*/
this._callOnVisibleChildren(this._processOnResize);
},
+ _processDiscardCachedSize: function()
+ {
+ if (this._isLayoutBoundary) {
+ this.element.style.removeProperty("width");
+ this.element.style.removeProperty("height");
+ }
+ this._callOnVisibleChildren(this._processDiscardCachedSize);
+ },
+
+ _cacheSize: function()
+ {
+ this._prepareCacheSize();
+ this._applyCacheSize();
+ },
+
+ _prepareCacheSize: function()
+ {
+ if (this._isLayoutBoundary) {
+ this._cachedOffsetWidth = this.element.offsetWidth;
+ this._cachedOffsetHeight = this.element.offsetHeight;
+ }
+ this._callOnVisibleChildren(this._prepareCacheSize);
+ },
+
+ _applyCacheSize: function()
+ {
+ if (this._isLayoutBoundary) {
+ this.element.style.setProperty("width", this._cachedOffsetWidth + "px");
+ this.element.style.setProperty("height", this._cachedOffsetHeight + "px");
+ delete this._cachedOffsetWidth;
+ delete this._cachedOffsetHeight;
+ }
+ this._callOnVisibleChildren(this._applyCacheSize);
+ },
+
/**
* @param {function(this:WebInspector.View)} notification
*/
WebInspector.View._originalAppendChild.call(parentElement, this.element);
}
- if (this._parentIsShowing())
+ if (this._parentIsShowing()) {
this._processWasShown();
+ this._cacheSize();
+ }
},
/**
if (!parentElement)
return;
- if (this._parentIsShowing())
+ if (this._parentIsShowing()) {
+ this._processDiscardCachedSize();
this._processWillHide();
+ }
if (this._hideOnDetach && !overrideHideOnDetach) {
this.element.classList.remove("visible");
doResize: function()
{
- this._processOnResize();
+ if (!this.isShowing())
+ return;
+ this._processDiscardCachedSize();
+ // No matter what notification we are in, dispatching onResize is not needed.
+ if (!this._inNotification())
+ this._callOnVisibleChildren(this._processOnResize);
+ this._cacheSize();
},
registerRequiredCSS: function(cssFile)
Element.prototype.appendChild = function(child)
{
- WebInspector.View._assert(!child.__view, "Attempt to add view via regular DOM operation.");
+ WebInspector.View._assert(!child.__view || child.parentElement === this, "Attempt to add view via regular DOM operation.");
return WebInspector.View._originalAppendChild.call(this, child);
}
Element.prototype.insertBefore = function(child, anchor)
{
- WebInspector.View._assert(!child.__view, "Attempt to add view via regular DOM operation.");
+ WebInspector.View._assert(!child.__view || child.parentElement === this, "Attempt to add view via regular DOM operation.");
return WebInspector.View._originalInsertBefore.call(this, child, anchor);
}