Web Inspector: replace TypeVerifier with subclasses of WI.Collection
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2017 23:49:05 +0000 (23:49 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2017 23:49:05 +0000 (23:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178045
<rdar://problem/35174307>

Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Models/Collection.js:
(WI.Collection):
(WI.Collection.prototype.get displayName):
(WI.Collection.prototype.objectIsRequiredType):
(WI.Collection.prototype.add):
(WI.Collection.prototype.get typeVerifier): Deleted.
Instead of exposing the typeVerifier, we create a public predicate that returns whether the
given object matches the expected type of the Collection. Subclasses can override it to
limit the scope of the collection to a particular type.

* UserInterface/Models/CollectionTypes.js:
(WI.FrameCollection.prototype.get displayName):
(WI.FrameCollection.prototype.objectIsRequiredType):
(WI.FrameCollection): Deleted.
(WI.ScriptCollection.prototype.get displayName):
(WI.ScriptCollection.prototype.objectIsRequiredType):
(WI.ScriptCollection): Deleted.
(WI.CSSStyleSheetCollection.prototype.get displayName):
(WI.CSSStyleSheetCollection.prototype.objectIsRequiredType):
(WI.CSSStyleSheetCollection): Deleted.
(WI.CanvasCollection.prototype.get displayName):
(WI.CanvasCollection.prototype.objectIsRequiredType):
(WI.CanvasCollection): Deleted.
(WI.ShaderProgramCollection.prototype.get displayName):
(WI.ShaderProgramCollection.prototype.objectIsRequiredType):
(WI.ShaderProgramCollection): Deleted.
(WI.RecordingCollection.prototype.get displayName):
(WI.RecordingCollection.prototype.objectIsRequiredType):
(WI.RecordingCollection): Deleted.
* UserInterface/Models/ResourceCollection.js:
(WI.ResourceCollection):
(WI.ResourceCollection.prototype.get displayName):
(WI.ResourceCollection.prototype.objectIsRequiredType):
(WI.ResourceCollection.verifierForType): Deleted.
* UserInterface/Views/TreeOutlineGroup.js:
(WI.TreeOutlineGroup.prototype.objectIsRequiredType):
(WI.TreeOutlineGroup): Deleted.
Introduce additional subclasses of Collection for other model types. Modify existing
subclasses to remove `typeVerifier` and instead extend `objectIsRequiredType`.

* UserInterface/Models/Canvas.js:
(WI.Canvas):
* UserInterface/Models/Frame.js:
(WI.Frame):
* UserInterface/Protocol/Target.js:
(WI.Target):
* UserInterface/Views/ResourceSidebarPanel.js:
(WI.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
(WI.ResourceSidebarPanel.prototype._addScript):

* UserInterface/Views/CollectionContentView.js:
(WI.CollectionContentView):
(WI.CollectionContentView.titleForCollection): Delete.
* UserInterface/Views/ResourceCollectionContentView.js:
(WI.ResourceCollectionContentView):
Require that subclasses of Collection override `get displayName` if the CollectionContentView
is not provided with a `contentPlaceholderText`.

(WI.CollectionContentView.prototype.initialLayout):
We don't need to create and add ContentView for each item of the Collection, as this is
already done by attached().

(WI.CollectionContentView.prototype._showContentPlaceholder):
Remove the 250ms delay before showing the placeholder TitleView.

* UserInterface/Views/FolderizedTreeElement.js:
(WI.FolderizedTreeElement.prototype._settingsForRepresentedObject):

LayoutTests:

* inspector/unit-tests/collection-expected.txt:
* inspector/unit-tests/collection.html:

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/unit-tests/collection-expected.txt
LayoutTests/inspector/unit-tests/collection.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Models/Canvas.js
Source/WebInspectorUI/UserInterface/Models/Collection.js
Source/WebInspectorUI/UserInterface/Models/CollectionTypes.js
Source/WebInspectorUI/UserInterface/Models/Frame.js
Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js
Source/WebInspectorUI/UserInterface/Protocol/Target.js
Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js
Source/WebInspectorUI/UserInterface/Views/FolderizedTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ResourceCollectionContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js

index f849672..2c6fc51 100644 (file)
@@ -1,3 +1,14 @@
+2017-10-25  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: replace TypeVerifier with subclasses of WI.Collection
+        https://bugs.webkit.org/show_bug.cgi?id=178045
+        <rdar://problem/35174307>
+
+        Reviewed by Brian Burg.
+
+        * inspector/unit-tests/collection-expected.txt:
+        * inspector/unit-tests/collection.html:
+
 2017-10-25  Youenn Fablet  <youenn@apple.com>
 
         Add service worker handle fetch support for all subresource requests
index d5b47e7..72b739f 100644 (file)
@@ -14,8 +14,7 @@ Testing all methods of Collection.
 ["one","two",3]
 []
 
--- Running test case: WI.Collection.prototype.get typeVerifier
+-- Running test case: WI.Collection.SpecifiedType
 ["one","two"]
 ["one","two"]
-PASS: typeVerifier is the given function.
 
index 62b33e8..fdf8f94 100644 (file)
@@ -5,12 +5,26 @@
 <script>
 function test()
 {
-    let suite = InspectorTest.createAsyncSuite("Collection");
+    class TestCollection extends WI.Collection {
+        objectIsRequiredType(object)
+        {
+            return true;
+        }
+    }
+
+    class StringCollection extends WI.Collection {
+        objectIsRequiredType(object)
+        {
+            return typeof object === "string";
+        }
+    }
+
+    let suite = InspectorTest.createSyncSuite("Collection");
 
     suite.addTestCase({
         name: "WI.Collection.prototype.add",
-        test(resolve, reject) {
-            let collection = new WI.Collection;
+        test() {
+            let collection = new TestCollection;
             collection.add("one");
             collection.add("two");
 
@@ -20,16 +34,16 @@ function test()
 
             InspectorTest.log(collection);
 
-            resolve();
+            return true;
         }
     });
 
     suite.addTestCase({
         name: "WI.Collection.prototype.remove",
-        test(resolve, reject) {
+        test() {
             let item = "one";
 
-            let collection = new WI.Collection;
+            let collection = new TestCollection;
             collection.add(item);
             collection.add("two");
 
@@ -39,14 +53,14 @@ function test()
 
             InspectorTest.log(collection);
 
-            resolve();
+            return true;
         }
     });
 
     suite.addTestCase({
         name: "WI.Collection.prototype.clear",
-        test(resolve, reject) {
-            let collection = new WI.Collection;
+        test() {
+            let collection = new TestCollection;
             collection.add("one");
             collection.add("two");
             collection.add(3);
@@ -57,18 +71,14 @@ function test()
 
             InspectorTest.log(collection);
 
-            resolve();
+            return true;
         }
     });
 
     suite.addTestCase({
-        name: "WI.Collection.prototype.get typeVerifier",
-        test(resolve, reject) {
-            function stringVerifier(object) {
-                return typeof object === "string";
-            }
-
-            let collection = new WI.Collection(stringVerifier);
+        name: "WI.Collection.SpecifiedType",
+        test() {
+            let collection = new StringCollection;
             collection.add("one");
             collection.add("two");
 
@@ -77,9 +87,8 @@ function test()
             collection.add(3);
 
             InspectorTest.log(collection);
-            InspectorTest.expectEqual(collection.typeVerifier, stringVerifier, "typeVerifier is the given function.");
 
-            resolve();
+            return true;
         }
     });
 
index 04a001d..076dba7 100644 (file)
@@ -1,29 +1,78 @@
 2017-10-25  Devin Rousso  <webkit@devinrousso.com>
 
-        Web Inspector: Canvas Tab: clicking on a canvas card causes details sidebar to show and mess up card arrangement
-        https://bugs.webkit.org/show_bug.cgi?id=178803
-        <rdar://problem/35176082>
+        Web Inspector: replace TypeVerifier with subclasses of WI.Collection
+        https://bugs.webkit.org/show_bug.cgi?id=178045
+        <rdar://problem/35174307>
 
         Reviewed by Brian Burg.
 
-        * Localizations/en.lproj/localizedStrings.js:
-        * UserInterface/Views/CanvasDetailsSidebarPanel.css:
-        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder):
-        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder > .message):
-        * UserInterface/Views/CanvasDetailsSidebarPanel.js:
-        (WI.CanvasDetailsSidebarPanel):
-        (WI.CanvasDetailsSidebarPanel.prototype.inspect):
-        (WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
-        (WI.CanvasDetailsSidebarPanel.prototype.layout):
+        * UserInterface/Models/Collection.js:
+        (WI.Collection):
+        (WI.Collection.prototype.get displayName):
+        (WI.Collection.prototype.objectIsRequiredType):
+        (WI.Collection.prototype.add):
+        (WI.Collection.prototype.get typeVerifier): Deleted.
+        Instead of exposing the typeVerifier, we create a public predicate that returns whether the
+        given object matches the expected type of the Collection. Subclasses can override it to
+        limit the scope of the collection to a particular type.
 
-        * UserInterface/Views/RecordingNavigationSidebarPanel.js:
-        (WI.RecordingNavigationSidebarPanel.disallowInstanceForClass): Deleted.
-        * UserInterface/Views/RecordingStateDetailsSidebarPanel.js:
-        (WI.RecordingStateDetailsSidebarPanel.disallowInstanceForClass): Deleted.
-        * UserInterface/Views/RecordingTraceDetailsSidebarPanel.js:
-        (WI.RecordingTraceDetailsSidebarPanel.disallowInstanceForClass): Deleted.
-        Drive-by: these sidebar panels are now only used by the Canvas tab, so we no longer need to
-        provide support for multiple instances of them.
+        * UserInterface/Models/CollectionTypes.js:
+        (WI.FrameCollection.prototype.get displayName):
+        (WI.FrameCollection.prototype.objectIsRequiredType):
+        (WI.FrameCollection): Deleted.
+        (WI.ScriptCollection.prototype.get displayName):
+        (WI.ScriptCollection.prototype.objectIsRequiredType):
+        (WI.ScriptCollection): Deleted.
+        (WI.CSSStyleSheetCollection.prototype.get displayName):
+        (WI.CSSStyleSheetCollection.prototype.objectIsRequiredType):
+        (WI.CSSStyleSheetCollection): Deleted.
+        (WI.CanvasCollection.prototype.get displayName):
+        (WI.CanvasCollection.prototype.objectIsRequiredType):
+        (WI.CanvasCollection): Deleted.
+        (WI.ShaderProgramCollection.prototype.get displayName):
+        (WI.ShaderProgramCollection.prototype.objectIsRequiredType):
+        (WI.ShaderProgramCollection): Deleted.
+        (WI.RecordingCollection.prototype.get displayName):
+        (WI.RecordingCollection.prototype.objectIsRequiredType):
+        (WI.RecordingCollection): Deleted.
+        * UserInterface/Models/ResourceCollection.js:
+        (WI.ResourceCollection):
+        (WI.ResourceCollection.prototype.get displayName):
+        (WI.ResourceCollection.prototype.objectIsRequiredType):
+        (WI.ResourceCollection.verifierForType): Deleted.
+        * UserInterface/Views/TreeOutlineGroup.js:
+        (WI.TreeOutlineGroup.prototype.objectIsRequiredType):
+        (WI.TreeOutlineGroup): Deleted.
+        Introduce additional subclasses of Collection for other model types. Modify existing
+        subclasses to remove `typeVerifier` and instead extend `objectIsRequiredType`.
+
+        * UserInterface/Models/Canvas.js:
+        (WI.Canvas):
+        * UserInterface/Models/Frame.js:
+        (WI.Frame):
+        * UserInterface/Protocol/Target.js:
+        (WI.Target):
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WI.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
+        (WI.ResourceSidebarPanel.prototype._addScript):
+
+        * UserInterface/Views/CollectionContentView.js:
+        (WI.CollectionContentView):
+        (WI.CollectionContentView.titleForCollection): Delete.
+        * UserInterface/Views/ResourceCollectionContentView.js:
+        (WI.ResourceCollectionContentView):
+        Require that subclasses of Collection override `get displayName` if the CollectionContentView
+        is not provided with a `contentPlaceholderText`.
+
+        (WI.CollectionContentView.prototype.initialLayout):
+        We don't need to create and add ContentView for each item of the Collection, as this is
+        already done by attached().
+
+        (WI.CollectionContentView.prototype._showContentPlaceholder):
+        Remove the 250ms delay before showing the placeholder TitleView.
+
+        * UserInterface/Views/FolderizedTreeElement.js:
+        (WI.FolderizedTreeElement.prototype._settingsForRepresentedObject):
 
 2017-10-25  Joseph Pecoraro  <pecoraro@apple.com>
 
 
 2017-10-25  Devin Rousso  <webkit@devinrousso.com>
 
+        Web Inspector: Canvas Tab: clicking on a canvas card causes details sidebar to show and mess up card arrangement
+        https://bugs.webkit.org/show_bug.cgi?id=178803
+        <rdar://problem/35176082>
+
+        Reviewed by Brian Burg.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Views/CanvasDetailsSidebarPanel.css:
+        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder):
+        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder > .message):
+        * UserInterface/Views/CanvasDetailsSidebarPanel.js:
+        (WI.CanvasDetailsSidebarPanel):
+        (WI.CanvasDetailsSidebarPanel.prototype.inspect):
+        (WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
+        (WI.CanvasDetailsSidebarPanel.prototype.layout):
+
+        * UserInterface/Views/RecordingNavigationSidebarPanel.js:
+        (WI.RecordingNavigationSidebarPanel.disallowInstanceForClass): Deleted.
+        * UserInterface/Views/RecordingStateDetailsSidebarPanel.js:
+        (WI.RecordingStateDetailsSidebarPanel.disallowInstanceForClass): Deleted.
+        * UserInterface/Views/RecordingTraceDetailsSidebarPanel.js:
+        (WI.RecordingTraceDetailsSidebarPanel.disallowInstanceForClass): Deleted.
+        Drive-by: these sidebar panels are now only used by the Canvas tab, so we no longer need to
+        provide support for multiple instances of them.
+
+2017-10-25  Devin Rousso  <webkit@devinrousso.com>
+
         Web Inspector: preserve Recordings for each Canvas after closing the Canvas tab
         https://bugs.webkit.org/show_bug.cgi?id=178767
         <rdar://problem/35167239>
index 9494583..29c2aa2 100644 (file)
@@ -211,7 +211,6 @@ localizedStrings["Code"] = "Code";
 localizedStrings["Collapse All"] = "Collapse All";
 localizedStrings["Collapse columns"] = "Collapse columns";
 localizedStrings["Collect garbage"] = "Collect garbage";
-localizedStrings["Collection"] = "Collection";
 localizedStrings["Color"] = "Color";
 localizedStrings["Comment"] = "Comment";
 localizedStrings["Comment All Properties"] = "Comment All Properties";
@@ -723,6 +722,7 @@ localizedStrings["Recording"] = "Recording";
 localizedStrings["Recording %d"] = "Recording %d";
 localizedStrings["Recording Timeline Data"] = "Recording Timeline Data";
 localizedStrings["Recording error: %s"] = "Recording error: %s";
+localizedStrings["Recordings"] = "Recordings";
 localizedStrings["Reference Issue"] = "Reference Issue";
 localizedStrings["Reflection"] = "Reflection";
 localizedStrings["Refresh"] = "Refresh";
index b924290..f797950 100644 (file)
@@ -42,7 +42,7 @@ WI.Canvas = class Canvas extends WI.Object
         this._memoryCost = memoryCost || NaN;
 
         this._cssCanvasClientNodes = null;
-        this._shaderProgramCollection = new WI.Collection(WI.Collection.TypeVerifier.ShaderProgram);
+        this._shaderProgramCollection = new WI.ShaderProgramCollection;
         this._recordingCollection = new WI.RecordingCollection;
 
         this._nextShaderProgramDisplayNumber = 1;
index c54f92b..4333984 100644 (file)
 
 WI.Collection = class Collection extends WI.Object
 {
-    constructor(typeVerifier)
+    constructor(items = [])
     {
         super();
 
         this._items = new Set;
 
-        console.assert(!typeVerifier || typeof typeVerifier === "function");
-        this._typeVerifier = typeVerifier || WI.Collection.TypeVerifier.Any;
+        for (let item of items)
+            this.add(item);
     }
 
-     // Public
+    // Public
 
     get items() { return this._items; }
-    get typeVerifier() { return this._typeVerifier; }
+
+    get displayName()
+    {
+        throw WI.NotImplementedError.subclassMustOverride();
+    }
+
+    objectIsRequiredType(object)
+    {
+        throw WI.NotImplementedError.subclassMustOverride();
+    }
 
     add(item)
     {
-        let isValidType = this._typeVerifier(item);
+        let isValidType = this.objectIsRequiredType(item);
         console.assert(isValidType);
         if (!isValidType)
             return;
@@ -105,17 +114,8 @@ WI.Collection = class Collection extends WI.Object
     }
 };
 
- WI.Collection.Event = {
+WI.Collection.Event = {
     ItemAdded: "collection-item-added",
     ItemRemoved: "collection-item-removed",
 };
 
- WI.Collection.TypeVerifier = {
-    Any: (object) => true,
-    Frame: (object) => object instanceof WI.Frame,
-    Resource: (object) => object instanceof WI.Resource,
-    Script: (object) => object instanceof WI.Script,
-    CSSStyleSheet: (object) => object instanceof WI.CSSStyleSheet,
-    Canvas: (object) => object instanceof WI.Canvas,
-    ShaderProgram: (object) => object instanceof WI.ShaderProgram,
-};
index 75afb61..d05d6ed 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Devin Rousso <webkit@devinrousso.com>. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WI.FrameCollection = class FrameCollection extends WI.Collection
+{
+    // Public
+
+    get displayName()
+    {
+        return WI.UIString("Frames");
+    }
+
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.Frame;
+    }
+};
+
+WI.ScriptCollection = class ScriptCollection extends WI.Collection
+{
+    // Public
+
+    get displayName()
+    {
+        return WI.UIString("Scripts");
+    }
+
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.Script;
+    }
+};
+
+WI.CSSStyleSheetCollection = class CSSStyleSheetCollection extends WI.Collection
+{
+    // Public
+
+    get displayName()
+    {
+        return WI.UIString("Stylesheets");
+    }
+
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.CSSStyleSheet;
+    }
+};
+
+
 WI.CanvasCollection = class CanvasCollection extends WI.Collection
 {
-    constructor(canvases = [])
+    // Public
+
+    get displayName()
     {
-        super((item) => item instanceof WI.Canvas);
+        return WI.UIString("Canvases");
+    }
 
-        for (let canvas of canvases)
-            this.add(canvas);
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.Canvas;
+    }
+};
+
+WI.ShaderProgramCollection = class ShaderProgramCollection extends WI.Collection
+{
+    // Public
+
+    get displayName()
+    {
+        return WI.UIString("Shader Programs");
+    }
+
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.ShaderProgram;
     }
 };
 
 WI.RecordingCollection = class RecordingCollection extends WI.Collection
 {
-    constructor(recordings = [])
+    // Public
+
+    get displayName()
     {
-        super((item) => item instanceof WI.Recording);
+        return WI.UIString("Recordings");
+    }
 
-        for (let recording of recordings)
-            this.add(recording);
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.Recording;
     }
 };
index 425da84..4b21e4e 100644 (file)
@@ -38,9 +38,9 @@ WI.Frame = class Frame extends WI.Object
 
         this._resourceCollection = new WI.ResourceCollection;
         this._provisionalResourceCollection = new WI.ResourceCollection;
-        this._extraScriptCollection = new WI.Collection(WI.Collection.TypeVerifier.Script);
+        this._extraScriptCollection = new WI.ScriptCollection;
 
-        this._childFrameCollection = new WI.Collection(WI.Collection.TypeVerifier.Frame);
+        this._childFrameCollection = new WI.FrameCollection;
         this._childFrameIdentifierMap = new Map;
 
         this._parentFrame = null;
index 13e2f99..88608f5 100644 (file)
@@ -28,48 +28,37 @@ WI.ResourceCollection = class ResourceCollection extends WI.Collection
 {
     constructor(resourceType)
     {
-        super(WI.ResourceCollection.verifierForType(resourceType));
+        super();
 
         this._resourceType = resourceType || null;
         this._resourceURLMap = new Map;
         this._resourcesTypeMap = new Map;
     }
 
-    // Static
-
-    static verifierForType(type) {
-        switch (type) {
-        case WI.Resource.Type.Document:
-            return WI.ResourceCollection.TypeVerifier.Document;
-        case WI.Resource.Type.Stylesheet:
-            return WI.ResourceCollection.TypeVerifier.Stylesheet;
-        case WI.Resource.Type.Image:
-            return WI.ResourceCollection.TypeVerifier.Image;
-        case WI.Resource.Type.Font:
-            return WI.ResourceCollection.TypeVerifier.Font;
-        case WI.Resource.Type.Script:
-            return WI.ResourceCollection.TypeVerifier.Script;
-        case WI.Resource.Type.XHR:
-            return WI.ResourceCollection.TypeVerifier.XHR;
-        case WI.Resource.Type.Fetch:
-            return WI.ResourceCollection.TypeVerifier.Fetch;
-        case WI.Resource.Type.Ping:
-            return WI.ResourceCollection.TypeVerifier.Ping;
-        case WI.Resource.Type.Beacon:
-            return WI.ResourceCollection.TypeVerifier.Beacon;
-        case WI.Resource.Type.WebSocket:
-            return WI.ResourceCollection.TypeVerifier.WebSocket;
-        case WI.Resource.Type.Other:
-            return WI.ResourceCollection.TypeVerifier.Other;
-        default:
-            return WI.Collection.TypeVerifier.Resource;
-        }
-    }
-
     // Public
 
     get resourceType() { return this._resourceType; }
 
+    get displayName()
+    {
+        const plural = true;
+        return this._resourceType ? WI.Resource.displayNameForType(this._resourceType, plural) : WI.UIString("Resources");
+    }
+
+    objectIsRequiredType(object)
+    {
+        if (!(object instanceof WI.Resource))
+            return false;
+
+        if (!this._resourceType)
+            return true;
+
+        if (this._resourceType === WI.Resource.Type.Stylesheet && object instanceof WI.CSSStyleSheet)
+            return true;
+
+        return object.type === this._resourceType;
+    }
+
     resourceForURL(url)
     {
         return this._resourceURLMap.get(url) || null;
@@ -191,21 +180,3 @@ WI.ResourceCollection = class ResourceCollection extends WI.Collection
         // above if statement).
     }
 };
-
-WI.ResourceCollection.TypeVerifier = {
-    Document: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Document,
-    Stylesheet: (object) => {
-        if (WI.Collection.TypeVerifier.CSSStyleSheet(object))
-            return true;
-        return WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Stylesheet;
-    },
-    Image: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Image,
-    Font: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Font,
-    Script: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Script,
-    XHR: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.XHR,
-    Fetch: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Fetch,
-    Ping: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Ping,
-    Beacon: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Beacon,
-    WebSocket: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.WebSocket,
-    Other: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Other,
-};
index 5c544e1..9c3d97f 100644 (file)
@@ -36,7 +36,7 @@ WI.Target = class Target extends WI.Object
         this._executionContext = null;
         this._mainResource = null;
         this._resourceCollection = new WI.ResourceCollection;
-        this._extraScriptCollection = new WI.Collection(WI.Collection.TypeVerifier.Script);
+        this._extraScriptCollection = new WI.ScriptCollection;
 
         this._connection.target = this;
     }
