Bug 1640540 - Part 2: Use ASCII case insensitive comparisons for all attribute selectors. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D76642
This commit is contained in:
Cameron McCormack 2020-05-25 00:46:03 +00:00
parent 0d9a9c6761
commit bc1ac01d88
2 changed files with 16 additions and 7 deletions

View File

@ -836,13 +836,13 @@ static bool AttrEquals(Implementor* aElement, nsAtom* aNS, nsAtom* aName,
return DoMatch(aElement, aNS, aName, match); return DoMatch(aElement, aNS, aName, match);
} }
#define WITH_COMPARATOR(ignore_case_, c_, expr_) \ #define WITH_COMPARATOR(ignore_case_, c_, expr_) \
if (ignore_case_) { \ if (ignore_case_) { \
const nsCaseInsensitiveStringComparator c_; \ const nsASCIICaseInsensitiveStringComparator c_; \
return expr_; \ return expr_; \
} else { \ } else { \
const nsDefaultStringComparator c_; \ const nsDefaultStringComparator c_; \
return expr_; \ return expr_; \
} }
template <typename Implementor> template <typename Implementor>

View File

@ -1,4 +1,5 @@
<!doctype html> <!doctype html>
<meta charset=utf-8>
<title>Selectors: semantics of case-sensitivity attribute selector</title> <title>Selectors: semantics of case-sensitivity attribute selector</title>
<link rel="help" href="https://drafts.csswg.org/selectors/#attribute-case"> <link rel="help" href="https://drafts.csswg.org/selectors/#attribute-case">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
@ -122,6 +123,14 @@ var nomatch = [
["@namespace x 'A'; [x|foo='' i]", ["a", "foo", ""]], ["@namespace x 'A'; [x|foo='' i]", ["a", "foo", ""]],
["[foo='bar' i][foo='bar']", ["", "foo", "BAR"]], ["[foo='bar' i][foo='bar']", ["", "foo", "BAR"]],
["[foo='bar' i]", ["", "baz", "BAR"]], ["[foo='bar' i]", ["", "baz", "BAR"]],
["[foo^='é' i]", ["", "foo", "É"]],
["[foo$='é' i]", ["", "foo", "É"]],
["[foo*='é' i]", ["", "foo", "É"]],
["[foo|='é' i]", ["", "foo", "É"]],
["[foo^='É' i]", ["", "foo", "é"]],
["[foo$='É' i]", ["", "foo", "é"]],
["[foo*='É' i]", ["", "foo", "é"]],
["[foo|='É' i]", ["", "foo", "é"]],
// Case-sensitive matching // Case-sensitive matching
["[foo='' s]", ["", "foo", "BAR"]], ["[foo='' s]", ["", "foo", "BAR"]],
["[foo='\u0000' s] /* \\0 in selector */", ["", "foo", ""]], ["[foo='\u0000' s] /* \\0 in selector */", ["", "foo", ""]],