Ejemplo n.º 1
0
 private function parseRule()
 {
     $oRule = new Rule($this->parseIdentifier());
     $this->consumeWhiteSpace();
     $this->consume(':');
     $oValue = $this->parseValue(self::listDelimiterForRule($oRule->getRule()));
     $oRule->setValue($oValue);
     if ($this->comes('!')) {
         $this->consume('!');
         $this->consumeWhiteSpace();
         $this->consume('important');
         $oRule->setIsImportant(true);
     }
     while ($this->comes(';')) {
         $this->consume(';');
         $this->consumeWhiteSpace();
     }
     return $oRule;
 }
Ejemplo n.º 2
0
 public function expandListStyleShorthand()
 {
     $aListProperties = array('list-style-type' => 'disc', 'list-style-position' => 'outside', 'list-style-image' => 'none');
     $aListStyleTypes = array('none', 'disc', 'circle', 'square', 'decimal-leading-zero', 'decimal', 'lower-roman', 'upper-roman', 'lower-greek', 'lower-alpha', 'lower-latin', 'upper-alpha', 'upper-latin', 'hebrew', 'armenian', 'georgian', 'cjk-ideographic', 'hiragana', 'hira-gana-iroha', 'katakana-iroha', 'katakana');
     $aListStylePositions = array('inside', 'outside');
     $aRules = $this->getRulesAssoc();
     if (!isset($aRules['list-style'])) {
         return;
     }
     $oRule = $aRules['list-style'];
     $mRuleValue = $oRule->getValue();
     $aValues = array();
     if (!$mRuleValue instanceof RuleValueList) {
         $aValues[] = $mRuleValue;
     } else {
         $aValues = $mRuleValue->getListComponents();
     }
     if (count($aValues) == 1 && $aValues[0] == 'inherit') {
         foreach ($aListProperties as $sProperty => $mValue) {
             $oNewRule = new Rule($sProperty);
             $oNewRule->addValue('inherit');
             $oNewRule->setIsImportant($oRule->getIsImportant());
             $this->addRule($oNewRule);
         }
         $this->removeRule('list-style');
         return;
     }
     foreach ($aValues as $mValue) {
         if (!$mValue instanceof Value) {
             $mValue = mb_strtolower($mValue);
         }
         if ($mValue instanceof Url) {
             $aListProperties['list-style-image'] = $mValue;
         } else {
             if (in_array($mValue, $aListStyleTypes)) {
                 $aListProperties['list-style-types'] = $mValue;
             } else {
                 if (in_array($mValue, $aListStylePositions)) {
                     $aListProperties['list-style-position'] = $mValue;
                 }
             }
         }
     }
     foreach ($aListProperties as $sProperty => $mValue) {
         $oNewRule = new Rule($sProperty);
         $oNewRule->setIsImportant($oRule->getIsImportant());
         $oNewRule->addValue($mValue);
         $this->addRule($oNewRule);
     }
     $this->removeRule('list-style');
 }
Ejemplo n.º 3
0
 private function parseRule()
 {
     $aComments = $this->consumeWhiteSpace();
     $oRule = new Rule($this->parseIdentifier(), $this->iLineNo);
     $oRule->setComments($aComments);
     $oRule->addComments($this->consumeWhiteSpace());
     $this->consume(':');
     $oValue = $this->parseValue(self::listDelimiterForRule($oRule->getRule()));
     $oRule->setValue($oValue);
     if ($this->oParserSettings->bLenientParsing) {
         while ($this->comes('\\')) {
             $this->consume('\\');
             $oRule->addIeHack($this->consume());
             $this->consumeWhiteSpace();
         }
     }
     if ($this->comes('!')) {
         $this->consume('!');
         $this->consumeWhiteSpace();
         $this->consume('important');
         $oRule->setIsImportant(true);
     }
     while ($this->comes(';')) {
         $this->consume(';');
     }
     return $oRule;
 }