index 3d06c8d..129a0ce 100644 (file)
@@ -33,7 +33,7 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
 
         this.element.classList.add("collection");
 
-        this._contentPlaceholderText = contentPlaceholderText || WI.CollectionContentView.titleForCollection(collection);
+        this._contentPlaceholderText = contentPlaceholderText || collection.displayName;
         this._contentViewConstructor = contentViewConstructor;
         this._contentViewMap = new Map;
         this._handleClickMap = new WeakMap;
@@ -41,27 +41,6 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
         this._selectionEnabled = false;
     }
 
-    static titleForCollection(collection)
-    {
-        switch (collection.typeVerifier) {
-        case WI.Collection.TypeVerifier.Frame:
-            return WI.UIString("Frames");
-        case WI.Collection.TypeVerifier.Resource:
-            return WI.UIString("Resources");
-        case WI.Collection.TypeVerifier.Script:
-            return WI.UIString("Scripts");
-        case WI.Collection.TypeVerifier.CSSStyleSheet:
-            return WI.UIString("Stylesheets");
-        case WI.Collection.TypeVerifier.Canvas:
-            return WI.UIString("Canvases");
-        case WI.Collection.TypeVerifier.ShaderProgram:
-            return WI.UIString("Shader Programs");
-        }
-
-        console.warn("No default title for Collection type verifier.", collection.typeVerifier);
-        return WI.UIString("Collection");
-    }
-
     // Public
 
     get supplementalRepresentedObjects()
