Skip to content

Commit fe54ded

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Migrate another chunk of legacy CSS files.
Bug: 391381439 Change-Id: I4de7afe8a5ebac7c86d0a00ce2e26b6b9d22a493 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6196956 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]>
1 parent b57b7ce commit fe54ded

File tree

12 files changed

+63
-72
lines changed

12 files changed

+63
-72
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ grd_files_debug_sources = [
23622362
"front_end/ui/legacy/XLink.js",
23632363
"front_end/ui/legacy/XWidget.js",
23642364
"front_end/ui/legacy/ZoomManager.js",
2365-
"front_end/ui/legacy/checkboxTextLabel.css.legacy.js",
2365+
"front_end/ui/legacy/checkboxTextLabel.css.js",
23662366
"front_end/ui/legacy/components/color_picker/ColorFormatSpec.js",
23672367
"front_end/ui/legacy/components/color_picker/ContrastDetails.js",
23682368
"front_end/ui/legacy/components/color_picker/ContrastInfo.js",
@@ -2459,8 +2459,8 @@ grd_files_debug_sources = [
24592459
"front_end/ui/legacy/components/source_frame/imageView.css.js",
24602460
"front_end/ui/legacy/components/source_frame/jsonView.css.js",
24612461
"front_end/ui/legacy/components/source_frame/resourceSourceFrame.css.js",
2462-
"front_end/ui/legacy/components/source_frame/selfXssDialog.css.legacy.js",
2463-
"front_end/ui/legacy/components/source_frame/xmlTree.css.legacy.js",
2462+
"front_end/ui/legacy/components/source_frame/selfXssDialog.css.js",
2463+
"front_end/ui/legacy/components/source_frame/xmlTree.css.js",
24642464
"front_end/ui/legacy/components/source_frame/xmlView.css.js",
24652465
"front_end/ui/legacy/components/utils/ImagePreview.js",
24662466
"front_end/ui/legacy/components/utils/JSPresentationUtils.js",
@@ -2469,36 +2469,36 @@ grd_files_debug_sources = [
24692469
"front_end/ui/legacy/components/utils/TargetDetachedDialog.js",
24702470
"front_end/ui/legacy/components/utils/imagePreview.css.js",
24712471
"front_end/ui/legacy/components/utils/jsUtils.css.js",
2472-
"front_end/ui/legacy/confirmDialog.css.legacy.js",
2472+
"front_end/ui/legacy/confirmDialog.css.js",
24732473
"front_end/ui/legacy/dialog.css.js",
2474-
"front_end/ui/legacy/dropTarget.css.legacy.js",
2474+
"front_end/ui/legacy/dropTarget.css.js",
24752475
"front_end/ui/legacy/emptyWidget.css.js",
24762476
"front_end/ui/legacy/filter.css.js",
24772477
"front_end/ui/legacy/glassPane.css.js",
2478-
"front_end/ui/legacy/infobar.css.legacy.js",
2479-
"front_end/ui/legacy/inlineButton.css.legacy.js",
2478+
"front_end/ui/legacy/infobar.css.js",
2479+
"front_end/ui/legacy/inlineButton.css.js",
24802480
"front_end/ui/legacy/inspectorCommon.css.js",
24812481
"front_end/ui/legacy/inspectorCommon.css.legacy.js",
24822482
"front_end/ui/legacy/inspectorViewTabbedPane.css.js",
24832483
"front_end/ui/legacy/listWidget.css.js",
24842484
"front_end/ui/legacy/popover.css.js",
2485-
"front_end/ui/legacy/progressIndicator.css.legacy.js",
2485+
"front_end/ui/legacy/progressIndicator.css.js",
24862486
"front_end/ui/legacy/remoteDebuggingTerminatedScreen.css.js",
24872487
"front_end/ui/legacy/reportView.css.js",
24882488
"front_end/ui/legacy/rootView.css.js",
24892489
"front_end/ui/legacy/searchableView.css.js",
2490-
"front_end/ui/legacy/smallBubble.css.legacy.js",
2490+
"front_end/ui/legacy/smallBubble.css.js",
24912491
"front_end/ui/legacy/softContextMenu.css.js",
2492-
"front_end/ui/legacy/softDropDown.css.legacy.js",
2492+
"front_end/ui/legacy/softDropDown.css.js",
24932493
"front_end/ui/legacy/softDropDownButton.css.legacy.js",
24942494
"front_end/ui/legacy/splitWidget.css.js",
2495-
"front_end/ui/legacy/suggestBox.css.legacy.js",
2495+
"front_end/ui/legacy/suggestBox.css.js",
24962496
"front_end/ui/legacy/tabbedPane.css.js",
24972497
"front_end/ui/legacy/targetCrashedScreen.css.js",
24982498
"front_end/ui/legacy/textPrompt.css.legacy.js",
24992499
"front_end/ui/legacy/theme_support/ThemeSupport.js",
25002500
"front_end/ui/legacy/toolbar.css.js",
2501-
"front_end/ui/legacy/treeoutline.css.legacy.js",
2501+
"front_end/ui/legacy/treeoutline.css.js",
25022502
"front_end/ui/legacy/viewContainers.css.js",
25032503
"front_end/ui/lit-html/i18n-template.js",
25042504
"front_end/ui/visual_logging/Debugging.js",

front_end/ui/legacy/BUILD.gn

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ import("./visibility.gni")
1010

1111
generate_css("css_files") {
1212
sources = [
13+
"checkboxTextLabel.css",
14+
"confirmDialog.css",
1315
"dialog.css",
16+
"dropTarget.css",
1417
"emptyWidget.css",
1518
"filter.css",
1619
"glassPane.css",
20+
"infobar.css",
21+
"inlineButton.css",
1722
"inspectorCommon.css",
1823
"inspectorViewTabbedPane.css",
1924
"listWidget.css",
2025
"popover.css",
26+
"progressIndicator.css",
2127
"remoteDebuggingTerminatedScreen.css",
2228
"reportView.css",
2329
"rootView.css",
2430
"searchableView.css",
31+
"smallBubble.css",
2532
"softContextMenu.css",
33+
"softDropDown.css",
2634
"splitWidget.css",
35+
"suggestBox.css",
2736
"tabbedPane.css",
2837
"targetCrashedScreen.css",
2938
"toolbar.css",
39+
"treeoutline.css",
3040
"viewContainers.css",
3141
]
3242
}
3343

3444
generate_css("legacy_css_files") {
3545
sources = [
36-
"checkboxTextLabel.css",
37-
"confirmDialog.css",
38-
"dropTarget.css",
39-
"infobar.css",
40-
"inlineButton.css",
4146
"inspectorCommon.css",
42-
"progressIndicator.css",
43-
"smallBubble.css",
44-
"softDropDown.css",
4547
"softDropDownButton.css",
46-
"suggestBox.css",
4748
"textPrompt.css",
48-
"treeoutline.css",
4949
]
5050

5151
legacy = true

front_end/ui/legacy/DropTarget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import dropTargetStyles from './dropTarget.css.legacy.js';
5+
import dropTargetStyles from './dropTarget.css.js';
66
import {createShadowRootWithCoreStyles} from './UIUtils.js';
77

88
export class DropTarget {
@@ -71,7 +71,7 @@ export class DropTarget {
7171
return;
7272
}
7373
this.dragMaskElement = this.element.createChild('div', '');
74-
const shadowRoot = createShadowRootWithCoreStyles(this.dragMaskElement, {cssFile: dropTargetStyles});
74+
const shadowRoot = createShadowRootWithCoreStyles(this.dragMaskElement, {cssFile: [dropTargetStyles]});
7575
shadowRoot.createChild('div', 'drop-target-message').textContent = this.messageText;
7676
this.dragMaskElement.addEventListener('drop', this.onDrop.bind(this), true);
7777
this.dragMaskElement.addEventListener('dragleave', this.onDragLeave.bind(this), true);

front_end/ui/legacy/Infobar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as Buttons from '../../ui/components/buttons/buttons.js';
88
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
99

1010
import * as ARIAUtils from './ARIAUtils.js';
11-
import infobarStyles from './infobar.css.legacy.js';
11+
import infobarStyles from './infobar.css.js';
1212
import {Keys} from './KeyboardShortcut.js';
1313
import {createShadowRootWithCoreStyles, createTextButton, type DevToolsCloseButton} from './UIUtils.js';
1414
import type {Widget} from './Widget.js';
@@ -59,7 +59,7 @@ export class Infobar {
5959
'jslog', `${VisualLogging.dialog(jslogContext).track({resize: true, keydown: 'Enter|Escape'})}`);
6060
}
6161
this.element.classList.add('flex-none');
62-
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: infobarStyles});
62+
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: [infobarStyles]});
6363

