identMatcher = $matcherFactory->ident(); $this->ruleSanitizer = new StyleRuleSanitizer( Quantifier::hash( new Alternative( [ new KeywordMatcher( [ 'from', 'to' ] ), $matcherFactory->rawPercentage() ] ) ), $propertySanitizer ); } public function handlesRule( Rule $rule ) { return $rule instanceof AtRule && !strcasecmp( $rule->getName(), 'keyframes' ); } protected function doSanitize( CSSObject $object ) { if ( !$object instanceof Rule || !$this->handlesRule( $object ) ) { $this->sanitizationError( 'expected-at-rule', $object, [ 'keyframes' ] ); return null; } if ( $object->getBlock() === null ) { $this->sanitizationError( 'at-rule-block-required', $object, [ 'keyframes' ] ); return null; } // Test the keyframe name if ( !$this->identMatcher->match( $object->getPrelude(), [ 'mark-significance' => true ] ) ) { $cv = Util::findFirstNonWhitespace( $object->getPrelude() ); if ( $cv ) { $this->sanitizationError( 'invalid-keyframe-name', $cv ); } else { $this->sanitizationError( 'missing-keyframe-name', $object ); } return null; } $ret = clone( $object ); $this->fixPreludeWhitespace( $ret, false ); $this->sanitizeRuleBlock( $ret->getBlock(), [ $this->ruleSanitizer ] ); return $ret; } }