chrome-devtools-frontend 1.0.952284 → 1.0.952865
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/gni/devtools_grd_files.gni +3 -0
- package/front_end/.eslintrc.js +1 -1
- package/front_end/core/host/UserMetrics.ts +2 -1
- package/front_end/core/i18n/locales/af.json +158 -176
- package/front_end/core/i18n/locales/am.json +163 -181
- package/front_end/core/i18n/locales/ar.json +162 -180
- package/front_end/core/i18n/locales/as.json +163 -181
- package/front_end/core/i18n/locales/az.json +161 -179
- package/front_end/core/i18n/locales/be.json +160 -178
- package/front_end/core/i18n/locales/bg.json +159 -177
- package/front_end/core/i18n/locales/bn.json +166 -184
- package/front_end/core/i18n/locales/bs.json +161 -179
- package/front_end/core/i18n/locales/ca.json +159 -177
- package/front_end/core/i18n/locales/cs.json +159 -177
- package/front_end/core/i18n/locales/cy.json +164 -182
- package/front_end/core/i18n/locales/da.json +158 -176
- package/front_end/core/i18n/locales/de.json +160 -178
- package/front_end/core/i18n/locales/el.json +158 -176
- package/front_end/core/i18n/locales/en-GB.json +158 -176
- package/front_end/core/i18n/locales/en-US.json +3 -0
- package/front_end/core/i18n/locales/en-XL.json +3 -0
- package/front_end/core/i18n/locales/es-419.json +160 -178
- package/front_end/core/i18n/locales/es.json +156 -174
- package/front_end/core/i18n/locales/et.json +161 -179
- package/front_end/core/i18n/locales/eu.json +159 -177
- package/front_end/core/i18n/locales/fa.json +166 -184
- package/front_end/core/i18n/locales/fi.json +161 -179
- package/front_end/core/i18n/locales/fil.json +162 -180
- package/front_end/core/i18n/locales/fr-CA.json +159 -177
- package/front_end/core/i18n/locales/fr.json +158 -176
- package/front_end/core/i18n/locales/gl.json +160 -178
- package/front_end/core/i18n/locales/gu.json +179 -197
- package/front_end/core/i18n/locales/he.json +160 -178
- package/front_end/core/i18n/locales/hi.json +166 -184
- package/front_end/core/i18n/locales/hr.json +161 -179
- package/front_end/core/i18n/locales/hu.json +161 -179
- package/front_end/core/i18n/locales/hy.json +157 -175
- package/front_end/core/i18n/locales/id.json +160 -178
- package/front_end/core/i18n/locales/is.json +163 -181
- package/front_end/core/i18n/locales/it.json +162 -180
- package/front_end/core/i18n/locales/ja.json +160 -178
- package/front_end/core/i18n/locales/ka.json +161 -179
- package/front_end/core/i18n/locales/kk.json +164 -182
- package/front_end/core/i18n/locales/km.json +160 -178
- package/front_end/core/i18n/locales/kn.json +162 -180
- package/front_end/core/i18n/locales/ko.json +162 -180
- package/front_end/core/i18n/locales/ky.json +160 -178
- package/front_end/core/i18n/locales/lo.json +159 -177
- package/front_end/core/i18n/locales/lt.json +159 -177
- package/front_end/core/i18n/locales/lv.json +162 -180
- package/front_end/core/i18n/locales/mk.json +162 -180
- package/front_end/core/i18n/locales/ml.json +160 -178
- package/front_end/core/i18n/locales/mn.json +164 -182
- package/front_end/core/i18n/locales/mr.json +163 -181
- package/front_end/core/i18n/locales/ms.json +163 -181
- package/front_end/core/i18n/locales/my.json +164 -182
- package/front_end/core/i18n/locales/ne.json +160 -178
- package/front_end/core/i18n/locales/nl.json +160 -178
- package/front_end/core/i18n/locales/no.json +281 -299
- package/front_end/core/i18n/locales/or.json +165 -183
- package/front_end/core/i18n/locales/pa.json +159 -177
- package/front_end/core/i18n/locales/pl.json +163 -181
- package/front_end/core/i18n/locales/pt-PT.json +160 -178
- package/front_end/core/i18n/locales/pt.json +159 -177
- package/front_end/core/i18n/locales/ro.json +161 -179
- package/front_end/core/i18n/locales/ru.json +159 -177
- package/front_end/core/i18n/locales/si.json +161 -179
- package/front_end/core/i18n/locales/sk.json +158 -176
- package/front_end/core/i18n/locales/sl.json +160 -178
- package/front_end/core/i18n/locales/sq.json +279 -297
- package/front_end/core/i18n/locales/sr-Latn.json +160 -178
- package/front_end/core/i18n/locales/sr.json +160 -178
- package/front_end/core/i18n/locales/sv.json +159 -177
- package/front_end/core/i18n/locales/sw.json +164 -182
- package/front_end/core/i18n/locales/ta.json +160 -178
- package/front_end/core/i18n/locales/te.json +165 -183
- package/front_end/core/i18n/locales/th.json +158 -176
- package/front_end/core/i18n/locales/tr.json +162 -180
- package/front_end/core/i18n/locales/uk.json +160 -178
- package/front_end/core/i18n/locales/ur.json +160 -178
- package/front_end/core/i18n/locales/uz.json +160 -178
- package/front_end/core/i18n/locales/vi.json +162 -180
- package/front_end/core/i18n/locales/zh-HK.json +160 -178
- package/front_end/core/i18n/locales/zh-TW.json +161 -179
- package/front_end/core/i18n/locales/zh.json +162 -180
- package/front_end/core/i18n/locales/zu.json +164 -182
- package/front_end/core/root/Runtime.ts +4 -12
- package/front_end/core/sdk/PageResourceLoader.ts +2 -1
- package/front_end/entrypoints/formatter_worker/AcornTokenizer.ts +3 -3
- package/front_end/entrypoints/formatter_worker/CSSFormatter.ts +2 -2
- package/front_end/entrypoints/formatter_worker/ESTreeWalker.ts +9 -9
- package/front_end/entrypoints/formatter_worker/FormattedContentBuilder.ts +11 -11
- package/front_end/entrypoints/formatter_worker/HTMLFormatter.ts +40 -40
- package/front_end/entrypoints/formatter_worker/JavaScriptFormatter.ts +14 -14
- package/front_end/entrypoints/heap_snapshot_worker/AllocationProfile.ts +15 -15
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +2 -0
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +29 -29
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +2 -2
- package/front_end/entrypoints/inspector_main/InspectorMain.ts +12 -12
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +25 -25
- package/front_end/entrypoints/main/ExecutionContextSelector.ts +26 -29
- package/front_end/entrypoints/main/MainImpl.ts +38 -38
- package/front_end/entrypoints/node_app/NodeConnectionsPanel.ts +10 -10
- package/front_end/entrypoints/node_app/NodeMain.ts +3 -3
- package/front_end/legacy/legacy-defs.d.ts +0 -21
- package/front_end/models/heap_snapshot_model/HeapSnapshotModel.ts +1 -1
- package/front_end/models/issues_manager/ClientHintIssue.ts +95 -0
- package/front_end/models/issues_manager/IssuesManager.ts +5 -0
- package/front_end/models/issues_manager/descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
- package/front_end/models/issues_manager/descriptions/clientHintMetaTagModifiedHTML.md +4 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/panels/console/ConsoleView.ts +1 -1
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +86 -25
- package/front_end/panels/performance_monitor/performanceMonitor.css +32 -0
- package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +2 -2
- package/front_end/panels/timeline/TimelineFlameChartView.ts +1 -1
- package/front_end/panels/timeline/TimelineTreeView.ts +1 -1
- package/front_end/third_party/diff/DiffWrapper.ts +7 -0
- package/front_end/ui/components/data_grid/DataGrid.ts +2 -2
- package/front_end/ui/components/data_grid/DataGridUtils.ts +3 -0
- package/front_end/ui/legacy/SearchableView.ts +13 -4
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +1 -1
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +13 -12
- package/front_end/ui/legacy/components/source_frame/XMLView.ts +2 -2
- package/front_end/ui/legacy/theme_support/theme_support_impl.ts +22 -7
- package/package.json +1 -1
- package/config/gni/all_devtools_files.gni +0 -255
- package/scripts/build/devtools_file_hashes.py +0 -82
- package/scripts/devtools_run/devtools_run_cli +0 -49
- package/scripts/devtools_run/package.json +0 -13
- package/scripts/unzip.py +0 -20
- package/scripts/visualize_deps/jquery_svg.html +0 -57
- package/scripts/visualize_deps/run_visualize.js +0 -119
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const originalAssert = console.assert;
|
|
5
|
+
import * as Platform from '../platform/platform.js';
|
|
7
6
|
|
|
8
7
|
const queryParamsObject = new URLSearchParams(location.search);
|
|
9
8
|
|
|
@@ -100,13 +99,6 @@ export class Runtime {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
static assert(value: boolean|undefined, message: string): void {
|
|
104
|
-
if (value) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
originalAssert.call(originalConsole, value, message + ' ' + new Error().stack);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
102
|
static setPlatform(platform: string): void {
|
|
111
103
|
runtimePlatform = platform;
|
|
112
104
|
}
|
|
@@ -197,8 +189,8 @@ export class ExperimentsSupport {
|
|
|
197
189
|
}
|
|
198
190
|
|
|
199
191
|
register(experimentName: string, experimentTitle: string, unstable?: boolean, docLink?: string): void {
|
|
200
|
-
|
|
201
|
-
!this.#experimentNames.has(experimentName), 'Duplicate registration of experiment ' + experimentName);
|
|
192
|
+
Platform.DCHECK(
|
|
193
|
+
() => !this.#experimentNames.has(experimentName), 'Duplicate registration of experiment ' + experimentName);
|
|
202
194
|
this.#experimentNames.add(experimentName);
|
|
203
195
|
this.#experiments.push(new Experiment(this, experimentName, experimentTitle, Boolean(unstable), docLink ?? ''));
|
|
204
196
|
}
|
|
@@ -278,7 +270,7 @@ export class ExperimentsSupport {
|
|
|
278
270
|
}
|
|
279
271
|
|
|
280
272
|
private checkExperiment(experimentName: string): void {
|
|
281
|
-
|
|
273
|
+
Platform.DCHECK(() => this.#experimentNames.has(experimentName), 'Unknown experiment ' + experimentName);
|
|
282
274
|
}
|
|
283
275
|
}
|
|
284
276
|
|
|
@@ -219,7 +219,8 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
|
|
|
219
219
|
return this.#loadOverride(url);
|
|
220
220
|
}
|
|
221
221
|
const parsedURL = new Common.ParsedURL.ParsedURL(url);
|
|
222
|
-
const eligibleForLoadFromTarget =
|
|
222
|
+
const eligibleForLoadFromTarget =
|
|
223
|
+
getLoadThroughTargetSetting().get() && parsedURL && parsedURL.scheme !== 'file' && parsedURL.scheme !== 'data';
|
|
223
224
|
Host.userMetrics.developerResourceScheme(this.getDeveloperResourceScheme(parsedURL));
|
|
224
225
|
if (eligibleForLoadFromTarget) {
|
|
225
226
|
try {
|
|
@@ -66,7 +66,7 @@ export class AcornTokenizer {
|
|
|
66
66
|
// we see the comment itself. In that case, we should proceed and
|
|
67
67
|
// initialize `bufferedToken` as normal, to allow us to fix the reordering.
|
|
68
68
|
if (this.#comments.length === 0) {
|
|
69
|
-
this
|
|
69
|
+
this.#nextTokenInternal();
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -94,7 +94,7 @@ export class AcornTokenizer {
|
|
|
94
94
|
return token.type === 'Block';
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
#nextTokenInternal(): TokenOrComment|undefined {
|
|
98
98
|
if (this.#comments.length) {
|
|
99
99
|
const nextComment = this.#comments.shift();
|
|
100
100
|
// If this was the last comment to process, we need to make
|
|
@@ -113,7 +113,7 @@ export class AcornTokenizer {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
nextToken(): TokenOrComment|null {
|
|
116
|
-
const token = this
|
|
116
|
+
const token = this.#nextTokenInternal();
|
|
117
117
|
if (!token || token.type === Acorn.tokTypes.eof) {
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
@@ -75,11 +75,11 @@ export class CSSFormatter {
|
|
|
75
75
|
this.#lastLine = -1;
|
|
76
76
|
const tokenize = createTokenizer('text/css');
|
|
77
77
|
const oldEnforce = this.#builder.setEnforceSpaceBetweenWords(false);
|
|
78
|
-
tokenize(text.substring(this.#fromOffset, this.#toOffset), this
|
|
78
|
+
tokenize(text.substring(this.#fromOffset, this.#toOffset), this.#tokenCallback.bind(this));
|
|
79
79
|
this.#builder.setEnforceSpaceBetweenWords(oldEnforce);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
#tokenCallback(token: string, type: string|null, startPosition: number): void {
|
|
83
83
|
startPosition += this.#fromOffset;
|
|
84
84
|
const startLine = Platform.ArrayUtilities.lowerBound(
|
|
85
85
|
this.#lineEndings, startPosition, Platform.ArrayUtilities.DEFAULT_COMPARATOR);
|
|
@@ -30,10 +30,10 @@ export class ESTreeWalker {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
walk(ast: Acorn.ESTree.Node): void {
|
|
33
|
-
this
|
|
33
|
+
this.#innerWalk(ast, null);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
#innerWalk(node: Acorn.ESTree.Node, parent: Acorn.ESTree.Node|null): void {
|
|
37
37
|
if (!node && parent && this.#walkNulls) {
|
|
38
38
|
const result = ({raw: 'null', value: null, parent: null} as Acorn.ESTree.SimpleLiteral);
|
|
39
39
|
// Otherwise Closure can't handle the definition
|
|
@@ -62,10 +62,10 @@ export class ESTreeWalker {
|
|
|
62
62
|
const templateLiteral = (node as Acorn.ESTree.TemplateLiteral);
|
|
63
63
|
const expressionsLength = templateLiteral.expressions.length;
|
|
64
64
|
for (let i = 0; i < expressionsLength; ++i) {
|
|
65
|
-
this
|
|
66
|
-
this
|
|
65
|
+
this.#innerWalk(templateLiteral.quasis[i], templateLiteral);
|
|
66
|
+
this.#innerWalk(templateLiteral.expressions[i], templateLiteral);
|
|
67
67
|
}
|
|
68
|
-
this
|
|
68
|
+
this.#innerWalk(templateLiteral.quasis[expressionsLength], templateLiteral);
|
|
69
69
|
} else {
|
|
70
70
|
for (let i = 0; i < walkOrder.length; ++i) {
|
|
71
71
|
// @ts-ignore We are doing type traversal here, but the strings
|
|
@@ -75,9 +75,9 @@ export class ESTreeWalker {
|
|
|
75
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
76
|
const entity = (node[walkOrder[i]] as any);
|
|
77
77
|
if (Array.isArray(entity)) {
|
|
78
|
-
this
|
|
78
|
+
this.#walkArray((entity as Acorn.ESTree.Node[]), node);
|
|
79
79
|
} else {
|
|
80
|
-
this
|
|
80
|
+
this.#innerWalk((entity as Acorn.ESTree.Node), node);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -85,9 +85,9 @@ export class ESTreeWalker {
|
|
|
85
85
|
this.#afterVisit.call(null, node);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
#walkArray(nodeArray: Acorn.ESTree.Node[], parentNode: Acorn.ESTree.Node|null): void {
|
|
89
89
|
for (let i = 0; i < nodeArray.length; ++i) {
|
|
90
|
-
this
|
|
90
|
+
this.#innerWalk(nodeArray[i], parentNode);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -31,11 +31,11 @@ export class FormattedContentBuilder {
|
|
|
31
31
|
this.addSoftSpace();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
this
|
|
34
|
+
this.#appendFormatting();
|
|
35
35
|
|
|
36
36
|
// Insert token.
|
|
37
|
-
this
|
|
38
|
-
this
|
|
37
|
+
this.#addMappingIfNeeded(offset);
|
|
38
|
+
this.#addText(token);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
addSoftSpace(): void {
|
|
@@ -75,18 +75,18 @@ export class FormattedContentBuilder {
|
|
|
75
75
|
return this.#formattedContent.join('') + (this.#newLines ? '\n' : '');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
#appendFormatting(): void {
|
|
79
79
|
if (this.#newLines) {
|
|
80
80
|
for (let i = 0; i < this.#newLines; ++i) {
|
|
81
|
-
this
|
|
81
|
+
this.#addText('\n');
|
|
82
82
|
}
|
|
83
|
-
this
|
|
83
|
+
this.#addText(this.#indent());
|
|
84
84
|
} else if (this.#softSpace) {
|
|
85
|
-
this
|
|
85
|
+
this.#addText(' ');
|
|
86
86
|
}
|
|
87
87
|
if (this.#hardSpaces) {
|
|
88
88
|
for (let i = 0; i < this.#hardSpaces; ++i) {
|
|
89
|
-
this
|
|
89
|
+
this.#addText(' ');
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
this.#newLines = 0;
|
|
@@ -94,7 +94,7 @@ export class FormattedContentBuilder {
|
|
|
94
94
|
this.#hardSpaces = 0;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
#indent(): string {
|
|
98
98
|
const cachedValue = this.#cachedIndents.get(this.#nestingLevel);
|
|
99
99
|
if (cachedValue) {
|
|
100
100
|
return cachedValue;
|
|
@@ -112,12 +112,12 @@ export class FormattedContentBuilder {
|
|
|
112
112
|
return fullIndent;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
#addText(text: string): void {
|
|
116
116
|
this.#formattedContent.push(text);
|
|
117
117
|
this.#formattedContentLength += text.length;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
#addMappingIfNeeded(originalPosition: number): void {
|
|
121
121
|
if (originalPosition - this.#lastOriginalPosition === this.#formattedContentLength - this.#lastFormattedPosition) {
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
@@ -27,10 +27,10 @@ export class HTMLFormatter {
|
|
|
27
27
|
this.#text = text;
|
|
28
28
|
this.#lineEndings = lineEndings;
|
|
29
29
|
this.#model = new HTMLModel(text);
|
|
30
|
-
this
|
|
30
|
+
this.#walk(this.#model.document());
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
#formatTokensTill(element: FormatterElement, offset: number): void {
|
|
34
34
|
if (!this.#model) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -38,33 +38,33 @@ export class HTMLFormatter {
|
|
|
38
38
|
let nextToken = this.#model.peekToken();
|
|
39
39
|
while (nextToken && nextToken.startOffset < offset) {
|
|
40
40
|
const token = (this.#model.nextToken() as Token);
|
|
41
|
-
this
|
|
41
|
+
this.#formatToken(element, token);
|
|
42
42
|
nextToken = this.#model.peekToken();
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
#walk(element: FormatterElement): void {
|
|
47
47
|
if (!element.openTag || !element.closeTag) {
|
|
48
48
|
throw new Error('Element is missing open or close tag');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (element.parent) {
|
|
52
|
-
this
|
|
52
|
+
this.#formatTokensTill(element.parent, element.openTag.startOffset);
|
|
53
53
|
}
|
|
54
|
-
this
|
|
55
|
-
this
|
|
56
|
-
this
|
|
54
|
+
this.#beforeOpenTag(element);
|
|
55
|
+
this.#formatTokensTill(element, element.openTag.endOffset);
|
|
56
|
+
this.#afterOpenTag(element);
|
|
57
57
|
for (let i = 0; i < element.children.length; ++i) {
|
|
58
|
-
this
|
|
58
|
+
this.#walk(element.children[i]);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
this
|
|
62
|
-
this
|
|
63
|
-
this
|
|
64
|
-
this
|
|
61
|
+
this.#formatTokensTill(element, element.closeTag.startOffset);
|
|
62
|
+
this.#beforeCloseTag(element);
|
|
63
|
+
this.#formatTokensTill(element, element.closeTag.endOffset);
|
|
64
|
+
this.#afterCloseTag(element);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
#beforeOpenTag(element: FormatterElement): void {
|
|
68
68
|
if (!this.#model) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -75,7 +75,7 @@ export class HTMLFormatter {
|
|
|
75
75
|
this.#builder.addNewLine();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
#afterOpenTag(element: FormatterElement): void {
|
|
79
79
|
if (!this.#model) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
@@ -87,7 +87,7 @@ export class HTMLFormatter {
|
|
|
87
87
|
this.#builder.addNewLine();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
#beforeCloseTag(element: FormatterElement): void {
|
|
91
91
|
if (!this.#model) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
@@ -99,11 +99,11 @@ export class HTMLFormatter {
|
|
|
99
99
|
this.#builder.addNewLine();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
#afterCloseTag(_element: FormatterElement): void {
|
|
103
103
|
this.#builder.addNewLine();
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
#formatToken(element: FormatterElement, token: Token): void {
|
|
107
107
|
if (Platform.StringUtilities.isWhitespace(token.value)) {
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
@@ -130,7 +130,7 @@ export class HTMLFormatter {
|
|
|
130
130
|
if (isBodyToken && element.name === 'script') {
|
|
131
131
|
this.#builder.addNewLine();
|
|
132
132
|
this.#builder.increaseNestingLevel();
|
|
133
|
-
if (this
|
|
133
|
+
if (this.#scriptTagIsJavaScript(element)) {
|
|
134
134
|
this.#jsFormatter.format(this.#text || '', this.#lineEndings || [], token.startOffset, token.endOffset);
|
|
135
135
|
} else {
|
|
136
136
|
this.#builder.addToken(token.value, token.startOffset);
|
|
@@ -147,7 +147,7 @@ export class HTMLFormatter {
|
|
|
147
147
|
this.#builder.addToken(token.value, token.startOffset);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
#scriptTagIsJavaScript(element: FormatterElement): boolean {
|
|
151
151
|
if (!element.openTag) {
|
|
152
152
|
return true;
|
|
153
153
|
}
|
|
@@ -222,7 +222,7 @@ export class HTMLModel {
|
|
|
222
222
|
|
|
223
223
|
this.#tokens = [];
|
|
224
224
|
this.#tokenIndex = 0;
|
|
225
|
-
this
|
|
225
|
+
this.#build(text);
|
|
226
226
|
|
|
227
227
|
this.#attributes = new Map();
|
|
228
228
|
this.#attributeName = '';
|
|
@@ -230,7 +230,7 @@ export class HTMLModel {
|
|
|
230
230
|
this.#isOpenTag = false;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
#build(text: string): void {
|
|
234
234
|
const tokenizer = createTokenizer('text/html');
|
|
235
235
|
let lastOffset = 0;
|
|
236
236
|
const lowerCaseText = text.toLowerCase();
|
|
@@ -266,7 +266,7 @@ export class HTMLModel {
|
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
this
|
|
269
|
+
this.#popElement(new Tag(element.name, text.length, text.length, new Map(), false, false));
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
function processToken(
|
|
@@ -279,7 +279,7 @@ export class HTMLModel {
|
|
|
279
279
|
const tokenType = type ? new Set<string>(type.split(' ')) : new Set<string>();
|
|
280
280
|
const token = new Token(tokenValue, tokenType, tokenStart, tokenEnd);
|
|
281
281
|
this.#tokens.push(token);
|
|
282
|
-
this
|
|
282
|
+
this.#updateDOM(token);
|
|
283
283
|
|
|
284
284
|
const element = this.#stack[this.#stack.length - 1];
|
|
285
285
|
if (element && (element.name === 'script' || element.name === 'style') && element.openTag &&
|
|
@@ -291,13 +291,13 @@ export class HTMLModel {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
#updateDOM(token: Token): void {
|
|
295
295
|
const value = token.value;
|
|
296
296
|
const type = token.type;
|
|
297
297
|
switch (this.#state) {
|
|
298
298
|
case ParseState.Initial:
|
|
299
299
|
if (hasTokenInSet(type, 'bracket') && (value === '<' || value === '</')) {
|
|
300
|
-
this
|
|
300
|
+
this.#onStartTag(token);
|
|
301
301
|
this.#state = ParseState.Tag;
|
|
302
302
|
}
|
|
303
303
|
return;
|
|
@@ -309,7 +309,7 @@ export class HTMLModel {
|
|
|
309
309
|
this.#attributes.set(this.#attributeName, '');
|
|
310
310
|
this.#state = ParseState.AttributeName;
|
|
311
311
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
312
|
-
this
|
|
312
|
+
this.#onEndTag(token);
|
|
313
313
|
this.#state = ParseState.Initial;
|
|
314
314
|
}
|
|
315
315
|
return;
|
|
@@ -317,7 +317,7 @@ export class HTMLModel {
|
|
|
317
317
|
if (!type.size && value === '=') {
|
|
318
318
|
this.#state = ParseState.AttributeValue;
|
|
319
319
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
320
|
-
this
|
|
320
|
+
this.#onEndTag(token);
|
|
321
321
|
this.#state = ParseState.Initial;
|
|
322
322
|
}
|
|
323
323
|
return;
|
|
@@ -326,14 +326,14 @@ export class HTMLModel {
|
|
|
326
326
|
this.#attributes.set(this.#attributeName, value);
|
|
327
327
|
this.#state = ParseState.Tag;
|
|
328
328
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
329
|
-
this
|
|
329
|
+
this.#onEndTag(token);
|
|
330
330
|
this.#state = ParseState.Initial;
|
|
331
331
|
}
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
#onStartTag(token: Token): void {
|
|
337
337
|
this.#tagName = '';
|
|
338
338
|
this.#tagStartOffset = token.startOffset;
|
|
339
339
|
this.#tagEndOffset = null;
|
|
@@ -342,46 +342,46 @@ export class HTMLModel {
|
|
|
342
342
|
this.#isOpenTag = token.value === '<';
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
#onEndTag(token: Token): void {
|
|
346
346
|
this.#tagEndOffset = token.endOffset;
|
|
347
347
|
const selfClosingTag = token.value === '/>' || SelfClosingTags.has(this.#tagName);
|
|
348
348
|
const tag = new Tag(
|
|
349
349
|
this.#tagName, this.#tagStartOffset || 0, this.#tagEndOffset, this.#attributes, this.#isOpenTag,
|
|
350
350
|
selfClosingTag);
|
|
351
|
-
this
|
|
351
|
+
this.#onTagComplete(tag);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
#onTagComplete(tag: Tag): void {
|
|
355
355
|
if (tag.isOpenTag) {
|
|
356
356
|
const topElement = this.#stack[this.#stack.length - 1];
|
|
357
357
|
if (topElement) {
|
|
358
358
|
const tagSet = AutoClosingTags.get(topElement.name);
|
|
359
359
|
if (topElement !== this.#documentInternal && topElement.openTag && topElement.openTag.selfClosingTag) {
|
|
360
|
-
this
|
|
360
|
+
this.#popElement(autocloseTag(topElement, topElement.openTag.endOffset));
|
|
361
361
|
} else if (tagSet && tagSet.has(tag.name)) {
|
|
362
|
-
this
|
|
362
|
+
this.#popElement(autocloseTag(topElement, tag.startOffset));
|
|
363
363
|
}
|
|
364
|
-
this
|
|
364
|
+
this.#pushElement(tag);
|
|
365
365
|
}
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
let lastTag = this.#stack[this.#stack.length - 1];
|
|
370
370
|
while (this.#stack.length > 1 && lastTag && lastTag.name !== tag.name) {
|
|
371
|
-
this
|
|
371
|
+
this.#popElement(autocloseTag(lastTag, tag.startOffset));
|
|
372
372
|
lastTag = this.#stack[this.#stack.length - 1];
|
|
373
373
|
}
|
|
374
374
|
if (this.#stack.length === 1) {
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
this
|
|
377
|
+
this.#popElement(tag);
|
|
378
378
|
|
|
379
379
|
function autocloseTag(element: FormatterElement, offset: number): Tag {
|
|
380
380
|
return new Tag(element.name, offset, offset, new Map(), false, false);
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
|
|
384
|
+
#popElement(closeTag: Tag): void {
|
|
385
385
|
const element = this.#stack.pop();
|
|
386
386
|
if (!element) {
|
|
387
387
|
return;
|
|
@@ -389,7 +389,7 @@ export class HTMLModel {
|
|
|
389
389
|
element.closeTag = closeTag;
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
|
|
392
|
+
#pushElement(openTag: Tag): void {
|
|
393
393
|
const topElement = this.#stack[this.#stack.length - 1];
|
|
394
394
|
const newElement = new FormatterElement(openTag.name);
|
|
395
395
|
if (topElement) {
|
|
@@ -59,7 +59,7 @@ export class JavaScriptFormatter {
|
|
|
59
59
|
ecmaVersion: ECMA_VERSION,
|
|
60
60
|
allowHashBang: true,
|
|
61
61
|
});
|
|
62
|
-
const walker = new ESTreeWalker(this
|
|
62
|
+
const walker = new ESTreeWalker(this.#beforeVisit.bind(this), this.#afterVisit.bind(this));
|
|
63
63
|
// @ts-ignore Technically, the acorn Node type is a subclass of Acorn.ESTree.Node.
|
|
64
64
|
// However, the acorn package currently exports its type without specifying
|
|
65
65
|
// this relationship. So while this is allowed on runtime, we can't properly
|
|
@@ -67,7 +67,7 @@ export class JavaScriptFormatter {
|
|
|
67
67
|
walker.walk(ast);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
#push(token: Acorn.Token|Acorn.Comment|null, format: string): void {
|
|
71
71
|
for (let i = 0; i < format.length; ++i) {
|
|
72
72
|
if (format[i] === 's') {
|
|
73
73
|
this.#builder.addSoftSpace();
|
|
@@ -91,7 +91,7 @@ export class JavaScriptFormatter {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
#beforeVisit(node: Acorn.ESTree.Node): undefined {
|
|
95
95
|
if (!node.parent) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
@@ -99,23 +99,23 @@ export class JavaScriptFormatter {
|
|
|
99
99
|
while ((token = this.#tokenizer.peekToken()) && token.start < node.start) {
|
|
100
100
|
const token = (this.#tokenizer.nextToken() as TokenOrComment);
|
|
101
101
|
// @ts-ignore Same reason as above about Acorn types and ESTree types
|
|
102
|
-
const format = this
|
|
103
|
-
this
|
|
102
|
+
const format = this.#formatToken(node.parent, token);
|
|
103
|
+
this.#push(token, format);
|
|
104
104
|
}
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
#afterVisit(node: Acorn.ESTree.Node): void {
|
|
109
109
|
let token;
|
|
110
110
|
while ((token = this.#tokenizer.peekToken()) && token.start < node.end) {
|
|
111
111
|
const token = (this.#tokenizer.nextToken() as TokenOrComment);
|
|
112
|
-
const format = this
|
|
113
|
-
this
|
|
112
|
+
const format = this.#formatToken(node, token);
|
|
113
|
+
this.#push(token, format);
|
|
114
114
|
}
|
|
115
|
-
this
|
|
115
|
+
this.#push(null, this.#finishNode(node));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
#inForLoopHeader(node: Acorn.ESTree.Node): boolean {
|
|
119
119
|
const parent = node.parent;
|
|
120
120
|
if (!parent) {
|
|
121
121
|
return false;
|
|
@@ -131,7 +131,7 @@ export class JavaScriptFormatter {
|
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
#formatToken(node: Acorn.ESTree.Node, tokenOrComment: TokenOrComment): string {
|
|
135
135
|
const AT = AcornTokenizer;
|
|
136
136
|
if (AT.lineComment(tokenOrComment)) {
|
|
137
137
|
return 'tn';
|
|
@@ -241,7 +241,7 @@ export class JavaScriptFormatter {
|
|
|
241
241
|
// it exists. We can't fix that, unless we use proper typechecking
|
|
242
242
|
allVariablesInitialized = allVariablesInitialized && Boolean(declarations[i].init);
|
|
243
243
|
}
|
|
244
|
-
return !this
|
|
244
|
+
return !this.#inForLoopHeader(node) && allVariablesInitialized ? 'nSSts' : 'ts';
|
|
245
245
|
}
|
|
246
246
|
} else if (node.type === 'PropertyDefinition') {
|
|
247
247
|
if (AT.punctuator(token, '=')) {
|
|
@@ -356,13 +356,13 @@ export class JavaScriptFormatter {
|
|
|
356
356
|
return AT.keyword(token) && !AT.keyword(token, 'this') ? 'ts' : 't';
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
#finishNode(node: Acorn.ESTree.Node): string {
|
|
360
360
|
if (node.type === 'WithStatement') {
|
|
361
361
|
if (node.body && node.body.type !== 'BlockStatement') {
|
|
362
362
|
return 'n<';
|
|
363
363
|
}
|
|
364
364
|
} else if (node.type === 'VariableDeclaration') {
|
|
365
|
-
if (!this
|
|
365
|
+
if (!this.#inForLoopHeader(node)) {
|
|
366
366
|
return 'n';
|
|
367
367
|
}
|
|
368
368
|
} else if (node.type === 'ForStatement' || node.type === 'ForOfStatement' || node.type === 'ForInStatement') {
|
|
@@ -57,13 +57,13 @@ export class AllocationProfile {
|
|
|
57
57
|
|
|
58
58
|
this.#traceTops = null;
|
|
59
59
|
|
|
60
|
-
this
|
|
61
|
-
this
|
|
60
|
+
this.#buildFunctionAllocationInfos(profile);
|
|
61
|
+
this.#buildAllocationTree(profile, liveObjectStats);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
|
|
66
|
+
#buildFunctionAllocationInfos(profile: any): void {
|
|
67
67
|
const strings = this.#strings;
|
|
68
68
|
|
|
69
69
|
const functionInfoFields = profile.snapshot.meta.trace_function_info_fields;
|
|
@@ -87,7 +87,7 @@ export class AllocationProfile {
|
|
|
87
87
|
|
|
88
88
|
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
|
|
89
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
|
|
90
|
+
#buildAllocationTree(profile: any, liveObjectStats: any): TopDownAllocationNode {
|
|
91
91
|
const traceTreeRaw = profile.trace_tree;
|
|
92
92
|
const functionInfos = this.#functionInfos;
|
|
93
93
|
const idToTopDownNode = this.#idToTopDownNode;
|
|
@@ -140,7 +140,7 @@ export class AllocationProfile {
|
|
|
140
140
|
}
|
|
141
141
|
const nodeId = this.#nextNodeId++;
|
|
142
142
|
const isRoot = i === 0;
|
|
143
|
-
result.push(this
|
|
143
|
+
result.push(this.#serializeNode(
|
|
144
144
|
nodeId, info, info.totalCount, info.totalSize, info.totalLiveCount, info.totalLiveSize, !isRoot));
|
|
145
145
|
this.#collapsedTopNodeIdToFunctionInfo[nodeId] = info;
|
|
146
146
|
}
|
|
@@ -151,17 +151,17 @@ export class AllocationProfile {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
serializeCallers(nodeId: number): HeapSnapshotModel.HeapSnapshotModel.AllocationNodeCallers {
|
|
154
|
-
let node = this
|
|
154
|
+
let node = this.#ensureBottomUpNode(nodeId);
|
|
155
155
|
const nodesWithSingleCaller = [];
|
|
156
156
|
while (node.callers().length === 1) {
|
|
157
157
|
node = node.callers()[0];
|
|
158
|
-
nodesWithSingleCaller.push(this
|
|
158
|
+
nodesWithSingleCaller.push(this.#serializeCaller(node));
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
const branchingCallers = [];
|
|
162
162
|
const callers = node.callers();
|
|
163
163
|
for (let i = 0; i < callers.length; i++) {
|
|
164
|
-
branchingCallers.push(this
|
|
164
|
+
branchingCallers.push(this.#serializeCaller(callers[i]));
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
return new HeapSnapshotModel.HeapSnapshotModel.AllocationNodeCallers(nodesWithSingleCaller, branchingCallers);
|
|
@@ -181,10 +181,10 @@ export class AllocationProfile {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
traceIds(allocationNodeId: number): number[] {
|
|
184
|
-
return this
|
|
184
|
+
return this.#ensureBottomUpNode(allocationNodeId).traceTopIds;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
#ensureBottomUpNode(nodeId: number): BottomUpAllocationNode {
|
|
188
188
|
let node = this.#idToNode[nodeId];
|
|
189
189
|
if (!node) {
|
|
190
190
|
const functionInfo = this.#collapsedTopNodeIdToFunctionInfo[nodeId];
|
|
@@ -195,15 +195,15 @@ export class AllocationProfile {
|
|
|
195
195
|
return node as BottomUpAllocationNode;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
#serializeCaller(node: BottomUpAllocationNode): HeapSnapshotModel.HeapSnapshotModel.SerializedAllocationNode {
|
|
199
199
|
const callerId = this.#nextNodeId++;
|
|
200
200
|
this.#idToNode[callerId] = node;
|
|
201
|
-
return this
|
|
201
|
+
return this.#serializeNode(
|
|
202
202
|
callerId, node.functionInfo, node.allocationCount, node.allocationSize, node.liveCount, node.liveSize,
|
|
203
203
|
node.hasCallers());
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
#serializeNode(
|
|
207
207
|
nodeId: number, functionInfo: FunctionAllocationInfo, count: number, size: number, liveCount: number,
|
|
208
208
|
liveSize: number, hasChildren: boolean): HeapSnapshotModel.HeapSnapshotModel.SerializedAllocationNode {
|
|
209
209
|
return new HeapSnapshotModel.HeapSnapshotModel.SerializedAllocationNode(
|
|
@@ -324,12 +324,12 @@ export class FunctionAllocationInfo {
|
|
|
324
324
|
return null;
|
|
325
325
|
}
|
|
326
326
|
if (!this.#bottomUpTree) {
|
|
327
|
-
this
|
|
327
|
+
this.#buildAllocationTraceTree();
|
|
328
328
|
}
|
|
329
329
|
return this.#bottomUpTree as BottomUpAllocationNode;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
|
|
332
|
+
#buildAllocationTraceTree(): void {
|
|
333
333
|
this.#bottomUpTree = new BottomUpAllocationNode(this);
|
|
334
334
|
|
|
335
335
|
for (let i = 0; i < this.#traceTops.length; i++) {
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
/* eslint-disable rulesdir/use_private_class_members */
|
|
32
|
+
|
|
31
33
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
32
34
|
import * as Platform from '../../core/platform/platform.js';
|
|
33
35
|
import * as HeapSnapshotModel from '../../models/heap_snapshot_model/heap_snapshot_model.js';
|