mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Upgrade rust-selectors.
This commit is contained in:
parent
364c8e2976
commit
1d8d1cb9d9
19 changed files with 280 additions and 174 deletions
|
@ -2217,6 +2217,34 @@ impl VirtualMethods for Element {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ::selectors::MatchAttrGeneric for Root<Element> {
|
||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
|
||||
where F: Fn(&str) -> bool
|
||||
{
|
||||
use ::selectors::Element;
|
||||
let local_name = {
|
||||
if self.is_html_element_in_html_document() {
|
||||
&attr.lower_name
|
||||
} else {
|
||||
&attr.name
|
||||
}
|
||||
};
|
||||
match attr.namespace {
|
||||
NamespaceConstraint::Specific(ref ns) => {
|
||||
self.get_attribute(ns, local_name)
|
||||
.map_or(false, |attr| {
|
||||
test(&attr.value())
|
||||
})
|
||||
},
|
||||
NamespaceConstraint::Any => {
|
||||
self.attrs.borrow().iter().any(|attr| {
|
||||
attr.local_name() == local_name && test(&attr.value())
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::selectors::Element for Root<Element> {
|
||||
type Impl = ServoSelectorImpl;
|
||||
|
||||
|
@ -2317,31 +2345,6 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
}
|
||||
}
|
||||
|
||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
|
||||
where F: Fn(&str) -> bool
|
||||
{
|
||||
let local_name = {
|
||||
if self.is_html_element_in_html_document() {
|
||||
&attr.lower_name
|
||||
} else {
|
||||
&attr.name
|
||||
}
|
||||
};
|
||||
match attr.namespace {
|
||||
NamespaceConstraint::Specific(ref ns) => {
|
||||
self.get_attribute(ns, local_name)
|
||||
.map_or(false, |attr| {
|
||||
test(&attr.value())
|
||||
})
|
||||
},
|
||||
NamespaceConstraint::Any => {
|
||||
self.attrs.borrow().iter().any(|attr| {
|
||||
attr.local_name() == local_name && test(&attr.value())
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
self.html_element_in_html_document()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue