Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (208440 => 208441)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-11-09 18:25:30 UTC (rev 208441)
@@ -1,3 +1,50 @@
+2016-11-09 Devin Rousso <[email protected]>
+
+ Web Inspector: Allow FolderTreeElement to display content when selected
+ https://bugs.webkit.org/show_bug.cgi?id=164407
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Main.html:
+ Add CollectionContentView and TitleView.
+
+ * UserInterface/Base/Main.js:
+ * UserInterface/Views/ContentView.js:
+ (WebInspector.ContentView.createFromRepresentedObject):
+ (WebInspector.ContentView.isViewable):
+ Add support for Collection as the representedObject of a content view.
+
+ * UserInterface/Views/CollectionContentView.css: Added.
+ (.content-view.collection):
+ (.content-view.collection > .content-view):
+ * UserInterface/Views/CollectionContentView.js: Added.
+ (WebInspector.CollectionContentView):
+ (WebInspector.CollectionContentView.prototype.initialLayout):
+ (WebInspector.CollectionContentView.prototype._addContentViewForItem):
+ (WebInspector.CollectionContentView.prototype._removeContentViewForItem):
+ (WebInspector.CollectionContentView.prototype._handleItemAdded):
+ (WebInspector.CollectionContentView.prototype._handleItemRemoved):
+ (WebInspector.CollectionContentView.prototype._handleContentError):
+ Takes in a Collection when constructed, and attempts to display a sub-ContentView for each
+ item in the collection if the type of the collection is viewable en masse. Currently, this
+ is only supported for WebInspector.Resource.Type.Image collections.
+
+ * UserInterface/Views/ResourceContentView.js:
+ (WebInspector.ResourceContentView.prototype._contentError):
+ Dispatch an event whenever the content fails to load.
+
+ * UserInterface/Views/ResourceSidebarPanel.js:
+ (WebInspector.ResourceSidebarPanel.prototype._treeSelectionDidChange):
+ * UserInterface/Views/ResourcesTabContentView.js:
+ (WebInspector.ResourcesTabContentView.prototype.canShowRepresentedObject):
+ Allow FolderTreeElements to be selected.
+
+ * UserInterface/Views/TitleView.css: Added.
+ (.title-view):
+ * UserInterface/Views/TitleView.js: Added.
+ (WebInspector.TitleView):
+ Basic view that displays the given text in the center of the viewable area.
+
2016-11-03 Nikita Vasilyev <[email protected]>
Web Inspector: Stack overflow when searching a timeline recording for JS function names
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -1110,6 +1110,9 @@
representedObject instanceof WebInspector.IndexedDatabaseObjectStoreIndex)
return WebInspector.ResourcesTabContentView;
+ if (representedObject instanceof WebInspector.Collection)
+ return WebInspector.CollectionContentView;
+
return null;
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2016-11-09 18:25:30 UTC (rev 208441)
@@ -49,6 +49,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -175,6 +176,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -489,6 +491,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
@@ -652,6 +655,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Added: trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.css (0 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.css (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.css 2016-11-09 18:25:30 UTC (rev 208441)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 Devin Rousso <[email protected]>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.content-view.collection {
+ display: flex;
+ flex-wrap: wrap;
+ overflow-y: scroll !important;
+}
+
+.content-view.collection > .content-view {
+ flex-grow: 1;
+}
Added: trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js (0 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2016 Devin Rousso <[email protected]>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.CollectionContentView = class CollectionContentView extends WebInspector.ContentView
+{
+ constructor(collection)
+ {
+ console.assert(collection instanceof WebInspector.Collection);
+
+ super(collection);
+
+ this.representedObject.addEventListener(WebInspector.Collection.Event.ItemAdded, this._handleItemAdded, this);
+ this.representedObject.addEventListener(WebInspector.Collection.Event.ItemRemoved, this._handleItemRemoved, this);
+
+ this._contentViewMap = new WeakMap;
+ this._handleClickMap = new WeakMap;
+
+ this._contentViewConstructor = null;
+ let title = "";
+ switch (this.representedObject.typeVerifier) {
+ case WebInspector.Collection.TypeVerifier.Frame:
+ title = WebInspector.UIString("Frames");
+ break;
+
+ case WebInspector.Collection.TypeVerifier.ContentFlow:
+ title = WebInspector.UIString("Flows");
+ break;
+
+ case WebInspector.Collection.TypeVerifier.Script:
+ title = WebInspector.UIString("Extra Scripts");
+ break;
+
+ case WebInspector.Collection.TypeVerifier.Resource:
+ title = WebInspector.UIString("Resource");
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Document:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Document, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Stylesheet:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Stylesheet, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Image:
+ this._contentViewConstructor = WebInspector.ImageResourceContentView;
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Image, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Font:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Font, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Script:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Script, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.XHR:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.XHR, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.WebSocket:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.WebSocket, true);
+ break;
+
+ case WebInspector.ResourceCollection.TypeVerifier.Other:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Other, true);
+ break;
+ }
+
+ this._contentPlaceholder = new WebInspector.TitleView(title);
+
+ this.element.classList.add("collection");
+ }
+
+ // Public
+
+ initialLayout()
+ {
+ let items = this.representedObject.items;
+ if (this._contentViewConstructor && items.size) {
+ for (let item of items)
+ this._addContentViewForItem(item);
+ } else
+ this.addSubview(this._contentPlaceholder);
+ }
+
+ // Private
+
+ _addContentViewForItem(item)
+ {
+ if (!this._contentViewConstructor)
+ return;
+
+ if (this._contentPlaceholder.parentView)
+ this.removeSubview(this._contentPlaceholder);
+
+ let contentView = new this._contentViewConstructor(item);
+
+ contentView.addEventListener(WebInspector.ResourceContentView.Event.ContentError, this._handleContentError, this);
+
+ let handleClick = (event) => {
+ if (event.button !== 0 || event.ctrlKey)
+ return;
+
+ WebInspector.showRepresentedObject(item);
+ };
+ this._handleClickMap.set(item, handleClick);
+ contentView.element.addEventListener("click", handleClick);
+
+ contentView.element.title = WebInspector.displayNameForURL(item.url, item.urlComponents);
+
+ this.addSubview(contentView);
+ this._contentViewMap.set(item, contentView);
+ }
+
+ _removeContentViewForItem(item)
+ {
+ if (!this._contentViewConstructor)
+ return;
+
+ let contentView = this._contentViewMap.get(item);
+ console.assert(contentView);
+ if (!contentView)
+ return;
+
+ this.removeSubview(contentView);
+ this._contentViewMap.delete(item);
+
+ contentView.removeEventListener(null, null, this);
+
+ let handleClick = this._handleClickMap.get(item);
+ console.assert(handleClick);
+ if (handleClick) {
+ contentView.element.removeEventListener("click", handleClick);
+ this._handleClickMap.delete(item);
+ }
+
+ if (!this.representedObject.resources.length)
+ this.addSubview(this._contentPlaceholder);
+ }
+
+ _handleItemAdded(event)
+ {
+ let item = event.data.item;
+ if (!item)
+ return;
+
+ this._addContentViewForItem(item);
+ }
+
+ _handleItemRemoved(event)
+ {
+ let item = event.data.item;
+ if (!item)
+ return;
+
+ this._removeContentViewForItem(item);
+ }
+
+ _handleContentError(event)
+ {
+ if (event && event.target)
+ this._removeContentViewForItem(event.target.representedObject);
+ }
+};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -141,6 +141,9 @@
if (representedObject instanceof WebInspector.HeapSnapshotProxy || representedObject instanceof WebInspector.HeapSnapshotDiffProxy)
return new WebInspector.HeapSnapshotClusterContentView(representedObject, extraArguments);
+ if (representedObject instanceof WebInspector.Collection)
+ return new WebInspector.CollectionContentView(representedObject, extraArguments);
+
if (typeof representedObject === "string" || representedObject instanceof String)
return new WebInspector.TextContentView(representedObject, extraArguments);
@@ -244,6 +247,8 @@
return true;
if (representedObject instanceof WebInspector.HeapSnapshotProxy || representedObject instanceof WebInspector.HeapSnapshotDiffProxy)
return true;
+ if (representedObject instanceof WebInspector.Collection)
+ return true;
if (typeof representedObject === "string" || representedObject instanceof String)
return true;
return false;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -104,6 +104,8 @@
this.element.removeChildren();
this.element.appendChild(WebInspector.createMessageTextView(error, true));
+
+ this.dispatchEventToListeners(WebInspector.ResourceContentView.Event.ContentError);
}
_protocolError(error)
@@ -132,3 +134,7 @@
WebInspector.handlePossibleLinkClick(event, this.resource.parentFrame);
}
};
+
+WebInspector.ResourceContentView.Event = {
+ ContentError: "resource-content-view-content-error",
+};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -113,7 +113,7 @@
{
// A custom implementation is needed for this since the frames are populated lazily.
- if (!this._mainFrameTreeElement && (representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame)) {
+ if (!this._mainFrameTreeElement && (representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.Collection)) {
// All resources are under the main frame, so we need to return early if we don't have the main frame yet.
return null;
}
@@ -440,10 +440,11 @@
_treeSelectionDidChange(event)
{
let treeElement = event.data.selectedElement;
- if (!treeElement || treeElement instanceof WebInspector.FolderTreeElement)
+ if (!treeElement)
return;
- if (treeElement instanceof WebInspector.ResourceTreeElement
+ if (treeElement instanceof WebInspector.FolderTreeElement
+ || treeElement instanceof WebInspector.ResourceTreeElement
|| treeElement instanceof WebInspector.ScriptTreeElement
|| treeElement instanceof WebInspector.ContentFlowTreeElement) {
WebInspector.showRepresentedObject(treeElement.representedObject);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js (208440 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js 2016-11-09 18:24:09 UTC (rev 208440)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -59,7 +59,8 @@
return representedObject instanceof WebInspector.Frame
|| representedObject instanceof WebInspector.Resource
|| representedObject instanceof WebInspector.Script
- || representedObject instanceof WebInspector.ContentFlow;
+ || representedObject instanceof WebInspector.ContentFlow
+ || representedObject instanceof WebInspector.Collection;
}
};
Added: trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.css (0 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.css (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.css 2016-11-09 18:25:30 UTC (rev 208441)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Devin Rousso <[email protected]>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.title-view {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ font-size: 40px;
+ font-weight: lighter;
+}
Added: trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.js (0 => 208441)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TitleView.js 2016-11-09 18:25:30 UTC (rev 208441)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Devin Rousso <[email protected]>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.TitleView = class TitleView extends WebInspector.View
+{
+ constructor(title)
+ {
+ super();
+
+ this.element.classList.add("title-view");
+ this.element.textContent = title;
+ }
+};