6464
this.contentElement = this.shadowRoot.createChild('div', 'infobar infobar-' + type);
6565

front_end/ui/legacy/ProgressIndicator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import type * as Common from '../../core/common/common.js';
3232

33-
import progressIndicatorStyles from './progressIndicator.css.legacy.js';
33+
import progressIndicatorStyles from './progressIndicator.css.js';
3434
import {createShadowRootWithCoreStyles} from './UIUtils.js';
3535

3636
export class ProgressIndicator implements Common.Progress.Progress {
@@ -47,7 +47,7 @@ export class ProgressIndicator implements Common.Progress.Progress {
4747
constructor(options = {showStopButton: true}) {
4848
this.element = document.createElement('div');
4949
this.element.classList.add('progress-indicator');
50-
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: progressIndicatorStyles});
50+
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: [progressIndicatorStyles]});
5151
this.contentElement = this.shadowRoot.createChild('div', 'progress-indicator-shadow-container');
5252

5353
this.labelElement = this.contentElement.createChild('div', 'title');

front_end/ui/legacy/SoftDropDown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Size} from './Geometry.js';
1212
import {AnchorBehavior, GlassPane, MarginBehavior, PointerEventsBehavior} from './GlassPane.js';
1313
import {ListControl, type ListDelegate, ListMode} from './ListControl.js';
1414
import {Events as ListModelEvents, type ItemsReplacedEvent, type ListModel} from './ListModel.js';
15-
import softDropDownStyles from './softDropDown.css.legacy.js';
15+
import softDropDownStyles from './softDropDown.css.js';
1616
import softDropDownButtonStyles from './softDropDownButton.css.legacy.js';
1717
import * as ThemeSupport from './theme_support/theme_support.js';
1818
import {createShadowRootWithCoreStyles} from './UIUtils.js';
@@ -70,7 +70,7 @@ export class SoftDropDown<T> implements ListDelegate<T> {
7070
this.rowHeight = 36;
7171
this.width = 315;
7272
createShadowRootWithCoreStyles(this.glassPane.contentElement, {
73-
cssFile: softDropDownStyles,
73+
cssFile: [softDropDownStyles]
7474
}).appendChild(this.list.element);
7575
ARIAUtils.markAsMenu(this.list.element);
7676
VisualLogging.setMappedParent(this.list.element, this.element);

front_end/ui/legacy/SuggestBox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {Size} from './Geometry.js';
3838
import {AnchorBehavior, GlassPane} from './GlassPane.js';
3939
import {ListControl, type ListDelegate, ListMode} from './ListControl.js';
4040
import {ListModel} from './ListModel.js';
41-
import suggestBoxStyles from './suggestBox.css.legacy.js';
41+
import suggestBoxStyles from './suggestBox.css.js';
4242
import {createShadowRootWithCoreStyles, measuredScrollbarWidth, measurePreferredSize} from './UIUtils.js';
4343

4444
const UIStrings = {
@@ -105,7 +105,7 @@ export class SuggestBox implements ListDelegate<Suggestion> {
105105
this.glassPane = new GlassPane();
106106
this.glassPane.setAnchorBehavior(AnchorBehavior.PREFER_BOTTOM);
107107
this.glassPane.setOutsideClickCallback(this.hide.bind(this));
108-
const shadowRoot = createShadowRootWithCoreStyles(this.glassPane.contentElement, {cssFile: suggestBoxStyles});
108+
const shadowRoot = createShadowRootWithCoreStyles(this.glassPane.contentElement, {cssFile: [suggestBoxStyles]});
109109
shadowRoot.appendChild(this.element);
110110
}
111111

front_end/ui/legacy/Treeoutline.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ import * as VisualLogging from '../visual_logging/visual_logging.js';
4242
import * as ARIAUtils from './ARIAUtils.js';
4343
import {type Config, InplaceEditor} from './InplaceEditor.js';
4444
import {Keys} from './KeyboardShortcut.js';
45-
import * as ThemeSupport from './theme_support/theme_support.js';
4645
import {Tooltip} from './Tooltip.js';
47-
import treeoutlineStyles from './treeoutline.css.legacy.js';
46+
import treeoutlineStyles from './treeoutline.css.js';
4847
import {
4948
createShadowRootWithCoreStyles,
5049
deepElementFromPoint,
@@ -406,7 +405,7 @@ export class TreeOutlineInShadow extends TreeOutline {
406405
super();
407406
this.contentElement.classList.add('tree-outline');
408407
this.element = document.createElement('div');
409-
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: treeoutlineStyles});
408+
this.shadowRoot = createShadowRootWithCoreStyles(this.element, {cssFile: [treeoutlineStyles]});
410409
this.disclosureElement = this.shadowRoot.createChild('div', 'tree-outline-disclosure');
411410
this.disclosureElement.appendChild(this.contentElement);
412411
this.renderSelection = true;
@@ -416,10 +415,6 @@ export class TreeOutlineInShadow extends TreeOutline {
416415
}
417416
}
418417

419-
registerRequiredCSS(cssFile: {cssContent: string}): void {
420-
ThemeSupport.ThemeSupport.instance().appendStyle(this.shadowRoot, cssFile);
421-
}
422-
423418
registerCSSFiles(cssFiles: CSSStyleSheet[]): void {
424419
this.shadowRoot.adoptedStyleSheets = this.shadowRoot.adoptedStyleSheets.concat(cssFiles);
425420
}

front_end/ui/legacy/UIUtils.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ import * as IconButton from '../components/icon_button/icon_button.js';
4444
import * as VisualLogging from '../visual_logging/visual_logging.js';
4545

4646
import * as ARIAUtils from './ARIAUtils.js';
47-
import checkboxTextLabelStyles from './checkboxTextLabel.css.legacy.js';
48-
import confirmDialogStyles from './confirmDialog.css.legacy.js';
47+
import checkboxTextLabelStyles from './checkboxTextLabel.css.js';
48+
import confirmDialogStyles from './confirmDialog.css.js';
4949
import {Dialog} from './Dialog.js';
5050
import {Size} from './Geometry.js';
5151
import {GlassPane, PointerEventsBehavior, SizeBehavior} from './GlassPane.js';
52-
import inlineButtonStyles from './inlineButton.css.legacy.js';
52+
import inlineButtonStyles from './inlineButton.css.js';
5353
import inspectorCommonStyles from './inspectorCommon.css.legacy.js';
5454
import {KeyboardShortcut, Keys} from './KeyboardShortcut.js';
55-
import smallBubbleStyles from './smallBubble.css.legacy.js';
55+
import smallBubbleStyles from './smallBubble.css.js';
5656
import * as ThemeSupport from './theme_support/theme_support.js';
5757
import type {ToolbarButton} from './Toolbar.js';
5858
import {Tooltip} from './Tooltip.js';
@@ -1300,15 +1300,15 @@ export function setTitle(element: HTMLElement, title: string): void {
13001300
}
13011301

13021302
export class CheckboxLabel extends HTMLElement {
1303-
private readonly shadowRootInternal!: DocumentFragment;
1303+
private readonly shadowRootInternal: ShadowRoot;
13041304
checkboxElement!: HTMLInputElement;
13051305
textElement!: HTMLElement;
13061306

13071307
constructor() {
13081308
super();
13091309
CheckboxLabel.lastId = CheckboxLabel.lastId + 1;
13101310
const id = 'ui-checkbox-label' + CheckboxLabel.lastId;
1311-
this.shadowRootInternal = createShadowRootWithCoreStyles(this, {cssFile: checkboxTextLabelStyles});
1311+
this.shadowRootInternal = createShadowRootWithCoreStyles(this);
13121312
this.checkboxElement = this.shadowRootInternal.createChild('input');
13131313
this.checkboxElement.type = 'checkbox';
13141314
this.checkboxElement.setAttribute('id', id);
@@ -1317,6 +1317,10 @@ export class CheckboxLabel extends HTMLElement {
13171317
this.shadowRootInternal.createChild('slot');
13181318
}
13191319

1320+
connectedCallback(): void {
1321+
this.shadowRootInternal.adoptedStyleSheets.push(checkboxTextLabelStyles);
1322+
}
1323+
13201324
static create(
13211325
title?: Platform.UIString.LocalizedString, checked?: boolean, subtitle?: Platform.UIString.LocalizedString,
13221326
jslogContext?: string, small?: boolean): CheckboxLabel {
@@ -1378,16 +1382,21 @@ export class DevToolsIconLabel extends HTMLElement {
13781382
customElements.define('dt-icon-label', DevToolsIconLabel);
13791383

13801384
export class DevToolsSmallBubble extends HTMLElement {
1385+
#shadowRoot: ShadowRoot;
13811386
private textElement: Element;
13821387

13831388
constructor() {
13841389
super();
1385-
const root = createShadowRootWithCoreStyles(this, {cssFile: smallBubbleStyles});
1386-
this.textElement = root.createChild('div');
1390+
this.#shadowRoot = createShadowRootWithCoreStyles(this);
1391+
this.textElement = this.#shadowRoot.createChild('div');
13871392
this.textElement.className = 'info';
13881393
this.textElement.createChild('slot');
13891394
}
13901395

1396+
connectedCallback(): void {
1397+
this.#shadowRoot.adoptedStyleSheets.push(smallBubbleStyles);
1398+
}
1399+
13911400
set type(type: string) {
13921401
this.textElement.className = type;
13931402
}
@@ -1622,7 +1631,7 @@ export class MessageDialog {
16221631
const dialog = new Dialog(jslogContext);
16231632
dialog.setSizeBehavior(SizeBehavior.MEASURE_CONTENT);
16241633
dialog.setDimmed(true);
1625-
const shadowRoot = createShadowRootWithCoreStyles(dialog.contentElement, {cssFile: confirmDialogStyles});
1634+
const shadowRoot = createShadowRootWithCoreStyles(dialog.contentElement, {cssFile: [confirmDialogStyles]});
16261635
const content = shadowRoot.createChild('div', 'widget');
16271636
await new Promise(resolve => {
16281637
const okButton = createTextButton(
@@ -1646,7 +1655,7 @@ export class ConfirmDialog {
16461655
dialog.setSizeBehavior(SizeBehavior.MEASURE_CONTENT);
16471656
dialog.setDimmed(true);
16481657
ARIAUtils.setLabel(dialog.contentElement, message);
1649-
const shadowRoot = createShadowRootWithCoreStyles(dialog.contentElement, {cssFile: confirmDialogStyles});
1658+
const shadowRoot = createShadowRootWithCoreStyles(dialog.contentElement, {cssFile: [confirmDialogStyles]});
16501659
const content = shadowRoot.createChild('div', 'widget');
16511660
content.createChild('div', 'message').createChild('span').textContent = message;
16521661
const buttonsBar = content.createChild('div', 'button');
@@ -1671,7 +1680,7 @@ export class ConfirmDialog {
16711680

16721681
export function createInlineButton(toolbarButton: ToolbarButton): Element {
16731682
const element = document.createElement('span');
1674-
const shadowRoot = createShadowRootWithCoreStyles(element, {cssFile: inlineButtonStyles});
1683+
const shadowRoot = createShadowRootWithCoreStyles(element, {cssFile: [inlineButtonStyles]});
16751684
element.classList.add('inline-button');
16761685
const toolbar = shadowRoot.createChild('devtools-toolbar');
16771686
toolbar.appendToolbarItem(toolbarButton);
@@ -1885,24 +1894,18 @@ export function injectCoreStyles(elementOrShadowRoot: Element|ShadowRoot): void
18851894
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow
18861895
*/
18871896
export function createShadowRootWithCoreStyles(
1888-
element: Element, options: {cssFile?: CSSStyleSheet[]|{cssContent: string}, delegatesFocus?: boolean} = {
1897+
element: Element, options: {cssFile?: CSSStyleSheet[], delegatesFocus?: boolean} = {
18891898
delegatesFocus: undefined,
18901899
cssFile: undefined,
18911900
}): ShadowRoot {
18921901
const {
1893-
cssFile,
1902+
cssFile = [],
18941903
delegatesFocus,
18951904
} = options;
18961905

18971906
const shadowRoot = element.attachShadow({mode: 'open', delegatesFocus});
18981907
injectCoreStyles(shadowRoot);
1899-
if (cssFile) {
1900-
if ('cssContent' in cssFile) {
1901-
ThemeSupport.ThemeSupport.instance().appendStyle(shadowRoot, cssFile);
1902-
} else {
1903-
shadowRoot.adoptedStyleSheets.push(...cssFile);
1904-
}
1905-
}
1908+
shadowRoot.adoptedStyleSheets.push(...cssFile);
19061909
shadowRoot.addEventListener('focus', focusChanged, true);
19071910
return shadowRoot;
19081911
}

front_end/ui/legacy/components/source_frame/BUILD.gn

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@ generate_css("css_files") {
1414
"imageView.css",
1515
"jsonView.css",
1616
"resourceSourceFrame.css",
17-
"xmlView.css",
18-
]
19-
}
20-
21-
generate_css("legacy_css_files") {
22-
sources = [
2317
"selfXssDialog.css",
2418
"xmlTree.css",
19+
"xmlView.css",
2520
]
26-
27-
legacy = true
2821
}
2922

3023
devtools_module("source_frame") {
@@ -62,7 +55,6 @@ devtools_entrypoint("bundle") {
6255

6356
deps = [
6457
":css_files",
65-
":legacy_css_files",
6658
":source_frame",
6759
]
6860

0 commit comments

Comments
 (0)