servo: Merge #17247 - stylo: Make all attribute selectors respect case insensitivity (from Manishearth:stylo-insensitive-selectors); r=SimonSapin
authorManish Goregaokar <manishearth@gmail.com>
Thu, 08 Jun 2017 17:26:45 -0700
changeset 411226 bbabea85e0aad084a64e2d0b4ca3aa1ace4fda5b
parent 411225 07a573e7aef39759c3a863c7ab4a974e50ebe1e0
child 411227 a43b9bebbc130260a86de84b06d0cf9f1add6796
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
bugs17247, 1364162
milestone55.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
servo: Merge #17247 - stylo: Make all attribute selectors respect case insensitivity (from Manishearth:stylo-insensitive-selectors); r=SimonSapin r=simonsapin https://bugzilla.mozilla.org/show_bug.cgi?id=1364162 Source-Repo: https://github.com/servo/servo Source-Revision: a6b3bf1517b8329e26c6b8dec84b294bf7d257be
servo/components/script/layout_wrapper.rs
servo/components/style/dom.rs
servo/components/style/gecko/generated/bindings.rs
servo/components/style/gecko/snapshot.rs
servo/components/style/gecko/wrapper.rs
--- a/servo/components/script/layout_wrapper.rs
+++ b/servo/components/script/layout_wrapper.rs
@@ -394,21 +394,16 @@ impl<'le> TElement for ServoLayoutElemen
         self.element.get_state_for_layout()
     }
 
     #[inline]
     fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool {
         self.get_attr(namespace, attr).is_some()
     }
 
-    #[inline]
-    fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, val: &Atom) -> bool {
-        self.get_attr(namespace, attr).map_or(false, |x| x == val)
-    }
-
     #[inline(always)]
     fn each_class<F>(&self, mut callback: F) where F: FnMut(&Atom) {
         unsafe {
             if let Some(ref classes) = self.element.get_classes_for_layout() {
                 for class in *classes {
                     callback(class)
                 }
             }
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -363,19 +363,16 @@ pub trait TElement : Eq + PartialEq + De
     }
 
     /// Get this element's state, for non-tree-structural pseudos.
     fn get_state(&self) -> ElementState;
 
     /// Whether this element has an attribute with a given namespace.
     fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
 
-    /// Whether an attribute value equals `value`.
-    fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool;
-
     /// Internal iterator for the classes of this element.
     fn each_class<F>(&self, callback: F) where F: FnMut(&Atom);
 
     /// Get the pre-existing style to calculate restyle damage (change hints).
     ///
     /// This needs to be generic since it varies between Servo and Gecko.
     ///
     /// XXX(emilio): It's a bit unfortunate we need to pass the current computed
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -614,37 +614,38 @@ extern "C" {
 extern "C" {
     pub fn Gecko_AttrEquals(element: RawGeckoElementBorrowed,
                             ns: *mut nsIAtom, name: *mut nsIAtom,
                             str: *mut nsIAtom, ignoreCase: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_AttrDashEquals(element: RawGeckoElementBorrowed,
                                 ns: *mut nsIAtom, name: *mut nsIAtom,
-                                str: *mut nsIAtom) -> bool;
+                                str: *mut nsIAtom, ignore_case: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_AttrIncludes(element: RawGeckoElementBorrowed,
                               ns: *mut nsIAtom, name: *mut nsIAtom,
-                              str: *mut nsIAtom) -> bool;
+                              str: *mut nsIAtom, ignore_case: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_AttrHasSubstring(element: RawGeckoElementBorrowed,
                                   ns: *mut nsIAtom, name: *mut nsIAtom,
-                                  str: *mut nsIAtom) -> bool;
+                                  str: *mut nsIAtom, ignore_case: bool)
+     -> bool;
 }
 extern "C" {
     pub fn Gecko_AttrHasPrefix(element: RawGeckoElementBorrowed,
                                ns: *mut nsIAtom, name: *mut nsIAtom,
-                               str: *mut nsIAtom) -> bool;
+                               str: *mut nsIAtom, ignore_case: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_AttrHasSuffix(element: RawGeckoElementBorrowed,
                                ns: *mut nsIAtom, name: *mut nsIAtom,
-                               str: *mut nsIAtom) -> bool;
+                               str: *mut nsIAtom, ignore_case: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_ClassOrClassList(element: RawGeckoElementBorrowed,
                                   class_: *mut *mut nsIAtom,
                                   classList: *mut *mut *mut nsIAtom) -> u32;
 }
 extern "C" {
     pub fn Gecko_SnapshotAtomAttrValue(element: *const ServoElementSnapshot,
@@ -664,39 +665,44 @@ extern "C" {
     pub fn Gecko_SnapshotAttrEquals(element: *const ServoElementSnapshot,
                                     ns: *mut nsIAtom, name: *mut nsIAtom,
                                     str: *mut nsIAtom, ignoreCase: bool)
      -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotAttrDashEquals(element: *const ServoElementSnapshot,
                                         ns: *mut nsIAtom, name: *mut nsIAtom,
-                                        str: *mut nsIAtom) -> bool;
+                                        str: *mut nsIAtom, ignore_case: bool)
+     -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotAttrIncludes(element: *const ServoElementSnapshot,
                                       ns: *mut nsIAtom, name: *mut nsIAtom,
-                                      str: *mut nsIAtom) -> bool;
+                                      str: *mut nsIAtom, ignore_case: bool)
+     -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotAttrHasSubstring(element:
                                               *const ServoElementSnapshot,
                                           ns: *mut nsIAtom,
                                           name: *mut nsIAtom,
-                                          str: *mut nsIAtom) -> bool;
+                                          str: *mut nsIAtom,
+                                          ignore_case: bool) -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotAttrHasPrefix(element: *const ServoElementSnapshot,
                                        ns: *mut nsIAtom, name: *mut nsIAtom,
-                                       str: *mut nsIAtom) -> bool;
+                                       str: *mut nsIAtom, ignore_case: bool)
+     -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotAttrHasSuffix(element: *const ServoElementSnapshot,
                                        ns: *mut nsIAtom, name: *mut nsIAtom,
-                                       str: *mut nsIAtom) -> bool;
+                                       str: *mut nsIAtom, ignore_case: bool)
+     -> bool;
 }
 extern "C" {
     pub fn Gecko_SnapshotClassOrClassList(element:
                                               *const ServoElementSnapshot,
                                           class_: *mut *mut nsIAtom,
                                           classList: *mut *mut *mut nsIAtom)
      -> u32;
 }
