mirror of
https://github.com/servo/servo.git
synced 2025-06-14 11:24:33 +00:00
Give get_attr_for_layout a more useful signature.
This commit is contained in:
parent
e78683430f
commit
d67d6bfa3a
1 changed files with 3 additions and 4 deletions
|
@ -171,14 +171,14 @@ pub trait RawLayoutElementHelpers {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &Atom) -> Option<&'a JS<Attr>> {
|
unsafe fn get_attr_for_layout(elem: &Element, namespace: &Namespace, name: &Atom) -> Option<LayoutJS<Attr>> {
|
||||||
// cast to point to T in RefCell<T> directly
|
// cast to point to T in RefCell<T> directly
|
||||||
let attrs = elem.attrs.borrow_for_layout();
|
let attrs = elem.attrs.borrow_for_layout();
|
||||||
attrs.iter().find(|attr: & &JS<Attr>| {
|
attrs.iter().find(|attr: & &JS<Attr>| {
|
||||||
let attr = attr.to_layout().unsafe_get();
|
let attr = attr.to_layout().unsafe_get();
|
||||||
*name == (*attr).local_name_atom_forever() &&
|
*name == (*attr).local_name_atom_forever() &&
|
||||||
(*attr).namespace() == namespace
|
(*attr).namespace() == namespace
|
||||||
})
|
}).map(|attr| attr.to_layout())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -187,8 +187,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
|
unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
|
||||||
-> Option<&'a str> {
|
-> Option<&'a str> {
|
||||||
get_attr_for_layout(self, namespace, name).map(|attr| {
|
get_attr_for_layout(self, namespace, name).map(|attr| {
|
||||||
let attr = attr.to_layout().unsafe_get();
|
(*attr.unsafe_get()).value_ref_forever()
|
||||||
(*attr).value_ref_forever()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue