Ejemplo n.º 1
0
 /**
  * 
  * @param CSS\Value\RuleValueList $value
  */
 public function rtl_border_radius_components($value)
 {
     // border-radius: 25px 10px => 10px 25px
     /*  @var $components CSS\Value\Size[] */
     $components = $value->getListComponents();
     if (count($components) == 2) {
         $top_left = $components[1]->getSize();
         $top_left_unit = $components[1]->getUnit();
         $components[1]->setSize($components[0]->getSize());
         $components[1]->setUnit($components[0]->getUnit());
         $components[0]->setSize($top_left);
         $components[0]->setUnit($top_left_unit);
         return false;
     } else {
         if (count($components) == 3) {
             // border-radius: 25px 10px 15px => 10px 25px 10px 15px;
             // swap 1st and 2nd components
             $top_left = $components[1]->getSize();
             $top_left_unit = $components[1]->getUnit();
             $components[1]->setSize($components[0]->getSize());
             $components[1]->setUnit($components[0]->getUnit());
             $components[0]->setSize($top_left);
             $components[0]->setUnit($top_left_unit);
             // copy 3rd to 4th components
             $value->addListComponent(clone $components[2]);
             // copy the 1st components to the 3rd
             $components[2]->setSize($components[0]->getSize());
             $components[2]->setUnit($components[0]->getUnit());
             return false;
         } else {
             if (count($components) == 4) {
                 // border-radius: 25px 10px 15px 8px => 10px 25px 8px 15px;
                 // swap 1st and 2nd components
                 $top_left = $components[1]->getSize();
                 $top_left_unit = $components[1]->getUnit();
                 $components[1]->setSize($components[0]->getSize());
                 $components[1]->setUnit($components[0]->getUnit());
                 $components[0]->setSize($top_left);
                 $components[0]->setUnit($top_left_unit);
                 // swap 3rd and 4th components
                 $buttom_right = $components[3]->getSize();
                 $buttom_right_unit = $components[3]->getUnit();
                 $components[3]->setSize($components[2]->getSize());
                 $components[3]->setUnit($components[2]->getUnit());
                 $components[2]->setSize($buttom_right);
                 $components[2]->setUnit($buttom_right_unit);
                 return false;
             } else {
                 return true;
             }
         }
     }
 }