mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Issue #2691: Add basic parentheses tracking to ParseSupportsSelector
This commit is contained in:
parent
e9a7190529
commit
fcb4b3d01f
1 changed files with 15 additions and 6 deletions
|
|
@ -4861,6 +4861,7 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
|||
nsAutoString selectorText;
|
||||
bool foundClosingParen = false;
|
||||
bool hasContent = false;
|
||||
int32_t parenDepth = 0;
|
||||
|
||||
while (true) {
|
||||
if (!GetToken(true)) {
|
||||
|
|
@ -4868,11 +4869,18 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
|||
}
|
||||
|
||||
if (mToken.IsSymbol(')')) {
|
||||
foundClosingParen = true;
|
||||
break;
|
||||
}
|
||||
|
||||
hasContent = true;
|
||||
if (parenDepth == 0) {
|
||||
foundClosingParen = true;
|
||||
break;
|
||||
} else {
|
||||
parenDepth--;
|
||||
selectorText.Append(mToken.mSymbol);
|
||||
}
|
||||
} else if (mToken.IsSymbol('(')) {
|
||||
parenDepth++;
|
||||
selectorText.Append(mToken.mSymbol);
|
||||
} else {
|
||||
hasContent = true;
|
||||
|
||||
bool needSpace = false;
|
||||
if (!selectorText.IsEmpty()) {
|
||||
|
|
@ -4915,6 +4923,7 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
|||
if (needSpace) selectorText.Append(' ');
|
||||
selectorText.Append(mToken.mIdent);
|
||||
selectorText.Append('(');
|
||||
parenDepth++;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -4943,7 +4952,7 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
|||
return true;
|
||||
}
|
||||
|
||||
int32_t parenDepth = 0;
|
||||
parenDepth = 0; // reset parenDepth for comma checking
|
||||
for (uint32_t i = 0; i < selectorText.Length(); i++) {
|
||||
char16_t c = selectorText.CharAt(i);
|
||||
if (c == '(') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue