mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support arbitrary protos when wrapping DOM objects with constructors.
This commit is contained in:
parent
d9600ff50f
commit
dbff26bce0
197 changed files with 2028 additions and 586 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue