private function parseAtRule() { $this->consume('@'); $sIdentifier = $this->parseIdentifier(); $this->consumeWhiteSpace(); if ($sIdentifier === 'media') { $oResult = new CSSMediaQuery(); $oResult->setQuery(trim($this->consumeUntil('{'))); $this->consume('{'); $this->consumeWhiteSpace(); $this->parseList($oResult); return $oResult; } else { if ($sIdentifier === 'import') { $oLocation = $this->parseURLValue(); $this->consumeWhiteSpace(); $sMediaQuery = null; if (!$this->comes(';')) { $sMediaQuery = $this->consumeUntil(';'); } $this->consume(';'); return new CSSImport($oLocation, $sMediaQuery); } else { if ($sIdentifier === 'charset') { $sCharset = $this->parseStringValue(); $this->consumeWhiteSpace(); $this->consume(';'); $this->setCharset($sCharset->getString()); return new CSSCharset($sCharset); } else { //Unknown other at rule (font-face or such) $this->consume('{'); $this->consumeWhiteSpace(); $oAtRule = new CSSAtRule($sIdentifier); $this->parseRuleSet($oAtRule); return $oAtRule; } } } }
private function parseAtRule() { $this->consume('@'); $sIdentifier = $this->parseIdentifier(); $this->consumeWhiteSpace(); if ($sIdentifier === 'media') { $this->bIgnoreCharsetRules = true; $this->bIgnoreImportRules = true; $oResult = new CSSMediaQuery(); $oResult->setQuery(trim($this->consumeUntil('{'))); $this->consume('{'); $this->consumeWhiteSpace(); $this->parseList($oResult); return $oResult; } else { if ($sIdentifier === 'import') { $this->bIgnoreCharsetRules = true; $oLocation = $this->parseURLValue(); $this->consumeWhiteSpace(); $sMediaQuery = null; if (!$this->comes(';')) { $sMediaQuery = $this->consumeUntil(';'); } $this->consume(';'); $oImport = new CSSImport($oLocation, $sMediaQuery); if ($this->bIgnoreImportRules) { return new CSSIgnoredValue($oImport); } return $oImport; } else { if ($sIdentifier === 'charset') { $sCharset = $this->parseStringValue(); $this->consumeWhiteSpace(); $this->consume(';'); $oCharset = new CSSCharset($sCharset); if ($this->bIgnoreCharsetRules) { return new CSSIgnoredValue($oCharset); } $this->bIgnoreCharsetRules = true; return $oCharset; } else { if ($sIdentifier === 'namespace') { if ($this->comes('"') || $this->comes("'") || $this->comes('url')) { $oNamespace = new CSSNamespace($this->parseURLValue()); } else { $sPrefix = $this->parseIdentifier(); $oNamespace = new CSSNamespace($this->parseURLValue(), $sPrefix); } $this->consumeWhiteSpace(); $this->consume(';'); return $oNamespace; } else { //Unknown other at rule (font-face or such) $this->bIgnoreCharsetRules = true; $this->bIgnoreImportRules = true; $this->consume('{'); $this->consumeWhiteSpace(); $oAtRule = new CSSAtRule($sIdentifier); $this->parseRuleSet($oAtRule); return $oAtRule; } } } } }