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

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

Issue 2570633004: DevTools: remove invalidateSize from Widget, make show/hideWidget receive no params. (Closed)
Patch Set: review comments addressed Created 4 years 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 b355d80f4024acf562547e207a58dc8ad25b1bf0..825ca18813b4e8fce220c99921077f91ada7354d 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
@@ -247,7 +247,7 @@ UI.Widget = class extends Common.Object {
/**
* @param {!Element} parentElement
- * @param {?Element=} insertBefore
+ * @param {?Node=} insertBefore
*/
show(parentElement, insertBefore) {
UI.Widget.__assert(parentElement, 'Attempt to attach widget with no parent element');
@@ -258,30 +258,43 @@ UI.Widget = class extends Common.Object {
while (currentParent && !currentParent.__widget)
currentParent = currentParent.parentElementOrShadowHost();
UI.Widget.__assert(currentParent, 'Attempt to attach widget to orphan node');
- this.attach(currentParent.__widget);
+ this.attach(currentParent.__widget, parentElement, insertBefore);
+ } else {
+ this._attachedToParentElement = parentElement;
+ this._attachedBeforeNode = insertBefore;
}
- this.showWidget(parentElement, insertBefore);
+ this.showWidget();
}
/**
* @param {!UI.Widget} parentWidget
- */
- attach(parentWidget) {
- if (parentWidget === this._parentWidget)
+ * @param {!Element=} parentElement
+ * @param {?Node=} insertBefore
+ */
+ attach(parentWidget, parentElement, insertBefore) {
+ parentElement = parentElement || parentWidget.element;
+ if (parentWidget === this._parentWidget) {
+ this._attachedToParentElement = parentElement;
+ this._attachedBeforeNode = insertBefore;
+ if (this._visible)
+ this.showWidget();
return;
+ }
if (this._parentWidget)
this.detach();
this._parentWidget = parentWidget;
this._parentWidget._children.push(this);
+ this._attachedToParentElement = parentElement;
+ this._attachedBeforeNode = insertBefore;
this._isRoot = false;
}
- /**
- * @param {!Element} parentElement
- * @param {?Element=} insertBefore
- */
- showWidget(parentElement, insertBefore) {
+ showWidget() {
+ UI.Widget.__assert(this._parentWidget || this._isRoot, 'Attempt to show widget that has not been attached');
+ var parentElement = this._attachedToParentElement;
+ var insertBefore = this._attachedBeforeNode;
+
var currentParent = parentElement;
while (currentParent && !currentParent.__widget)
currentParent = currentParent.parentElementOrShadowHost();
@@ -324,8 +337,7 @@ UI.Widget = class extends Common.Object {
}
hideWidget() {
- if (!this._parentWidget)
- return;
+ UI.Widget.__assert(this._parentWidget || this._isRoot, 'Attempt to hide widget that has not been attached');
this._hideWidget();
}
@@ -337,6 +349,8 @@ UI.Widget = class extends Common.Object {
return;
this._visible = false;
var parentElement = this.element.parentElement;
+ this._attachedToParentElement = parentElement;
+ this._attachedBeforeNode = this.element.nextSibling;
if (this._parentIsShowing())
this._processWillHide();
@@ -376,6 +390,9 @@ UI.Widget = class extends Common.Object {
} else {
UI.Widget.__assert(this._isRoot, 'Removing non-root widget from DOM');
}
+
+ this._attachedToParentElement = null;
+ this._attachedBeforeNode = null;
}
detachChildWidgets() {
@@ -586,11 +603,6 @@ UI.Widget = class extends Common.Object {
else
this.doLayout();
}
-
- invalidateSize() {
- if (this._parentWidget)
- this._parentWidget.doLayout();
- }
};
UI.Widget._originalAppendChild = Element.prototype.appendChild;
« 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