chrome-devtools-frontend 1.0.941208 → 1.0.942095

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.
Files changed (99) hide show
  1. package/config/gni/all_devtools_files.gni +0 -6
  2. package/config/gni/devtools_grd_files.gni +6 -12
  3. package/config/gni/devtools_image_files.gni +0 -2
  4. package/front_end/Tests.js +1 -0
  5. package/front_end/core/common/Color.ts +5 -0
  6. package/front_end/core/i18n/locales/en-US.json +16 -28
  7. package/front_end/core/i18n/locales/en-XL.json +16 -28
  8. package/front_end/core/sdk/sdk-meta.ts +17 -3
  9. package/front_end/entrypoints/devtools_app/devtools_app.json +1 -7
  10. package/front_end/entrypoints/main/MainImpl.ts +26 -0
  11. package/front_end/entrypoints/shell/shell.js +0 -11
  12. package/front_end/entrypoints/worker_app/worker_app.json +0 -4
  13. package/front_end/generated/InspectorBackendCommands.js +1 -0
  14. package/front_end/generated/protocol.d.ts +2 -0
  15. package/front_end/legacy_test_runner/legacy_test_runner.ts +10 -1
  16. package/front_end/models/formatter/SourceFormatter.ts +0 -10
  17. package/front_end/models/workspace/UISourceCode.ts +9 -42
  18. package/front_end/panels/animation/AnimationTimeline.ts +3 -3
  19. package/front_end/panels/application/ApplicationPanelSidebar.ts +3 -3
  20. package/front_end/panels/application/application-meta.ts +0 -3
  21. package/front_end/panels/console/ConsolePinPane.ts +21 -26
  22. package/front_end/panels/coverage/CoverageDecorationManager.ts +4 -5
  23. package/front_end/panels/coverage/CoverageView.ts +2 -105
  24. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +11 -56
  25. package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -8
  26. package/front_end/panels/elements/ElementsTreeElement.ts +4 -9
  27. package/front_end/panels/elements/components/adornerSettingsPane.css +0 -4
  28. package/front_end/panels/emulation/emulation-meta.ts +2 -2
  29. package/front_end/panels/issues/issues-meta.ts +0 -2
  30. package/front_end/panels/layers/module.json +0 -1
  31. package/front_end/panels/lighthouse/lighthouseStartView.css +4 -0
  32. package/front_end/panels/media/media-meta.ts +0 -3
  33. package/front_end/panels/network/ResourceWebSocketFrameView.ts +2 -1
  34. package/front_end/panels/network/network-meta.ts +0 -3
  35. package/front_end/panels/security/security-meta.ts +0 -3
  36. package/front_end/panels/sources/BreakpointEditDialog.ts +16 -30
  37. package/front_end/panels/sources/CSSPlugin.ts +310 -331
  38. package/front_end/panels/sources/CallStackSidebarPane.ts +28 -34
  39. package/front_end/panels/sources/CoveragePlugin.ts +121 -6
  40. package/front_end/panels/sources/DebuggerPlugin.ts +1166 -1243
  41. package/front_end/panels/sources/EditingLocationHistoryManager.ts +71 -101
  42. package/front_end/panels/sources/GoToLineQuickOpen.ts +4 -3
  43. package/front_end/panels/sources/InplaceFormatterEditorAction.ts +3 -3
  44. package/front_end/panels/sources/JavaScriptCompilerPlugin.ts +26 -23
  45. package/front_end/panels/sources/Plugin.ts +20 -4
  46. package/front_end/panels/sources/ProfilePlugin.ts +185 -0
  47. package/front_end/panels/sources/ScriptFormatterEditorAction.ts +3 -3
  48. package/front_end/panels/sources/ScriptOriginPlugin.ts +0 -10
  49. package/front_end/panels/sources/SnippetsPlugin.ts +1 -10
  50. package/front_end/panels/sources/SourcesPanel.ts +6 -5
  51. package/front_end/panels/sources/SourcesView.ts +10 -8
  52. package/front_end/panels/sources/TabbedEditorContainer.ts +31 -27
  53. package/front_end/panels/sources/UISourceCodeFrame.ts +335 -470
  54. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -2
  55. package/front_end/panels/sources/sources-legacy.ts +0 -6
  56. package/front_end/panels/sources/sources.ts +0 -2
  57. package/front_end/panels/timeline/module.json +0 -1
  58. package/front_end/third_party/codemirror.next/bundle.ts +9 -13
  59. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  60. package/front_end/third_party/codemirror.next/chunk/javascript.js +2 -2
  61. package/front_end/third_party/codemirror.next/chunk/markdown.js +2 -6
  62. package/front_end/third_party/codemirror.next/chunk/php.js +2 -6
  63. package/front_end/third_party/codemirror.next/chunk/python.js +1 -1
  64. package/front_end/third_party/codemirror.next/chunk/wast.js +1 -1
  65. package/front_end/third_party/codemirror.next/chunk/xml.js +2 -2
  66. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +279 -198
  67. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  68. package/front_end/third_party/codemirror.next/package.json +13 -11
  69. package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +60 -68
  70. package/front_end/ui/components/data_grid/dataGrid.css +12 -10
  71. package/front_end/ui/components/docs/css_overview/start_view.html +25 -0
  72. package/front_end/ui/components/docs/css_overview/start_view.ts +14 -0
  73. package/front_end/ui/components/text_editor/TextEditor.ts +79 -36
  74. package/front_end/ui/components/text_editor/config.ts +42 -26
  75. package/front_end/ui/components/text_editor/javascript.ts +2 -3
  76. package/front_end/ui/components/text_editor/position.ts +17 -0
  77. package/front_end/ui/components/text_editor/text_editor.ts +1 -0
  78. package/front_end/ui/components/text_editor/theme.ts +5 -1
  79. package/front_end/ui/legacy/Infobar.ts +2 -6
  80. package/front_end/ui/legacy/ShortcutRegistry.ts +11 -7
  81. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +35 -131
  82. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +3 -6
  83. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +18 -14
  84. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +502 -252
  85. package/front_end/ui/legacy/components/source_frame/source_frame-legacy.ts +0 -11
  86. package/front_end/ui/legacy/components/source_frame/source_frame.ts +0 -2
  87. package/front_end/ui/legacy/components/text_editor/cmdevtools.css +3 -1
  88. package/front_end/ui/legacy/radioButton.css +1 -13
  89. package/front_end/ui/legacy/themeColors.css +36 -0
  90. package/package.json +1 -1
  91. package/front_end/Images/radioDot-dark-theme.png +0 -0
  92. package/front_end/Images/radioDot.png +0 -0
  93. package/front_end/panels/application/module.json +0 -6
  94. package/front_end/panels/issues/module.json +0 -6
  95. package/front_end/panels/layer_viewer/module.json +0 -5
  96. package/front_end/panels/media/module.json +0 -5
  97. package/front_end/panels/network/module.json +0 -5
  98. package/front_end/panels/security/module.json +0 -5
  99. package/front_end/ui/legacy/components/source_frame/SourcesTextEditor.ts +0 -1030
@@ -4,4 +4,5 @@
4
4
 
5
5
  export * as Config from './config.js';
6
6
  export * as JavaScript from './javascript.js';
7
+ export * as Position from './position.js';
7
8
  export * as TextEditor from './TextEditor.js';
@@ -52,6 +52,10 @@ export const editorTheme = CM.EditorView.theme({
52
52
  backgroundColor: 'var(--color-background)',
53
53
  },
54
54
 
55
+ '.cm-lineNumbers': {
56
+ overflow: 'visible',
57
+ minWidth: '40px',
58
+ },
55
59
  '.cm-lineNumbers .cm-gutterElement': {
56
60
  color: 'var(--color-line-number)',
57
61
  padding: '0 3px 0 9px',
@@ -74,7 +78,7 @@ export const editorTheme = CM.EditorView.theme({
74
78
  },
75
79
 
76
80
  '.cm-trailingWhitespace': {
77
- backgroundColor: 'var(--color-error-text)',
81
+ backgroundColor: 'var(--color-trailing-whitespace)',
78
82
  },
79
83
 
80
84
  '.cm-highlightedTab': {
@@ -46,9 +46,7 @@ export class Infobar {
46
46
  private readonly closeContainer: HTMLElement;
47
47
  private readonly toggleElement: HTMLButtonElement;
48
48
  private readonly closeButton: HTMLElement;
49
- // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
50
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- private closeCallback: (() => any)|null;
49
+ private closeCallback: (() => void)|null;
52
50
  private parentView?: Widget;
53
51
 
54
52
  // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
@@ -160,9 +158,7 @@ export class Infobar {
160
158
  this.onResize();
161
159
  }
162
160
 
163
- // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
164
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
- setCloseCallback(callback: (() => any)|null): void {
161
+ setCloseCallback(callback: (() => void)|null): void {
166
162
  this.closeCallback = callback;
167
163
  }
168
164
 
@@ -144,27 +144,31 @@ export class ShortcutRegistry {
144
144
  return this.devToolsDefaultShortcutActions.has(actionId);
145
145
  }
146
146
 
147
- addShortcutListener(element: Element, handlers: {
148
- [x: string]: () => Promise<boolean>,
149
- }): (arg0: Event) => void {
147
+ getShortcutListener(handlers: {[x: string]: () => Promise<boolean>}): (event: KeyboardEvent) => void {
148
+ const shortcuts = Object.keys(handlers).flatMap(action => [...this.actionToShortcut.get(action)]);
150
149
  // We only want keys for these specific actions to get handled this
151
150
  // way; all others should be allowed to bubble up.
152
151
  const allowlistKeyMap = new ShortcutTreeNode(0, 0);
153
- const shortcuts = Object.keys(handlers).flatMap(action => [...this.actionToShortcut.get(action)]);
154
152
  shortcuts.forEach(shortcut => {
155
153
  allowlistKeyMap.addKeyMapping(shortcut.descriptors.map(descriptor => descriptor.key), shortcut.action);
156
154
  });
157
155
 
158
- const listener = (event: Event): void => {
159
- const key = KeyboardShortcut.makeKeyFromEvent((event as KeyboardEvent));
156
+ return (event: KeyboardEvent): void => {
157
+ const key = KeyboardShortcut.makeKeyFromEvent(event);
160
158
  const keyMap = this.activePrefixKey ? allowlistKeyMap.getNode(this.activePrefixKey.key()) : allowlistKeyMap;
161
159
  if (!keyMap) {
162
160
  return;
163
161
  }
164
162
  if (keyMap.getNode(key)) {
165
- this.handleShortcut((event as KeyboardEvent), handlers);
163
+ this.handleShortcut(event, handlers);
166
164
  }
167
165
  };
166
+ }
167
+
168
+ addShortcutListener(element: Element, handlers: {
169
+ [x: string]: () => Promise<boolean>,
170
+ }): (arg0: Event) => void {
171
+ const listener = this.getShortcutListener(handlers) as (event: Event) => void;
168
172
  element.addEventListener('keydown', listener);
169
173
  return listener;
170
174
  }
@@ -2,37 +2,19 @@
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
- import * as i18n from '../../../../core/i18n/i18n.js';
6
- import * as Platform from '../../../../core/platform/platform.js';
7
5
  import * as SDK from '../../../../core/sdk/sdk.js';
8
6
  import * as Bindings from '../../../../models/bindings/bindings.js';
9
7
  import * as Workspace from '../../../../models/workspace/workspace.js';
10
8
  import * as SourceFrame from '../source_frame/source_frame.js';
11
9
  import type * as Protocol from '../../../../generated/protocol.js';
12
10
 
13
- const UIStrings = {
14
- /**
15
- *@description The milisecond unit
16
- */
17
- ms: 'ms',
18
- /**
19
- *@description Unit for data size in DevTools
20
- */
21
- mb: 'MB',
22
- /**
23
- *@description A unit
24
- */
25
- kb: 'kB',
26
- };
27
- const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/perf_ui/LineLevelProfile.ts', UIStrings);
28
- const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
29
11
  let performanceInstance: Performance;
30
12
 
31
13
  export class Performance {
32
14
  private readonly helper: Helper;
33
15
 
34
16
  private constructor() {
35
- this.helper = new Helper('performance');
17
+ this.helper = new Helper(SourceFrame.SourceFrame.DecoratorType.PERFORMANCE);
36
18
  }
37
19
 
38
20
  static instance(opts: {
@@ -112,7 +94,7 @@ let memoryInstance: Memory;
112
94
  export class Memory {
113
95
  private readonly helper: Helper;
114
96
  private constructor() {
115
- this.helper = new Helper('memory');
97
+ this.helper = new Helper(SourceFrame.SourceFrame.DecoratorType.MEMORY);
116
98
  }
117
99
 
118
100
  static instance(opts: {
@@ -193,10 +175,12 @@ export class Helper {
193
175
  }, 0);
194
176
  }
195
177
 
196
- private doUpdate(): void {
178
+ private async doUpdate(): Promise<void> {
197
179
  this.locationPool.disposeAll();
198
- Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodes().forEach(
199
- uiSourceCode => uiSourceCode.removeDecorationsForType(this.type));
180
+ // Map from sources to line->value profile maps.
181
+ const decorationsBySource = new Map<Workspace.UISourceCode.UISourceCode, Map<number, number>>();
182
+ const pending: Promise<void>[] = [];
183
+
200
184
  for (const targetToScript of this.lineData) {
201
185
  const target = (targetToScript[0] as SDK.Target.Target | null);
202
186
  const debuggerModel = target ? target.model(SDK.DebuggerModel.DebuggerModel) : null;
@@ -206,124 +190,44 @@ export class Helper {
206
190
  const lineToDataMap = (scriptToLine[1] as Map<number, number>);
207
191
  // debuggerModel is null when the profile is loaded from file.
208
192
  // Try to get UISourceCode by the URL in this case.
209
- const uiSourceCode = !debuggerModel && typeof scriptIdOrUrl === 'string' ?
210
- Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(scriptIdOrUrl) :
211
- null;
212
- if (!debuggerModel && !uiSourceCode) {
213
- continue;
214
- }
215
- for (const lineToData of lineToDataMap) {
216
- const line = (lineToData[0] as number) - 1;
217
- const data = (lineToData[1] as number);
218
- if (uiSourceCode) {
219
- uiSourceCode.addLineDecoration(line, this.type, data);
220
- continue;
221
- }
222
- if (debuggerModel) {
193
+ const workspace = Workspace.Workspace.WorkspaceImpl.instance();
194
+ if (debuggerModel) {
195
+ const workspaceBinding = Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();
196
+ for (const lineToData of lineToDataMap) {
197
+ const line = lineToData[0] - 1;
198
+ const data = lineToData[1];
223
199
  const rawLocation = typeof scriptIdOrUrl === 'string' ?
224
200
  debuggerModel.createRawLocationByURL(scriptIdOrUrl, line, 0) :
225
201
  debuggerModel.createRawLocationByScriptId(String(scriptIdOrUrl) as Protocol.Runtime.ScriptId, line, 0);
226
202
  if (rawLocation) {
227
- new Presentation(rawLocation, this.type, data, this.locationPool);
203
+ pending.push(workspaceBinding.rawLocationToUILocation(rawLocation).then((uiLocation): void => {
204
+ if (uiLocation) {
205
+ let lineMap = decorationsBySource.get(uiLocation.uiSourceCode);
206
+ if (!lineMap) {
207
+ lineMap = new Map<number, number>();
208
+ decorationsBySource.set(uiLocation.uiSourceCode, lineMap);
209
+ }
210
+ lineMap.set(uiLocation.lineNumber + 1, data);
211
+ }
212
+ }));
228
213
  }
229
214
  }
215
+ } else if (typeof scriptIdOrUrl === 'string') {
216
+ const uiSourceCode = workspace.uiSourceCodeForURL(scriptIdOrUrl);
217
+ if (uiSourceCode) {
218
+ decorationsBySource.set(uiSourceCode, lineToDataMap);
219
+ }
230
220
  }
231
221
  }
222
+ await Promise.all(pending);
223
+ for (const [uiSourceCode, lineMap] of decorationsBySource) {
224
+ uiSourceCode.setDecorationData(this.type, lineMap);
225
+ }
232
226
  }
233
- }
234
- }
235
-
236
- export class Presentation {
237
- private readonly type: string;
238
- private readonly time: number;
239
- private uiLocation: Workspace.UISourceCode.UILocation|null;
240
-
241
- constructor(
242
- rawLocation: SDK.DebuggerModel.Location, type: string, time: number,
243
- locationPool: Bindings.LiveLocation.LiveLocationPool) {
244
- this.type = type;
245
- this.time = time;
246
- this.uiLocation = null;
247
- Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createLiveLocation(
248
- rawLocation, this.updateLocation.bind(this), locationPool);
249
- }
250
-
251
- async updateLocation(liveLocation: Bindings.LiveLocation.LiveLocation): Promise<void> {
252
- if (this.uiLocation) {
253
- this.uiLocation.uiSourceCode.removeDecorationsForType(this.type);
254
- }
255
- this.uiLocation = await liveLocation.uiLocation();
256
- if (this.uiLocation) {
257
- this.uiLocation.uiSourceCode.addLineDecoration(this.uiLocation.lineNumber, this.type, this.time);
258
- }
259
- }
260
- }
261
-
262
- let lineDecoratorInstance: LineDecorator;
263
-
264
- export class LineDecorator implements SourceFrame.SourceFrame.LineDecorator {
265
- static instance(opts: {
266
- forceNew: boolean|null,
267
- } = {forceNew: null}): LineDecorator {
268
- const {forceNew} = opts;
269
- if (!lineDecoratorInstance || forceNew) {
270
- lineDecoratorInstance = new LineDecorator();
271
- }
272
-
273
- return lineDecoratorInstance;
274
- }
275
- decorate(
276
- uiSourceCode: Workspace.UISourceCode.UISourceCode, textEditor: SourceFrame.SourcesTextEditor.SourcesTextEditor,
277
- type: string): void {
278
- const gutterType = `CodeMirror-gutter-${type}`;
279
- const decorations = uiSourceCode.decorationsForType(type);
280
- textEditor.uninstallGutter(gutterType);
281
- if (!decorations || !decorations.size) {
282
- return;
283
- }
284
- textEditor.installGutter(gutterType, false);
285
- for (const decoration of decorations) {
286
- const value = (decoration.data() as number);
287
- const element = this.createElement(type, value);
288
- textEditor.setGutterDecoration(decoration.range().startLine, gutterType, element);
289
- }
290
- }
291
-
292
- private createElement(type: string, value: number): Element {
293
- const element = document.createElement('div');
294
- element.classList.add('text-editor-line-marker-text');
295
- if (type === 'performance') {
296
- const intensity = Platform.NumberUtilities.clamp(Math.log10(1 + 10 * value) / 5, 0.02, 1);
297
- element.textContent = value.toFixed(1);
298
- element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3)})`;
299
- element.createChild('span', 'line-marker-units').textContent = i18nString(UIStrings.ms);
300
- } else {
301
- const intensity = Platform.NumberUtilities.clamp(Math.log10(1 + 2e-3 * value) / 5, 0.02, 1);
302
- element.style.backgroundColor = `hsla(217, 100%, 70%, ${intensity.toFixed(3)})`;
303
- value /= 1e3;
304
- let units;
305
- let fractionDigits;
306
- if (value >= 1e3) {
307
- units = i18nString(UIStrings.mb);
308
- value /= 1e3;
309
- fractionDigits = value >= 20 ? 0 : 1;
310
- } else {
311
- units = i18nString(UIStrings.kb);
312
- fractionDigits = 0;
227
+ for (const uiSourceCode of Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodes()) {
228
+ if (!decorationsBySource.has(uiSourceCode)) {
229
+ uiSourceCode.setDecorationData(this.type, undefined);
313
230
  }
314
- element.textContent = value.toFixed(fractionDigits);
315
- element.createChild('span', 'line-marker-units').textContent = units;
316
231
  }
317
- return element;
318
232
  }
319
233
  }
320
-
321
- SourceFrame.SourceFrame.registerLineDecorator({
322
- lineDecorator: LineDecorator.instance,
323
- decoratorType: SourceFrame.SourceFrame.DecoratorType.MEMORY,
324
- });
325
-
326
- SourceFrame.SourceFrame.registerLineDecorator({
327
- lineDecorator: LineDecorator.instance,
328
- decoratorType: SourceFrame.SourceFrame.DecoratorType.PERFORMANCE,
329
- });
@@ -4,7 +4,6 @@
4
4
 
5
5
  import type * as Common from '../../../../core/common/common.js';
6
6
  import * as TextUtils from '../../../../models/text_utils/text_utils.js';
7
- import type * as UI from '../../legacy.js';
8
7
 
9
8
  import {ResourceSourceFrame} from './ResourceSourceFrame.js';
10
9
 
@@ -64,7 +63,7 @@ export class BinaryResourceViewFactory {
64
63
  return new ResourceSourceFrame(
65
64
  TextUtils.StaticContentProvider.StaticContentProvider.fromString(
66
65
  this.contentUrl, this.resourceType, this.base64content),
67
- /* autoPrettyPrint */ false, ({lineNumbers: false, lineWrapping: true} as UI.TextEditor.Options));
66
+ this.resourceType.canonicalMimeType(), {lineNumbers: false, lineWrapping: true});
68
67
  }
69
68
 
70
69
  createHexView(): ResourceSourceFrame {
@@ -75,8 +74,7 @@ export class BinaryResourceViewFactory {
75
74
  return {content, isEncoded: false};
76
75
  });
77
76
  return new ResourceSourceFrame(
78
- hexViewerContentProvider,
79
- /* autoPrettyPrint */ false, ({lineNumbers: false, lineWrapping: false} as UI.TextEditor.Options));
77
+ hexViewerContentProvider, this.resourceType.canonicalMimeType(), {lineNumbers: false, lineWrapping: false});
80
78
  }
81
79
 
82
80
  createUtf8View(): ResourceSourceFrame {
@@ -84,8 +82,7 @@ export class BinaryResourceViewFactory {
84
82
  const utf8ContentProvider =
85
83
  new TextUtils.StaticContentProvider.StaticContentProvider(this.contentUrl, this.resourceType, utf8fn);
86
84
  return new ResourceSourceFrame(
87
- utf8ContentProvider,
88
- /* autoPrettyPrint */ false, ({lineNumbers: true, lineWrapping: true} as UI.TextEditor.Options));
85
+ utf8ContentProvider, this.resourceType.canonicalMimeType(), {lineNumbers: true, lineWrapping: true});
89
86
  }
90
87
 
91
88
  static uint8ArrayToHexString(uint8Array: Uint8Array): string {
@@ -35,6 +35,7 @@ import * as i18n from '../../../../core/i18n/i18n.js';
35
35
  import type * as TextUtils from '../../../../models/text_utils/text_utils.js';
36
36
  import * as UI from '../../legacy.js';
37
37
 
38
+ import type {SourceFrameOptions} from './SourceFrame.js';
38
39
  import {SourceFrameImpl} from './SourceFrame.js';
39
40
 
40
41
  const UIStrings = {
@@ -50,40 +51,43 @@ export class ResourceSourceFrame extends SourceFrameImpl {
50
51
  private readonly resourceInternal: TextUtils.ContentProvider.ContentProvider;
51
52
 
52
53
  constructor(
53
- resource: TextUtils.ContentProvider.ContentProvider, autoPrettyPrint?: boolean,
54
- codeMirrorOptions?: UI.TextEditor.Options) {
55
- super(() => resource.requestContent(), codeMirrorOptions);
54
+ resource: TextUtils.ContentProvider.ContentProvider, private readonly givenContentType: string,
55
+ options?: SourceFrameOptions) {
56
+ super(() => resource.requestContent(), options);
56
57
  this.resourceInternal = resource;
57
58
  }
58
59
 
59
60
  static createSearchableView(
60
- resource: TextUtils.ContentProvider.ContentProvider, highlighterType: string,
61
+ resource: TextUtils.ContentProvider.ContentProvider, contentType: string,
61
62
  autoPrettyPrint?: boolean): UI.Widget.Widget {
62
- return new SearchableContainer(resource, highlighterType, autoPrettyPrint);
63
+ return new SearchableContainer(resource, contentType, autoPrettyPrint);
64
+ }
65
+
66
+ protected getContentType(): string {
67
+ return this.givenContentType;
63
68
  }
64
69
 
65
70
  get resource(): TextUtils.ContentProvider.ContentProvider {
66
71
  return this.resourceInternal;
67
72
  }
68
73
 
69
- populateTextAreaContextMenu(contextMenu: UI.ContextMenu.ContextMenu, _lineNumber: number, _columnNumber: number):
70
- Promise<void> {
74
+ protected populateTextAreaContextMenu(
75
+ contextMenu: UI.ContextMenu.ContextMenu, lineNumber: number, columnNumber: number): void {
76
+ super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber);
71
77
  contextMenu.appendApplicableItems(this.resourceInternal);
72
- return Promise.resolve();
73
78
  }
74
79
  }
75
80
 
76
81
  export class SearchableContainer extends UI.Widget.VBox {
77
82
  private readonly sourceFrame: ResourceSourceFrame;
78
83
 
79
- constructor(resource: TextUtils.ContentProvider.ContentProvider, highlighterType: string, autoPrettyPrint?: boolean) {
84
+ constructor(resource: TextUtils.ContentProvider.ContentProvider, contentType: string, autoPrettyPrint?: boolean) {
80
85
  super(true);
81
86
  this.registerRequiredCSS('ui/legacy/components/source_frame/resourceSourceFrame.css');
82
- const sourceFrame = new ResourceSourceFrame(resource, autoPrettyPrint);
87
+ const sourceFrame = new ResourceSourceFrame(resource, contentType);
83
88
  this.sourceFrame = sourceFrame;
84
- sourceFrame.setHighlighterType(highlighterType);
85
- const canPrettyPrint = sourceFrame.resource.contentType().isDocumentOrScriptOrStyleSheet() ||
86
- sourceFrame.highlighterType() === 'application/json';
89
+ const canPrettyPrint =
90
+ sourceFrame.resource.contentType().isDocumentOrScriptOrStyleSheet() || contentType === 'application/json';
87
91
  sourceFrame.setCanPrettyPrint(canPrettyPrint, autoPrettyPrint);
88
92
  const searchableView = new UI.SearchableView.SearchableView(sourceFrame, sourceFrame);
89
93
  searchableView.element.classList.add('searchable-view');
@@ -99,6 +103,6 @@ export class SearchableContainer extends UI.Widget.VBox {
99
103
  }
100
104
 
101
105
  async revealPosition(lineNumber: number, columnNumber?: number): Promise<void> {
102
- this.sourceFrame.revealPosition(lineNumber, columnNumber, true);
106
+ this.sourceFrame.revealPosition({lineNumber, columnNumber}, true);
103
107
  }
104
108
  }