@@ -232,13 +232,14 @@ export class VariableRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
232232 const substitution = context . tracing ?. substitution ( ) ;
233233 if ( substitution ) {
234234 if ( declaration ?. declaration instanceof SDK . CSSProperty . CSSProperty ) {
235- const valueElement = Renderer . renderValueElement (
235+ const { valueElement, cssControls } = Renderer . renderValueElement (
236236 declaration . declaration . name , declaration . declaration . value ,
237237 declaration . declaration . parseValue ( this . #matchedStyles, this . #computedStyles) ,
238238 getPropertyRenderers (
239239 declaration . declaration . ownerStyle , this . #stylesPane, this . #matchedStyles, this . #treeElement,
240240 this . #computedStyles) ,
241241 substitution ) ;
242+ cssControls . forEach ( ( value , key ) => value . forEach ( control => context . addControl ( key , control ) ) ) ;
242243 return [ valueElement ] ;
243244 }
244245 if ( ! declaration && match . fallback . length > 0 ) {
@@ -562,9 +563,11 @@ export class LightDarkColorRenderer extends rendererBase(SDK.CSSPropertyParserMa
562563export class ColorMixRenderer extends rendererBase ( SDK . CSSPropertyParserMatchers . ColorMixMatch ) {
563564 // clang-format on
564565 readonly #pane: StylesSidebarPane ;
565- constructor ( pane : StylesSidebarPane ) {
566+ #treeElement: StylePropertyTreeElement | null ;
567+ constructor ( pane : StylesSidebarPane , treeElement : StylePropertyTreeElement | null ) {
566568 super ( ) ;
567569 this . #pane = pane ;
570+ this . #treeElement = treeElement ;
568571 }
569572
570573 override render ( match : SDK . CSSPropertyParserMatchers . ColorMixMatch , context : RenderingContext ) : Node [ ] {
@@ -587,30 +590,55 @@ export class ColorMixRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
587590 return false ;
588591 } ;
589592
593+ const childTracingContexts = context . tracing ?. evaluation ( [ match . space , match . color1 , match . color2 ] ) ;
594+ const childRenderingContexts =
595+ childTracingContexts ?. map ( ctx => ctx . renderingContext ( context ) ) ?? [ context , context , context ] ;
596+
590597 const contentChild = document . createElement ( 'span' ) ;
591598 contentChild . appendChild ( document . createTextNode ( 'color-mix(' ) ) ;
592- Renderer . renderInto ( match . space , context , contentChild ) ;
599+ Renderer . renderInto ( match . space , childRenderingContexts [ 0 ] , contentChild ) ;
593600 contentChild . appendChild ( document . createTextNode ( ', ' ) ) ;
594- const color1 = Renderer . renderInto ( match . color1 , context , contentChild ) . cssControls . get ( 'color' ) ?? [ ] ;
601+ const color1 =
602+ Renderer . renderInto ( match . color1 , childRenderingContexts [ 1 ] , contentChild ) . cssControls . get ( 'color' ) ?? [ ] ;
595603 contentChild . appendChild ( document . createTextNode ( ', ' ) ) ;
596- const color2 = Renderer . renderInto ( match . color2 , context , contentChild ) . cssControls . get ( 'color' ) ?? [ ] ;
604+ const color2 =
605+ Renderer . renderInto ( match . color2 , childRenderingContexts [ 2 ] , contentChild ) . cssControls . get ( 'color' ) ?? [ ] ;
597606 contentChild . appendChild ( document . createTextNode ( ')' ) ) ;
598607
599608 if ( context . matchedResult . hasUnresolvedVars ( match . node ) || color1 . length !== 1 || color2 . length !== 1 ) {
600609 return [ contentChild ] ;
601610 }
602611
612+ const space = match . space . map ( space => context . matchedResult . getComputedText ( space ) ) . join ( ' ' ) ;
613+ const color1Text = match . color1 . map ( color => context . matchedResult . getComputedText ( color ) ) . join ( ' ' ) ;
614+ const color2Text = match . color2 . map ( color => context . matchedResult . getComputedText ( color ) ) . join ( ' ' ) ;
615+ const colorMixText = `color-mix(${ space } , ${ color1Text } , ${ color2Text } )` ;
616+
617+ if ( childTracingContexts && context . tracing ?. applyEvaluation ( childTracingContexts ) ) {
618+ const initialColor = Common . Color . parse ( '#000' ) as Common . Color . Color ;
619+ const swatch = new ColorRenderer ( this . #pane, this . #treeElement) . renderColorSwatch ( initialColor ) ;
620+ context . addControl ( 'color' , swatch ) ;
621+ const nodeId = this . #pane. node ( ) ?. id ;
622+ if ( nodeId !== undefined ) {
623+ void this . #pane. cssModel ( ) ?. resolveValues ( nodeId , colorMixText ) . then ( results => {
624+ if ( results ) {
625+ const color = Common . Color . parse ( results [ 0 ] ) ;
626+ if ( color ) {
627+ swatch . setColorText ( color . as ( Common . Color . Format . HEXA ) ) ;
628+ }
629+ }
630+ } ) ;
631+ return [ swatch ] ;
632+ }
633+ }
634+
603635 const swatch = new InlineEditor . ColorMixSwatch . ColorMixSwatch ( ) ;
604636 if ( ! hookUpColorArg ( color1 [ 0 ] , text => swatch . setFirstColor ( text ) ) ||
605637 ! hookUpColorArg ( color2 [ 0 ] , text => swatch . setSecondColor ( text ) ) ) {
606638 return [ contentChild ] ;
607639 }
608-
609- const space = match . space . map ( space => context . matchedResult . getComputedText ( space ) ) . join ( ' ' ) ;
610- const color1Text = match . color1 . map ( color => context . matchedResult . getComputedText ( color ) ) . join ( ' ' ) ;
611- const color2Text = match . color2 . map ( color => context . matchedResult . getComputedText ( color ) ) . join ( ' ' ) ;
612640 swatch . tabIndex = - 1 ;
613- swatch . setColorMixText ( `color-mix( ${ space } , ${ color1Text } , ${ color2Text } )` ) ;
641+ swatch . setColorMixText ( colorMixText ) ;
614642 this . #pane. addPopover ( swatch , {
615643 contents : ( ) => {
616644 const color = swatch . mixedColor ( ) ;
@@ -1439,7 +1467,7 @@ export function getPropertyRenderers(
14391467 return [
14401468 new VariableRenderer ( stylesPane , treeElement , matchedStyles , computedStyles ) ,
14411469 new ColorRenderer ( stylesPane , treeElement ) ,
1442- new ColorMixRenderer ( stylesPane ) ,
1470+ new ColorMixRenderer ( stylesPane , treeElement ) ,
14431471 new URLRenderer ( style . parentRule , stylesPane . node ( ) ) ,
14441472 new AngleRenderer ( treeElement ) ,
14451473 new LinkableNameRenderer ( matchedStyles , stylesPane ) ,
@@ -1886,7 +1914,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
18861914 }
18871915 this . listItemElement . removeChildren ( ) ;
18881916 const matchedResult = this . property . parseValue ( this . matchedStyles ( ) , this . computedStyles ) ;
1889- this . valueElement = Renderer . renderValueElement ( this . name , this . value , matchedResult , renderers ) ;
1917+ this . valueElement = Renderer . renderValueElement ( this . name , this . value , matchedResult , renderers ) . valueElement ;
18901918 this . nameElement = Renderer . renderNameElement ( this . name ) ;
18911919 if ( this . property . name . startsWith ( '--' ) && this . nameElement ) {
18921920 this . parentPaneInternal . addPopover ( this . nameElement , {
0 commit comments