Beispiel #1
0
 /**
  * Checks the declaration property.
  *
  * @param string $property
  * @return bool
  */
 public function checkProperty(&$property)
 {
     if (parent::checkProperty($property)) {
         if (preg_match('/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D', $property)) {
             return true;
         } else {
             $this->setIsValid(false);
             $this->addValidationError("Invalid property '{$property}' for @font-face declaration.");
         }
     }
     return false;
 }
Beispiel #2
0
 /**
  * Checks the value.
  *
  * @param string $value
  * @return bool
  */
 public function checkValue(&$value)
 {
     if (parent::checkValue($value)) {
         $value = trim($value, " \r\n\t\f;");
         // Check if declaration contains "!important"
         if (strpos($value, "!") !== false) {
             $charset = $this->getStyleSheet()->getCharset();
             if (mb_strtolower(mb_substr($value, -10, null, $charset), $charset) === "!important") {
                 $this->setIsImportant(true);
                 $value = rtrim(mb_substr($value, 0, -10, $charset));
             }
         }
         // Optimize the value
         $value = Optimizer::optimizeDeclarationValue($value);
         return true;
     }
     return false;
 }
Beispiel #3
0
 /**
  * Checks the declaration value.
  *
  * @param string $value
  * @return bool
  */
 public function checkValue(&$value)
 {
     if (parent::checkValue($value)) {
         $value = trim($value, " \r\n\t\f;");
         // Check if declaration contains "!important"
         if (strpos($value, "!") !== false) {
             $charset = $this->getStyleSheet()->getCharset();
             if (mb_strtolower(mb_substr($value, -10, null, $charset), $charset) === "!important") {
                 // Invalidate declaration, because "!important" isn't allowed and the declaration should be ignored
                 // @see: https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#!important_in_a_keyframe
                 $this->setIsValid(false);
                 $this->addValidationError("Invalid value '{$value}' for @keyframes declaration. '!important' not allowed.");
             }
         }
         // Optimize the value
         $value = Optimizer::optimizeDeclarationValue($value);
         return true;
     }
     return false;
 }
Beispiel #4
0
 /**
  * Checks the declaration property.
  *
  * @param string $property
  * @return bool
  */
 public function checkProperty(&$property)
 {
     // TODO: Add checks
     return parent::checkProperty($property);
 }