@@ -188,9 +167,6 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
             this._showContentPlaceholder();
             return;
         }
-
-        for (let item of items)
-            this.addContentViewForItem(item);
     }
 
     attached()
@@ -276,7 +252,7 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
             this._contentPlaceholder = new WI.TitleView(this._contentPlaceholderText);
 
         if (!this._contentPlaceholder.parentView)
-            this.debounce(250).addSubview(this._contentPlaceholder);
+            this.addSubview(this._contentPlaceholder);
     }
 
     _hideContentPlaceholder()
index a6e7821..785bd75 100644 (file)
@@ -325,7 +325,7 @@ WI.FolderizedTreeElement = class FolderizedTreeElement extends WI.GeneralTreeEle
     _settingsForRepresentedObject(representedObject)
     {
         for (let settings of this._folderizeSettingsMap.values()) {
-            if (settings.representedObject.typeVerifier(representedObject))
+            if (settings.representedObject.objectIsRequiredType(representedObject))
                 return settings;
         }
         return null;
index f56f404..9f83719 100644 (file)
@@ -33,10 +33,7 @@ WI.ResourceCollectionContentView = class ResourceCollectionContentView extends W
         if (collection.resourceType === WI.Resource.Type.Image)
             contentViewConstructor = WI.ImageResourceContentView;
 
-        const plural = true;
-        let contentPlaceholderText = WI.Resource.displayNameForType(collection.resourceType, plural);
-
-        super(collection, contentViewConstructor, contentPlaceholderText);
+        super(collection, contentViewConstructor);
     }
 
     // Protected
index 92450bf..7cb8fa1 100644 (file)
@@ -168,7 +168,7 @@ WI.ResourceSidebarPanel = class ResourceSidebarPanel extends WI.NavigationSideba
         // we have a ScriptContentView asking for the tree element we will make a ScriptTreeElement on demand and add it.
 
         if (!this._anonymousScriptsFolderTreeElement) {
-            let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
+            let collection = new WI.ScriptCollection;
             this._anonymousScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Anonymous Scripts"), collection);
         }
 
@@ -320,7 +320,7 @@ WI.ResourceSidebarPanel = class ResourceSidebarPanel extends WI.NavigationSideba
 
         if (script.injected) {
             if (!this._extensionScriptsFolderTreeElement) {
-                let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
+                let collection = new WI.ScriptCollection;
                 this._extensionScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extension Scripts"), collection);
             }
 
@@ -330,7 +330,7 @@ WI.ResourceSidebarPanel = class ResourceSidebarPanel extends WI.NavigationSideba
                 insertIntoTopLevel = true;
             else {
                 if (!this._extraScriptsFolderTreeElement) {
-                    let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
+                    let collection = new WI.ScriptCollection;
                     this._extraScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extra Scripts"), collection);
                 }
 
index 2de0830..b2a8062 100644 (file)
 
 WI.TreeOutlineGroup = class TreeOutlineGroup extends WI.Collection
 {
-    constructor()
-    {
-        super((object) => object instanceof WI.TreeOutline);
-    }
-
     // Static
 
     static groupForTreeOutline(treeOutline)
@@ -39,6 +34,11 @@ WI.TreeOutlineGroup = class TreeOutlineGroup extends WI.Collection
 
     // Public
 
+    objectIsRequiredType(object)
+    {
+        return object instanceof WI.TreeOutline;
+    }
+
     get selectedTreeElement()
     {
         for (let treeOutline of this.items) {