diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2023-02-20 22:28:50 +0800 |
---|---|---|
committer | FranklinDM <mrmineshafter17@gmail.com> | 2023-02-20 23:36:28 +0800 |
commit | 31c074ce15f63628f61f63127e80ed416ec6ca4d (patch) | |
tree | d1f829f8d88535a9dc66d0e6c353dc700213c5d6 /layout | |
parent | f19504608e06ea1a724aad8a3a2edb2dc6b244ce (diff) | |
download | uxp-31c074ce15f63628f61f63127e80ed416ec6ca4d.tar.gz |
Issue #2078 - Part 6: Replace empty list head with the next non-empty list for forgiving selector lists
What happens here if aListHead is an empty selector list:
(1) next selector group is parsed and continues to the next iteration if it's empty or invalid
(2) if we're a forgiving selector list and aListHead is empty, replace it with the selector group that we've just parsed
(3) step 1 ignores invalid/empty, so we assert that step 2 should never have an empty selector list
Diffstat (limited to 'layout')
-rw-r--r-- | layout/style/nsCSSParser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 7775df29cd..c81de2d9f6 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -5492,8 +5492,15 @@ CSSParserImpl::ParseSelectorList(nsCSSSelectorList*& aListHead, } break; } - // add new list to the end of the selector list - list->mNext = newList; + // Replace the list head if: it's empty and we're a forgiving selector + // list. Otherwise, add the new list to the end of the selector list. + if (aIsForgiving && !aListHead->mSelectors) { + MOZ_ASSERT(newList->mSelectors, + "replacing empty list head with an empty selector list?"); + aListHead = newList; + } else { + list->mNext = newList; + } list = newList; continue; } else if (aStopChar == tk->mSymbol && aStopChar != char16_t(0)) { |