chrome-devtools-frontend 1.0.940255 → 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.
- package/config/gni/all_devtools_files.gni +0 -13
- package/config/gni/devtools_grd_files.gni +13 -13
- package/config/gni/devtools_image_files.gni +1 -2
- package/front_end/.eslintrc.js +1 -0
- package/front_end/Images/src/feedback_button_icon.svg +3 -0
- package/front_end/Tests.js +15 -0
- package/front_end/core/common/Color.ts +5 -0
- package/front_end/core/i18n/locales/en-US.json +39 -30
- package/front_end/core/i18n/locales/en-XL.json +39 -30
- package/front_end/core/sdk/DOMDebuggerModel.ts +18 -1
- package/front_end/core/sdk/sdk-meta.ts +17 -3
- package/front_end/entrypoints/devtools_app/devtools_app.json +1 -7
- package/front_end/entrypoints/main/MainImpl.ts +26 -0
- package/front_end/entrypoints/shell/shell.js +0 -11
- package/front_end/entrypoints/shell/shell.json +0 -1
- package/front_end/entrypoints/worker_app/worker_app.json +0 -4
- package/front_end/generated/InspectorBackendCommands.js +1 -0
- package/front_end/generated/protocol.d.ts +2 -0
- package/front_end/global_typings/global_defs.d.ts +5 -0
- package/front_end/legacy_test_runner/console_test_runner/console_test_runner.js +14 -2
- package/front_end/legacy_test_runner/legacy_test_runner.ts +10 -1
- package/front_end/legacy_test_runner/test_runner/TestRunner.js +9 -0
- package/front_end/models/formatter/SourceFormatter.ts +0 -10
- package/front_end/models/workspace/UISourceCode.ts +9 -42
- package/front_end/panels/animation/AnimationTimeline.ts +3 -3
- package/front_end/panels/application/ApplicationPanelSidebar.ts +3 -3
- package/front_end/panels/application/application-meta.ts +0 -3
- package/front_end/panels/console/ConsolePinPane.ts +21 -26
- package/front_end/panels/coverage/CoverageDecorationManager.ts +4 -5
- package/front_end/panels/coverage/CoverageView.ts +2 -105
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +11 -56
- package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -8
- package/front_end/panels/elements/ElementsTreeElement.ts +4 -9
- package/front_end/panels/elements/components/adornerSettingsPane.css +0 -4
- package/front_end/panels/emulation/emulation-meta.ts +2 -2
- package/front_end/panels/issues/IssueKindView.ts +22 -4
- package/front_end/panels/issues/issues-meta.ts +0 -2
- package/front_end/panels/layers/module.json +0 -1
- package/front_end/panels/lighthouse/lighthouseStartView.css +4 -0
- package/front_end/panels/media/media-meta.ts +0 -3
- package/front_end/panels/network/NetworkLogView.ts +3 -0
- package/front_end/panels/network/ResourceWebSocketFrameView.ts +2 -1
- package/front_end/panels/network/network-meta.ts +0 -3
- package/front_end/panels/profiler/module.json +1 -2
- package/front_end/panels/security/security-meta.ts +0 -3
- package/front_end/panels/sources/BreakpointEditDialog.ts +16 -30
- package/front_end/panels/sources/CSSPlugin.ts +310 -331
- package/front_end/panels/sources/CallStackSidebarPane.ts +28 -34
- package/front_end/panels/sources/CoveragePlugin.ts +121 -6
- package/front_end/panels/sources/DebuggerPlugin.ts +1166 -1243
- package/front_end/panels/sources/EditingLocationHistoryManager.ts +71 -101
- package/front_end/panels/sources/GoToLineQuickOpen.ts +4 -3
- package/front_end/panels/sources/InplaceFormatterEditorAction.ts +3 -3
- package/front_end/panels/sources/JavaScriptCompilerPlugin.ts +26 -23
- package/front_end/panels/sources/Plugin.ts +20 -4
- package/front_end/panels/sources/ProfilePlugin.ts +185 -0
- package/front_end/panels/sources/ScriptFormatterEditorAction.ts +3 -3
- package/front_end/panels/sources/ScriptOriginPlugin.ts +0 -10
- package/front_end/panels/sources/SnippetsPlugin.ts +1 -10
- package/front_end/panels/sources/SourcesPanel.ts +15 -10
- package/front_end/panels/sources/SourcesView.ts +10 -8
- package/front_end/panels/sources/TabbedEditorContainer.ts +31 -27
- package/front_end/panels/sources/UISourceCodeFrame.ts +335 -470
- package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -2
- package/front_end/panels/sources/sources-legacy.ts +0 -6
- package/front_end/panels/sources/sources.ts +0 -2
- package/front_end/panels/timeline/module.json +0 -2
- package/front_end/third_party/codemirror.next/bundle.ts +9 -13
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/javascript.js +2 -2
- package/front_end/third_party/codemirror.next/chunk/markdown.js +2 -6
- package/front_end/third_party/codemirror.next/chunk/php.js +2 -6
- package/front_end/third_party/codemirror.next/chunk/python.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/wast.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/xml.js +2 -2
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +279 -198
- package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +13 -11
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +60 -68
- package/front_end/ui/components/data_grid/dataGrid.css +12 -10
- package/front_end/ui/components/docs/css_overview/start_view.html +25 -0
- package/front_end/ui/components/docs/css_overview/start_view.ts +14 -0
- package/front_end/ui/components/docs/panel_feedback/basic.html +25 -0
- package/front_end/ui/components/docs/panel_feedback/basic.ts +20 -0
- package/front_end/ui/components/docs/panel_feedback/button.html +25 -0
- package/front_end/ui/components/docs/panel_feedback/button.ts +18 -0
- package/front_end/ui/components/helpers/get-stylesheet.ts +1 -0
- package/front_end/ui/components/panel_feedback/FeedbackButton.ts +67 -0
- package/front_end/ui/components/panel_feedback/PanelFeedback.ts +100 -0
- package/front_end/ui/components/panel_feedback/panelFeedback.css +76 -0
- package/front_end/ui/components/panel_feedback/panel_feedback.ts +6 -0
- package/front_end/ui/components/report_view/reportValue.css +1 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +79 -36
- package/front_end/ui/components/text_editor/config.ts +42 -26
- package/front_end/ui/components/text_editor/javascript.ts +2 -3
- package/front_end/ui/components/text_editor/position.ts +17 -0
- package/front_end/ui/components/text_editor/text_editor.ts +1 -0
- package/front_end/ui/components/text_editor/theme.ts +5 -1
- package/front_end/ui/legacy/Infobar.ts +2 -6
- package/front_end/ui/legacy/ShortcutRegistry.ts +11 -7
- package/front_end/ui/legacy/Widget.ts +1 -1
- package/front_end/ui/legacy/components/perf_ui/ChartViewport.ts +2 -1
- package/front_end/ui/legacy/components/perf_ui/FilmStripView.ts +3 -1
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +2 -1
- package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +35 -131
- package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +2 -1
- package/front_end/ui/legacy/components/perf_ui/TimelineGrid.ts +3 -1
- package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +2 -1
- package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +3 -6
- package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +18 -14
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +502 -252
- package/front_end/ui/legacy/components/source_frame/source_frame-legacy.ts +0 -11
- package/front_end/ui/legacy/components/source_frame/source_frame.ts +0 -2
- package/front_end/ui/legacy/components/text_editor/cmdevtools.css +3 -1
- package/front_end/ui/legacy/radioButton.css +1 -13
- package/front_end/ui/legacy/softContextMenu.css +1 -0
- package/front_end/ui/legacy/themeColors.css +36 -0
- package/front_end/ui/legacy/utils/append-style.ts +9 -4
- package/package.json +1 -1
- package/scripts/build/generate_css_js_files.js +23 -9
- package/scripts/build/ninja/generate_css.gni +10 -1
- package/scripts/eslint_rules/lib/check_css_import.js +2 -2
- package/scripts/eslint_rules/tests/check_css_import_test.js +12 -0
- package/front_end/Images/radioDot-dark-theme.png +0 -0
- package/front_end/Images/radioDot.png +0 -0
- package/front_end/panels/application/module.json +0 -7
- package/front_end/panels/issues/module.json +0 -6
- package/front_end/panels/layer_viewer/module.json +0 -6
- package/front_end/panels/media/module.json +0 -6
- package/front_end/panels/network/module.json +0 -6
- package/front_end/panels/security/module.json +0 -5
- package/front_end/ui/legacy/components/perf_ui/module.json +0 -13
- package/front_end/ui/legacy/components/source_frame/SourcesTextEditor.ts +0 -1030
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
export * as FeedbackButton from './FeedbackButton.js';
|
|
6
|
+
export * as PanelFeedback from './PanelFeedback.js';
|
|
@@ -8,7 +8,8 @@ import * as LitHtml from '../../lit-html/lit-html.js';
|
|
|
8
8
|
import * as CodeHighlighter from '../code_highlighter/code_highlighter.js';
|
|
9
9
|
import * as ComponentHelpers from '../helpers/helpers.js';
|
|
10
10
|
|
|
11
|
-
import {baseConfiguration, dynamicSetting} from './config.js';
|
|
11
|
+
import {baseConfiguration, dynamicSetting, DynamicSetting} from './config.js';
|
|
12
|
+
import {toLineColumn, toOffset} from './position.js';
|
|
12
13
|
|
|
13
14
|
declare global {
|
|
14
15
|
interface HTMLElementTagNameMap {
|
|
@@ -21,6 +22,7 @@ export class TextEditor extends HTMLElement {
|
|
|
21
22
|
|
|
22
23
|
private readonly shadow = this.attachShadow({mode: 'open'});
|
|
23
24
|
private activeEditor: CodeMirror.EditorView|undefined = undefined;
|
|
25
|
+
private dynamicSettings: readonly DynamicSetting<unknown>[] = DynamicSetting.none;
|
|
24
26
|
private activeSettingListeners: [Common.Settings.Setting<unknown>, (event: {data: unknown}) => void][] = [];
|
|
25
27
|
private pendingState: CodeMirror.EditorState|undefined;
|
|
26
28
|
|
|
@@ -32,10 +34,17 @@ export class TextEditor extends HTMLElement {
|
|
|
32
34
|
|
|
33
35
|
private createEditor(): CodeMirror.EditorView {
|
|
34
36
|
this.activeEditor = new CodeMirror.EditorView({
|
|
35
|
-
state: this.
|
|
37
|
+
state: this.state,
|
|
36
38
|
parent: this.shadow,
|
|
37
39
|
root: this.shadow,
|
|
40
|
+
dispatch: (tr: CodeMirror.Transaction): void => {
|
|
41
|
+
this.editor.update([tr]);
|
|
42
|
+
if (tr.reconfigured) {
|
|
43
|
+
this.ensureSettingListeners();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
38
46
|
});
|
|
47
|
+
this.ensureSettingListeners();
|
|
39
48
|
return this.activeEditor;
|
|
40
49
|
}
|
|
41
50
|
|
|
@@ -43,6 +52,10 @@ export class TextEditor extends HTMLElement {
|
|
|
43
52
|
return this.activeEditor || this.createEditor();
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
dispatch(spec: CodeMirror.TransactionSpec): void {
|
|
56
|
+
return this.editor.dispatch(spec);
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
get state(): CodeMirror.EditorState {
|
|
47
60
|
if (this.activeEditor) {
|
|
48
61
|
return this.activeEditor.state;
|
|
@@ -65,7 +78,6 @@ export class TextEditor extends HTMLElement {
|
|
|
65
78
|
if (!this.activeEditor) {
|
|
66
79
|
this.createEditor();
|
|
67
80
|
}
|
|
68
|
-
this.registerSettingHandlers();
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
disconnectedCallback(): void {
|
|
@@ -73,63 +85,94 @@ export class TextEditor extends HTMLElement {
|
|
|
73
85
|
this.pendingState = this.activeEditor.state;
|
|
74
86
|
this.activeEditor.destroy();
|
|
75
87
|
this.activeEditor = undefined;
|
|
88
|
+
this.ensureSettingListeners();
|
|
76
89
|
}
|
|
77
|
-
for (const [setting, listener] of this.activeSettingListeners) {
|
|
78
|
-
setting.removeChangeListener(listener);
|
|
79
|
-
}
|
|
80
|
-
this.activeSettingListeners = [];
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
for (const opt of state.facet(dynamicSetting)) {
|
|
87
|
-
const mustUpdate = opt.sync(state, settings.moduleSetting(opt.settingName).get());
|
|
88
|
-
if (mustUpdate) {
|
|
89
|
-
changes.push(mustUpdate);
|
|
90
|
-
}
|
|
92
|
+
focus(): void {
|
|
93
|
+
if (this.activeEditor) {
|
|
94
|
+
this.activeEditor.focus();
|
|
91
95
|
}
|
|
92
|
-
return changes.length ? state.update({effects: changes}).state : state;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
private
|
|
98
|
+
private ensureSettingListeners(): void {
|
|
99
|
+
const dynamicSettings = this.activeEditor ? this.activeEditor.state.facet(dynamicSetting) : DynamicSetting.none;
|
|
100
|
+
if (dynamicSettings === this.dynamicSettings) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.dynamicSettings = dynamicSettings;
|
|
104
|
+
|
|
105
|
+
for (const [setting, listener] of this.activeSettingListeners) {
|
|
106
|
+
setting.removeChangeListener(listener);
|
|
107
|
+
}
|
|
108
|
+
this.activeSettingListeners = [];
|
|
109
|
+
|
|
96
110
|
const settings = Common.Settings.Settings.instance();
|
|
97
|
-
for (const
|
|
111
|
+
for (const dynamicSetting of dynamicSettings) {
|
|
98
112
|
const handler = ({data}: {data: unknown}): void => {
|
|
99
|
-
const change =
|
|
113
|
+
const change = dynamicSetting.sync(this.state, data);
|
|
100
114
|
if (change && this.activeEditor) {
|
|
101
115
|
this.activeEditor.dispatch({effects: change});
|
|
102
116
|
}
|
|
103
117
|
};
|
|
104
|
-
const setting = settings.moduleSetting(
|
|
118
|
+
const setting = settings.moduleSetting(dynamicSetting.settingName);
|
|
105
119
|
setting.addChangeListener(handler);
|
|
106
120
|
this.activeSettingListeners.push([setting, handler]);
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
revealPosition(
|
|
124
|
+
revealPosition(selection: CodeMirror.EditorSelection, highlight: boolean = true): void {
|
|
111
125
|
const view = this.activeEditor;
|
|
112
126
|
if (!view) {
|
|
113
127
|
return;
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
const line = view.state.doc.lineAt(
|
|
130
|
+
const line = view.state.doc.lineAt(selection.main.head);
|
|
131
|
+
const effects: CodeMirror.StateEffect<unknown>[] = [];
|
|
132
|
+
if (highlight) {
|
|
133
|
+
effects.push(
|
|
134
|
+
view.state.field(highlightState, false) ?
|
|
135
|
+
setHighlightLine.of(line.from) :
|
|
136
|
+
CodeMirror.StateEffect.appendConfig.of(highlightState.init(() => highlightDeco(line.from))));
|
|
137
|
+
}
|
|
138
|
+
const editorRect = view.scrollDOM.getBoundingClientRect();
|
|
139
|
+
const targetPos = view.coordsAtPos(selection.main.head);
|
|
140
|
+
if (!targetPos || targetPos.top < editorRect.top || targetPos.bottom > editorRect.bottom) {
|
|
141
|
+
effects.push(CodeMirror.EditorView.centerOn.of(selection.main));
|
|
142
|
+
}
|
|
143
|
+
|
|
117
144
|
view.dispatch({
|
|
118
|
-
selection
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
[view.state.field(highlightState, false) ?
|
|
122
|
-
setHighlightLine.of(line.from) :
|
|
123
|
-
CodeMirror.StateEffect.appendConfig.of(highlightState.init(() => highlightDeco(line.from)))],
|
|
145
|
+
selection,
|
|
146
|
+
effects,
|
|
147
|
+
userEvent: 'select.reveal',
|
|
124
148
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
view.
|
|
131
|
-
|
|
132
|
-
|
|
149
|
+
if (highlight) {
|
|
150
|
+
const {id} = view.state.field(highlightState);
|
|
151
|
+
// Reset the highlight state if, after 2 seconds (the animation
|
|
152
|
+
// duration) it is still showing this highlight.
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
if (view.state.field(highlightState).id === id) {
|
|
155
|
+
view.dispatch({effects: setHighlightLine.of(null)});
|
|
156
|
+
}
|
|
157
|
+
}, 2000);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
createSelection(head: {lineNumber: number, columnNumber: number}, anchor?: {
|
|
162
|
+
lineNumber: number,
|
|
163
|
+
columnNumber: number,
|
|
164
|
+
}): CodeMirror.EditorSelection {
|
|
165
|
+
const {doc} = this.state;
|
|
166
|
+
const headPos = toOffset(doc, head);
|
|
167
|
+
return CodeMirror.EditorSelection.single(anchor ? toOffset(doc, anchor) : headPos, headPos);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
toLineColumn(pos: number): {lineNumber: number, columnNumber: number} {
|
|
171
|
+
return toLineColumn(this.state.doc, pos);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
toOffset(pos: {lineNumber: number, columnNumber: number}): number {
|
|
175
|
+
return toOffset(this.state.doc, pos);
|
|
133
176
|
}
|
|
134
177
|
}
|
|
135
178
|
|
|
@@ -31,24 +31,35 @@ export const dynamicSetting = CM.Facet.define<DynamicSetting<unknown>>();
|
|
|
31
31
|
|
|
32
32
|
export class DynamicSetting<T> {
|
|
33
33
|
compartment = new CM.Compartment();
|
|
34
|
-
extension: CM.Extension;
|
|
35
34
|
|
|
36
35
|
constructor(
|
|
37
36
|
readonly settingName: string,
|
|
38
|
-
private readonly getExtension: (value: T
|
|
37
|
+
private readonly getExtension: (value: T) => CM.Extension,
|
|
39
38
|
) {
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
settingValue(): T {
|
|
42
|
+
return Common.Settings.Settings.instance().moduleSetting(this.settingName).get() as T;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
instance(): CM.Extension {
|
|
46
|
+
return [
|
|
47
|
+
this.compartment.of(this.getExtension(this.settingValue())),
|
|
48
|
+
dynamicSetting.of(this as DynamicSetting<unknown>),
|
|
49
|
+
];
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
sync(state: CM.EditorState, value: T): CM.StateEffect<unknown>|null {
|
|
44
53
|
const cur = this.compartment.get(state);
|
|
45
|
-
const needed = this.getExtension(value
|
|
54
|
+
const needed = this.getExtension(value);
|
|
46
55
|
return cur === needed ? null : this.compartment.reconfigure(needed);
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
static bool(name: string, enabled: CM.Extension, disabled: CM.Extension = empty): DynamicSetting<boolean> {
|
|
50
59
|
return new DynamicSetting<boolean>(name, val => val ? enabled : disabled);
|
|
51
60
|
}
|
|
61
|
+
|
|
62
|
+
static none: readonly DynamicSetting<unknown>[] = [];
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
export const tabMovesFocus = DynamicSetting.bool('textEditorTabMovesFocus', CM.keymap.of([{
|
|
@@ -82,23 +93,15 @@ export function guessIndent(doc: CM.Text): string {
|
|
|
82
93
|
values[space] = (values[space] || 0) + 1;
|
|
83
94
|
}
|
|
84
95
|
const minOccurrence = scanned * 0.05;
|
|
85
|
-
const
|
|
86
|
-
|
|
96
|
+
const shortest = Object.entries(values).reduce((shortest, [string, count]): string|null => {
|
|
97
|
+
return count < minOccurrence || shortest && shortest.length < string.length ? shortest : string;
|
|
98
|
+
}, null as string | null);
|
|
99
|
+
return shortest ?? Common.Settings.Settings.instance().moduleSetting('textEditorIndent').get();
|
|
87
100
|
}
|
|
88
101
|
|
|
89
|
-
const
|
|
102
|
+
const deriveIndentUnit = CM.Prec.highest(CM.indentUnit.compute([], (state: CM.EditorState) => guessIndent(state.doc)));
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
let value = cachedIndentUnit[indent];
|
|
93
|
-
if (!value) {
|
|
94
|
-
value = cachedIndentUnit[indent] = CM.indentUnit.of(indent);
|
|
95
|
-
}
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const autoDetectIndent = new DynamicSetting<boolean>('textEditorAutoDetectIndent', (on, state) => {
|
|
100
|
-
return on ? CM.Prec.override(getIndentUnit(guessIndent(state.doc))) : empty;
|
|
101
|
-
});
|
|
104
|
+
export const autoDetectIndent = DynamicSetting.bool('textEditorAutoDetectIndent', deriveIndentUnit);
|
|
102
105
|
|
|
103
106
|
function matcher(decorator: CM.MatchDecorator): CM.Extension {
|
|
104
107
|
return CM.ViewPlugin.define(
|
|
@@ -154,6 +157,16 @@ export const showWhitespace = new DynamicSetting<string>('showWhitespacesInEdito
|
|
|
154
157
|
|
|
155
158
|
export const allowScrollPastEof = DynamicSetting.bool('allowScrollPastEof', CM.scrollPastEnd());
|
|
156
159
|
|
|
160
|
+
const cachedIndentUnit: {[indent: string]: CM.Extension} = Object.create(null);
|
|
161
|
+
|
|
162
|
+
function getIndentUnit(indent: string): CM.Extension {
|
|
163
|
+
let value = cachedIndentUnit[indent];
|
|
164
|
+
if (!value) {
|
|
165
|
+
value = cachedIndentUnit[indent] = CM.indentUnit.of(indent);
|
|
166
|
+
}
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
|
|
157
170
|
export const indentUnit = new DynamicSetting<string>('textEditorIndent', getIndentUnit);
|
|
158
171
|
|
|
159
172
|
export const domWordWrap = DynamicSetting.bool('domWordWrap', CM.EditorView.lineWrapping);
|
|
@@ -184,22 +197,25 @@ function themeIsDark(): boolean {
|
|
|
184
197
|
|
|
185
198
|
const dummyDarkTheme = CM.EditorView.theme({}, {dark: true});
|
|
186
199
|
|
|
200
|
+
export function theme(): CM.Extension {
|
|
201
|
+
return [editorTheme, themeIsDark() ? dummyDarkTheme : []];
|
|
202
|
+
}
|
|
203
|
+
|
|
187
204
|
export function baseConfiguration(text: string): CM.Extension {
|
|
188
205
|
return [
|
|
189
|
-
|
|
190
|
-
themeIsDark() ? dummyDarkTheme : [],
|
|
206
|
+
theme(),
|
|
191
207
|
CM.highlightSpecialChars(),
|
|
192
208
|
CM.history(),
|
|
193
209
|
CM.drawSelection(),
|
|
194
210
|
CM.EditorState.allowMultipleSelections.of(true),
|
|
195
211
|
CM.indentOnInput(),
|
|
196
|
-
CodeHighlighter.CodeHighlighter.
|
|
212
|
+
CodeHighlighter.CodeHighlighter.highlightStyle,
|
|
197
213
|
CM.closeBrackets(),
|
|
198
214
|
baseKeymap,
|
|
199
|
-
tabMovesFocus,
|
|
200
|
-
bracketMatching,
|
|
201
|
-
indentUnit,
|
|
202
|
-
CM.Prec.
|
|
215
|
+
tabMovesFocus.instance(),
|
|
216
|
+
bracketMatching.instance(),
|
|
217
|
+
indentUnit.instance(),
|
|
218
|
+
CM.Prec.lowest(CM.EditorView.contentAttributes.of({'aria-label': i18nString(UIStrings.codeEditor)})),
|
|
203
219
|
detectLineSeparator(text),
|
|
204
220
|
autocompletion,
|
|
205
221
|
CM.tooltips({parent: getTooltipHost() as unknown as HTMLElement}),
|
|
@@ -221,7 +237,7 @@ function getTooltipHost(): ShadowRoot {
|
|
|
221
237
|
extensions: [
|
|
222
238
|
editorTheme,
|
|
223
239
|
themeIsDark() ? dummyDarkTheme : [],
|
|
224
|
-
CodeHighlighter.CodeHighlighter.
|
|
240
|
+
CodeHighlighter.CodeHighlighter.highlightStyle,
|
|
225
241
|
CM.showTooltip.of({
|
|
226
242
|
pos: 0,
|
|
227
243
|
create() {
|
|
@@ -9,9 +9,8 @@ import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.nex
|
|
|
9
9
|
import * as UI from '../../legacy/legacy.js';
|
|
10
10
|
import {cursorTooltip} from './cursor_tooltip.js';
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
return javascriptLanguage.data.of({
|
|
12
|
+
export function completion(): CodeMirror.Extension {
|
|
13
|
+
return CodeMirror.javascript.javascriptLanguage.data.of({
|
|
15
14
|
autocomplete: javascriptCompletionSource,
|
|
16
15
|
});
|
|
17
16
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import type * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
|
|
6
|
+
|
|
7
|
+
export function toOffset(
|
|
8
|
+
doc: CodeMirror.Text, {lineNumber, columnNumber}: {lineNumber: number, columnNumber: number}): number {
|
|
9
|
+
const line = doc.line(Math.max(1, Math.min(doc.lines, lineNumber + 1)));
|
|
10
|
+
return Math.max(line.from, Math.min(line.to, line.from + columnNumber));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function toLineColumn(doc: CodeMirror.Text, offset: number): {lineNumber: number, columnNumber: number} {
|
|
14
|
+
offset = Math.max(0, Math.min(offset, doc.length));
|
|
15
|
+
const line = doc.lineAt(offset);
|
|
16
|
+
return {lineNumber: line.number - 1, columnNumber: offset - line.from};
|
|
17
|
+
}
|
|
@@ -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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
148
|
-
|
|
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
|
-
|
|
159
|
-
const key = KeyboardShortcut.makeKeyFromEvent(
|
|
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(
|
|
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
|
}
|
|
@@ -458,7 +458,7 @@ export class Widget {
|
|
|
458
458
|
this.doResize();
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
registerRequiredCSS(cssFile: string): void {
|
|
461
|
+
registerRequiredCSS(cssFile: string|{cssContent: string}): void {
|
|
462
462
|
if (this.isWebComponent) {
|
|
463
463
|
Utils.appendStyle((this.shadowRoot as DocumentFragment), cssFile);
|
|
464
464
|
} else {
|
|
@@ -7,6 +7,7 @@ import * as i18n from '../../../../core/i18n/i18n.js';
|
|
|
7
7
|
import * as Platform from '../../../../core/platform/platform.js';
|
|
8
8
|
import * as UI from '../../legacy.js';
|
|
9
9
|
|
|
10
|
+
import chartViewPortStyles from './chartViewport.css.legacy.js';
|
|
10
11
|
import {MinimalTimeWindowMs} from './FlameChart.js';
|
|
11
12
|
|
|
12
13
|
export interface ChartViewportDelegate {
|
|
@@ -51,7 +52,7 @@ export class ChartViewport extends UI.Widget.VBox {
|
|
|
51
52
|
|
|
52
53
|
constructor(delegate: ChartViewportDelegate) {
|
|
53
54
|
super();
|
|
54
|
-
this.registerRequiredCSS(
|
|
55
|
+
this.registerRequiredCSS(chartViewPortStyles);
|
|
55
56
|
|
|
56
57
|
this.delegate = delegate;
|
|
57
58
|
|
|
@@ -9,6 +9,8 @@ import * as Platform from '../../../../core/platform/platform.js';
|
|
|
9
9
|
import type * as SDK from '../../../../core/sdk/sdk.js';
|
|
10
10
|
import * as UI from '../../legacy.js';
|
|
11
11
|
|
|
12
|
+
import filmStripViewStyles from './filmStripView.css.legacy.js';
|
|
13
|
+
|
|
12
14
|
const UIStrings = {
|
|
13
15
|
/**
|
|
14
16
|
*@description Element title in Film Strip View of the Performance panel
|
|
@@ -43,7 +45,7 @@ export class FilmStripView extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
|
43
45
|
|
|
44
46
|
constructor() {
|
|
45
47
|
super(true);
|
|
46
|
-
this.registerRequiredCSS(
|
|
48
|
+
this.registerRequiredCSS(filmStripViewStyles);
|
|
47
49
|
this.contentElement.classList.add('film-strip-view');
|
|
48
50
|
this.statusLabel = this.contentElement.createChild('div', 'label');
|
|
49
51
|
this.reset();
|
|
@@ -42,6 +42,7 @@ import type {ChartViewportDelegate} from './ChartViewport.js';
|
|
|
42
42
|
import {ChartViewport} from './ChartViewport.js';
|
|
43
43
|
import type {Calculator} from './TimelineGrid.js';
|
|
44
44
|
import {TimelineGrid} from './TimelineGrid.js';
|
|
45
|
+
import flameChartStyles from './flameChart.css.legacy.js';
|
|
45
46
|
|
|
46
47
|
const UIStrings = {
|
|
47
48
|
/**
|
|
@@ -157,7 +158,7 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
|
|
|
157
158
|
dataProvider: FlameChartDataProvider, flameChartDelegate: FlameChartDelegate,
|
|
158
159
|
groupExpansionSetting?: Common.Settings.Setting<GroupExpansionState>) {
|
|
159
160
|
super(true);
|
|
160
|
-
this.registerRequiredCSS(
|
|
161
|
+
this.registerRequiredCSS(flameChartStyles);
|
|
161
162
|
this.contentElement.classList.add('flame-chart-main-pane');
|
|
162
163
|
this.groupExpansionSetting = groupExpansionSetting;
|
|
163
164
|
this.groupExpansionState = groupExpansionSetting && groupExpansionSetting.get() || {};
|