Formatting.

This commit is contained in:
Josh Matthews 2023-05-28 23:25:41 -04:00
parent dbff26bce0
commit 0e8ac3fdac
81 changed files with 588 additions and 206 deletions

View file

@ -39,7 +39,12 @@ impl AnimationEvent {
Self::new_with_proto(window, None, type_, init)
}
fn new_with_proto(window: &Window, proto: Option<HandleObject>, type_: Atom, init: &AnimationEventInit) -> DomRoot<AnimationEvent> {
fn new_with_proto(
window: &Window,
proto: Option<HandleObject>,
type_: Atom,
init: &AnimationEventInit,
) -> DomRoot<AnimationEvent> {
let ev = reflect_dom_object2(Box::new(AnimationEvent::new_inherited(init)), window, proto);
{
let event = ev.upcast::<Event>();

View file

@ -84,7 +84,14 @@ impl AudioBuffer {
sample_rate: f32,
initial_data: Option<&[Vec<f32>]>,
) -> DomRoot<AudioBuffer> {
Self::new_with_proto(global, None, number_of_channels, length, sample_rate, initial_data)
Self::new_with_proto(
global,
None,
number_of_channels,
length,
sample_rate,
initial_data,
)
}
#[allow(unrooted_must_root)]

View file

@ -80,7 +80,11 @@ impl AudioContext {
}
#[allow(unrooted_must_root)]
fn new(window: &Window, proto: Option<HandleObject>, options: &AudioContextOptions) -> DomRoot<AudioContext> {
fn new(
window: &Window,
proto: Option<HandleObject>,
options: &AudioContextOptions,
) -> DomRoot<AudioContext> {
let pipeline_id = window.pipeline_id();
let context = AudioContext::new_inherited(options, pipeline_id);
let context = reflect_dom_object2(Box::new(context), window, proto);

View file

@ -230,7 +230,13 @@ unsafe fn html_constructor(
let element = if definition.is_autonomous() {
DomRoot::upcast(HTMLElement::new(name.local, None, &*document, None))
} else {
create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated, None)
create_native_html_element(
name,
None,
&*document,
ElementCreator::ScriptCreated,
None,
)
};
// Step 8.2 is performed in the generated caller code.

View file

@ -11,18 +11,24 @@ use crate::dom::bindings::conversions::{get_dom_class, DOM_OBJECT_SLOT};
use crate::dom::bindings::guard::Guard;
use crate::dom::bindings::principals::ServoJSPrincipals;
use crate::dom::bindings::utils::{
get_proto_or_iface_array, ProtoOrIfaceArray, DOM_PROTOTYPE_SLOT, JSCLASS_DOM_GLOBAL,
DOMJSClass,
get_proto_or_iface_array, DOMJSClass, ProtoOrIfaceArray, DOM_PROTOTYPE_SLOT, JSCLASS_DOM_GLOBAL,
};
use crate::script_runtime::JSContext as SafeJSContext;
use js::error::throw_type_error;
use js::glue::UncheckedUnwrapObject;
use js::jsapi::CheckedUnwrapStatic;
use js::jsapi::CurrentGlobalOrNull;
use js::jsapi::GetFunctionRealm;
use js::jsapi::GetNonCCWObjectGlobal;
use js::jsapi::GetRealmGlobalOrNull;
use js::jsapi::GetWellKnownSymbol;
use js::jsapi::HandleObject as RawHandleObject;
use js::jsapi::JS_GetProperty;
use js::jsapi::JS_WrapObject;
use js::jsapi::{jsid, JSClass, JSClassOps};
use js::jsapi::{
Compartment, CompartmentSpecifier, IsSharableCompartment, IsSystemCompartment,
JS_IterateCompartments, JS::CompartmentIterResult, CallArgs,
CallArgs, Compartment, CompartmentSpecifier, IsSharableCompartment, IsSystemCompartment,
JS_IterateCompartments, JS::CompartmentIterResult,
};
use js::jsapi::{JSAutoRealm, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR};
use js::jsapi::{JSPropertySpec, JSString, JSTracer, JS_AtomizeAndPinString};
@ -32,15 +38,8 @@ use js::jsapi::{JS_NewStringCopyN, JS_SetReservedSlot};
use js::jsapi::{ObjectOps, OnNewGlobalHookOption, SymbolCode};
use js::jsapi::{TrueHandleValue, Value};
use js::jsapi::{JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING};
use js::jsapi::CheckedUnwrapStatic;
use js::jsapi::JS_GetProperty;
use js::jsapi::GetFunctionRealm;
use js::jsapi::GetRealmGlobalOrNull;
use js::jsapi::GetNonCCWObjectGlobal;
use js::jsapi::JS_WrapObject;
use js::jsapi::CurrentGlobalOrNull;
use js::jsval::{JSVal, PrivateValue};
use js::jsval::NullValue;
use js::jsval::{JSVal, PrivateValue};
use js::rust::is_dom_class;
use js::rust::wrappers::JS_FireOnNewGlobalObject;
use js::rust::wrappers::RUST_SYMBOL_TO_JSID;
@ -603,9 +602,7 @@ pub fn define_dom_interface(
assert!(!proto.is_null());
}
fn get_proto_id_for_new_target(
new_target: HandleObject,
) -> Option<PrototypeList::ID> {
fn get_proto_id_for_new_target(new_target: HandleObject) -> Option<PrototypeList::ID> {
unsafe {
let new_target_class = get_object_class(*new_target);
if is_dom_class(&*new_target_class) {
@ -644,18 +641,17 @@ pub fn get_desired_proto(
rooted!(in(*cx) let original_new_target = *new_target);
// See whether we have a known DOM constructor here, such that we can take a
// fast path.
let target_proto_id = get_proto_id_for_new_target(new_target.handle())
.or_else(|| {
// We might still have a cross-compartment wrapper for a known DOM
// constructor. CheckedUnwrapStatic is fine here, because we're looking for
// DOM constructors and those can't be cross-origin objects.
*new_target = CheckedUnwrapStatic(*new_target);
if !new_target.is_null() && &*new_target != &*original_new_target {
get_proto_id_for_new_target(new_target.handle())
} else {
None
}
});
let target_proto_id = get_proto_id_for_new_target(new_target.handle()).or_else(|| {
// We might still have a cross-compartment wrapper for a known DOM
// constructor. CheckedUnwrapStatic is fine here, because we're looking for
// DOM constructors and those can't be cross-origin objects.
*new_target = CheckedUnwrapStatic(*new_target);
if !new_target.is_null() && &*new_target != &*original_new_target {
get_proto_id_for_new_target(new_target.handle())
} else {
None
}
});
if let Some(proto_id) = target_proto_id {
let global = GetNonCCWObjectGlobal(*new_target);
@ -663,7 +659,7 @@ pub fn get_desired_proto(
desired_proto.set((*proto_or_iface_cache)[proto_id as usize]);
if &*new_target != &*original_new_target {
if !JS_WrapObject(*cx, desired_proto.into()) {
return Err(());
return Err(());
}
}
return Ok(());
@ -674,7 +670,12 @@ pub fn get_desired_proto(
// the fallback prototype we determine the fallback based on the proto id we
// were handed.
rooted!(in(*cx) let mut proto_val = NullValue());
if !JS_GetProperty(*cx, original_new_target.handle().into(), b"prototype\0".as_ptr() as *const libc::c_char, proto_val.handle_mut().into()) {
if !JS_GetProperty(
*cx,
original_new_target.handle().into(),
b"prototype\0".as_ptr() as *const libc::c_char,
proto_val.handle_mut().into(),
) {
return Err(());
}
@ -699,7 +700,7 @@ pub fn get_desired_proto(
global.handle(),
ProtoOrIfaceIndex::ID(proto_id),
creator,
desired_proto
desired_proto,
);
if desired_proto.is_null() {
return Err(());
@ -707,6 +708,6 @@ pub fn get_desired_proto(
}
maybe_wrap_object(*cx, desired_proto);
return Ok(())
return Ok(());
}
}

View file

@ -20,7 +20,7 @@ use dom_struct::dom_struct;
use js::conversions::ToJSValConvertible;
use js::jsapi::{Heap, JSObject};
use js::jsval::UndefinedValue;
use js::rust::{HandleValue, MutableHandleObject, HandleObject};
use js::rust::{HandleObject, HandleValue, MutableHandleObject};
use std::cell::Cell;
use std::ptr;
use std::ptr::NonNull;
@ -118,7 +118,12 @@ impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> IterableIterator<T> {
}
impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> DomObjectWrap for IterableIterator<T> {
const WRAP: unsafe fn(JSContext, &GlobalScope, Option<HandleObject>, Box<Self>) -> Root<Dom<Self>> = T::ITER_WRAP;
const WRAP: unsafe fn(
JSContext,
&GlobalScope,
Option<HandleObject>,
Box<Self>,
) -> Root<Dom<Self>> = T::ITER_WRAP;
}
fn dict_return(

View file

@ -118,7 +118,12 @@ impl MutDomObject for Reflector {
/// A trait to provide a function pointer to wrap function for DOM objects.
pub trait DomObjectWrap: Sized + DomObject {
/// Function pointer to the general wrap function type
const WRAP: unsafe fn(JSContext, &GlobalScope, Option<HandleObject>, Box<Self>) -> Root<Dom<Self>>;
const WRAP: unsafe fn(
JSContext,
&GlobalScope,
Option<HandleObject>,
Box<Self>,
) -> Root<Dom<Self>>;
}
/// A trait to provide a function pointer to wrap function for

View file

@ -42,8 +42,13 @@ impl Blob {
Self::new_with_proto(global, None, blob_impl)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, blob_impl: BlobImpl) -> DomRoot<Blob> {
let dom_blob = reflect_dom_object2(Box::new(Blob::new_inherited(&blob_impl)), global, proto);
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
blob_impl: BlobImpl,
) -> DomRoot<Blob> {
let dom_blob =
reflect_dom_object2(Box::new(Blob::new_inherited(&blob_impl)), global, proto);
global.track_blob(&dom_blob, blob_impl);
dom_blob
}

View file

@ -12,7 +12,7 @@ use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::JSContext as SafeJSContext;
use dom_struct::dom_struct;
use js::rust::{HandleValue, HandleObject};
use js::rust::{HandleObject, HandleValue};
use script_traits::BroadcastMsg;
use std::cell::Cell;
use uuid::Uuid;
@ -28,12 +28,24 @@ pub struct BroadcastChannel {
impl BroadcastChannel {
/// <https://html.spec.whatwg.org/multipage/#broadcastchannel>
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>, name: DOMString) -> DomRoot<BroadcastChannel> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
name: DOMString,
) -> DomRoot<BroadcastChannel> {
BroadcastChannel::new(global, proto, name)
}
fn new(global: &GlobalScope, proto: Option<HandleObject>, name: DOMString) -> DomRoot<BroadcastChannel> {
let channel = reflect_dom_object2(Box::new(BroadcastChannel::new_inherited(name)), global, proto);
fn new(
global: &GlobalScope,
proto: Option<HandleObject>,
name: DOMString,
) -> DomRoot<BroadcastChannel> {
let channel = reflect_dom_object2(
Box::new(BroadcastChannel::new_inherited(name)),
global,
proto,
);
global.track_broadcast_channel(&*channel);
channel
}

View file

@ -45,14 +45,7 @@ impl CloseEvent {
reason: DOMString,
) -> DomRoot<CloseEvent> {
Self::new_with_proto(
global,
None,
type_,
bubbles,
cancelable,
wasClean,
code,
reason,
global, None, type_, bubbles, cancelable, wasClean, code, reason,
)
}

View file

@ -26,12 +26,24 @@ impl Comment {
}
}
pub fn new(text: DOMString, document: &Document, proto: Option<HandleObject>) -> DomRoot<Comment> {
Node::reflect_node_with_proto(Box::new(Comment::new_inherited(text, document)), document, proto)
pub fn new(
text: DOMString,
document: &Document,
proto: Option<HandleObject>,
) -> DomRoot<Comment> {
Node::reflect_node_with_proto(
Box::new(Comment::new_inherited(text, document)),
document,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>, data: DOMString) -> Fallible<DomRoot<Comment>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
data: DOMString,
) -> Fallible<DomRoot<Comment>> {
let document = window.Document();
Ok(Comment::new(data, &document, proto))
}

View file

@ -43,14 +43,7 @@ impl CompositionEvent {
data: DOMString,
) -> DomRoot<CompositionEvent> {
Self::new_with_proto(
window,
None,
type_,
can_bubble,
cancelable,
view,
detail,
data,
window, None, type_, can_bubble, cancelable, view, detail, data,
)
}

View file

@ -41,7 +41,10 @@ impl CustomEvent {
Self::new_uninitialized_with_proto(global, None)
}
fn new_uninitialized_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<CustomEvent> {
fn new_uninitialized_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> DomRoot<CustomEvent> {
reflect_dom_object2(Box::new(CustomEvent::new_inherited()), global, proto)
}

View file

@ -3249,7 +3249,10 @@ impl Document {
// https://dom.spec.whatwg.org/#dom-document-document
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<Document>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<Document>> {
let doc = window.Document();
let docloader = DocumentLoader::new(&*doc.loader());
Ok(Document::new_with_proto(

View file

@ -42,7 +42,10 @@ impl DocumentFragment {
Self::new_with_proto(document, None)
}
fn new_with_proto(document: &Document, proto: Option<HandleObject>) -> DomRoot<DocumentFragment> {
fn new_with_proto(
document: &Document,
proto: Option<HandleObject>,
) -> DomRoot<DocumentFragment> {
Node::reflect_node_with_proto(
Box::new(DocumentFragment::new_inherited(document)),
document,
@ -51,7 +54,10 @@ impl DocumentFragment {
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<DocumentFragment>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<DocumentFragment>> {
let document = window.Document();
Ok(DocumentFragment::new_with_proto(&document, proto))

View file

@ -167,14 +167,22 @@ impl DOMImplementationMethods for DOMImplementation {
{
// Step 4.
let doc_node = doc.upcast::<Node>();
let doc_html =
DomRoot::upcast::<Node>(HTMLHtmlElement::new(local_name!("html"), None, &doc, None));
let doc_html = DomRoot::upcast::<Node>(HTMLHtmlElement::new(
local_name!("html"),
None,
&doc,
None,
));
doc_node.AppendChild(&doc_html).expect("Appending failed");
{
// Step 5.
let doc_head =
DomRoot::upcast::<Node>(HTMLHeadElement::new(local_name!("head"), None, &doc, None));
let doc_head = DomRoot::upcast::<Node>(HTMLHeadElement::new(
local_name!("head"),
None,
&doc,
None,
));
doc_html.AppendChild(&doc_head).unwrap();
// Step 6.

View file

@ -32,7 +32,12 @@ impl DOMMatrix {
}
#[allow(unrooted_must_root)]
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
is2D: bool,
matrix: Transform3D<f64>,
) -> DomRoot<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object2(Box::new(dommatrix), global, proto)
}
@ -50,7 +55,12 @@ impl DOMMatrix {
init: Option<StringOrUnrestrictedDoubleSequence>,
) -> Fallible<DomRoot<Self>> {
if init.is_none() {
return Ok(Self::new_with_proto(global, proto, true, Transform3D::identity()));
return Ok(Self::new_with_proto(
global,
proto,
true,
Transform3D::identity(),
));
}
match init.unwrap() {
StringOrUnrestrictedDoubleSequence::String(ref s) => {

View file

@ -45,7 +45,12 @@ impl DOMMatrixReadOnly {
}
#[allow(unrooted_must_root)]
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
is2D: bool,
matrix: Transform3D<f64>,
) -> DomRoot<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object2(Box::new(dommatrix), global, proto)
}
@ -65,7 +70,12 @@ impl DOMMatrixReadOnly {
init: Option<StringOrUnrestrictedDoubleSequence>,
) -> Fallible<DomRoot<Self>> {
if init.is_none() {
return Ok(Self::new_with_proto(global, proto, true, Transform3D::identity()));
return Ok(Self::new_with_proto(
global,
proto,
true,
Transform3D::identity(),
));
}
match init.unwrap() {
StringOrUnrestrictedDoubleSequence::String(ref s) => {

View file

@ -42,7 +42,10 @@ impl DOMParser {
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<DOMParser>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<DOMParser>> {
Ok(DOMParser::new(window, proto))
}
}

View file

@ -30,7 +30,14 @@ impl DOMPoint {
Self::new_with_proto(global, None, x, y, z, w)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPoint> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
x: f64,
y: f64,
z: f64,
w: f64,
) -> DomRoot<DOMPoint> {
reflect_dom_object2(Box::new(DOMPoint::new_inherited(x, y, z, w)), global, proto)
}

View file

@ -38,7 +38,14 @@ impl DOMPointReadOnly {
Self::new_with_proto(global, None, x, y, z, w)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPointReadOnly> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
x: f64,
y: f64,
z: f64,
w: f64,
) -> DomRoot<DOMPointReadOnly> {
reflect_dom_object2(
Box::new(DOMPointReadOnly::new_inherited(x, y, z, w)),
global,

View file

@ -54,7 +54,11 @@ impl DOMQuad {
p3: &DOMPoint,
p4: &DOMPoint,
) -> DomRoot<DOMQuad> {
reflect_dom_object2(Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)), global, proto)
reflect_dom_object2(
Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)),
global,
proto,
)
}
pub fn Constructor(

View file

@ -28,7 +28,14 @@ impl DOMRect {
Self::new_with_proto(global, None, x, y, width, height)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, x: f64, y: f64, width: f64, height: f64) -> DomRoot<DOMRect> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
x: f64,
y: f64,
width: f64,
height: f64,
) -> DomRoot<DOMRect> {
reflect_dom_object2(
Box::new(DOMRect::new_inherited(x, y, width, height)),
global,

View file

@ -1821,7 +1821,12 @@ impl Element {
{
DomRoot::from_ref(elem)
},
_ => DomRoot::upcast(HTMLBodyElement::new(local_name!("body"), None, owner_doc, None)),
_ => DomRoot::upcast(HTMLBodyElement::new(
local_name!("body"),
None,
owner_doc,
None,
)),
}
}

View file

@ -61,16 +61,7 @@ impl ErrorEvent {
error: HandleValue,
) -> DomRoot<ErrorEvent> {
Self::new_with_proto(
global,
None,
type_,
bubbles,
cancelable,
message,
filename,
lineno,
colno,
error,
global, None, type_, bubbles, cancelable, message, filename, lineno, colno, error,
)
}

View file

@ -76,7 +76,10 @@ impl Event {
Self::new_uninitialized_with_proto(global, None)
}
pub fn new_uninitialized_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Event> {
pub fn new_uninitialized_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> DomRoot<Event> {
reflect_dom_object2(Box::new(Event::new_inherited()), global, proto)
}
@ -110,7 +113,13 @@ impl Event {
) -> Fallible<DomRoot<Event>> {
let bubbles = EventBubbles::from(init.bubbles);
let cancelable = EventCancelable::from(init.cancelable);
Ok(Event::new_with_proto(global, proto, Atom::from(type_), bubbles, cancelable))
Ok(Event::new_with_proto(
global,
proto,
Atom::from(type_),
bubbles,
cancelable,
))
}
pub fn init_event(&self, type_: Atom, bubbles: bool, cancelable: bool) {

View file

@ -460,7 +460,12 @@ impl EventSource {
}
}
fn new(global: &GlobalScope, proto: Option<HandleObject>, url: ServoUrl, with_credentials: bool) -> DomRoot<EventSource> {
fn new(
global: &GlobalScope,
proto: Option<HandleObject>,
url: ServoUrl,
with_credentials: bool,
) -> DomRoot<EventSource> {
reflect_dom_object2(
Box::new(EventSource::new_inherited(url, with_credentials)),
global,

View file

@ -39,7 +39,7 @@ use fnv::FnvHasher;
use js::jsapi::JS_GetFunctionObject;
use js::rust::transform_u16_to_source_text;
use js::rust::wrappers::CompileFunction;
use js::rust::{CompileOptionsWrapper, RootedObjectVectorWrapper, HandleObject};
use js::rust::{CompileOptionsWrapper, HandleObject, RootedObjectVectorWrapper};
use libc::c_char;
use servo_atoms::Atom;
use servo_url::ServoUrl;
@ -360,7 +360,10 @@ impl EventTarget {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<EventTarget>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<EventTarget>> {
Ok(EventTarget::new(global, proto))
}

View file

@ -157,7 +157,10 @@ impl FileReader {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<FileReader>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<FileReader>> {
Ok(FileReader::new(global, proto))
}

View file

@ -36,7 +36,10 @@ impl FileReaderSync {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<FileReaderSync>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<FileReaderSync>> {
Ok(FileReaderSync::new(global, proto))
}

View file

@ -36,7 +36,10 @@ impl FocusEvent {
Self::new_uninitialized_with_proto(window, None)
}
pub fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<FocusEvent> {
pub fn new_uninitialized_with_proto(
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<FocusEvent> {
reflect_dom_object2(Box::new(FocusEvent::new_inherited()), window, proto)
}

View file

@ -46,8 +46,16 @@ impl FormData {
Self::new_with_proto(form_datums, global, None)
}
fn new_with_proto(form_datums: Option<Vec<FormDatum>>, global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<FormData> {
reflect_dom_object2(Box::new(FormData::new_inherited(form_datums)), global, proto)
fn new_with_proto(
form_datums: Option<Vec<FormDatum>>,
global: &GlobalScope,
proto: Option<HandleObject>,
) -> DomRoot<FormData> {
reflect_dom_object2(
Box::new(FormData::new_inherited(form_datums)),
global,
proto,
)
}
// https://xhr.spec.whatwg.org/#dom-formdata

View file

@ -33,14 +33,7 @@ impl FormDataEvent {
cancelable: EventCancelable,
form_data: &FormData,
) -> DomRoot<FormDataEvent> {
Self::new_with_proto(
global,
None,
type_,
can_bubble,
cancelable,
form_data,
)
Self::new_with_proto(global, None, type_, can_bubble, cancelable, form_data)
}
fn new_with_proto(

View file

@ -55,7 +55,11 @@ impl GamepadEvent {
cancelable: bool,
gamepad: &Gamepad,
) -> DomRoot<GamepadEvent> {
let ev = reflect_dom_object2(Box::new(GamepadEvent::new_inherited(&gamepad)), global, proto);
let ev = reflect_dom_object2(
Box::new(GamepadEvent::new_inherited(&gamepad)),
global,
proto,
);
{
let event = ev.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);

View file

@ -25,7 +25,11 @@ impl GPUOutOfMemoryError {
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Self> {
reflect_dom_object2(Box::new(GPUOutOfMemoryError::new_inherited()), global, proto)
reflect_dom_object2(
Box::new(GPUOutOfMemoryError::new_inherited()),
global,
proto,
)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuoutofmemoryerror-gpuoutofmemoryerror

View file

@ -28,13 +28,25 @@ impl GPUValidationError {
Self::new_with_proto(global, None, message)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, message: DOMString) -> DomRoot<Self> {
reflect_dom_object2(Box::new(GPUValidationError::new_inherited(message)), global, proto)
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
message: DOMString,
) -> DomRoot<Self> {
reflect_dom_object2(
Box::new(GPUValidationError::new_inherited(message)),
global,
proto,
)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuvalidationerror-gpuvalidationerror
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>, message: DOMString) -> DomRoot<Self> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
message: DOMString,
) -> DomRoot<Self> {
GPUValidationError::new_with_proto(global, proto, message)
}
}

View file

@ -37,7 +37,10 @@ impl HashChangeEvent {
Self::new_uninitialized_with_proto(window, None)
}
fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<HashChangeEvent> {
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,

View file

@ -63,7 +63,7 @@ impl HTMLAnchorElement {
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
proto: Option<HandleObject>,
proto: Option<HandleObject>,
) -> DomRoot<HTMLAnchorElement> {
Node::reflect_node_with_proto(
Box::new(HTMLAnchorElement::new_inherited(

View file

@ -51,7 +51,11 @@ impl HTMLAudioElement {
// https://html.spec.whatwg.org/multipage/#dom-audio
#[allow(non_snake_case)]
pub fn Audio(window: &Window, proto: Option<HandleObject>, src: Option<DOMString>) -> Fallible<DomRoot<HTMLAudioElement>> {
pub fn Audio(
window: &Window,
proto: Option<HandleObject>,
src: Option<DOMString>,
) -> Fallible<DomRoot<HTMLAudioElement>> {
let element = Element::create(
QualName::new(None, ns!(html), local_name!("audio")),
None,

View file

@ -31,7 +31,7 @@ impl HTMLBRElement {
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
proto: Option<HandleObject>
proto: Option<HandleObject>,
) -> DomRoot<HTMLBRElement> {
Node::reflect_node_with_proto(
Box::new(HTMLBRElement::new_inherited(local_name, prefix, document)),

View file

@ -45,8 +45,8 @@ use ipc_channel::router::ROUTER;
use js::jsapi::{CanCompileOffThread, CompileToStencilOffThread1, OffThreadToken};
use js::jsval::UndefinedValue;
use js::rust::{
transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, Stencil,
HandleObject,
transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, HandleObject,
Stencil,
};
use msg::constellation_msg::PipelineId;
use net_traits::request::{

View file

@ -138,7 +138,8 @@ impl HTMLTableElement {
return section;
}
let section = HTMLTableSectionElement::new(atom.clone(), None, &document_from_node(self), None);
let section =
HTMLTableSectionElement::new(atom.clone(), None, &document_from_node(self), None);
match atom {
&local_name!("thead") => self.SetTHead(Some(&section)),
&local_name!("tfoot") => self.SetTFoot(Some(&section)),
@ -299,8 +300,12 @@ impl HTMLTableElementMethods for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-createtbody
fn CreateTBody(&self) -> DomRoot<HTMLTableSectionElement> {
let tbody =
HTMLTableSectionElement::new(local_name!("tbody"), None, &document_from_node(self), None);
let tbody = HTMLTableSectionElement::new(
local_name!("tbody"),
None,
&document_from_node(self),
None,
);
let node = self.upcast::<Node>();
let last_tbody = node
.rev_children()
@ -322,7 +327,8 @@ impl HTMLTableElementMethods for HTMLTableElement {
return Err(Error::IndexSize);
}
let new_row = HTMLTableRowElement::new(local_name!("tr"), None, &document_from_node(self), None);
let new_row =
HTMLTableRowElement::new(local_name!("tr"), None, &document_from_node(self), None);
let node = self.upcast::<Node>();
if number_of_row_elements == 0 {

View file

@ -123,7 +123,12 @@ impl ImageData {
}
// https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3
#[allow(unsafe_code, non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>, width: u32, height: u32) -> Fallible<DomRoot<Self>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
width: u32,
height: u32,
) -> Fallible<DomRoot<Self>> {
unsafe { Self::new_without_jsobject(global, proto, width, height) }
}

View file

@ -15,8 +15,8 @@ use crate::dom::event::Event;
use crate::dom::uievent::UIEvent;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use keyboard_types::{Key, Modifiers};
use js::rust::HandleObject;
use keyboard_types::{Key, Modifiers};
use std::cell::Cell;
unsafe_no_jsmanaged_fields!(Key);
@ -56,7 +56,10 @@ impl KeyboardEvent {
Self::new_uninitialized_with_proto(window, None)
}
fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<KeyboardEvent> {
fn new_uninitialized_with_proto(
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<KeyboardEvent> {
reflect_dom_object2(Box::new(KeyboardEvent::new_inherited()), window, proto)
}

View file

@ -38,7 +38,11 @@ impl MediaMetadata {
Self::new_with_proto(global, None, init)
}
fn new_with_proto(global: &Window, proto: Option<HandleObject>, init: &MediaMetadataInit) -> DomRoot<MediaMetadata> {
fn new_with_proto(
global: &Window,
proto: Option<HandleObject>,
init: &MediaMetadataInit,
) -> DomRoot<MediaMetadata> {
reflect_dom_object2(Box::new(MediaMetadata::new_inherited(init)), global, proto)
}

View file

@ -51,11 +51,18 @@ impl MediaStream {
this
}
pub fn Constructor(global: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<MediaStream>> {
pub fn Constructor(
global: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<MediaStream>> {
Ok(MediaStream::new_with_proto(&global.global(), proto))
}
pub fn Constructor_(_: &Window, proto: Option<HandleObject>, stream: &MediaStream) -> Fallible<DomRoot<MediaStream>> {
pub fn Constructor_(
_: &Window,
proto: Option<HandleObject>,
stream: &MediaStream,
) -> Fallible<DomRoot<MediaStream>> {
Ok(stream.clone_with_proto(proto))
}

View file

@ -66,6 +66,11 @@ impl MediaStreamTrackAudioSourceNode {
context: &AudioContext,
options: &MediaStreamTrackAudioSourceOptions,
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
MediaStreamTrackAudioSourceNode::new_with_proto(window, proto, context, &options.mediaStreamTrack)
MediaStreamTrackAudioSourceNode::new_with_proto(
window,
proto,
context,
&options.mediaStreamTrack,
)
}
}

View file

@ -20,7 +20,10 @@ pub struct MessageChannel {
impl MessageChannel {
/// <https://html.spec.whatwg.org/multipage/#dom-messagechannel>
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<MessageChannel> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> DomRoot<MessageChannel> {
MessageChannel::new(global, proto)
}

View file

@ -94,7 +94,10 @@ impl MessageEvent {
Self::new_uninitialized_with_proto(global, None)
}
fn new_uninitialized_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<MessageEvent> {
fn new_uninitialized_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> DomRoot<MessageEvent> {
MessageEvent::new_initialized(
global,
proto,
@ -164,7 +167,8 @@ impl MessageEvent {
lastEventId: DOMString,
ports: Vec<DomRoot<MessagePort>>,
) -> DomRoot<MessageEvent> {
let ev = MessageEvent::new_initialized(global, proto, data, origin, source, lastEventId, ports);
let ev =
MessageEvent::new_initialized(global, proto, data, origin, source, lastEventId, ports);
{
let event = ev.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);

View file

@ -75,7 +75,10 @@ impl MouseEvent {
Self::new_uninitialized_with_proto(window, None)
}
fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<MouseEvent> {
fn new_uninitialized_with_proto(
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<MouseEvent> {
reflect_dom_object2(Box::new(MouseEvent::new_inherited()), window, proto)
}

View file

@ -65,7 +65,11 @@ pub struct ObserverOptions {
}
impl MutationObserver {
fn new_with_proto(global: &Window, proto: Option<HandleObject>, callback: Rc<MutationCallback>) -> DomRoot<MutationObserver> {
fn new_with_proto(
global: &Window,
proto: Option<HandleObject>,
callback: Rc<MutationCallback>,
) -> DomRoot<MutationObserver> {
let boxed_observer = Box::new(MutationObserver::new_inherited(callback));
reflect_dom_object2(boxed_observer, global, proto)
}

View file

@ -1760,7 +1760,11 @@ impl Node {
Self::reflect_node_with_proto(node, document, None)
}
pub fn reflect_node_with_proto<N>(node: Box<N>, document: &Document, proto: Option<HandleObject>) -> DomRoot<N>
pub fn reflect_node_with_proto<N>(
node: Box<N>,
document: &Document,
proto: Option<HandleObject>,
) -> DomRoot<N>
where
N: DerivedFrom<Node> + DomObject + DomObjectWrap,
{

View file

@ -32,8 +32,15 @@ impl PageTransitionEvent {
}
}
fn new_uninitialized(window: &Window, proto: Option<HandleObject>) -> DomRoot<PageTransitionEvent> {
reflect_dom_object2(Box::new(PageTransitionEvent::new_inherited()), window, proto)
fn new_uninitialized(
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<PageTransitionEvent> {
reflect_dom_object2(
Box::new(PageTransitionEvent::new_inherited()),
window,
proto,
)
}
pub fn new(

View file

@ -89,7 +89,12 @@ impl PerformanceObserver {
proto: Option<HandleObject>,
callback: Rc<PerformanceObserverCallback>,
) -> Fallible<DomRoot<PerformanceObserver>> {
Ok(PerformanceObserver::new_with_proto(global, proto, callback, Vec::new()))
Ok(PerformanceObserver::new_with_proto(
global,
proto,
callback,
Vec::new(),
))
}
/// Buffer a new performance entry.

View file

@ -440,7 +440,11 @@ impl Request {
}
impl Request {
fn from_net_request(global: &GlobalScope, proto: Option<HandleObject>, net_request: NetTraitsRequest) -> DomRoot<Request> {
fn from_net_request(
global: &GlobalScope,
proto: Option<HandleObject>,
net_request: NetTraitsRequest,
) -> DomRoot<Request> {
let r = Request::new(global, proto, net_request.current_url());
*r.request.borrow_mut() = net_request;
r

View file

@ -45,7 +45,12 @@ impl RTCError {
Self::new_with_proto(global, None, init, message)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, init: &RTCErrorInit, message: DOMString) -> DomRoot<RTCError> {
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
init: &RTCErrorInit,
message: DOMString,
) -> DomRoot<RTCError> {
reflect_dom_object2(
Box::new(RTCError::new_inherited(global, init, message)),
global,

View file

@ -49,7 +49,11 @@ impl RTCErrorEvent {
cancelable: bool,
error: &RTCError,
) -> DomRoot<RTCErrorEvent> {
let event = reflect_dom_object2(Box::new(RTCErrorEvent::new_inherited(&error)), global, proto);
let event = reflect_dom_object2(
Box::new(RTCErrorEvent::new_inherited(&error)),
global,
proto,
);
{
let event = event.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);

View file

@ -46,7 +46,14 @@ impl RTCIceCandidate {
sdp_m_line_index: Option<u16>,
username_fragment: Option<DOMString>,
) -> DomRoot<RTCIceCandidate> {
Self::new_with_proto(global, None, candidate, sdp_m_id, sdp_m_line_index, username_fragment)
Self::new_with_proto(
global,
None,
candidate,
sdp_m_id,
sdp_m_line_index,
username_fragment,
)
}
fn new_with_proto(

View file

@ -193,7 +193,11 @@ impl RTCPeerConnection {
}
}
fn new(global: &GlobalScope, proto: Option<HandleObject>, config: &RTCConfiguration) -> DomRoot<RTCPeerConnection> {
fn new(
global: &GlobalScope,
proto: Option<HandleObject>,
config: &RTCConfiguration,
) -> DomRoot<RTCPeerConnection> {
let this = reflect_dom_object2(Box::new(RTCPeerConnection::new_inherited()), global, proto);
let signaller = this.make_signaller();
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
@ -632,20 +636,28 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
.borrow_mut()
.as_ref()
.unwrap()
.set_local_description(desc.clone(), (move || {
.set_local_description(
desc.clone(),
(move || {
let _ = task_source.queue_with_canceller(
task!(local_description_set: move || {
// XXXManishearth spec actually asks for an intricate
// dance between pending/current local/remote descriptions
let this = this.root();
let desc = desc.into();
let desc = RTCSessionDescription::Constructor(&this.global().as_window(), None, &desc).unwrap();
let desc = RTCSessionDescription::Constructor(
&this.global().as_window(),
None,
&desc,
).unwrap();
this.local_description.set(Some(&desc));
trusted_promise.root().resolve_native(&())
}),
&canceller,
);
}).into());
})
.into(),
);
p
}
@ -665,20 +677,28 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
.borrow_mut()
.as_ref()
.unwrap()
.set_remote_description(desc.clone(), (move || {
.set_remote_description(
desc.clone(),
(move || {
let _ = task_source.queue_with_canceller(
task!(remote_description_set: move || {
// XXXManishearth spec actually asks for an intricate
// dance between pending/current local/remote descriptions
let this = this.root();
let desc = desc.into();
let desc = RTCSessionDescription::Constructor(&this.global().as_window(), None, &desc).unwrap();
let desc = RTCSessionDescription::Constructor(
&this.global().as_window(),
None,
&desc,
).unwrap();
this.remote_description.set(Some(&desc));
trusted_promise.root().resolve_native(&())
}),
&canceller,
);
}).into());
})
.into(),
);
p
}

View file

@ -50,7 +50,11 @@ impl RTCTrackEvent {
cancelable: bool,
track: &MediaStreamTrack,
) -> DomRoot<RTCTrackEvent> {
let trackevent = reflect_dom_object2(Box::new(RTCTrackEvent::new_inherited(&track)), global, proto);
let trackevent = reflect_dom_object2(
Box::new(RTCTrackEvent::new_inherited(&track)),
global,
proto,
);
{
let event = trackevent.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);

View file

@ -51,7 +51,11 @@ impl StorageEvent {
Self::new_uninitialized_with_proto(window, None, url)
}
fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>, url: DOMString) -> DomRoot<StorageEvent> {
fn new_uninitialized_with_proto(
window: &Window,
proto: Option<HandleObject>,
url: DOMString,
) -> DomRoot<StorageEvent> {
reflect_dom_object2(
Box::new(StorageEvent::new_inherited(None, None, None, url, None)),
window,

View file

@ -50,7 +50,11 @@ impl SubmitEvent {
cancelable: bool,
submitter: Option<DomRoot<HTMLElement>>,
) -> DomRoot<SubmitEvent> {
let ev = reflect_dom_object2(Box::new(SubmitEvent::new_inherited(submitter)), global, proto);
let ev = reflect_dom_object2(
Box::new(SubmitEvent::new_inherited(submitter)),
global,
proto,
);
{
let event = ev.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);

View file

@ -88,17 +88,28 @@ impl TestBinding {
reflect_dom_object2(Box::new(TestBinding::new_inherited()), global, proto)
}
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<TestBinding>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global, proto))
}
#[allow(unused_variables)]
pub fn Constructor_(global: &GlobalScope, proto: Option<HandleObject>, nums: Vec<f64>) -> Fallible<DomRoot<TestBinding>> {
pub fn Constructor_(
global: &GlobalScope,
proto: Option<HandleObject>,
nums: Vec<f64>,
) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global, proto))
}
#[allow(unused_variables)]
pub fn Constructor__(global: &GlobalScope, proto: Option<HandleObject>, num: f64) -> Fallible<DomRoot<TestBinding>> {
pub fn Constructor__(
global: &GlobalScope,
proto: Option<HandleObject>,
num: f64,
) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global, proto))
}
}

View file

@ -33,7 +33,10 @@ impl TestBindingIterable {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<TestBindingIterable>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<TestBindingIterable>> {
Ok(TestBindingIterable::new(global, proto))
}
}

View file

@ -60,7 +60,10 @@ impl TestBindingPairIterable {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<TestBindingPairIterable>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<TestBindingPairIterable>> {
Ok(TestBindingPairIterable::new(global, proto))
}
}

View file

@ -38,11 +38,18 @@ impl TestWorklet {
fn new(window: &Window, proto: Option<HandleObject>) -> DomRoot<TestWorklet> {
let worklet = Worklet::new(window, WorkletGlobalScopeType::Test);
reflect_dom_object2(Box::new(TestWorklet::new_inherited(&*worklet)), window, proto)
reflect_dom_object2(
Box::new(TestWorklet::new_inherited(&*worklet)),
window,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<TestWorklet>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<TestWorklet>> {
Ok(TestWorklet::new(window, proto))
}
}

View file

@ -35,12 +35,24 @@ impl Text {
Self::new_with_proto(text, document, None)
}
fn new_with_proto(text: DOMString, document: &Document, proto: Option<HandleObject>) -> DomRoot<Text> {
Node::reflect_node_with_proto(Box::new(Text::new_inherited(text, document)), document, proto)
fn new_with_proto(
text: DOMString,
document: &Document,
proto: Option<HandleObject>,
) -> DomRoot<Text> {
Node::reflect_node_with_proto(
Box::new(Text::new_inherited(text, document)),
document,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>, text: DOMString) -> Fallible<DomRoot<Text>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
text: DOMString,
) -> Fallible<DomRoot<Text>> {
let document = window.Document();
Ok(Text::new_with_proto(text, &document, proto))
}

View file

@ -34,7 +34,10 @@ impl TextEncoder {
// https://encoding.spec.whatwg.org/#dom-textencoder
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<TextEncoder>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<TextEncoder>> {
Ok(TextEncoder::new(global, proto))
}
}

View file

@ -50,7 +50,11 @@ impl TransitionEvent {
type_: Atom,
init: &TransitionEventInit,
) -> DomRoot<TransitionEvent> {
let ev = reflect_dom_object2(Box::new(TransitionEvent::new_inherited(init)), window, proto);
let ev = reflect_dom_object2(
Box::new(TransitionEvent::new_inherited(init)),
window,
proto,
);
{
let event = ev.upcast::<Event>();
event.init_event(type_, init.parent.bubbles, init.parent.cancelable);
@ -65,7 +69,12 @@ impl TransitionEvent {
type_: DOMString,
init: &TransitionEventInit,
) -> Fallible<DomRoot<TransitionEvent>> {
Ok(TransitionEvent::new_with_proto(window, proto, Atom::from(type_), init))
Ok(TransitionEvent::new_with_proto(
window,
proto,
Atom::from(type_),
init,
))
}
}

View file

@ -39,7 +39,10 @@ impl UIEvent {
Self::new_uninitialized_with_proto(window, None)
}
fn new_uninitialized_with_proto(window: &Window, proto: Option<HandleObject>) -> DomRoot<UIEvent> {
fn new_uninitialized_with_proto(
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<UIEvent> {
reflect_dom_object2(Box::new(UIEvent::new_inherited()), window, proto)
}

View file

@ -40,7 +40,11 @@ impl URLSearchParams {
Self::new_with_proto(global, None, url)
}
pub fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, url: Option<&URL>) -> DomRoot<URLSearchParams> {
pub fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
url: Option<&URL>,
) -> DomRoot<URLSearchParams> {
reflect_dom_object2(Box::new(URLSearchParams::new_inherited(url)), global, proto)
}

View file

@ -131,7 +131,11 @@ impl WebSocket {
url: ServoUrl,
sender: IpcSender<WebSocketDomAction>,
) -> DomRoot<WebSocket> {
reflect_dom_object2(Box::new(WebSocket::new_inherited(url, sender)), global, proto)
reflect_dom_object2(
Box::new(WebSocket::new_inherited(url, sender)),
global,
proto,
)
}
/// <https://html.spec.whatwg.org/multipage/#dom-websocket>

View file

@ -55,16 +55,7 @@ impl WheelEvent {
delta_mode: u32,
) -> DomRoot<WheelEvent> {
Self::new_with_proto(
window,
None,
type_,
can_bubble,
cancelable,
view,
detail,
delta_x,
delta_y,
delta_z,
window, None, type_, can_bubble, cancelable, view, detail, delta_x, delta_y, delta_z,
delta_mode,
)
}

View file

@ -69,7 +69,11 @@ impl Worker {
sender: Sender<DedicatedWorkerScriptMsg>,
closing: Arc<AtomicBool>,
) -> DomRoot<Worker> {
reflect_dom_object2(Box::new(Worker::new_inherited(sender, closing)), global, proto)
reflect_dom_object2(
Box::new(Worker::new_inherited(sender, closing)),
global,
proto,
)
}
// https://html.spec.whatwg.org/multipage/#dom-worker

View file

@ -52,8 +52,8 @@ use ipc_channel::router::ROUTER;
use js::jsapi::JS_ClearPendingException;
use js::jsapi::{Heap, JSObject};
use js::jsval::{JSVal, NullValue, UndefinedValue};
use js::rust::HandleObject;
use js::rust::wrappers::JS_ParseJSON;
use js::rust::HandleObject;
use js::typedarray::{ArrayBuffer, CreateWith};
use mime::{self, Mime, Name};
use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder, RequestMode};
@ -216,12 +216,19 @@ impl XMLHttpRequest {
}
fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<XMLHttpRequest> {
reflect_dom_object2(Box::new(XMLHttpRequest::new_inherited(global)), global, proto)
reflect_dom_object2(
Box::new(XMLHttpRequest::new_inherited(global)),
global,
proto,
)
}
// https://xhr.spec.whatwg.org/#constructors
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<XMLHttpRequest>> {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<XMLHttpRequest>> {
Ok(XMLHttpRequest::new(global, proto))
}

View file

@ -28,11 +28,18 @@ impl XMLSerializer {
}
pub fn new(window: &Window, proto: Option<HandleObject>) -> DomRoot<XMLSerializer> {
reflect_dom_object2(Box::new(XMLSerializer::new_inherited(window)), window, proto)
reflect_dom_object2(
Box::new(XMLSerializer::new_inherited(window)),
window,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<XMLSerializer>> {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
) -> Fallible<DomRoot<XMLSerializer>> {
Ok(XMLSerializer::new(window, proto))
}
}

View file

@ -55,14 +55,7 @@ impl XRInputSourcesChangeEvent {
removed: &[DomRoot<XRInputSource>],
) -> DomRoot<XRInputSourcesChangeEvent> {
Self::new_with_proto(
global,
None,
type_,
bubbles,
cancelable,
session,
added,
removed,
global, None, type_, bubbles, cancelable, session, added, removed,
)
}

View file

@ -33,12 +33,24 @@ impl XRMediaBinding {
}
}
fn new(global: &Window, proto: Option<HandleObject>, session: &XRSession) -> DomRoot<XRMediaBinding> {
reflect_dom_object2(Box::new(XRMediaBinding::new_inherited(session)), global, proto)
fn new(
global: &Window,
proto: Option<HandleObject>,
session: &XRSession,
) -> DomRoot<XRMediaBinding> {
reflect_dom_object2(
Box::new(XRMediaBinding::new_inherited(session)),
global,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(global: &Window, proto: Option<HandleObject>, session: &XRSession) -> Fallible<DomRoot<XRMediaBinding>> {
pub fn Constructor(
global: &Window,
proto: Option<HandleObject>,
session: &XRSession,
) -> Fallible<DomRoot<XRMediaBinding>> {
// Step 1.
if session.is_ended() {
return Err(Error::InvalidState);

View file

@ -38,7 +38,11 @@ impl XRRay {
}
}
fn new(global: &GlobalScope, proto: Option<HandleObject>, ray: Ray<ApiSpace>) -> DomRoot<XRRay> {
fn new(
global: &GlobalScope,
proto: Option<HandleObject>,
ray: Ray<ApiSpace>,
) -> DomRoot<XRRay> {
reflect_dom_object2(Box::new(XRRay::new_inherited(ray)), global, proto)
}
@ -70,19 +74,31 @@ impl XRRay {
)
.normalize();
Ok(Self::new(&window.global(), proto, Ray { origin, direction }))
Ok(Self::new(
&window.global(),
proto,
Ray { origin, direction },
))
}
#[allow(non_snake_case)]
/// https://immersive-web.github.io/hit-test/#dom-xrray-xrray-transform
pub fn Constructor_(window: &Window, proto: Option<HandleObject>, transform: &XRRigidTransform) -> Fallible<DomRoot<Self>> {
pub fn Constructor_(
window: &Window,
proto: Option<HandleObject>,
transform: &XRRigidTransform,
) -> Fallible<DomRoot<Self>> {
let transform = transform.transform();
let origin = transform.translation;
let direction = transform
.rotation
.transform_vector3d(Vector3D::new(0., 0., -1.));
Ok(Self::new(&window.global(), proto, Ray { origin, direction }))
Ok(Self::new(
&window.global(),
proto,
Ray { origin, direction },
))
}
pub fn ray(&self) -> Ray<ApiSpace> {

View file

@ -49,8 +49,16 @@ impl XRRigidTransform {
Self::new_with_proto(global, None, transform)
}
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, transform: ApiRigidTransform) -> DomRoot<XRRigidTransform> {
reflect_dom_object2(Box::new(XRRigidTransform::new_inherited(transform)), global, proto)
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
transform: ApiRigidTransform,
) -> DomRoot<XRRigidTransform> {
reflect_dom_object2(
Box::new(XRRigidTransform::new_inherited(transform)),
global,
proto,
)
}
pub fn identity(window: &GlobalScope) -> DomRoot<XRRigidTransform> {
@ -87,7 +95,11 @@ impl XRRigidTransform {
return Err(Error::InvalidState);
}
let transform = RigidTransform3D::new(rotate, translate);
Ok(XRRigidTransform::new_with_proto(&window.global(), proto, transform))
Ok(XRRigidTransform::new_with_proto(
&window.global(),
proto,
transform,
))
}
}

View file

@ -50,8 +50,11 @@ impl XRSessionEvent {
cancelable: bool,
session: &XRSession,
) -> DomRoot<XRSessionEvent> {
let trackevent =
reflect_dom_object2(Box::new(XRSessionEvent::new_inherited(&session)), global, proto);
let trackevent = reflect_dom_object2(
Box::new(XRSessionEvent::new_inherited(&session)),
global,
proto,
);
{
let event = trackevent.upcast::<Event>();
event.init_event(type_, bubbles, cancelable);