mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Fixes #4164 Make Constructor and new functions take GlobalRef by value
This commit is contained in:
parent
cf616b90a2
commit
85df7f0d6f
25 changed files with 61 additions and 61 deletions
|
@ -4014,7 +4014,7 @@ let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
|
||||||
let global = global.root();
|
let global = global.root();
|
||||||
""")
|
""")
|
||||||
nativeName = MakeNativeName(self._ctor.identifier.name)
|
nativeName = MakeNativeName(self._ctor.identifier.name)
|
||||||
callGenerator = CGMethodCall(["&global.r()"], nativeName, True,
|
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
|
||||||
self.descriptor, self._ctor)
|
self.descriptor, self._ctor)
|
||||||
return CGList([preamble, callGenerator])
|
return CGList([preamble, callGenerator])
|
||||||
|
|
||||||
|
|
|
@ -37,30 +37,30 @@ fn is_ascii_printable(string: &DOMString) -> bool{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Blob {
|
impl Blob {
|
||||||
pub fn new_inherited(global: &GlobalRef, type_: BlobTypeId,
|
pub fn new_inherited(global: GlobalRef, type_: BlobTypeId,
|
||||||
bytes: Option<Vec<u8>>, typeString: &str) -> Blob {
|
bytes: Option<Vec<u8>>, typeString: &str) -> Blob {
|
||||||
Blob {
|
Blob {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
type_: type_,
|
type_: type_,
|
||||||
bytes: bytes,
|
bytes: bytes,
|
||||||
typeString: typeString.into_string(),
|
typeString: typeString.into_string(),
|
||||||
global: GlobalField::from_rooted(global)
|
global: GlobalField::from_rooted(&global)
|
||||||
//isClosed_: false
|
//isClosed_: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalRef, bytes: Option<Vec<u8>>,
|
pub fn new(global: GlobalRef, bytes: Option<Vec<u8>>,
|
||||||
typeString: &str) -> Temporary<Blob> {
|
typeString: &str) -> Temporary<Blob> {
|
||||||
reflect_dom_object(box Blob::new_inherited(global, BlobTypeId::Blob, bytes, typeString),
|
reflect_dom_object(box Blob::new_inherited(global, BlobTypeId::Blob, bytes, typeString),
|
||||||
*global,
|
global,
|
||||||
BlobBinding::Wrap)
|
BlobBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Blob>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Blob>> {
|
||||||
Ok(Blob::new(global, None, ""))
|
Ok(Blob::new(global, None, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor_(global: &GlobalRef, blobParts: DOMString, blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Temporary<Blob>> {
|
pub fn Constructor_(global: GlobalRef, blobParts: DOMString, blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Temporary<Blob>> {
|
||||||
//TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
|
//TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
|
||||||
let bytes: Option<Vec<u8>> = Some(blobParts.into_bytes());
|
let bytes: Option<Vec<u8>> = Some(blobParts.into_bytes());
|
||||||
let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
|
let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
|
||||||
|
@ -121,13 +121,13 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
|
||||||
let span: i64 = max(relativeEnd - relativeStart, 0);
|
let span: i64 = max(relativeEnd - relativeStart, 0);
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
match self.bytes {
|
match self.bytes {
|
||||||
None => Blob::new(&global.r(), None, relativeContentType.as_slice()),
|
None => Blob::new(global.r(), None, relativeContentType.as_slice()),
|
||||||
Some(ref vec) => {
|
Some(ref vec) => {
|
||||||
let start = relativeStart.to_uint().unwrap();
|
let start = relativeStart.to_uint().unwrap();
|
||||||
let end = (relativeStart + span).to_uint().unwrap();
|
let end = (relativeStart + span).to_uint().unwrap();
|
||||||
let mut bytes: Vec<u8> = Vec::new();
|
let mut bytes: Vec<u8> = Vec::new();
|
||||||
bytes.push_all(vec.slice(start, end));
|
bytes.push_all(vec.slice(start, end));
|
||||||
Blob::new(&global.r(), Some(bytes), relativeContentType.as_slice())
|
Blob::new(global.r(), Some(bytes), relativeContentType.as_slice())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,18 @@ pub struct CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CanvasRenderingContext2D {
|
impl CanvasRenderingContext2D {
|
||||||
fn new_inherited(global: &GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> CanvasRenderingContext2D {
|
fn new_inherited(global: GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> CanvasRenderingContext2D {
|
||||||
CanvasRenderingContext2D {
|
CanvasRenderingContext2D {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
global: GlobalField::from_rooted(global),
|
global: GlobalField::from_rooted(&global),
|
||||||
renderer: CanvasPaintTask::start(size),
|
renderer: CanvasPaintTask::start(size),
|
||||||
canvas: JS::from_rooted(canvas),
|
canvas: JS::from_rooted(canvas),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> Temporary<CanvasRenderingContext2D> {
|
pub fn new(global: GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> Temporary<CanvasRenderingContext2D> {
|
||||||
reflect_dom_object(box CanvasRenderingContext2D::new_inherited(global, canvas, size),
|
reflect_dom_object(box CanvasRenderingContext2D::new_inherited(global, canvas, size),
|
||||||
*global, CanvasRenderingContext2DBinding::Wrap)
|
global, CanvasRenderingContext2DBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recreate(&self, size: Size2D<i32>) {
|
pub fn recreate(&self, size: Size2D<i32>) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl Comment {
|
||||||
document, CommentBinding::Wrap)
|
document, CommentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef, data: DOMString) -> Fallible<Temporary<Comment>> {
|
pub fn Constructor(global: GlobalRef, data: DOMString) -> Fallible<Temporary<Comment>> {
|
||||||
let document = global.as_window().Document().root();
|
let document = global.as_window().Document().root();
|
||||||
Ok(Comment::new(data, document.r()))
|
Ok(Comment::new(data, document.r()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,12 @@ impl CustomEvent {
|
||||||
global,
|
global,
|
||||||
CustomEventBinding::Wrap)
|
CustomEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
pub fn new(global: &GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> {
|
pub fn new(global: GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> {
|
||||||
let ev = CustomEvent::new_uninitialized(*global).root();
|
let ev = CustomEvent::new_uninitialized(global).root();
|
||||||
ev.r().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
ev.r().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CustomEventBinding::CustomEventInit) -> Fallible<Temporary<CustomEvent>>{
|
init: &CustomEventBinding::CustomEventInit) -> Fallible<Temporary<CustomEvent>>{
|
||||||
Ok(CustomEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable, init.detail))
|
Ok(CustomEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable, init.detail))
|
||||||
|
|
|
@ -451,7 +451,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document
|
// http://dom.spec.whatwg.org/#dom-document
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Document>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Document>> {
|
||||||
Ok(Document::new(global.as_window(), None,
|
Ok(Document::new(global.as_window(), None,
|
||||||
IsHTMLDocument::NonHTMLDocument, None,
|
IsHTMLDocument::NonHTMLDocument, None,
|
||||||
DocumentSource::NotFromParser))
|
DocumentSource::NotFromParser))
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl DocumentFragment {
|
||||||
document, DocumentFragmentBinding::Wrap)
|
document, DocumentFragmentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<DocumentFragment>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<DocumentFragment>> {
|
||||||
let document = global.as_window().Document();
|
let document = global.as_window().Document();
|
||||||
let document = document.root();
|
let document = document.root();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl DOMParser {
|
||||||
DOMParserBinding::Wrap)
|
DOMParserBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<DOMParser>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<DOMParser>> {
|
||||||
Ok(DOMParser::new(global.as_window()))
|
Ok(DOMParser::new(global.as_window()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,13 @@ impl ErrorEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalRef) -> Temporary<ErrorEvent> {
|
pub fn new_uninitialized(global: GlobalRef) -> Temporary<ErrorEvent> {
|
||||||
reflect_dom_object(box ErrorEvent::new_inherited(EventTypeId::ErrorEvent),
|
reflect_dom_object(box ErrorEvent::new_inherited(EventTypeId::ErrorEvent),
|
||||||
*global,
|
global,
|
||||||
ErrorEventBinding::Wrap)
|
ErrorEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalRef,
|
pub fn new(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
@ -75,7 +75,7 @@ impl ErrorEvent {
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Temporary<ErrorEvent>>{
|
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Temporary<ErrorEvent>>{
|
||||||
let msg = match init.message.as_ref() {
|
let msg = match init.message.as_ref() {
|
||||||
|
|
|
@ -104,12 +104,12 @@ impl Event {
|
||||||
Temporary::from_rooted(event.r())
|
Temporary::from_rooted(event.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &EventBinding::EventInit) -> Fallible<Temporary<Event>> {
|
init: &EventBinding::EventInit) -> Fallible<Temporary<Event>> {
|
||||||
let bubbles = if init.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
|
let bubbles = if init.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
|
||||||
let cancelable = if init.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
|
let cancelable = if init.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
|
||||||
Ok(Event::new(*global, type_, bubbles, cancelable))
|
Ok(Event::new(global, type_, bubbles, cancelable))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl File {
|
||||||
_file_bits: JSRef<Blob>, name: DOMString) -> File {
|
_file_bits: JSRef<Blob>, name: DOMString) -> File {
|
||||||
File {
|
File {
|
||||||
//TODO: get type from the underlying filesystem instead of "".to_string()
|
//TODO: get type from the underlying filesystem instead of "".to_string()
|
||||||
blob: Blob::new_inherited(global, type_, None, ""),
|
blob: Blob::new_inherited(*global, type_, None, ""),
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
// XXXManishearth Once Blob is able to store data
|
// XXXManishearth Once Blob is able to store data
|
||||||
|
|
|
@ -36,21 +36,21 @@ pub struct FormData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormData {
|
impl FormData {
|
||||||
fn new_inherited(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> FormData {
|
fn new_inherited(form: Option<JSRef<HTMLFormElement>>, global: GlobalRef) -> FormData {
|
||||||
FormData {
|
FormData {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
data: DOMRefCell::new(HashMap::new()),
|
data: DOMRefCell::new(HashMap::new()),
|
||||||
global: GlobalField::from_rooted(global),
|
global: GlobalField::from_rooted(&global),
|
||||||
form: form.map(|f| JS::from_rooted(f)),
|
form: form.map(|f| JS::from_rooted(f)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> Temporary<FormData> {
|
pub fn new(form: Option<JSRef<HTMLFormElement>>, global: GlobalRef) -> Temporary<FormData> {
|
||||||
reflect_dom_object(box FormData::new_inherited(form, global),
|
reflect_dom_object(box FormData::new_inherited(form, global),
|
||||||
*global, FormDataBinding::Wrap)
|
global, FormDataBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
|
pub fn Constructor(global: GlobalRef, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
|
||||||
Ok(FormData::new(form, global))
|
Ok(FormData::new(form, global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
|
||||||
Some(self.context.or_init(|| {
|
Some(self.context.or_init(|| {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let (w, h) = (self.width.get() as i32, self.height.get() as i32);
|
let (w, h) = (self.width.get() as i32, self.height.get() as i32);
|
||||||
CanvasRenderingContext2D::new(&GlobalRef::Window(window.r()), self, Size2D(w, h))
|
CanvasRenderingContext2D::new(GlobalRef::Window(window.r()), self, Size2D(w, h))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl KeyboardEvent {
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Temporary<KeyboardEvent>> {
|
init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible<Temporary<KeyboardEvent>> {
|
||||||
let event = KeyboardEvent::new(global.as_window(), type_,
|
let event = KeyboardEvent::new(global.as_window(), type_,
|
||||||
|
|
|
@ -63,11 +63,11 @@ impl MessageEvent {
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MessageEventBinding::MessageEventInit)
|
init: &MessageEventBinding::MessageEventInit)
|
||||||
-> Fallible<Temporary<MessageEvent>> {
|
-> Fallible<Temporary<MessageEvent>> {
|
||||||
let ev = MessageEvent::new(*global, type_, init.parent.bubbles, init.parent.cancelable,
|
let ev = MessageEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable,
|
||||||
init.data, init.origin.clone(), init.lastEventId.clone());
|
init.data, init.origin.clone(), init.lastEventId.clone());
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl MouseEvent {
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
|
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
|
||||||
let event = MouseEvent::new(global.as_window(), type_,
|
let event = MouseEvent::new(global.as_window(), type_,
|
||||||
|
|
|
@ -46,11 +46,11 @@ impl ProgressEvent {
|
||||||
event.InitEvent(type_, can_bubble, cancelable);
|
event.InitEvent(type_, can_bubble, cancelable);
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ProgressEventBinding::ProgressEventInit)
|
init: &ProgressEventBinding::ProgressEventInit)
|
||||||
-> Fallible<Temporary<ProgressEvent>> {
|
-> Fallible<Temporary<ProgressEvent>> {
|
||||||
let ev = ProgressEvent::new(*global, type_, init.parent.bubbles, init.parent.cancelable,
|
let ev = ProgressEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable,
|
||||||
init.lengthComputable, init.loaded, init.total);
|
init.lengthComputable, init.loaded, init.total);
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl Range {
|
||||||
RangeBinding::Wrap)
|
RangeBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Range>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Range>> {
|
||||||
let document = global.as_window().Document().root();
|
let document = global.as_window().Document().root();
|
||||||
Ok(Range::new(document.r()))
|
Ok(Range::new(document.r()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn SetEnumAttribute(self, _: TestEnum) {}
|
fn SetEnumAttribute(self, _: TestEnum) {}
|
||||||
fn InterfaceAttribute(self) -> Temporary<Blob> {
|
fn InterfaceAttribute(self) -> Temporary<Blob> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Blob::new(&global.r(), None, "")
|
Blob::new(global.r(), None, "")
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttribute(self, _: JSRef<Blob>) {}
|
fn SetInterfaceAttribute(self, _: JSRef<Blob>) {}
|
||||||
fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) }
|
fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) }
|
||||||
|
@ -99,7 +99,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
|
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
|
fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(&global.r(), None, ""))
|
Some(Blob::new(global.r(), None, ""))
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttributeNullable(self, _: Option<JSRef<Blob>>) {}
|
fn SetInterfaceAttributeNullable(self, _: Option<JSRef<Blob>>) {}
|
||||||
fn GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
fn GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
|
@ -123,7 +123,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn ReceiveEnum(self) -> TestEnum { _empty }
|
fn ReceiveEnum(self) -> TestEnum { _empty }
|
||||||
fn ReceiveInterface(self) -> Temporary<Blob> {
|
fn ReceiveInterface(self) -> Temporary<Blob> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Blob::new(&global.r(), None, "")
|
Blob::new(global.r(), None, "")
|
||||||
}
|
}
|
||||||
fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) }
|
fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) }
|
||||||
|
@ -145,7 +145,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn ReceiveNullableEnum(self) -> Option<TestEnum> { Some(_empty) }
|
fn ReceiveNullableEnum(self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn ReceiveNullableInterface(self) -> Option<Temporary<Blob>> {
|
fn ReceiveNullableInterface(self) -> Option<Temporary<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(&global.r(), None, ""))
|
Some(Blob::new(global.r(), None, ""))
|
||||||
}
|
}
|
||||||
fn ReceiveNullableUnion(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
fn ReceiveNullableUnion(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
fn ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".into_string())) }
|
fn ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".into_string())) }
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl Text {
|
||||||
document, TextBinding::Wrap)
|
document, TextBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef, text: DOMString) -> Fallible<Temporary<Text>> {
|
pub fn Constructor(global: GlobalRef, text: DOMString) -> Fallible<Temporary<Text>> {
|
||||||
let document = global.as_window().Document().root();
|
let document = global.as_window().Document().root();
|
||||||
Ok(Text::new(text, document.r()))
|
Ok(Text::new(text, document.r()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl UIEvent {
|
||||||
Temporary::from_rooted(ev.r())
|
Temporary::from_rooted(ev.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef,
|
pub fn Constructor(global: GlobalRef,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &UIEventBinding::UIEventInit) -> Fallible<Temporary<UIEvent>> {
|
init: &UIEventBinding::UIEventInit) -> Fallible<Temporary<UIEvent>> {
|
||||||
let event = UIEvent::new(global.as_window(), type_,
|
let event = UIEvent::new(global.as_window(), type_,
|
||||||
|
|
|
@ -40,8 +40,8 @@ impl URLSearchParams {
|
||||||
reflect_dom_object(box URLSearchParams::new_inherited(), global, URLSearchParamsBinding::Wrap)
|
reflect_dom_object(box URLSearchParams::new_inherited(), global, URLSearchParamsBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef, init: Option<StringOrURLSearchParams>) -> Fallible<Temporary<URLSearchParams>> {
|
pub fn Constructor(global: GlobalRef, init: Option<StringOrURLSearchParams>) -> Fallible<Temporary<URLSearchParams>> {
|
||||||
let usp = URLSearchParams::new(*global).root();
|
let usp = URLSearchParams::new(global).root();
|
||||||
match init {
|
match init {
|
||||||
Some(eString(_s)) => {
|
Some(eString(_s)) => {
|
||||||
// XXXManishearth we need to parse the input here
|
// XXXManishearth we need to parse the input here
|
||||||
|
|
|
@ -31,8 +31,8 @@ impl WebSocket {
|
||||||
WebSocketBinding::Wrap)
|
WebSocketBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef, url: DOMString) -> Fallible<Temporary<WebSocket>> {
|
pub fn Constructor(global: GlobalRef, url: DOMString) -> Fallible<Temporary<WebSocket>> {
|
||||||
Ok(WebSocket::new(*global, url))
|
Ok(WebSocket::new(global, url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,23 +43,23 @@ pub struct Worker {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Worker {
|
impl Worker {
|
||||||
fn new_inherited(global: &GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Worker {
|
fn new_inherited(global: GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Worker {
|
||||||
Worker {
|
Worker {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker),
|
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker),
|
||||||
refcount: Cell::new(0),
|
refcount: Cell::new(0),
|
||||||
global: GlobalField::from_rooted(global),
|
global: GlobalField::from_rooted(&global),
|
||||||
sender: sender,
|
sender: sender,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Temporary<Worker> {
|
pub fn new(global: GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Temporary<Worker> {
|
||||||
reflect_dom_object(box Worker::new_inherited(global, sender),
|
reflect_dom_object(box Worker::new_inherited(global, sender),
|
||||||
*global,
|
global,
|
||||||
WorkerBinding::Wrap)
|
WorkerBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#dom-worker
|
// http://www.whatwg.org/html/#dom-worker
|
||||||
pub fn Constructor(global: &GlobalRef, scriptURL: DOMString) -> Fallible<Temporary<Worker>> {
|
pub fn Constructor(global: GlobalRef, scriptURL: DOMString) -> Fallible<Temporary<Worker>> {
|
||||||
// Step 2-4.
|
// Step 2-4.
|
||||||
let worker_url = match UrlParser::new().base_url(&global.get_url())
|
let worker_url = match UrlParser::new().base_url(&global.get_url())
|
||||||
.parse(scriptURL.as_slice()) {
|
.parse(scriptURL.as_slice()) {
|
||||||
|
|
|
@ -160,13 +160,13 @@ pub struct XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XMLHttpRequest {
|
impl XMLHttpRequest {
|
||||||
fn new_inherited(global: &GlobalRef) -> XMLHttpRequest {
|
fn new_inherited(global: GlobalRef) -> XMLHttpRequest {
|
||||||
XMLHttpRequest {
|
XMLHttpRequest {
|
||||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(XMLHttpRequestEventTargetTypeId::XMLHttpRequest),
|
eventtarget: XMLHttpRequestEventTarget::new_inherited(XMLHttpRequestEventTargetTypeId::XMLHttpRequest),
|
||||||
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
||||||
timeout: Cell::new(0u32),
|
timeout: Cell::new(0u32),
|
||||||
with_credentials: Cell::new(false),
|
with_credentials: Cell::new(false),
|
||||||
upload: JS::from_rooted(XMLHttpRequestUpload::new(*global)),
|
upload: JS::from_rooted(XMLHttpRequestUpload::new(global)),
|
||||||
response_url: "".into_string(),
|
response_url: "".into_string(),
|
||||||
status: Cell::new(0),
|
status: Cell::new(0),
|
||||||
status_text: DOMRefCell::new(ByteString::new(vec!())),
|
status_text: DOMRefCell::new(ByteString::new(vec!())),
|
||||||
|
@ -185,19 +185,19 @@ impl XMLHttpRequest {
|
||||||
upload_complete: Cell::new(false),
|
upload_complete: Cell::new(false),
|
||||||
upload_events: Cell::new(false),
|
upload_events: Cell::new(false),
|
||||||
|
|
||||||
global: GlobalField::from_rooted(global),
|
global: GlobalField::from_rooted(&global),
|
||||||
timer: DOMRefCell::new(Timer::new().unwrap()),
|
timer: DOMRefCell::new(Timer::new().unwrap()),
|
||||||
fetch_time: Cell::new(0),
|
fetch_time: Cell::new(0),
|
||||||
terminate_sender: DOMRefCell::new(None),
|
terminate_sender: DOMRefCell::new(None),
|
||||||
generation_id: Cell::new(GenerationId(0))
|
generation_id: Cell::new(GenerationId(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new(global: &GlobalRef) -> Temporary<XMLHttpRequest> {
|
pub fn new(global: GlobalRef) -> Temporary<XMLHttpRequest> {
|
||||||
reflect_dom_object(box XMLHttpRequest::new_inherited(global),
|
reflect_dom_object(box XMLHttpRequest::new_inherited(global),
|
||||||
*global,
|
global,
|
||||||
XMLHttpRequestBinding::Wrap)
|
XMLHttpRequestBinding::Wrap)
|
||||||
}
|
}
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<XMLHttpRequest>> {
|
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<XMLHttpRequest>> {
|
||||||
Ok(XMLHttpRequest::new(global))
|
Ok(XMLHttpRequest::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue