setCssWideKeywordsMatcher( new FunctionMatcher( 'var', new Juxtaposition( [ new WhitespaceMatcher( [ 'significant' => false ] ), new VarNameMatcher(), new WhitespaceMatcher( [ 'significant' => false ] ), ] ) ) ); } /** * Adds the image-rendering matcher * * @param StylePropertySanitizer $propertySanitizer */ public function addImageRendering( StylePropertySanitizer $propertySanitizer ): void { try { $propertySanitizer->addKnownProperties( [ 'image-rendering' => new KeywordMatcher( [ 'auto', 'crisp-edges', 'pixelated', 'inherit', 'initial', 'unset', ] ) ] ); } catch ( InvalidArgumentException $e ) { // Fail silently } } /** * Adds the ruby-position and ruby-align matcher * * @param StylePropertySanitizer $propertySanitizer */ public function addRuby( StylePropertySanitizer $propertySanitizer ): void { try { $propertySanitizer->addKnownProperties( [ 'ruby-position' => new KeywordMatcher( [ 'start', 'center', 'space-between', 'space-around', 'inherit', 'initial', 'unset', ] ) ] ); $propertySanitizer->addKnownProperties( [ 'ruby-align' => new KeywordMatcher( [ 'over', 'under', 'inter-character', 'inherit', 'initial', 'unset', ] ) ] ); } catch ( InvalidArgumentException $e ) { // Fail silently } } /** * Adds scroll-margin-* and scroll-padding-* matcher * This is not well tested * * @param StylePropertySanitizer $propertySanitizer * @param MatcherFactory $factory */ public function addScrollMarginProperties( StylePropertySanitizer $propertySanitizer, MatcherFactory $factory ): void { $suffixes = [ 'margin-block-end', 'margin-block-start', 'margin-block', 'margin-bottom', 'margin-inline-end', 'margin-inline-start', 'margin-inline', 'margin-left', 'margin-right', 'margin-top', 'margin', 'padding-block-end', 'padding-block-start', 'padding-block', 'padding-bottom', 'padding-inline-end', 'padding-inline-start', 'padding-inline', 'padding-left', 'padding-right', 'padding-top', 'padding', ]; foreach ( $suffixes as $suffix ) { try { $propertySanitizer->addKnownProperties( [ sprintf( 'scroll-%s', $suffix ) => new Alternative( [ $factory->length() ] ) ] ); } catch ( InvalidArgumentException $e ) { // Fail silently } } } }