Changeset 246555 in webkit


Ignore:
Timestamp:
Jun 18, 2019 12:09:37 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Canvas: imported recordings aren't selectable from the overview if there are no canvases in the page
https://bugs.webkit.org/show_bug.cgi?id=198955

Reviewed by Joseph Pecoraro.

  • UserInterface/Views/CanvasOverviewContentView.js:

(WI.CanvasOverviewContentView.prototype._addSavedRecording):
Hide the content placeholder when a recording is imported. It won't be shown again because
the subviews list will never be empty, as there's no way to remove an imported recording.

  • UserInterface/Views/CollectionContentView.js:

(WI.CollectionContentView.prototype.addContentViewForItem):
(WI.CollectionContentView.prototype.removeContentViewForItem):
(WI.CollectionContentView.prototype.showContentPlaceholder): Added.
(WI.CollectionContentView.prototype.hideContentPlaceholder): Added.
(WI.CollectionContentView.prototype.initialLayout):
(WI.CollectionContentView.prototype._selectItem):
(WI.CollectionContentView.prototype._showContentPlaceholder): Deleted.
(WI.CollectionContentView.prototype._hideContentPlaceholder): Deleted.
Make showContentPlaceholder/hideContentPlaceholder protected for any subclasses to call.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r246532 r246555  
     12019-06-18  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: imported recordings aren't selectable from the overview if there are no canvases in the page
     4        https://bugs.webkit.org/show_bug.cgi?id=198955
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Views/CanvasOverviewContentView.js:
     9        (WI.CanvasOverviewContentView.prototype._addSavedRecording):
     10        Hide the content placeholder when a recording is imported. It won't be shown again because
     11        the `subviews` list will never be empty, as there's no way to remove an imported recording.
     12
     13        * UserInterface/Views/CollectionContentView.js:
     14        (WI.CollectionContentView.prototype.addContentViewForItem):
     15        (WI.CollectionContentView.prototype.removeContentViewForItem):
     16        (WI.CollectionContentView.prototype.showContentPlaceholder): Added.
     17        (WI.CollectionContentView.prototype.hideContentPlaceholder): Added.
     18        (WI.CollectionContentView.prototype.initialLayout):
     19        (WI.CollectionContentView.prototype._selectItem):
     20        (WI.CollectionContentView.prototype._showContentPlaceholder): Deleted.
     21        (WI.CollectionContentView.prototype._hideContentPlaceholder): Deleted.
     22        Make `showContentPlaceholder`/`hideContentPlaceholder` protected for any subclasses to call.
     23
    1242019-06-17  Matt Baker  <mattbaker@apple.com>
    225
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js

    r244560 r246555  
    291291            let header = this._savedRecordingsContentView.element.appendChild(document.createElement("header"));
    292292            header.textContent = WI.UIString("Saved Recordings");
     293
     294            this.hideContentPlaceholder();
    293295        }
    294296
  • trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js

    r235873 r246555  
    110110        }
    111111
    112         this._hideContentPlaceholder();
     112        this.hideContentPlaceholder();
    113113
    114114        let contentView = new this._contentViewConstructor(item);
     
    172172
    173173        if (!this.subviews.length)
    174             this._showContentPlaceholder();
     174            this.showContentPlaceholder();
    175175    }
    176176
     
    185185    }
    186186
    187     initialLayout()
    188     {
    189         if (!this.representedObject.size || !this._contentViewConstructor) {
    190             this._showContentPlaceholder();
    191             return;
    192         }
    193     }
    194 
    195     attached()
    196     {
    197         super.attached();
    198 
    199         this.representedObject.addEventListener(WI.Collection.Event.ItemAdded, this._handleItemAdded, this);
    200         this.representedObject.addEventListener(WI.Collection.Event.ItemRemoved, this._handleItemRemoved, this);
    201 
    202         for (let item of this._contentViewMap.keys()) {
    203             if (this.representedObject.has(item))
    204                 continue;
    205 
    206             this.removeContentViewForItem(item);
    207             if (this._selectedItem === item)
    208                 this._selectItem(null);
    209         }
    210 
    211         for (let item of this.representedObject) {
    212             if (!this._contentViewMap.has(item))
    213                 this.addContentViewForItem(item);
    214         }
    215     }
    216 
    217     detached()
    218     {
    219         this.representedObject.removeEventListener(null, null, this);
    220 
    221         super.detached();
    222     }
    223 
    224      // Private
    225 
    226     _handleItemAdded(event)
    227     {
    228         let item = event.data.item;
    229         if (!item)
    230             return;
    231 
    232         this.addContentViewForItem(item);
    233     }
    234 
    235     _handleItemRemoved(event)
    236     {
    237         let item = event.data.item;
    238         if (!item)
    239             return;
    240 
    241         this.removeContentViewForItem(item);
    242     }
    243 
    244     _handleContentError(event)
    245     {
    246         if (event && event.target)
    247             this._removeContentViewForItem(event.target.representedObject);
    248     }
    249 
    250     _selectItem(item)
    251     {
    252         if (this._selectedItem === item)
    253             return;
    254 
    255         if (this._selectedItem) {
    256             let contentView = this._contentViewMap.get(this._selectedItem);
    257             console.assert(contentView, "Missing ContentView for deselected item.", this._selectedItem);
    258             contentView.element.classList.remove("selected");
    259         }
    260 
    261         this._selectedItem = item;
    262 
    263         if (this._selectedItem) {
    264             let selectedContentView = this._contentViewMap.get(this._selectedItem);
    265             console.assert(selectedContentView, "Missing ContentView for selected item.", this._selectedItem);
    266             selectedContentView.element.classList.add("selected");
    267         }
    268 
    269         this.dispatchEventToListeners(WI.ContentView.Event.SupplementalRepresentedObjectsDidChange);
    270     }
    271 
    272     _showContentPlaceholder()
     187    showContentPlaceholder()
    273188    {
    274189        if (!this._contentPlaceholderElement) {
     
    283198    }
    284199
    285     _hideContentPlaceholder()
     200    hideContentPlaceholder()
    286201    {
    287202        if (this._contentPlaceholderElement)
    288203            this._contentPlaceholderElement.remove();
    289204    }
     205
     206    initialLayout()
     207    {
     208        if (!this.representedObject.size || !this._contentViewConstructor) {
     209            this.showContentPlaceholder();
     210            return;
     211        }
     212    }
     213
     214    attached()
     215    {
     216        super.attached();
     217
     218        this.representedObject.addEventListener(WI.Collection.Event.ItemAdded, this._handleItemAdded, this);
     219        this.representedObject.addEventListener(WI.Collection.Event.ItemRemoved, this._handleItemRemoved, this);
     220
     221        for (let item of this._contentViewMap.keys()) {
     222            if (this.representedObject.has(item))
     223                continue;
     224
     225            this.removeContentViewForItem(item);
     226            if (this._selectedItem === item)
     227                this._selectItem(null);
     228        }
     229
     230        for (let item of this.representedObject) {
     231            if (!this._contentViewMap.has(item))
     232                this.addContentViewForItem(item);
     233        }
     234    }
     235
     236    detached()
     237    {
     238        this.representedObject.removeEventListener(null, null, this);
     239
     240        super.detached();
     241    }
     242
     243     // Private
     244
     245    _handleItemAdded(event)
     246    {
     247        let item = event.data.item;
     248        if (!item)
     249            return;
     250
     251        this.addContentViewForItem(item);
     252    }
     253
     254    _handleItemRemoved(event)
     255    {
     256        let item = event.data.item;
     257        if (!item)
     258            return;
     259
     260        this.removeContentViewForItem(item);
     261    }
     262
     263    _handleContentError(event)
     264    {
     265        if (event && event.target)
     266            this._removeContentViewForItem(event.target.representedObject);
     267    }
     268
     269    _selectItem(item)
     270    {
     271        if (this._selectedItem === item)
     272            return;
     273
     274        if (this._selectedItem) {
     275            let contentView = this._contentViewMap.get(this._selectedItem);
     276            console.assert(contentView, "Missing ContentView for deselected item.", this._selectedItem);
     277            contentView.element.classList.remove("selected");
     278        }
     279
     280        this._selectedItem = item;
     281
     282        if (this._selectedItem) {
     283            let selectedContentView = this._contentViewMap.get(this._selectedItem);
     284            console.assert(selectedContentView, "Missing ContentView for selected item.", this._selectedItem);
     285            selectedContentView.element.classList.add("selected");
     286        }
     287
     288        this.dispatchEventToListeners(WI.ContentView.Event.SupplementalRepresentedObjectsDidChange);
     289    }
    290290};
Note: See TracChangeset for help on using the changeset viewer.