--- a/servo/components/style/gecko/snapshot.rs
+++ b/servo/components/style/gecko/snapshot.rs
@@ -89,40 +89,45 @@ impl GeckoElementSnapshot {
                             expected_value.as_ptr(),
                             ignore_case
                         ),
                         AttrSelectorOperator::Includes => bindings::Gecko_SnapshotAttrIncludes(
                             self,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::DashMatch => bindings::Gecko_SnapshotAttrDashEquals(
                             self,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Prefix => bindings::Gecko_SnapshotAttrHasPrefix(
                             self,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Suffix => bindings::Gecko_SnapshotAttrHasSuffix(
                             self,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Substring => bindings::Gecko_SnapshotAttrHasSubstring(
                             self,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                     }
                 }
             }
         }
     }
 }
 
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -721,27 +721,16 @@ impl<'le> TElement for GeckoElement<'le>
     fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool {
         unsafe {
             bindings::Gecko_HasAttr(self.0,
                                     namespace.0.as_ptr(),
                                     attr.as_ptr())
         }
     }
 
-    #[inline]
-    fn attr_equals(&self, namespace: &Namespace, attr: &Atom, val: &Atom) -> bool {
-        unsafe {
-            bindings::Gecko_AttrEquals(self.0,
-                                       namespace.0.as_ptr(),
-                                       attr.as_ptr(),
-                                       val.as_ptr(),
-                                       /* ignoreCase = */ false)
-        }
-    }
-
     fn each_class<F>(&self, callback: F)
         where F: FnMut(&Atom)
     {
         snapshot_helpers::each_class(self.0,
                                      callback,
                                      Gecko_ClassOrClassList)
     }
 
@@ -1350,40 +1339,45 @@ impl<'le> ::selectors::Element for Gecko
                             expected_value.as_ptr(),
                             ignore_case
                         ),
                         AttrSelectorOperator::Includes => bindings::Gecko_AttrIncludes(
                             self.0,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::DashMatch => bindings::Gecko_AttrDashEquals(
                             self.0,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Prefix => bindings::Gecko_AttrHasPrefix(
                             self.0,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Suffix => bindings::Gecko_AttrHasSuffix(
                             self.0,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                         AttrSelectorOperator::Substring => bindings::Gecko_AttrHasSubstring(
                             self.0,
                             ns.atom_or_null(),
                             local_name.as_ptr(),
                             expected_value.as_ptr(),
+                            ignore_case,
                         ),
                     }
                 }
             }
         }
     }
 
     fn is_root(&self) -> bool {