<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[243722] trunk/Source/WebInspectorUI</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/243722">243722</a></dd>
<dt>Author</dt> <dd>drousso@apple.com</dd>
<dt>Date</dt> <dd>2019-04-01 16:38:45 -0700 (Mon, 01 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: DOMDebugger: disabling a breakpoint for a specific event listener removes it from the UI
https://bugs.webkit.org/show_bug.cgi?id=196453
<rdar://problem/49489318>

Reviewed by Joseph Pecoraro.

Allow breakpoints for specific event listeners to be disabled, rather than immeditately
removing/deleting them when they are about to become disabled. This preserves the existing
functionality, but now allows for the tree element to stay in the UI in a disabled state.

* UserInterface/Controllers/DOMManager.js:
(WI.DOMManager):
(WI.DOMManager.prototype.setBreakpointForEventListener):
(WI.DOMManager.prototype.removeBreakpointForEventListener):
(WI.DOMManager.prototype.removeEventListenerBreakpointsForNode): Added.
(WI.DOMManager.prototype._updateEventBreakpoint): Added.
(WI.DOMManager.prototype._handleEventBreakpointDisabledStateChanged): Added.

* UserInterface/Controllers/DOMDebuggerManager.js:
(WI.DOMDebuggerManager.prototype._handleEventBreakpointDisabledStateChanged):

* UserInterface/Views/EventBreakpointTreeElement.js:
(WI.EventBreakpointTreeElement.prototype.populateContextMenu):
(WI.EventBreakpointTreeElement.prototype._toggleBreakpoint):

* UserInterface/Views/ContextMenuUtilities.js:
(WI.appendContextMenuItemsForDOMNodeBreakpoints):

* UserInterface/Views/DOMNodeTreeElement.js:
(WI.DOMNodeTreeElement.prototype.ondelete):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDOMDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDOMManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsContextMenuUtilitiesjs">trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDOMNodeTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeTreeElement.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsEventBreakpointTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/ChangeLog       2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -1,5 +1,38 @@
</span><span class="cx"> 2019-04-01  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        Web Inspector: DOMDebugger: disabling a breakpoint for a specific event listener removes it from the UI
+        https://bugs.webkit.org/show_bug.cgi?id=196453
+        <rdar://problem/49489318>
+
+        Reviewed by Joseph Pecoraro.
+
+        Allow breakpoints for specific event listeners to be disabled, rather than immeditately
+        removing/deleting them when they are about to become disabled. This preserves the existing
+        functionality, but now allows for the tree element to stay in the UI in a disabled state.
+
+        * UserInterface/Controllers/DOMManager.js:
+        (WI.DOMManager):
+        (WI.DOMManager.prototype.setBreakpointForEventListener):
+        (WI.DOMManager.prototype.removeBreakpointForEventListener):
+        (WI.DOMManager.prototype.removeEventListenerBreakpointsForNode): Added.
+        (WI.DOMManager.prototype._updateEventBreakpoint): Added.
+        (WI.DOMManager.prototype._handleEventBreakpointDisabledStateChanged): Added.
+
+        * UserInterface/Controllers/DOMDebuggerManager.js:
+        (WI.DOMDebuggerManager.prototype._handleEventBreakpointDisabledStateChanged):
+
+        * UserInterface/Views/EventBreakpointTreeElement.js:
+        (WI.EventBreakpointTreeElement.prototype.populateContextMenu):
+        (WI.EventBreakpointTreeElement.prototype._toggleBreakpoint):
+
+        * UserInterface/Views/ContextMenuUtilities.js:
+        (WI.appendContextMenuItemsForDOMNodeBreakpoints):
+
+        * UserInterface/Views/DOMNodeTreeElement.js:
+        (WI.DOMNodeTreeElement.prototype.ondelete):
+
+2019-04-01  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Web Inspector: Canvas: auto-record after page load sometimes shows the wrong UI
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=196320
</span><span class="cx">         <rdar://problem/49356686>
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDOMDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js      2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js 2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -554,6 +554,11 @@
</span><span class="cx">     _handleEventBreakpointDisabledStateChanged(event)
</span><span class="cx">     {
</span><span class="cx">         let breakpoint = event.target;
</span><ins>+
+        // Specific event listener breakpoints are handled by `DOMManager`.
+        if (breakpoint.eventListener)
+            return;
+
</ins><span class="cx">         for (let target of WI.targets) {
</span><span class="cx">             if (target.DOMDebuggerAgent)
</span><span class="cx">                 this._updateEventBreakpoint(breakpoint, target);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDOMManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js      2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js 2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -50,6 +50,8 @@
</span><span class="cx">         this._hasRequestedDocument = false;
</span><span class="cx">         this._pendingDocumentRequestCallbacks = null;
</span><span class="cx"> 
</span><ins>+        WI.EventBreakpoint.addEventListener(WI.EventBreakpoint.Event.DisabledStateChanged, this._handleEventBreakpointDisabledStateChanged, this);
+
</ins><span class="cx">         WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -592,34 +594,46 @@
</span><span class="cx"> 
</span><span class="cx">     setBreakpointForEventListener(eventListener)
</span><span class="cx">     {
</span><del>-        let breakpoint = new WI.EventBreakpoint(WI.EventBreakpoint.Type.Listener, eventListener.type, {eventListener});
</del><ins>+        let breakpoint = this._breakpointsForEventListeners.get(eventListener.eventListenerId);
+        if (breakpoint) {
+            console.assert(breakpoint.disabled);
+            breakpoint.disabled = false;
+            return;
+        }
+
+        breakpoint = new WI.EventBreakpoint(WI.EventBreakpoint.Type.Listener, eventListener.type, {eventListener});
+        console.assert(!breakpoint.disabled);
+
</ins><span class="cx">         this._breakpointsForEventListeners.set(eventListener.eventListenerId, breakpoint);
</span><span class="cx"> 
</span><del>-        DOMAgent.setBreakpointForEventListener(eventListener.eventListenerId, (error) => {
-            if (error) {
-                console.error(error);
-                return;
-            }
</del><ins>+        for (let target of WI.targets) {
+            if (target.DOMAgent)
+                this._updateEventBreakpoint(breakpoint, target);
+        }
</ins><span class="cx"> 
</span><del>-            WI.domDebuggerManager.dispatchEventToListeners(WI.DOMDebuggerManager.Event.EventBreakpointAdded, {breakpoint});
-        });
</del><ins>+        WI.domDebuggerManager.dispatchEventToListeners(WI.DOMDebuggerManager.Event.EventBreakpointAdded, {breakpoint});
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     removeBreakpointForEventListener(eventListener)
</span><span class="cx">     {
</span><del>-        let breakpoint = this._breakpointsForEventListeners.get(eventListener.eventListenerId);
</del><ins>+        let breakpoint = this._breakpointsForEventListeners.take(eventListener.eventListenerId);
</ins><span class="cx">         console.assert(breakpoint);
</span><span class="cx"> 
</span><del>-        this._breakpointsForEventListeners.delete(eventListener.eventListenerId);
</del><ins>+        for (let target of WI.targets) {
+            if (target.DOMAgent)
+                target.DOMAgent.removeBreakpointForEventListener(eventListener.eventListenerId);
+        }
</ins><span class="cx"> 
</span><del>-        DOMAgent.removeBreakpointForEventListener(eventListener.eventListenerId, (error) => {
-            if (error) {
-                console.error(error);
-                return;
-            }
</del><ins>+        WI.domDebuggerManager.dispatchEventToListeners(WI.DOMDebuggerManager.Event.EventBreakpointRemoved, {breakpoint});
+    }
</ins><span class="cx"> 
</span><del>-            WI.domDebuggerManager.dispatchEventToListeners(WI.DOMDebuggerManager.Event.EventBreakpointRemoved, {breakpoint});
-        });
</del><ins>+    removeEventListenerBreakpointsForNode(domNode)
+    {
+        for (let breakpoint of Array.from(this._breakpointsForEventListeners.values())) {
+            let eventListener = breakpoint.eventListener;
+            if (eventListener.nodeId === domNode.id)
+                this.removeBreakpointForEventListener(eventListener);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     breakpointForEventListenerId(eventListenerId)
</span><span class="lines">@@ -627,6 +641,8 @@
</span><span class="cx">         return this._breakpointsForEventListeners.get(eventListenerId) || null;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Private
+
</ins><span class="cx">     _buildHighlightConfig(mode = "all")
</span><span class="cx">     {
</span><span class="cx">         let highlightConfig = {showInfo: mode === "all"};
</span><span class="lines">@@ -646,8 +662,31 @@
</span><span class="cx">         return highlightConfig;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Private
</del><ins>+    _updateEventBreakpoint(breakpoint, target)
+    {
+        let eventListener = breakpoint.eventListener;
+        console.assert(eventListener);
</ins><span class="cx"> 
</span><ins>+        if (breakpoint.disabled)
+            target.DOMAgent.removeBreakpointForEventListener(eventListener.eventListenerId);
+        else
+            target.DOMAgent.setBreakpointForEventListener(eventListener.eventListenerId);
+    }
+
+    _handleEventBreakpointDisabledStateChanged(event)
+    {
+        let breakpoint = event.target;
+
+        // Non-specific event listener breakpoints are handled by `DOMDebuggerManager`.
+        if (!breakpoint.eventListener)
+            return;
+
+        for (let target of WI.targets) {
+            if (target.DOMAgent)
+                this._updateEventBreakpoint(breakpoint, target);
+        }
+    }
+
</ins><span class="cx">     _mainResourceDidChange(event)
</span><span class="cx">     {
</span><span class="cx">         if (!event.target.isMainFrame())
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsContextMenuUtilitiesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js  2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js     2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -306,6 +306,7 @@
</span><span class="cx"> 
</span><span class="cx">         contextMenu.appendItem(WI.UIString("Delete Breakpoints"), function() {
</span><span class="cx">             WI.domDebuggerManager.removeDOMBreakpointsForNode(domNode);
</span><ins>+            WI.domManager.removeEventListenerBreakpointsForNode(domNode);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDOMNodeTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeTreeElement.js (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeTreeElement.js    2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeTreeElement.js       2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -46,12 +46,8 @@
</span><span class="cx">         this.__deletedViaDeleteKeyboardShortcut = true;
</span><span class="cx"> 
</span><span class="cx">         WI.domDebuggerManager.removeDOMBreakpointsForNode(this.representedObject);
</span><ins>+        WI.domManager.removeEventListenerBreakpointsForNode(this.representedObject);
</ins><span class="cx"> 
</span><del>-        for (let treeElement of this.children) {
-            if (treeElement instanceof WI.EventBreakpointTreeElement)
-                treeElement.ondelete();
-        }
-
</del><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsEventBreakpointTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.js (243721 => 243722)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.js    2019-04-01 23:13:11 UTC (rev 243721)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.js       2019-04-01 23:38:45 UTC (rev 243722)
</span><span class="lines">@@ -110,11 +110,10 @@
</span><span class="cx">     populateContextMenu(contextMenu, event)
</span><span class="cx">     {
</span><span class="cx">         let breakpoint = this.representedObject;
</span><del>-        if (!breakpoint.eventListener) {
-            let label = breakpoint.disabled ? WI.UIString("Enable Breakpoint") : WI.UIString("Disable Breakpoint");
-            contextMenu.appendItem(label, this._toggleBreakpoint.bind(this));
-        }
</del><span class="cx"> 
</span><ins>+        let label = breakpoint.disabled ? WI.UIString("Enable Breakpoint") : WI.UIString("Disable Breakpoint");
+        contextMenu.appendItem(label, this._toggleBreakpoint.bind(this));
+
</ins><span class="cx">         contextMenu.appendSeparator();
</span><span class="cx"> 
</span><span class="cx">         contextMenu.appendItem(WI.UIString("Delete Breakpoint"), () => {
</span><span class="lines">@@ -146,11 +145,6 @@
</span><span class="cx"> 
</span><span class="cx">     _toggleBreakpoint()
</span><span class="cx">     {
</span><del>-        if (this.representedObject.eventListener) {
-            WI.domManager.removeBreakpointForEventListener(this.representedObject.eventListener);
-            return;
-        }
-
</del><span class="cx">         this.representedObject.disabled = !this.representedObject.disabled;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>