diff --git a/lib/Sabberworm/CSS/CSSList/KeyFrame.php b/lib/Sabberworm/CSS/CSSList/KeyFrame.php new file mode 100644 index 00000000..8936e4b7 --- /dev/null +++ b/lib/Sabberworm/CSS/CSSList/KeyFrame.php @@ -0,0 +1,40 @@ +vendorKeyFrame = null; + $this->animationName = null; + } + + public function setVendorKeyFrame($vendorKeyFrame) { + $this->vendorKeyFrame = $vendorKeyFrame; + } + + public function getVendorKeyFrame() { + return $this->vendorKeyFrame; + } + + public function setAnimationName($animationName) { + $this->animationName = $animationName; + } + + public function getAnimationName() { + return $this->animationName; + } + + public function __toString() { + $sResult = "@{$this->vendorKeyFrame} {$this->animationName} {"; + $sResult .= parent::__toString(); + $sResult .= '}'; + return $sResult; + } + +} diff --git a/lib/Sabberworm/CSS/Parser.php b/lib/Sabberworm/CSS/Parser.php index e32eb808..09890402 100644 --- a/lib/Sabberworm/CSS/Parser.php +++ b/lib/Sabberworm/CSS/Parser.php @@ -5,6 +5,7 @@ use Sabberworm\CSS\CSSList\CSSList; use Sabberworm\CSS\CSSList\Document; use Sabberworm\CSS\CSSList\MediaQuery; +use Sabberworm\CSS\CSSList\Keyframe; use Sabberworm\CSS\Property\Import; use Sabberworm\CSS\Property\Charset; use Sabberworm\CSS\RuleSet\AtRule; @@ -88,7 +89,16 @@ private function parseAtRule() { $this->consume('@'); $sIdentifier = $this->parseIdentifier(); $this->consumeWhiteSpace(); - if ($sIdentifier === 'media') { + if($sIdentifier == '-webkit-keyframes' || $sIdentifier == '-moz-keyframes' || $sIdentifier == '-ms-keyframes' || $sIdentifier == '-o-keyframes' || $sIdentifier == 'keyframes') { + $oResult = new KeyFrame(); + $oResult->setVendorKeyFrame($sIdentifier); + $oResult->setAnimationName(trim($this->consumeUntil('{'))); + $this->consume('{'); + $this->consumeWhiteSpace(); + $this->parseList($oResult); + return $oResult; + + } else if ($sIdentifier === 'media') { $oResult = new MediaQuery(); $oResult->setQuery(trim($this->consumeUntil('{'))); $this->consume('{');