@@ -38,7 +38,7 @@ import * as Common from '../../core/common/common.js';
3838import * as i18n from '../../core/i18n/i18n.js' ;
3939import * as Platform from '../../core/platform/platform.js' ;
4040import * as SDK from '../../core/sdk/sdk.js' ;
41- import * as ComputedStyleModule from '../../models/computed_style/computed_style.js' ;
41+ import type * as ComputedStyleModule from '../../models/computed_style/computed_style.js' ;
4242import * as TreeOutline from '../../ui/components/tree_outline/tree_outline.js' ;
4343import * as InlineEditor from '../../ui/legacy/components/inline_editor/inline_editor.js' ;
4444import * as Components from '../../ui/legacy/components/utils/utils.js' ;
@@ -296,17 +296,17 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
296296 > ${ i18nString ( UIStrings . group ) } </ devtools-checkbox >
297297 </ devtools-toolbar >
298298 </ div >
299- < div class ="computed-style-tree-outline-container ">
300- ${ input . computedStylesTree }
301- </ div >
299+ ${ input . computedStylesTree }
302300 ${ ! input . hasMatches ? html `< div class ="gray-info-message "> ${ i18nString ( UIStrings . noMatchingProperty ) } </ div > ` : '' }
303301 < devtools-widget .widgetConfig =${ UI . Widget . widgetConfig ( PlatformFontsWidget , { sharedModel : input . computedStyleModel } ) } > </ devtools-widget >
304302 ` , target ) ;
305303 // clang-format on
306304} ;
307305
308306export class ComputedStyleWidget extends UI . Widget . VBox {
309- private computedStyleModel : ComputedStyleModule . ComputedStyleModel . ComputedStyleModel ;
307+ #computedStyleModel: ComputedStyleModule . ComputedStyleModel . ComputedStyleModel ;
308+ #nodeStyle: ComputedStyleModule . ComputedStyleModel . ComputedStyle | null = null ;
309+ #matchedStyles: SDK . CSSMatchedStyles . CSSMatchedStyles | null = null ;
310310 private readonly showInheritedComputedStylePropertiesSetting : Common . Settings . Setting < boolean > ;
311311 private readonly groupComputedStylesSetting : Common . Settings . Setting < boolean > ;
312312 private filterRegex : RegExp | null ;
@@ -324,11 +324,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
324324
325325 this . contentElement . classList . add ( 'styles-sidebar-computed-style-widget' ) ;
326326
327- this . computedStyleModel = computedStyleModel ;
328- this . computedStyleModel . addEventListener (
329- ComputedStyleModule . ComputedStyleModel . Events . CSS_MODEL_CHANGED , this . requestUpdate , this ) ;
330- this . computedStyleModel . addEventListener (
331- ComputedStyleModule . ComputedStyleModel . Events . COMPUTED_STYLE_CHANGED , this . requestUpdate , this ) ;
327+ this . #computedStyleModel = computedStyleModel ;
332328
333329 this . showInheritedComputedStylePropertiesSetting =
334330 Common . Settings . Settings . instance ( ) . createSetting ( 'show-inherited-computed-style-properties' , false ) ;
@@ -340,16 +336,14 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
340336 } ) ;
341337
342338 this . filterRegex = null ;
343-
344339 this . linkifier = new Components . Linkifier . Linkifier ( maxLinkLength ) ;
345-
346340 this . imagePreviewPopover = new ImagePreviewPopover ( this . contentElement , event => {
347341 const link = event . composedPath ( ) [ 0 ] ;
348342 if ( link instanceof Element ) {
349343 return link ;
350344 }
351345 return null ;
352- } , ( ) => this . computedStyleModel . node ) ;
346+ } , ( ) => this . # computedStyleModel. node ) ;
353347
354348 this . #updateView( { hasMatches : true } ) ;
355349 }
@@ -377,7 +371,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
377371 {
378372 computedStylesTree : this . #computedStylesTree,
379373 hasMatches,
380- computedStyleModel : this . computedStyleModel ,
374+ computedStyleModel : this . # computedStyleModel,
381375 showInheritedComputedStylePropertiesSetting : this . showInheritedComputedStylePropertiesSetting ,
382376 groupComputedStylesSetting : this . groupComputedStylesSetting ,
383377 onFilterChanged : this . onFilterChanged . bind ( this ) ,
@@ -386,8 +380,27 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
386380 null , this . contentElement ) ;
387381 }
388382
383+ get nodeStyle ( ) : ComputedStyleModule . ComputedStyleModel . ComputedStyle | null {
384+ return this . #nodeStyle;
385+ }
386+
387+ set nodeStyle ( nodeStyle : ComputedStyleModule . ComputedStyleModel . ComputedStyle | null ) {
388+ this . #nodeStyle = nodeStyle ;
389+ this . requestUpdate ( ) ;
390+ }
391+
392+ get matchedStyles ( ) : SDK . CSSMatchedStyles . CSSMatchedStyles | null {
393+ return this . #matchedStyles;
394+ }
395+
396+ set matchedStyles ( matchedStyles : SDK . CSSMatchedStyles . CSSMatchedStyles | null ) {
397+ this . #matchedStyles = matchedStyles ;
398+ this . requestUpdate ( ) ;
399+ }
400+
389401 override async performUpdate ( ) : Promise < void > {
390- const { computedStyle : nodeStyles , matchedStyles} = await this . computedStyleModel . fetchAllComputedStyleInfo ( ) ;
402+ const nodeStyles = this . #nodeStyle;
403+ const matchedStyles = this . #matchedStyles;
391404 if ( ! nodeStyles || ! matchedStyles ) {
392405 this . #updateView( { hasMatches : false } ) ;
393406 return ;
@@ -405,7 +418,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
405418 matchedStyles : SDK . CSSMatchedStyles . CSSMatchedStyles ) : Promise < void > {
406419 this . imagePreviewPopover . hide ( ) ;
407420 this . linkifier . reset ( ) ;
408- const cssModel = this . computedStyleModel . cssModel ( ) ;
421+ const cssModel = this . # computedStyleModel. cssModel ( ) ;
409422 if ( ! cssModel ) {
410423 return ;
411424 }
@@ -448,7 +461,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
448461 matchedStyles : SDK . CSSMatchedStyles . CSSMatchedStyles | null ) : Promise < void > {
449462 this . imagePreviewPopover . hide ( ) ;
450463 this . linkifier . reset ( ) ;
451- const cssModel = this . computedStyleModel . cssModel ( ) ;
464+ const cssModel = this . # computedStyleModel. cssModel ( ) ;
452465 if ( ! nodeStyle || ! matchedStyles || ! cssModel ) {
453466 this . #updateView( { hasMatches : false } ) ;
454467 return ;
0 commit comments