Skip to content

Commit

Permalink
Auto merge of #17247 - Manishearth:stylo-insensitive-selectors, r=Sim…
Browse files Browse the repository at this point in the history
…onSapin

stylo: Make all attribute selectors respect case insensitivity

r=simonsapin https://bugzilla.mozilla.org/show_bug.cgi?id=1364162

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17247)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 9, 2017
2 parents 094c2c7 + 5b86afd commit a6b3bf1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
5 changes: 0 additions & 5 deletions components/script/layout_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(&self, mut callback: F) where F: FnMut(&Atom) {
unsafe {
Expand Down
3 changes: 0 additions & 3 deletions components/style/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(&self, callback: F) where F: FnMut(&Atom);

Expand Down
26 changes: 16 additions & 10 deletions components/style/gecko/generated/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions components/style/gecko/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
}
}
Expand Down
16 changes: 5 additions & 11 deletions components/style/gecko/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(&self, callback: F)
where F: FnMut(&Atom)
{
Expand Down Expand Up @@ -1355,30 +1344,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,
),
}
}
Expand Down

0 comments on commit a6b3bf1

Please sign in to comment.