Change MutNullableJS<T> to MutNullableHeap<JS<T>>

This commit is contained in:
Anthony Ramine 2015-04-27 01:51:28 +02:00
parent 21c38d0de8
commit afafde5191
18 changed files with 176 additions and 173 deletions

View file

@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
use dom::bindings::codegen::InheritTypes::NodeCast; use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, MutNullableJS, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::js::{OptionalRootable, OptionalRootedRootable}; use dom::bindings::js::{OptionalRootable, OptionalRootedRootable};
use dom::bindings::js::RootedReference; use dom::bindings::js::RootedReference;
use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflector, reflect_dom_object};
@ -104,7 +104,7 @@ pub struct Attr {
prefix: Option<DOMString>, prefix: Option<DOMString>,
/// the element that owns this attribute. /// the element that owns this attribute.
owner: MutNullableJS<Element>, owner: MutNullableHeap<JS<Element>>,
} }
impl Attr { impl Attr {
@ -117,7 +117,7 @@ impl Attr {
name: name, name: name,
namespace: namespace, namespace: namespace,
prefix: prefix, prefix: prefix,
owner: MutNullableJS::new(owner), owner: MutNullableHeap::new(owner.map(JS::from_rooted)),
} }
} }
@ -271,11 +271,11 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
} }
(old, new) => assert!(old == new) (old, new) => assert!(old == new)
} }
self.owner.assign(owner) self.owner.set(owner.map(JS::from_rooted))
} }
fn owner(self) -> Option<Temporary<Element>> { fn owner(self) -> Option<Temporary<Element>> {
self.owner.get() self.owner.get().map(Temporary::new)
} }
fn summarize(self) -> AttrInfo { fn summarize(self) -> AttrInfo {

View file

@ -339,54 +339,50 @@ impl<T: HeapGCValue+Copy> MutHeap<T> {
} }
} }
/// A mutable `JS<T>` value, with nullability represented by an enclosing /// A mutable holder for GC-managed values such as `JSval` and `JS<T>`, with
/// Option wrapper. Must be used in place of traditional internal mutability /// nullability represented by an enclosing Option wrapper. Must be used in
/// to ensure that the proper GC barriers are enforced. /// place of traditional internal mutability to ensure that the proper GC
/// barriers are enforced.
#[must_root] #[must_root]
#[jstraceable] #[jstraceable]
pub struct MutNullableJS<T: Reflectable> { pub struct MutNullableHeap<T: HeapGCValue+Copy> {
ptr: Cell<Option<JS<T>>> ptr: Cell<Option<T>>
} }
impl<U: Reflectable> MutNullableJS<U> { impl<T: HeapGCValue+Copy> MutNullableHeap<T> {
/// Create a new `MutNullableJS` /// Create a new `MutNullableHeap`.
pub fn new<T: Assignable<U>>(initial: Option<T>) -> MutNullableJS<U> { pub fn new(initial: Option<T>) -> MutNullableHeap<T> {
MutNullableJS { MutNullableHeap {
ptr: Cell::new(initial.map(|initial| { ptr: Cell::new(initial)
unsafe { initial.get_js() }
}))
} }
} }
}
impl<T: Reflectable> Default for MutNullableJS<T> { /// Set this `MutNullableHeap` to the given value, calling write barriers
fn default() -> MutNullableJS<T> { /// as appropriate.
MutNullableJS { pub fn set(&self, val: Option<T>) {
ptr: Cell::new(None) self.ptr.set(val);
}
}
}
impl<T: Reflectable> MutNullableJS<T> {
/// Store an unrooted value in this field. This is safe under the
/// assumption that `MutNullableJS<T>` values are only used as fields in
/// DOM types that are reachable in the GC graph, so this unrooted value
/// becomes transitively rooted for the lifetime of its new owner.
pub fn assign<U: Assignable<T>>(&self, val: Option<U>) {
self.ptr.set(val.map(|val| {
unsafe { val.get_js() }
}));
}
/// Set the inner value to null, without making API users jump through
/// useless type-ascription hoops.
pub fn clear(&self) {
self.assign(None::<JS<T>>);
} }
/// Retrieve a copy of the current optional inner value. /// Retrieve a copy of the current optional inner value.
pub fn get(&self) -> Option<Temporary<T>> { pub fn get(&self) -> Option<T> {
self.ptr.get().map(Temporary::new) self.ptr.get()
}
}
impl<T: Reflectable> MutNullableHeap<JS<T>> {
/// Retrieve a copy of the current inner value. If it is `None`, it is
/// initialized with the result of `cb` first.
pub fn or_init<F>(&self, cb: F) -> Temporary<T>
where F: FnOnce() -> Temporary<T>
{
match self.get() {
Some(inner) => Temporary::new(inner),
None => {
let inner = cb();
self.set(Some(JS::from_rooted(inner.clone())));
inner
},
}
} }
/// Retrieve a copy of the inner optional `JS<T>` as `LayoutJS<T>`. /// Retrieve a copy of the inner optional `JS<T>` as `LayoutJS<T>`.
@ -394,19 +390,12 @@ impl<T: Reflectable> MutNullableJS<T> {
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> { pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
self.ptr.get().map(|js| js.to_layout()) self.ptr.get().map(|js| js.to_layout())
} }
}
/// Retrieve a copy of the current inner value. If it is `None`, it is impl<T: HeapGCValue+Copy> Default for MutNullableHeap<T> {
/// initialized with the result of `cb` first. fn default() -> MutNullableHeap<T> {
pub fn or_init<F>(&self, cb: F) -> Temporary<T> MutNullableHeap {
where F: FnOnce() -> Temporary<T> ptr: Cell::new(None)
{
match self.get() {
Some(inner) => inner,
None => {
let inner = cb();
self.assign(Some(inner.clone()));
inner
},
} }
} }
} }

