mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Remove Temporary::new()
Temporary::from_rooted() now takes an Assignable value.
This commit is contained in:
parent
2770886196
commit
1a30925cad
19 changed files with 45 additions and 48 deletions
|
@ -274,7 +274,7 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn owner(self) -> Option<Temporary<Element>> {
|
fn owner(self) -> Option<Temporary<Element>> {
|
||||||
self.owner.get().map(Temporary::new)
|
self.owner.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summarize(self) -> AttrInfo {
|
fn summarize(self) -> AttrInfo {
|
||||||
|
|
|
@ -153,14 +153,6 @@ impl<T> PartialEq for Temporary<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> Temporary<T> {
|
impl<T: Reflectable> Temporary<T> {
|
||||||
/// Create a new `Temporary` value from a JS-owned value.
|
|
||||||
pub fn new(inner: JS<T>) -> Temporary<T> {
|
|
||||||
Temporary {
|
|
||||||
inner: inner,
|
|
||||||
_js_ptr: inner.reflector().get_jsobject(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new `Temporary` value from an unrooted value.
|
/// Create a new `Temporary` value from an unrooted value.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn from_unrooted(unrooted: Unrooted<T>) -> Temporary<T> {
|
pub fn from_unrooted(unrooted: Unrooted<T>) -> Temporary<T> {
|
||||||
|
@ -171,8 +163,13 @@ impl<T: Reflectable> Temporary<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new `Temporary` value from a rooted value.
|
/// Create a new `Temporary` value from a rooted value.
|
||||||
pub fn from_rooted<'a>(root: JSRef<'a, T>) -> Temporary<T> {
|
#[allow(unrooted_must_root)]
|
||||||
Temporary::new(JS::from_rooted(root))
|
pub fn from_rooted<U: Assignable<T>>(root: U) -> Temporary<T> {
|
||||||
|
let inner = JS::from_rooted(root);
|
||||||
|
Temporary {
|
||||||
|
inner: inner,
|
||||||
|
_js_ptr: inner.reflector().get_jsobject(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +369,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||||
where F: FnOnce() -> Temporary<T>
|
where F: FnOnce() -> Temporary<T>
|
||||||
{
|
{
|
||||||
match self.get() {
|
match self.get() {
|
||||||
Some(inner) => Temporary::new(inner),
|
Some(inner) => Temporary::from_rooted(inner),
|
||||||
None => {
|
None => {
|
||||||
let inner = cb();
|
let inner = cb();
|
||||||
self.set(Some(JS::from_rooted(inner.clone())));
|
self.set(Some(JS::from_rooted(inner.clone())));
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl BrowserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_document(&self) -> Temporary<Document> {
|
pub fn active_document(&self) -> Temporary<Document> {
|
||||||
Temporary::new(self.history[self.active_index].document.clone())
|
Temporary::from_rooted(self.history[self.active_index].document.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_window(&self) -> Temporary<Window> {
|
pub fn active_window(&self) -> Temporary<Window> {
|
||||||
|
@ -59,7 +59,7 @@ impl BrowserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_element(&self) -> Option<Temporary<Element>> {
|
pub fn frame_element(&self) -> Option<Temporary<Element>> {
|
||||||
self.frame_element.map(Temporary::new)
|
self.frame_element.map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_proxy(&self) -> *mut JSObject {
|
pub fn window_proxy(&self) -> *mut JSObject {
|
||||||
|
|
|
@ -326,7 +326,7 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D
|
||||||
impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> {
|
impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
||||||
fn Canvas(self) -> Temporary<HTMLCanvasElement> {
|
fn Canvas(self) -> Temporary<HTMLCanvasElement> {
|
||||||
Temporary::new(self.canvas)
|
Temporary::from_rooted(self.canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
||||||
|
|
|
@ -242,7 +242,7 @@ pub trait DocumentHelpers<'a> {
|
||||||
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn window(self) -> Temporary<Window> {
|
fn window(self) -> Temporary<Window> {
|
||||||
Temporary::new(self.window)
|
Temporary::from_rooted(self.window)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -444,7 +444,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
/// Return the element that currently has focus.
|
/// Return the element that currently has focus.
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus
|
||||||
fn get_focused_element(self) -> Option<Temporary<Element>> {
|
fn get_focused_element(self) -> Option<Temporary<Element>> {
|
||||||
self.focused.get().map(Temporary::new)
|
self.focused.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initiate a new round of checking for elements requesting focus. The last element to call
|
/// Initiate a new round of checking for elements requesting focus. The last element to call
|
||||||
|
@ -1019,7 +1019,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
let id = Atom::from_slice(&id);
|
let id = Atom::from_slice(&id);
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let idmap = self.idmap.borrow();
|
let idmap = self.idmap.borrow();
|
||||||
idmap.get(&id).map(|ref elements| Temporary::new((*elements)[0].clone()))
|
idmap.get(&id).map(|ref elements| Temporary::from_rooted((*elements)[0].clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createelement
|
// https://dom.spec.whatwg.org/#dom-document-createelement
|
||||||
|
@ -1269,7 +1269,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-currentscript
|
// https://html.spec.whatwg.org/#dom-document-currentscript
|
||||||
fn GetCurrentScript(self) -> Option<Temporary<HTMLScriptElement>> {
|
fn GetCurrentScript(self) -> Option<Temporary<HTMLScriptElement>> {
|
||||||
self.current_script.get().map(Temporary::new)
|
self.current_script.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-body
|
// https://html.spec.whatwg.org/#dom-document-body
|
||||||
|
@ -1481,7 +1481,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
||||||
fn DefaultView(self) -> Temporary<Window> {
|
fn DefaultView(self) -> Temporary<Window> {
|
||||||
Temporary::new(self.window)
|
Temporary::from_rooted(self.window)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> DOMRectListMethods for JSRef<'a, DOMRectList> {
|
||||||
fn Item(self, index: u32) -> Option<Temporary<DOMRect>> {
|
fn Item(self, index: u32) -> Option<Temporary<DOMRect>> {
|
||||||
let rects = &self.rects;
|
let rects = &self.rects;
|
||||||
if index < rects.len() as u32 {
|
if index < rects.len() as u32 {
|
||||||
Some(Temporary::new(rects[index as usize].clone()))
|
Some(Temporary::from_rooted(rects[index as usize].clone()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,12 +188,12 @@ impl<'a> EventMethods for JSRef<'a, Event> {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-target
|
// https://dom.spec.whatwg.org/#dom-event-target
|
||||||
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
||||||
self.target.get().map(Temporary::new)
|
self.target.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||||
fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> {
|
fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> {
|
||||||
self.current_target.get().map(Temporary::new)
|
self.current_target.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
||||||
match self.collection {
|
match self.collection {
|
||||||
CollectionTypeId::Static(ref elems) => elems
|
CollectionTypeId::Static(ref elems) => elems
|
||||||
.get(index)
|
.get(index)
|
||||||
.map(|elem| Temporary::new(elem.clone())),
|
.map(|elem| Temporary::from_rooted(elem.clone())),
|
||||||
CollectionTypeId::Live(ref root, ref filter) => {
|
CollectionTypeId::Live(ref root, ref filter) => {
|
||||||
let root = root.root();
|
let root = root.root();
|
||||||
HTMLCollection::traverse(root.r())
|
HTMLCollection::traverse(root.r())
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetRelatedTarget(self) -> Option<Temporary<EventTarget>> {
|
fn GetRelatedTarget(self) -> Option<Temporary<EventTarget>> {
|
||||||
self.related_target.get().map(Temporary::new)
|
self.related_target.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn InitMouseEvent(self,
|
fn InitMouseEvent(self,
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> {
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
let attrs = owner.attrs();
|
let attrs = owner.attrs();
|
||||||
attrs.get(index as usize).map(|x| Temporary::new(x.clone()))
|
attrs.get(index as usize).map(|x| Temporary::from_rooted(x.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem
|
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem
|
||||||
|
|
|
@ -570,25 +570,25 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_node(self) -> Option<Temporary<Node>> {
|
fn parent_node(self) -> Option<Temporary<Node>> {
|
||||||
self.parent_node.get().map(Temporary::new)
|
self.parent_node.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_child(self) -> Option<Temporary<Node>> {
|
fn first_child(self) -> Option<Temporary<Node>> {
|
||||||
self.first_child.get().map(Temporary::new)
|
self.first_child.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_child(self) -> Option<Temporary<Node>> {
|
fn last_child(self) -> Option<Temporary<Node>> {
|
||||||
self.last_child.get().map(Temporary::new)
|
self.last_child.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the previous sibling of this node. Fails if this node is borrowed mutably.
|
/// Returns the previous sibling of this node. Fails if this node is borrowed mutably.
|
||||||
fn prev_sibling(self) -> Option<Temporary<Node>> {
|
fn prev_sibling(self) -> Option<Temporary<Node>> {
|
||||||
self.prev_sibling.get().map(Temporary::new)
|
self.prev_sibling.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the next sibling of this node. Fails if this node is borrowed mutably.
|
/// Returns the next sibling of this node. Fails if this node is borrowed mutably.
|
||||||
fn next_sibling(self) -> Option<Temporary<Node>> {
|
fn next_sibling(self) -> Option<Temporary<Node>> {
|
||||||
self.next_sibling.get().map(Temporary::new)
|
self.next_sibling.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -947,7 +947,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn owner_doc(self) -> Temporary<Document> {
|
fn owner_doc(self) -> Temporary<Document> {
|
||||||
Temporary::new(self.owner_doc.get().unwrap())
|
Temporary::from_rooted(self.owner_doc.get().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_owner_doc(self, document: JSRef<Document>) {
|
fn set_owner_doc(self, document: JSRef<Document>) {
|
||||||
|
@ -1873,7 +1873,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-parentnode
|
// https://dom.spec.whatwg.org/#dom-node-parentnode
|
||||||
fn GetParentNode(self) -> Option<Temporary<Node>> {
|
fn GetParentNode(self) -> Option<Temporary<Node>> {
|
||||||
self.parent_node.get().map(Temporary::new)
|
self.parent_node.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-parentelement
|
// https://dom.spec.whatwg.org/#dom-node-parentelement
|
||||||
|
@ -1903,22 +1903,22 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-firstchild
|
// https://dom.spec.whatwg.org/#dom-node-firstchild
|
||||||
fn GetFirstChild(self) -> Option<Temporary<Node>> {
|
fn GetFirstChild(self) -> Option<Temporary<Node>> {
|
||||||
self.first_child.get().map(Temporary::new)
|
self.first_child.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-lastchild
|
// https://dom.spec.whatwg.org/#dom-node-lastchild
|
||||||
fn GetLastChild(self) -> Option<Temporary<Node>> {
|
fn GetLastChild(self) -> Option<Temporary<Node>> {
|
||||||
self.last_child.get().map(Temporary::new)
|
self.last_child.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-previoussibling
|
// https://dom.spec.whatwg.org/#dom-node-previoussibling
|
||||||
fn GetPreviousSibling(self) -> Option<Temporary<Node>> {
|
fn GetPreviousSibling(self) -> Option<Temporary<Node>> {
|
||||||
self.prev_sibling.get().map(Temporary::new)
|
self.prev_sibling.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nextsibling
|
// https://dom.spec.whatwg.org/#dom-node-nextsibling
|
||||||
fn GetNextSibling(self) -> Option<Temporary<Node>> {
|
fn GetNextSibling(self) -> Option<Temporary<Node>> {
|
||||||
self.next_sibling.get().map(Temporary::new)
|
self.next_sibling.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
|
||||||
fn Item(self, index: u32) -> Option<Temporary<Node>> {
|
fn Item(self, index: u32) -> Option<Temporary<Node>> {
|
||||||
match self.list_type {
|
match self.list_type {
|
||||||
_ if index >= self.Length() => None,
|
_ if index >= self.Length() => None,
|
||||||
NodeListType::Simple(ref elems) => Some(Temporary::new(elems[index as usize].clone())),
|
NodeListType::Simple(ref elems) => Some(Temporary::from_rooted(elems[index as usize].clone())),
|
||||||
NodeListType::Children(ref node) => {
|
NodeListType::Children(ref node) => {
|
||||||
let node = node.root();
|
let node = node.root();
|
||||||
node.r().children().nth(index as usize)
|
node.r().children().nth(index as usize)
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl Performance {
|
||||||
|
|
||||||
impl<'a> PerformanceMethods for JSRef<'a, Performance> {
|
impl<'a> PerformanceMethods for JSRef<'a, Performance> {
|
||||||
fn Timing(self) -> Temporary<PerformanceTiming> {
|
fn Timing(self) -> Temporary<PerformanceTiming> {
|
||||||
Temporary::new(self.timing.clone())
|
Temporary::from_rooted(self.timing.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now
|
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl<'a> StorageEventMethods for JSRef<'a, StorageEvent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetStorageArea(self) -> Option<Temporary<Storage>> {
|
fn GetStorageArea(self) -> Option<Temporary<Storage>> {
|
||||||
self.storageArea.get().map(Temporary::new)
|
self.storageArea.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl TreeWalker {
|
||||||
impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> {
|
impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> {
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-root
|
// https://dom.spec.whatwg.org/#dom-treewalker-root
|
||||||
fn Root(self) -> Temporary<Node> {
|
fn Root(self) -> Temporary<Node> {
|
||||||
Temporary::new(self.root_node)
|
Temporary::from_rooted(self.root_node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-whattoshow
|
// https://dom.spec.whatwg.org/#dom-treewalker-whattoshow
|
||||||
|
@ -83,7 +83,7 @@ impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
||||||
fn CurrentNode(self) -> Temporary<Node> {
|
fn CurrentNode(self) -> Temporary<Node> {
|
||||||
Temporary::new(self.current_node.get())
|
Temporary::from_rooted(self.current_node.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl UIEvent {
|
||||||
impl<'a> UIEventMethods for JSRef<'a, UIEvent> {
|
impl<'a> UIEventMethods for JSRef<'a, UIEvent> {
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-view
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-view
|
||||||
fn GetView(self) -> Option<Temporary<Window>> {
|
fn GetView(self) -> Option<Temporary<Window>> {
|
||||||
self.view.get().map(Temporary::new)
|
self.view.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-detail
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-detail
|
||||||
|
|
|
@ -463,7 +463,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-upload-attribute
|
// https://xhr.spec.whatwg.org/#the-upload-attribute
|
||||||
fn Upload(self) -> Temporary<XMLHttpRequestUpload> {
|
fn Upload(self) -> Temporary<XMLHttpRequestUpload> {
|
||||||
Temporary::new(self.upload)
|
Temporary::from_rooted(self.upload)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-send()-method
|
// https://xhr.spec.whatwg.org/#the-send()-method
|
||||||
|
@ -711,7 +711,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsexml-attribute
|
// https://xhr.spec.whatwg.org/#the-responsexml-attribute
|
||||||
fn GetResponseXML(self) -> Option<Temporary<Document>> {
|
fn GetResponseXML(self) -> Option<Temporary<Document>> {
|
||||||
self.response_xml.get().map(Temporary::new)
|
self.response_xml.get().map(Temporary::from_rooted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window(&self) -> Temporary<Window> {
|
pub fn window(&self) -> Temporary<Window> {
|
||||||
Temporary::new(self.frame.borrow().as_ref().unwrap().window.clone())
|
Temporary::from_rooted(self.frame.borrow().as_ref().unwrap().window.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_for_script_deallocation(&self) -> Unrooted<Window> {
|
pub fn window_for_script_deallocation(&self) -> Unrooted<Window> {
|
||||||
|
@ -81,7 +81,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn document(&self) -> Temporary<Document> {
|
pub fn document(&self) -> Temporary<Document> {
|
||||||
Temporary::new(self.frame.borrow().as_ref().unwrap().document.clone())
|
Temporary::from_rooted(self.frame.borrow().as_ref().unwrap().document.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// must handle root case separately
|
// must handle root case separately
|
||||||
|
|
|
@ -63,7 +63,7 @@ trait SinkHelpers {
|
||||||
impl SinkHelpers for servohtmlparser::Sink {
|
impl SinkHelpers for servohtmlparser::Sink {
|
||||||
fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Temporary<Node> {
|
fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Temporary<Node> {
|
||||||
match child {
|
match child {
|
||||||
AppendNode(n) => Temporary::new(n),
|
AppendNode(n) => Temporary::from_rooted(n),
|
||||||
AppendText(t) => {
|
AppendText(t) => {
|
||||||
let doc = self.document.root();
|
let doc = self.document.root();
|
||||||
let text = Text::new(t, doc.r());
|
let text = Text::new(t, doc.r());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue