Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Error Event Interface (NCSU Team: ronak, shreya, sayali) #3821

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

ErrorEvent compile time errors resolution # 1

  • Loading branch information
RonakNisher committed Oct 26, 2014
commit 8ed21239f6ac7f6dfe669bf425c1cd1913cec011
@@ -6,24 +6,25 @@ use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::global;
use dom::bindings::js::{MutNullableJS, JSRef, RootedReference, Temporary, OptionalSettable};
use js::jsapi::JSContext;

use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::event::{Event, EventTypeId, ErrorEventTypeId};
use dom::event::{Event, EventTypeId, ErrorEventTypeId };
use dom::window::Window;
use servo_util::str::DOMString;

use std::cell::Cell;
use std::default::Default;
use js::jsval::JSVal;
use js::jsval::{JSVal, NullValue};

#[dom_struct]
pub struct ErrorEvent {
event: Event,
message: Cell<DOMString>,
filename: Cell<DOMString>,
lineno: Cell<u64>,
colno: Cell<u64>,
error: Cell<JSVal>
message: Cell<DOMString>,
filename: Cell<DOMString>,
lineno: Cell<u32>,
colno: Cell<u32>,
error: Cell<JSVal>
}

impl ErrorEventDerived for Event {
@@ -36,11 +37,11 @@ impl ErrorEvent {
pub fn new_inherited(type_id: EventTypeId) -> ErrorEvent {
ErrorEvent {
event: Event::new_inherited(type_id),
message: Cell::new("".to_string()),
message: Cell::new(""),
filename: Cell::new("".to_string()),
lineno: Cell::new(0),
colno: Cell::new(0),
error: Cell::new(JSVal)
error: Cell::new(NullValue())
}
}

@@ -51,25 +52,27 @@ impl ErrorEvent {
}

pub fn new(window: JSRef<Window>,
global: &GlobalRef,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
message: DOMString,
filename: DOMString,
lineno: u64,
colno: u64,
message: DOMString,
filename: DOMString,
lineno: u32,
colno: u32,
error: JSVal) -> Temporary<ErrorEvent> {
let ev = ErrorEvent::new_uninitialized(window).root();
ev.InitErrorEvent(type_, can_bubble, cancelable, message, filename, lineno, colno, error);
ev.InitErrorEvent(global.get_cx(),type_, can_bubble, cancelable, message, filename, lineno, colno, error);
Temporary::from_rooted(*ev)
}

pub fn Constructor(global: &GlobalRef,
type_: DOMString,
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Temporary<ErrorEvent>> {
let event = ErrorEvent::new(global.as_window(), type_,
let event = ErrorEvent::new(global.as_window(), global, type_,
init.parent.bubbles, init.parent.cancelable,
init.view.root_ref(), init.detail);
init.message, init.filename,
init.lineno, init.colno, init.error);
Ok(event)
}

@@ -80,22 +83,48 @@ impl ErrorEvent {
}

impl<'a> ErrorEventMethods for JSRef<'a, ErrorEvent> {

//TODO: add methods



fn Lineno(self) -> u32 {
self.lineno.get()
}

fn Colno(self) -> u32 {
self.colno.get()
}

fn Message(self) -> DOMString {
self.message.get()
}

fn Filename(self) -> DOMString {
self.filename.get()
}

fn Error(self) -> JSVal {
self.error.get()
}

fn InitErrorEvent(self,
_cx: *mut JSContext,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
message: DOMString,
filename: DOMString,
lineno: u64,
colno: u64,
message: DOMString,
filename: DOMString,
lineno: u32,
colno: u32,
error: JSVal) {
let event: JSRef<Event> = EventCast::from_ref(self);
event.InitEvent(type_, can_bubble, cancelable);
self.message.set(message);
self.filename.set(filename);
self.lineno.set(lineno);
self.colno.set(colno);
self.error.set(error);
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.