mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-28 00:45:04 +08:00
Partly type path and URL variables in files in panels/ to Branded Types
Bug: 1299782 Change-Id: If35a3832e990affb4ef0a0918a290f58fcb0ca87 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3566003 Reviewed-by: Eric Leese <leese@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Kateryna Prokopenko <kprokopenko@chromium.org>
This commit is contained in:
committed by
Devtools-frontend LUCI CQ
parent
768dea3c3c
commit
d05ac48187
@@ -808,9 +808,9 @@ export class DOMNode {
|
||||
traverse(this);
|
||||
}
|
||||
|
||||
resolveURL(url: string): string|null {
|
||||
resolveURL(url: string): Platform.DevToolsPath.UrlString|null {
|
||||
if (!url) {
|
||||
return url;
|
||||
return url as Platform.DevToolsPath.UrlString;
|
||||
}
|
||||
for (let frameOwnerCandidate: (DOMNode|null) = (this as DOMNode | null); frameOwnerCandidate;
|
||||
frameOwnerCandidate = frameOwnerCandidate.parentNode) {
|
||||
|
||||
@@ -266,9 +266,7 @@ export class CoverageListView extends UI.Widget.VBox {
|
||||
return;
|
||||
}
|
||||
const coverageInfo = (node as GridNode).coverageInfo;
|
||||
// TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
|
||||
let sourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(
|
||||
coverageInfo.url() as Platform.DevToolsPath.UrlString);
|
||||
let sourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(coverageInfo.url());
|
||||
if (!sourceCode) {
|
||||
return;
|
||||
}
|
||||
@@ -317,7 +315,7 @@ function getPercentageFormatter(): Intl.NumberFormat {
|
||||
export class GridNode extends DataGrid.SortableDataGrid.SortableDataGridNode<GridNode> {
|
||||
coverageInfo: URLCoverageInfo;
|
||||
private lastUsedSize!: number|undefined;
|
||||
private url: string;
|
||||
private url: Platform.DevToolsPath.UrlString;
|
||||
private maxSize: number;
|
||||
private highlightRegExp: RegExp|null;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class CoverageModel extends SDK.SDKModel.SDKModel<EventTypes> {
|
||||
private cpuProfilerModel: SDK.CPUProfilerModel.CPUProfilerModel|null;
|
||||
private cssModel: SDK.CSSModel.CSSModel|null;
|
||||
private debuggerModel: SDK.DebuggerModel.DebuggerModel|null;
|
||||
private coverageByURL: Map<string, URLCoverageInfo>;
|
||||
private coverageByURL: Map<Platform.DevToolsPath.UrlString, URLCoverageInfo>;
|
||||
private coverageByContentProvider: Map<TextUtils.ContentProvider.ContentProvider, CoverageInfo>;
|
||||
private coverageUpdateTimes: Set<number>;
|
||||
private suspensionState: SuspensionState;
|
||||
@@ -216,7 +216,7 @@ export class CoverageModel extends SDK.SDKModel.SDKModel<EventTypes> {
|
||||
return Array.from(this.coverageByURL.values());
|
||||
}
|
||||
|
||||
getCoverageForUrl(url: string): URLCoverageInfo|null {
|
||||
getCoverageForUrl(url: Platform.DevToolsPath.UrlString): URLCoverageInfo|null {
|
||||
return this.coverageByURL.get(url) || null;
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ export class CoverageModel extends SDK.SDKModel.SDKModel<EventTypes> {
|
||||
SDK.SDKModel.SDKModel.register(CoverageModel, {capabilities: SDK.Target.Capability.None, autostart: false});
|
||||
|
||||
export interface EntryForExport {
|
||||
url: string;
|
||||
url: Platform.DevToolsPath.UrlString;
|
||||
ranges: {start: number, end: number}[];
|
||||
text: string|null;
|
||||
}
|
||||
@@ -495,14 +495,14 @@ function locationCompare(a: string, b: string): number {
|
||||
}
|
||||
|
||||
export class URLCoverageInfo extends Common.ObjectWrapper.ObjectWrapper<URLCoverageInfo.EventTypes> {
|
||||
private readonly urlInternal: string;
|
||||
private readonly urlInternal: Platform.DevToolsPath.UrlString;
|
||||
private coverageInfoByLocation: Map<string, CoverageInfo>;
|
||||
private sizeInternal: number;
|
||||
private usedSizeInternal: number;
|
||||
private typeInternal!: CoverageType;
|
||||
private isContentScriptInternal: boolean;
|
||||
|
||||
constructor(url: string) {
|
||||
constructor(url: Platform.DevToolsPath.UrlString) {
|
||||
super();
|
||||
|
||||
this.urlInternal = url;
|
||||
@@ -512,7 +512,7 @@ export class URLCoverageInfo extends Common.ObjectWrapper.ObjectWrapper<URLCover
|
||||
this.isContentScriptInternal = false;
|
||||
}
|
||||
|
||||
url(): string {
|
||||
url(): Platform.DevToolsPath.UrlString {
|
||||
return this.urlInternal;
|
||||
}
|
||||
|
||||
@@ -618,8 +618,7 @@ export class URLCoverageInfo extends Common.ObjectWrapper.ObjectWrapper<URLCover
|
||||
if (!useFullText) {
|
||||
return null;
|
||||
}
|
||||
// TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
|
||||
const resource = SDK.ResourceTreeModel.ResourceTreeModel.resourceForURL(url as Platform.DevToolsPath.UrlString);
|
||||
const resource = SDK.ResourceTreeModel.ResourceTreeModel.resourceForURL(url);
|
||||
if (!resource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ export class ImagePreviewPopover {
|
||||
this.popover.hidePopover();
|
||||
}
|
||||
|
||||
static setImageUrl(element: Element, url: string): Element {
|
||||
static setImageUrl(element: Element, url: Platform.DevToolsPath.UrlString): Element {
|
||||
elementToURLMap.set(element, url);
|
||||
return element;
|
||||
}
|
||||
|
||||
static getImageURL(element: Element): string|undefined {
|
||||
static getImageURL(element: Element): Platform.DevToolsPath.UrlString|undefined {
|
||||
return elementToURLMap.get(element);
|
||||
}
|
||||
}
|
||||
|
||||
const elementToURLMap = new WeakMap<Element, string>();
|
||||
const elementToURLMap = new WeakMap<Element, Platform.DevToolsPath.UrlString>();
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// TODO(crbug.com/1253323): Casts to UrlString will be removed from this file when migration to branded types is complete.
|
||||
|
||||
import * as Common from '../../core/common/common.js';
|
||||
import * as Host from '../../core/host/host.js';
|
||||
import * as i18n from '../../core/i18n/i18n.js';
|
||||
@@ -260,7 +258,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
|
||||
private readonly resizeThrottler: Common.Throttler.Throttler;
|
||||
private readonly imagePreviewPopover: ImagePreviewPopover;
|
||||
activeCSSAngle: InlineEditor.CSSAngle.CSSAngle|null;
|
||||
#urlToChangeTracker: Map<string, ChangeTracker> = new Map();
|
||||
#urlToChangeTracker: Map<Platform.DevToolsPath.UrlString, ChangeTracker> = new Map();
|
||||
|
||||
static instance(): StylesSidebarPane {
|
||||
if (!stylesSidebarPaneInstance) {
|
||||
@@ -1087,7 +1085,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
|
||||
return sections;
|
||||
}
|
||||
|
||||
async trackURLForChanges(url: string): Promise<void> {
|
||||
async trackURLForChanges(url: Platform.DevToolsPath.UrlString): Promise<void> {
|
||||
const currentTracker = this.#urlToChangeTracker.get(url);
|
||||
if (currentTracker) {
|
||||
WorkspaceDiff.WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(
|
||||
@@ -1095,8 +1093,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
|
||||
}
|
||||
|
||||
// We get a refreshed uiSourceCode each time because the underlying instance may be recreated.
|
||||
const uiSourceCode =
|
||||
Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(url as Platform.DevToolsPath.UrlString);
|
||||
const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(url);
|
||||
if (!uiSourceCode) {
|
||||
return;
|
||||
}
|
||||
@@ -3394,14 +3391,14 @@ export class StylesSidebarPropertyRenderer {
|
||||
|
||||
private processURL(text: string): Node {
|
||||
// Strip "url(" and ")" along with whitespace.
|
||||
let url = text.substring(4, text.length - 1).trim();
|
||||
let url = text.substring(4, text.length - 1).trim() as Platform.DevToolsPath.UrlString;
|
||||
const isQuoted = /^'.*'$/s.test(url) || /^".*"$/s.test(url);
|
||||
if (isQuoted) {
|
||||
url = url.substring(1, url.length - 1);
|
||||
url = Common.ParsedURL.ParsedURL.substring(url, 1, url.length - 1);
|
||||
}
|
||||
const container = document.createDocumentFragment();
|
||||
UI.UIUtils.createTextChild(container, 'url(');
|
||||
let hrefUrl: (string|null)|null = null;
|
||||
let hrefUrl: Platform.DevToolsPath.UrlString|null = null;
|
||||
if (this.rule && this.rule.resourceURL()) {
|
||||
hrefUrl = Common.ParsedURL.ParsedURL.completeURL(this.rule.resourceURL(), url);
|
||||
} else if (this.node) {
|
||||
|
||||
@@ -1183,9 +1183,7 @@ export class NetworkRequestNode extends NetworkNode {
|
||||
switch (initiator.type) {
|
||||
case SDK.NetworkRequest.InitiatorType.Parser: {
|
||||
UI.Tooltip.Tooltip.install(cell, initiator.url + ':' + (initiator.lineNumber + 1));
|
||||
// TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
|
||||
const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(
|
||||
initiator.url as Platform.DevToolsPath.UrlString);
|
||||
const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(initiator.url);
|
||||
cell.appendChild(
|
||||
Components.Linkifier.Linkifier.linkifyURL(initiator.url, ({
|
||||
text: uiSourceCode ? uiSourceCode.displayName() : undefined,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import * as i18n from '../../core/i18n/i18n.js';
|
||||
import type * as Platform from '../../core/platform/platform.js';
|
||||
import * as SDK from '../../core/sdk/sdk.js';
|
||||
import * as Formatter from '../../models/formatter/formatter.js';
|
||||
import type * as Workspace from '../../models/workspace/workspace.js';
|
||||
@@ -190,7 +191,7 @@ const coverageState = CodeMirror.StateField.define<CodeMirror.RangeSet<CodeMirro
|
||||
},
|
||||
});
|
||||
|
||||
function coverageGutter(url: string): CodeMirror.Extension {
|
||||
function coverageGutter(url: Platform.DevToolsPath.UrlString): CodeMirror.Extension {
|
||||
return CodeMirror.gutter({
|
||||
markers: (view): CodeMirror.RangeSet<CodeMirror.GutterMarker> => view.state.field(coverageState),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user