aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r--components/script/dom/bindings/callback.rs26
-rw-r--r--components/script/dom/bindings/cell.rs10
-rw-r--r--components/script/dom/bindings/constant.rs6
-rw-r--r--components/script/dom/bindings/conversions.rs44
-rw-r--r--components/script/dom/bindings/error.rs34
-rw-r--r--components/script/dom/bindings/guard.rs8
-rw-r--r--components/script/dom/bindings/htmlconstructor.rs112
-rw-r--r--components/script/dom/bindings/inheritance.rs7
-rw-r--r--components/script/dom/bindings/interface.rs65
-rw-r--r--components/script/dom/bindings/iterable.rs23
-rw-r--r--components/script/dom/bindings/like.rs7
-rw-r--r--components/script/dom/bindings/namespace.rs8
-rw-r--r--components/script/dom/bindings/num.rs5
-rw-r--r--components/script/dom/bindings/principals.rs18
-rw-r--r--components/script/dom/bindings/proxyhandler.rs65
-rw-r--r--components/script/dom/bindings/record.rs37
-rw-r--r--components/script/dom/bindings/refcounted.rs21
-rw-r--r--components/script/dom/bindings/reflector.rs8
-rw-r--r--components/script/dom/bindings/root.rs24
-rw-r--r--components/script/dom/bindings/settings_stack.rs13
-rw-r--r--components/script/dom/bindings/str.rs17
-rw-r--r--components/script/dom/bindings/structuredclone.rs48
-rw-r--r--components/script/dom/bindings/trace.rs51
-rw-r--r--components/script/dom/bindings/transferable.rs3
-rw-r--r--components/script/dom/bindings/utils.rs68
-rw-r--r--components/script/dom/bindings/weakref.rs20
-rw-r--r--components/script/dom/bindings/xmlname.rs3
27 files changed, 347 insertions, 404 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs
index 9b14f3ced60..4389c9fc280 100644
--- a/components/script/dom/bindings/callback.rs
+++ b/components/script/dom/bindings/callback.rs
@@ -4,6 +4,20 @@
//! Base classes to work with IDL callbacks.
+use std::default::Default;
+use std::ffi::CString;
+use std::mem::drop;
+use std::ops::Deref;
+use std::ptr;
+use std::rc::Rc;
+
+use js::jsapi::{
+ AddRawValueRoot, EnterRealm, Heap, IsCallable, JSObject, LeaveRealm, Realm, RemoveRawValueRoot,
+};
+use js::jsval::{JSVal, ObjectValue, UndefinedValue};
+use js::rust::wrappers::{JS_GetProperty, JS_WrapObject};
+use js::rust::{MutableHandleObject, Runtime};
+
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::error::{report_pending_exception, Error, Fallible};
use crate::dom::bindings::inheritance::Castable;
@@ -15,18 +29,6 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use crate::realms::{enter_realm, InRealm};
use crate::script_runtime::JSContext;
-use js::jsapi::Heap;
-use js::jsapi::{AddRawValueRoot, IsCallable, JSObject};
-use js::jsapi::{EnterRealm, LeaveRealm, Realm, RemoveRawValueRoot};
-use js::jsval::{JSVal, ObjectValue, UndefinedValue};
-use js::rust::wrappers::{JS_GetProperty, JS_WrapObject};
-use js::rust::{MutableHandleObject, Runtime};
-use std::default::Default;
-use std::ffi::CString;
-use std::mem::drop;
-use std::ops::Deref;
-use std::ptr;
-use std::rc::Rc;
/// The exception handling used for a call.
#[derive(Clone, Copy, PartialEq)]
diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs
index 7d567e04847..124240e311e 100644
--- a/components/script/dom/bindings/cell.rs
+++ b/components/script/dom/bindings/cell.rs
@@ -4,14 +4,16 @@
//! A shareable mutable container for the DOM.
-use crate::dom::bindings::root::{assert_in_layout, assert_in_script};
+use std::cell::{BorrowError, BorrowMutError};
+#[cfg(not(feature = "refcell_backtrace"))]
+pub use std::cell::{Ref, RefCell, RefMut};
+
#[cfg(feature = "refcell_backtrace")]
pub use accountable_refcell::{ref_filter_map, Ref, RefCell, RefMut};
#[cfg(not(feature = "refcell_backtrace"))]
pub use ref_filter_map::ref_filter_map;
-use std::cell::{BorrowError, BorrowMutError};
-#[cfg(not(feature = "refcell_backtrace"))]
-pub use std::cell::{Ref, RefCell, RefMut};
+
+use crate::dom::bindings::root::{assert_in_layout, assert_in_script};
/// A mutable field in the DOM.
///
diff --git a/components/script/dom/bindings/constant.rs b/components/script/dom/bindings/constant.rs
index bce6e3d7844..4bfa3c67338 100644
--- a/components/script/dom/bindings/constant.rs
+++ b/components/script/dom/bindings/constant.rs
@@ -4,13 +4,13 @@
//! WebIDL constants.
-use crate::script_runtime::JSContext;
-use js::jsapi::JSPROP_READONLY;
-use js::jsapi::{JSPROP_ENUMERATE, JSPROP_PERMANENT};
+use js::jsapi::{JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UInt32Value};
use js::rust::wrappers::JS_DefineProperty;
use js::rust::HandleObject;
+use crate::script_runtime::JSContext;
+
/// Representation of an IDL constant.
#[derive(Clone)]
pub struct ConstantSpec {
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs
index 405789f294d..0c79b67134c 100644
--- a/components/script/dom/bindings/conversions.rs
+++ b/components/script/dom/bindings/conversions.rs
@@ -32,6 +32,28 @@
//! | sequences | `Vec<T>` | |
//! | union types | `T` | |
+use std::{char, ffi, ptr, slice};
+
+use js::conversions::latin1_to_string;
+pub use js::conversions::{
+ ConversionBehavior, ConversionResult, FromJSValConvertible, ToJSValConvertible,
+};
+use js::error::throw_type_error;
+use js::glue::{GetProxyReservedSlot, IsWrapper, JS_GetReservedSlot, UnwrapObjectDynamic};
+use js::jsapi::{
+ Heap, IsWindowProxy, JSContext, JSObject, JSString, JS_DeprecatedStringHasLatin1Chars,
+ JS_GetLatin1StringCharsAndLength, JS_GetTwoByteStringCharsAndLength, JS_IsExceptionPending,
+ JS_NewStringCopyN,
+};
+use js::jsval::{ObjectValue, StringValue, UndefinedValue};
+use js::rust::wrappers::{IsArrayObject, JS_GetProperty, JS_HasProperty};
+use js::rust::{
+ get_object_class, is_dom_class, is_dom_object, maybe_wrap_value, HandleId, HandleObject,
+ HandleValue, MutableHandleValue, ToString,
+};
+use num_traits::Float;
+use servo_config::opts;
+
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::num::Finite;
@@ -46,25 +68,6 @@ use crate::dom::htmlformcontrolscollection::HTMLFormControlsCollection;
use crate::dom::htmloptionscollection::HTMLOptionsCollection;
use crate::dom::nodelist::NodeList;
use crate::dom::windowproxy::WindowProxy;
-use js::conversions::latin1_to_string;
-pub use js::conversions::ConversionBehavior;
-pub use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
-use js::error::throw_type_error;
-use js::glue::GetProxyReservedSlot;
-use js::glue::JS_GetReservedSlot;
-use js::glue::{IsWrapper, UnwrapObjectDynamic};
-use js::jsapi::{Heap, JSContext, JSObject, JSString};
-use js::jsapi::{IsWindowProxy, JS_DeprecatedStringHasLatin1Chars, JS_NewStringCopyN};
-use js::jsapi::{
- JS_GetLatin1StringCharsAndLength, JS_GetTwoByteStringCharsAndLength, JS_IsExceptionPending,
-};
-use js::jsval::{ObjectValue, StringValue, UndefinedValue};
-use js::rust::wrappers::{IsArrayObject, JS_GetProperty, JS_HasProperty};
-use js::rust::{get_object_class, is_dom_class, is_dom_object, maybe_wrap_value, ToString};
-use js::rust::{HandleId, HandleObject, HandleValue, MutableHandleValue};
-use num_traits::Float;
-use servo_config::opts;
-use std::{char, ffi, ptr, slice};
/// A trait to check whether a given `JSObject` implements an IDL interface.
pub trait IDLInterface {
@@ -384,9 +387,10 @@ pub unsafe fn private_from_object(obj: *mut JSObject) -> *const libc::c_void {
/// Get the `DOMClass` from `obj`, or `Err(())` if `obj` is not a DOM object.
pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<&'static DOMClass, ()> {
- use crate::dom::bindings::utils::DOMJSClass;
use js::glue::GetProxyHandlerExtra;
+ use crate::dom::bindings::utils::DOMJSClass;
+
let clasp = get_object_class(obj);
if is_dom_class(&*clasp) {
trace!("plain old dom object");
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index 87df14d0544..2e578b4d2f3 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -4,34 +4,32 @@
//! Utilities to throw exceptions from Rust bindings.
+use std::slice::from_raw_parts;
+
+#[cfg(feature = "js_backtrace")]
+use backtrace::Backtrace;
+use js::error::{throw_range_error, throw_type_error};
+#[cfg(feature = "js_backtrace")]
+use js::jsapi::StackFormat as JSStackFormat;
+use js::jsapi::{
+ ExceptionStackBehavior, JSContext, JS_ClearPendingException, JS_IsExceptionPending,
+};
+use js::jsval::UndefinedValue;
+use js::rust::wrappers::{JS_ErrorFromException, JS_GetPendingException, JS_SetPendingException};
+use js::rust::{HandleObject, HandleValue, MutableHandleValue};
+use libc::c_uint;
+
#[cfg(feature = "js_backtrace")]
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::PrototypeList::proto_id_to_name;
-use crate::dom::bindings::conversions::root_from_object;
use crate::dom::bindings::conversions::{
- ConversionResult, FromJSValConvertible, ToJSValConvertible,
+ root_from_object, ConversionResult, FromJSValConvertible, ToJSValConvertible,
};
use crate::dom::bindings::str::USVString;
use crate::dom::domexception::{DOMErrorName, DOMException};
use crate::dom::globalscope::GlobalScope;
use crate::realms::InRealm;
use crate::script_runtime::JSContext as SafeJSContext;
-#[cfg(feature = "js_backtrace")]
-use backtrace::Backtrace;
-use js::error::{throw_range_error, throw_type_error};
-use js::jsapi::ExceptionStackBehavior;
-use js::jsapi::JSContext;
-use js::jsapi::JS_ClearPendingException;
-use js::jsapi::JS_IsExceptionPending;
-#[cfg(feature = "js_backtrace")]
-use js::jsapi::StackFormat as JSStackFormat;
-use js::jsval::UndefinedValue;
-use js::rust::wrappers::JS_ErrorFromException;
-use js::rust::wrappers::JS_GetPendingException;
-use js::rust::wrappers::JS_SetPendingException;
-use js::rust::{HandleObject, HandleValue, MutableHandleValue};
-use libc::c_uint;
-use std::slice::from_raw_parts;
#[cfg(feature = "js_backtrace")]
thread_local! {
diff --git a/components/script/dom/bindings/guard.rs b/components/script/dom/bindings/guard.rs
index 17f3a3d20bc..4702e0b71e6 100644
--- a/components/script/dom/bindings/guard.rs
+++ b/components/script/dom/bindings/guard.rs
@@ -4,14 +4,14 @@
//! Machinery to conditionally expose things.
+use js::rust::HandleObject;
+use servo_config::prefs;
+
use crate::dom::bindings::codegen::InterfaceObjectMap;
use crate::dom::bindings::interface::is_exposed_in;
use crate::dom::globalscope::GlobalScope;
-use crate::realms::AlreadyInRealm;
-use crate::realms::InRealm;
+use crate::realms::{AlreadyInRealm, InRealm};
use crate::script_runtime::JSContext;
-use js::rust::HandleObject;
-use servo_config::prefs;
/// A container with a condition.
pub struct Guard<T: Clone + Copy> {
diff --git a/components/script/dom/bindings/htmlconstructor.rs b/components/script/dom/bindings/htmlconstructor.rs
index 5eb79e28e1b..703bfeb7c70 100644
--- a/components/script/dom/bindings/htmlconstructor.rs
+++ b/components/script/dom/bindings/htmlconstructor.rs
@@ -2,74 +2,42 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::dom::bindings::codegen::Bindings::HTMLAnchorElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLBRElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLBaseElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDListElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDataListElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDetailsElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDialogElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDirectoryElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLDivElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLEmbedElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLFontElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLFrameElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLHtmlElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLLIElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLLegendElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLMapElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLMenuElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLMeterElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLModElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLOListElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLOutputElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLParagraphElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLParamElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLPictureElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLPreElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLProgressElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLQuoteElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLScriptElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLSpanElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLStyleElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableColElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTimeElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLTrackElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLUListElementBinding;
-use crate::dom::bindings::codegen::Bindings::HTMLVideoElementBinding;
+use std::ptr;
+
+use html5ever::interface::QualName;
+use html5ever::{local_name, namespace_url, ns, LocalName};
+use js::conversions::ToJSValConvertible;
+use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
+use js::jsapi::{CallArgs, CurrentGlobalOrNull, JSAutoRealm, JSObject};
+use js::jsval::UndefinedValue;
+use js::rust::wrappers::{JS_GetProperty, JS_SetPrototype, JS_WrapObject};
+use js::rust::{HandleObject, MutableHandleObject, MutableHandleValue};
+
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
+use crate::dom::bindings::codegen::Bindings::{
+ HTMLAnchorElementBinding, HTMLAreaElementBinding, HTMLAudioElementBinding,
+ HTMLBRElementBinding, HTMLBaseElementBinding, HTMLBodyElementBinding, HTMLButtonElementBinding,
+ HTMLCanvasElementBinding, HTMLDListElementBinding, HTMLDataElementBinding,
+ HTMLDataListElementBinding, HTMLDetailsElementBinding, HTMLDialogElementBinding,
+ HTMLDirectoryElementBinding, HTMLDivElementBinding, HTMLElementBinding,
+ HTMLEmbedElementBinding, HTMLFieldSetElementBinding, HTMLFontElementBinding,
+ HTMLFormElementBinding, HTMLFrameElementBinding, HTMLFrameSetElementBinding,
+ HTMLHRElementBinding, HTMLHeadElementBinding, HTMLHeadingElementBinding,
+ HTMLHtmlElementBinding, HTMLIFrameElementBinding, HTMLImageElementBinding,
+ HTMLInputElementBinding, HTMLLIElementBinding, HTMLLabelElementBinding,
+ HTMLLegendElementBinding, HTMLLinkElementBinding, HTMLMapElementBinding,
+ HTMLMenuElementBinding, HTMLMetaElementBinding, HTMLMeterElementBinding, HTMLModElementBinding,
+ HTMLOListElementBinding, HTMLObjectElementBinding, HTMLOptGroupElementBinding,
+ HTMLOptionElementBinding, HTMLOutputElementBinding, HTMLParagraphElementBinding,
+ HTMLParamElementBinding, HTMLPictureElementBinding, HTMLPreElementBinding,
+ HTMLProgressElementBinding, HTMLQuoteElementBinding, HTMLScriptElementBinding,
+ HTMLSelectElementBinding, HTMLSourceElementBinding, HTMLSpanElementBinding,
+ HTMLStyleElementBinding, HTMLTableCaptionElementBinding, HTMLTableCellElementBinding,
+ HTMLTableColElementBinding, HTMLTableElementBinding, HTMLTableRowElementBinding,
+ HTMLTableSectionElementBinding, HTMLTemplateElementBinding, HTMLTextAreaElementBinding,
+ HTMLTimeElementBinding, HTMLTitleElementBinding, HTMLTrackElementBinding,
+ HTMLUListElementBinding, HTMLVideoElementBinding,
+};
use crate::dom::bindings::conversions::DerivedFrom;
use crate::dom::bindings::error::{throw_dom_exception, Error};
use crate::dom::bindings::inheritance::Castable;
@@ -83,16 +51,6 @@ use crate::dom::htmlelement::HTMLElement;
use crate::dom::window::Window;
use crate::script_runtime::JSContext;
use crate::script_thread::ScriptThread;
-use html5ever::interface::QualName;
-use html5ever::{local_name, namespace_url, ns, LocalName};
-use js::conversions::ToJSValConvertible;
-use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
-use js::jsapi::{CallArgs, CurrentGlobalOrNull};
-use js::jsapi::{JSAutoRealm, JSObject};
-use js::jsval::UndefinedValue;
-use js::rust::wrappers::{JS_GetProperty, JS_SetPrototype, JS_WrapObject};
-use js::rust::{HandleObject, MutableHandleObject, MutableHandleValue};
-use std::ptr;
// https://html.spec.whatwg.org/multipage/#htmlconstructor
unsafe fn html_constructor(
diff --git a/components/script/dom/bindings/inheritance.rs b/components/script/dom/bindings/inheritance.rs
index b9091221221..9ef1f7ad0a1 100644
--- a/components/script/dom/bindings/inheritance.rs
+++ b/components/script/dom/bindings/inheritance.rs
@@ -4,12 +4,11 @@
//! The `Castable` trait.
-pub use crate::dom::bindings::codegen::InheritTypes::*;
+use std::mem;
-use crate::dom::bindings::conversions::get_dom_class;
-use crate::dom::bindings::conversions::{DerivedFrom, IDLInterface};
+pub use crate::dom::bindings::codegen::InheritTypes::*;
+use crate::dom::bindings::conversions::{get_dom_class, DerivedFrom, IDLInterface};
use crate::dom::bindings::reflector::DomObject;
-use std::mem;
/// A trait to hold the cast functions of IDL interfaces that either derive
/// or are derived from other interfaces.
diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs
index 0874881deec..cbe67894170 100644
--- a/components/script/dom/bindings/interface.rs
+++ b/components/script/dom/bindings/interface.rs
@@ -4,6 +4,34 @@
//! Machinery to initialise interface prototype objects and interface objects.
+use std::convert::TryFrom;
+use std::ptr;
+
+use js::error::throw_type_error;
+use js::glue::UncheckedUnwrapObject;
+use js::jsapi::JS::CompartmentIterResult;
+use js::jsapi::{
+ jsid, CallArgs, CheckedUnwrapStatic, Compartment, CompartmentSpecifier, CurrentGlobalOrNull,
+ GetFunctionRealm, GetNonCCWObjectGlobal, GetRealmGlobalOrNull, GetWellKnownSymbol,
+ HandleObject as RawHandleObject, IsSharableCompartment, IsSystemCompartment, JSAutoRealm,
+ JSClass, JSClassOps, JSContext, JSFunctionSpec, JSObject, JSPropertySpec, JSString, JSTracer,
+ JS_AtomizeAndPinString, JS_GetFunctionObject, JS_GetProperty, JS_IterateCompartments,
+ JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewPlainObject, JS_NewStringCopyN,
+ JS_SetReservedSlot, JS_WrapObject, ObjectOps, OnNewGlobalHookOption, SymbolCode,
+ TrueHandleValue, Value, JSFUN_CONSTRUCTOR, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING,
+};
+use js::jsval::{JSVal, NullValue, PrivateValue};
+use js::rust::wrappers::{
+ JS_DefineProperty, JS_DefineProperty3, JS_DefineProperty4, JS_DefineProperty5,
+ JS_DefinePropertyById5, JS_FireOnNewGlobalObject, JS_LinkConstructorAndPrototype,
+ JS_NewObjectWithGivenProto, RUST_SYMBOL_TO_JSID,
+};
+use js::rust::{
+ define_methods, define_properties, get_object_class, is_dom_class, maybe_wrap_object,
+ HandleObject, HandleValue, MutableHandleObject, RealmOptions,
+};
+use servo_url::MutableOrigin;
+
use crate::dom::bindings::codegen::InterfaceObjectMap::Globals;
use crate::dom::bindings::codegen::PrototypeList;
use crate::dom::bindings::constant::{define_constants, ConstantSpec};
@@ -15,43 +43,6 @@ use crate::dom::bindings::utils::{
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::{
- 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};
-use js::jsapi::{JS_GetFunctionObject, JS_NewFunction, JS_NewGlobalObject};
-use js::jsapi::{JS_NewObject, JS_NewPlainObject};
-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::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;
-use js::rust::wrappers::{JS_DefineProperty, JS_DefineProperty5};
-use js::rust::wrappers::{JS_DefineProperty3, JS_DefineProperty4, JS_DefinePropertyById5};
-use js::rust::wrappers::{JS_LinkConstructorAndPrototype, JS_NewObjectWithGivenProto};
-use js::rust::{define_methods, define_properties, get_object_class, maybe_wrap_object};
-use js::rust::{HandleObject, HandleValue, MutableHandleObject, RealmOptions};
-use servo_url::MutableOrigin;
-use std::convert::TryFrom;
-use std::ptr;
/// The class of a non-callback interface object.
#[derive(Clone, Copy)]
diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs
index 566d53c584a..0a1bfa4f359 100644
--- a/components/script/dom/bindings/iterable.rs
+++ b/components/script/dom/bindings/iterable.rs
@@ -6,8 +6,19 @@
//! Implementation of `iterable<...>` and `iterable<..., ...>` WebIDL declarations.
-use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult;
-use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
+use std::cell::Cell;
+use std::ptr;
+use std::ptr::NonNull;
+
+use dom_struct::dom_struct;
+use js::conversions::ToJSValConvertible;
+use js::jsapi::{Heap, JSObject};
+use js::jsval::UndefinedValue;
+use js::rust::{HandleObject, HandleValue, MutableHandleObject};
+
+use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::{
+ IterableKeyAndValueResult, IterableKeyOrValueResult,
+};
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::{
reflect_dom_object, DomObjectIteratorWrap, DomObjectWrap, Reflector,
@@ -16,14 +27,6 @@ use crate::dom::bindings::root::{Dom, DomRoot, Root};
use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox};
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::JSContext;
-use dom_struct::dom_struct;
-use js::conversions::ToJSValConvertible;
-use js::jsapi::{Heap, JSObject};
-use js::jsval::UndefinedValue;
-use js::rust::{HandleObject, HandleValue, MutableHandleObject};
-use std::cell::Cell;
-use std::ptr;
-use std::ptr::NonNull;
/// The values that an iterator will iterate over.
#[derive(JSTraceable, MallocSizeOf)]
diff --git a/components/script/dom/bindings/like.rs b/components/script/dom/bindings/like.rs
index ad14e453655..9aaefd48a53 100644
--- a/components/script/dom/bindings/like.rs
+++ b/components/script/dom/bindings/like.rs
@@ -6,13 +6,14 @@
//! Implementation of `setlike<...>` and `maplike<..., ...>` WebIDL declarations.
-use crate::dom::bindings::cell::DomRefCell;
-use indexmap::{IndexMap, IndexSet};
-use js::conversions::ToJSValConvertible;
use std::cmp::Eq;
use std::hash::Hash;
+use indexmap::{IndexMap, IndexSet};
+use js::conversions::ToJSValConvertible;
+
use super::iterable::Iterable;
+use crate::dom::bindings::cell::DomRefCell;
/// Every Setlike dom_struct must implement this to provide access to underlying storage
/// so codegen can automatically generate all setlike methods
diff --git a/components/script/dom/bindings/namespace.rs b/components/script/dom/bindings/namespace.rs
index 64b7b0b2626..e6c730907a5 100644
--- a/components/script/dom/bindings/namespace.rs
+++ b/components/script/dom/bindings/namespace.rs
@@ -4,12 +4,14 @@
//! Machinery to initialise namespace objects.
+use std::ptr;
+
+use js::jsapi::{JSClass, JSFunctionSpec};
+use js::rust::{HandleObject, MutableHandleObject};
+
use crate::dom::bindings::guard::Guard;
use crate::dom::bindings::interface::{create_object, define_on_global_object};
use crate::script_runtime::JSContext;
-use js::jsapi::{JSClass, JSFunctionSpec};
-use js::rust::{HandleObject, MutableHandleObject};
-use std::ptr;
/// The class of a namespace object.
#[derive(Clone, Copy)]
diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs
index c7f987e98ef..ba2162e96fc 100644
--- a/components/script/dom/bindings/num.rs
+++ b/components/script/dom/bindings/num.rs
@@ -4,11 +4,12 @@
//! The `Finite<T>` struct.
-use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
-use num_traits::Float;
use std::default::Default;
use std::ops::Deref;
+use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
+use num_traits::Float;
+
/// Encapsulates the IDL restricted float type.
#[derive(Clone, Copy, Eq, JSTraceable, PartialEq)]
pub struct Finite<T: Float>(T);
diff --git a/components/script/dom/bindings/principals.rs b/components/script/dom/bindings/principals.rs
index 079aff4892c..f408f92cbc7 100644
--- a/components/script/dom/bindings/principals.rs
+++ b/components/script/dom/bindings/principals.rs
@@ -2,16 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use js::{
- glue::{
- CreateRustJSPrincipals, DestroyRustJSPrincipals, GetRustJSPrincipalsPrivate,
- JSPrincipalsCallbacks,
- },
- jsapi::{JSPrincipals, JS_DropPrincipals, JS_HoldPrincipals},
- rust::Runtime,
+use std::marker::PhantomData;
+use std::mem::ManuallyDrop;
+use std::ops::Deref;
+use std::ptr::NonNull;
+
+use js::glue::{
+ CreateRustJSPrincipals, DestroyRustJSPrincipals, GetRustJSPrincipalsPrivate,
+ JSPrincipalsCallbacks,
};
+use js::jsapi::{JSPrincipals, JS_DropPrincipals, JS_HoldPrincipals};
+use js::rust::Runtime;
use servo_url::MutableOrigin;
-use std::{marker::PhantomData, mem::ManuallyDrop, ops::Deref, ptr::NonNull};
/// An owned reference to Servo's `JSPrincipals` instance.
#[repr(transparent)]
diff --git a/components/script/dom/bindings/proxyhandler.rs b/components/script/dom/bindings/proxyhandler.rs
index 07e215b72c5..715896fe70d 100644
--- a/components/script/dom/bindings/proxyhandler.rs
+++ b/components/script/dom/bindings/proxyhandler.rs
@@ -6,6 +6,36 @@
#![deny(missing_docs)]
+use std::ffi::CStr;
+use std::os::raw::c_char;
+use std::ptr;
+
+use js::conversions::ToJSValConvertible;
+use js::glue::{
+ GetProxyHandler, GetProxyHandlerFamily, GetProxyPrivate, InvokeGetOwnPropertyDescriptor,
+ SetProxyPrivate,
+};
+use js::jsapi;
+use js::jsapi::{
+ jsid, DOMProxyShadowsResult, GetObjectRealmOrNull, GetRealmPrincipals, GetStaticPrototype,
+ GetWellKnownSymbol, Handle as RawHandle, HandleId as RawHandleId,
+ HandleObject as RawHandleObject, HandleValue as RawHandleValue, JSAutoRealm, JSContext,
+ JSErrNum, JSFunctionSpec, JSObject, JSPropertySpec, JS_AtomizeAndPinString,
+ JS_DefinePropertyById, JS_GetOwnPropertyDescriptorById, JS_IsExceptionPending,
+ MutableHandle as RawMutableHandle, MutableHandleIdVector as RawMutableHandleIdVector,
+ MutableHandleObject as RawMutableHandleObject, MutableHandleValue as RawMutableHandleValue,
+ ObjectOpResult, PropertyDescriptor, SetDOMProxyInformation, SymbolCode,
+};
+use js::jsid::SymbolId;
+use js::jsval::{ObjectValue, UndefinedValue};
+use js::rust::wrappers::{
+ AppendToIdVector, JS_AlreadyHasOwnPropertyById, JS_NewObjectWithGivenProto,
+ SetDataPropertyDescriptor, RUST_INTERNED_STRING_TO_JSID,
+};
+use js::rust::{
+ get_context_realm, Handle, HandleObject, HandleValue, MutableHandle, MutableHandleObject,
+};
+
use crate::dom::bindings::conversions::{is_dom_proxy, jsid_to_string, jsstring_to_str};
use crate::dom::bindings::error::{throw_dom_exception, Error};
use crate::dom::bindings::principals::ServoJSPrincipalsRef;
@@ -15,41 +45,6 @@ use crate::dom::bindings::utils::delete_property_by_id;
use crate::dom::globalscope::GlobalScope;
use crate::realms::{AlreadyInRealm, InRealm};
use crate::script_runtime::JSContext as SafeJSContext;
-use js::conversions::ToJSValConvertible;
-use js::glue::{GetProxyHandler, GetProxyHandlerFamily, InvokeGetOwnPropertyDescriptor};
-use js::glue::{GetProxyPrivate, SetProxyPrivate};
-use js::jsapi;
-use js::jsapi::GetStaticPrototype;
-use js::jsapi::Handle as RawHandle;
-use js::jsapi::HandleId as RawHandleId;
-use js::jsapi::HandleObject as RawHandleObject;
-use js::jsapi::HandleValue as RawHandleValue;
-use js::jsapi::JSAutoRealm;
-use js::jsapi::JS_AtomizeAndPinString;
-use js::jsapi::JS_DefinePropertyById;
-use js::jsapi::JS_GetOwnPropertyDescriptorById;
-use js::jsapi::JS_IsExceptionPending;
-use js::jsapi::MutableHandle as RawMutableHandle;
-use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
-use js::jsapi::MutableHandleObject as RawMutableHandleObject;
-use js::jsapi::MutableHandleValue as RawMutableHandleValue;
-use js::jsapi::ObjectOpResult;
-use js::jsapi::{jsid, GetObjectRealmOrNull, GetRealmPrincipals, JSFunctionSpec, JSPropertySpec};
-use js::jsapi::{DOMProxyShadowsResult, JSContext, JSObject, PropertyDescriptor};
-use js::jsapi::{GetWellKnownSymbol, SymbolCode};
-use js::jsapi::{JSErrNum, SetDOMProxyInformation};
-use js::jsid::SymbolId;
-use js::jsval::ObjectValue;
-use js::jsval::UndefinedValue;
-use js::rust::wrappers::JS_AlreadyHasOwnPropertyById;
-use js::rust::wrappers::JS_NewObjectWithGivenProto;
-use js::rust::wrappers::{
- AppendToIdVector, SetDataPropertyDescriptor, RUST_INTERNED_STRING_TO_JSID,
-};
-use js::rust::{
- get_context_realm, Handle, HandleObject, HandleValue, MutableHandle, MutableHandleObject,
-};
-use std::{ffi::CStr, os::raw::c_char, ptr};
/// Determine if this id shadows any existing properties for this proxy.
pub unsafe extern "C" fn shadow_check_callback(
diff --git a/components/script/dom/bindings/record.rs b/components/script/dom/bindings/record.rs
index e5a796f5478..54c8dc96630 100644
--- a/components/script/dom/bindings/record.rs
+++ b/components/script/dom/bindings/record.rs
@@ -4,34 +4,25 @@
//! The `Record` (open-ended dictionary) type.
-use crate::dom::bindings::conversions::jsid_to_string;
-use crate::dom::bindings::str::{ByteString, DOMString, USVString};
-use indexmap::IndexMap;
-use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
-use js::jsapi::glue::JS_GetOwnPropertyDescriptorById;
-use js::jsapi::HandleId as RawHandleId;
-use js::jsapi::JSContext;
-use js::jsapi::JS_NewPlainObject;
-use js::jsapi::PropertyDescriptor;
-use js::jsapi::JSITER_HIDDEN;
-use js::jsapi::JSITER_OWNONLY;
-use js::jsapi::JSITER_SYMBOLS;
-use js::jsapi::JSPROP_ENUMERATE;
-use js::jsval::ObjectValue;
-use js::jsval::UndefinedValue;
-use js::rust::wrappers::GetPropertyKeys;
-use js::rust::wrappers::JS_DefineUCProperty2;
-use js::rust::wrappers::JS_GetPropertyById;
-use js::rust::wrappers::JS_IdToValue;
-use js::rust::HandleId;
-use js::rust::HandleValue;
-use js::rust::IdVector;
-use js::rust::MutableHandleValue;
use std::cmp::Eq;
use std::hash::Hash;
use std::marker::Sized;
use std::ops::Deref;
+use indexmap::IndexMap;
+use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
+use js::jsapi::glue::JS_GetOwnPropertyDescriptorById;
+use js::jsapi::{
+ HandleId as RawHandleId, JSContext, JS_NewPlainObject, PropertyDescriptor, JSITER_HIDDEN,
+ JSITER_OWNONLY, JSITER_SYMBOLS, JSPROP_ENUMERATE,
+};
+use js::jsval::{ObjectValue, UndefinedValue};
+use js::rust::wrappers::{GetPropertyKeys, JS_DefineUCProperty2, JS_GetPropertyById, JS_IdToValue};
+use js::rust::{HandleId, HandleValue, IdVector, MutableHandleValue};
+
+use crate::dom::bindings::conversions::jsid_to_string;
+use crate::dom::bindings::str::{ByteString, DOMString, USVString};
+
pub trait RecordKey: Eq + Hash + Sized {
fn to_utf16_vec(&self) -> Vec<u16>;
unsafe fn from_id(cx: *mut JSContext, id: HandleId) -> Result<ConversionResult<Self>, ()>;
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs
index ab7aea3e922..0279e98b6ba 100644
--- a/components/script/dom/bindings/refcounted.rs
+++ b/components/script/dom/bindings/refcounted.rs
@@ -22,14 +22,6 @@
//! its hash table during the next GC. During GC, the entries of the hash table are counted
//! as JS roots.
-use crate::dom::bindings::conversions::ToJSValConvertible;
-use crate::dom::bindings::error::Error;
-use crate::dom::bindings::reflector::{DomObject, Reflector};
-use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::trace::trace_reflector;
-use crate::dom::promise::Promise;
-use crate::task::TaskOnce;
-use js::jsapi::JSTracer;
use std::cell::RefCell;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_map::HashMap;
@@ -38,12 +30,23 @@ use std::marker::PhantomData;
use std::rc::Rc;
use std::sync::{Arc, Weak};
+use js::jsapi::JSTracer;
+
+use crate::dom::bindings::conversions::ToJSValConvertible;
+use crate::dom::bindings::error::Error;
+use crate::dom::bindings::reflector::{DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::bindings::trace::trace_reflector;
+use crate::dom::promise::Promise;
+use crate::task::TaskOnce;
+
#[allow(missing_docs)] // FIXME
mod dummy {
// Attributes don’t apply through the macro.
- use super::LiveDOMReferences;
use std::cell::RefCell;
use std::rc::Rc;
+
+ use super::LiveDOMReferences;
thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> =
Rc::new(RefCell::new(None)));
}
diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs
index c0f1305bf6c..4b1ba97c525 100644
--- a/components/script/dom/bindings/reflector.rs
+++ b/components/script/dom/bindings/reflector.rs
@@ -4,6 +4,11 @@
//! The `Reflector` struct.
+use std::default::Default;
+
+use js::jsapi::{Heap, JSObject};
+use js::rust::HandleObject;
+
use crate::dom::bindings::conversions::DerivedFrom;
use crate::dom::bindings::iterable::{Iterable, IterableIterator};
use crate::dom::bindings::root::{Dom, DomRoot, Root};
@@ -11,9 +16,6 @@ use crate::dom::bindings::trace::JSTraceable;
use crate::dom::globalscope::GlobalScope;
use crate::realms::AlreadyInRealm;
use crate::script_runtime::JSContext;
-use js::jsapi::{Heap, JSObject};
-use js::rust::HandleObject;
-use std::default::Default;
/// Create the reflector for a new DOM object and yield ownership to the
/// reflector.
diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs
index b51730848b6..1e67474ea99 100644
--- a/components/script/dom/bindings/root.rs
+++ b/components/script/dom/bindings/root.rs
@@ -24,25 +24,25 @@
//! originating `DomRoot<T>`.
//!
-use crate::dom::bindings::conversions::DerivedFrom;
-use crate::dom::bindings::inheritance::Castable;
-use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
-use crate::dom::bindings::trace::trace_reflector;
-use crate::dom::bindings::trace::JSTraceable;
-use crate::dom::node::Node;
-use js::jsapi::{Heap, JSObject, JSTracer};
-use js::rust::GCMethods;
-use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
-use script_layout_interface::TrustedNodeAddress;
use std::cell::{Cell, OnceCell, UnsafeCell};
use std::default::Default;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
-use std::mem;
use std::ops::Deref;
-use std::ptr;
+use std::{mem, ptr};
+
+use js::jsapi::{Heap, JSObject, JSTracer};
+use js::rust::GCMethods;
+use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
+use script_layout_interface::TrustedNodeAddress;
use style::thread_state;
+use crate::dom::bindings::conversions::DerivedFrom;
+use crate::dom::bindings::inheritance::Castable;
+use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
+use crate::dom::bindings::trace::{trace_reflector, JSTraceable};
+use crate::dom::node::Node;
+
/// A rooted value.
#[allow(unrooted_must_root)]
#[unrooted_must_root_lint::allow_unrooted_interior]
diff --git a/components/script/dom/bindings/settings_stack.rs b/components/script/dom/bindings/settings_stack.rs
index 24b6175f159..6461a790025 100644
--- a/components/script/dom/bindings/settings_stack.rs
+++ b/components/script/dom/bindings/settings_stack.rs
@@ -2,16 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+use std::cell::RefCell;
+use std::thread;
+
+use js::jsapi::{GetScriptedCallerGlobal, HideScriptedCaller, JSTracer, UnhideScriptedCaller};
+use js::rust::Runtime;
+
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::globalscope::GlobalScope;
-use js::jsapi::GetScriptedCallerGlobal;
-use js::jsapi::HideScriptedCaller;
-use js::jsapi::JSTracer;
-use js::jsapi::UnhideScriptedCaller;
-use js::rust::Runtime;
-use std::cell::RefCell;
-use std::thread;
thread_local!(static STACK: RefCell<Vec<StackEntry>> = RefCell::new(Vec::new()));
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs
index ef772ce355c..6db9d0773ad 100644
--- a/components/script/dom/bindings/str.rs
+++ b/components/script/dom/bindings/str.rs
@@ -3,6 +3,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! The `ByteString` struct.
+use std::borrow::{Borrow, Cow, ToOwned};
+use std::default::Default;
+use std::hash::{Hash, Hasher};
+use std::marker::PhantomData;
+use std::ops::{Deref, DerefMut};
+use std::str::FromStr;
+use std::{fmt, ops, str};
+
use chrono::prelude::{Utc, Weekday};
use chrono::{Datelike, TimeZone};
use cssparser::CowRcStr;
@@ -10,15 +18,6 @@ use html5ever::{LocalName, Namespace};
use lazy_static::lazy_static;
use regex::Regex;
use servo_atoms::Atom;
-use std::borrow::{Borrow, Cow, ToOwned};
-use std::default::Default;
-use std::fmt;
-use std::hash::{Hash, Hasher};
-use std::marker::PhantomData;
-use std::ops;
-use std::ops::{Deref, DerefMut};
-use std::str;
-use std::str::FromStr;
/// Encapsulates the IDL `ByteString` type.
#[derive(Clone, Debug, Default, Eq, JSTraceable, MallocSizeOf, PartialEq)]
diff --git a/components/script/dom/bindings/structuredclone.rs b/components/script/dom/bindings/structuredclone.rs
index 85cb758e600..5de0569bcf7 100644
--- a/components/script/dom/bindings/structuredclone.rs
+++ b/components/script/dom/bindings/structuredclone.rs
@@ -5,6 +5,29 @@
//! This module implements structured cloning, as defined by [HTML]
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
+use std::collections::HashMap;
+use std::os::raw;
+use std::ptr;
+
+use js::glue::{
+ CopyJSStructuredCloneData, DeleteJSAutoStructuredCloneBuffer, GetLengthOfJSStructuredCloneData,
+ NewJSAutoStructuredCloneBuffer, WriteBytesToJSStructuredCloneData,
+};
+use js::jsapi::{
+ CloneDataPolicy, HandleObject as RawHandleObject, JSContext, JSObject,
+ JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter,
+ JS_ClearPendingException, JS_ReadUint32Pair, JS_WriteUint32Pair,
+ MutableHandleObject as RawMutableHandleObject, StructuredCloneScope, TransferableOwnership,
+ JS_STRUCTURED_CLONE_VERSION,
+};
+use js::jsval::UndefinedValue;
+use js::rust::wrappers::{JS_ReadStructuredClone, JS_WriteStructuredClone};
+use js::rust::{CustomAutoRooterGuard, HandleValue, MutableHandleValue};
+use msg::constellation_msg::{BlobId, MessagePortId};
+use script_traits::serializable::BlobImpl;
+use script_traits::transferable::MessagePortImpl;
+use script_traits::StructuredSerializedData;
+
use crate::dom::bindings::conversions::{root_from_object, ToJSValConvertible};
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::reflector::DomObject;
@@ -16,31 +39,6 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::messageport::MessagePort;
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
use crate::script_runtime::JSContext as SafeJSContext;
-use js::glue::CopyJSStructuredCloneData;
-use js::glue::DeleteJSAutoStructuredCloneBuffer;
-use js::glue::GetLengthOfJSStructuredCloneData;
-use js::glue::NewJSAutoStructuredCloneBuffer;
-use js::glue::WriteBytesToJSStructuredCloneData;
-use js::jsapi::CloneDataPolicy;
-use js::jsapi::HandleObject as RawHandleObject;
-use js::jsapi::JSContext;
-use js::jsapi::MutableHandleObject as RawMutableHandleObject;
-use js::jsapi::StructuredCloneScope;
-use js::jsapi::TransferableOwnership;
-use js::jsapi::JS_STRUCTURED_CLONE_VERSION;
-use js::jsapi::{JSObject, JS_ClearPendingException};
-use js::jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter};
-use js::jsapi::{JS_ReadUint32Pair, JS_WriteUint32Pair};
-use js::jsval::UndefinedValue;
-use js::rust::wrappers::{JS_ReadStructuredClone, JS_WriteStructuredClone};
-use js::rust::{CustomAutoRooterGuard, HandleValue, MutableHandleValue};
-use msg::constellation_msg::{BlobId, MessagePortId};
-use script_traits::serializable::BlobImpl;
-use script_traits::transferable::MessagePortImpl;
-use script_traits::StructuredSerializedData;
-use std::collections::HashMap;
-use std::os::raw;
-use std::ptr;
// TODO: Should we add Min and Max const to https://github.com/servo/rust-mozjs/blob/master/src/consts.rs?
// TODO: Determine for sure which value Min and Max should have.
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index e3c30c943ab..8d5f0db0c0e 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -29,40 +29,24 @@
//! The `unsafe_no_jsmanaged_fields!()` macro adds an empty implementation of
//! `JSTraceable` to a datatype.
-use crate::dom::bindings::cell::DomRefCell;
-use crate::dom::bindings::error::Error;
-use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
-use crate::dom::bindings::reflector::{DomObject, Reflector};
-use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::{DOMString, USVString};
-use crate::dom::bindings::utils::WindowProxyHandler;
-use crate::dom::gpubuffer::GPUBufferState;
-use crate::dom::gpucanvascontext::WebGPUContextId;
-use crate::dom::gpucommandencoder::GPUCommandEncoderState;
-use crate::dom::htmlimageelement::SourceSet;
-use crate::dom::htmlmediaelement::HTMLMediaElementFetchContext;
-use crate::script_runtime::{ContextForRequestInterrupt, StreamConsumer};
-use crate::script_thread::IncompleteParserContexts;
-use crate::task::TaskBox;
+use std::collections::hash_map::RandomState;
+use std::collections::HashMap;
+use std::fmt::Display;
+use std::hash::{BuildHasher, Hash};
+use std::mem;
+use std::ops::{Deref, DerefMut};
+
use indexmap::IndexMap;
+/// A trait to allow tracing (only) DOM objects.
+pub use js::gc::Traceable as JSTraceable;
use js::glue::{CallObjectTracer, CallScriptTracer, CallStringTracer, CallValueTracer};
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSScript, JSString, JSTracer, TraceKind};
use js::jsval::JSVal;
use js::rust::{GCMethods, Handle};
-
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use parking_lot::RwLock;
use servo_arc::Arc as ServoArc;
use smallvec::SmallVec;
-
-use std::collections::hash_map::RandomState;
-use std::collections::HashMap;
-use std::fmt::Display;
-use std::hash::{BuildHasher, Hash};
-use std::mem;
-
-use std::ops::{Deref, DerefMut};
-
use style::author_styles::AuthorStyles;
use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
use tendril::fmt::UTF8;
@@ -70,8 +54,21 @@ use tendril::stream::LossyDecoder;
use tendril::TendrilSink;
use webxr_api::{Finger, Hand};
-/// A trait to allow tracing (only) DOM objects.
-pub use js::gc::Traceable as JSTraceable;
+use crate::dom::bindings::cell::DomRefCell;
+use crate::dom::bindings::error::Error;
+use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
+use crate::dom::bindings::reflector::{DomObject, Reflector};
+use crate::dom::bindings::root::{Dom, DomRoot};
+use crate::dom::bindings::str::{DOMString, USVString};
+use crate::dom::bindings::utils::WindowProxyHandler;
+use crate::dom::gpubuffer::GPUBufferState;
+use crate::dom::gpucanvascontext::WebGPUContextId;
+use crate::dom::gpucommandencoder::GPUCommandEncoderState;
+use crate::dom::htmlimageelement::SourceSet;
+use crate::dom::htmlmediaelement::HTMLMediaElementFetchContext;
+use crate::script_runtime::{ContextForRequestInterrupt, StreamConsumer};
+use crate::script_thread::IncompleteParserContexts;
+use crate::task::TaskBox;
/// A trait to allow tracing only DOM sub-objects.
pub unsafe trait CustomTraceable {
diff --git a/components/script/dom/bindings/transferable.rs b/components/script/dom/bindings/transferable.rs
index 608988db35d..5e15ec785fa 100644
--- a/components/script/dom/bindings/transferable.rs
+++ b/components/script/dom/bindings/transferable.rs
@@ -5,10 +5,11 @@
//! Trait representing the concept of [transferable objects]
//! (https://html.spec.whatwg.org/multipage/#transferable-objects).
+use js::jsapi::MutableHandleObject;
+
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::structuredclone::StructuredDataHolder;
use crate::dom::globalscope::GlobalScope;
-use js::jsapi::MutableHandleObject;
pub trait Transferable: DomObject {
fn transfer(&self, sc_holder: &mut StructuredDataHolder) -> Result<u64, ()>;
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index d7d274dc701..af54544d3c5 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -4,9 +4,38 @@
//! Various utilities to glue JavaScript and the DOM implementation together.
-use crate::dom::bindings::codegen::InterfaceObjectMap;
-use crate::dom::bindings::codegen::PrototypeList;
+use std::ffi::CString;
+use std::os::raw::{c_char, c_void};
+use std::{ptr, slice, str};
+
+use js::conversions::ToJSValConvertible;
+use js::glue::{
+ CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper, JS_GetReservedSlot,
+ UnwrapObjectDynamic, UnwrapObjectStatic, RUST_FUNCTION_VALUE_TO_JITINFO,
+};
+use js::jsapi::{
+ AtomToLinearString, CallArgs, DOMCallbacks, GetLinearStringCharAt, GetLinearStringLength,
+ GetNonCCWObjectGlobal, HandleId as RawHandleId, HandleObject as RawHandleObject, Heap, JSAtom,
+ JSContext, JSJitInfo, JSObject, JSTracer, JS_DeprecatedStringHasLatin1Chars,
+ JS_EnumerateStandardClasses, JS_FreezeObject, JS_GetLatin1StringCharsAndLength,
+ JS_IsExceptionPending, JS_IsGlobalObject, JS_ResolveStandardClass,
+ MutableHandleIdVector as RawMutableHandleIdVector, ObjectOpResult, StringIsArrayIndex,
+};
+use js::jsval::{JSVal, UndefinedValue};
+use js::rust::wrappers::{
+ JS_DeletePropertyById, JS_ForwardGetPropertyTo, JS_GetProperty, JS_GetPrototype,
+ JS_HasProperty, JS_HasPropertyById, JS_SetProperty,
+};
+use js::rust::{
+ get_object_class, is_dom_class, GCMethods, Handle, HandleId, HandleObject, HandleValue,
+ MutableHandleValue, ToString,
+};
+use js::typedarray::{CreateWith, Float32Array};
+use js::JS_CALLEE;
+use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
+
use crate::dom::bindings::codegen::PrototypeList::{MAX_PROTO_CHAIN_LENGTH, PROTO_OR_IFACE_LENGTH};
+use crate::dom::bindings::codegen::{InterfaceObjectMap, PrototypeList};
use crate::dom::bindings::conversions::{
jsstring_to_str, private_from_proto_check, PrototypeCheck,
};
@@ -16,41 +45,6 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::trace::trace_object;
use crate::dom::windowproxy;
use crate::script_runtime::JSContext as SafeJSContext;
-use js::conversions::ToJSValConvertible;
-use js::glue::JS_GetReservedSlot;
-use js::glue::RUST_FUNCTION_VALUE_TO_JITINFO;
-use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
-use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
-use js::jsapi::HandleId as RawHandleId;
-use js::jsapi::HandleObject as RawHandleObject;
-use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
-use js::jsapi::{AtomToLinearString, GetLinearStringCharAt, GetLinearStringLength};
-use js::jsapi::{CallArgs, DOMCallbacks, GetNonCCWObjectGlobal};
-use js::jsapi::{Heap, JSContext, JS_FreezeObject};
-use js::jsapi::{JSAtom, JS_IsExceptionPending, JS_IsGlobalObject};
-use js::jsapi::{JSJitInfo, JSObject, JSTracer};
-use js::jsapi::{
- JS_DeprecatedStringHasLatin1Chars, JS_ResolveStandardClass, ObjectOpResult, StringIsArrayIndex,
-};
-use js::jsapi::{JS_EnumerateStandardClasses, JS_GetLatin1StringCharsAndLength};
-use js::jsval::{JSVal, UndefinedValue};
-use js::rust::wrappers::JS_DeletePropertyById;
-use js::rust::wrappers::JS_ForwardGetPropertyTo;
-use js::rust::wrappers::JS_GetProperty;
-use js::rust::wrappers::JS_GetPrototype;
-use js::rust::wrappers::JS_HasProperty;
-use js::rust::wrappers::JS_HasPropertyById;
-use js::rust::wrappers::JS_SetProperty;
-use js::rust::{get_object_class, is_dom_class, GCMethods, ToString};
-use js::rust::{Handle, HandleId, HandleObject, HandleValue, MutableHandleValue};
-use js::typedarray::{CreateWith, Float32Array};
-use js::JS_CALLEE;
-use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
-use std::ffi::CString;
-use std::os::raw::{c_char, c_void};
-use std::ptr;
-use std::slice;
-use std::str;
/// Proxy handler for a WindowProxy.
pub struct WindowProxyHandler(pub *const libc::c_void);
diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs
index 5c74e111816..a0bd0ea362d 100644
--- a/components/script/dom/bindings/weakref.rs
+++ b/components/script/dom/bindings/weakref.rs
@@ -11,20 +11,20 @@
//! slot. When all associated `WeakRef` values are dropped, the
//! `WeakBox` itself is dropped too.
-use crate::dom::bindings::cell::DomRefCell;
-use crate::dom::bindings::reflector::DomObject;
-use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::trace::JSTraceable;
+use std::cell::{Cell, UnsafeCell};
+use std::ops::{Deref, DerefMut, Drop};
+use std::{mem, ptr};
+
use js::glue::JS_GetReservedSlot;
use js::jsapi::{JSTracer, JS_SetReservedSlot};
-use js::jsval::PrivateValue;
-use js::jsval::UndefinedValue;
+use js::jsval::{PrivateValue, UndefinedValue};
use libc::c_void;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
-use std::cell::{Cell, UnsafeCell};
-use std::mem;
-use std::ops::{Deref, DerefMut, Drop};
-use std::ptr;
+
+use crate::dom::bindings::cell::DomRefCell;
+use crate::dom::bindings::reflector::DomObject;
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::bindings::trace::JSTraceable;
/// The index of the slot wherein a pointer to the weak holder cell is
/// stored for weak-referenceable bindings. We use slot 1 for holding it,
diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs
index 672f8c522b3..30082c2d6e8 100644
--- a/components/script/dom/bindings/xmlname.rs
+++ b/components/script/dom/bindings/xmlname.rs
@@ -4,9 +4,10 @@
//! Functions for validating and extracting qualified XML names.
+use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix};
+
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::str::DOMString;
-use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix};
/// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details.
pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {