chrome-devtools-frontend 1.0.955630 → 1.0.956881
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/AUTHORS +1 -0
- package/config/gni/devtools_grd_files.gni +0 -2
- package/front_end/.eslintrc.js +1 -11
- package/front_end/Images/generate-css-vars.js +2 -2
- package/front_end/core/common/ParsedURL.ts +35 -2
- package/front_end/core/common/Settings.ts +1 -1
- package/front_end/core/host/InspectorFrontendHost.ts +2 -1
- package/front_end/core/i18n/i18nImpl.ts +2 -3
- package/front_end/core/i18n/locales/en-US.json +0 -3
- package/front_end/core/i18n/locales/en-XL.json +0 -3
- package/front_end/core/root/Runtime.ts +0 -72
- package/front_end/core/root/root-legacy.ts +0 -2
- package/front_end/entrypoints/formatter_worker/FormatterActions.ts +10 -0
- package/front_end/entrypoints/formatter_worker/FormatterWorker.ts +3 -4
- package/front_end/entrypoints/lighthouse_worker/LighthouseService.ts +4 -7
- package/front_end/entrypoints/main/MainImpl.ts +21 -13
- package/front_end/entrypoints/main/main-meta.ts +1 -1
- package/front_end/generated/protocol.d.ts +1 -0
- package/front_end/global_typings/global_defs.d.ts +0 -1
- package/front_end/models/extensions/ExtensionServer.ts +1 -22
- package/front_end/models/formatter/FormatterWorkerPool.ts +2 -12
- package/front_end/models/formatter/ScriptFormatter.ts +3 -3
- package/front_end/models/issues_manager/DeprecationIssue.ts +7 -7
- package/front_end/panels/console/ConsoleSidebar.ts +9 -9
- package/front_end/panels/elements/ElementsPanel.ts +1 -1
- package/front_end/panels/elements/ElementsTreeElement.ts +5 -4
- package/front_end/panels/elements/components/LayoutPane.ts +1 -1
- package/front_end/panels/emulation/AdvancedApp.ts +2 -2
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +2 -1
- package/front_end/panels/sources/SourcesPanel.ts +1 -1
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +19 -0
- package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +7 -1
- package/front_end/third_party/acorn/acorn.ts +1 -1
- package/front_end/ui/legacy/GlassPane.ts +0 -1
- package/front_end/ui/legacy/ResizerWidget.ts +4 -2
- package/front_end/ui/legacy/SoftDropDown.ts +2 -1
- package/front_end/ui/legacy/TextPrompt.ts +2 -2
- package/front_end/ui/legacy/Treeoutline.ts +9 -15
- package/front_end/ui/legacy/UIUtils.ts +17 -24
- package/front_end/ui/legacy/ViewManager.ts +1 -1
- package/front_end/ui/legacy/Widget.ts +3 -2
- package/front_end/ui/legacy/components/color_picker/Spectrum.ts +5 -5
- package/front_end/ui/legacy/components/color_picker/spectrum.css +5 -2
- package/front_end/ui/legacy/components/data_grid/DataGrid.ts +1 -0
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +13 -18
- package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +2 -1
- package/front_end/ui/legacy/components/perf_ui/TimelineGrid.ts +1 -2
- package/front_end/ui/legacy/components/perf_ui/flameChart.css +8 -0
- package/front_end/ui/legacy/components/source_frame/FontView.ts +0 -1
- package/front_end/ui/legacy/components/source_frame/ImageView.ts +0 -1
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +0 -1
- package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +0 -1
- package/front_end/ui/legacy/components/source_frame/XMLView.ts +0 -2
- package/front_end/ui/legacy/inspectorSyntaxHighlight.css +8 -11
- package/front_end/ui/legacy/softContextMenu.css +4 -1
- package/front_end/ui/legacy/tabbedPane.css +1 -0
- package/front_end/ui/legacy/themeColors.css +3 -1
- package/front_end/ui/legacy/theme_support/theme_support_impl.ts +24 -234
- package/front_end/ui/legacy/treeoutline.css +0 -4
- package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +3 -2
- package/front_end/ui/legacy/utils/inject-core-styles.ts +3 -31
- package/front_end/ui/legacy/utils/utils.ts +1 -5
- package/front_end/ui/lit-html/lit-html.ts +1 -1
- package/package.json +1 -1
- package/scripts/build/generate_css_js_files.js +2 -2
- package/scripts/build/ninja/generate_css.gni +3 -0
- package/scripts/component_server/server.js +2 -2
- package/scripts/eslint_rules/lib/no_bound_component_methods.js +116 -0
- package/scripts/eslint_rules/tests/no_bound_component_methods_test.js +85 -0
- package/front_end/global_typings/intl_display_names.d.ts +0 -111
- package/front_end/ui/legacy/inspectorSyntaxHighlightDark.css +0 -270
- package/front_end/ui/legacy/utils/append-style.ts +0 -9
|
@@ -28,11 +28,9 @@ export class XMLView extends UI.Widget.Widget implements UI.SearchableView.Searc
|
|
|
28
28
|
|
|
29
29
|
constructor(parsedXML: Document) {
|
|
30
30
|
super(true);
|
|
31
|
-
// eslint-disable-next-line no-restricted-syntax -- Should import styles https://crbug.com/1106746
|
|
32
31
|
this.registerRequiredCSS(xmlViewStyles);
|
|
33
32
|
this.contentElement.classList.add('shadow-xml-view', 'source-code');
|
|
34
33
|
this.treeOutline = new UI.TreeOutline.TreeOutlineInShadow();
|
|
35
|
-
// eslint-disable-next-line no-restricted-syntax -- Should import styles https://crbug.com/1106746
|
|
36
34
|
this.treeOutline.registerRequiredCSS(xmlTreeStyles);
|
|
37
35
|
this.contentElement.appendChild(this.treeOutline.element);
|
|
38
36
|
this.currentSearchFocusIndex = 0;
|
|
@@ -27,18 +27,16 @@
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
.webkit-css-property {
|
|
30
|
-
color: var(--webkit-css-property-color,
|
|
30
|
+
color: var(--webkit-css-property-color, var(--color-syntax-1)); /* stylelint-disable-line plugin/use_theme_colors */ /* See: crbug.com/1152736 for color variable migration. */
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.webkit-html-comment {
|
|
34
34
|
/* Keep this in sync with view-source.css (.webkit-html-comment) */
|
|
35
|
-
color:
|
|
36
|
-
/* See: crbug.com/1152736 for color variable migration. */
|
|
35
|
+
color: var(--color-token-comment);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
.webkit-html-tag {
|
|
40
|
-
color:
|
|
41
|
-
/* See: crbug.com/1152736 for color variable migration. */
|
|
39
|
+
color: var(--color-token-tag);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
.webkit-html-tag-name,
|
|
@@ -49,16 +47,17 @@
|
|
|
49
47
|
|
|
50
48
|
.webkit-html-pseudo-element {
|
|
51
49
|
/* This one is non-standard. */
|
|
52
|
-
color:
|
|
53
|
-
/* See: crbug.com/1152736 for color variable migration. */
|
|
50
|
+
color: var(--color-token-pseudo-element);
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
.webkit-html-js-node,
|
|
57
54
|
.webkit-html-css-node {
|
|
55
|
+
color: var(--color-text-primary);
|
|
58
56
|
white-space: pre-wrap;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
.webkit-html-text-node {
|
|
60
|
+
color: var(--color-text-primary);
|
|
62
61
|
unicode-bidi: -webkit-isolate;
|
|
63
62
|
}
|
|
64
63
|
|
|
@@ -77,15 +76,13 @@
|
|
|
77
76
|
|
|
78
77
|
.webkit-html-attribute-name {
|
|
79
78
|
/* Keep this in sync with view-source.css (.webkit-html-attribute-name) */
|
|
80
|
-
color: var(--color-token-attribute);
|
|
81
|
-
/* See: crbug.com/1152736 for color variable migration. */
|
|
79
|
+
color: var(--color-token-attribute);
|
|
82
80
|
unicode-bidi: -webkit-isolate;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
.webkit-html-attribute-value {
|
|
86
84
|
/* Keep this in sync with view-source.css (.webkit-html-attribute-value) */
|
|
87
|
-
color:
|
|
88
|
-
/* See: crbug.com/1152736 for color variable migration. */
|
|
85
|
+
color: var(--color-token-attribute-value);
|
|
89
86
|
unicode-bidi: -webkit-isolate;
|
|
90
87
|
word-break: break-all;
|
|
91
88
|
}
|
|
@@ -35,12 +35,15 @@
|
|
|
35
35
|
box-shadow: var(--override-mac-specific-box-shadow);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
.dockside-title {
|
|
39
|
+
padding-right: 13px;
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
.soft-context-menu-item {
|
|
39
43
|
display: flex;
|
|
40
44
|
width: 100%;
|
|
41
45
|
font-size: 12px;
|
|
42
46
|
padding: 3px 7px 3px 8px;
|
|
43
|
-
margin: 0 13px 0 0;
|
|
44
47
|
white-space: nowrap;
|
|
45
48
|
align-items: center;
|
|
46
49
|
}
|
|
@@ -155,6 +155,7 @@
|
|
|
155
155
|
--color-token-meta: rgb(85 85 85);
|
|
156
156
|
--color-token-deleted: rgb(221 68 68);
|
|
157
157
|
--color-token-inserted: rgb(34 153 34);
|
|
158
|
+
--color-token-pseudo-element: rgb(17 85 204);
|
|
158
159
|
|
|
159
160
|
/* Colors used by the code editor */
|
|
160
161
|
--color-secondary-cursor: #c0c0c0;
|
|
@@ -295,8 +296,9 @@
|
|
|
295
296
|
--color-token-comment: rgb(137 137 137);
|
|
296
297
|
--color-token-tag: rgb(93 176 215);
|
|
297
298
|
--color-token-attribute: rgb(155 187 220);
|
|
298
|
-
--color-token-attribute-value: rgb(
|
|
299
|
+
--color-token-attribute-value: rgb(242 151 102);
|
|
299
300
|
--color-token-meta: rgb(221 251 85);
|
|
301
|
+
--color-token-pseudo-element: rgb(237 119 229);
|
|
300
302
|
|
|
301
303
|
/* Colors used by the code editor */
|
|
302
304
|
--color-secondary-cursor: rgb(63 63 63);
|
|
@@ -34,46 +34,20 @@
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
import * as Common from '../../../core/common/common.js';
|
|
37
|
-
import * as Platform from '../../../core/platform/platform.js';
|
|
38
37
|
|
|
39
38
|
import inspectorSyntaxHighlightStyles from '../inspectorSyntaxHighlight.css.legacy.js';
|
|
40
|
-
import inspectorSyntaxHighlightDarkStyles from '../inspectorSyntaxHighlightDark.css.legacy.js';
|
|
41
39
|
|
|
42
40
|
let themeSupportInstance: ThemeSupport;
|
|
43
41
|
|
|
44
42
|
const themeValuesCache = new Map<CSSStyleDeclaration, Map<string, string>>();
|
|
45
43
|
|
|
46
|
-
export class ThemeSupport {
|
|
47
|
-
private
|
|
48
|
-
private
|
|
49
|
-
private
|
|
50
|
-
private readonly setting: Common.Settings.Setting<string>;
|
|
51
|
-
private readonly customSheets: Set<string>;
|
|
52
|
-
private readonly computedRoot: () => symbol | CSSStyleDeclaration;
|
|
53
|
-
private injectingStyleSheet?: boolean;
|
|
44
|
+
export class ThemeSupport extends EventTarget {
|
|
45
|
+
private themeNameInternal = 'systemPreferred';
|
|
46
|
+
private customSheets: Set<string> = new Set();
|
|
47
|
+
private computedRoot = Common.Lazy.lazy(() => window.getComputedStyle(document.documentElement));
|
|
54
48
|
|
|
55
|
-
private constructor(setting: Common.Settings.Setting<string>) {
|
|
56
|
-
|
|
57
|
-
this.themeNameInternal = setting.get() === 'systemPreferred' ? systemPreferredTheme : setting.get();
|
|
58
|
-
this.themableProperties = new Set([
|
|
59
|
-
'color',
|
|
60
|
-
'box-shadow',
|
|
61
|
-
'text-shadow',
|
|
62
|
-
'outline-color',
|
|
63
|
-
'background-image',
|
|
64
|
-
'background-color',
|
|
65
|
-
'border-left-color',
|
|
66
|
-
'border-right-color',
|
|
67
|
-
'border-top-color',
|
|
68
|
-
'border-bottom-color',
|
|
69
|
-
'-webkit-border-image',
|
|
70
|
-
'fill',
|
|
71
|
-
'stroke',
|
|
72
|
-
]);
|
|
73
|
-
this.cachedThemePatches = new Map();
|
|
74
|
-
this.setting = setting;
|
|
75
|
-
this.customSheets = new Set();
|
|
76
|
-
this.computedRoot = Common.Lazy.lazy(() => window.getComputedStyle(document.documentElement));
|
|
49
|
+
private constructor(private setting: Common.Settings.Setting<string>) {
|
|
50
|
+
super();
|
|
77
51
|
}
|
|
78
52
|
|
|
79
53
|
static hasInstance(): boolean {
|
|
@@ -139,19 +113,10 @@ export class ThemeSupport {
|
|
|
139
113
|
}
|
|
140
114
|
|
|
141
115
|
injectHighlightStyleSheets(element: Element|ShadowRoot): void {
|
|
142
|
-
this.injectingStyleSheet = true;
|
|
143
116
|
this.appendStyle(element, inspectorSyntaxHighlightStyles);
|
|
144
|
-
if (this.themeNameInternal === 'dark') {
|
|
145
|
-
this.appendStyle(element, inspectorSyntaxHighlightDarkStyles);
|
|
146
|
-
}
|
|
147
|
-
this.injectingStyleSheet = false;
|
|
148
117
|
}
|
|
149
118
|
|
|
150
|
-
|
|
151
|
-
* Note: this is a duplicate of the function in ui/utils. It exists here
|
|
152
|
-
* so there is no circular dependency between ui/utils and theme_support.
|
|
153
|
-
*/
|
|
154
|
-
private appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
|
|
119
|
+
appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
|
|
155
120
|
const styleElement = document.createElement('style');
|
|
156
121
|
styleElement.textContent = cssContent;
|
|
157
122
|
node.appendChild(styleElement);
|
|
@@ -165,212 +130,37 @@ export class ThemeSupport {
|
|
|
165
130
|
}
|
|
166
131
|
}
|
|
167
132
|
|
|
168
|
-
isForcedColorsMode(): boolean {
|
|
169
|
-
return window.matchMedia('(forced-colors: active)').matches;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
133
|
addCustomStylesheet(sheetText: string): void {
|
|
173
134
|
this.customSheets.add(sheetText);
|
|
174
135
|
}
|
|
175
136
|
|
|
176
137
|
applyTheme(document: Document): void {
|
|
177
|
-
|
|
138
|
+
const isForcedColorsMode = window.matchMedia('(forced-colors: active)').matches;
|
|
139
|
+
if (isForcedColorsMode) {
|
|
178
140
|
return;
|
|
179
141
|
}
|
|
180
142
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const styleSheets = document.styleSheets;
|
|
186
|
-
const result = [];
|
|
187
|
-
for (let i = 0; i < styleSheets.length; ++i) {
|
|
188
|
-
const href = styleSheets[i].href;
|
|
189
|
-
if (!href) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
result.push(this.patchForTheme(href, (styleSheets[i] as CSSStyleSheet)));
|
|
193
|
-
}
|
|
194
|
-
result.push('/*# sourceURL=inspector.css.theme */');
|
|
195
|
-
|
|
196
|
-
const styleElement = document.createElement('style');
|
|
197
|
-
styleElement.textContent = result.join('\n');
|
|
198
|
-
document.head.appendChild(styleElement);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
themeStyleSheet(id: string, text: string): string {
|
|
202
|
-
if (!this.hasTheme() || this.injectingStyleSheet || this.isForcedColorsMode()) {
|
|
203
|
-
return '';
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
let patch = this.cachedThemePatches.get(id);
|
|
207
|
-
if (!patch) {
|
|
208
|
-
const styleElement = document.createElement('style');
|
|
209
|
-
styleElement.textContent = text;
|
|
210
|
-
document.body.appendChild(styleElement);
|
|
211
|
-
|
|
212
|
-
const {sheet} = styleElement;
|
|
213
|
-
if (!sheet) {
|
|
214
|
-
throw new Error('No sheet in stylesheet object');
|
|
215
|
-
}
|
|
216
|
-
patch = this.patchForTheme(id, sheet);
|
|
217
|
-
document.body.removeChild(styleElement);
|
|
218
|
-
}
|
|
219
|
-
return patch;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private patchForTheme(id: string, styleSheet: CSSStyleSheet): string {
|
|
223
|
-
const cached = this.cachedThemePatches.get(id);
|
|
224
|
-
if (cached) {
|
|
225
|
-
return cached;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
try {
|
|
229
|
-
const rules = styleSheet.cssRules;
|
|
230
|
-
const result = [];
|
|
231
|
-
for (let j = 0; j < rules.length; ++j) {
|
|
232
|
-
const rule = rules[j];
|
|
233
|
-
if (rule instanceof CSSImportRule) {
|
|
234
|
-
result.push(this.patchForTheme(rule.styleSheet.href || '', rule.styleSheet));
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (!(rule instanceof CSSStyleRule)) {
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const output: string[] = [];
|
|
243
|
-
const style = rule.style;
|
|
244
|
-
const selectorText = rule.selectorText;
|
|
245
|
-
for (let i = 0; style && i < style.length; ++i) {
|
|
246
|
-
this.patchProperty(selectorText, style, style[i], output);
|
|
247
|
-
}
|
|
248
|
-
if (output.length) {
|
|
249
|
-
result.push(rule.selectorText + '{' + output.join('') + '}');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const fullText = result.join('\n');
|
|
254
|
-
this.cachedThemePatches.set(id, fullText);
|
|
255
|
-
return fullText;
|
|
256
|
-
} catch (e) {
|
|
257
|
-
this.setting.set('default');
|
|
258
|
-
return '';
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Theming API is primarily targeted at making dark theme look good.
|
|
264
|
-
* - If rule has ".-theme-preserve" in selector, it won't be affected.
|
|
265
|
-
* - One can create specializations for dark themes via body.-theme-with-dark-background selector in host context.
|
|
266
|
-
*/
|
|
267
|
-
private patchProperty(selectorText: string, style: CSSStyleDeclaration, name: string, output: string[]): void {
|
|
268
|
-
if (!this.themableProperties.has(name)) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const value = style.getPropertyValue(name);
|
|
273
|
-
if (!value || value === 'none' || value === 'inherit' || value === 'initial' || value === 'transparent') {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (name === 'background-image' && value.indexOf('gradient') === -1) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
143
|
+
const systemPreferredTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default';
|
|
144
|
+
this.themeNameInternal = this.setting.get() === 'systemPreferred' ? systemPreferredTheme : this.setting.get();
|
|
279
145
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
146
|
+
const wasDarkThemed = document.documentElement.classList.contains('-theme-with-dark-background');
|
|
147
|
+
document.documentElement.classList.toggle('-theme-with-dark-background', this.themeNameInternal === 'dark');
|
|
283
148
|
|
|
284
|
-
|
|
285
|
-
if (name.indexOf('background') === 0 || name.indexOf('border') === 0) {
|
|
286
|
-
colorUsage |= ThemeSupport.ColorUsage.Background;
|
|
287
|
-
}
|
|
288
|
-
if (name.indexOf('background') === -1) {
|
|
289
|
-
colorUsage |= ThemeSupport.ColorUsage.Foreground;
|
|
290
|
-
}
|
|
149
|
+
const isDarkThemed = document.documentElement.classList.contains('-theme-with-dark-background');
|
|
291
150
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
} else {
|
|
298
|
-
const items = value.replace(Common.Color.Regex, '\0$1\0').split('\0');
|
|
299
|
-
for (const item of items) {
|
|
300
|
-
output.push(this.patchColorText(item, (colorUsage as number)));
|
|
301
|
-
}
|
|
151
|
+
// In the event the theme changes we need to clear caches and notify subscribers.
|
|
152
|
+
if (wasDarkThemed !== isDarkThemed) {
|
|
153
|
+
themeValuesCache.clear();
|
|
154
|
+
this.customSheets.clear();
|
|
155
|
+
this.dispatchEvent(new ThemeChangeEvent());
|
|
302
156
|
}
|
|
303
|
-
if (style.getPropertyPriority(name)) {
|
|
304
|
-
output.push(' !important');
|
|
305
|
-
}
|
|
306
|
-
output.push(';');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* This legacy function has been supeseded by CSS custom properties. Wherever possible, please use
|
|
311
|
-
* the values declared in global stylesheets.
|
|
312
|
-
*
|
|
313
|
-
* @deprecated
|
|
314
|
-
*/
|
|
315
|
-
patchColorText(text: string, colorUsage: number): string {
|
|
316
|
-
const color = Common.Color.Color.parse(text);
|
|
317
|
-
if (!color) {
|
|
318
|
-
return text;
|
|
319
|
-
}
|
|
320
|
-
const outColor = this.patchColor(color, colorUsage);
|
|
321
|
-
let outText = outColor.asString(null);
|
|
322
|
-
if (!outText) {
|
|
323
|
-
outText = outColor.asString(outColor.hasAlpha() ? Common.Color.Format.RGBA : Common.Color.Format.RGB);
|
|
324
|
-
}
|
|
325
|
-
return outText || text;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* This legacy function has been supeseded by CSS custom properties. Wherever possible, please use
|
|
330
|
-
* the values declared in global stylesheets.
|
|
331
|
-
*
|
|
332
|
-
* @deprecated
|
|
333
|
-
*/
|
|
334
|
-
patchColor(color: Common.Color.Color, colorUsage: number): Common.Color.Color {
|
|
335
|
-
const hsla = color.hsla();
|
|
336
|
-
this.patchHSLA(hsla, colorUsage);
|
|
337
|
-
|
|
338
|
-
const rgba: number[] = [];
|
|
339
|
-
Common.Color.Color.hsl2rgb(hsla, rgba);
|
|
340
|
-
return new Common.Color.Color(rgba, color.format());
|
|
341
157
|
}
|
|
158
|
+
}
|
|
342
159
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const sat = hsla[1];
|
|
346
|
-
let lit: number = hsla[2];
|
|
347
|
-
const alpha = hsla[3];
|
|
160
|
+
export class ThemeChangeEvent extends Event {
|
|
161
|
+
static readonly eventName = 'themechange';
|
|
348
162
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const minCap = colorUsage & ThemeSupport.ColorUsage.Background ? 0.14 : 0;
|
|
352
|
-
const maxCap = colorUsage & ThemeSupport.ColorUsage.Foreground ? 0.9 : 1;
|
|
353
|
-
lit = 1 - lit;
|
|
354
|
-
if (lit < minCap * 2) {
|
|
355
|
-
lit = minCap + lit / 2;
|
|
356
|
-
} else if (lit > 2 * maxCap - 1) {
|
|
357
|
-
lit = maxCap - 1 / 2 + lit / 2;
|
|
358
|
-
}
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
hsla[0] = Platform.NumberUtilities.clamp(hue, 0, 1);
|
|
363
|
-
hsla[1] = Platform.NumberUtilities.clamp(sat, 0, 1);
|
|
364
|
-
hsla[2] = Platform.NumberUtilities.clamp(lit, 0, 1);
|
|
365
|
-
hsla[3] = Platform.NumberUtilities.clamp(alpha, 0, 1);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
export namespace ThemeSupport {
|
|
369
|
-
// TODO(crbug.com/1167717): Make this a const enum again
|
|
370
|
-
// eslint-disable-next-line rulesdir/const_enum
|
|
371
|
-
export enum ColorUsage {
|
|
372
|
-
Unknown = 0,
|
|
373
|
-
Foreground = 1,
|
|
374
|
-
Background = 2,
|
|
163
|
+
constructor() {
|
|
164
|
+
super(ThemeChangeEvent.eventName, {bubbles: true, composed: true});
|
|
375
165
|
}
|
|
376
166
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
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
|
|
5
|
+
import * as ThemeSupport from '../theme_support/theme_support.js';
|
|
6
|
+
|
|
6
7
|
import {focusChanged} from './focus-changed.js';
|
|
7
8
|
import {injectCoreStyles} from './inject-core-styles.js';
|
|
8
9
|
|
|
@@ -24,7 +25,7 @@ export function createShadowRootWithCoreStyles(element: Element, options: Option
|
|
|
24
25
|
injectCoreStyles(shadowRoot);
|
|
25
26
|
if (cssFile) {
|
|
26
27
|
if ('cssContent' in cssFile) {
|
|
27
|
-
appendStyle(shadowRoot, cssFile);
|
|
28
|
+
ThemeSupport.ThemeSupport.instance().appendStyle(shadowRoot, cssFile);
|
|
28
29
|
} else {
|
|
29
30
|
shadowRoot.adoptedStyleSheets = cssFile;
|
|
30
31
|
}
|
|
@@ -7,39 +7,11 @@ import textButtonStyles from '../textButton.css.legacy.js';
|
|
|
7
7
|
import * as ThemeSupport from '../theme_support/theme_support.js';
|
|
8
8
|
import themeColorsStyles from '../themeColors.css.legacy.js';
|
|
9
9
|
|
|
10
|
-
import {appendStyle} from './append-style.js';
|
|
11
|
-
|
|
12
10
|
export function injectCoreStyles(root: Element|ShadowRoot): void {
|
|
13
|
-
appendStyle(root, inspectorCommonStyles);
|
|
14
|
-
appendStyle(root, textButtonStyles);
|
|
15
|
-
appendStyle(root, themeColorsStyles);
|
|
11
|
+
ThemeSupport.ThemeSupport.instance().appendStyle(root, inspectorCommonStyles);
|
|
12
|
+
ThemeSupport.ThemeSupport.instance().appendStyle(root, textButtonStyles);
|
|
13
|
+
ThemeSupport.ThemeSupport.instance().appendStyle(root, themeColorsStyles);
|
|
16
14
|
|
|
17
15
|
ThemeSupport.ThemeSupport.instance().injectHighlightStyleSheets(root);
|
|
18
16
|
ThemeSupport.ThemeSupport.instance().injectCustomStyleSheets(root);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
let bodyComputedStylesCached: CSSStyleDeclaration|null = null;
|
|
22
|
-
export function getThemeColorValue(variableName: string): string {
|
|
23
|
-
if (!bodyComputedStylesCached) {
|
|
24
|
-
/**
|
|
25
|
-
* We are safe to cache this value as we're only using this code to look up
|
|
26
|
-
* theme variables, and they do not change during runtime. And if the user
|
|
27
|
-
* swaps from light => dark theme, or vice-versa, DevTools is entirely
|
|
28
|
-
* reloaded, removing this cache.
|
|
29
|
-
*/
|
|
30
|
-
bodyComputedStylesCached = window.getComputedStyle(document.body);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const colorValue = bodyComputedStylesCached.getPropertyValue(variableName);
|
|
34
|
-
if (!colorValue) {
|
|
35
|
-
throw new Error(`Could not find theme color for variable ${variableName}.`);
|
|
36
|
-
}
|
|
37
|
-
return colorValue;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getCurrentTheme(): 'light'|'dark' {
|
|
41
|
-
if (document.documentElement.classList.contains('-theme-with-dark-background')) {
|
|
42
|
-
return 'dark';
|
|
43
|
-
}
|
|
44
|
-
return 'light';
|
|
45
|
-
}
|
|
@@ -4,19 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable rulesdir/es_modules_import */
|
|
6
6
|
|
|
7
|
-
import {appendStyle} from './append-style.js';
|
|
8
7
|
import {createShadowRootWithCoreStyles} from './create-shadow-root-with-core-styles.js';
|
|
9
8
|
import {focusChanged} from './focus-changed.js';
|
|
10
|
-
import {
|
|
9
|
+
import {injectCoreStyles} from './inject-core-styles.js';
|
|
11
10
|
import {measuredScrollbarWidth, resetMeasuredScrollbarWidthForTest} from './measured-scrollbar-width.js';
|
|
12
11
|
import {registerCustomElement} from './register-custom-element.js';
|
|
13
12
|
|
|
14
13
|
export {
|
|
15
|
-
appendStyle,
|
|
16
14
|
createShadowRootWithCoreStyles,
|
|
17
15
|
focusChanged,
|
|
18
|
-
getCurrentTheme,
|
|
19
|
-
getThemeColorValue,
|
|
20
16
|
injectCoreStyles,
|
|
21
17
|
measuredScrollbarWidth,
|
|
22
18
|
registerCustomElement,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as LitHtml from '../../third_party/lit-html/lit-html.js';
|
|
6
6
|
import * as Static from './static.js';
|
|
7
|
-
export {Directive, TemplateResult} from '../../third_party/lit-html/lit-html.js';
|
|
7
|
+
export {Directive, type TemplateResult} from '../../third_party/lit-html/lit-html.js';
|
|
8
8
|
|
|
9
9
|
const {render, svg, Directives, nothing, noChange} = LitHtml;
|
|
10
10
|
const {html, literal, flattenTemplate} = Static;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const CleanCSS = require('clean-css');
|
|
7
|
-
const [, , isDebugString, legacyString, targetName, srcDir, targetGenDir, files] = process.argv;
|
|
7
|
+
const [, , buildTimestamp, isDebugString, legacyString, targetName, srcDir, targetGenDir, files] = process.argv;
|
|
8
8
|
|
|
9
9
|
const filenames = files.split(',');
|
|
10
10
|
const configFiles = [];
|
|
@@ -37,7 +37,7 @@ export default styles;`;
|
|
|
37
37
|
|
|
38
38
|
fs.writeFileSync(
|
|
39
39
|
path.join(targetGenDir, generatedFileName),
|
|
40
|
-
`// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved.
|
|
40
|
+
`// Copyright ${new Date(Number(buildTimestamp) * 1000).getFullYear()} The Chromium Authors. All rights reserved.
|
|
41
41
|
// Use of this source code is governed by a BSD-style license that can be
|
|
42
42
|
// found in the LICENSE file.
|
|
43
43
|
// IMPORTANT: this file is auto generated. Please do not edit this file.
|
|
@@ -2,8 +2,10 @@
|
|
|
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("//build/timestamp.gni")
|
|
5
6
|
import("./node.gni")
|
|
6
7
|
import("./vars.gni")
|
|
8
|
+
|
|
7
9
|
template("generate_css") {
|
|
8
10
|
node_action(target_name) {
|
|
9
11
|
forward_variables_from(invoker, [ "sources" ])
|
|
@@ -17,6 +19,7 @@ template("generate_css") {
|
|
|
17
19
|
[ devtools_location_prepend + "node_modules/clean-css/package.json" ]
|
|
18
20
|
|
|
19
21
|
args = [
|
|
22
|
+
build_timestamp,
|
|
20
23
|
"$is_debug",
|
|
21
24
|
"${invoker.legacy}",
|
|
22
25
|
target_name,
|
|
@@ -150,8 +150,8 @@ function createServerIndexFile(componentNames) {
|
|
|
150
150
|
<meta charset="UTF-8" />
|
|
151
151
|
<meta name="viewport" content="width=device-width" />
|
|
152
152
|
<title>DevTools components</title>
|
|
153
|
-
<link rel="stylesheet" href="
|
|
154
|
-
<link rel="stylesheet" href="
|
|
153
|
+
<link rel="stylesheet" href="${sharedResourcesBase}front_end/ui/legacy/themeColors.css" />
|
|
154
|
+
<link rel="stylesheet" href="${sharedResourcesBase}front_end/ui/components/docs/component_docs_styles.css" />
|
|
155
155
|
</head>
|
|
156
156
|
<body id="index-page">
|
|
157
157
|
<h1>DevTools components</h1>
|