Bug 820902. nsAttrValue::Equals should do ASCII-case-insensitive compares when it's doing case-insensitive compares. r=sicking
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 13 Dec 2012 17:08:44 -0500
changeset 125091 66f91a854410103cdf77d6a884d7b4bdb751fe1d
parent 125090 55b2d38ac36c986f3d76117be170f17e7dbde297
child 125092 b80437be0e7001991a34d5f7f6a66186c08858bd
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs820902
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 820902. nsAttrValue::Equals should do ASCII-case-insensitive compares when it's doing case-insensitive compares. r=sicking
content/base/src/nsAttrValue.cpp
layout/reftests/css-selectors/attr-case-insensitive-1-ref.html
layout/reftests/css-selectors/attr-case-insensitive-1.html
layout/reftests/css-selectors/reftest.list
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -1061,34 +1061,35 @@ nsAttrValue::Equals(const nsAString& aVa
   switch (BaseType()) {
     case eStringBase:
     {
       nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
       if (str) {
         nsDependentString dep(static_cast<PRUnichar*>(str->Data()),
                               str->StorageSize()/sizeof(PRUnichar) - 1);
         return aCaseSensitive == eCaseMatters ? aValue.Equals(dep) :
-          aValue.Equals(dep, nsCaseInsensitiveStringComparator());
+          nsContentUtils::EqualsIgnoreASCIICase(aValue, dep);
       }
       return aValue.IsEmpty();
     }
     case eAtomBase:
       if (aCaseSensitive == eCaseMatters) {
         return static_cast<nsIAtom*>(GetPtr())->Equals(aValue);
       }
-      return nsDependentAtomString(static_cast<nsIAtom*>(GetPtr())).
-        Equals(aValue, nsCaseInsensitiveStringComparator());
+      return nsContentUtils::EqualsIgnoreASCIICase(
+          nsDependentAtomString(static_cast<nsIAtom*>(GetPtr())),
+          aValue);
     default:
       break;
   }
 
   nsAutoString val;
   ToString(val);
   return aCaseSensitive == eCaseMatters ? val.Equals(aValue) :
-    val.Equals(aValue, nsCaseInsensitiveStringComparator());
+    nsContentUtils::EqualsIgnoreASCIICase(val, aValue);
 }
 
 bool
 nsAttrValue::Equals(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const
 {
   if (aCaseSensitive != eCaseMatters) {
     // Need a better way to handle this!
     nsAutoString value;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-selectors/attr-case-insensitive-1-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<style type="text/css">
+.ascii > span {
+  background-color: yellow;
+}
+</style>
+</head>
+<body>
+
+<div class="ascii"><span lang="paSSfield-killroyß">case-sensitive</span></div>
+<div class="ascii"><span lang="passfield-killroyß">lowercase</span></div>
+<div class="ascii"><span lang="PASSFIELD-KILLROYß">uppercase</span></div>
+<div class="nonascii"><span lang="paſſfield-killroyß">small long s (C)</span></div>
+<div class="nonascii"><span lang="passfield-&#x212a;illroyß">kelvin sign (C)</span></div>
+<div class="nonascii"><span lang="paßfield-killroyß">small sharp s (F)</span></div>
+<div class="nonascii"><span lang="paẞfield-killroyß">capital sharp s (F)</span></div>
+<div class="nonascii"><span lang="passfield-killroyẞ">capital sharp s (S)</span></div>
+<div class="nonascii"><span lang="passfield-killroyß">fi ligature (U+fb01) (F)</span></div>
+<div class="nonascii"><span lang="passfıeld-killroyß"> dotless i (T)</span></div>
+<div class="nonascii"><span lang="passfİeld-killroyß">dotted I (T)</span></div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-selectors/attr-case-insensitive-1.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<style type="text/css">
+span[lang="paSSfield-killroyß"] {
+  background-color: yellow;
+}
+</style>
+</head>
+<body>
+
+<div class="ascii"><span lang="paSSfield-killroyß">case-sensitive</span></div>
+<div class="ascii"><span lang="passfield-killroyß">lowercase</span></div>
+<div class="ascii"><span lang="PASSFIELD-KILLROYß">uppercase</span></div>
+<div class="nonascii"><span lang="paſſfield-killroyß">small long s (C)</span></div>
+<div class="nonascii"><span lang="passfield-&#x212a;illroyß">kelvin sign (C)</span></div>
+<div class="nonascii"><span lang="paßfield-killroyß">small sharp s (F)</span></div>
+<div class="nonascii"><span lang="paẞfield-killroyß">capital sharp s (F)</span></div>
+<div class="nonascii"><span lang="passfield-killroyẞ">capital sharp s (S)</span></div>
+<div class="nonascii"><span lang="passfield-killroyß">fi ligature (U+fb01) (F)</span></div>
+<div class="nonascii"><span lang="passfıeld-killroyß"> dotless i (T)</span></div>
+<div class="nonascii"><span lang="passfİeld-killroyß">dotted I (T)</span></div>
+
+</body>
+</html>
--- a/layout/reftests/css-selectors/reftest.list
+++ b/layout/reftests/css-selectors/reftest.list
@@ -1,1 +1,2 @@
 == state-dependent-in-any.html state-dependent-in-any-ref.html
+== attr-case-insensitive-1.html attr-case-insensitive-1-ref.html