View file

@ -24,8 +24,10 @@ use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{NotSupported, InvalidCharacter, Security}; use dom::bindings::error::Error::{NotSupported, InvalidCharacter, Security};
use dom::bindings::error::Error::HierarchyRequest; use dom::bindings::error::Error::HierarchyRequest;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable}; use dom::bindings::js::{JS, JSRef, LayoutJS, MutNullableHeap};
use dom::bindings::js::{OptionalRootable, RootedReference}; use dom::bindings::js::{OptionalRootable, OptionalRootedRootable};
use dom::bindings::js::{RootedReference, Temporary};
use dom::bindings::js::TemporaryPushable;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::bindings::trace::RootedVec; use dom::bindings::trace::RootedVec;
use dom::bindings::utils::reflect_dom_object; use dom::bindings::utils::reflect_dom_object;
@ -102,28 +104,28 @@ pub struct Document {
node: Node, node: Node,
window: JS<Window>, window: JS<Window>,
idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>, idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
implementation: MutNullableJS<DOMImplementation>, implementation: MutNullableHeap<JS<DOMImplementation>>,
location: MutNullableJS<Location>, location: MutNullableHeap<JS<Location>>,
content_type: DOMString, content_type: DOMString,
last_modified: Option<DOMString>, last_modified: Option<DOMString>,
encoding_name: DOMRefCell<DOMString>, encoding_name: DOMRefCell<DOMString>,
is_html_document: bool, is_html_document: bool,
url: Url, url: Url,
quirks_mode: Cell<QuirksMode>, quirks_mode: Cell<QuirksMode>,
images: MutNullableJS<HTMLCollection>, images: MutNullableHeap<JS<HTMLCollection>>,
embeds: MutNullableJS<HTMLCollection>, embeds: MutNullableHeap<JS<HTMLCollection>>,
links: MutNullableJS<HTMLCollection>, links: MutNullableHeap<JS<HTMLCollection>>,
forms: MutNullableJS<HTMLCollection>, forms: MutNullableHeap<JS<HTMLCollection>>,
scripts: MutNullableJS<HTMLCollection>, scripts: MutNullableHeap<JS<HTMLCollection>>,
anchors: MutNullableJS<HTMLCollection>, anchors: MutNullableHeap<JS<HTMLCollection>>,
applets: MutNullableJS<HTMLCollection>, applets: MutNullableHeap<JS<HTMLCollection>>,
ready_state: Cell<DocumentReadyState>, ready_state: Cell<DocumentReadyState>,
/// The element that has most recently requested focus for itself. /// The element that has most recently requested focus for itself.
possibly_focused: MutNullableJS<Element>, possibly_focused: MutNullableHeap<JS<Element>>,
/// The element that currently has the document focus context. /// The element that currently has the document focus context.
focused: MutNullableJS<Element>, focused: MutNullableHeap<JS<Element>>,
/// The script element that is currently executing. /// The script element that is currently executing.
current_script: MutNullableJS<HTMLScriptElement>, current_script: MutNullableHeap<JS<HTMLScriptElement>>,
/// https://html.spec.whatwg.org/multipage/#concept-n-noscript /// https://html.spec.whatwg.org/multipage/#concept-n-noscript
/// True if scripting is enabled for all scripts in this document /// True if scripting is enabled for all scripts in this document
scripting_enabled: Cell<bool>, scripting_enabled: Cell<bool>,
@ -440,19 +442,19 @@ 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() self.focused.get().map(Temporary::new)
} }
/// 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
/// `request_focus` before `commit_focus_transaction` is called will receive focus. /// `request_focus` before `commit_focus_transaction` is called will receive focus.
fn begin_focus_transaction(self) { fn begin_focus_transaction(self) {
self.possibly_focused.clear(); self.possibly_focused.set(None);
} }
/// Request that the given element receive focus once the current transaction is complete. /// Request that the given element receive focus once the current transaction is complete.
fn request_focus(self, elem: JSRef<Element>) { fn request_focus(self, elem: JSRef<Element>) {
if elem.is_focusable_area() { if elem.is_focusable_area() {
self.possibly_focused.assign(Some(elem)) self.possibly_focused.set(Some(JS::from_rooted(elem)))
} }
} }
@ -466,7 +468,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
node.set_focus_state(false); node.set_focus_state(false);
} }
self.focused.assign(self.possibly_focused.get()); self.focused.set(self.possibly_focused.get());
if let Some(ref elem) = self.focused.get().root() { if let Some(ref elem) = self.focused.get().root() {
let node: JSRef<Node> = NodeCast::from_ref(elem.r()); let node: JSRef<Node> = NodeCast::from_ref(elem.r());
@ -741,7 +743,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
} }
fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) { fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) {
self.current_script.assign(script); self.current_script.set(script.map(JS::from_rooted));
} }
fn trigger_mozbrowser_event(self, event: MozBrowserEvent) { fn trigger_mozbrowser_event(self, event: MozBrowserEvent) {
@ -1250,7 +1252,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() self.current_script.get().map(Temporary::new)
} }
// https://html.spec.whatwg.org/#dom-document-body // https://html.spec.whatwg.org/#dom-document-body

View file

@ -27,8 +27,9 @@ use dom::bindings::codegen::UnionTypes::NodeOrString;
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{InvalidCharacter, Syntax}; use dom::bindings::error::Error::{InvalidCharacter, Syntax};
use dom::bindings::error::Error::NoModificationAllowed; use dom::bindings::error::Error::NoModificationAllowed;
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable}; use dom::bindings::js::{JS, JSRef, LayoutJS, MutNullableHeap};
use dom::bindings::js::{OptionalRootable, RootedReference}; use dom::bindings::js::{OptionalRootable, RootedReference, Temporary};
use dom::bindings::js::TemporaryPushable;
use dom::bindings::trace::RootedVec; use dom::bindings::trace::RootedVec;
use dom::bindings::utils::{xml_name_type, validate_and_extract}; use dom::bindings::utils::{xml_name_type, validate_and_extract};
use dom::bindings::utils::XMLName::InvalidXMLName; use dom::bindings::utils::XMLName::InvalidXMLName;
@ -88,8 +89,8 @@ pub struct Element {
prefix: Option<DOMString>, prefix: Option<DOMString>,
attrs: DOMRefCell<Vec<JS<Attr>>>, attrs: DOMRefCell<Vec<JS<Attr>>>,
style_attribute: DOMRefCell<Option<PropertyDeclarationBlock>>, style_attribute: DOMRefCell<Option<PropertyDeclarationBlock>>,
attr_list: MutNullableJS<NamedNodeMap>, attr_list: MutNullableHeap<JS<NamedNodeMap>>,
class_list: MutNullableJS<DOMTokenList>, class_list: MutNullableHeap<JS<DOMTokenList>>,
} }
impl ElementDerived for EventTarget { impl ElementDerived for EventTarget {

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods}; use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::eventtarget::{EventTarget, EventTargetHelpers}; use dom::eventtarget::{EventTarget, EventTargetHelpers};
use util::str::DOMString; use util::str::DOMString;
@ -58,8 +58,8 @@ pub enum EventCancelable {
pub struct Event { pub struct Event {
reflector_: Reflector, reflector_: Reflector,
type_id: EventTypeId, type_id: EventTypeId,
current_target: MutNullableJS<EventTarget>, current_target: MutNullableHeap<JS<EventTarget>>,
target: MutNullableJS<EventTarget>, target: MutNullableHeap<JS<EventTarget>>,
type_: DOMRefCell<DOMString>, type_: DOMRefCell<DOMString>,
phase: Cell<EventPhase>, phase: Cell<EventPhase>,
canceled: Cell<bool>, canceled: Cell<bool>,
@ -124,17 +124,17 @@ impl Event {
#[inline] #[inline]
pub fn clear_current_target(&self) { pub fn clear_current_target(&self) {
self.current_target.clear(); self.current_target.set(None);
} }
#[inline] #[inline]
pub fn set_current_target(&self, val: JSRef<EventTarget>) { pub fn set_current_target(&self, val: JSRef<EventTarget>) {
self.current_target.assign(Some(val)); self.current_target.set(Some(JS::from_rooted(val)));
} }
#[inline] #[inline]
pub fn set_target(&self, val: JSRef<EventTarget>) { pub fn set_target(&self, val: JSRef<EventTarget>) {
self.target.assign(Some(val)); self.target.set(Some(JS::from_rooted(val)));
} }
#[inline] #[inline]
@ -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() self.target.get().map(Temporary::new)
} }
// 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() self.current_target.get().map(Temporary::new)
} }
// https://dom.spec.whatwg.org/#dom-event-defaultprevented // https://dom.spec.whatwg.org/#dom-event-defaultprevented
@ -248,7 +248,7 @@ impl<'a> EventMethods for JSRef<'a, Event> {
self.stop_immediate.set(false); self.stop_immediate.set(false);
self.canceled.set(false); self.canceled.set(false);
self.trusted.set(false); self.trusted.set(false);
self.target.clear(); self.target.set(None);
*self.type_.borrow_mut() = type_; *self.type_.borrow_mut() = type_;
self.bubbles.set(bubbles); self.bubbles.set(bubbles);
self.cancelable.set(cancelable); self.cancelable.set(cancelable);

View file

@ -13,7 +13,8 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLImageElementDerived}; use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLImageElementDerived};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
use dom::bindings::codegen::InheritTypes::{MouseEventCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{MouseEventCast, NodeCast};
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalRootable}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::js::OptionalRootable;
use dom::document::{Document, DocumentHelpers}; use dom::document::{Document, DocumentHelpers};
use dom::domtokenlist::DOMTokenList; use dom::domtokenlist::DOMTokenList;
use dom::element::{Element, AttributeHandlers, ElementTypeId}; use dom::element::{Element, AttributeHandlers, ElementTypeId};
@ -32,7 +33,7 @@ use util::str::DOMString;
#[dom_struct] #[dom_struct]
pub struct HTMLAnchorElement { pub struct HTMLAnchorElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
rel_list: MutNullableJS<DOMTokenList>, rel_list: MutNullableHeap<JS<DOMTokenList>>,
} }
impl HTMLAnchorElementDerived for EventTarget { impl HTMLAnchorElementDerived for EventTarget {

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods;
use dom::bindings::codegen::InheritTypes::{HTMLAreaElementDerived, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLAreaElementDerived, HTMLElementCast};
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use dom::bindings::js::{MutNullableJS, JSRef, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::utils::Reflectable; use dom::bindings::utils::Reflectable;
use dom::document::Document; use dom::document::Document;
use dom::domtokenlist::DOMTokenList; use dom::domtokenlist::DOMTokenList;
@ -24,7 +24,7 @@ use util::str::DOMString;
#[dom_struct] #[dom_struct]
pub struct HTMLAreaElement { pub struct HTMLAreaElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
rel_list: MutNullableJS<DOMTokenList>, rel_list: MutNullableHeap<JS<DOMTokenList>>,
} }
impl HTMLAreaElementDerived for EventTarget { impl HTMLAreaElementDerived for EventTarget {

View file

@ -11,7 +11,8 @@ use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRenderingContext; use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRenderingContext;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, LayoutJS, Temporary, Unrooted}; use dom::bindings::js::{JS, JSRef, LayoutJS, MutNullableHeap, Temporary};
use dom::bindings::js::Unrooted;
use dom::bindings::utils::{Reflectable}; use dom::bindings::utils::{Reflectable};
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers}; use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
use dom::document::Document; use dom::document::Document;
@ -37,8 +38,8 @@ const DEFAULT_HEIGHT: u32 = 150;
#[dom_struct] #[dom_struct]
pub struct HTMLCanvasElement { pub struct HTMLCanvasElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
context_2d: MutNullableJS<CanvasRenderingContext2D>, context_2d: MutNullableHeap<JS<CanvasRenderingContext2D>>,
context_webgl: MutNullableJS<WebGLRenderingContext>, context_webgl: MutNullableHeap<JS<WebGLRenderingContext>>,
width: Cell<u32>, width: Cell<u32>,
height: Cell<u32>, height: Cell<u32>,
} }
@ -192,11 +193,12 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
let window = window_from_node(self).root(); let window = window_from_node(self).root();
let size = self.get_size(); let size = self.get_size();
self.context_webgl.assign(WebGLRenderingContext::new(GlobalRef::Window(window.r()), self, size)) self.context_webgl.set(
WebGLRenderingContext::new(GlobalRef::Window(window.r()), self, size).map(JS::from_rooted))
} }
self.context_webgl.get().map( |ctx| self.context_webgl.get().map( |ctx|
CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext(Unrooted::from_temporary(ctx))) CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext(Unrooted::from_js(ctx)))
} }
_ => None _ => None
} }

View file

@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived};
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLInputElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLInputElementCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{HTMLElementDerived, HTMLBodyElementDerived}; use dom::bindings::codegen::InheritTypes::{HTMLElementDerived, HTMLBodyElementDerived};
use dom::bindings::js::{JSRef, Temporary, MutNullableJS}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::error::ErrorResult; use dom::bindings::error::ErrorResult;
use dom::bindings::error::Error::Syntax; use dom::bindings::error::Error::Syntax;
use dom::bindings::utils::Reflectable; use dom::bindings::utils::Reflectable;
@ -39,8 +39,8 @@ use std::default::Default;
#[dom_struct] #[dom_struct]
pub struct HTMLElement { pub struct HTMLElement {
element: Element, element: Element,
style_decl: MutNullableJS<CSSStyleDeclaration>, style_decl: MutNullableHeap<JS<CSSStyleDeclaration>>,
dataset: MutNullableJS<DOMStringMap>, dataset: MutNullableHeap<JS<DOMStringMap>>,
} }
impl HTMLElementDerived for EventTarget { impl HTMLElementDerived for EventTarget {

View file

@ -14,8 +14,9 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLInp
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived, EventTargetCast}; use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived, EventTargetCast};
use dom::bindings::codegen::InheritTypes::KeyboardEventCast; use dom::bindings::codegen::InheritTypes::KeyboardEventCast;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Comparable, JSRef, LayoutJS, Root, Temporary, OptionalRootable}; use dom::bindings::js::{Comparable, JS, JSRef, LayoutJS, MutNullableHeap};
use dom::bindings::js::{ResultRootable, RootedReference, MutNullableJS}; use dom::bindings::js::{OptionalRootable, OptionalRootedRootable};
use dom::bindings::js::{ResultRootable, Root, RootedReference, Temporary};
use dom::document::{Document, DocumentHelpers}; use dom::document::{Document, DocumentHelpers};
use dom::element::{AttributeHandlers, Element}; use dom::element::{AttributeHandlers, Element};
use dom::element::{RawLayoutElementHelpers, ActivationElementHelpers}; use dom::element::{RawLayoutElementHelpers, ActivationElementHelpers};
@ -80,7 +81,7 @@ struct InputActivationState {
indeterminate: bool, indeterminate: bool,
checked: bool, checked: bool,
checked_changed: bool, checked_changed: bool,
checked_radio: MutNullableJS<HTMLInputElement>, checked_radio: MutNullableHeap<JS<HTMLInputElement>>,
// In case mutability changed // In case mutability changed
was_mutable: bool, was_mutable: bool,
// In case the type changed // In case the type changed
@ -694,7 +695,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
r.r().Checked() r.r().Checked()
}) })
}; };
cache.checked_radio.assign(checked_member.r()); cache.checked_radio.set(checked_member.r().map(JS::from_rooted));
cache.checked_changed = self.checked_changed.get(); cache.checked_changed = self.checked_changed.get();
self.SetChecked(true); self.SetChecked(true);
} }

