Skip to content

Commit bf0e2b4

Browse files
bmeurerDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
Move text-button styles to the button component.
This is the next step in unifying the way we inject CSS. While we should probably have a proper `<devtools-text-button>` component instead of the `.text-button` styles, I'm leaving that as a refactoring for later, and for now, move the styles out of the legacy UI bundle and into the button component. Bug: 391381439 Change-Id: Id4708319dbfe2d609da0947ef9e3f7692723393b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6189456 Reviewed-by: Alex Rudenko <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 32b08c1 commit bf0e2b4

File tree

12 files changed

+36
-27
lines changed

12 files changed

+36
-27
lines changed

config/gni/devtools_grd_files.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,7 @@ grd_files_debug_sources = [
21982198
"front_end/ui/components/adorners/adorner.css.js",
21992199
"front_end/ui/components/buttons/Button.js",
22002200
"front_end/ui/components/buttons/button.css.js",
2201+
"front_end/ui/components/buttons/textButton.css.js",
22012202
"front_end/ui/components/cards/Card.js",
22022203
"front_end/ui/components/cards/card.css.js",
22032204
"front_end/ui/components/chrome_link/ChromeLink.js",
@@ -2499,7 +2500,6 @@ grd_files_debug_sources = [
24992500
"front_end/ui/legacy/suggestBox.css.legacy.js",
25002501
"front_end/ui/legacy/tabbedPane.css.legacy.js",
25012502
"front_end/ui/legacy/targetCrashedScreen.css.legacy.js",
2502-
"front_end/ui/legacy/textButton.css.legacy.js",
25032503
"front_end/ui/legacy/textPrompt.css.legacy.js",
25042504
"front_end/ui/legacy/theme_support/ThemeSupport.js",
25052505
"front_end/ui/legacy/toolbar.css.js",

front_end/panels/elements/components/ComputedStyleTrace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class ComputedStyleTrace extends HTMLElement {
2525
#ruleOriginNode?: Node;
2626

2727
connectedCallback(): void {
28-
this.#shadow.adoptedStyleSheets = [computedStyleTraceStyles];
2928
UI.UIUtils.injectCoreStyles(this.#shadow);
29+
this.#shadow.adoptedStyleSheets.push(computedStyleTraceStyles);
3030
}
3131

3232
set data(data: ComputedStyleTraceData) {

front_end/panels/timeline/components/LayoutShiftDetails.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import * as SDK from '../../../core/sdk/sdk.js';
88
import type * as Protocol from '../../../generated/protocol.js';
99
import * as Helpers from '../../../models/trace/helpers/helpers.js';
1010
import * as Trace from '../../../models/trace/trace.js';
11+
import * as Buttons from '../../../ui/components/buttons/buttons.js';
1112
import * as LegacyComponents from '../../../ui/legacy/components/utils/utils.js';
12-
import * as UI from '../../../ui/legacy/legacy.js';
1313
import * as LitHtml from '../../../ui/lit-html/lit-html.js';
1414
import * as Utils from '../utils/utils.js';
1515

@@ -89,9 +89,11 @@ export class LayoutShiftDetails extends HTMLElement {
8989
#isFreshRecording: Boolean = false;
9090

9191
connectedCallback(): void {
92-
this.#shadow.adoptedStyleSheets = [layoutShiftDetailsStyles];
93-
// Styles for linkifier button.
94-
UI.UIUtils.injectTextButtonStyles(this.#shadow);
92+
this.#shadow.adoptedStyleSheets = [
93+
layoutShiftDetailsStyles,
94+
// Styles for linkifier button.
95+
Buttons.textButtonStyles,
96+
];
9597
this.#render();
9698
}
9799

front_end/ui/components/buttons/BUILD.gn

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ import("../../../../scripts/build/ninja/generate_css.gni")
88
import("../../../../scripts/build/typescript/typescript.gni")
99
import("../visibility.gni")
1010

11-
generate_css("legacy_css_files") {
12-
sources = [ "button.css" ]
11+
generate_css("css_files") {
12+
sources = [
13+
"button.css",
14+
"textButton.css",
15+
]
16+
}
17+
18+
copy_to_gen("copy_stylesheets_for_server") {
19+
sources = [ "textButton.css" ]
1320
}
1421

1522
devtools_module("button") {
@@ -27,7 +34,7 @@ devtools_entrypoint("bundle") {
2734

2835
deps = [
2936
":button",
30-
":legacy_css_files",
37+
":css_files",
3138
]
3239

3340
visibility = [ "../../../entrypoints/main/*" ]

front_end/ui/components/buttons/buttons.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// found in the LICENSE file.
44

55
import * as Button from './Button.js';
6+
import textButtonStyles from './textButton.css.js';
67

78
export {
89
Button,
10+
textButtonStyles,
911
};

front_end/ui/legacy/BUILD.gn

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ generate_css("legacy_css_files") {
4545
"suggestBox.css",
4646
"tabbedPane.css",
4747
"targetCrashedScreen.css",
48-
"textButton.css",
4948
"textPrompt.css",
5049
"treeoutline.css",
5150
"viewContainers.css",
@@ -58,7 +57,6 @@ copy_to_gen("copy_stylesheets_for_server") {
5857
sources = [
5958
"inspectorCommon.css",
6059
"inspectorSyntaxHighlight.css",
61-
"textButton.css",
6260
]
6361
}
6462

front_end/ui/legacy/UIUtils.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import inlineButtonStyles from './inlineButton.css.legacy.js';
5353
import inspectorCommonStyles from './inspectorCommon.css.legacy.js';
5454
import {KeyboardShortcut, Keys} from './KeyboardShortcut.js';
5555
import smallBubbleStyles from './smallBubble.css.legacy.js';
56-
import textButtonStyles from './textButton.css.legacy.js';
5756
import * as ThemeSupport from './theme_support/theme_support.js';
5857
import type {ToolbarButton} from './Toolbar.js';
5958
import {Tooltip} from './Tooltip.js';
@@ -1868,15 +1867,14 @@ function focusChanged(event: Event): void {
18681867
updateXWidgetfocusWidgetForNode(element);
18691868
}
18701869

1871-
export function injectCoreStyles(root: Element|ShadowRoot): void {
1872-
ThemeSupport.ThemeSupport.instance().appendStyle(root, inspectorCommonStyles);
1873-
ThemeSupport.ThemeSupport.instance().appendStyle(root, textButtonStyles);
1870+
export function injectCoreStyles(elementOrShadowRoot: Element|ShadowRoot): void {
1871+
ThemeSupport.ThemeSupport.instance().appendStyle(elementOrShadowRoot, inspectorCommonStyles);
1872+
const shadowRootOrDocument = (elementOrShadowRoot instanceof ShadowRoot) ?
1873+
elementOrShadowRoot :
1874+
(elementOrShadowRoot.shadowRoot ?? elementOrShadowRoot.ownerDocument);
1875+
shadowRootOrDocument.adoptedStyleSheets.push(Buttons.textButtonStyles);
18741876

1875-
ThemeSupport.ThemeSupport.instance().injectHighlightStyleSheets(root);
1876-
}
1877-
1878-
export function injectTextButtonStyles(root: Element|ShadowRoot): void {
1879-
ThemeSupport.ThemeSupport.instance().appendStyle(root, textButtonStyles);
1877+
ThemeSupport.ThemeSupport.instance().injectHighlightStyleSheets(elementOrShadowRoot);
18801878
}
18811879

18821880
/**
@@ -1904,7 +1902,7 @@ export function createShadowRootWithCoreStyles(
19041902
if ('cssContent' in cssFile) {
19051903
ThemeSupport.ThemeSupport.instance().appendStyle(shadowRoot, cssFile);
19061904
} else {
1907-
shadowRoot.adoptedStyleSheets = cssFile;
1905+
shadowRoot.adoptedStyleSheets.push(...cssFile);
19081906
}
19091907
}
19101908
shadowRoot.addEventListener('focus', focusChanged, true);

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

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ devtools_module("inline_editor") {
5757
"../../../../models/text_utils:bundle",
5858
"../../../../panels/css_overview:bundle",
5959
"../../../../third_party/codemirror.next:bundle",
60+
"../../../../ui/components/buttons:bundle",
6061
"../../../../ui/components/helpers:bundle",
6162
"../../../../ui/legacy:bundle",
6263
"../../../../ui/legacy/components/utils:bundle",

front_end/ui/legacy/components/inline_editor/LinkSwatch.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
// found in the LICENSE file.
44

55
import * as i18n from '../../../../core/i18n/i18n.js';
6+
import * as Buttons from '../../../components/buttons/buttons.js';
67
import * as LitHtml from '../../../lit-html/lit-html.js';
78
import * as VisualLogging from '../../../visual_logging/visual_logging.js';
8-
import textButtonStyles from '../../textButton.css.legacy.js';
9-
import * as ThemeSupport from '../../theme_support/theme_support.js';
109

1110
import linkSwatchStyles from './linkSwatch.css.js';
1211

@@ -35,8 +34,7 @@ class BaseLinkSwatch extends HTMLElement {
3534
#linkElement: HTMLSpanElement|undefined;
3635

3736
connectedCallback(): void {
38-
this.shadow.adoptedStyleSheets = [linkSwatchStyles];
39-
ThemeSupport.ThemeSupport.instance().appendStyle(this.shadow, textButtonStyles);
37+
this.shadow.adoptedStyleSheets = [linkSwatchStyles, Buttons.textButtonStyles];
4038
}
4139

4240
set data(data: BaseLinkSwatchRenderData) {

scripts/component_server/BUILD.gn

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ import("../build/ninja/copy.gni")
77
copy_to_gen("component_server") {
88
sources = [ "server.js" ]
99

10-
deps = [ "../../front_end/ui/legacy:copy_stylesheets_for_server" ]
10+
deps = [
11+
"../../front_end/ui/components/buttons:copy_stylesheets_for_server",
12+
"../../front_end/ui/legacy:copy_stylesheets_for_server",
13+
]
1114
}

scripts/component_server/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ const styleSheetPaths = [
147147
'front_end/tokens.css',
148148
'front_end/application_color_tokens.css',
149149
'front_end/design_tokens.css',
150+
'front_end/ui/components/buttons/textButton.css',
150151
'front_end/ui/legacy/inspectorCommon.css',
151152
'front_end/ui/legacy/inspectorSyntaxHighlight.css',
152-
'front_end/ui/legacy/textButton.css',
153153
'front_end/ui/components/docs/component_docs_styles.css',
154154
];
155155

0 commit comments

Comments
 (0)