Move the CloseEventInit defaults into IDL.

This commit is contained in:
Ms2ger 2015-05-06 12:13:29 +02:00
parent 692fc09041
commit 94b3617629
2 changed files with 5 additions and 12 deletions

View file

@ -15,8 +15,6 @@ use script_task::ScriptChan;
use util::str::DOMString;
use std::borrow::ToOwned;
#[dom_struct]
pub struct CloseEvent {
event: Event,
@ -57,15 +55,10 @@ impl CloseEvent {
type_: DOMString,
init: &CloseEventBinding::CloseEventInit)
-> Fallible<Temporary<CloseEvent>> {
let clean_status = init.wasClean.unwrap_or(true);
let cd = init.code.unwrap_or(0);
let rsn = match init.reason.as_ref() {
Some(reason) => reason.clone(),
None => "".to_owned(),
};
let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
let cancelable = if init.parent.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
Ok(CloseEvent::new(global, type_, bubbles, cancelable, clean_status, cd, rsn))
Ok(CloseEvent::new(global, type_, bubbles, cancelable, init.wasClean,
init.code, init.reason.clone()))
}
}

View file

@ -11,7 +11,7 @@ interface CloseEvent : Event {
};
dictionary CloseEventInit : EventInit {
boolean wasClean;
unsigned short code;
DOMString reason;
boolean wasClean = true;
unsigned short code = 0;
DOMString reason = "";
};