View file

@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived; use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalRootable}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::js::OptionalRootable;
use dom::document::Document; use dom::document::Document;
use dom::domtokenlist::DOMTokenList; use dom::domtokenlist::DOMTokenList;
use dom::element::{AttributeHandlers, Element}; use dom::element::{AttributeHandlers, Element};
@ -33,7 +34,7 @@ use string_cache::Atom;
#[dom_struct] #[dom_struct]
pub struct HTMLLinkElement { pub struct HTMLLinkElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
rel_list: MutNullableJS<DOMTokenList>, rel_list: MutNullableHeap<JS<DOMTokenList>>,
} }
impl HTMLLinkElementDerived for EventTarget { impl HTMLLinkElementDerived for EventTarget {

View file

@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
use dom::bindings::codegen::InheritTypes::{EventCast, UIEventCast, MouseEventDerived}; use dom::bindings::codegen::InheritTypes::{EventCast, UIEventCast, MouseEventDerived};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, RootedReference, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, RootedReference};
use dom::bindings::js::Temporary;
use dom::bindings::utils::reflect_dom_object; use dom::bindings::utils::reflect_dom_object;
use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable}; use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget; use dom::eventtarget::EventTarget;
@ -30,7 +31,7 @@ pub struct MouseEvent {
alt_key: Cell<bool>, alt_key: Cell<bool>,
meta_key: Cell<bool>, meta_key: Cell<bool>,
button: Cell<i16>, button: Cell<i16>,
related_target: MutNullableJS<EventTarget> related_target: MutNullableHeap<JS<EventTarget>>,
} }
impl MouseEventDerived for Event { impl MouseEventDerived for Event {
@ -142,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() self.related_target.get().map(Temporary::new)
} }
fn InitMouseEvent(self, fn InitMouseEvent(self,
@ -177,7 +178,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
self.shift_key.set(shiftKeyArg); self.shift_key.set(shiftKeyArg);
self.meta_key.set(metaKeyArg); self.meta_key.set(metaKeyArg);
self.button.set(buttonArg); self.button.set(buttonArg);
self.related_target.assign(relatedTargetArg); self.related_target.set(relatedTargetArg.map(JS::from_rooted));
} }
} }

View file

@ -24,9 +24,10 @@ use dom::bindings::conversions;
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{NotFound, HierarchyRequest, Syntax}; use dom::bindings::error::Error::{NotFound, HierarchyRequest, Syntax};
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, JSRef, LayoutJS, RootedReference, Temporary, Root, Unrooted}; use dom::bindings::js::{JS, JSRef, LayoutJS, OptionalRootable};
use dom::bindings::js::{TemporaryPushable, OptionalRootedRootable}; use dom::bindings::js::{OptionalRootedRootable, MutNullableHeap};
use dom::bindings::js::{ResultRootable, OptionalRootable, MutNullableJS}; use dom::bindings::js::{ResultRootable, Root, RootedReference, Temporary};
use dom::bindings::js::{TemporaryPushable, Unrooted};
use dom::bindings::trace::JSTraceable; use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::RootedVec; use dom::bindings::trace::RootedVec;
use dom::bindings::utils::{Reflectable, reflect_dom_object}; use dom::bindings::utils::{Reflectable, reflect_dom_object};
@ -85,25 +86,25 @@ pub struct Node {
type_id: NodeTypeId, type_id: NodeTypeId,
/// The parent of this node. /// The parent of this node.
parent_node: MutNullableJS<Node>, parent_node: MutNullableHeap<JS<Node>>,
/// The first child of this node. /// The first child of this node.
first_child: MutNullableJS<Node>, first_child: MutNullableHeap<JS<Node>>,
/// The last child of this node. /// The last child of this node.
last_child: MutNullableJS<Node>, last_child: MutNullableHeap<JS<Node>>,
/// The next sibling of this node. /// The next sibling of this node.
next_sibling: MutNullableJS<Node>, next_sibling: MutNullableHeap<JS<Node>>,
/// The previous sibling of this node. /// The previous sibling of this node.
prev_sibling: MutNullableJS<Node>, prev_sibling: MutNullableHeap<JS<Node>>,
/// The document that this node belongs to. /// The document that this node belongs to.
owner_doc: MutNullableJS<Document>, owner_doc: MutNullableHeap<JS<Document>>,
/// The live list of children return by .childNodes. /// The live list of children return by .childNodes.
child_list: MutNullableJS<NodeList>, child_list: MutNullableHeap<JS<NodeList>>,
/// A bitfield of flags for node items. /// A bitfield of flags for node items.
flags: Cell<NodeFlags>, flags: Cell<NodeFlags>,
@ -328,31 +329,31 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
match before.prev_sibling().root() { match before.prev_sibling().root() {
None => { None => {
assert!(Some(*before) == self.first_child().root().r()); assert!(Some(*before) == self.first_child().root().r());
self.first_child.assign(Some(new_child)); self.first_child.set(Some(JS::from_rooted(new_child)));
}, },
Some(prev_sibling) => { Some(prev_sibling) => {
prev_sibling.r().next_sibling.assign(Some(new_child)); prev_sibling.r().next_sibling.set(Some(JS::from_rooted(new_child)));
new_child.prev_sibling.assign(Some(prev_sibling.r())); new_child.prev_sibling.set(Some(JS::from_rooted(prev_sibling.r())));
}, },
} }
before.prev_sibling.assign(Some(new_child)); before.prev_sibling.set(Some(JS::from_rooted(new_child)));
new_child.next_sibling.assign(Some(*before)); new_child.next_sibling.set(Some(JS::from_rooted(*before)));
}, },
None => { None => {
match self.last_child().root() { match self.last_child().root() {
None => self.first_child.assign(Some(new_child)), None => self.first_child.set(Some(JS::from_rooted(new_child))),
Some(last_child) => { Some(last_child) => {
assert!(last_child.r().next_sibling().is_none()); assert!(last_child.r().next_sibling().is_none());
last_child.r().next_sibling.assign(Some(new_child)); last_child.r().next_sibling.set(Some(JS::from_rooted(new_child)));
new_child.prev_sibling.assign(Some(last_child.r())); new_child.prev_sibling.set(Some(JS::from_rooted(last_child.r())));
} }
} }
self.last_child.assign(Some(new_child)); self.last_child.set(Some(JS::from_rooted(new_child)));
}, },
} }
new_child.parent_node.assign(Some(self)); new_child.parent_node.set(Some(JS::from_rooted(self)));
} }
/// Removes the given child from this node's list of children. /// Removes the given child from this node's list of children.
@ -363,25 +364,25 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
match child.prev_sibling.get().root() { match child.prev_sibling.get().root() {
None => { None => {
self.first_child.assign(child.next_sibling.get()); self.first_child.set(child.next_sibling.get());
} }
Some(prev_sibling) => { Some(prev_sibling) => {
prev_sibling.r().next_sibling.assign(child.next_sibling.get()); prev_sibling.r().next_sibling.set(child.next_sibling.get());
} }
} }
match child.next_sibling.get().root() { match child.next_sibling.get().root() {
None => { None => {
self.last_child.assign(child.prev_sibling.get()); self.last_child.set(child.prev_sibling.get());
} }
Some(next_sibling) => { Some(next_sibling) => {
next_sibling.r().prev_sibling.assign(child.prev_sibling.get()); next_sibling.r().prev_sibling.set(child.prev_sibling.get());
} }
} }
child.prev_sibling.clear(); child.prev_sibling.set(None);
child.next_sibling.clear(); child.next_sibling.set(None);
child.parent_node.clear(); child.parent_node.set(None);
} }
} }
@ -569,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() self.parent_node.get().map(Temporary::new)
} }
fn first_child(self) -> Option<Temporary<Node>> { fn first_child(self) -> Option<Temporary<Node>> {
self.first_child.get() self.first_child.get().map(Temporary::new)
} }
fn last_child(self) -> Option<Temporary<Node>> { fn last_child(self) -> Option<Temporary<Node>> {
self.last_child.get() self.last_child.get().map(Temporary::new)
} }
/// 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() self.prev_sibling.get().map(Temporary::new)
} }
/// 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() self.next_sibling.get().map(Temporary::new)
} }
#[inline] #[inline]
@ -946,11 +947,11 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
} }
fn owner_doc(self) -> Temporary<Document> { fn owner_doc(self) -> Temporary<Document> {
self.owner_doc.get().unwrap() Temporary::new(self.owner_doc.get().unwrap())
} }
fn set_owner_doc(self, document: JSRef<Document>) { fn set_owner_doc(self, document: JSRef<Document>) {
self.owner_doc.assign(Some(document.clone())); self.owner_doc.set(Some(JS::from_rooted(document)));
} }
fn is_in_html_doc(self) -> bool { fn is_in_html_doc(self) -> bool {
@ -959,7 +960,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
fn children(self) -> NodeSiblingIterator { fn children(self) -> NodeSiblingIterator {
NodeSiblingIterator { NodeSiblingIterator {
current: self.first_child.get(), current: self.first_child(),
} }
} }
@ -1346,7 +1347,7 @@ impl Node {
last_child: Default::default(), last_child: Default::default(),
next_sibling: Default::default(), next_sibling: Default::default(),
prev_sibling: Default::default(), prev_sibling: Default::default(),
owner_doc: MutNullableJS::new(doc), owner_doc: MutNullableHeap::new(doc.map(JS::from_rooted)),
child_list: Default::default(), child_list: Default::default(),
flags: Cell::new(NodeFlags::new(type_id)), flags: Cell::new(NodeFlags::new(type_id)),
@ -1872,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() self.parent_node.get().map(Temporary::new)
} }
// https://dom.spec.whatwg.org/#dom-node-parentelement // https://dom.spec.whatwg.org/#dom-node-parentelement
@ -1902,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() self.first_child.get().map(Temporary::new)
} }
// 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() self.last_child.get().map(Temporary::new)
} }
// 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() self.prev_sibling.get().map(Temporary::new)
} }
// 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() self.next_sibling.get().map(Temporary::new)
} }
// https://dom.spec.whatwg.org/#dom-node-nodevalue // https://dom.spec.whatwg.org/#dom-node-nodevalue

View file

@ -10,7 +10,8 @@ use dom::bindings::codegen::Bindings::StorageEventBinding::{StorageEventMethods}
use dom::bindings::codegen::InheritTypes::{EventCast}; use dom::bindings::codegen::InheritTypes::{EventCast};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, RootedReference, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, RootedReference};
use dom::bindings::js::Temporary;
use dom::bindings::utils::{reflect_dom_object}; use dom::bindings::utils::{reflect_dom_object};
use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable}; use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable};
use dom::storage::Storage; use dom::storage::Storage;
@ -23,7 +24,7 @@ pub struct StorageEvent {
oldValue: DOMRefCell<Option<DOMString>>, oldValue: DOMRefCell<Option<DOMString>>,
newValue: DOMRefCell<Option<DOMString>>, newValue: DOMRefCell<Option<DOMString>>,
url: DOMRefCell<DOMString>, url: DOMRefCell<DOMString>,
storageArea: MutNullableJS<Storage> storageArea: MutNullableHeap<JS<Storage>>
} }
@ -40,7 +41,7 @@ impl StorageEvent {
oldValue: DOMRefCell::new(oldValue), oldValue: DOMRefCell::new(oldValue),
newValue: DOMRefCell::new(newValue), newValue: DOMRefCell::new(newValue),
url: DOMRefCell::new(url), url: DOMRefCell::new(url),
storageArea: MutNullableJS::new(storageArea) storageArea: MutNullableHeap::new(storageArea.map(JS::from_rooted))
} }
} }
@ -107,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() self.storageArea.get().map(Temporary::new)
} }
} }

View file

@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
use dom::bindings::codegen::InheritTypes::{EventCast, UIEventDerived}; use dom::bindings::codegen::InheritTypes::{EventCast, UIEventDerived};
use dom::bindings::error::Fallible; use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, RootedReference, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, RootedReference};
use dom::bindings::js::Temporary;
use dom::bindings::utils::reflect_dom_object; use dom::bindings::utils::reflect_dom_object;
use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable}; use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable};
@ -22,7 +23,7 @@ use std::default::Default;
#[dom_struct] #[dom_struct]
pub struct UIEvent { pub struct UIEvent {
event: Event, event: Event,
view: MutNullableJS<Window>, view: MutNullableHeap<JS<Window>>,
detail: Cell<i32> detail: Cell<i32>
} }
@ -73,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() self.view.get().map(Temporary::new)
} }
// 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
@ -93,7 +94,7 @@ impl<'a> UIEventMethods for JSRef<'a, UIEvent> {
} }
event.InitEvent(type_, can_bubble, cancelable); event.InitEvent(type_, can_bubble, cancelable);
self.view.assign(view); self.view.set(view.map(JS::from_rooted));
self.detail.set(detail); self.detail.set(detail);
} }
} }

View file

@ -13,7 +13,8 @@ use dom::bindings::global::global_object_for_js_object;
use dom::bindings::error::{report_pending_exception, Fallible}; use dom::bindings::error::{report_pending_exception, Fallible};
use dom::bindings::error::Error::InvalidCharacter; use dom::bindings::error::Error::InvalidCharacter;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalRootable, RootedReference}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, OptionalRootable};
use dom::bindings::js::{RootedReference, Temporary};
use dom::bindings::utils::{GlobalStaticData, Reflectable, WindowProxyHandler}; use dom::bindings::utils::{GlobalStaticData, Reflectable, WindowProxyHandler};
use dom::browsercontext::BrowserContext; use dom::browsercontext::BrowserContext;
use dom::console::Console; use dom::console::Console;
@ -87,19 +88,19 @@ pub struct Window {
eventtarget: EventTarget, eventtarget: EventTarget,
script_chan: Box<ScriptChan+Send>, script_chan: Box<ScriptChan+Send>,
control_chan: ScriptControlChan, control_chan: ScriptControlChan,
console: MutNullableJS<Console>, console: MutNullableHeap<JS<Console>>,
navigator: MutNullableJS<Navigator>, navigator: MutNullableHeap<JS<Navigator>>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
image_cache_chan: ImageCacheChan, image_cache_chan: ImageCacheChan,
compositor: DOMRefCell<Box<ScriptListener+'static>>, compositor: DOMRefCell<Box<ScriptListener+'static>>,
browser_context: DOMRefCell<Option<BrowserContext>>, browser_context: DOMRefCell<Option<BrowserContext>>,
page: Rc<Page>, page: Rc<Page>,
performance: MutNullableJS<Performance>, performance: MutNullableHeap<JS<Performance>>,
navigation_start: u64, navigation_start: u64,
navigation_start_precise: f64, navigation_start_precise: f64,
screen: MutNullableJS<Screen>, screen: MutNullableHeap<JS<Screen>>,
session_storage: MutNullableJS<Storage>, session_storage: MutNullableHeap<JS<Storage>>,
local_storage: MutNullableJS<Storage>, local_storage: MutNullableHeap<JS<Storage>>,
timers: TimerManager, timers: TimerManager,
next_worker_id: Cell<WorkerId>, next_worker_id: Cell<WorkerId>,

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::InheritTypes::DedicatedWorkerGlobalScopeCast;
use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{Syntax, Network, JSFailed}; use dom::bindings::error::Error::{Syntax, Network, JSFailed};
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, Temporary}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::utils::Reflectable; use dom::bindings::utils::Reflectable;
use dom::console::Console; use dom::console::Console;
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, DedicatedWorkerGlobalScopeHelpers}; use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, DedicatedWorkerGlobalScopeHelpers};
@ -48,9 +48,9 @@ pub struct WorkerGlobalScope {
js_context: Rc<Cx>, js_context: Rc<Cx>,
next_worker_id: Cell<WorkerId>, next_worker_id: Cell<WorkerId>,
resource_task: ResourceTask, resource_task: ResourceTask,
location: MutNullableJS<WorkerLocation>, location: MutNullableHeap<JS<WorkerLocation>>,
navigator: MutNullableJS<WorkerNavigator>, navigator: MutNullableHeap<JS<WorkerNavigator>>,
console: MutNullableJS<Console>, console: MutNullableHeap<JS<Console>>,
timers: TimerManager, timers: TimerManager,
devtools_chan: Option<DevtoolsControlChan>, devtools_chan: Option<DevtoolsControlChan>,
} }

View file

@ -14,7 +14,8 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::error::Error::{InvalidState, InvalidAccess}; use dom::bindings::error::Error::{InvalidState, InvalidAccess};
use dom::bindings::error::Error::{Network, Syntax, Security, Abort, Timeout}; use dom::bindings::error::Error::{Network, Syntax, Security, Abort, Timeout};
use dom::bindings::global::{GlobalField, GlobalRef, GlobalRoot}; use dom::bindings::global::{GlobalField, GlobalRef, GlobalRoot};
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, OptionalRootedRootable}; use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::js::OptionalRootedRootable;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::bindings::str::ByteString; use dom::bindings::str::ByteString;
use dom::bindings::utils::{Reflectable, reflect_dom_object}; use dom::bindings::utils::{Reflectable, reflect_dom_object};
@ -125,7 +126,7 @@ pub struct XMLHttpRequest {
status_text: DOMRefCell<ByteString>, status_text: DOMRefCell<ByteString>,
response: DOMRefCell<ByteString>, response: DOMRefCell<ByteString>,
response_type: Cell<XMLHttpRequestResponseType>, response_type: Cell<XMLHttpRequestResponseType>,
response_xml: MutNullableJS<Document>, response_xml: MutNullableHeap<JS<Document>>,
response_headers: DOMRefCell<Headers>, response_headers: DOMRefCell<Headers>,
// Associated concepts // Associated concepts
@ -710,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() self.response_xml.get().map(Temporary::new)
} }
} }