Web Inspector: Attempting to dismiss a popover that is already being dismissed causes...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 16:05:20 +0000 (16:05 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 16:05:20 +0000 (16:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156385
<rdar://problem/25617962>

Reviewed by Timothy Hatcher.

The Popover element is removed from the DOM once it's fade-out transition
completes. Since Popover.dismiss proceeds as long as it's element has a
parent, successive calls to dismiss can run before the popover is removed.

Rather than rely on the presence of the popover in the DOM, set a "dismissing"
flag the first time dismiss is called, before the fade-out animation begins.

* UserInterface/Controllers/BreakpointPopoverController.js:
(WebInspector.BreakpointPopoverController.prototype._conditionCodeMirrorEscapeOrEnterKey):
Check for null popover.

* UserInterface/Views/Popover.js:
(WebInspector.Popover):
(WebInspector.Popover.prototype.dismiss):
Do nothing if already dismissing.

(WebInspector.Popover.prototype.handleEvent):
Reset dismissing flag after style transition completes.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199227 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js
Source/WebInspectorUI/UserInterface/Views/Popover.js

index 289078d..74b5c7d 100644 (file)
@@ -1,5 +1,32 @@
 2016-04-08  Matt Baker  <mattbaker@apple.com>
 
+        Web Inspector: Attempting to dismiss a popover that is already being dismissed causes an error
+        https://bugs.webkit.org/show_bug.cgi?id=156385
+        <rdar://problem/25617962>
+
+        Reviewed by Timothy Hatcher.
+
+        The Popover element is removed from the DOM once it's fade-out transition
+        completes. Since Popover.dismiss proceeds as long as it's element has a
+        parent, successive calls to dismiss can run before the popover is removed.
+
+        Rather than rely on the presence of the popover in the DOM, set a "dismissing"
+        flag the first time dismiss is called, before the fade-out animation begins.
+
+        * UserInterface/Controllers/BreakpointPopoverController.js:
+        (WebInspector.BreakpointPopoverController.prototype._conditionCodeMirrorEscapeOrEnterKey):
+        Check for null popover.
+
+        * UserInterface/Views/Popover.js:
+        (WebInspector.Popover):
+        (WebInspector.Popover.prototype.dismiss):
+        Do nothing if already dismissing.
+
+        (WebInspector.Popover.prototype.handleEvent):
+        Reset dismissing flag after style transition completes.
+
+2016-04-08  Matt Baker  <mattbaker@apple.com>
+
         Web Inspector: Quick Open fails to match pattern "bB" in file "abBc"
         https://bugs.webkit.org/show_bug.cgi?id=156398
 
index d3b2187..1f0cb0f 100644 (file)
@@ -246,6 +246,9 @@ WebInspector.BreakpointPopoverController = class BreakpointPopoverController ext
 
     _conditionCodeMirrorEscapeOrEnterKey()
     {
+        if (!this._popover)
+            return;
+
         this._popover.dismiss();
     }
 
index d3a0d22..89a136d 100644 (file)
@@ -38,6 +38,7 @@ WebInspector.Popover = class Popover extends WebInspector.Object
         this._preferredEdges = null;
 
         this._contentNeedsUpdate = false;
+        this._dismissing = false;
 
         this._element = document.createElement("div");
         this._element.className = "popover";
@@ -132,9 +133,11 @@ WebInspector.Popover = class Popover extends WebInspector.Object
 
     dismiss()
     {
-        if (this._element.parentNode !== document.body)
+        if (this._dismissing || this._element.parentNode !== document.body)
             return;
 
+        this._dismissing = true;
+
         console.assert(this._isListeningForPopoverEvents);
         this._isListeningForPopoverEvents = false;
         window.removeEventListener("mousedown", this, true);
@@ -161,6 +164,8 @@ WebInspector.Popover = class Popover extends WebInspector.Object
                 this._container.textContent = "";
                 if (this.delegate && typeof this.delegate.didDismissPopover === "function")
                     this.delegate.didDismissPopover(this);
+
+                this._dismissing = false;
                 break;
             }
         }