mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add Unrooted::from_js.
There should not be a JS here; that is #2661. Until that's fixed, though, it's better to encapsulate it.
This commit is contained in:
parent
b655b54f80
commit
8ab7d37ef2
2 changed files with 9 additions and 3 deletions
|
@ -83,6 +83,14 @@ impl<T: Reflectable> Unrooted<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new unrooted value from a `JS<T>`.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn from_js(ptr: JS<T>) -> Unrooted<T> {
|
||||
Unrooted {
|
||||
ptr: ptr.ptr
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `Reflector` for this pointer.
|
||||
pub fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||
unsafe {
|
||||
|
|
|
@ -88,9 +88,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
|||
match (*self.data.borrow())[name][0].clone() {
|
||||
FormDatum::StringData(ref s) => Some(eString(s.clone())),
|
||||
FormDatum::FileData(ref f) => {
|
||||
Some(eFile(unsafe {
|
||||
Unrooted::from_raw(f.unsafe_get())
|
||||
}))
|
||||
Some(eFile(Unrooted::from_js(*f)))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue