Upgrade to SM 39

This commit is contained in:
Michael Wu 2015-04-06 19:27:56 -04:00
parent a256f39796
commit 675267b782
205 changed files with 6546 additions and 5340 deletions

View file

@ -8,18 +8,18 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::InheritTypes::{EventCast, CustomEventDerived};
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, MutHeap, Rootable, Temporary};
use dom::bindings::js::{Root, MutHeapJSVal};
use dom::bindings::utils::reflect_dom_object;
use dom::event::{Event, EventTypeId};
use js::jsapi::JSContext;
use js::jsval::{JSVal, NullValue};
use js::jsapi::{JSContext, HandleValue};
use js::jsval::JSVal;
use util::str::DOMString;
// https://dom.spec.whatwg.org/#interface-customevent
#[dom_struct]
pub struct CustomEvent {
event: Event,
detail: MutHeap<JSVal>,
detail: MutHeapJSVal,
}
impl CustomEventDerived for Event {
@ -32,11 +32,11 @@ impl CustomEvent {
fn new_inherited(type_id: EventTypeId) -> CustomEvent {
CustomEvent {
event: Event::new_inherited(type_id),
detail: MutHeap::new(NullValue()),
detail: MutHeapJSVal::new(),
}
}
pub fn new_uninitialized(global: GlobalRef) -> Temporary<CustomEvent> {
pub fn new_uninitialized(global: GlobalRef) -> Root<CustomEvent> {
reflect_dom_object(box CustomEvent::new_inherited(EventTypeId::CustomEvent),
global,
CustomEventBinding::Wrap)
@ -45,19 +45,23 @@ impl CustomEvent {
type_: DOMString,
bubbles: bool,
cancelable: bool,
detail: JSVal) -> Temporary<CustomEvent> {
let ev = CustomEvent::new_uninitialized(global).root();
detail: HandleValue) -> Root<CustomEvent> {
let ev = CustomEvent::new_uninitialized(global);
ev.r().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
Temporary::from_rooted(ev.r())
ev
}
pub fn Constructor(global: GlobalRef,
type_: DOMString,
init: &CustomEventBinding::CustomEventInit) -> Fallible<Temporary<CustomEvent>>{
Ok(CustomEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable, init.detail))
init: &CustomEventBinding::CustomEventInit) -> Fallible<Root<CustomEvent>>{
Ok(CustomEvent::new(global,
type_,
init.parent.bubbles,
init.parent.cancelable,
HandleValue { ptr: &init.detail }))
}
}
impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> {
impl<'a> CustomEventMethods for &'a CustomEvent {
// https://dom.spec.whatwg.org/#dom-customevent-detail
fn Detail(self, _cx: *mut JSContext) -> JSVal {
self.detail.get()
@ -69,13 +73,13 @@ impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> {
type_: DOMString,
can_bubble: bool,
cancelable: bool,
detail: JSVal) {
let event: JSRef<Event> = EventCast::from_ref(self);
detail: HandleValue) {
let event = EventCast::from_ref(self);
if event.dispatching() {
return;
}
self.detail.set(detail);
self.detail.set(detail.get());
event.InitEvent(type_, can_bubble, cancelable);
}
}