Skip to content

Commit 2b5d031

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[UIEngineering] Enable no-unscoped-styles-in-views eslint rule
The changes are: * Enabled the eslint rule and used `UI.Widget.widgetScoped` for all the views. * Updated all the view styles that styled the widget container either via `.widget` class or `:host` to use `:scope` (as `.widget` and `:host` do not apply when they are inside the `@scope`d rule with the `.widget` parent). * Updated the `widgetScoped` to have an inclusive limit so that we can still style `<devtools-widget>` elements from parents (but not the children of `<devtools-widget>`). Bug: 431945418 Change-Id: If5259ca59779885d7038d8e22ace5891335d38b8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6765265 Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Ergün Erdoğmuş <[email protected]> Auto-Submit: Ergün Erdoğmuş <[email protected]>
1 parent 31fb5bf commit 2b5d031

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+72
-66
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ export default defineConfig([
664664
],
665665
'rulesdir/enforce-ui-strings-as-const': 'error',
666666
'rulesdir/no-new-lit-element-components': 'error',
667+
'rulesdir/no-unscoped-styles-in-views': 'error',
667668
},
668669
},
669670
{

front_end/models/persistence/EditFileSystemView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export type View = (input: EditFileSystemViewInput, output: object, target: HTML
9797
export const DEFAULT_VIEW: View = (input, _output, target) => {
9898
// clang-format off
9999
render(html`
100-
<style>${editFileSystemViewStyles}</style>
100+
<style>${UI.Widget.widgetScoped(editFileSystemViewStyles)}</style>
101101
<div class="excluded-folder-header">
102102
<span>${i18nString(UIStrings.url)}</span>
103103
<span class="excluded-folder-url">${input.fileSystemPath}</span>

front_end/models/persistence/WorkspaceSettingsTab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export type View = (input: WorkspaceSettingsTabInput, output: object, target: HT
5656
export const DEFAULT_VIEW: View = (input, _output, target) => {
5757
// clang-format off
5858
render(html`
59-
<style>${workspaceSettingsTabStyles}</style>
59+
<style>${UI.Widget.widgetScoped(workspaceSettingsTabStyles)}</style>
6060
<div class="settings-card-container-wrapper" jslog=${VisualLogging.pane('workspace')}>
6161
<div class="settings-card-container">
6262
<devtools-card heading=${i18nString(UIStrings.workspace)}>

front_end/panels/ai_assistance/SelectWorkspaceDialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const SELECT_WORKSPACE_DIALOG_DEFAULT_VIEW = (input: ViewInput, _output:
7474
const hasFolders = input.folders.length > 0;
7575
render(
7676
html`
77-
<style>${selectWorkspaceDialogStyles}</style>
77+
<style>${UI.Widget.widgetScoped(selectWorkspaceDialogStyles)}</style>
7878
<h2 class="dialog-header">${lockedString(UIStringsNotTranslate.selectFolder)}</h2>
7979
<div class="main-content">
8080
<div class="select-project-root">${lockedString(UIStringsNotTranslate.selectProjectRoot)}</div>

front_end/panels/ai_assistance/components/ExploreWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const DEFAULT_VIEW = (
6767
render(
6868
html`
6969
<style>
70-
${exploreWidgetStyles}
70+
${UI.Widget.widgetScoped(exploreWidgetStyles)}
7171
</style>
7272
<div class="ai-assistance-explore-container">
7373
<div class="header">

front_end/panels/ai_assistance/components/UserActionRow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export interface UserActionRowWidgetParams {
115115
export const DEFAULT_VIEW = (input: UserActionRowViewInput, output: ViewOutput, target: HTMLElement): void => {
116116
// clang-format off
117117
Lit.render(html`
118-
<style>${Input.textInputStyles}</style>
119-
<style>${userActionRowStyles}</style>
118+
<style>${UI.Widget.widgetScoped(Input.textInputStyles)}</style>
119+
<style>${UI.Widget.widgetScoped(userActionRowStyles)}</style>
120120
<div class="ai-assistance-feedback-row">
121121
<div class="rate-buttons">
122122
${input.showRateButtons ? html`

front_end/panels/ai_assistance/selectWorkspaceDialog.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* found in the LICENSE file.
55
*/
66

7-
.widget.dialog-container {
7+
:scope {
88
width: 100%;
99
box-shadow: none;
10-
}
10+
}
1111

1212
.dialog-header {
1313
margin: var(--sys-size-6) var(--sys-size-8) var(--sys-size-5);

front_end/panels/application/components/SharedStorageAccessGrid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export type View = (input: ViewInput, output: object, target: HTMLElement) => vo
9090
export const DEFAULT_VIEW: View = (input, _output, target) => {
9191
// clang-format off
9292
render(html`
93-
<style>${sharedStorageAccessGridStyles}</style>
93+
<style>${UI.Widget.widgetScoped(sharedStorageAccessGridStyles)}</style>
9494
${input.events.length === 0
9595
? html`
9696
<div class="empty-state" jslog=${VisualLogging.section().context('empty-view')}>

front_end/panels/application/components/sharedStorageAccessGrid.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use of this source code is governed by a BSD-style license that can be
44
* found in the LICENSE file.
55
*/
6-
.widget {
6+
:scope {
77
padding: 20px;
88
height: 100%;
99
display: flex;

front_end/panels/autofill/AutofillView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: ViewOutput, target: HTMLE
221221
// Disabled until https://crbug.com/1079231 is fixed.
222222
// clang-format off
223223
render(html`
224-
<style>${autofillViewStyles}</style>
225-
<style>${UI.inspectorCommonStyles}</style>
224+
<style>${UI.Widget.widgetScoped(autofillViewStyles)}</style>
225+
<style>${UI.Widget.widgetScoped(UI.inspectorCommonStyles)}</style>
226226
<main>
227227
<div class="top-left-corner">
228228
<devtools-checkbox
@@ -257,8 +257,8 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: ViewOutput, target: HTMLE
257257
// Disabled until https://crbug.com/1079231 is fixed.
258258
// clang-format off
259259
render(html`
260-
<style>${autofillViewStyles}</style>
261-
<style>${UI.inspectorCommonStyles}</style>
260+
<style>${UI.Widget.widgetScoped(autofillViewStyles)}</style>
261+
<style>${UI.Widget.widgetScoped(UI.inspectorCommonStyles)}</style>
262262
<main>
263263
<div class="content-container" jslog=${VisualLogging.pane('autofill')}>
264264
<div class="right-to-left" role="region" aria-label=${i18nString(UIStrings.addressPreview)}>

0 commit comments

Comments
 (0)