зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #5862 - Change MutNullableJS<T> to MutNullableHeap<JS<T>> (from nox:mutnullableheap); r=jdm
This is useful for union types, in cases where we need MutNullableHeap<NodeOrString>. Source-Repo: https://github.com/servo/servo Source-Revision: b0ddd8149b04db6bceba0c0b8de852acc1086838
This commit is contained in:
Родитель
478a939a2f
Коммит
293fcb77e2
|
@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||
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::RootedReference;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
|
@ -104,7 +104,7 @@ pub struct Attr {
|
|||
prefix: Option<DOMString>,
|
||||
|
||||
/// the element that owns this attribute.
|
||||
owner: MutNullableJS<Element>,
|
||||
owner: MutNullableHeap<JS<Element>>,
|
||||
}
|
||||
|
||||
impl Attr {
|
||||
|
@ -117,7 +117,7 @@ impl Attr {
|
|||
name: name,
|
||||
namespace: namespace,
|
||||
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)
|
||||
}
|
||||
self.owner.assign(owner)
|
||||
self.owner.set(owner.map(JS::from_rooted))
|
||||
}
|
||||
|
||||
fn owner(self) -> Option<Temporary<Element>> {
|
||||
self.owner.get()
|
||||
self.owner.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
fn summarize(self) -> AttrInfo {
|
||||
|
|
|
@ -339,54 +339,50 @@ impl<T: HeapGCValue+Copy> MutHeap<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A mutable `JS<T>` value, with nullability represented by an enclosing
|
||||
/// Option wrapper. Must be used in place of traditional internal mutability
|
||||
/// to ensure that the proper GC barriers are enforced.
|
||||
/// A mutable holder for GC-managed values such as `JSval` and `JS<T>`, with
|
||||
/// nullability represented by an enclosing Option wrapper. Must be used in
|
||||
/// place of traditional internal mutability to ensure that the proper GC
|
||||
/// barriers are enforced.
|
||||
#[must_root]
|
||||
#[jstraceable]
|
||||
pub struct MutNullableJS<T: Reflectable> {
|
||||
ptr: Cell<Option<JS<T>>>
|
||||
pub struct MutNullableHeap<T: HeapGCValue+Copy> {
|
||||
ptr: Cell<Option<T>>
|
||||
}
|
||||
|
||||
impl<U: Reflectable> MutNullableJS<U> {
|
||||
/// Create a new `MutNullableJS`
|
||||
pub fn new<T: Assignable<U>>(initial: Option<T>) -> MutNullableJS<U> {
|
||||
MutNullableJS {
|
||||
ptr: Cell::new(initial.map(|initial| {
|
||||
unsafe { initial.get_js() }
|
||||
}))
|
||||
impl<T: HeapGCValue+Copy> MutNullableHeap<T> {
|
||||
/// Create a new `MutNullableHeap`.
|
||||
pub fn new(initial: Option<T>) -> MutNullableHeap<T> {
|
||||
MutNullableHeap {
|
||||
ptr: Cell::new(initial)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Reflectable> Default for MutNullableJS<T> {
|
||||
fn default() -> MutNullableJS<T> {
|
||||
MutNullableJS {
|
||||
ptr: Cell::new(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>>);
|
||||
/// Set this `MutNullableHeap` to the given value, calling write barriers
|
||||
/// as appropriate.
|
||||
pub fn set(&self, val: Option<T>) {
|
||||
self.ptr.set(val);
|
||||
}
|
||||
|
||||
/// Retrieve a copy of the current optional inner value.
|
||||
pub fn get(&self) -> Option<Temporary<T>> {
|
||||
self.ptr.get().map(Temporary::new)
|
||||
pub fn get(&self) -> Option<T> {
|
||||
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>`.
|
||||
|
@ -394,19 +390,12 @@ impl<T: Reflectable> MutNullableJS<T> {
|
|||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
|
||||
self.ptr.get().map(|js| js.to_layout())
|
||||
}
|
||||
}
|
||||
|
||||
/// 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) => inner,
|
||||
None => {
|
||||
let inner = cb();
|
||||
self.assign(Some(inner.clone()));
|
||||
inner
|
||||
},
|
||||
impl<T: HeapGCValue+Copy> Default for MutNullableHeap<T> {
|
||||
fn default() -> MutNullableHeap<T> {
|
||||
MutNullableHeap {
|
||||
ptr: Cell::new(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@ use dom::bindings::error::{ErrorResult, Fallible};
|
|||
use dom::bindings::error::Error::{NotSupported, InvalidCharacter, Security};
|
||||
use dom::bindings::error::Error::HierarchyRequest;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
|
||||
use dom::bindings::js::{OptionalRootable, RootedReference};
|
||||
use dom::bindings::js::{JS, JSRef, LayoutJS, MutNullableHeap};
|
||||
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::trace::RootedVec;
|
||||
use dom::bindings::utils::reflect_dom_object;
|
||||
|
@ -102,28 +104,28 @@ pub struct Document {
|
|||
node: Node,
|
||||
window: JS<Window>,
|
||||
idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
||||
implementation: MutNullableJS<DOMImplementation>,
|
||||
location: MutNullableJS<Location>,
|
||||
implementation: MutNullableHeap<JS<DOMImplementation>>,
|
||||
location: MutNullableHeap<JS<Location>>,
|
||||
content_type: DOMString,
|
||||
last_modified: Option<DOMString>,
|
||||
encoding_name: DOMRefCell<DOMString>,
|
||||
is_html_document: bool,
|
||||
url: Url,
|
||||
quirks_mode: Cell<QuirksMode>,
|
||||
images: MutNullableJS<HTMLCollection>,
|
||||
embeds: MutNullableJS<HTMLCollection>,
|
||||
links: MutNullableJS<HTMLCollection>,
|
||||
forms: MutNullableJS<HTMLCollection>,
|
||||
scripts: MutNullableJS<HTMLCollection>,
|
||||
anchors: MutNullableJS<HTMLCollection>,
|
||||
applets: MutNullableJS<HTMLCollection>,
|
||||
images: MutNullableHeap<JS<HTMLCollection>>,
|
||||
embeds: MutNullableHeap<JS<HTMLCollection>>,
|
||||
links: MutNullableHeap<JS<HTMLCollection>>,
|
||||
forms: MutNullableHeap<JS<HTMLCollection>>,
|
||||
scripts: MutNullableHeap<JS<HTMLCollection>>,
|
||||
anchors: MutNullableHeap<JS<HTMLCollection>>,
|
||||
applets: MutNullableHeap<JS<HTMLCollection>>,
|
||||
ready_state: Cell<DocumentReadyState>,
|
||||
/// 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.
|
||||
focused: MutNullableJS<Element>,
|
||||
focused: MutNullableHeap<JS<Element>>,
|
||||
/// 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
|
||||
/// True if scripting is enabled for all scripts in this document
|
||||
scripting_enabled: Cell<bool>,
|
||||
|
@ -440,19 +442,19 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
/// Return the element that currently has 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>> {
|
||||
self.focused.get()
|
||||
self.focused.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
/// 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.
|
||||
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.
|
||||
fn request_focus(self, elem: JSRef<Element>) {
|
||||
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);
|
||||
}
|
||||
|
||||
self.focused.assign(self.possibly_focused.get());
|
||||
self.focused.set(self.possibly_focused.get());
|
||||
|
||||
if let Some(ref elem) = self.focused.get().root() {
|
||||
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>>) {
|
||||
self.current_script.assign(script);
|
||||
self.current_script.set(script.map(JS::from_rooted));
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
@ -27,8 +27,9 @@ use dom::bindings::codegen::UnionTypes::NodeOrString;
|
|||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{InvalidCharacter, Syntax};
|
||||
use dom::bindings::error::Error::NoModificationAllowed;
|
||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
|
||||
use dom::bindings::js::{OptionalRootable, RootedReference};
|
||||
use dom::bindings::js::{JS, JSRef, LayoutJS, MutNullableHeap};
|
||||
use dom::bindings::js::{OptionalRootable, RootedReference, Temporary};
|
||||
use dom::bindings::js::TemporaryPushable;
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::{xml_name_type, validate_and_extract};
|
||||
use dom::bindings::utils::XMLName::InvalidXMLName;
|
||||
|
@ -88,8 +89,8 @@ pub struct Element {
|
|||
prefix: Option<DOMString>,
|
||||
attrs: DOMRefCell<Vec<JS<Attr>>>,
|
||||
style_attribute: DOMRefCell<Option<PropertyDeclarationBlock>>,
|
||||
attr_list: MutNullableJS<NamedNodeMap>,
|
||||
class_list: MutNullableJS<DOMTokenList>,
|
||||
attr_list: MutNullableHeap<JS<NamedNodeMap>>,
|
||||
class_list: MutNullableHeap<JS<DOMTokenList>>,
|
||||
}
|
||||
|
||||
impl ElementDerived for EventTarget {
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::EventBinding;
|
|||
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
|
||||
use dom::bindings::error::Fallible;
|
||||
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::eventtarget::{EventTarget, EventTargetHelpers};
|
||||
use util::str::DOMString;
|
||||
|
@ -58,8 +58,8 @@ pub enum EventCancelable {
|
|||
pub struct Event {
|
||||
reflector_: Reflector,
|
||||
type_id: EventTypeId,
|
||||
current_target: MutNullableJS<EventTarget>,
|
||||
target: MutNullableJS<EventTarget>,
|
||||
current_target: MutNullableHeap<JS<EventTarget>>,
|
||||
target: MutNullableHeap<JS<EventTarget>>,
|
||||
type_: DOMRefCell<DOMString>,
|
||||
phase: Cell<EventPhase>,
|
||||
canceled: Cell<bool>,
|
||||
|
@ -124,17 +124,17 @@ impl Event {
|
|||
|
||||
#[inline]
|
||||
pub fn clear_current_target(&self) {
|
||||
self.current_target.clear();
|
||||
self.current_target.set(None);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
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]
|
||||
pub fn set_target(&self, val: JSRef<EventTarget>) {
|
||||
self.target.assign(Some(val));
|
||||
self.target.set(Some(JS::from_rooted(val)));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -188,12 +188,12 @@ impl<'a> EventMethods for JSRef<'a, Event> {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-event-target
|
||||
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
||||
self.target.get()
|
||||
self.target.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||
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
|
||||
|
@ -248,7 +248,7 @@ impl<'a> EventMethods for JSRef<'a, Event> {
|
|||
self.stop_immediate.set(false);
|
||||
self.canceled.set(false);
|
||||
self.trusted.set(false);
|
||||
self.target.clear();
|
||||
self.target.set(None);
|
||||
*self.type_.borrow_mut() = type_;
|
||||
self.bubbles.set(bubbles);
|
||||
self.cancelable.set(cancelable);
|
||||
|
|
|
@ -13,7 +13,8 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLImageElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
|
||||
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::domtokenlist::DOMTokenList;
|
||||
use dom::element::{Element, AttributeHandlers, ElementTypeId};
|
||||
|
@ -32,7 +33,7 @@ use util::str::DOMString;
|
|||
#[dom_struct]
|
||||
pub struct HTMLAnchorElement {
|
||||
htmlelement: HTMLElement,
|
||||
rel_list: MutNullableJS<DOMTokenList>,
|
||||
rel_list: MutNullableHeap<JS<DOMTokenList>>,
|
||||
}
|
||||
|
||||
impl HTMLAnchorElementDerived for EventTarget {
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLAreaElementDerived, HTMLElementCast};
|
||||
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::document::Document;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
|
@ -24,7 +24,7 @@ use util::str::DOMString;
|
|||
#[dom_struct]
|
||||
pub struct HTMLAreaElement {
|
||||
htmlelement: HTMLElement,
|
||||
rel_list: MutNullableJS<DOMTokenList>,
|
||||
rel_list: MutNullableHeap<JS<DOMTokenList>>,
|
||||
}
|
||||
|
||||
impl HTMLAreaElementDerived for EventTarget {
|
||||
|
|
|
@ -11,7 +11,8 @@ use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
|
|||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
|
||||
use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRenderingContext;
|
||||
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::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
|
||||
use dom::document::Document;
|
||||
|
@ -37,8 +38,8 @@ const DEFAULT_HEIGHT: u32 = 150;
|
|||
#[dom_struct]
|
||||
pub struct HTMLCanvasElement {
|
||||
htmlelement: HTMLElement,
|
||||
context_2d: MutNullableJS<CanvasRenderingContext2D>,
|
||||
context_webgl: MutNullableJS<WebGLRenderingContext>,
|
||||
context_2d: MutNullableHeap<JS<CanvasRenderingContext2D>>,
|
||||
context_webgl: MutNullableHeap<JS<WebGLRenderingContext>>,
|
||||
width: Cell<u32>,
|
||||
height: Cell<u32>,
|
||||
}
|
||||
|
@ -192,11 +193,12 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
let window = window_from_node(self).root();
|
||||
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|
|
||||
CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext(Unrooted::from_temporary(ctx)))
|
||||
CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext(Unrooted::from_js(ctx)))
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLInputElementCast, NodeCast};
|
||||
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::Error::Syntax;
|
||||
use dom::bindings::utils::Reflectable;
|
||||
|
@ -39,8 +39,8 @@ use std::default::Default;
|
|||
#[dom_struct]
|
||||
pub struct HTMLElement {
|
||||
element: Element,
|
||||
style_decl: MutNullableJS<CSSStyleDeclaration>,
|
||||
dataset: MutNullableJS<DOMStringMap>,
|
||||
style_decl: MutNullableHeap<JS<CSSStyleDeclaration>>,
|
||||
dataset: MutNullableHeap<JS<DOMStringMap>>,
|
||||
}
|
||||
|
||||
impl HTMLElementDerived for EventTarget {
|
||||
|
|
|
@ -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::KeyboardEventCast;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{Comparable, JSRef, LayoutJS, Root, Temporary, OptionalRootable};
|
||||
use dom::bindings::js::{ResultRootable, RootedReference, MutNullableJS};
|
||||
use dom::bindings::js::{Comparable, JS, JSRef, LayoutJS, MutNullableHeap};
|
||||
use dom::bindings::js::{OptionalRootable, OptionalRootedRootable};
|
||||
use dom::bindings::js::{ResultRootable, Root, RootedReference, Temporary};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::{AttributeHandlers, Element};
|
||||
use dom::element::{RawLayoutElementHelpers, ActivationElementHelpers};
|
||||
|
@ -80,7 +81,7 @@ struct InputActivationState {
|
|||
indeterminate: bool,
|
||||
checked: bool,
|
||||
checked_changed: bool,
|
||||
checked_radio: MutNullableJS<HTMLInputElement>,
|
||||
checked_radio: MutNullableHeap<JS<HTMLInputElement>>,
|
||||
// In case mutability changed
|
||||
was_mutable: bool,
|
||||
// In case the type changed
|
||||
|
@ -694,7 +695,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
|
|||
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();
|
||||
self.SetChecked(true);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
|
||||
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::domtokenlist::DOMTokenList;
|
||||
use dom::element::{AttributeHandlers, Element};
|
||||
|
@ -33,7 +34,7 @@ use string_cache::Atom;
|
|||
#[dom_struct]
|
||||
pub struct HTMLLinkElement {
|
||||
htmlelement: HTMLElement,
|
||||
rel_list: MutNullableJS<DOMTokenList>,
|
||||
rel_list: MutNullableHeap<JS<DOMTokenList>>,
|
||||
}
|
||||
|
||||
impl HTMLLinkElementDerived for EventTarget {
|
||||
|
|
|
@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{EventCast, UIEventCast, MouseEventDerived};
|
||||
use dom::bindings::error::Fallible;
|
||||
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::event::{Event, EventTypeId, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
|
@ -30,7 +31,7 @@ pub struct MouseEvent {
|
|||
alt_key: Cell<bool>,
|
||||
meta_key: Cell<bool>,
|
||||
button: Cell<i16>,
|
||||
related_target: MutNullableJS<EventTarget>
|
||||
related_target: MutNullableHeap<JS<EventTarget>>,
|
||||
}
|
||||
|
||||
impl MouseEventDerived for Event {
|
||||
|
@ -142,7 +143,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
|||
}
|
||||
|
||||
fn GetRelatedTarget(self) -> Option<Temporary<EventTarget>> {
|
||||
self.related_target.get()
|
||||
self.related_target.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
fn InitMouseEvent(self,
|
||||
|
@ -177,7 +178,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
|||
self.shift_key.set(shiftKeyArg);
|
||||
self.meta_key.set(metaKeyArg);
|
||||
self.button.set(buttonArg);
|
||||
self.related_target.assign(relatedTargetArg);
|
||||
self.related_target.set(relatedTargetArg.map(JS::from_rooted));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ use dom::bindings::conversions;
|
|||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{NotFound, HierarchyRequest, Syntax};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, JSRef, LayoutJS, RootedReference, Temporary, Root, Unrooted};
|
||||
use dom::bindings::js::{TemporaryPushable, OptionalRootedRootable};
|
||||
use dom::bindings::js::{ResultRootable, OptionalRootable, MutNullableJS};
|
||||
use dom::bindings::js::{JS, JSRef, LayoutJS, OptionalRootable};
|
||||
use dom::bindings::js::{OptionalRootedRootable, MutNullableHeap};
|
||||
use dom::bindings::js::{ResultRootable, Root, RootedReference, Temporary};
|
||||
use dom::bindings::js::{TemporaryPushable, Unrooted};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||
|
@ -85,25 +86,25 @@ pub struct Node {
|
|||
type_id: NodeTypeId,
|
||||
|
||||
/// The parent of this node.
|
||||
parent_node: MutNullableJS<Node>,
|
||||
parent_node: MutNullableHeap<JS<Node>>,
|
||||
|
||||
/// The first child of this node.
|
||||
first_child: MutNullableJS<Node>,
|
||||
first_child: MutNullableHeap<JS<Node>>,
|
||||
|
||||
/// The last child of this node.
|
||||
last_child: MutNullableJS<Node>,
|
||||
last_child: MutNullableHeap<JS<Node>>,
|
||||
|
||||
/// The next sibling of this node.
|
||||
next_sibling: MutNullableJS<Node>,
|
||||
next_sibling: MutNullableHeap<JS<Node>>,
|
||||
|
||||
/// The previous sibling of this node.
|
||||
prev_sibling: MutNullableJS<Node>,
|
||||
prev_sibling: MutNullableHeap<JS<Node>>,
|
||||
|
||||
/// The document that this node belongs to.
|
||||
owner_doc: MutNullableJS<Document>,
|
||||
owner_doc: MutNullableHeap<JS<Document>>,
|
||||
|
||||
/// The live list of children return by .childNodes.
|
||||
child_list: MutNullableJS<NodeList>,
|
||||
child_list: MutNullableHeap<JS<NodeList>>,
|
||||
|
||||
/// A bitfield of flags for node items.
|
||||
flags: Cell<NodeFlags>,
|
||||
|
@ -328,31 +329,31 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
match before.prev_sibling().root() {
|
||||
None => {
|
||||
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) => {
|
||||
prev_sibling.r().next_sibling.assign(Some(new_child));
|
||||
new_child.prev_sibling.assign(Some(prev_sibling.r()));
|
||||
prev_sibling.r().next_sibling.set(Some(JS::from_rooted(new_child)));
|
||||
new_child.prev_sibling.set(Some(JS::from_rooted(prev_sibling.r())));
|
||||
},
|
||||
}
|
||||
before.prev_sibling.assign(Some(new_child));
|
||||
new_child.next_sibling.assign(Some(*before));
|
||||
before.prev_sibling.set(Some(JS::from_rooted(new_child)));
|
||||
new_child.next_sibling.set(Some(JS::from_rooted(*before)));
|
||||
},
|
||||
None => {
|
||||
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) => {
|
||||
assert!(last_child.r().next_sibling().is_none());
|
||||
last_child.r().next_sibling.assign(Some(new_child));
|
||||
new_child.prev_sibling.assign(Some(last_child.r()));
|
||||
last_child.r().next_sibling.set(Some(JS::from_rooted(new_child)));
|
||||
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.
|
||||
|
@ -363,25 +364,25 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
|
||||
match child.prev_sibling.get().root() {
|
||||
None => {
|
||||
self.first_child.assign(child.next_sibling.get());
|
||||
self.first_child.set(child.next_sibling.get());
|
||||
}
|
||||
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() {
|
||||
None => {
|
||||
self.last_child.assign(child.prev_sibling.get());
|
||||
self.last_child.set(child.prev_sibling.get());
|
||||
}
|
||||
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.next_sibling.clear();
|
||||
child.parent_node.clear();
|
||||
child.prev_sibling.set(None);
|
||||
child.next_sibling.set(None);
|
||||
child.parent_node.set(None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,25 +570,25 @@ impl<'a> NodeHelpers for JSRef<'a, 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>> {
|
||||
self.first_child.get()
|
||||
self.first_child.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
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.
|
||||
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.
|
||||
fn next_sibling(self) -> Option<Temporary<Node>> {
|
||||
self.next_sibling.get()
|
||||
self.next_sibling.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -946,11 +947,11 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
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>) {
|
||||
self.owner_doc.assign(Some(document.clone()));
|
||||
self.owner_doc.set(Some(JS::from_rooted(document)));
|
||||
}
|
||||
|
||||
fn is_in_html_doc(self) -> bool {
|
||||
|
@ -959,7 +960,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
|
||||
fn children(self) -> NodeSiblingIterator {
|
||||
NodeSiblingIterator {
|
||||
current: self.first_child.get(),
|
||||
current: self.first_child(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1346,7 +1347,7 @@ impl Node {
|
|||
last_child: Default::default(),
|
||||
next_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(),
|
||||
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
|
||||
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
|
||||
|
@ -1902,22 +1903,22 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-node-firstchild
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
|
@ -10,7 +10,8 @@ use dom::bindings::codegen::Bindings::StorageEventBinding::{StorageEventMethods}
|
|||
use dom::bindings::codegen::InheritTypes::{EventCast};
|
||||
use dom::bindings::error::Fallible;
|
||||
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::event::{Event, EventTypeId, EventBubbles, EventCancelable};
|
||||
use dom::storage::Storage;
|
||||
|
@ -23,7 +24,7 @@ pub struct StorageEvent {
|
|||
oldValue: DOMRefCell<Option<DOMString>>,
|
||||
newValue: DOMRefCell<Option<DOMString>>,
|
||||
url: DOMRefCell<DOMString>,
|
||||
storageArea: MutNullableJS<Storage>
|
||||
storageArea: MutNullableHeap<JS<Storage>>
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +41,7 @@ impl StorageEvent {
|
|||
oldValue: DOMRefCell::new(oldValue),
|
||||
newValue: DOMRefCell::new(newValue),
|
||||
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>> {
|
||||
self.storageArea.get()
|
||||
self.storageArea.get().map(Temporary::new)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{EventCast, UIEventDerived};
|
||||
use dom::bindings::error::Fallible;
|
||||
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::event::{Event, EventTypeId, EventBubbles, EventCancelable};
|
||||
|
@ -22,7 +23,7 @@ use std::default::Default;
|
|||
#[dom_struct]
|
||||
pub struct UIEvent {
|
||||
event: Event,
|
||||
view: MutNullableJS<Window>,
|
||||
view: MutNullableHeap<JS<Window>>,
|
||||
detail: Cell<i32>
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ impl UIEvent {
|
|||
impl<'a> UIEventMethods for JSRef<'a, UIEvent> {
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-view
|
||||
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
|
||||
|
@ -93,7 +94,7 @@ impl<'a> UIEventMethods for JSRef<'a, UIEvent> {
|
|||
}
|
||||
|
||||
event.InitEvent(type_, can_bubble, cancelable);
|
||||
self.view.assign(view);
|
||||
self.view.set(view.map(JS::from_rooted));
|
||||
self.detail.set(detail);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::Error::InvalidCharacter;
|
||||
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::browsercontext::BrowserContext;
|
||||
use dom::console::Console;
|
||||
|
@ -87,19 +88,19 @@ pub struct Window {
|
|||
eventtarget: EventTarget,
|
||||
script_chan: Box<ScriptChan+Send>,
|
||||
control_chan: ScriptControlChan,
|
||||
console: MutNullableJS<Console>,
|
||||
navigator: MutNullableJS<Navigator>,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
navigator: MutNullableHeap<JS<Navigator>>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
image_cache_chan: ImageCacheChan,
|
||||
compositor: DOMRefCell<Box<ScriptListener+'static>>,
|
||||
browser_context: DOMRefCell<Option<BrowserContext>>,
|
||||
page: Rc<Page>,
|
||||
performance: MutNullableJS<Performance>,
|
||||
performance: MutNullableHeap<JS<Performance>>,
|
||||
navigation_start: u64,
|
||||
navigation_start_precise: f64,
|
||||
screen: MutNullableJS<Screen>,
|
||||
session_storage: MutNullableJS<Storage>,
|
||||
local_storage: MutNullableJS<Storage>,
|
||||
screen: MutNullableHeap<JS<Screen>>,
|
||||
session_storage: MutNullableHeap<JS<Storage>>,
|
||||
local_storage: MutNullableHeap<JS<Storage>>,
|
||||
timers: TimerManager,
|
||||
|
||||
next_worker_id: Cell<WorkerId>,
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::InheritTypes::DedicatedWorkerGlobalScopeCast;
|
|||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{Syntax, Network, JSFailed};
|
||||
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::console::Console;
|
||||
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, DedicatedWorkerGlobalScopeHelpers};
|
||||
|
@ -48,9 +48,9 @@ pub struct WorkerGlobalScope {
|
|||
js_context: Rc<Cx>,
|
||||
next_worker_id: Cell<WorkerId>,
|
||||
resource_task: ResourceTask,
|
||||
location: MutNullableJS<WorkerLocation>,
|
||||
navigator: MutNullableJS<WorkerNavigator>,
|
||||
console: MutNullableJS<Console>,
|
||||
location: MutNullableHeap<JS<WorkerLocation>>,
|
||||
navigator: MutNullableHeap<JS<WorkerNavigator>>,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
timers: TimerManager,
|
||||
devtools_chan: Option<DevtoolsControlChan>,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use dom::bindings::error::Error::{InvalidState, InvalidAccess};
|
||||
use dom::bindings::error::Error::{Network, Syntax, Security, Abort, Timeout};
|
||||
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::str::ByteString;
|
||||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||
|
@ -125,7 +126,7 @@ pub struct XMLHttpRequest {
|
|||
status_text: DOMRefCell<ByteString>,
|
||||
response: DOMRefCell<ByteString>,
|
||||
response_type: Cell<XMLHttpRequestResponseType>,
|
||||
response_xml: MutNullableJS<Document>,
|
||||
response_xml: MutNullableHeap<JS<Document>>,
|
||||
response_headers: DOMRefCell<Headers>,
|
||||
|
||||
// Associated concepts
|
||||
|
@ -710,7 +711,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
|
||||
// https://xhr.spec.whatwg.org/#the-responsexml-attribute
|
||||
fn GetResponseXML(self) -> Option<Temporary<Document>> {
|
||||
self.response_xml.get()
|
||||
self.response_xml.get().map(Temporary::new)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче