mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +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,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding;
|
|||
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods;
|
||||
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;
|
||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
|
@ -18,7 +18,7 @@ use crate::script_runtime::JSContext;
|
|||
use dom_struct::dom_struct;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use js::rust::{HandleObject, HandleValue};
|
||||
use servo_atoms::Atom;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -41,7 +41,6 @@ impl PromiseRejectionEvent {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
type_: Atom,
|
||||
|
@ -50,9 +49,23 @@ impl PromiseRejectionEvent {
|
|||
promise: Rc<Promise>,
|
||||
reason: HandleValue,
|
||||
) -> DomRoot<Self> {
|
||||
let ev = reflect_dom_object(
|
||||
Self::new_with_proto(global, None, type_, bubbles, cancelable, promise, reason)
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
fn new_with_proto(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
promise: Rc<Promise>,
|
||||
reason: HandleValue,
|
||||
) -> DomRoot<Self> {
|
||||
let ev = reflect_dom_object2(
|
||||
Box::new(PromiseRejectionEvent::new_inherited(promise)),
|
||||
global,
|
||||
proto,
|
||||
);
|
||||
|
||||
{
|
||||
|
@ -67,6 +80,7 @@ impl PromiseRejectionEvent {
|
|||
#[allow(unrooted_must_root, non_snake_case)]
|
||||
pub fn Constructor(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
|
||||
) -> Fallible<DomRoot<Self>> {
|
||||
|
@ -75,8 +89,9 @@ impl PromiseRejectionEvent {
|
|||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
|
||||
let event = PromiseRejectionEvent::new(
|
||||
let event = PromiseRejectionEvent::new_with_proto(
|
||||
global,
|
||||
proto,
|
||||
Atom::from(type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue