Title: [239051] trunk/Source/WebInspectorUI
Revision
239051
Author
[email protected]
Date
2018-12-10 14:03:13 -0800 (Mon, 10 Dec 2018)

Log Message

Web Inspector: Move TreeOutlineGroup coordination out of TreeElement
https://bugs.webkit.org/show_bug.cgi?id=192487
<rdar://problem/46543431>

Reviewed by Devin Rousso.

* UserInterface/Views/TreeElement.js:
(WI.TreeElement.prototype.select):
(WI.TreeElement.prototype.deselect):

* UserInterface/Views/TreeOutlineGroup.js:
(WI.TreeOutlineGroup):
(WI.TreeOutlineGroup.prototype.itemAdded):
(WI.TreeOutlineGroup.prototype.itemRemoved):
(WI.TreeOutlineGroup.prototype._removeConflictingTreeSelections):
(WI.TreeOutlineGroup.prototype._treeOutlineSelectionDidChange):
(WI.TreeOutlineGroup.groupForTreeOutline): Deleted.
(WI.TreeOutlineGroup.prototype.didSelectTreeElement): Deleted.
make the group responsible for listening to selection changes from the
TreeOutlines it manages, and synchronizing the selection between them.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (239050 => 239051)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-12-10 21:55:56 UTC (rev 239050)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-12-10 22:03:13 UTC (rev 239051)
@@ -1,3 +1,26 @@
+2018-12-10  Matt Baker  <[email protected]>
+
+        Web Inspector: Move TreeOutlineGroup coordination out of TreeElement
+        https://bugs.webkit.org/show_bug.cgi?id=192487
+        <rdar://problem/46543431>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/TreeElement.js:
+        (WI.TreeElement.prototype.select):
+        (WI.TreeElement.prototype.deselect):
+
+        * UserInterface/Views/TreeOutlineGroup.js:
+        (WI.TreeOutlineGroup):
+        (WI.TreeOutlineGroup.prototype.itemAdded):
+        (WI.TreeOutlineGroup.prototype.itemRemoved):
+        (WI.TreeOutlineGroup.prototype._removeConflictingTreeSelections):
+        (WI.TreeOutlineGroup.prototype._treeOutlineSelectionDidChange):
+        (WI.TreeOutlineGroup.groupForTreeOutline): Deleted.
+        (WI.TreeOutlineGroup.prototype.didSelectTreeElement): Deleted.
+        make the group responsible for listening to selection changes from the
+        TreeOutlines it manages, and synchronizing the selection between them.
+
 2018-12-10  Dean Jackson  <[email protected]>
 
         Use text/_javascript_ as recommended by the HTML specification

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js (239050 => 239051)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js	2018-12-10 21:55:56 UTC (rev 239050)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js	2018-12-10 22:03:13 UTC (rev 239051)
@@ -516,12 +516,6 @@
 
         this.selected = true;
         treeOutline.selectTreeElementInternal(this, suppressNotification, selectedByUser);
-
-        let treeOutlineGroup = WI.TreeOutlineGroup.groupForTreeOutline(treeOutline);
-        if (!treeOutlineGroup)
-            return;
-
-        treeOutlineGroup.didSelectTreeElement(this);
     }
 
     revealAndSelect(omitFocus, selectedByUser, suppressNotification)
@@ -535,8 +529,6 @@
         if (!this.treeOutline || !this.selected)
             return false;
 
-        console.assert(this.treeOutline.selectedTreeElements.includes(this));
-
         this.selected = false;
         this.treeOutline.selectTreeElementInternal(null, suppressNotification);
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js (239050 => 239051)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js	2018-12-10 21:55:56 UTC (rev 239050)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js	2018-12-10 22:03:13 UTC (rev 239051)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017, 2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,13 +25,6 @@
 
 WI.TreeOutlineGroup = class TreeOutlineGroup extends WI.Collection
 {
-    // Static
-
-    static groupForTreeOutline(treeOutline)
-    {
-        return treeOutline[WI.TreeOutlineGroup.GroupForTreeOutlineSymbol] || null;
-    }
-
     // Public
 
     objectIsRequiredType(object)
@@ -53,36 +46,21 @@
 
     itemAdded(treeOutline)
     {
-        console.assert(!treeOutline[WI.TreeOutlineGroup.GroupForTreeOutlineSymbol]);
-        treeOutline[WI.TreeOutlineGroup.GroupForTreeOutlineSymbol] = this;
+        if (treeOutline.selectedTreeElement)
+            this._removeConflictingTreeSelections(treeOutline);
 
-        if (treeOutline.selectedTreeElement)
-            this._removeConflictingTreeSelections(treeOutline.selectedTreeElement);
+        treeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeOutlineSelectionDidChange, this);
     }
 
     itemRemoved(treeOutline)
     {
-        console.assert(treeOutline[WI.TreeOutlineGroup.GroupForTreeOutlineSymbol] === this);
-        treeOutline[WI.TreeOutlineGroup.GroupForTreeOutlineSymbol] = null;
+        treeOutline.removeEventListener(null, null, this);
     }
 
-    didSelectTreeElement(treeElement)
-    {
-        // Called by TreeOutline.
-
-        if (!treeElement)
-            return;
-
-        this._removeConflictingTreeSelections(treeElement);
-    }
-
     // Private
 
-    _removeConflictingTreeSelections(treeElement)
+    _removeConflictingTreeSelections(selectedTreeOutline)
     {
-        let selectedTreeOutline = treeElement.treeOutline;
-        console.assert(selectedTreeOutline, "Should have a parent tree outline.");
-
         for (let treeOutline of this) {
             if (selectedTreeOutline === treeOutline)
                 continue;
@@ -90,6 +68,13 @@
             treeOutline.selectedTreeElement = null;
         }
     }
+
+    _treeOutlineSelectionDidChange(event)
+    {
+        let treeOutline = event.target;
+        if (!treeOutline.selectedTreeElement)
+            return;
+
+        this._removeConflictingTreeSelections(treeOutline);
+    }
 };
-
-WI.TreeOutlineGroup.GroupForTreeOutlineSymbol = Symbol("group-for-tree-outline");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to