mirror of
https://github.com/servo/servo.git
synced 2025-06-14 19:34:29 +00:00
Implement binding support for returning and accepting Promises in WebIDL.
This commit is contained in:
parent
73b2963509
commit
a1091772ec
12 changed files with 217 additions and 20 deletions
|
@ -43,6 +43,7 @@ use std::intrinsics::type_name;
|
|||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use style::thread_state;
|
||||
|
||||
/// A traced reference to a DOM object
|
||||
|
@ -439,6 +440,18 @@ impl<T: Reflectable> LayoutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get an `&T` out of a `Rc<T>`
|
||||
pub trait RootedRcReference<T> {
|
||||
/// Obtain a safe reference to the wrapped non-JS owned value.
|
||||
fn r(&self) -> &T;
|
||||
}
|
||||
|
||||
impl<T: Reflectable> RootedRcReference<T> for Rc<T> {
|
||||
fn r(&self) -> &T {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
/// Get an `Option<&T>` out of an `Option<Root<T>>`
|
||||
pub trait RootedReference<T> {
|
||||
/// Obtain a safe optional reference to the wrapped JS owned-value that
|
||||
|
@ -446,6 +459,12 @@ pub trait RootedReference<T> {
|
|||
fn r(&self) -> Option<&T>;
|
||||
}
|
||||
|
||||
impl<T: Reflectable> RootedReference<T> for Option<Rc<T>> {
|
||||
fn r(&self) -> Option<&T> {
|
||||
self.as_ref().map(|root| &**root)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
|
||||
fn r(&self) -> Option<&T> {
|
||||
self.as_ref().map(|root| root.r())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue