mirror of
https://github.com/servo/servo.git
synced 2025-06-20 07:08:59 +01:00
Add a lifetime parameter to the ElementHelper trait
This refines the lifetime used in get_local_name / get_namespace and makes it independent of the lifetime on the &self parameter.
This commit is contained in:
parent
4ef0f39c78
commit
be9618d55b
1 changed files with 8 additions and 8 deletions
|
@ -237,26 +237,26 @@ impl LayoutElementHelpers for JS<Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ElementHelpers {
|
pub trait ElementHelpers<'a> {
|
||||||
fn html_element_in_html_document(self) -> bool;
|
fn html_element_in_html_document(self) -> bool;
|
||||||
fn get_local_name<'a>(&'a self) -> &'a Atom;
|
fn get_local_name(&self) -> &'a Atom;
|
||||||
fn get_namespace<'a>(&'a self) -> &'a Namespace;
|
fn get_namespace(&self) -> &'a Namespace;
|
||||||
fn summarize(self) -> Vec<AttrInfo>;
|
fn summarize(self) -> Vec<AttrInfo>;
|
||||||
fn is_void(self) -> bool;
|
fn is_void(self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ElementHelpers for JSRef<'a, Element> {
|
impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
|
||||||
fn html_element_in_html_document(self) -> bool {
|
fn html_element_in_html_document(self) -> bool {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
self.namespace == ns!(HTML) && node.is_in_html_doc()
|
self.namespace == ns!(HTML) && node.is_in_html_doc()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name<'a>(&'a self) -> &'a Atom {
|
fn get_local_name(&self) -> &'a Atom {
|
||||||
&self.deref().local_name
|
&self.extended_deref().local_name
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace<'a>(&'a self) -> &'a Namespace {
|
fn get_namespace(&self) -> &'a Namespace {
|
||||||
&self.deref().namespace
|
&self.extended_deref().namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summarize(self) -> Vec<AttrInfo> {
|
fn summarize(self) -> Vec<AttrInfo> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue