chrome-devtools-frontend 1.0.1011873 → 1.0.1012379
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/codereview.settings +4 -0
- package/front_end/core/host/UserMetrics.ts +2 -1
- package/front_end/core/root/Runtime.ts +1 -0
- package/front_end/core/sdk/CSSModel.ts +4 -0
- package/front_end/entrypoints/main/MainImpl.ts +5 -0
- package/front_end/entrypoints/wasmparser_worker/WasmParserWorker.ts +2 -14
- package/front_end/generated/protocol.ts +4 -0
- package/front_end/models/emulation/EmulatedDevices.ts +29 -2
- package/front_end/models/javascript_metadata/NativeFunctions.js +8 -17
- package/front_end/models/persistence/NetworkPersistenceManager.ts +7 -4
- package/front_end/ui/components/panel_feedback/PreviewToggle.ts +2 -2
- package/front_end/ui/components/text_editor/config.ts +2 -2
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +15 -12
- package/package.json +1 -1
@@ -626,8 +626,9 @@ export enum DevtoolsExperiments {
|
|
626
626
|
'cssLayers' = 59,
|
627
627
|
'eyedropperColorPicker' = 60,
|
628
628
|
'instrumentationBreakpoints' = 61,
|
629
|
+
'cssAuthoringHints' = 62,
|
629
630
|
// Increment this when new experiments are added.
|
630
|
-
'MaxValue' =
|
631
|
+
'MaxValue' = 63,
|
631
632
|
}
|
632
633
|
/* eslint-enable @typescript-eslint/naming-convention */
|
633
634
|
|
@@ -291,6 +291,7 @@ export enum ExperimentName {
|
|
291
291
|
CSS_LAYERS = 'cssLayers',
|
292
292
|
EYEDROPPER_COLOR_PICKER = 'eyedropperColorPicker',
|
293
293
|
INSTRUMENTATION_BREAKPOINTS = 'instrumentationBreakpoints',
|
294
|
+
CSS_AUTHORING_HINTS = 'cssAuthoringHints',
|
294
295
|
}
|
295
296
|
|
296
297
|
// TODO(crbug.com/1167717): Make this a const enum again
|
@@ -517,6 +517,10 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
517
517
|
return [...this.#fontFaces.values()];
|
518
518
|
}
|
519
519
|
|
520
|
+
fontFaceForSource(src: string): CSSFontFace|undefined {
|
521
|
+
return this.#fontFaces.get(src);
|
522
|
+
}
|
523
|
+
|
520
524
|
styleSheetHeaderForId(id: Protocol.CSS.StyleSheetId): CSSStyleSheetHeader|null {
|
521
525
|
return this.#styleSheetIdToHeader.get(id) || null;
|
522
526
|
}
|
@@ -386,6 +386,11 @@ export class MainImpl {
|
|
386
386
|
Root.Runtime.experiments.register(
|
387
387
|
Root.Runtime.ExperimentName.HEADER_OVERRIDES, 'Local overrides for response headers');
|
388
388
|
|
389
|
+
// Enable CSS Authoring hints for inactive rules, deprecated properties, etc.
|
390
|
+
Root.Runtime.experiments.register(
|
391
|
+
Root.Runtime.ExperimentName.CSS_AUTHORING_HINTS,
|
392
|
+
'Enable CSS Authoring hints for inactive rules, deprecated properties, etc.');
|
393
|
+
|
389
394
|
// New Lighthouse panel with timespan and snapshot mode
|
390
395
|
Root.Runtime.experiments.register('lighthousePanelFR', 'Use Lighthouse panel with timespan and snapshot modes');
|
391
396
|
|
@@ -55,7 +55,6 @@ export function dissambleWASM(
|
|
55
55
|
const lines = [];
|
56
56
|
const offsets = [];
|
57
57
|
const functionBodyOffsets = [];
|
58
|
-
const MAX_LINES = 1000 * 1000;
|
59
58
|
let chunkSize: number = 128 * 1024;
|
60
59
|
let buffer: Uint8Array = new Uint8Array(chunkSize);
|
61
60
|
let pendingSize = 0;
|
@@ -86,6 +85,7 @@ export function dissambleWASM(
|
|
86
85
|
end: number,
|
87
86
|
}>,
|
88
87
|
});
|
88
|
+
|
89
89
|
for (const line of result.lines) {
|
90
90
|
lines.push(line);
|
91
91
|
}
|
@@ -96,14 +96,6 @@ export function dissambleWASM(
|
|
96
96
|
functionBodyOffsets.push(functionBodyOffset);
|
97
97
|
}
|
98
98
|
|
99
|
-
if (lines.length > MAX_LINES) {
|
100
|
-
lines[MAX_LINES] = ';; .... text is truncated due to size';
|
101
|
-
lines.splice(MAX_LINES + 1);
|
102
|
-
if (offsets) {
|
103
|
-
offsets.splice(MAX_LINES + 1);
|
104
|
-
}
|
105
|
-
break;
|
106
|
-
}
|
107
99
|
if (finished) {
|
108
100
|
break;
|
109
101
|
}
|
@@ -124,13 +116,9 @@ export function dissambleWASM(
|
|
124
116
|
postMessage({event: 'progress', params: {percentage}});
|
125
117
|
}
|
126
118
|
|
127
|
-
postMessage({event: 'progress', params: {percentage: 99}});
|
128
|
-
|
129
|
-
const source = lines.join('\n');
|
130
|
-
|
131
119
|
postMessage({event: 'progress', params: {percentage: 100}});
|
132
120
|
|
133
|
-
postMessage({method: 'disassemble', result: {
|
121
|
+
postMessage({method: 'disassemble', result: {lines, offsets, functionBodyOffsets}});
|
134
122
|
} catch (error) {
|
135
123
|
postMessage({method: 'disassemble', error});
|
136
124
|
}
|
@@ -725,6 +725,8 @@ const emulatedDevices = [
|
|
725
725
|
'capabilities': ['touch', 'mobile'],
|
726
726
|
'user-agent':
|
727
727
|
'Mozilla/5.0 (Linux; Android 11; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36',
|
728
|
+
'user-agent-metadata':
|
729
|
+
{'platform': 'Android', 'platformVersion': '11', 'architecture': '', 'model': 'Pixel 3', 'mobile': true},
|
728
730
|
'type': 'phone',
|
729
731
|
},
|
730
732
|
{
|
@@ -745,6 +747,8 @@ const emulatedDevices = [
|
|
745
747
|
'capabilities': ['touch', 'mobile'],
|
746
748
|
'user-agent':
|
747
749
|
'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36',
|
750
|
+
'user-agent-metadata':
|
751
|
+
{'platform': 'Android', 'platformVersion': '11', 'architecture': '', 'model': 'Pixel 5', 'mobile': true},
|
748
752
|
'type': 'phone',
|
749
753
|
},
|
750
754
|
{
|
@@ -765,6 +769,8 @@ const emulatedDevices = [
|
|
765
769
|
'capabilities': ['touch', 'mobile'],
|
766
770
|
'user-agent':
|
767
771
|
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36',
|
772
|
+
'user-agent-metadata':
|
773
|
+
{'platform': 'Android', 'platformVersion': '8.0.0', 'architecture': '', 'model': 'SM-G955U', 'mobile': true},
|
768
774
|
'type': 'phone',
|
769
775
|
},
|
770
776
|
{
|
@@ -785,6 +791,8 @@ const emulatedDevices = [
|
|
785
791
|
'capabilities': ['touch', 'mobile'],
|
786
792
|
'user-agent':
|
787
793
|
'Mozilla/5.0 (Linux; Android 10; SM-G981B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Mobile Safari/537.36',
|
794
|
+
'user-agent-metadata':
|
795
|
+
{'platform': 'Android', 'platformVersion': '10', 'architecture': '', 'model': 'SM-G981B', 'mobile': true},
|
788
796
|
'type': 'phone',
|
789
797
|
},
|
790
798
|
{
|
@@ -869,7 +877,9 @@ const emulatedDevices = [
|
|
869
877
|
},
|
870
878
|
'capabilities': ['touch', 'mobile'],
|
871
879
|
'user-agent':
|
872
|
-
'Mozilla/5.0 (Linux; Android
|
880
|
+
'Mozilla/5.0 (Linux; Android 11.0; Surface Duo) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36',
|
881
|
+
'user-agent-metadata':
|
882
|
+
{'platform': 'Android', 'platformVersion': '11.0', 'architecture': '', 'model': 'Surface Duo', 'mobile': true},
|
873
883
|
'type': 'phone',
|
874
884
|
'modes': [
|
875
885
|
{'title': 'default', 'orientation': 'vertical', 'insets': {'left': 0, 'top': 0, 'right': 0, 'bottom': 0}},
|
@@ -896,7 +906,9 @@ const emulatedDevices = [
|
|
896
906
|
},
|
897
907
|
'capabilities': ['touch', 'mobile'],
|
898
908
|
'user-agent':
|
899
|
-
'Mozilla/5.0 (Linux; Android
|
909
|
+
'Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36',
|
910
|
+
'user-agent-metadata':
|
911
|
+
{'platform': 'Android', 'platformVersion': '9.0', 'architecture': '', 'model': 'SM-F900U', 'mobile': true},
|
900
912
|
'type': 'phone',
|
901
913
|
'modes': [
|
902
914
|
{'title': 'default', 'orientation': 'vertical', 'insets': {'left': 0, 'top': 0, 'right': 0, 'bottom': 0}},
|
@@ -927,6 +939,8 @@ const emulatedDevices = [
|
|
927
939
|
'capabilities': ['touch', 'mobile'],
|
928
940
|
'user-agent':
|
929
941
|
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36',
|
942
|
+
'user-agent-metadata':
|
943
|
+
{'platform': 'Android', 'platformVersion': '8.0.0', 'architecture': '', 'model': 'SM-G955U', 'mobile': true},
|
930
944
|
'type': 'phone',
|
931
945
|
},
|
932
946
|
{
|
@@ -976,6 +990,8 @@ const emulatedDevices = [
|
|
976
990
|
'capabilities': ['touch', 'mobile'],
|
977
991
|
'user-agent':
|
978
992
|
'Mozilla/5.0 (Linux; Android) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.109 Safari/537.36 CrKey/1.54.248666',
|
993
|
+
'user-agent-metadata':
|
994
|
+
{'platform': 'Android', 'platformVersion': '', 'architecture': '', 'model': '', 'mobile': true},
|
979
995
|
'type': 'tablet',
|
980
996
|
'modes': [{'title': 'default', 'orientation': 'horizontal'}],
|
981
997
|
},
|
@@ -1409,6 +1425,8 @@ const emulatedDevices = [
|
|
1409
1425
|
'capabilities': ['touch', 'mobile'],
|
1410
1426
|
'user-agent':
|
1411
1427
|
'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263',
|
1428
|
+
'user-agent-metadata':
|
1429
|
+
{'platform': 'Android', 'platformVersion': '4.2.1', 'architecture': '', 'model': 'Lumia 550', 'mobile': true},
|
1412
1430
|
'type': 'phone',
|
1413
1431
|
},
|
1414
1432
|
{
|
@@ -1422,6 +1440,8 @@ const emulatedDevices = [
|
|
1422
1440
|
'capabilities': ['touch', 'mobile'],
|
1423
1441
|
'user-agent':
|
1424
1442
|
'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263',
|
1443
|
+
'user-agent-metadata':
|
1444
|
+
{'platform': 'Android', 'platformVersion': '4.2.1', 'architecture': '', 'model': 'Lumia 950', 'mobile': true},
|
1425
1445
|
'type': 'phone',
|
1426
1446
|
},
|
1427
1447
|
{
|
@@ -1512,6 +1532,13 @@ const emulatedDevices = [
|
|
1512
1532
|
'capabilities': ['touch', 'mobile'],
|
1513
1533
|
'user-agent':
|
1514
1534
|
'Mozilla/5.0 (Mobile; LYF/F300B/LYF-F300B-001-01-15-130718-i;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.5',
|
1535
|
+
'user-agent-metadata': {
|
1536
|
+
'platform': 'Android',
|
1537
|
+
'platformVersion': '',
|
1538
|
+
'architecture': '',
|
1539
|
+
'model': 'LYF/F300B/LYF-F300B-001-01-15-130718-i',
|
1540
|
+
'mobile': true,
|
1541
|
+
},
|
1515
1542
|
'type': 'phone',
|
1516
1543
|
},
|
1517
1544
|
{
|
@@ -1247,7 +1247,7 @@ export const NativeFunctions = [
|
|
1247
1247
|
},
|
1248
1248
|
{
|
1249
1249
|
name: 'add',
|
1250
|
-
signatures: [['
|
1250
|
+
signatures: [['sub_apps']],
|
1251
1251
|
receivers: ['SubApps']
|
1252
1252
|
},
|
1253
1253
|
{
|
@@ -1745,11 +1745,6 @@ export const NativeFunctions = [
|
|
1745
1745
|
name: 'replaceWith',
|
1746
1746
|
signatures: [['...nodes']]
|
1747
1747
|
},
|
1748
|
-
{
|
1749
|
-
name: 'read',
|
1750
|
-
signatures: [['?options']],
|
1751
|
-
receivers: ['Clipboard']
|
1752
|
-
},
|
1753
1748
|
{
|
1754
1749
|
name: 'read',
|
1755
1750
|
signatures: [['view']],
|
@@ -2572,7 +2567,7 @@ export const NativeFunctions = [
|
|
2572
2567
|
{
|
2573
2568
|
name: 'focus',
|
2574
2569
|
signatures: [['focus_behavior']],
|
2575
|
-
receivers: ['FocusableMediaStreamTrack']
|
2570
|
+
receivers: ['BrowserCaptureMediaStreamTrack','FocusableMediaStreamTrack']
|
2576
2571
|
},
|
2577
2572
|
{
|
2578
2573
|
name: 'assign',
|
@@ -5898,10 +5893,6 @@ export const NativeFunctions = [
|
|
5898
5893
|
name: 'registerProperty',
|
5899
5894
|
signatures: [['definition']]
|
5900
5895
|
},
|
5901
|
-
{
|
5902
|
-
name: 'setElement',
|
5903
|
-
signatures: [['element','tag','?options']]
|
5904
|
-
},
|
5905
5896
|
{
|
5906
5897
|
name: 'timeout',
|
5907
5898
|
signatures: [['milliseconds']]
|
@@ -6767,7 +6758,7 @@ export const NativeFunctions = [
|
|
6767
6758
|
},
|
6768
6759
|
{
|
6769
6760
|
name: 'ClipboardItem',
|
6770
|
-
signatures: [['items'
|
6761
|
+
signatures: [['items']]
|
6771
6762
|
},
|
6772
6763
|
{
|
6773
6764
|
name: 'CompressionStream',
|
@@ -7113,6 +7104,10 @@ export const NativeFunctions = [
|
|
7113
7104
|
name: 'cropTo',
|
7114
7105
|
signatures: [['crop_id']]
|
7115
7106
|
},
|
7107
|
+
{
|
7108
|
+
name: 'fromElement',
|
7109
|
+
signatures: [['element']]
|
7110
|
+
},
|
7116
7111
|
{
|
7117
7112
|
name: 'getDisplayMediaSet',
|
7118
7113
|
signatures: [['?constraints']]
|
@@ -7121,10 +7116,6 @@ export const NativeFunctions = [
|
|
7121
7116
|
name: 'setCaptureHandleConfig',
|
7122
7117
|
signatures: [['?config']]
|
7123
7118
|
},
|
7124
|
-
{
|
7125
|
-
name: 'produceCropId',
|
7126
|
-
signatures: [['target']]
|
7127
|
-
},
|
7128
7119
|
{
|
7129
7120
|
name: 'MediaStreamEvent',
|
7130
7121
|
signatures: [['type','?eventInitDict']]
|
@@ -7399,7 +7390,7 @@ export const NativeFunctions = [
|
|
7399
7390
|
},
|
7400
7391
|
{
|
7401
7392
|
name: 'requestPictureInPictureWindow',
|
7402
|
-
signatures: [['options']]
|
7393
|
+
signatures: [['?options']]
|
7403
7394
|
},
|
7404
7395
|
{
|
7405
7396
|
name: 'PresentationConnectionAvailableEvent',
|
@@ -310,8 +310,11 @@ export class NetworkPersistenceManager extends Common.ObjectWrapper.ObjectWrappe
|
|
310
310
|
if (binding) {
|
311
311
|
const mutex = this.#getOrCreateMutex(binding.network);
|
312
312
|
const release = await mutex.acquire();
|
313
|
-
|
314
|
-
|
313
|
+
try {
|
314
|
+
await this.#innerUnbind(binding);
|
315
|
+
} finally {
|
316
|
+
release();
|
317
|
+
}
|
315
318
|
}
|
316
319
|
}
|
317
320
|
|
@@ -340,10 +343,10 @@ export class NetworkPersistenceManager extends Common.ObjectWrapper.ObjectWrappe
|
|
340
343
|
if (networkUISourceCode === network && fileSystemUISourceCode === fileSystem) {
|
341
344
|
return;
|
342
345
|
}
|
346
|
+
await this.#unbindUnguarded(networkUISourceCode);
|
347
|
+
await this.#unbindUnguarded(fileSystemUISourceCode);
|
343
348
|
}
|
344
349
|
|
345
|
-
await this.#unbindUnguarded(networkUISourceCode);
|
346
|
-
await this.#unbindUnguarded(fileSystemUISourceCode);
|
347
350
|
await this.#innerAddBinding(networkUISourceCode, fileSystemUISourceCode);
|
348
351
|
} finally {
|
349
352
|
release();
|
@@ -60,7 +60,7 @@ export class PreviewToggle extends HTMLElement {
|
|
60
60
|
// clang-format off
|
61
61
|
render(
|
62
62
|
html`
|
63
|
-
<
|
63
|
+
<label class="experiment-preview">
|
64
64
|
<input type="checkbox" ?checked=${checked} @change=${this.#checkboxChanged} aria-label=${this.#name}/>
|
65
65
|
<${IconButton.Icon.Icon.litTagName} .data=${{
|
66
66
|
iconName: 'ic_preview_feature',
|
@@ -74,7 +74,7 @@ export class PreviewToggle extends HTMLElement {
|
|
74
74
|
${this.#helperText && this.#feedbackURL
|
75
75
|
? html`<p>${this.#helperText} <x-link href=${this.#feedbackURL}>${i18nString(UIStrings.previewTextFeedbackLink)}</x-link></p>`
|
76
76
|
: nothing}
|
77
|
-
</
|
77
|
+
</label>`,
|
78
78
|
this.#shadow,
|
79
79
|
{
|
80
80
|
host: this,
|
@@ -236,7 +236,7 @@ function getTooltipSpace(): DOMRect {
|
|
236
236
|
return sideBarElement.getBoundingClientRect();
|
237
237
|
}
|
238
238
|
|
239
|
-
export function baseConfiguration(text: string): CM.Extension {
|
239
|
+
export function baseConfiguration(text: string|CM.Text): CM.Extension {
|
240
240
|
return [
|
241
241
|
theme(),
|
242
242
|
CM.highlightSpecialChars(),
|
@@ -252,7 +252,7 @@ export function baseConfiguration(text: string): CM.Extension {
|
|
252
252
|
bracketMatching.instance(),
|
253
253
|
indentUnit.instance(),
|
254
254
|
CM.Prec.lowest(CM.EditorView.contentAttributes.of({'aria-label': i18nString(UIStrings.codeEditor)})),
|
255
|
-
detectLineSeparator(text),
|
255
|
+
text instanceof CM.Text ? [] : detectLineSeparator(text),
|
256
256
|
CM.tooltips({
|
257
257
|
tooltipSpace: getTooltipSpace,
|
258
258
|
}),
|
@@ -105,7 +105,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
105
105
|
UI.View.SimpleView) implements UI.SearchableView.Searchable, UI.SearchableView.Replaceable, Transformer {
|
106
106
|
private readonly lazyContent: () => Promise<TextUtils.ContentProvider.DeferredContent>;
|
107
107
|
private prettyInternal: boolean;
|
108
|
-
private rawContent: string|null;
|
108
|
+
private rawContent: string|CodeMirror.Text|null;
|
109
109
|
private formattedContentPromise: Promise<Formatter.ScriptFormatter.FormattedContent>|null;
|
110
110
|
private formattedMap: Formatter.ScriptFormatter.FormatterSourceMapping|null;
|
111
111
|
private readonly prettyToggle: UI.Toolbar.ToolbarToggle;
|
@@ -203,7 +203,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
203
203
|
});
|
204
204
|
}
|
205
205
|
|
206
|
-
protected editorConfiguration(doc: string): CodeMirror.Extension {
|
206
|
+
protected editorConfiguration(doc: string|CodeMirror.Text): CodeMirror.Extension {
|
207
207
|
return [
|
208
208
|
CodeMirror.EditorView.updateListener.of(update => this.dispatchEventToListeners(Events.EditorUpdate, update)),
|
209
209
|
TextEditor.Config.baseConfiguration(doc),
|
@@ -459,7 +459,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
459
459
|
const worker = Common.Worker.WorkerWrapper.fromURL(
|
460
460
|
new URL('../../../../entrypoints/wasmparser_worker/wasmparser_worker-entrypoint.js', import.meta.url));
|
461
461
|
const promise = new Promise<{
|
462
|
-
|
462
|
+
lines: string[],
|
463
463
|
offsets: number[],
|
464
464
|
functionBodyOffsets: {
|
465
465
|
start: number,
|
@@ -492,8 +492,8 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
492
492
|
});
|
493
493
|
worker.postMessage({method: 'disassemble', params: {content}});
|
494
494
|
try {
|
495
|
-
const {
|
496
|
-
this.rawContent = content =
|
495
|
+
const {lines, offsets, functionBodyOffsets} = await promise;
|
496
|
+
this.rawContent = content = CodeMirror.Text.of(lines);
|
497
497
|
this.wasmDisassemblyInternal = new Common.WasmDisassembly.WasmDisassembly(offsets, functionBodyOffsets);
|
498
498
|
} catch (e) {
|
499
499
|
this.rawContent = content = error = e.message;
|
@@ -528,8 +528,8 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
528
528
|
if (this.formattedContentPromise) {
|
529
529
|
return this.formattedContentPromise;
|
530
530
|
}
|
531
|
-
this.
|
532
|
-
|
531
|
+
const content = this.rawContent instanceof CodeMirror.Text ? this.rawContent.sliceString(0) : this.rawContent || '';
|
532
|
+
this.formattedContentPromise = Formatter.ScriptFormatter.formatScriptContent(this.contentType, content);
|
533
533
|
return this.formattedContentPromise;
|
534
534
|
}
|
535
535
|
|
@@ -648,7 +648,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
648
648
|
this.prettyToggle.setEnabled(true);
|
649
649
|
}
|
650
650
|
|
651
|
-
private simplifyMimeType(content: string, mimeType: string): string {
|
651
|
+
private simplifyMimeType(content: string|CodeMirror.Text, mimeType: string): string {
|
652
652
|
if (!mimeType) {
|
653
653
|
return '';
|
654
654
|
}
|
@@ -663,8 +663,11 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
663
663
|
return 'text/jsx';
|
664
664
|
}
|
665
665
|
// A hack around the fact that files with "php" extension might be either standalone or html embedded php scripts.
|
666
|
-
if (mimeType === 'text/x-php'
|
667
|
-
|
666
|
+
if (mimeType === 'text/x-php') {
|
667
|
+
const strContent = typeof content === 'string' ? content : content.sliceString(0);
|
668
|
+
if (strContent.match(/\<\?.*\?\>/g)) {
|
669
|
+
return 'application/x-httpd-php';
|
670
|
+
}
|
668
671
|
}
|
669
672
|
if (mimeType === 'application/wasm') {
|
670
673
|
// text/webassembly is not a proper MIME type, but CodeMirror uses it for WAT syntax highlighting.
|
@@ -674,7 +677,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
674
677
|
return mimeType;
|
675
678
|
}
|
676
679
|
|
677
|
-
protected async getLanguageSupport(content: string): Promise<CodeMirror.Extension> {
|
680
|
+
protected async getLanguageSupport(content: string|CodeMirror.Text): Promise<CodeMirror.Extension> {
|
678
681
|
const mimeType = this.simplifyMimeType(content, this.contentType) || '';
|
679
682
|
const languageDesc = await CodeHighlighter.CodeHighlighter.languageFromMIME(mimeType);
|
680
683
|
if (!languageDesc) {
|
@@ -694,7 +697,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
694
697
|
this.textEditor.dispatch({effects: config.language.reconfigure(langExtension)});
|
695
698
|
}
|
696
699
|
|
697
|
-
async setContent(content: string): Promise<void> {
|
700
|
+
async setContent(content: string|CodeMirror.Text): Promise<void> {
|
698
701
|
this.muteChangeEventsForSetContent = true;
|
699
702
|
const {textEditor} = this;
|
700
703
|
const wasLoaded = this.loadedInternal;
|
package/package.json
CHANGED