mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
Issue #2691: Improve Parser State Handling
This commit is contained in:
parent
224d1724b2
commit
ea580ec54b
1 changed files with 13 additions and 19 deletions
|
|
@ -5066,29 +5066,23 @@ CSSParserImpl::ParseSupportsSelector(bool& aConditionMet)
|
|||
return true;
|
||||
}
|
||||
|
||||
nsCSSScanner tempScanner(selectorText, 0);
|
||||
css::ErrorReporter tempReporter(tempScanner, mSheet, mChildLoader, mSheetURI);
|
||||
// isolate parser instance to avoid state corruption
|
||||
CSSParserImpl tempParser;
|
||||
tempParser.SetStyleSheet(mSheet);
|
||||
tempParser.SetChildLoader(mChildLoader);
|
||||
|
||||
nsCSSScanner* savedScanner = mScanner;
|
||||
css::ErrorReporter* savedReporter = mReporter;
|
||||
|
||||
mScanner = &tempScanner;
|
||||
mReporter = &tempReporter;
|
||||
|
||||
nsCSSSelectorList* selectorList = nullptr;
|
||||
// check support
|
||||
SelectorParsingFlags flags = SelectorParsingFlags::eNone;
|
||||
bool parseSuccess = ParseSelectorGroup(selectorList, flags);
|
||||
|
||||
mScanner = savedScanner;
|
||||
mReporter = savedReporter;
|
||||
|
||||
if (parseSuccess && selectorList) {
|
||||
aConditionMet = true;
|
||||
nsCSSSelectorList* selectorList = nullptr;
|
||||
bool supportSuccess = tempParser.ParseSelectorString(selectorText, mSheetURI, 0, &selectorList) == NS_OK;
|
||||
|
||||
// clean up
|
||||
if (selectorList) {
|
||||
delete selectorList;
|
||||
} else {
|
||||
aConditionMet = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
aConditionMet = supportSuccess;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue