summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/source.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /devtools/client/debugger/src/utils/source.js
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/utils/source.js')
-rw-r--r--devtools/client/debugger/src/utils/source.js95
1 files changed, 5 insertions, 90 deletions
diff --git a/devtools/client/debugger/src/utils/source.js b/devtools/client/debugger/src/utils/source.js
index 31920453eb..91a02778e2 100644
--- a/devtools/client/debugger/src/utils/source.js
+++ b/devtools/client/debugger/src/utils/source.js
@@ -17,7 +17,6 @@ const {
import { getRelativePath } from "../utils/sources-tree/utils";
import { endTruncateStr } from "./utils";
import { truncateMiddleText } from "../utils/text";
-import { parse as parseURL } from "../utils/url";
import { memoizeLast } from "../utils/memoizeLast";
import { renderWasmText } from "./wasm";
import { toEditorLine } from "./editor/index";
@@ -214,33 +213,10 @@ export function getFormattedSourceId(id) {
}
/**
- * Gets a readable filename from a source URL for display purposes.
- * If the source does not have a URL, the source ID will be returned instead.
- *
- * @memberof utils/source
- * @static
- */
-export function getFilename(
- source,
- rawSourceURL = getRawSourceURL(source.url)
-) {
- const { id } = source;
- if (!rawSourceURL) {
- return getFormattedSourceId(id);
- }
-
- const { filename } = source.displayURL;
- return getRawSourceURL(filename);
-}
-
-/**
- * Provides a middle-trunated filename
- *
- * @memberof utils/source
- * @static
+ * Provides a middle-truncated filename displayed in Tab titles
*/
-export function getTruncatedFileName(source, querystring = "", length = 30) {
- return truncateMiddleText(`${getFilename(source)}${querystring}`, length);
+export function getTruncatedFileName(source) {
+ return truncateMiddleText(source.longName, 30);
}
/* Gets path for files with same filename for editor tabs, breakpoints, etc.
@@ -252,15 +228,13 @@ export function getTruncatedFileName(source, querystring = "", length = 30) {
export function getDisplayPath(mySource, sources) {
const rawSourceURL = getRawSourceURL(mySource.url);
- const filename = getFilename(mySource, rawSourceURL);
+ const filename = mySource.shortName;
// Find sources that have the same filename, but different paths
// as the original source
const similarSources = sources.filter(source => {
const rawSource = getRawSourceURL(source.url);
- return (
- rawSourceURL != rawSource && filename == getFilename(source, rawSource)
- );
+ return rawSourceURL != rawSource && filename == source.shortName;
});
if (!similarSources.length) {
@@ -314,16 +288,6 @@ export function getFileURL(source, truncate = true) {
return resolveFileURL(url, getUnicodeUrl, truncate);
}
-export function getSourcePath(url) {
- if (!url) {
- return "";
- }
-
- const { path, href } = parseURL(url);
- // for URLs like "about:home" the path is null so we pass the full href
- return path || href;
-}
-
/**
* Returns amount of lines in the source. If source is a WebAssembly binary,
* the function returns amount of bytes.
@@ -345,10 +309,6 @@ export function getSourceLineCount(content) {
return count + 1;
}
-export function isInlineScript(source) {
- return source.introductionType === "scriptElement";
-}
-
function getNthLine(str, lineNum) {
let startIndex = -1;
@@ -454,51 +414,6 @@ export function getRelativeUrl(source, root) {
return url.slice(url.indexOf(root) + root.length + 1);
}
-/**
- * source.url doesn't include thread actor ID, so before calling underRoot(), the thread actor ID
- * must be removed from the root, which this function handles.
- * @param {string} root The root url to be cleaned
- * @param {Set<Thread>} threads The list of threads
- * @returns {string} The root url with thread actor IDs removed
- */
-export function removeThreadActorId(root, threads) {
- threads.forEach(thread => {
- if (root.includes(thread.actor)) {
- root = root.slice(thread.actor.length + 1);
- }
- });
- return root;
-}
-
-/**
- * Checks if the source is descendant of the root identified by the
- * root url specified. The root might likely be projectDirectoryRoot which
- * is a defined by a pref that allows users restrict the source tree to
- * a subset of sources.
- *
- * @param {Object} source
- * The source object
- * @param {String} rootUrlWithoutThreadActor
- * The url for the root node, without the thread actor ID. This can be obtained
- * by calling removeThreadActorId()
- */
-export function isDescendantOfRoot(source, rootUrlWithoutThreadActor) {
- if (source.url && source.url.includes("chrome://")) {
- const { group, path } = source.displayURL;
- return (group + path).includes(rootUrlWithoutThreadActor);
- }
-
- return !!source.url && source.url.includes(rootUrlWithoutThreadActor);
-}
-
-export function getSourceQueryString(source) {
- if (!source) {
- return "";
- }
-
- return parseURL(getRawSourceURL(source.url)).search;
-}
-
export function isUrlExtension(url) {
return url.includes("moz-extension:") || url.includes("chrome-extension");
}