MDL-70300 lib: Upgrade php css parser to 8.3.1
This commit is contained in:
@@ -69,9 +69,34 @@ abstract class CSSBlockList extends CSSList {
|
||||
if ($sSpecificitySearch === null) {
|
||||
$aResult[] = $oSelector;
|
||||
} else {
|
||||
$sComparison = "\$bRes = {$oSelector->getSpecificity()} $sSpecificitySearch;";
|
||||
eval($sComparison);
|
||||
if ($bRes) {
|
||||
$sComparator = '===';
|
||||
$aSpecificitySearch = explode(' ', $sSpecificitySearch);
|
||||
$iTargetSpecificity = $aSpecificitySearch[0];
|
||||
if(count($aSpecificitySearch) > 1) {
|
||||
$sComparator = $aSpecificitySearch[0];
|
||||
$iTargetSpecificity = $aSpecificitySearch[1];
|
||||
}
|
||||
$iTargetSpecificity = (int)$iTargetSpecificity;
|
||||
$iSelectorSpecificity = $oSelector->getSpecificity();
|
||||
$bMatches = false;
|
||||
switch($sComparator) {
|
||||
case '<=':
|
||||
$bMatches = $iSelectorSpecificity <= $iTargetSpecificity;
|
||||
break;
|
||||
case '<':
|
||||
$bMatches = $iSelectorSpecificity < $iTargetSpecificity;
|
||||
break;
|
||||
case '>=':
|
||||
$bMatches = $iSelectorSpecificity >= $iTargetSpecificity;
|
||||
break;
|
||||
case '>':
|
||||
$bMatches = $iSelectorSpecificity > $iTargetSpecificity;
|
||||
break;
|
||||
default:
|
||||
$bMatches = $iSelectorSpecificity === $iTargetSpecificity;
|
||||
break;
|
||||
}
|
||||
if ($bMatches) {
|
||||
$aResult[] = $oSelector;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ abstract class CSSList implements Renderable, Commentable {
|
||||
$oListItem->setComments($comments);
|
||||
$oList->append($oListItem);
|
||||
}
|
||||
$oParserState->consumeWhiteSpace();
|
||||
}
|
||||
if(!$bIsRoot && !$bLenientParsing) {
|
||||
throw new SourceException("Unexpected end of document", $oParserState->currentLine());
|
||||
@@ -211,20 +212,6 @@ abstract class CSSList implements Renderable, Commentable {
|
||||
array_splice($this->aContents, $iOffset, $iLength, $mReplacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an item before its sibling.
|
||||
*
|
||||
* @param mixed $oItem The item.
|
||||
* @param mixed $oSibling The sibling.
|
||||
*/
|
||||
public function insert($oItem, $oSibling) {
|
||||
$iIndex = array_search($oSibling, $this->aContents);
|
||||
if ($iIndex === false) {
|
||||
return $this->append($oItem);
|
||||
}
|
||||
array_splice($this->aContents, $iIndex, 0, array($oItem));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an item from the CSS list.
|
||||
* @param RuleSet|Import|Charset|CSSList $oItemToRemove May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset or another CSSList (most likely a MediaQuery)
|
||||
@@ -327,7 +314,7 @@ abstract class CSSList implements Renderable, Commentable {
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the list can not be further outdented. Only important when rendering.
|
||||
*/
|
||||
|
||||
@@ -72,9 +72,6 @@ class Document extends CSSBlockList {
|
||||
* @example getSelectorsBySpecificity('>= 100')
|
||||
*/
|
||||
public function getSelectorsBySpecificity($sSpecificitySearch = null) {
|
||||
if (is_numeric($sSpecificitySearch) || is_numeric($sSpecificitySearch[0])) {
|
||||
$sSpecificitySearch = "== $sSpecificitySearch";
|
||||
}
|
||||
$aResult = array();
|
||||
$this->allSelectors($aResult, $sSpecificitySearch);
|
||||
return $aResult;
|
||||
|
||||
@@ -56,6 +56,7 @@ class Rule implements Renderable, Commentable {
|
||||
while ($oParserState->comes(';')) {
|
||||
$oParserState->consume(';');
|
||||
}
|
||||
$oParserState->consumeWhiteSpace();
|
||||
|
||||
return $oRule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user