mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 16:17:29 +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;
|
nsAutoString selectorText;
|
||||||
bool foundClosingParen = false;
|
bool foundClosingParen = false;
|
||||||
bool hasContent = false;
|
bool hasContent = false;
|
||||||
|
int32_t parenDepth = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!GetToken(true)) {
|
if (!GetToken(true)) {
|
||||||
|
|
@ -4868,11 +4869,18 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mToken.IsSymbol(')')) {
|
if (mToken.IsSymbol(')')) {
|
||||||
foundClosingParen = true;
|
if (parenDepth == 0) {
|
||||||
break;
|
foundClosingParen = true;
|
||||||
}
|
break;
|
||||||
|
} else {
|
||||||
hasContent = true;
|
parenDepth--;
|
||||||
|
selectorText.Append(mToken.mSymbol);
|
||||||
|
}
|
||||||
|
} else if (mToken.IsSymbol('(')) {
|
||||||
|
parenDepth++;
|
||||||
|
selectorText.Append(mToken.mSymbol);
|
||||||
|
} else {
|
||||||
|
hasContent = true;
|
||||||
|
|
||||||
bool needSpace = false;
|
bool needSpace = false;
|
||||||
if (!selectorText.IsEmpty()) {
|
if (!selectorText.IsEmpty()) {
|
||||||
|
|
@ -4915,6 +4923,7 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
||||||
if (needSpace) selectorText.Append(' ');
|
if (needSpace) selectorText.Append(' ');
|
||||||
selectorText.Append(mToken.mIdent);
|
selectorText.Append(mToken.mIdent);
|
||||||
selectorText.Append('(');
|
selectorText.Append('(');
|
||||||
|
parenDepth++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -4943,7 +4952,7 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parenDepth = 0;
|
parenDepth = 0; // reset parenDepth for comma checking
|
||||||
for (uint32_t i = 0; i < selectorText.Length(); i++) {
|
for (uint32_t i = 0; i < selectorText.Length(); i++) {
|
||||||
char16_t c = selectorText.CharAt(i);
|
char16_t c = selectorText.CharAt(i);
|
||||||
if (c == '(') {
|
if (c == '(') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue