Changeset 223997 in webkit


Ignore:
Timestamp:
Oct 25, 2017 4:49:05 PM (7 years ago)
Author:
webkit@devinrousso.com
Message:

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.

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:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223994 r223997  
     12017-10-25  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: replace TypeVerifier with subclasses of WI.Collection
     4        https://bugs.webkit.org/show_bug.cgi?id=178045
     5        <rdar://problem/35174307>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/unit-tests/collection-expected.txt:
     10        * inspector/unit-tests/collection.html:
     11
    1122017-10-25  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/inspector/unit-tests/collection-expected.txt

    r220119 r223997  
    1515[]
    1616
    17 -- Running test case: WI.Collection.prototype.get typeVerifier
     17-- Running test case: WI.Collection.SpecifiedType
    1818["one","two"]
    1919["one","two"]
    20 PASS: typeVerifier is the given function.
    2120
  • trunk/LayoutTests/inspector/unit-tests/collection.html

    r220119 r223997  
    66function test()
    77{
    8     let suite = InspectorTest.createAsyncSuite("Collection");
     8    class TestCollection extends WI.Collection {
     9        objectIsRequiredType(object)
     10        {
     11            return true;
     12        }
     13    }
     14
     15    class StringCollection extends WI.Collection {
     16        objectIsRequiredType(object)
     17        {
     18            return typeof object === "string";
     19        }
     20    }
     21
     22    let suite = InspectorTest.createSyncSuite("Collection");
    923
    1024    suite.addTestCase({
    1125        name: "WI.Collection.prototype.add",
    12         test(resolve, reject) {
    13             let collection = new WI.Collection;
     26        test() {
     27            let collection = new TestCollection;
    1428            collection.add("one");
    1529            collection.add("two");
     
    2135            InspectorTest.log(collection);
    2236
    23             resolve();
     37            return true;
    2438        }
    2539    });
     
    2741    suite.addTestCase({
    2842        name: "WI.Collection.prototype.remove",
    29         test(resolve, reject) {
     43        test() {
    3044            let item = "one";
    3145
    32             let collection = new WI.Collection;
     46            let collection = new TestCollection;
    3347            collection.add(item);
    3448            collection.add("two");
     
    4054            InspectorTest.log(collection);
    4155
    42             resolve();
     56            return true;
    4357        }
    4458    });
     
    4660    suite.addTestCase({
    4761        name: "WI.Collection.prototype.clear",
    48         test(resolve, reject) {
    49             let collection = new WI.Collection;
     62        test() {
     63            let collection = new TestCollection;
    5064            collection.add("one");
    5165            collection.add("two");
     
    5872            InspectorTest.log(collection);
    5973
    60             resolve();
     74            return true;
    6175        }
    6276    });
    6377
    6478    suite.addTestCase({
    65         name: "WI.Collection.prototype.get typeVerifier",
    66         test(resolve, reject) {
    67             function stringVerifier(object) {
    68                 return typeof object === "string";
    69             }
    70 
    71             let collection = new WI.Collection(stringVerifier);
     79        name: "WI.Collection.SpecifiedType",
     80        test() {
     81            let collection = new StringCollection;
    7282            collection.add("one");
    7383            collection.add("two");
     
    7888
    7989            InspectorTest.log(collection);
    80             InspectorTest.expectEqual(collection.typeVerifier, stringVerifier, "typeVerifier is the given function.");
    8190
    82             resolve();
     91            return true;
    8392        }
    8493    });
  • trunk/Source/WebInspectorUI/ChangeLog

    r223991 r223997  
    112017-10-25  Devin Rousso  <webkit@devinrousso.com>
    22
    3         Web Inspector: Canvas Tab: clicking on a canvas card causes details sidebar to show and mess up card arrangement
    4         https://bugs.webkit.org/show_bug.cgi?id=178803
    5         <rdar://problem/35176082>
     3        Web Inspector: replace TypeVerifier with subclasses of WI.Collection
     4        https://bugs.webkit.org/show_bug.cgi?id=178045
     5        <rdar://problem/35174307>
    66
    77        Reviewed by Brian Burg.
    88
    9         * Localizations/en.lproj/localizedStrings.js:
    10         * UserInterface/Views/CanvasDetailsSidebarPanel.css:
    11         (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder):
    12         (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder > .message):
    13         * UserInterface/Views/CanvasDetailsSidebarPanel.js:
    14         (WI.CanvasDetailsSidebarPanel):
    15         (WI.CanvasDetailsSidebarPanel.prototype.inspect):
    16         (WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
    17         (WI.CanvasDetailsSidebarPanel.prototype.layout):
    18 
    19         * UserInterface/Views/RecordingNavigationSidebarPanel.js:
    20         (WI.RecordingNavigationSidebarPanel.disallowInstanceForClass): Deleted.
    21         * UserInterface/Views/RecordingStateDetailsSidebarPanel.js:
    22         (WI.RecordingStateDetailsSidebarPanel.disallowInstanceForClass): Deleted.
    23         * UserInterface/Views/RecordingTraceDetailsSidebarPanel.js:
    24         (WI.RecordingTraceDetailsSidebarPanel.disallowInstanceForClass): Deleted.
    25         Drive-by: these sidebar panels are now only used by the Canvas tab, so we no longer need to
    26         provide support for multiple instances of them.
     9        * UserInterface/Models/Collection.js:
     10        (WI.Collection):
     11        (WI.Collection.prototype.get displayName):
     12        (WI.Collection.prototype.objectIsRequiredType):
     13        (WI.Collection.prototype.add):
     14        (WI.Collection.prototype.get typeVerifier): Deleted.
     15        Instead of exposing the typeVerifier, we create a public predicate that returns whether the
     16        given object matches the expected type of the Collection. Subclasses can override it to
     17        limit the scope of the collection to a particular type.
     18
     19        * UserInterface/Models/CollectionTypes.js:
     20        (WI.FrameCollection.prototype.get displayName):
     21        (WI.FrameCollection.prototype.objectIsRequiredType):
     22        (WI.FrameCollection): Deleted.
     23        (WI.ScriptCollection.prototype.get displayName):
     24        (WI.ScriptCollection.prototype.objectIsRequiredType):
     25        (WI.ScriptCollection): Deleted.
     26        (WI.CSSStyleSheetCollection.prototype.get displayName):
     27        (WI.CSSStyleSheetCollection.prototype.objectIsRequiredType):
     28        (WI.CSSStyleSheetCollection): Deleted.
     29        (WI.CanvasCollection.prototype.get displayName):
     30        (WI.CanvasCollection.prototype.objectIsRequiredType):
     31        (WI.CanvasCollection): Deleted.
     32        (WI.ShaderProgramCollection.prototype.get displayName):
     33        (WI.ShaderProgramCollection.prototype.objectIsRequiredType):
     34        (WI.ShaderProgramCollection): Deleted.
     35        (WI.RecordingCollection.prototype.get displayName):
     36        (WI.RecordingCollection.prototype.objectIsRequiredType):
     37        (WI.RecordingCollection): Deleted.
     38        * UserInterface/Models/ResourceCollection.js:
     39        (WI.ResourceCollection):
     40        (WI.ResourceCollection.prototype.get displayName):
     41        (WI.ResourceCollection.prototype.objectIsRequiredType):
     42        (WI.ResourceCollection.verifierForType): Deleted.
     43        * UserInterface/Views/TreeOutlineGroup.js:
     44        (WI.TreeOutlineGroup.prototype.objectIsRequiredType):
     45        (WI.TreeOutlineGroup): Deleted.
     46        Introduce additional subclasses of Collection for other model types. Modify existing
     47        subclasses to remove `typeVerifier` and instead extend `objectIsRequiredType`.
     48
     49        * UserInterface/Models/Canvas.js:
     50        (WI.Canvas):
     51        * UserInterface/Models/Frame.js:
     52        (WI.Frame):
     53        * UserInterface/Protocol/Target.js:
     54        (WI.Target):
     55        * UserInterface/Views/ResourceSidebarPanel.js:
     56        (WI.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
     57        (WI.ResourceSidebarPanel.prototype._addScript):
     58
     59        * UserInterface/Views/CollectionContentView.js:
     60        (WI.CollectionContentView):
     61        (WI.CollectionContentView.titleForCollection): Delete.
     62        * UserInterface/Views/ResourceCollectionContentView.js:
     63        (WI.ResourceCollectionContentView):
     64        Require that subclasses of Collection override `get displayName` if the CollectionContentView
     65        is not provided with a `contentPlaceholderText`.
     66
     67        (WI.CollectionContentView.prototype.initialLayout):
     68        We don't need to create and add ContentView for each item of the Collection, as this is
     69        already done by attached().
     70
     71        (WI.CollectionContentView.prototype._showContentPlaceholder):
     72        Remove the 250ms delay before showing the placeholder TitleView.
     73
     74        * UserInterface/Views/FolderizedTreeElement.js:
     75        (WI.FolderizedTreeElement.prototype._settingsForRepresentedObject):
    2776
    28772017-10-25  Joseph Pecoraro  <pecoraro@apple.com>
     
    109158        Introduce updateClassNames method. Unlike _update, it doesn't change text selection or focus and
    110159        can be safely called on a property while it's being edited.
     160
     1612017-10-25  Devin Rousso  <webkit@devinrousso.com>
     162
     163        Web Inspector: Canvas Tab: clicking on a canvas card causes details sidebar to show and mess up card arrangement
     164        https://bugs.webkit.org/show_bug.cgi?id=178803
     165        <rdar://problem/35176082>
     166
     167        Reviewed by Brian Burg.
     168
     169        * Localizations/en.lproj/localizedStrings.js:
     170        * UserInterface/Views/CanvasDetailsSidebarPanel.css:
     171        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder):
     172        (.sidebar > .panel.details.canvas > .content > .empty-content-placeholder > .message):
     173        * UserInterface/Views/CanvasDetailsSidebarPanel.js:
     174        (WI.CanvasDetailsSidebarPanel):
     175        (WI.CanvasDetailsSidebarPanel.prototype.inspect):
     176        (WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
     177        (WI.CanvasDetailsSidebarPanel.prototype.layout):
     178
     179        * UserInterface/Views/RecordingNavigationSidebarPanel.js:
     180        (WI.RecordingNavigationSidebarPanel.disallowInstanceForClass): Deleted.
     181        * UserInterface/Views/RecordingStateDetailsSidebarPanel.js:
     182        (WI.RecordingStateDetailsSidebarPanel.disallowInstanceForClass): Deleted.
     183        * UserInterface/Views/RecordingTraceDetailsSidebarPanel.js:
     184        (WI.RecordingTraceDetailsSidebarPanel.disallowInstanceForClass): Deleted.
     185        Drive-by: these sidebar panels are now only used by the Canvas tab, so we no longer need to
     186        provide support for multiple instances of them.
    111187
    1121882017-10-25  Devin Rousso  <webkit@devinrousso.com>
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r223991 r223997  
    212212localizedStrings["Collapse columns"] = "Collapse columns";
    213213localizedStrings["Collect garbage"] = "Collect garbage";
    214 localizedStrings["Collection"] = "Collection";
    215214localizedStrings["Color"] = "Color";
    216215localizedStrings["Comment"] = "Comment";
     
    724723localizedStrings["Recording Timeline Data"] = "Recording Timeline Data";
    725724localizedStrings["Recording error: %s"] = "Recording error: %s";
     725localizedStrings["Recordings"] = "Recordings";
    726726localizedStrings["Reference Issue"] = "Reference Issue";
    727727localizedStrings["Reflection"] = "Reflection";
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r223952 r223997  
    4343
    4444        this._cssCanvasClientNodes = null;
    45         this._shaderProgramCollection = new WI.Collection(WI.Collection.TypeVerifier.ShaderProgram);
     45        this._shaderProgramCollection = new WI.ShaderProgramCollection;
    4646        this._recordingCollection = new WI.RecordingCollection;
    4747
  • trunk/Source/WebInspectorUI/UserInterface/Models/Collection.js

    r222356 r223997  
    2626WI.Collection = class Collection extends WI.Object
    2727{
    28     constructor(typeVerifier)
     28    constructor(items = [])
    2929    {
    3030        super();
     
    3232        this._items = new Set;
    3333
    34         console.assert(!typeVerifier || typeof typeVerifier === "function");
    35         this._typeVerifier = typeVerifier || WI.Collection.TypeVerifier.Any;
     34        for (let item of items)
     35            this.add(item);
    3636    }
    3737
    38      // Public
     38    // Public
    3939
    4040    get items() { return this._items; }
    41     get typeVerifier() { return this._typeVerifier; }
     41
     42    get displayName()
     43    {
     44        throw WI.NotImplementedError.subclassMustOverride();
     45    }
     46
     47    objectIsRequiredType(object)
     48    {
     49        throw WI.NotImplementedError.subclassMustOverride();
     50    }
    4251
    4352    add(item)
    4453    {
    45         let isValidType = this._typeVerifier(item);
     54        let isValidType = this.objectIsRequiredType(item);
    4655        console.assert(isValidType);
    4756        if (!isValidType)
     
    106115};
    107116
    108  WI.Collection.Event = {
     117WI.Collection.Event = {
    109118    ItemAdded: "collection-item-added",
    110119    ItemRemoved: "collection-item-removed",
    111120};
    112121
    113  WI.Collection.TypeVerifier = {
    114     Any: (object) => true,
    115     Frame: (object) => object instanceof WI.Frame,
    116     Resource: (object) => object instanceof WI.Resource,
    117     Script: (object) => object instanceof WI.Script,
    118     CSSStyleSheet: (object) => object instanceof WI.CSSStyleSheet,
    119     Canvas: (object) => object instanceof WI.Canvas,
    120     ShaderProgram: (object) => object instanceof WI.ShaderProgram,
    121 };
  • trunk/Source/WebInspectorUI/UserInterface/Models/CollectionTypes.js

    r223952 r223997  
    11/*
    22 * Copyright (C) 2017 Apple Inc. All rights reserved.
     3 * Copyright (C) 2017 Devin Rousso <webkit@devinrousso.com>. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2425 */
    2526
     27WI.FrameCollection = class FrameCollection extends WI.Collection
     28{
     29    // Public
     30
     31    get displayName()
     32    {
     33        return WI.UIString("Frames");
     34    }
     35
     36    objectIsRequiredType(object)
     37    {
     38        return object instanceof WI.Frame;
     39    }
     40};
     41
     42WI.ScriptCollection = class ScriptCollection extends WI.Collection
     43{
     44    // Public
     45
     46    get displayName()
     47    {
     48        return WI.UIString("Scripts");
     49    }
     50
     51    objectIsRequiredType(object)
     52    {
     53        return object instanceof WI.Script;
     54    }
     55};
     56
     57WI.CSSStyleSheetCollection = class CSSStyleSheetCollection extends WI.Collection
     58{
     59    // Public
     60
     61    get displayName()
     62    {
     63        return WI.UIString("Stylesheets");
     64    }
     65
     66    objectIsRequiredType(object)
     67    {
     68        return object instanceof WI.CSSStyleSheet;
     69    }
     70};
     71
     72
    2673WI.CanvasCollection = class CanvasCollection extends WI.Collection
    2774{
    28     constructor(canvases = [])
     75    // Public
     76
     77    get displayName()
    2978    {
    30         super((item) => item instanceof WI.Canvas);
     79        return WI.UIString("Canvases");
     80    }
    3181
    32         for (let canvas of canvases)
    33             this.add(canvas);
     82    objectIsRequiredType(object)
     83    {
     84        return object instanceof WI.Canvas;
     85    }
     86};
     87
     88WI.ShaderProgramCollection = class ShaderProgramCollection extends WI.Collection
     89{
     90    // Public
     91
     92    get displayName()
     93    {
     94        return WI.UIString("Shader Programs");
     95    }
     96
     97    objectIsRequiredType(object)
     98    {
     99        return object instanceof WI.ShaderProgram;
    34100    }
    35101};
     
    37103WI.RecordingCollection = class RecordingCollection extends WI.Collection
    38104{
    39     constructor(recordings = [])
     105    // Public
     106
     107    get displayName()
    40108    {
    41         super((item) => item instanceof WI.Recording);
     109        return WI.UIString("Recordings");
     110    }
    42111
    43         for (let recording of recordings)
    44             this.add(recording);
     112    objectIsRequiredType(object)
     113    {
     114        return object instanceof WI.Recording;
    45115    }
    46116};
  • trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js

    r223920 r223997  
    3939        this._resourceCollection = new WI.ResourceCollection;
    4040        this._provisionalResourceCollection = new WI.ResourceCollection;
    41         this._extraScriptCollection = new WI.Collection(WI.Collection.TypeVerifier.Script);
    42 
    43         this._childFrameCollection = new WI.Collection(WI.Collection.TypeVerifier.Frame);
     41        this._extraScriptCollection = new WI.ScriptCollection;
     42
     43        this._childFrameCollection = new WI.FrameCollection;
    4444        this._childFrameIdentifierMap = new Map;
    4545
  • trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js

    r223308 r223997  
    2929    constructor(resourceType)
    3030    {
    31         super(WI.ResourceCollection.verifierForType(resourceType));
     31        super();
    3232
    3333        this._resourceType = resourceType || null;
     
    3636    }
    3737
    38     // Static
    39 
    40     static verifierForType(type) {
    41         switch (type) {
    42         case WI.Resource.Type.Document:
    43             return WI.ResourceCollection.TypeVerifier.Document;
    44         case WI.Resource.Type.Stylesheet:
    45             return WI.ResourceCollection.TypeVerifier.Stylesheet;
    46         case WI.Resource.Type.Image:
    47             return WI.ResourceCollection.TypeVerifier.Image;
    48         case WI.Resource.Type.Font:
    49             return WI.ResourceCollection.TypeVerifier.Font;
    50         case WI.Resource.Type.Script:
    51             return WI.ResourceCollection.TypeVerifier.Script;
    52         case WI.Resource.Type.XHR:
    53             return WI.ResourceCollection.TypeVerifier.XHR;
    54         case WI.Resource.Type.Fetch:
    55             return WI.ResourceCollection.TypeVerifier.Fetch;
    56         case WI.Resource.Type.Ping:
    57             return WI.ResourceCollection.TypeVerifier.Ping;
    58         case WI.Resource.Type.Beacon:
    59             return WI.ResourceCollection.TypeVerifier.Beacon;
    60         case WI.Resource.Type.WebSocket:
    61             return WI.ResourceCollection.TypeVerifier.WebSocket;
    62         case WI.Resource.Type.Other:
    63             return WI.ResourceCollection.TypeVerifier.Other;
    64         default:
    65             return WI.Collection.TypeVerifier.Resource;
    66         }
    67     }
    68 
    6938    // Public
    7039
    7140    get resourceType() { return this._resourceType; }
     41
     42    get displayName()
     43    {
     44        const plural = true;
     45        return this._resourceType ? WI.Resource.displayNameForType(this._resourceType, plural) : WI.UIString("Resources");
     46    }
     47
     48    objectIsRequiredType(object)
     49    {
     50        if (!(object instanceof WI.Resource))
     51            return false;
     52
     53        if (!this._resourceType)
     54            return true;
     55
     56        if (this._resourceType === WI.Resource.Type.Stylesheet && object instanceof WI.CSSStyleSheet)
     57            return true;
     58
     59        return object.type === this._resourceType;
     60    }
    7261
    7362    resourceForURL(url)
     
    192181    }
    193182};
    194 
    195 WI.ResourceCollection.TypeVerifier = {
    196     Document: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Document,
    197     Stylesheet: (object) => {
    198         if (WI.Collection.TypeVerifier.CSSStyleSheet(object))
    199             return true;
    200         return WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Stylesheet;
    201     },
    202     Image: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Image,
    203     Font: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Font,
    204     Script: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Script,
    205     XHR: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.XHR,
    206     Fetch: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Fetch,
    207     Ping: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Ping,
    208     Beacon: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Beacon,
    209     WebSocket: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.WebSocket,
    210     Other: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Other,
    211 };
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/Target.js

    r220119 r223997  
    3737        this._mainResource = null;
    3838        this._resourceCollection = new WI.ResourceCollection;
    39         this._extraScriptCollection = new WI.Collection(WI.Collection.TypeVerifier.Script);
     39        this._extraScriptCollection = new WI.ScriptCollection;
    4040
    4141        this._connection.target = this;
  • trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js

    r223011 r223997  
    3434        this.element.classList.add("collection");
    3535
    36         this._contentPlaceholderText = contentPlaceholderText || WI.CollectionContentView.titleForCollection(collection);
     36        this._contentPlaceholderText = contentPlaceholderText || collection.displayName;
    3737        this._contentViewConstructor = contentViewConstructor;
    3838        this._contentViewMap = new Map;
     
    4242    }
    4343
    44     static titleForCollection(collection)
    45     {
    46         switch (collection.typeVerifier) {
    47         case WI.Collection.TypeVerifier.Frame:
    48             return WI.UIString("Frames");
    49         case WI.Collection.TypeVerifier.Resource:
    50             return WI.UIString("Resources");
    51         case WI.Collection.TypeVerifier.Script:
    52             return WI.UIString("Scripts");
    53         case WI.Collection.TypeVerifier.CSSStyleSheet:
    54             return WI.UIString("Stylesheets");
    55         case WI.Collection.TypeVerifier.Canvas:
    56             return WI.UIString("Canvases");
    57         case WI.Collection.TypeVerifier.ShaderProgram:
    58             return WI.UIString("Shader Programs");
    59         }
    60 
    61         console.warn("No default title for Collection type verifier.", collection.typeVerifier);
    62         return WI.UIString("Collection");
    63     }
    64 
    6544    // Public
    6645
     
    189168            return;
    190169        }
    191 
    192         for (let item of items)
    193             this.addContentViewForItem(item);
    194170    }
    195171
     
    277253
    278254        if (!this._contentPlaceholder.parentView)
    279             this.debounce(250).addSubview(this._contentPlaceholder);
     255            this.addSubview(this._contentPlaceholder);
    280256    }
    281257
  • trunk/Source/WebInspectorUI/UserInterface/Views/FolderizedTreeElement.js

    r220119 r223997  
    326326    {
    327327        for (let settings of this._folderizeSettingsMap.values()) {
    328             if (settings.representedObject.typeVerifier(representedObject))
     328            if (settings.representedObject.objectIsRequiredType(representedObject))
    329329                return settings;
    330330        }
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceCollectionContentView.js

    r222573 r223997  
    3434            contentViewConstructor = WI.ImageResourceContentView;
    3535
    36         const plural = true;
    37         let contentPlaceholderText = WI.Resource.displayNameForType(collection.resourceType, plural);
    38 
    39         super(collection, contentViewConstructor, contentPlaceholderText);
     36        super(collection, contentViewConstructor);
    4037    }
    4138
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js

    r223920 r223997  
    169169
    170170        if (!this._anonymousScriptsFolderTreeElement) {
    171             let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
     171            let collection = new WI.ScriptCollection;
    172172            this._anonymousScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Anonymous Scripts"), collection);
    173173        }
     
    321321        if (script.injected) {
    322322            if (!this._extensionScriptsFolderTreeElement) {
    323                 let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
     323                let collection = new WI.ScriptCollection;
    324324                this._extensionScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extension Scripts"), collection);
    325325            }
     
    331331            else {
    332332                if (!this._extraScriptsFolderTreeElement) {
    333                     let collection = new WI.Collection(WI.Collection.TypeVerifier.Script);
     333                    let collection = new WI.ScriptCollection;
    334334                    this._extraScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extra Scripts"), collection);
    335335                }
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js

    r220119 r223997  
    2626WI.TreeOutlineGroup = class TreeOutlineGroup extends WI.Collection
    2727{
    28     constructor()
    29     {
    30         super((object) => object instanceof WI.TreeOutline);
    31     }
    32 
    3328    // Static
    3429
     
    3934
    4035    // Public
     36
     37    objectIsRequiredType(object)
     38    {
     39        return object instanceof WI.TreeOutline;
     40    }
    4141
    4242    get selectedTreeElement()
Note: See TracChangeset for help on using the changeset viewer.