From 618efc635750de6d7ec7d587e232fd257e2a3add Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Jun 2017 14:09:41 -0700 Subject: [PATCH 1/2] stylo: Remove TElement::attr_equals --- components/script/layout_wrapper.rs | 5 ----- components/style/dom.rs | 3 --- components/style/gecko/wrapper.rs | 11 ----------- 3 files changed, 19 deletions(-) diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index f7f5396dc8d..80f87eb8504 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -399,11 +399,6 @@ impl<'le> TElement for ServoLayoutElement<'le> { 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(&self, mut callback: F) where F: FnMut(&Atom) { unsafe { diff --git a/components/style/dom.rs b/components/style/dom.rs index 870690c2027..1d9462a6335 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -368,9 +368,6 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + /// 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(&self, callback: F) where F: FnMut(&Atom); diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index ba346d671c7..750cb8b5a53 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -726,17 +726,6 @@ impl<'le> TElement for GeckoElement<'le> { } } - #[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(&self, callback: F) where F: FnMut(&Atom) { From 5b86afd4f67152c29c04cdefe9c9d197f39688be Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 8 Jun 2017 14:09:41 -0700 Subject: [PATCH 2/2] stylo: Make all attribute selectors respect case insensitivity --- components/style/gecko/generated/bindings.rs | 26 ++++++++++++-------- components/style/gecko/snapshot.rs | 5 ++++ components/style/gecko/wrapper.rs | 5 ++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index a300dd8d3d4..a42bd753faa 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -619,27 +619,28 @@ extern "C" { 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, @@ -669,29 +670,34 @@ extern "C" { 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: diff --git a/components/style/gecko/snapshot.rs b/components/style/gecko/snapshot.rs index d238151fd9a..b2f7907a64a 100644 --- a/components/style/gecko/snapshot.rs +++ b/components/style/gecko/snapshot.rs @@ -94,30 +94,35 @@ impl GeckoElementSnapshot { 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, ), } } diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 750cb8b5a53..31a82df797a 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1352,30 +1352,35 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { 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, ), } }