Skip to content

Commit

Permalink
DevTools: merge uisourcecode's url-alike members.
Browse files Browse the repository at this point in the history
Review URL: https://codereview.chromium.org/1564113003

Cr-Commit-Position: refs/heads/master@{#368639}
  • Loading branch information
pavelfeldman authored and Commit bot committed Jan 11, 2016
1 parent af12426 commit 2ccd467
Show file tree
Hide file tree
Showing 27 changed files with 198 additions and 237 deletions.
4 changes: 2 additions & 2 deletions front_end/bindings/BreakpointManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ WebInspector.BreakpointManager.prototype = {
var networkURL = this._networkMapping.networkURL(uiSourceCode)
if (!networkURL)
return "";
return uiSourceCode.uri();
return uiSourceCode.url();
},

/**
Expand Down Expand Up @@ -243,7 +243,7 @@ WebInspector.BreakpointManager.prototype = {
return breakpoint;
}
var projectId = uiSourceCode.project().id();
var path = uiSourceCode.path();
var path = uiSourceCode.url();
var sourceFileId = this._sourceFileId(uiSourceCode);
breakpoint = new WebInspector.BreakpointManager.Breakpoint(this, projectId, path, sourceFileId, lineNumber, columnNumber, condition, enabled);
if (!this._breakpointsForPrimaryUISourceCode.get(uiSourceCode))
Expand Down
4 changes: 2 additions & 2 deletions front_end/bindings/CompilerScriptMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ WebInspector.CompilerScriptMapping.prototype = {
this._stubUISourceCodes.set(script.scriptId, stubUISourceCode);

this._debuggerWorkspaceBinding.pushSourceMapping(script, this);
this._loadSourceMapForScript(script, this._sourceMapLoaded.bind(this, script, stubUISourceCode.path()));
this._loadSourceMapForScript(script, this._sourceMapLoaded.bind(this, script, stubUISourceCode.url()));
},

/**
Expand Down Expand Up @@ -212,7 +212,7 @@ WebInspector.CompilerScriptMapping.prototype = {
continue;
this._sourceMapForURL.set(sourceURL, sourceMap);
var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceURL, script);
if (!uiSourceCode && !this._networkMapping.hasMappingForURL(sourceURL)) {
if (!uiSourceCode && !this._networkMapping.hasMappingForNetworkURL(sourceURL)) {
var contentProvider = sourceMap.sourceContentProvider(sourceURL, WebInspector.resourceTypes.SourceMapScript);
uiSourceCode = this._networkProject.addFileForURL(sourceURL, contentProvider, WebInspector.ResourceTreeFrame.fromScript(script), script.isContentScript());
uiSourceCode[WebInspector.CompilerScriptMapping._originSymbol] = script.sourceURL;
Expand Down
8 changes: 4 additions & 4 deletions front_end/bindings/ContentProviderBasedProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ WebInspector.ContentProviderBasedProject.prototype = {
*/
requestFileContent: function(uiSourceCode, callback)
{
var contentProvider = this._contentProviders[uiSourceCode.path()];
var contentProvider = this._contentProviders[uiSourceCode.url()];
contentProvider.requestContent(callback);

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ WebInspector.ContentProviderBasedProject.prototype = {
*/
rename: function(uiSourceCode, newName, callback)
{
var path = uiSourceCode.path();
var path = uiSourceCode.url();
this.performRename(path, newName, innerCallback.bind(this));

/**
Expand Down Expand Up @@ -191,7 +191,7 @@ WebInspector.ContentProviderBasedProject.prototype = {
*/
searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback)
{
var contentProvider = this._contentProviders[uiSourceCode.path()];
var contentProvider = this._contentProviders[uiSourceCode.url()];
contentProvider.searchInContent(query, caseSensitive, isRegex, callback);
},

Expand Down Expand Up @@ -289,7 +289,7 @@ WebInspector.ContentProviderBasedProject.prototype = {
*/
addUISourceCodeWithProvider: function(uiSourceCode, contentProvider)
{
this._contentProviders[uiSourceCode.path()] = contentProvider;
this._contentProviders[uiSourceCode.url()] = contentProvider;
this.addUISourceCode(uiSourceCode, true);
},

Expand Down
22 changes: 11 additions & 11 deletions front_end/bindings/FileSystemWorkspaceBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath)
WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode)
{
var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem}*/(uiSourceCode.project())._fileSystemBaseURL;
return uiSourceCode.path().substring(baseURL.length).split("/");
return uiSourceCode.url().substring(baseURL.length).split("/");
}

/**
Expand Down Expand Up @@ -203,7 +203,7 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
*/
_filePathForUISourceCode: function(uiSourceCode)
{
return uiSourceCode.path().substring(this._fileSystemPath.length);
return uiSourceCode.url().substring(this._fileSystemPath.length);
},

/**
Expand Down Expand Up @@ -271,7 +271,7 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
rename: function(uiSourceCode, newName, callback)
{
if (newName === uiSourceCode.name()) {
callback(true, uiSourceCode.name(), uiSourceCode.originURL(), uiSourceCode.contentType());
callback(true, uiSourceCode.name(), uiSourceCode.url(), uiSourceCode.contentType());
return;
}

Expand All @@ -295,10 +295,10 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
filePath = parentPath + "/" + newName;
filePath = filePath.substr(1);
var extension = this._extensionForPath(newName);
var newOriginURL = this._fileSystemBaseURL + filePath;
var newURL = this._fileSystemBaseURL + filePath;
var newContentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(extension);
this.renameUISourceCode(uiSourceCode, newName);
callback(true, newName, newOriginURL, newContentType);
callback(true, newName, newURL, newContentType);
}
},

Expand Down Expand Up @@ -408,11 +408,11 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {

/**
* @override
* @param {string} path
* @param {string} url
*/
excludeFolder: function(path)
excludeFolder: function(url)
{
var relativeFolder = path.substring(this._fileSystemBaseURL.length);
var relativeFolder = url.substring(this._fileSystemBaseURL.length);
if (!relativeFolder.startsWith("/"))
relativeFolder = "/" + relativeFolder;
if (!relativeFolder.endsWith("/"))
Expand All @@ -422,8 +422,8 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
var uiSourceCodes = this.uiSourceCodes().slice();
for (var i = 0; i < uiSourceCodes.length; ++i) {
var uiSourceCode = uiSourceCodes[i];
if (uiSourceCode.path().startsWith(path))
this.removeUISourceCode(uiSourceCode.path());
if (uiSourceCode.url().startsWith(url))
this.removeUISourceCode(uiSourceCode.url());
}
},

Expand Down Expand Up @@ -506,7 +506,7 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
*/
_fileChanged: function(path)
{
var uiSourceCode = this.uiSourceCode(path);
var uiSourceCode = this.uiSourceCodeForURL(path);
if (!uiSourceCode) {
this._addFile(path);
return;
Expand Down
25 changes: 11 additions & 14 deletions front_end/bindings/NetworkMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ WebInspector.NetworkMapping.prototype = {
{
if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
var fileSystemPath = this._fileSystemWorkspaceBinding.fileSystemPath(uiSourceCode.project().id());
return this._urlForPath(fileSystemPath, uiSourceCode.path());
return this._networkURLForFileSystemURL(fileSystemPath, uiSourceCode.url());
}
return uiSourceCode.originURL();
return uiSourceCode.url();
},

/**
* @param {string} url
* @return {boolean}
*/
hasMappingForURL: function(url)
hasMappingForNetworkURL: function(url)
{
return this._fileSystemMapping.hasMappingForURL(url);
return this._fileSystemMapping.hasMappingForNetworkURL(url);
},

/**
Expand All @@ -99,8 +99,7 @@ WebInspector.NetworkMapping.prototype = {
*/
_networkUISourceCodeForURL: function(target, frame, url)
{
var project = this._workspace.project(WebInspector.NetworkProject.projectId(target, frame, false));
return project ? project.uiSourceCode(url) : null;
return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectId(target, frame, false), url);
},

/**
Expand All @@ -111,8 +110,7 @@ WebInspector.NetworkMapping.prototype = {
*/
_contentScriptUISourceCodeForURL: function(target, frame, url)
{
var project = this._workspace.project(WebInspector.NetworkProject.projectId(target, frame, true));
return project ? project.uiSourceCode(url) : null;
return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectId(target, frame, true), url);
},

/**
Expand All @@ -124,8 +122,7 @@ WebInspector.NetworkMapping.prototype = {
var file = this._fileSystemMapping.fileForURL(url);
if (file) {
var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(file.fileSystemPath);
var project = this._workspace.project(projectId);
return project ? project.uiSourceCode(file.fileURL) : null;
return this._workspace.uiSourceCode(projectId, file.fileURL);
}
return null;
},
Expand Down Expand Up @@ -169,17 +166,17 @@ WebInspector.NetworkMapping.prototype = {
*/
uiSourceCodeForURLForAnyTarget: function(url)
{
return this._fileSystemUISourceCodeForURL(url) || WebInspector.workspace.uiSourceCodeForOriginURL(url);
return this._fileSystemUISourceCodeForURL(url) || WebInspector.workspace.uiSourceCodeForURL(url);
},

/**
* @param {string} fileSystemPath
* @param {string} filePath
* @return {string}
*/
_urlForPath: function(fileSystemPath, filePath)
_networkURLForFileSystemURL: function(fileSystemPath, filePath)
{
return this._fileSystemMapping.urlForPath(fileSystemPath, filePath);
return this._fileSystemMapping.networkURLForFileSystemURL(fileSystemPath, filePath);
},

/**
Expand All @@ -189,7 +186,7 @@ WebInspector.NetworkMapping.prototype = {
addMapping: function(networkUISourceCode, uiSourceCode)
{
var url = this.networkURL(networkUISourceCode);
var path = uiSourceCode.path();
var path = uiSourceCode.url();
var fileSystemPath = this._fileSystemWorkspaceBinding.fileSystemPath(uiSourceCode.project().id());
this._fileSystemMapping.addMappingForResource(url, fileSystemPath, path);
},
Expand Down
6 changes: 3 additions & 3 deletions front_end/bindings/NetworkProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ WebInspector.NetworkProject.uiSourceCodeMimeType = function(uiSourceCode)
var resource = uiSourceCode[WebInspector.NetworkProject._resourceSymbol];
if (resource)
return resource.mimeType;
var mimeType = WebInspector.ResourceType.mimeFromURL(uiSourceCode.originURL());
var mimeType = WebInspector.ResourceType.mimeFromURL(uiSourceCode.url());
return mimeType || uiSourceCode.contentType().canonicalMimeType();
}

Expand Down Expand Up @@ -357,7 +357,7 @@ WebInspector.NetworkProject.prototype = {
return;

// Never load document twice.
if (this._workspace.uiSourceCodeForOriginURL(resource.url))
if (this._workspace.uiSourceCodeForURL(resource.url))
return;

var uiSourceCode = this._createFile(resource.url, resource, WebInspector.ResourceTreeFrame.fromResource(resource), false, false);
Expand Down Expand Up @@ -408,7 +408,7 @@ WebInspector.NetworkProject.prototype = {
*/
_createFile: function(url, contentProvider, frame, isContentScript, addIntoProject)
{
if (this._networkMapping.hasMappingForURL(url))
if (this._networkMapping.hasMappingForNetworkURL(url))
return null;

var project = this._workspaceProject(frame, isContentScript);
Expand Down
2 changes: 1 addition & 1 deletion front_end/bindings/SASSSourceMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ WebInspector.SASSSourceMapping.prototype = {
var sources = sourceMap ? sourceMap.sources() : [];
for (var i = 0; i < sources.length; ++i) {
var sassURL = sources[i];
if (!this._networkMapping.hasMappingForURL(sassURL)) {
if (!this._networkMapping.hasMappingForNetworkURL(sassURL)) {
var contentProvider = sourceMap.sourceContentProvider(sassURL, WebInspector.resourceTypes.SourceMapStyleSheet);
this._networkProject.addFileForURL(sassURL, contentProvider, WebInspector.ResourceTreeFrame.fromStyleSheet(header));
}
Expand Down
17 changes: 17 additions & 0 deletions front_end/common/ParsedURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ WebInspector.ParsedURL.splitURLIntoPathComponents = function(url)
return result;
}

/**
* @param {string} url
* @return {string}
*/
WebInspector.ParsedURL.extractOrigin = function(url)
{
var decodedURL = WebInspector.ParsedURL._decodeIfPossible(url);
var parsedURL = new WebInspector.ParsedURL(decodedURL);
if (!parsedURL.isValid)
return "";

var origin = parsedURL.scheme + "://" + parsedURL.host;
if (parsedURL.port)
origin += ":" + parsedURL.port;
return origin;
}

/**
* @param {string} baseURL
* @param {string} href
Expand Down
2 changes: 1 addition & 1 deletion front_end/components/Linkifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ WebInspector.Linkifier.DefaultFormatter.prototype = {
text = text.trimMiddle(this._maxLength);
anchor.textContent = text;

var titleText = uiLocation.uiSourceCode.originURL();
var titleText = uiLocation.uiSourceCode.url();
if (typeof uiLocation.lineNumber === "number")
titleText += ":" + (uiLocation.lineNumber + 1);
anchor.title = titleText;
Expand Down
2 changes: 1 addition & 1 deletion front_end/emulation/MediaQueryInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ WebInspector.MediaQueryInspector.prototype = {
var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILocation(locations[i]);
if (!uiLocation)
continue;
var descriptor = String.sprintf("%s:%d:%d", uiLocation.uiSourceCode.uri(), uiLocation.lineNumber + 1, uiLocation.columnNumber + 1);
var descriptor = String.sprintf("%s:%d:%d", uiLocation.uiSourceCode.url(), uiLocation.lineNumber + 1, uiLocation.columnNumber + 1);
uiLocations.set(descriptor, uiLocation);
}

Expand Down
6 changes: 3 additions & 3 deletions front_end/extensions/ExtensionServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ WebInspector.ExtensionServer.prototype = {
_handleOpenURL: function(port, details)
{
var url = /** @type {string} */ (details.url);
var contentProvider = WebInspector.workspace.uiSourceCodeForOriginURL(url) || WebInspector.resourceForURL(url);
var contentProvider = WebInspector.workspace.uiSourceCodeForURL(url) || WebInspector.resourceForURL(url);
if (!contentProvider)
return false;

Expand Down Expand Up @@ -538,7 +538,7 @@ WebInspector.ExtensionServer.prototype = {
_onGetResourceContent: function(message, port)
{
var url = /** @type {string} */ (message.url);
var contentProvider = WebInspector.workspace.uiSourceCodeForOriginURL(url) || WebInspector.resourceForURL(url);
var contentProvider = WebInspector.workspace.uiSourceCodeForURL(url) || WebInspector.resourceForURL(url);
if (!contentProvider)
return this._status.E_NOTFOUND(url);
this._getResourceContent(contentProvider, message, port);
Expand All @@ -557,7 +557,7 @@ WebInspector.ExtensionServer.prototype = {
}

var url = /** @type {string} */ (message.url);
var uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(url);
var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url);
if (!uiSourceCode || !uiSourceCode.contentType().isDocumentOrScriptOrStyleSheet()) {
var resource = WebInspector.ResourceTreeModel.resourceForURL(url);
if (!resource)
Expand Down
6 changes: 3 additions & 3 deletions front_end/main/FrontendWebSocketAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WebInspector.FrontendWebSocketAPI.prototype = {
{
var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarget(url);
if (uiSourceCode)
url = uiSourceCode.originURL();
url = uiSourceCode.url();
if (url.startsWith("file://")) {
var file = url.substring(7);
this._issueFrontendAPINotification("Frontend.revealLocation", { file: file, line: lineNumber });
Expand Down Expand Up @@ -69,7 +69,7 @@ WebInspector.FrontendWebSocketAPI.prototype = {
var file = params["file"];
var buffer = params["buffer"];
var saved = params["saved"];
var uiSourceCode = WebInspector.workspace.filesystemUISourceCode("file://" + file);
var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL("file://" + file);
if (uiSourceCode) {
if (buffer !== uiSourceCode.workingCopy())
uiSourceCode.setWorkingCopy(buffer);
Expand All @@ -93,7 +93,7 @@ WebInspector.FrontendWebSocketAPI.prototype = {
if (this._dispatchingFrontendMessage)
return;
var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data["uiSourceCode"]);
var url = uiSourceCode.originURL();
var url = uiSourceCode.url();
if (url.startsWith("file://"))
url = url.substring(7);
var params = { file: url, buffer: uiSourceCode.workingCopy() };
Expand Down
Loading

0 comments on commit 2ccd467

Please sign in to comment.