Negates horizontal offset in tranform: translate()

@param $css string
@return string
550221
private static function fixTranslate($css) {
		$css = preg_replace_callback(self::$patterns['translate'], function ($matches) {
			return $matches[1] . $matches[2] . self::flipSign($matches[3]) . $matches[4];
		}, $css);

		$css = preg_replace_callback(self::$patterns['translate_x'], function ($matches) {
			return $matches[1] . $matches[2] . self::flipSign($matches[3]) . $matches[4];
		}, $css);

		return $css;
	}
334968
public function translate($string)
    {
        $args = func_get_args();
        $translated = array_shift($args);
        $extraParams = $args;
        if (count($extraParams)>0)
        {
            $translated = vsprintf($translated, $extraParams);
        }

        return $translated;
    }
1140029
public function convertBackgroundPosition($css, &$res)
    {
        // init the res
        $res = false;

        // explode the value
        $css = explode(' ', $css);

        // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
        if (count($css)<2) {
            if (!$css[0]) return null;
            $css[1] = 'center';
        }
        if (count($css)>2) return null;

        // prepare the values
        $x = 0;
        $y = 0;
        $res = true;

        // convert the first value
        if ($css[0]=='left')        $x = '0%';
        else if ($css[0]=='center') $x = '50%';
        else if ($css[0]=='right')  $x = '100%';
        else if ($css[0]=='top')    $y = '0%';
        else if ($css[0]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
        else $res = false;

        // convert the second value
        if ($css[1]=='left')        $x = '0%';
        else if ($css[1]=='right')  $x = '100%';
        else if ($css[1]=='top')    $y = '0%';
        else if ($css[1]=='center') $y = '50%';
        else if ($css[1]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
        else $res = false;

        // return the values
        return array($x, $y);
    }
902
private function loadStyleSheetAsset($css){

        $imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi";
        $importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi";
        $fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi";
        $fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i";

        //extract images
        preg_match_all($imageRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $match){
                $this->addAsset('img', $match);
            }
        }

        //extract @import
        preg_match_all($importRe, $css, $matches);
        if(isset($matches[2])){
            foreach($matches[2] as $match){
                $this->addAsset('css', $match);
            }
        }

        //extract fonts
        preg_match_all($fontFaceRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $faceMatch){
                preg_match_all($fontRe, $faceMatch, $fontMatches);
                if(isset($fontMatches[1])){
                    foreach($fontMatches[1] as $fontMatch){
                        $this->addAsset('font', $fontMatch);
                    }
                }
            }
        }
    }
762820
public static function compress($css)
    {
        $css = (string) $css;
        try {
            $css_minifier = new static($css);
            $minified_css = $css_minifier->min();
            return $minified_css;
        } catch (\Exception $exception) {
            return $css;
        }
    }
809932
public function parent($css = null)
    {
        if ($css === '') {
            return clone  $this;
        }

        return $this->css('parent::' . ($css === null ? '*' : $css));
    }
788199
public static function css($content) {
        $error = 'unknown';
        try {
            $minifier = new MatthiasMullie\Minify\CSS($content);
            return $minifier->minify();
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

        $return = <<<EOD

/* Error: $error */
/* Problem detected during CSS minimisation, please review the following code */
/* ========================================================================== */


EOD;

        return $return.$content;
    }
884679
public function fetchCSS()
    {
        $string = "";

        if (empty($this->queuedCSS)) {
            return $string;
        }

        foreach ($this->queuedCSS as $sheet) {
            $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n";
        }

        return $string;
    }
1244353
public function text_first($css)
    {
        $nodes = $this->_document->getQuery()->css($css, $this->_node);
        return $nodes ? $nodes->item(0)->textContent : null;
    }
1250757
public function strip($css)
    {
        /**
         * @var \DOMNode $node
         */
        $query = $this->_document->getQuery();
        foreach ($this->_nodes as $node) {
            foreach ($query->css($css, $node) as $node2) {
                $node2->parentNode->replaceChild(new \DOMText($node2->textContent), $node2);
            }
        }

        return $this;
    }
917858
public function remove($css)
    {
        /**
         * @var \DOMNode $node
         */
        $query = $this->_document->getQuery();
        foreach ($this->_nodes as $node) {
            foreach ($query->css($css, $node) as $node2) {
                $node2->parentNode->removeChild($node2);
            }
        }

        return $this;
    }
834067
public function getCss(){

		$precision = ini_get('precision');
		@ini_set('precision',16);
		$locale = setlocale(LC_NUMERIC, 0);
		setlocale(LC_NUMERIC, "C");

		try {

	 		$root = new Less_Tree_Ruleset(array(), $this->rules );
			$root->root = true;
			$root->firstRoot = true;


			$this->PreVisitors($root);

			self::$has_extends = false;
			$evaldRoot = $root->compile($this->env);



			$this->PostVisitors($evaldRoot);

			if( Less_Parser::$options['sourceMap'] ){
				$generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options );
				// will also save file
				// FIXME: should happen somewhere else?
				$css = $generator->generateCSS();
			}else{
				$css = $evaldRoot->toCSS();
			}

			if( Less_Parser::$options['compress'] ){
				$css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css);
			}

		} catch (Exception $exc) {
			// Intentional fall-through so we can reset environment
		}

		//reset php settings
		@ini_set('precision',$precision);
		setlocale(LC_NUMERIC, $locale);

		// If you previously defined $this->mb_internal_encoding
		// is required to return the encoding as it was before
		if ($this->mb_internal_encoding != '') {
			@ini_set("mbstring.internal_encoding", $this->mb_internal_encoding);
			$this->mb_internal_encoding = '';
		}

		// Rethrow exception after we handled resetting the environment
		if (!empty($exc)) {
			throw $exc;
		}



		return $css;
	}
930002
protected function _translate($matches)
    {
        $replacement = '';
        $translator = $this->getObject('translator');

        switch ($matches[0])
        {
            case 'D':
                $replacement = $translator->translate(strtoupper($this->_date->format('D')));
                break;

            case 'l':
                $replacement = $translator->translate(strtoupper($this->_date->format('l')));
                break;

            case 'F':
                $replacement = $translator->translate(strtoupper($this->_date->format('F')));
                break;

            case 'M':
                $replacement = $translator->translate(strtoupper($this->_date->format('F').'_SHORT'));
                break;
        }

        $replacement = preg_replace('/([a-z])/i', '\\\\$1', $replacement);

        return $replacement;
    }
644609
public function convertToMM($css, $old=0.)
    {
        $css = trim($css);
        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
        else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
        else                                              $css = null;

        return $css;
    }
648680
private static function fixBackgroundPosition($css) {
		$replaced = preg_replace_callback(
			self::$patterns['bg_horizontal_percentage'],
			array('self', 'calculateNewBackgroundPosition'),
			$css
		);
		if ($replaced !== null) {
			// preg_replace_callback() sometimes returns null
			$css = $replaced;
		}
		$replaced = preg_replace_callback(
			self::$patterns['bg_horizontal_percentage_x'],
			array('self', 'calculateNewBackgroundPosition'),
			$css
		);
		if ($replaced !== null) {
			$css = $replaced;
		}

		return $css;
	}
979787
public function &inline($styles)
    {
        $css_object = new CssObject();

        $css_object->setType('inline');
        $css_object->setCss($styles);

        $this->add($css_object);

        return $css_object;
    }
1045040
function xOffset()
    {
        $xOffset = $this->ez['xOffset'];
        if ( $xOffset == 0 ||
             $this->leftMargin() > $this->ez['xOffset'] )
        {
            $xOffset = $this->leftMargin();
        }
        return $xOffset;
    }