mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Disambiguate methods without using trait objects
This commit is contained in:
parent
be9618d55b
commit
e894499c17
2 changed files with 63 additions and 9 deletions
|
@ -966,10 +966,22 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
|||
}
|
||||
}
|
||||
fn get_local_name<'b>(&'b self) -> &'b Atom {
|
||||
(self as &ElementHelpers).get_local_name()
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn get_local_name<'a, T: ElementHelpers<'a>>(this: T) -> &'a Atom {
|
||||
this.get_local_name()
|
||||
}
|
||||
|
||||
get_local_name(*self)
|
||||
}
|
||||
fn get_namespace<'b>(&'b self) -> &'b Namespace {
|
||||
(self as &ElementHelpers).get_namespace()
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn get_namespace<'a, T: ElementHelpers<'a>>(this: T) -> &'a Namespace {
|
||||
this.get_namespace()
|
||||
}
|
||||
|
||||
get_namespace(*self)
|
||||
}
|
||||
fn get_hover_state(&self) -> bool {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
|
@ -993,6 +1005,12 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
|||
node.get_enabled_state()
|
||||
}
|
||||
fn has_class(&self, name: &str) -> bool {
|
||||
(self as &AttributeHandlers).has_class(name)
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn has_class<T: AttributeHandlers>(this: T, name: &str) -> bool {
|
||||
this.has_class(name)
|
||||
}
|
||||
|
||||
has_class(*self, name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2036,27 +2036,63 @@ impl<'a> VirtualMethods for JSRef<'a, Node> {
|
|||
|
||||
impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
|
||||
fn parent_node(&self) -> Option<JSRef<'a, Node>> {
|
||||
(self as &NodeHelpers).parent_node().map(|node| *node.root())
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn parent_node<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> Option<Temporary<Node>> {
|
||||
this.parent_node()
|
||||
}
|
||||
|
||||
parent_node(*self).map(|node| *node.root())
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<JSRef<'a, Node>> {
|
||||
(self as &NodeHelpers).first_child().map(|node| *node.root())
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn first_child<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> Option<Temporary<Node>> {
|
||||
this.first_child()
|
||||
}
|
||||
|
||||
first_child(*self).map(|node| *node.root())
|
||||
}
|
||||
|
||||
fn prev_sibling(&self) -> Option<JSRef<'a, Node>> {
|
||||
(self as &NodeHelpers).prev_sibling().map(|node| *node.root())
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn prev_sibling<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> Option<Temporary<Node>> {
|
||||
this.prev_sibling()
|
||||
}
|
||||
|
||||
prev_sibling(*self).map(|node| *node.root())
|
||||
}
|
||||
|
||||
fn next_sibling(&self) -> Option<JSRef<'a, Node>> {
|
||||
(self as &NodeHelpers).next_sibling().map(|node| *node.root())
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn next_sibling<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> Option<Temporary<Node>> {
|
||||
this.next_sibling()
|
||||
}
|
||||
|
||||
next_sibling(*self).map(|node| *node.root())
|
||||
}
|
||||
|
||||
fn is_document(&self) -> bool {
|
||||
(self as &NodeHelpers).is_document()
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn is_document<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> bool {
|
||||
this.is_document()
|
||||
}
|
||||
|
||||
is_document(*self)
|
||||
}
|
||||
|
||||
fn is_element(&self) -> bool {
|
||||
(self as &NodeHelpers).is_element()
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn is_element<'a, 'b, T: NodeHelpers<'a, 'b>>(this: T) -> bool {
|
||||
this.is_element()
|
||||
}
|
||||
|
||||
is_element(*self)
|
||||
}
|
||||
|
||||
fn as_element(&self) -> JSRef<'a, Element> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue