Index: third_party/WebKit/Source/devtools/front_end/ui/Widget.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js |
index cf6f9ceb3112efef51f10279026a7e855bee6ea4..5558f589144f8b9e4e97f525bef41f9e0d87a232 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js |
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js |
@@ -41,13 +41,12 @@ |
} |
this._isWebComponent = isWebComponent; |
this.element.__widget = this; |
- this._visible = false; |
+ this._visible = true; |
this._isRoot = false; |
this._isShowing = false; |
this._children = []; |
this._hideOnDetach = false; |
this._notificationDepth = 0; |
- this._invalidationsSuspended = 0; |
} |
WebInspector.Widget.prototype = { |
@@ -120,7 +119,7 @@ |
{ |
if (this._isRoot) |
return true; |
- return !!this._parentWidget && this._parentWidget.isShowing(); |
+ return this._parentWidget && this._parentWidget.isShowing(); |
}, |
/** |
@@ -206,53 +205,32 @@ |
}, |
/** |
- * @param {!Element} parentElement |
+ * @param {?Element} parentElement |
* @param {?Element=} insertBefore |
*/ |
show: function(parentElement, insertBefore) |
{ |
- this.attach(parentElement, insertBefore); |
- this.showWidget(); |
- }, |
- |
- /** |
- * @param {!Element} parentElement |
- * @param {?Element=} insertBefore |
- */ |
- attach: function(parentElement, insertBefore) |
- { |
WebInspector.Widget.__assert(parentElement, "Attempt to attach widget with no parent element"); |
// Update widget hierarchy. |
- var currentParent = parentElement; |
- while (currentParent && !currentParent.__widget) |
- currentParent = currentParent.parentElementOrShadowHost(); |
- var newParentWidget = currentParent ? currentParent.__widget : null; |
- |
- if (this._parentWidget && newParentWidget !== this._parentWidget) { |
- // Reparent. |
- this.detach(); |
- } |
- |
- if (newParentWidget) { |
- if (this._parentWidget !== newParentWidget) { |
- this._parentWidget = newParentWidget; |
+ if (this.element.parentElement !== parentElement) { |
+ if (this.element.parentElement) |
+ this.detach(); |
+ |
+ var currentParent = parentElement; |
+ while (currentParent && !currentParent.__widget) |
+ currentParent = currentParent.parentElementOrShadowHost(); |
+ |
+ if (currentParent) { |
+ this._parentWidget = currentParent.__widget; |
this._parentWidget._children.push(this); |
- } |
- this._isRoot = false; |
- } else { |
- WebInspector.Widget.__assert(this._isRoot, "Attempt to attach widget to orphan node"); |
- } |
- |
- this._parentElement = parentElement; |
- this._insertBeforeElement = insertBefore; |
- }, |
- |
- showWidget: function() |
- { |
- WebInspector.Widget.__assert(this._parentElement, "Attempt to show detached widget"); |
- if (this._visible) |
- return; |
+ this._isRoot = false; |
+ } else |
+ WebInspector.Widget.__assert(this._isRoot, "Attempt to attach widget to orphan node"); |
+ } else if (this._visible) { |
+ return; |
+ } |
+ |
this._visible = true; |
if (this._parentIsShowing()) |
@@ -261,12 +239,12 @@ |
this.element.classList.remove("hidden"); |
// Reparent |
- if (this.element.parentElement !== this._parentElement) { |
- WebInspector.Widget._incrementWidgetCounter(this._parentElement, this.element); |
- if (this._insertBeforeElement) |
- WebInspector.Widget._originalInsertBefore.call(this._parentElement, this.element, this._insertBeforeElement); |
+ if (this.element.parentElement !== parentElement) { |
+ WebInspector.Widget._incrementWidgetCounter(parentElement, this.element); |
+ if (insertBefore) |
+ WebInspector.Widget._originalInsertBefore.call(parentElement, this.element, insertBefore); |
else |
- WebInspector.Widget._originalAppendChild.call(this._parentElement, this.element); |
+ WebInspector.Widget._originalAppendChild.call(parentElement, this.element); |
} |
if (this._parentIsShowing()) |
@@ -278,48 +256,35 @@ |
this._processOnResize(); |
}, |
- hideWidget: function() |
- { |
- if (!this._parentWidget) |
- return; |
- this._hideWidget(); |
- }, |
- |
/** |
* @param {boolean=} overrideHideOnDetach |
*/ |
- _hideWidget: function(overrideHideOnDetach) |
- { |
- WebInspector.Widget.__assert(this._parentElement, "Attempt to hide detached widget"); |
- if (!this._visible) |
- return; |
- this._visible = false; |
- var parentElement = this._parentElement; |
+ detach: function(overrideHideOnDetach) |
+ { |
+ var parentElement = this.element.parentElement; |
+ if (!parentElement) |
+ return; |
if (this._parentIsShowing()) |
this._processWillHide(); |
if (!overrideHideOnDetach && this.shouldHideOnDetach()) { |
this.element.classList.add("hidden"); |
- } else { |
- // Force legal removal |
- WebInspector.Widget._decrementWidgetCounter(parentElement, this.element); |
- WebInspector.Widget._originalRemoveChild.call(parentElement, this.element); |
- } |
- |
+ this._visible = false; |
+ if (this._parentIsShowing()) |
+ this._processWasHidden(); |
+ if (this._parentWidget && this._hasNonZeroConstraints()) |
+ this._parentWidget.invalidateConstraints(); |
+ return; |
+ } |
+ |
+ // Force legal removal |
+ WebInspector.Widget._decrementWidgetCounter(parentElement, this.element); |
+ WebInspector.Widget._originalRemoveChild.call(parentElement, this.element); |
+ |
+ this._visible = false; |
if (this._parentIsShowing()) |
this._processWasHidden(); |
- if (this._hasNonZeroConstraints()) |
- this._parentWidget.invalidateConstraints(); |
- }, |
- |
- detach: function() |
- { |
- if (!this._parentWidget) |
- return; |
- |
- if (this._visible) |
- this._hideWidget(true); |
// Update widget hierarchy. |
if (this._parentWidget) { |
@@ -329,11 +294,10 @@ |
this._parentWidget.childWasDetached(this); |
var parent = this._parentWidget; |
this._parentWidget = null; |
- this._parentElement = null; |
- this._insertBeforeElement = null; |
- } else { |
+ if (this._hasNonZeroConstraints()) |
+ parent.invalidateConstraints(); |
+ } else |
WebInspector.Widget.__assert(this._isRoot, "Removing non-root widget from DOM"); |
- } |
}, |
detachChildWidgets: function() |
@@ -515,25 +479,8 @@ |
return !!(constraints.minimum.width || constraints.minimum.height || constraints.preferred.width || constraints.preferred.height); |
}, |
- suspendInvalidations() |
- { |
- ++this._invalidationsSuspended; |
- }, |
- |
- resumeInvalidations() |
- { |
- --this._invalidationsSuspended; |
- if (!this._invalidationsSuspended && this._invalidationsRequested) |
- this.invalidateConstraints(); |
- }, |
- |
invalidateConstraints: function() |
{ |
- if (this._invalidationsSuspended) { |
- this._invalidationsRequested = true; |
- return; |
- } |
- this._invalidationsRequested = false; |
var cached = this._cachedConstraints; |
delete this._cachedConstraints; |
var actual = this.constraints(); |