Commit 7bec67a0 authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Add dispose method to PopoverHelper

The PopoverHelper holds a reference to an external element. The helper
needs to be disposed if the element outlives should outlive the helper.

Change-Id: I58fb02a929a601cadf3472db886517c553a87575
Reviewed-on: https://chromium-review.googlesource.com/949668Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540973}
parent 90621b8d
...@@ -674,6 +674,7 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView { ...@@ -674,6 +674,7 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {
} }
dispose() { dispose() {
this._popoverHelper.dispose();
if (this._allocationStackView) { if (this._allocationStackView) {
this._allocationStackView.clear(); this._allocationStackView.clear();
this._allocationDataGrid.dispose(); this._allocationDataGrid.dispose();
......
...@@ -1567,6 +1567,8 @@ Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame { ...@@ -1567,6 +1567,8 @@ Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame {
* @override * @override
*/ */
dispose() { dispose() {
this._popoverHelper.dispose();
this._breakpointManager.removeEventListener( this._breakpointManager.removeEventListener(
Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this); Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this);
this._breakpointManager.removeEventListener( this._breakpointManager.removeEventListener(
......
...@@ -361,6 +361,7 @@ Sources.UISourceCodeFrame = class extends SourceFrame.SourceFrame { ...@@ -361,6 +361,7 @@ Sources.UISourceCodeFrame = class extends SourceFrame.SourceFrame {
} }
dispose() { dispose() {
this._errorPopoverHelper.dispose();
this._disposePlugins(); this._disposePlugins();
if (this._diff) if (this._diff)
this._diff.dispose(); this._diff.dispose();
......
...@@ -28,9 +28,6 @@ ...@@ -28,9 +28,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/**
* @unrestricted
*/
UI.PopoverHelper = class { UI.PopoverHelper = class {
/** /**
* @param {!Element} container * @param {!Element} container
...@@ -43,9 +40,19 @@ UI.PopoverHelper = class { ...@@ -43,9 +40,19 @@ UI.PopoverHelper = class {
this._scheduledRequest = null; this._scheduledRequest = null;
/** @type {?function()} */ /** @type {?function()} */
this._hidePopoverCallback = null; this._hidePopoverCallback = null;
container.addEventListener('mousedown', this._mouseDown.bind(this), false); this._container = container;
container.addEventListener('mousemove', this._mouseMove.bind(this), false); this._showTimeout = 0;
container.addEventListener('mouseout', this._mouseOut.bind(this), false); this._hideTimeout = 0;
/** @type {?number} */
this._hidePopoverTimer = null;
/** @type {?number} */
this._showPopoverTimer = null;
this._boundMouseDown = this._mouseDown.bind(this);
this._boundMouseMove = this._mouseMove.bind(this);
this._boundMouseOut = this._mouseOut.bind(this);
this._container.addEventListener('mousedown', this._boundMouseDown, false);
this._container.addEventListener('mousemove', this._boundMouseMove, false);
this._container.addEventListener('mouseout', this._boundMouseOut, false);
this.setTimeout(1000); this.setTimeout(1000);
} }
...@@ -150,7 +157,7 @@ UI.PopoverHelper = class { ...@@ -150,7 +157,7 @@ UI.PopoverHelper = class {
this._hidePopoverTimer = setTimeout(() => { this._hidePopoverTimer = setTimeout(() => {
this._hidePopover(); this._hidePopover();
delete this._hidePopoverTimer; this._hidePopoverTimer = null;
}, timeout); }, timeout);
} }
...@@ -164,7 +171,7 @@ UI.PopoverHelper = class { ...@@ -164,7 +171,7 @@ UI.PopoverHelper = class {
return; return;
this._showPopoverTimer = setTimeout(() => { this._showPopoverTimer = setTimeout(() => {
delete this._showPopoverTimer; this._showPopoverTimer = null;
this._stopHidePopoverTimer(); this._stopHidePopoverTimer();
this._hidePopover(); this._hidePopover();
this._showPopover(event.target.ownerDocument); this._showPopover(event.target.ownerDocument);
...@@ -175,7 +182,7 @@ UI.PopoverHelper = class { ...@@ -175,7 +182,7 @@ UI.PopoverHelper = class {
if (!this._showPopoverTimer) if (!this._showPopoverTimer)
return; return;
clearTimeout(this._showPopoverTimer); clearTimeout(this._showPopoverTimer);
delete this._showPopoverTimer; this._showPopoverTimer = null;
} }
/** /**
...@@ -242,12 +249,18 @@ UI.PopoverHelper = class { ...@@ -242,12 +249,18 @@ UI.PopoverHelper = class {
if (!this._hidePopoverTimer) if (!this._hidePopoverTimer)
return; return;
clearTimeout(this._hidePopoverTimer); clearTimeout(this._hidePopoverTimer);
delete this._hidePopoverTimer; this._hidePopoverTimer = null;
// We know that we reached the popup, but we might have moved over other elements. // We know that we reached the popup, but we might have moved over other elements.
// Discard pending command. // Discard pending command.
this._stopShowPopoverTimer(); this._stopShowPopoverTimer();
} }
dispose() {
this._container.removeEventListener('mousedown', this._boundMouseDown, false);
this._container.removeEventListener('mousemove', this._boundMouseMove, false);
this._container.removeEventListener('mouseout', this._boundMouseOut, false);
}
}; };
/** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>), hide:(function()|undefined)}} */ /** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>), hide:(function()|undefined)}} */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment