Bug 1413111 - Use nsTSubstring::Split in nsCSSRuleProcessor::LangPseudoMatches instead of manually go through with FindChar.
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1679,32 +1679,22 @@ nsCSSRuleProcessor::LangPseudoMatches(co
// is missing as well from the preferences.
// The content language can be a comma-separated list of
// language codes.
nsAutoString language;
aDocument->GetContentLanguage(language);
nsDependentString langString(aString);
language.StripWhitespace();
- int32_t begin = 0;
- int32_t len = language.Length();
- while (begin < len) {
- int32_t end = language.FindChar(char16_t(','), begin);
- if (end == kNotFound) {
- end = len;
- }
- if (nsStyleUtil::DashMatchCompare(Substring(language, begin, end - begin),
+ for (auto const& lang : language.Split(char16_t(','))) {
+ if (nsStyleUtil::DashMatchCompare(lang,
langString,
nsASCIICaseInsensitiveStringComparator())) {
return true;
}
- begin = end + 1;
- }
- if (begin < len) {
- return true;
}
return false;
}
/* static */ bool
nsCSSRuleProcessor::StringPseudoMatches(const mozilla::dom::Element* aElement,
CSSPseudoClassType aPseudo,
const char16_t* aString,