diff options
Diffstat (limited to 'components/script/dom/hashchangeevent.rs')
-rw-r--r-- | components/script/dom/hashchangeevent.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index 046500b9b6d..8dbb2fd704a 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -7,12 +7,13 @@ use crate::dom::bindings::codegen::Bindings::HashChangeEventBinding; use crate::dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::reflector::reflect_dom_object; +use crate::dom::bindings::reflector::reflect_dom_object2; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::event::Event; use crate::dom::window::Window; use dom_struct::dom_struct; +use js::rust::HandleObject; use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#hashchangeevent @@ -33,9 +34,14 @@ impl HashChangeEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<HashChangeEvent> { - reflect_dom_object( + Self::new_uninitialized_with_proto(window, None) + } + + fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<HashChangeEvent> { + reflect_dom_object2( Box::new(HashChangeEvent::new_inherited(String::new(), String::new())), window, + proto, ) } @@ -47,9 +53,22 @@ impl HashChangeEvent { old_url: String, new_url: String, ) -> DomRoot<HashChangeEvent> { - let ev = reflect_dom_object( + Self::new_with_proto(window, None, type_, bubbles, cancelable, old_url, new_url) + } + + fn new_with_proto( + window: &Window, + proto: Option<HandleObject>, + type_: Atom, + bubbles: bool, + cancelable: bool, + old_url: String, + new_url: String, + ) -> DomRoot<HashChangeEvent> { + let ev = reflect_dom_object2( Box::new(HashChangeEvent::new_inherited(old_url, new_url)), window, + proto, ); { let event = ev.upcast::<Event>(); @@ -61,11 +80,13 @@ impl HashChangeEvent { #[allow(non_snake_case)] pub fn Constructor( window: &Window, + proto: Option<HandleObject>, type_: DOMString, init: &HashChangeEventBinding::HashChangeEventInit, ) -> Fallible<DomRoot<HashChangeEvent>> { - Ok(HashChangeEvent::new( + Ok(HashChangeEvent::new_with_proto( window, + proto, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, |