servo: Merge #10844 - Implement the "progressevent" argument to Document::createEvent (from sliz1:10740); r=frewsxcv
authorStephen (Ziyun) Li <stephen.liziyun@gmail.com>
Mon, 25 Apr 2016 22:00:24 -0700
changeset 476793 d2acf676078007f780f8329f516ea35974525706
parent 476792 b3acff86056dc8bb1ab737b2e4655b4e5be22011
child 476794 78d5dcabf8b2790543fbb3a4d74dfc68dd9200d8
push id44079
push userbmo:gps@mozilla.com
push dateSat, 04 Feb 2017 00:14:49 +0000
reviewersfrewsxcv
servo: Merge #10844 - Implement the "progressevent" argument to Document::createEvent (from sliz1:10740); r=frewsxcv Fixes https://github.com/servo/servo/issues/10740 Source-Repo: https://github.com/servo/servo Source-Revision: 09b2efc7061337593d948c7fb11b9d80ba42df5a
servo/components/script/dom/document.rs
servo/components/script/dom/progressevent.rs
--- a/servo/components/script/dom/document.rs
+++ b/servo/components/script/dom/document.rs
@@ -63,16 +63,17 @@ use dom::htmltitleelement::HTMLTitleElem
 use dom::keyboardevent::KeyboardEvent;
 use dom::location::Location;
 use dom::messageevent::MessageEvent;
 use dom::mouseevent::MouseEvent;
 use dom::node::{self, CloneChildrenFlag, Node, NodeDamage, window_from_node};
 use dom::nodeiterator::NodeIterator;
 use dom::nodelist::NodeList;
 use dom::processinginstruction::ProcessingInstruction;
+use dom::progressevent::ProgressEvent;
 use dom::range::Range;
 use dom::servohtmlparser::{ParserRoot, ParserRef, MutNullableParserField};
 use dom::storageevent::StorageEvent;
 use dom::stylesheetlist::StyleSheetList;
 use dom::text::Text;
 use dom::touch::Touch;
 use dom::touchevent::TouchEvent;
 use dom::touchlist::TouchList;
@@ -2178,16 +2179,18 @@ impl DocumentMethods for Document {
                         &TouchList::new(&self.window, &[]),
                         &TouchList::new(&self.window, &[]),
                     )
                 )),
             "webglcontextevent" =>
                 Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
             "storageevent" =>
                 Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, self.URL()))),
+            "progressevent" =>
+                Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))),
             _ =>
                 Err(Error::NotSupported),
         }
     }
 
     // https://html.spec.whatwg.org/multipage/#dom-document-lastmodified
     fn LastModified(&self) -> DOMString {
         match self.last_modified {
--- a/servo/components/script/dom/progressevent.rs
+++ b/servo/components/script/dom/progressevent.rs
@@ -6,16 +6,17 @@ use dom::bindings::codegen::Bindings::Ev
 use dom::bindings::codegen::Bindings::ProgressEventBinding;
 use dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods;
 use dom::bindings::error::Fallible;
 use dom::bindings::global::GlobalRef;
 use dom::bindings::inheritance::Castable;
 use dom::bindings::js::Root;
 use dom::bindings::reflector::reflect_dom_object;
 use dom::event::{Event, EventBubbles, EventCancelable};
+use dom::window::Window;
 use string_cache::Atom;
 use util::str::DOMString;
 
 #[dom_struct]
 pub struct ProgressEvent {
     event: Event,
     length_computable: bool,
     loaded: u64,
@@ -26,16 +27,21 @@ impl ProgressEvent {
     fn new_inherited(length_computable: bool, loaded: u64, total: u64) -> ProgressEvent {
         ProgressEvent {
             event: Event::new_inherited(),
             length_computable: length_computable,
             loaded: loaded,
             total: total
         }
     }
+    pub fn new_uninitialized(window: &Window) -> Root<ProgressEvent> {
+        reflect_dom_object(box ProgressEvent::new_inherited(false, 0, 0),
+                           GlobalRef::Window(window),
+                           ProgressEventBinding::Wrap)
+    }
     pub fn new(global: GlobalRef, type_: Atom,
                can_bubble: EventBubbles, cancelable: EventCancelable,
                length_computable: bool, loaded: u64, total: u64) -> Root<ProgressEvent> {
         let ev = reflect_dom_object(box ProgressEvent::new_inherited(length_computable, loaded, total),
                                     global,
                                     ProgressEventBinding::Wrap);
         {
             let event = ev.upcast::<Event>();