Skip to content

Commit ea08c69

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[unified-css] Migrate several front_end/panels/ source files.
Bug: 391381439 Change-Id: I9359f654fbb8fe3b2d136fbc68876ad507107fe7 Fixed: 404268539, 404268020 Fixed: 404268162, 404267926, 404267831 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6449568 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 7c05584 commit ea08c69

File tree

5 files changed

+23
-48
lines changed

5 files changed

+23
-48
lines changed

front_end/panels/autofill/AutofillView.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
/* eslint-disable rulesdir/no-lit-render-outside-of-view */
4+
/* eslint-disable rulesdir/no-lit-render-outside-of-view, rulesdir/inject-checkbox-styles */
55

66
import '../../ui/components/adorners/adorners.js';
77
import '../../ui/legacy/components/data_grid/data_grid.js';
@@ -17,19 +17,11 @@ import * as Input from '../../ui/components/input/input.js';
1717
import * as LegacyWrapper from '../../ui/components/legacy_wrapper/legacy_wrapper.js';
1818
// inspectorCommonStyles is imported for the empty state styling that is used for the start view
1919
// eslint-disable-next-line rulesdir/es-modules-import
20-
import inspectorCommonStylesRaw from '../../ui/legacy/inspectorCommon.css.js';
20+
import inspectorCommonStyles from '../../ui/legacy/inspectorCommon.css.js';
2121
import * as Lit from '../../ui/lit/lit.js';
2222
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
2323

24-
import autofillViewStylesRaw from './autofillView.css.js';
25-
26-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
27-
const autofillViewStyles = new CSSStyleSheet();
28-
autofillViewStyles.replaceSync(autofillViewStylesRaw.cssText);
29-
30-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
31-
const inspectorCommonStyles = new CSSStyleSheet();
32-
inspectorCommonStyles.replaceSync(inspectorCommonStylesRaw.cssText);
24+
import autofillViewStyles from './autofillView.css.js';
3325

3426
const {html, render, Directives: {styleMap}} = Lit;
3527
const {FillingStrategy} = Protocol.Autofill;
@@ -135,7 +127,6 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
135127
}
136128

137129
connectedCallback(): void {
138-
this.#shadow.adoptedStyleSheets = [Input.checkboxStyles, autofillViewStyles, inspectorCommonStyles];
139130
const autofillManager = AutofillManager.AutofillManager.AutofillManager.instance();
140131
const formFilledEvent = autofillManager.getLastFilledAddressForm();
141132
if (formFilledEvent) {
@@ -183,6 +174,9 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
183174
// Disabled until https://crbug.com/1079231 is fixed.
184175
// clang-format off
185176
render(html`
177+
<style>${Input.checkboxStylesRaw}</style>
178+
<style>${autofillViewStyles.cssText}</style>
179+
<style>${inspectorCommonStyles.cssText}</style>
186180
<main>
187181
<div class="top-left-corner">
188182
<label class="checkbox-label" title=${i18nString(UIStrings.showTestAddressesInAutofillMenu)}>
@@ -221,6 +215,9 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
221215
// Disabled until https://crbug.com/1079231 is fixed.
222216
// clang-format off
223217
render(html`
218+
<style>${Input.checkboxStylesRaw}</style>
219+
<style>${autofillViewStyles.cssText}</style>
220+
<style>${inspectorCommonStyles.cssText}</style>
224221
<main>
225222
<div class="content-container" jslog=${VisualLogging.pane('autofill')}>
226223
<div class="right-to-left" role="region" aria-label=${i18nString(UIStrings.addressPreview)}>

front_end/panels/css_overview/components/CSSOverviewStartView.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import type * as Platform from '../../../core/platform/platform.js';
1111
import * as Buttons from '../../../ui/components/buttons/buttons.js';
1212
import {html, render} from '../../../ui/lit/lit.js';
1313

14-
import cssOverviewStartViewStylesRaw from './cssOverviewStartView.css.js';
15-
16-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
17-
const cssOverviewStartViewStyles = new CSSStyleSheet();
18-
cssOverviewStartViewStyles.replaceSync(cssOverviewStartViewStylesRaw.cssText);
14+
import cssOverviewStartViewStyles from './cssOverviewStartView.css.js';
1915

2016
const UIStrings = {
2117
/**
@@ -61,7 +57,6 @@ export class CSSOverviewStartView extends HTMLElement {
6157
readonly #shadow = this.attachShadow({mode: 'open'});
6258

6359
connectedCallback(): void {
64-
this.#shadow.adoptedStyleSheets = [cssOverviewStartViewStyles];
6560
this.#render();
6661
}
6762

@@ -81,6 +76,7 @@ export class CSSOverviewStartView extends HTMLElement {
8176
// Disabled until https://crbug.com/1079231 is fixed.
8277
// clang-format off
8378
render(html`
79+
<style>${cssOverviewStartViewStyles.cssText}</style>
8480
<div class="css-overview-start-view">
8581
<devtools-panel-introduction-steps>
8682
<span slot="title">${i18nString(UIStrings.identifyCSSImprovements)}</span>

front_end/panels/explain/components/ConsoleInsight.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,8 @@ import * as Lit from '../../../ui/lit/lit.js';
2121
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
2222
import {type PromptBuilder, type Source, SourceType} from '../PromptBuilder.js';
2323

24-
import stylesRaw from './consoleInsight.css.js';
25-
import listStylesRaw from './consoleInsightSourcesList.css.js';
26-
27-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
28-
const styles = new CSSStyleSheet();
29-
styles.replaceSync(stylesRaw.cssText);
30-
31-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
32-
const listStyles = new CSSStyleSheet();
33-
listStyles.replaceSync(listStylesRaw.cssText);
24+
import styles from './consoleInsight.css.js';
25+
import listStyles from './consoleInsightSourcesList.css.js';
3426

3527
// Note: privacy and legal notices are not localized so far.
3628
const UIStrings = {
@@ -383,7 +375,6 @@ export class ConsoleInsight extends HTMLElement {
383375
}
384376

385377
connectedCallback(): void {
386-
this.#shadow.adoptedStyleSheets = [styles, Input.checkboxStyles];
387378
this.classList.add('opening');
388379
this.#consoleInsightsEnabledSetting?.addChangeListener(this.#onConsoleInsightsSettingChanged, this);
389380
const blockedByAge = Root.Runtime.hostConfig.aidaAvailability?.blockedByAge === true;
@@ -1131,6 +1122,8 @@ export class ConsoleInsight extends HTMLElement {
11311122
#render(): void {
11321123
// clang-format off
11331124
render(html`
1125+
<style>${styles.cssText}</style>
1126+
<style>${Input.checkboxStylesRaw.cssText}</style>
11341127
<div class="wrapper" jslog=${VisualLogging.pane('console-insights').track({resize: true})}>
11351128
<div class="animation-wrapper">
11361129
${this.#renderHeader()}
@@ -1156,12 +1149,13 @@ class ConsoleInsightSourcesList extends HTMLElement {
11561149

11571150
constructor() {
11581151
super();
1159-
this.#shadow.adoptedStyleSheets = [listStyles, Input.checkboxStyles];
11601152
}
11611153

11621154
#render(): void {
11631155
// clang-format off
11641156
render(html`
1157+
<style>${listStyles.cssText}</style>
1158+
<style>${Input.checkboxStylesRaw.cssText}</style>
11651159
<ul>
11661160
${Directives.repeat(this.#sources, item => item.value, item => {
11671161
return html`<li><x-link class="link" title="${localizeType(item.type)} ${i18nString(UIStrings.opensInNewTab)}" href="data:text/plain,${encodeURIComponent(item.value)}" jslog=${VisualLogging.link('source-' + item.type).track({click: true})}>

front_end/panels/sources/components/BreakpointsView.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ import * as UI from '../../../ui/legacy/legacy.js';
2222
import * as Lit from '../../../ui/lit/lit.js';
2323
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
2424

25-
import breakpointsViewStylesRaw from './breakpointsView.css.js';
25+
import breakpointsViewStyles from './breakpointsView.css.js';
2626
import {findNextNodeForKeyboardNavigation, getDifferentiatingPathMap, type TitleInfo} from './BreakpointsViewUtils.js';
2727

28-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
29-
const breakpointsViewStyles = new CSSStyleSheet();
30-
breakpointsViewStyles.replaceSync(breakpointsViewStylesRaw.cssText);
31-
3228
const {html, Directives: {ifDefined, repeat, classMap, live}} = Lit;
3329

3430
const UIStrings = {
@@ -566,10 +562,6 @@ export class BreakpointsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
566562
void this.render();
567563
}
568564

569-
connectedCallback(): void {
570-
this.#shadow.adoptedStyleSheets = [Input.checkboxStyles, breakpointsViewStyles];
571-
}
572-
573565
override async render(): Promise<void> {
574566
await RenderCoordinator.write('BreakpointsView render', () => {
575567
const clickHandler = async(event: Event): Promise<void> => {
@@ -583,6 +575,8 @@ export class BreakpointsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
583575
const pauseOnCaughtExceptionIsDisabled = !this.#independentPauseToggles && !this.#pauseOnUncaughtExceptions;
584576
// clang-format off
585577
const out = html`
578+
<style>${Input.checkboxStylesRaw}</style>
579+
<style>${breakpointsViewStyles.cssText}</style>
586580
<div class='pause-on-uncaught-exceptions'
587581
tabindex='0'
588582
@click=${clickHandler}

front_end/panels/sources/components/HeadersView.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ import * as UI from '../../../ui/legacy/legacy.js';
1515
import * as Lit from '../../../ui/lit/lit.js';
1616
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1717

18-
import HeadersViewStylesRaw from './HeadersView.css.js';
19-
20-
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
21-
const HeadersViewStyles = new CSSStyleSheet();
22-
HeadersViewStyles.replaceSync(HeadersViewStylesRaw.cssText);
18+
import headersViewStyles from './HeadersView.css.js';
2319

2420
const {html} = Lit;
2521

@@ -150,10 +146,6 @@ export class HeadersViewComponent extends HTMLElement {
150146
this.addEventListener('contextmenu', this.#onContextMenu.bind(this));
151147
}
152148

153-
connectedCallback(): void {
154-
this.#shadow.adoptedStyleSheets = [HeadersViewStyles];
155-
}
156-
157149
set data(data: HeadersViewComponentData) {
158150
this.#headerOverrides = data.headerOverrides;
159151
this.#uiSourceCode = data.uiSourceCode;
@@ -350,6 +342,7 @@ export class HeadersViewComponent extends HTMLElement {
350342
const fileName = this.#uiSourceCode?.name() || '.headers';
351343
// clang-format off
352344
Lit.render(html`
345+
<style>${headersViewStyles.cssText}</style>
353346
<div class="center-wrapper">
354347
<div class="centered">
355348
<div class="error-header">${i18nString(UIStrings.errorWhenParsing, {PH1: fileName})}</div>
@@ -363,6 +356,7 @@ export class HeadersViewComponent extends HTMLElement {
363356

364357
// clang-format off
365358
Lit.render(html`
359+
<style>${headersViewStyles.cssText}</style>
366360
${this.#headerOverrides.map((headerOverride, blockIndex) =>
367361
html`
368362
${this.#renderApplyToRow(headerOverride.applyTo, blockIndex)}

0 commit comments

Comments
 (0)