@@ -44,15 +44,15 @@ import * as IconButton from '../components/icon_button/icon_button.js';
4444import * as VisualLogging from '../visual_logging/visual_logging.js' ;
4545
4646import * 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' ;
4949import { Dialog } from './Dialog.js' ;
5050import { Size } from './Geometry.js' ;
5151import { GlassPane , PointerEventsBehavior , SizeBehavior } from './GlassPane.js' ;
52- import inlineButtonStyles from './inlineButton.css.legacy. js' ;
52+ import inlineButtonStyles from './inlineButton.css.js' ;
5353import inspectorCommonStyles from './inspectorCommon.css.legacy.js' ;
5454import { KeyboardShortcut , Keys } from './KeyboardShortcut.js' ;
55- import smallBubbleStyles from './smallBubble.css.legacy. js' ;
55+ import smallBubbleStyles from './smallBubble.css.js' ;
5656import * as ThemeSupport from './theme_support/theme_support.js' ;
5757import type { ToolbarButton } from './Toolbar.js' ;
5858import { Tooltip } from './Tooltip.js' ;
@@ -1300,15 +1300,15 @@ export function setTitle(element: HTMLElement, title: string): void {
13001300}
13011301
13021302export 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 {
13781382customElements . define ( 'dt-icon-label' , DevToolsIconLabel ) ;
13791383
13801384export 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
16721681export 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 */
18871896export 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}
0 commit comments