Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (236782 => 236783)
--- trunk/Source/WebInspectorUI/ChangeLog 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/ChangeLog 2018-10-03 01:49:05 UTC (rev 236783)
@@ -1,3 +1,35 @@
+2018-10-02 Devin Rousso <[email protected]>
+
+ Web Inspector: merge SourceMapManager into NetworkManager
+ https://bugs.webkit.org/show_bug.cgi?id=190224
+
+ Reviewed by Joseph Pecoraro.
+
+ * UserInterface/Main.html:
+ * UserInterface/Base/Main.js:
+ (WI.loaded):
+ * UserInterface/Test.html:
+ * UserInterface/Test/Test.js:
+ (WI.loaded):
+
+ * UserInterface/Controllers/NetworkManager.js:
+ (WI.NetworkManager):
+ (WI.NetworkManager.prototype.downloadSourceMap): Added.
+ (WI.NetworkManager.prototype.resourceRequestWasServedFromMemoryCache):
+ (WI.NetworkManager.prototype.resourceRequestDidFinishLoading):
+ (WI.NetworkManager.prototype._createResource):
+ (WI.NetworkManager.prototype._loadAndParseSourceMap): Added.
+ (WI.NetworkManager.prototype._sourceMapLoadAndParseFailed): Added.
+ (WI.NetworkManager.prototype._sourceMapLoadAndParseSucceeded): Added.
+ (WI.NetworkManager.prototype._handleFrameMainResourceDidChange): Added.
+ * UserInterface/Controllers/SourceMapManager.js: Removed.
+
+ * UserInterface/Models/Script.js:
+ (WI.Script):
+
+ * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj:
+ * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters:
+
2018-10-02 Nikita Vasilyev <[email protected]>
Web Inspector: Styles: start editing property name/value on mouseup instead of mousedown
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2018-10-03 01:49:05 UTC (rev 236783)
@@ -123,7 +123,6 @@
this.applicationCacheManager = new WI.ApplicationCacheManager;
this.timelineManager = new WI.TimelineManager;
this.debuggerManager = new WI.DebuggerManager;
- this.sourceMapManager = new WI.SourceMapManager;
this.layerTreeManager = new WI.LayerTreeManager;
this.probeManager = new WI.ProbeManager;
this.workerManager = new WI.WorkerManager;
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js 2018-10-03 01:49:05 UTC (rev 236783)
@@ -37,6 +37,9 @@
this._waitingForMainFrameResourceTreePayload = true;
+ this._sourceMapURLMap = new Map;
+ this._downloadingSourceMaps = new Set;
+
if (window.PageAgent) {
PageAgent.enable();
PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this));
@@ -49,6 +52,7 @@
NetworkAgent.enable();
WI.notifications.addEventListener(WI.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this);
+ WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._handleFrameMainResourceDidChange, this);
}
// Public
@@ -73,6 +77,45 @@
return this._resourceRequestIdentifierMap.get(requestIdentifier) || null;
}
+ downloadSourceMap(sourceMapURL, baseURL, originalSourceCode)
+ {
+ // The baseURL could have come from a "//# sourceURL". Attempt to get a
+ // reasonable absolute URL for the base by using the main resource's URL.
+ if (WI.networkManager.mainFrame)
+ baseURL = absoluteURL(baseURL, WI.networkManager.mainFrame.url);
+
+ if (sourceMapURL.startsWith("data:")) {
+ this._loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode);
+ return;
+ }
+
+ sourceMapURL = absoluteURL(sourceMapURL, baseURL);
+ if (!sourceMapURL)
+ return;
+
+ console.assert(originalSourceCode.url);
+ if (!originalSourceCode.url)
+ return;
+
+ // FIXME: <rdar://problem/13265694> Source Maps: Better handle when multiple resources reference the same SourceMap
+
+ if (this._sourceMapURLMap.has(sourceMapURL) || this._downloadingSourceMaps.has(sourceMapURL))
+ return;
+
+ let loadAndParseSourceMap = () => {
+ this._loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode);
+ };
+
+ if (!WI.networkManager.mainFrame) {
+ // If we don't have a main frame, then we are likely in the middle of building the resource tree.
+ // Delaying until the next runloop is enough in this case to then start loading the source map.
+ setTimeout(loadAndParseSourceMap, 0);
+ return;
+ }
+
+ loadAndParseSourceMap();
+ }
+
frameDidNavigate(framePayload)
{
// Called from WI.PageObserver.
@@ -340,7 +383,7 @@
console.assert(resource.cached, "This resource should be classified as cached since it was served from the MemoryCache", resource);
if (cachedResourcePayload.sourceMapURL)
- WI.sourceMapManager.downloadSourceMap(cachedResourcePayload.sourceMapURL, resource.url, resource);
+ this.downloadSourceMap(cachedResourcePayload.sourceMapURL, resource.url, resource);
// No need to associate the resource with the requestIdentifier, since this is the only event
// sent for memory cache resource loads.
@@ -435,7 +478,7 @@
resource.markAsFinished(elapsedTime);
if (sourceMapURL)
- WI.sourceMapManager.downloadSourceMap(sourceMapURL, resource.url, resource);
+ this.downloadSourceMap(sourceMapURL, resource.url, resource);
this._resourceRequestIdentifierMap.delete(requestIdentifier);
}
@@ -701,7 +744,7 @@
var resource = new WI.Resource(payload.url, payload.mimeType, payload.type, framePayload.loaderId, payload.targetId);
if (payload.sourceMapURL)
- WI.sourceMapManager.downloadSourceMap(payload.sourceMapURL, resource.url, resource);
+ this.downloadSourceMap(payload.sourceMapURL, resource.url, resource);
return resource;
}
@@ -769,11 +812,102 @@
this.dispatchEventToListeners(WI.NetworkManager.Event.MainFrameDidChange, {oldMainFrame});
}
+ _loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode)
+ {
+ this._downloadingSourceMaps.add(sourceMapURL);
+
+ let sourceMapLoaded = (error, content, mimeType, statusCode) => {
+ if (error || statusCode >= 400) {
+ this._sourceMapLoadAndParseFailed(sourceMapURL);
+ return;
+ }
+
+ if (content.slice(0, 3) === ")]}") {
+ let firstNewlineIndex = content.indexOf("\n");
+ if (firstNewlineIndex === -1) {
+ this._sourceMapLoadAndParseFailed(sourceMapURL);
+ return;
+ }
+
+ content = content.substring(firstNewlineIndex);
+ }
+
+ try {
+ let payload = JSON.parse(content);
+ let baseURL = sourceMapURL.startsWith("data:") ? originalSourceCode.url : sourceMapURL;
+ let sourceMap = new WI.SourceMap(baseURL, payload, originalSourceCode);
+ this._sourceMapLoadAndParseSucceeded(sourceMapURL, sourceMap);
+ } catch {
+ this._sourceMapLoadAndParseFailed(sourceMapURL);
+ }
+ };
+
+ if (sourceMapURL.startsWith("data:")) {
+ let {mimeType, base64, data} = parseDataURL(sourceMapURL);
+ let content = base64 ? atob(data) : data;
+ sourceMapLoaded(null, content, mimeType, 0);
+ return;
+ }
+
+ if (!window.NetworkAgent) {
+ this._sourceMapLoadAndParseFailed(sourceMapURL);
+ return;
+ }
+
+ let frameIdentifier = null;
+ if (originalSourceCode instanceof WI.Resource && originalSourceCode.parentFrame)
+ frameIdentifier = originalSourceCode.parentFrame.id;
+
+ if (!frameIdentifier)
+ frameIdentifier = WI.networkManager.mainFrame ? WI.networkManager.mainFrame.id : "";
+
+ NetworkAgent.loadResource(frameIdentifier, sourceMapURL, sourceMapLoaded);
+ }
+
+ _sourceMapLoadAndParseFailed(ssourceMapLurceMapURL)
+ {
+ this._downloadingSourceMaps.delete(sourceMapURL);
+ }
+
+ _sourceMapLoadAndParseSucceeded(sourceMapURL, sourceMap)
+ {
+ if (!this._downloadingSourceMaps.has(sourceMapURL))
+ return;
+
+ this._downloadingSourceMaps.delete(sourceMapURL);
+
+ this._sourceMapURLMap.set(sourceMapURL, sourceMap);
+
+ for (let source of sourceMap.sources())
+ sourceMap.addResource(new WI.SourceMapResource(source, sourceMap));
+
+ // Associate the SourceMap with the originalSourceCode.
+ sourceMap.originalSourceCode.addSourceMap(sourceMap);
+
+ // If the originalSourceCode was not a Resource, be sure to also associate with the Resource if one exists.
+ // FIXME: We should try to use the right frame instead of a global lookup by URL.
+ if (!(sourceMap.originalSourceCode instanceof WI.Resource)) {
+ console.assert(sourceMap.originalSourceCode instanceof WI.Script);
+ let resource = sourceMap.originalSourceCode.resource;
+ if (resource)
+ resource.addSourceMap(sourceMap);
+ }
+ }
+
_extraDomainsActivated(event)
{
if (event.data.domains.includes("Page") && window.PageAgent)
PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this));
}
+
+ _handleFrameMainResourceDidChange(event)
+ {
+ if (!event.target.isMainFrame())
+ return;
+
+ this._sourceMapURLMap.clear();
+ this._downloadingSourceMaps.clear();
+ }
};
WI.NetworkManager.Event = {
Deleted: trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js 2018-10-03 01:49:05 UTC (rev 236783)
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. 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.
- */
-
-WI.SourceMapManager = class SourceMapManager extends WI.Object
-{
- constructor()
- {
- super();
-
- this._sourceMapURLMap = {};
- this._downloadingSourceMaps = {};
-
- WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
- }
-
- // Public
-
- sourceMapForURL(sourceMapURL)
- {
- return this._sourceMapURLMap[sourceMapURL];
- }
-
- downloadSourceMap(sourceMapURL, baseURL, originalSourceCode)
- {
- // The baseURL could have come from a "//# sourceURL". Attempt to get a
- // reasonable absolute URL for the base by using the main resource's URL.
- if (WI.networkManager.mainFrame)
- baseURL = absoluteURL(baseURL, WI.networkManager.mainFrame.url);
-
- if (sourceMapURL.startsWith("data:")) {
- this._loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode);
- return;
- }
-
- sourceMapURL = absoluteURL(sourceMapURL, baseURL);
- if (!sourceMapURL)
- return;
-
- console.assert(originalSourceCode.url);
- if (!originalSourceCode.url)
- return;
-
- // FIXME: <rdar://problem/13265694> Source Maps: Better handle when multiple resources reference the same SourceMap
-
- if (sourceMapURL in this._sourceMapURLMap)
- return;
-
- if (sourceMapURL in this._downloadingSourceMaps)
- return;
-
- function loadAndParseSourceMap()
- {
- this._loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode);
- }
-
- if (!WI.networkManager.mainFrame) {
- // If we don't have a main frame, then we are likely in the middle of building the resource tree.
- // Delaying until the next runloop is enough in this case to then start loading the source map.
- setTimeout(loadAndParseSourceMap.bind(this), 0);
- return;
- }
-
- loadAndParseSourceMap.call(this);
- }
-
- // Private
-
- _loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode)
- {
- this._downloadingSourceMaps[sourceMapURL] = true;
-
- function sourceMapLoaded(error, content, mimeType, statusCode)
- {
- if (error || statusCode >= 400) {
- this._loadAndParseFailed(sourceMapURL);
- return;
- }
-
- if (content.slice(0, 3) === ")]}") {
- var firstNewlineIndex = content.indexOf("\n");
- if (firstNewlineIndex === -1) {
- this._loadAndParseFailed(sourceMapURL);
- return;
- }
-
- content = content.substring(firstNewlineIndex);
- }
-
- try {
- var payload = JSON.parse(content);
- var baseURL = sourceMapURL.startsWith("data:") ? originalSourceCode.url : sourceMapURL;
- var sourceMap = new WI.SourceMap(baseURL, payload, originalSourceCode);
- this._loadAndParseSucceeded(sourceMapURL, sourceMap);
- } catch {
- this._loadAndParseFailed(sourceMapURL);
- }
- }
-
- if (sourceMapURL.startsWith("data:")) {
- let {mimeType, base64, data} = parseDataURL(sourceMapURL);
- let content = base64 ? atob(data) : data;
- sourceMapLoaded.call(this, null, content, mimeType, 0);
- return;
- }
-
- if (!window.NetworkAgent) {
- this._loadAndParseFailed(sourceMapURL);
- return;
- }
-
- var frameIdentifier = null;
- if (originalSourceCode instanceof WI.Resource && originalSourceCode.parentFrame)
- frameIdentifier = originalSourceCode.parentFrame.id;
-
- if (!frameIdentifier)
- frameIdentifier = WI.networkManager.mainFrame ? WI.networkManager.mainFrame.id : "";
-
- NetworkAgent.loadResource(frameIdentifier, sourceMapURL, sourceMapLoaded.bind(this));
- }
-
- _loadAndParseFailed(sourceMapURL)
- {
- delete this._downloadingSourceMaps[sourceMapURL];
- }
-
- _loadAndParseSucceeded(sourceMapURL, sourceMap)
- {
- if (!(sourceMapURL in this._downloadingSourceMaps))
- return;
-
- delete this._downloadingSourceMaps[sourceMapURL];
-
- this._sourceMapURLMap[sourceMapURL] = sourceMap;
-
- var sources = sourceMap.sources();
- for (var i = 0; i < sources.length; ++i) {
- var sourceMapResource = new WI.SourceMapResource(sources[i], sourceMap);
- sourceMap.addResource(sourceMapResource);
- }
-
- // Associate the SourceMap with the originalSourceCode.
- sourceMap.originalSourceCode.addSourceMap(sourceMap);
-
- // If the originalSourceCode was not a Resource, be sure to also associate with the Resource if one exists.
- // FIXME: We should try to use the right frame instead of a global lookup by URL.
- if (!(sourceMap.originalSourceCode instanceof WI.Resource)) {
- console.assert(sourceMap.originalSourceCode instanceof WI.Script);
- var resource = sourceMap.originalSourceCode.resource;
- if (resource)
- resource.addSourceMap(sourceMap);
- }
- }
-
- _mainResourceDidChange(event)
- {
- if (!event.target.isMainFrame())
- return;
-
- this._sourceMapURLMap = {};
- this._downloadingSourceMaps = {};
- }
-};
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2018-10-03 01:49:05 UTC (rev 236783)
@@ -810,7 +810,6 @@
<script src=""
<script src=""
<script src=""
- <script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2018-10-03 01:49:05 UTC (rev 236783)
@@ -65,7 +65,7 @@
}
if (this._sourceMappingURL)
- WI.sourceMapManager.downloadSourceMap(this._sourceMappingURL, this._url, this);
+ WI.networkManager.downloadSourceMap(this._sourceMappingURL, this._url, this);
}
// Static
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/Test.js (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Test/Test.js 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/Test.js 2018-10-03 01:49:05 UTC (rev 236783)
@@ -59,7 +59,6 @@
this.memoryManager = new WI.MemoryManager;
this.timelineManager = new WI.TimelineManager;
this.debuggerManager = new WI.DebuggerManager;
- this.sourceMapManager = new WI.SourceMapManager;
this.layerTreeManager = new WI.LayerTreeManager;
this.probeManager = new WI.ProbeManager;
this.workerManager = new WI.WorkerManager;
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (236782 => 236783)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2018-10-03 01:49:05 UTC (rev 236783)
@@ -224,7 +224,6 @@
<script src=""
<script src=""
<script src=""
- <script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj (236782 => 236783)
--- trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj 2018-10-03 01:49:05 UTC (rev 236783)
@@ -775,7 +775,6 @@
<None Include="..\UserInterface\SourceCodeTextRange.js" />
<None Include="..\UserInterface\SourceCodeTreeElement.js" />
<None Include="..\UserInterface\SourceMap.js" />
- <None Include="..\UserInterface\SourceMapManager.js" />
<None Include="..\UserInterface\SourceMapResource.js" />
<None Include="..\UserInterface\SourceMapResourceTreeElement.js" />
<None Include="..\UserInterface\StorageTreeElement.js" />
Modified: trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters (236782 => 236783)
--- trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters 2018-10-03 00:48:59 UTC (rev 236782)
+++ trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters 2018-10-03 01:49:05 UTC (rev 236783)
@@ -921,9 +921,6 @@
<None Include="..\UserInterface\SourceMap.js">
<Filter>UserInterface</Filter>
</None>
- <None Include="..\UserInterface\SourceMapManager.js">
- <Filter>UserInterface</Filter>
- </None>
<None Include="..\UserInterface\SourceMapResource.js">
<Filter>UserInterface</Filter>
</None>