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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/Widget.js

Issue 2170063002: Revert of DevTools: keep widgets in widget hierarchy upon hide, split attach/detach cycle from show… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5f7f7aa8d339bf4316a63035c01bcd7459355cc5..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,7 +41,7 @@ WebInspector.Widget = function(isWebComponent)
}
this._isWebComponent = isWebComponent;
this.element.__widget = this;
- this._visible = false;
+ this._visible = true;
this._isRoot = false;
this._isShowing = false;
this._children = [];
@@ -119,7 +119,7 @@ WebInspector.Widget.prototype = {
{
if (this._isRoot)
return true;
- return !!this._parentWidget && this._parentWidget.isShowing();
+ return this._parentWidget && this._parentWidget.isShowing();
},
/**
@@ -210,48 +210,27 @@ WebInspector.Widget.prototype = {
*/
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 (this.element.parentElement !== parentElement) {
+ if (this.element.parentElement)
+ this.detach();
- if (newParentWidget) {
- if (this._parentWidget !== newParentWidget) {
- this._parentWidget = newParentWidget;
+ 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._isRoot = false;
+ } else
+ WebInspector.Widget.__assert(this._isRoot, "Attempt to attach widget to orphan node");
+ } else if (this._visible) {
+ return;
}
- this._parentElement = parentElement;
- this._insertBeforeElement = insertBefore;
- },
-
- showWidget: function()
- {
- WebInspector.Widget.__assert(this._parentElement, "Attempt to show detached widget");
- if (this._visible)
- return;
this._visible = true;
if (this._parentIsShowing())
@@ -260,12 +239,12 @@ WebInspector.Widget.prototype = {
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())
@@ -277,51 +256,35 @@ WebInspector.Widget.prototype = {
this._processOnResize();
},
- hideWidget: function()
- {
- this._hideWidget();
- },
-
/**
* @param {boolean=} overrideHideOnDetach
- * @return {boolean}
*/
- _hideWidget: function(overrideHideOnDetach)
+ detach: function(overrideHideOnDetach)
{
- WebInspector.Widget.__assert(this._parentElement, "Attempt to hide detached widget");
- if (!this._visible)
- return false;
- this._visible = false;
- var parentElement = this._parentElement;
+ var parentElement = this.element.parentElement;
+ if (!parentElement)
+ return;
if (this._parentIsShowing())
this._processWillHide();
if (!overrideHideOnDetach && this.shouldHideOnDetach()) {
this.element.classList.add("hidden");
+ this._visible = false;
if (this._parentIsShowing())
this._processWasHidden();
if (this._parentWidget && this._hasNonZeroConstraints())
this._parentWidget.invalidateConstraints();
- return true;
+ 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();
- return true;
- },
-
- detach: function()
- {
- if (!this._parentWidget)
- return;
- var wasShown = this._hideWidget(true);
- if (!wasShown)
- return;
// Update widget hierarchy.
if (this._parentWidget) {
@@ -331,13 +294,10 @@ WebInspector.Widget.prototype = {
this._parentWidget.childWasDetached(this);
var parent = this._parentWidget;
this._parentWidget = null;
- this._parentElement = null;
- this._insertBeforeElement = null;
if (this._hasNonZeroConstraints())
parent.invalidateConstraints();
- } else {
+ } else
WebInspector.Widget.__assert(this._isRoot, "Removing non-root widget from DOM");
- }
},
detachChildWidgets: function()
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698