diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-12-14 08:31:30 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-12-28 13:17:47 +0100 |
commit | be69f9c3e6a6f5efb5ba1edd50955cb12c111bf8 (patch) | |
tree | db8be2dfee5cff6ef0c42e8d46c623eb87529e5a /components/script/dom | |
parent | 82fc6d9f49a657e2857da3f1b22140e3b6efdf09 (diff) | |
download | servo-be69f9c3e6a6f5efb5ba1edd50955cb12c111bf8.tar.gz servo-be69f9c3e6a6f5efb5ba1edd50955cb12c111bf8.zip |
Rustfmt has changed its default style :/
Diffstat (limited to 'components/script/dom')
72 files changed, 398 insertions, 397 deletions
diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 1b56d5c7dc8..4c2025f8eb4 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -108,9 +108,9 @@ impl AnalyserNode { let this = this.clone(); let _ = source.queue_with_canceller( task!(append_analysis_block: move || { - let this = this.root(); - this.push_block(block.to().unwrap()) - }), + let this = this.root(); + this.push_block(block.to().unwrap()) + }), &canceller, ); }), diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index c32ff146215..fbe6b5e34f5 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -134,20 +134,20 @@ impl AudioContextMethods for AudioContext { let context = Trusted::new(self); let _ = task_source.queue( task!(suspend_ok: move || { - let base_context = base_context.root(); - let context = context.root(); - let promise = trusted_promise.root(); - promise.resolve_native(&()); - if base_context.State() != AudioContextState::Suspended { - base_context.set_state_attribute(AudioContextState::Suspended); - let window = DomRoot::downcast::<Window>(context.global()).unwrap(); - window.task_manager().dom_manipulation_task_source().queue_simple_event( - context.upcast(), - atom!("statechange"), - &window - ); - } - }), + let base_context = base_context.root(); + let context = context.root(); + let promise = trusted_promise.root(); + promise.resolve_native(&()); + if base_context.State() != AudioContextState::Suspended { + base_context.set_state_attribute(AudioContextState::Suspended); + let window = DomRoot::downcast::<Window>(context.global()).unwrap(); + window.task_manager().dom_manipulation_task_source().queue_simple_event( + context.upcast(), + atom!("statechange"), + &window + ); + } + }), window.upcast(), ); }, @@ -156,9 +156,9 @@ impl AudioContextMethods for AudioContext { // never fail, but we handle the case here for completion. let _ = task_source.queue( task!(suspend_error: move || { - let promise = trusted_promise.root(); - promise.reject_error(Error::Type("Something went wrong".to_owned())); - }), + let promise = trusted_promise.root(); + promise.reject_error(Error::Type("Something went wrong".to_owned())); + }), window.upcast(), ); }, @@ -196,20 +196,20 @@ impl AudioContextMethods for AudioContext { let context = Trusted::new(self); let _ = task_source.queue( task!(suspend_ok: move || { - let base_context = base_context.root(); - let context = context.root(); - let promise = trusted_promise.root(); - promise.resolve_native(&()); - if base_context.State() != AudioContextState::Closed { - base_context.set_state_attribute(AudioContextState::Closed); - let window = DomRoot::downcast::<Window>(context.global()).unwrap(); - window.task_manager().dom_manipulation_task_source().queue_simple_event( - context.upcast(), - atom!("statechange"), - &window - ); - } - }), + let base_context = base_context.root(); + let context = context.root(); + let promise = trusted_promise.root(); + promise.resolve_native(&()); + if base_context.State() != AudioContextState::Closed { + base_context.set_state_attribute(AudioContextState::Closed); + let window = DomRoot::downcast::<Window>(context.global()).unwrap(); + window.task_manager().dom_manipulation_task_source().queue_simple_event( + context.upcast(), + atom!("statechange"), + &window + ); + } + }), window.upcast(), ); }, @@ -218,9 +218,9 @@ impl AudioContextMethods for AudioContext { // never fail, but we handle the case here for completion. let _ = task_source.queue( task!(suspend_error: move || { - let promise = trusted_promise.root(); - promise.reject_error(Error::Type("Something went wrong".to_owned())); - }), + let promise = trusted_promise.root(); + promise.reject_error(Error::Type("Something went wrong".to_owned())); + }), window.upcast(), ); }, diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 0b5aa7d8649..2417de5435c 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -244,8 +244,8 @@ impl BaseAudioContext { ))); let _ = task_source.queue( task!(resume_error: move || { - this.root().fulfill_in_flight_resume_promises(|| {}) - }), + this.root().fulfill_in_flight_resume_promises(|| {}) + }), window.upcast(), ); }, diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index 2e784ec5be8..6153f167df5 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -5,8 +5,6 @@ //! Utilities to throw exceptions from Rust bindings. #[cfg(feature = "js_backtrace")] -use backtrace::Backtrace; -#[cfg(feature = "js_backtrace")] use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods; use crate::dom::bindings::codegen::PrototypeList::proto_id_to_name; @@ -17,6 +15,8 @@ use crate::dom::bindings::conversions::{ use crate::dom::bindings::str::USVString; use crate::dom::domexception::{DOMErrorName, DOMException}; use crate::dom::globalscope::GlobalScope; +#[cfg(feature = "js_backtrace")] +use backtrace::Backtrace; use js::error::{throw_range_error, throw_type_error}; use js::jsapi::JSContext; use js::jsapi::JS_ClearPendingException; diff --git a/components/script/dom/bindings/htmlconstructor.rs b/components/script/dom/bindings/htmlconstructor.rs index 99ca45b44a6..5654b52938b 100644 --- a/components/script/dom/bindings/htmlconstructor.rs +++ b/components/script/dom/bindings/htmlconstructor.rs @@ -105,7 +105,7 @@ where None => { return Err(Error::Type( "No custom element definition found for new.target".to_owned(), - )) + )); }, }; diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 3142f011c9b..dfeedc636d6 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -734,10 +734,10 @@ fn parse_floating_point_number(input: &str) -> Result<f64, ()> { match input.trim().parse::<f64>() { Ok(val) if !( - // A valid number is the same as what rust considers to be valid, - // except for +1., NaN, and Infinity. - val.is_infinite() || val.is_nan() || input.ends_with(".") || input.starts_with("+") - ) => + // A valid number is the same as what rust considers to be valid, + // except for +1., NaN, and Infinity. + val.is_infinite() || val.is_nan() || input.ends_with(".") || input.starts_with("+") + ) => { // TODO(#19773): need consider `min`, `max`, `step`, when they are implemented Ok(val.round()) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index ae1a9e6e3b4..ee8e93e03ac 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -29,16 +29,6 @@ //! The `unsafe_no_jsmanaged_fields!()` macro adds an empty implementation of //! `JSTraceable` to a datatype. -use app_units::Au; -use canvas_traits::canvas::{ - CanvasGradientStop, CanvasId, LinearGradientStyle, RadialGradientStyle, -}; -use canvas_traits::canvas::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle}; -use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, TexDataType, TexFormat}; -use canvas_traits::webgl::{WebGLBufferId, WebGLChan, WebGLContextShareMode, WebGLError}; -use canvas_traits::webgl::{WebGLFramebufferId, WebGLMsgSender, WebGLPipeline, WebGLProgramId}; -use canvas_traits::webgl::{WebGLReceiver, WebGLRenderbufferId, WebGLSLVersion, WebGLSender}; -use canvas_traits::webgl::{WebGLShaderId, WebGLTextureId, WebGLVersion, WebGLVertexArrayId}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::error::Error; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; @@ -50,6 +40,16 @@ use crate::dom::document::PendingRestyle; use crate::dom::htmlimageelement::SourceSet; use crate::dom::htmlmediaelement::MediaFrameRenderer; use crate::task::TaskBox; +use app_units::Au; +use canvas_traits::canvas::{ + CanvasGradientStop, CanvasId, LinearGradientStyle, RadialGradientStyle, +}; +use canvas_traits::canvas::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle}; +use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, TexDataType, TexFormat}; +use canvas_traits::webgl::{WebGLBufferId, WebGLChan, WebGLContextShareMode, WebGLError}; +use canvas_traits::webgl::{WebGLFramebufferId, WebGLMsgSender, WebGLPipeline, WebGLProgramId}; +use canvas_traits::webgl::{WebGLReceiver, WebGLRenderbufferId, WebGLSLVersion, WebGLSender}; +use canvas_traits::webgl::{WebGLShaderId, WebGLTextureId, WebGLVersion, WebGLVertexArrayId}; use crossbeam_channel::{Receiver, Sender}; use cssparser::RGBA; use devtools_traits::{CSSError, TimelineMarkerType, WorkerId}; @@ -769,8 +769,10 @@ struct RootedTraceableSet { set: Vec<*const dyn JSTraceable>, } -thread_local!(/// TLV Holds a set of JSTraceables that need to be rooted -static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new());); +thread_local!( + /// TLV Holds a set of JSTraceables that need to be rooted + static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new()); +); impl RootedTraceableSet { fn new() -> RootedTraceableSet { diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs index 9cdcb000f86..ab1fe30c8a5 100644 --- a/components/script/dom/bindings/xmlname.rs +++ b/components/script/dom/bindings/xmlname.rs @@ -116,12 +116,16 @@ pub fn xml_name_type(name: &str) -> XMLName { } fn is_valid_continuation(c: char) -> bool { - is_valid_start(c) || match c { - '-' | '.' | '0'...'9' | '\u{B7}' | '\u{300}'...'\u{36F}' | '\u{203F}'...'\u{2040}' => { - true - }, - _ => false, - } + is_valid_start(c) || + match c { + '-' | + '.' | + '0'...'9' | + '\u{B7}' | + '\u{300}'...'\u{36F}' | + '\u{203F}'...'\u{2040}' => true, + _ => false, + } } let mut iter = name.chars(); diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 44169dd0e55..0e96e8488b5 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -426,7 +426,7 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth let manufacturer_id = match u16::from_str(key.as_ref()) { Ok(id) => id, Err(err) => { - return Err(Type(format!("{} {} {}", KEY_CONVERSION_ERROR, key, err))) + return Err(Type(format!("{} {} {}", KEY_CONVERSION_ERROR, key, err))); }, }; diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index 9b61871a972..10d351232bc 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -2,8 +2,6 @@ * 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 bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg}; -use bluetooth_traits::{BluetoothRequest, BluetoothResponse, BluetoothServiceMsg}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding; use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; @@ -23,6 +21,8 @@ use crate::dom::bluetoothremotegattservice::BluetoothRemoteGATTService; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; +use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg}; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse, BluetoothServiceMsg}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use profile_traits::ipc; diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs index 0d2a9478290..1051ecebb8e 100644 --- a/components/script/dom/bluetoothpermissionresult.rs +++ b/components/script/dom/bluetoothpermissionresult.rs @@ -2,7 +2,6 @@ * 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 bluetooth_traits::{BluetoothRequest, BluetoothResponse}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::{ self, BluetoothPermissionResultMethods, @@ -22,6 +21,7 @@ use crate::dom::bluetoothdevice::BluetoothDevice; use crate::dom::globalscope::GlobalScope; use crate::dom::permissionstatus::PermissionStatus; use crate::dom::promise::Promise; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use std::rc::Rc; diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index a3699437efb..6c2e1f012d3 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -2,8 +2,6 @@ * 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 bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; -use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding; @@ -25,6 +23,8 @@ use crate::dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID}; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; +use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use std::rc::Rc; diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index f4c56a6f668..83482a77c90 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -2,8 +2,6 @@ * 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 bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; -use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding; @@ -21,6 +19,8 @@ use crate::dom::bluetoothremotegattcharacteristic::{ }; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; +use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use std::rc::Rc; diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index 40c801faf60..c0ebeef0955 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -2,7 +2,6 @@ * 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 bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; @@ -15,6 +14,7 @@ use crate::dom::bluetoothdevice::BluetoothDevice; use crate::dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID}; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use std::cell::Cell; diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index dcc2c4fd946..adcf30c7645 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -2,7 +2,6 @@ * 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 bluetooth_traits::{BluetoothResponse, GATTType}; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; @@ -16,6 +15,7 @@ use crate::dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUI use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; +use bluetooth_traits::{BluetoothResponse, GATTType}; use dom_struct::dom_struct; use std::rc::Rc; diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index 5a1e787f72e..f24106d81c2 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -2,9 +2,6 @@ * 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 canvas_traits::canvas::{ - CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle, -}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding; use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods; @@ -14,6 +11,9 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; +use canvas_traits::canvas::{ + CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle, +}; use cssparser::Color as CSSColor; use cssparser::{Parser, ParserInput, RGBA}; use dom_struct::dom_struct; diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs index e844be5a702..a60a92988ac 100644 --- a/components/script/dom/canvaspattern.rs +++ b/components/script/dom/canvaspattern.rs @@ -2,12 +2,12 @@ * 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 canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use crate::dom::bindings::codegen::Bindings::CanvasPatternBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::canvasgradient::ToFillOrStrokeStyle; use crate::dom::globalscope::GlobalScope; +use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom_struct::dom_struct; use euclid::Size2D; diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index a50cce88870..f21c7bfda1c 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -2,10 +2,6 @@ * 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 canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg}; -use canvas_traits::canvas::{CompositionOrBlending, FillOrStrokeStyle, FillRule}; -use canvas_traits::canvas::{LineCapStyle, LineJoinStyle, LinearGradientStyle}; -use canvas_traits::canvas::{RadialGradientStyle, RepetitionStyle}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; @@ -29,6 +25,10 @@ use crate::dom::htmlcanvaselement::{CanvasContext, HTMLCanvasElement}; use crate::dom::imagedata::ImageData; use crate::dom::node::{window_from_node, Node, NodeDamage}; use crate::unpremultiplytable::UNPREMULTIPLY_TABLE; +use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg}; +use canvas_traits::canvas::{CompositionOrBlending, FillOrStrokeStyle, FillRule}; +use canvas_traits::canvas::{LineCapStyle, LineJoinStyle, LinearGradientStyle}; +use canvas_traits::canvas::{RadialGradientStyle, RepetitionStyle}; use cssparser::Color as CSSColor; use cssparser::{Parser, ParserInput, RGBA}; use dom_struct::dom_struct; diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index faad37a6f7e..8fe88ba8f94 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -522,7 +522,7 @@ impl CustomElementDefinition { Ok(ConversionResult::Failure(..)) => { return Err(Error::Type( "Constructor did not return a DOM node".to_owned(), - )) + )); }, _ => return Err(Error::JSFailed), }; diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index d679ff0dd3f..48e43f80590 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2,7 +2,6 @@ * 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 cookie::Cookie; use crate::document_loader::{DocumentLoader, LoadType}; use crate::dom::activation::{synthetic_click_activation, ActivationSource}; use crate::dom::attr::Attr; @@ -104,6 +103,7 @@ use crate::script_thread::{MainThreadScriptMsg, ScriptThread}; use crate::task::TaskBox; use crate::task_source::{TaskSource, TaskSourceName}; use crate::timers::OneshotTimerCallback; +use cookie::Cookie; use devtools_traits::ScriptToDevtoolsControlMsg; use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; @@ -542,30 +542,30 @@ impl Document { .dom_manipulation_task_source() .queue( task!(fire_pageshow_event: move || { - let document = document.root(); - let window = document.window(); - // Step 4.6.1 - if document.page_showing.get() { - return; - } - // Step 4.6.2 - document.page_showing.set(true); - // Step 4.6.4 - let event = PageTransitionEvent::new( - window, - atom!("pageshow"), - false, // bubbles - false, // cancelable - true, // persisted - ); - let event = event.upcast::<Event>(); - event.set_trusted(true); - // FIXME(nox): Why are errors silenced here? - let _ = window.upcast::<EventTarget>().dispatch_event_with_target( - document.upcast(), - &event, - ); - }), + let document = document.root(); + let window = document.window(); + // Step 4.6.1 + if document.page_showing.get() { + return; + } + // Step 4.6.2 + document.page_showing.set(true); + // Step 4.6.4 + let event = PageTransitionEvent::new( + window, + atom!("pageshow"), + false, // bubbles + false, // cancelable + true, // persisted + ); + let event = event.upcast::<Event>(); + event.set_trusted(true); + // FIXME(nox): Why are errors silenced here? + let _ = window.upcast::<EventTarget>().dispatch_event_with_target( + document.upcast(), + &event, + ); + }), self.window.upcast(), ) .unwrap(); @@ -615,11 +615,12 @@ impl Document { // FIXME: This should check the dirty bit on the document, // not the document element. Needs some layout changes to make // that workable. - self.stylesheets.borrow().has_changed() || self.GetDocumentElement().map_or(false, |root| { - root.upcast::<Node>().has_dirty_descendants() || - !self.pending_restyles.borrow().is_empty() || - self.needs_paint() - }) + self.stylesheets.borrow().has_changed() || + self.GetDocumentElement().map_or(false, |root| { + root.upcast::<Node>().has_dirty_descendants() || + !self.pending_restyles.borrow().is_empty() || + self.needs_paint() + }) } /// Returns the first `base` element in the DOM that has an `href` attribute. @@ -1940,46 +1941,46 @@ impl Document { .dom_manipulation_task_source() .queue( task!(fire_load_event: move || { - let document = document.root(); - let window = document.window(); - if !window.is_alive() { - return; - } + let document = document.root(); + let window = document.window(); + if !window.is_alive() { + return; + } - // Step 7.1. - document.set_ready_state(DocumentReadyState::Complete); + // Step 7.1. + document.set_ready_state(DocumentReadyState::Complete); - // Step 7.2. - if document.browsing_context().is_none() { - return; - } - let event = Event::new( - window.upcast(), - atom!("load"), - EventBubbles::DoesNotBubble, - EventCancelable::NotCancelable, - ); - event.set_trusted(true); + // Step 7.2. + if document.browsing_context().is_none() { + return; + } + let event = Event::new( + window.upcast(), + atom!("load"), + EventBubbles::DoesNotBubble, + EventCancelable::NotCancelable, + ); + event.set_trusted(true); - // http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventStart - update_with_current_time_ms(&document.load_event_start); + // http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventStart + update_with_current_time_ms(&document.load_event_start); - debug!("About to dispatch load for {:?}", document.url()); - // FIXME(nox): Why are errors silenced here? - let _ = window.upcast::<EventTarget>().dispatch_event_with_target( - document.upcast(), - &event, - ); + debug!("About to dispatch load for {:?}", document.url()); + // FIXME(nox): Why are errors silenced here? + let _ = window.upcast::<EventTarget>().dispatch_event_with_target( + document.upcast(), + &event, + ); - // http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd - update_with_current_time_ms(&document.load_event_end); + // http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd + update_with_current_time_ms(&document.load_event_end); - window.reflow(ReflowGoal::Full, ReflowReason::DocumentLoaded); + window.reflow(ReflowGoal::Full, ReflowReason::DocumentLoaded); - if let Some(fragment) = document.url().fragment() { - document.check_and_scroll_fragment(fragment); - } - }), + if let Some(fragment) = document.url().fragment() { + document.check_and_scroll_fragment(fragment); + } + }), self.window.upcast(), ) .unwrap(); @@ -1992,30 +1993,30 @@ impl Document { .dom_manipulation_task_source() .queue( task!(fire_pageshow_event: move || { - let document = document.root(); - let window = document.window(); - if document.page_showing.get() || !window.is_alive() { - return; - } + let document = document.root(); + let window = document.window(); + if document.page_showing.get() || !window.is_alive() { + return; + } - document.page_showing.set(true); + document.page_showing.set(true); - let event = PageTransitionEvent::new( - window, - atom!("pageshow"), - false, // bubbles - false, // cancelable - false, // persisted - ); - let event = event.upcast::<Event>(); - event.set_trusted(true); + let event = PageTransitionEvent::new( + window, + atom!("pageshow"), + false, // bubbles + false, // cancelable + false, // persisted + ); + let event = event.upcast::<Event>(); + event.set_trusted(true); - // FIXME(nox): Why are errors silenced here? - let _ = window.upcast::<EventTarget>().dispatch_event_with_target( - document.upcast(), - &event, - ); - }), + // FIXME(nox): Why are errors silenced here? + let _ = window.upcast::<EventTarget>().dispatch_event_with_target( + document.upcast(), + &event, + ); + }), self.window.upcast(), ) .unwrap(); @@ -2040,12 +2041,12 @@ impl Document { .dom_manipulation_task_source() .queue( task!(completely_loaded: move || { - let document = document.root(); - document.completely_loaded.set(true); - // Note: this will, among others, result in the "iframe-load-event-steps" being run. - // https://html.spec.whatwg.org/multipage/#iframe-load-event-steps - document.notify_constellation_load(); - }), + let document = document.root(); + document.completely_loaded.set(true); + // Note: this will, among others, result in the "iframe-load-event-steps" being run. + // https://html.spec.whatwg.org/multipage/#iframe-load-event-steps + document.notify_constellation_load(); + }), self.window.upcast(), ) .unwrap(); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 54c1b553beb..34ab0b4ffdb 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1532,11 +1532,9 @@ impl Element { pub fn get_int_attribute(&self, local_name: &LocalName, default: i32) -> i32 { // TODO: Is this assert necessary? - assert!( - local_name - .chars() - .all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch) - ); + assert!(local_name + .chars() + .all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch)); let attribute = self.get_attribute(&ns!(), local_name); match attribute { @@ -1557,11 +1555,9 @@ impl Element { } pub fn get_uint_attribute(&self, local_name: &LocalName, default: u32) -> u32 { - assert!( - local_name - .chars() - .all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch) - ); + assert!(local_name + .chars() + .all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch)); let attribute = self.get_attribute(&ns!(), local_name); match attribute { Some(ref attribute) => match *attribute.value() { @@ -2840,10 +2836,11 @@ impl<'a> SelectorsElement for DomRoot<Element> { fn is_empty(&self) -> bool { self.node.children().all(|node| { - !node.is::<Element>() && match node.downcast::<Text>() { - None => true, - Some(text) => text.upcast::<CharacterData>().data().is_empty(), - } + !node.is::<Element>() && + match node.downcast::<Text>() { + None => true, + Some(text) => text.upcast::<CharacterData>().data().is_empty(), + } }) } diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 43192587934..6092dcc9935 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -2,7 +2,6 @@ * 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 base64; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{ @@ -25,6 +24,7 @@ use crate::dom::progressevent::ProgressEvent; use crate::task::TaskCanceller; use crate::task_source::file_reading::{FileReadingTask, FileReadingTaskSource}; use crate::task_source::{TaskSource, TaskSourceName}; +use base64; use dom_struct::dom_struct; use encoding_rs::{Encoding, UTF_8}; use js::jsapi::Heap; diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index 2e7081cf8ba..82f479b0b80 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -97,14 +97,12 @@ impl FileReaderSyncMethods for FileReaderSync { // step 2 rooted!(in(cx) let mut array_buffer = ptr::null_mut::<JSObject>()); - assert!( - ArrayBuffer::create( - cx, - CreateWith::Slice(&blob_contents), - array_buffer.handle_mut() - ) - .is_ok() - ); + assert!(ArrayBuffer::create( + cx, + CreateWith::Slice(&blob_contents), + array_buffer.handle_mut() + ) + .is_ok()); Ok(NonNull::new_unchecked(array_buffer.get())) } diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index e9a2ccc6eb9..98b24dd1979 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -367,9 +367,10 @@ pub fn is_forbidden_header_name(name: &str) -> bool { let disallowed_header_prefixes = ["sec-", "proxy-"]; - disallowed_headers.iter().any(|header| *header == name) || disallowed_header_prefixes - .iter() - .any(|prefix| name.starts_with(prefix)) + disallowed_headers.iter().any(|header| *header == name) || + disallowed_header_prefixes + .iter() + .any(|prefix| name.starts_with(prefix)) } // There is some unresolved confusion over the definition of a name and a value. diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 34f056f3141..e024fb6a00a 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -413,8 +413,8 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement { Some(ref url) if url.host().is_none() || url.cannot_be_a_base() || url.scheme() == "file" => { - return - }, + return; + } None => return, // Step 4. Some(url) => { diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 666df0eefed..951643c7ea7 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -61,9 +61,10 @@ impl HTMLBodyElement { let self_node = self.upcast::<Node>(); let root_elem = self.upcast::<Element>().root_element(); let root_node = root_elem.upcast::<Node>(); - root_node.is_parent_of(self_node) && self_node - .preceding_siblings() - .all(|n| !n.is::<HTMLBodyElement>()) + root_node.is_parent_of(self_node) && + self_node + .preceding_siblings() + .all(|n| !n.is::<HTMLBodyElement>()) } } diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 1dbb0806728..f0f3f446157 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -2,9 +2,6 @@ * 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 base64; -use canvas_traits::canvas::{CanvasId, CanvasMsg, FromScriptMsg}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; @@ -31,6 +28,9 @@ use crate::dom::webgl2renderingcontext::WebGL2RenderingContext; use crate::dom::webglrenderingcontext::{ LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext, }; +use base64; +use canvas_traits::canvas::{CanvasId, CanvasMsg, FromScriptMsg}; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; use euclid::{Rect, Size2D}; use html5ever::{LocalName, Prefix}; diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 2bde8893a29..f9e249ca85a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -628,20 +628,20 @@ impl VirtualMethods for HTMLIFrameElement { let iframe = Trusted::new(self); document_from_node(self).add_delayed_task(task!(IFrameDelayedInitialize: move || { - let this = iframe.root(); - // https://html.spec.whatwg.org/multipage/#the-iframe-element - // "When an iframe element is inserted into a document that has - // a browsing context, the user agent must create a new - // browsing context, set the element's nested browsing context - // to the newly-created browsing context, and then process the - // iframe attributes for the "first time"." - if this.upcast::<Node>().is_in_doc_with_browsing_context() { - debug!("iframe bound to browsing context."); - debug_assert!(tree_in_doc, "is_in_doc_with_bc, but not tree_in_doc"); - this.create_nested_browsing_context(); - this.process_the_iframe_attributes(ProcessingMode::FirstTime); - } - })); + let this = iframe.root(); + // https://html.spec.whatwg.org/multipage/#the-iframe-element + // "When an iframe element is inserted into a document that has + // a browsing context, the user agent must create a new + // browsing context, set the element's nested browsing context + // to the newly-created browsing context, and then process the + // iframe attributes for the "first time"." + if this.upcast::<Node>().is_in_doc_with_browsing_context() { + debug!("iframe bound to browsing context."); + debug_assert!(tree_in_doc, "is_in_doc_with_bc, but not tree_in_doc"); + this.create_nested_browsing_context(); + this.process_the_iframe_attributes(ProcessingMode::FirstTime); + } + })); } fn unbind_from_tree(&self, context: &UnbindContext) { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 944703de9e7..cf6466b1f27 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -2,7 +2,6 @@ * 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 app_units::{Au, AU_PER_PX}; use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::activation::Activatable; use crate::dom::attr::Attr; @@ -43,6 +42,7 @@ use crate::microtask::{Microtask, MicrotaskRunnable}; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; +use app_units::{Au, AU_PER_PX}; use cssparser::{Parser, ParserInput}; use dom_struct::dom_struct; @@ -286,12 +286,12 @@ impl HTMLImageElement { // FIXME(nox): Why are errors silenced here? let _ = task_source.queue_with_canceller( task!(process_image_response: move || { - let element = element.root(); - // Ignore any image response for a previous request that has been discarded. - if generation == element.generation.get() { - element.process_image_response(image); - } - }), + let element = element.root(); + // Ignore any image response for a previous request that has been discarded. + if generation == element.generation.get() { + element.process_image_response(image); + } + }), &canceller, ); }), diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 63543652594..4541c38038e 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -2,7 +2,6 @@ * 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 caseless::compatibility_caseless_match_str; use crate::dom::activation::{synthetic_click_activation, Activatable, ActivationSource}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; @@ -47,6 +46,7 @@ use crate::textinput::KeyReaction::{ }; use crate::textinput::Lines::Single; use crate::textinput::{Direction, SelectionDirection, TextInput}; +use caseless::compatibility_caseless_match_str; use dom_struct::dom_struct; use embedder_traits::FilterPattern; use html5ever::{LocalName, Prefix}; @@ -946,7 +946,7 @@ impl HTMLInputElement { match self.input_type() { // Step 3.1: it's a button but it is not submitter. InputType::Submit | InputType::Button | InputType::Reset if !is_submitter => { - return vec![] + return vec![]; }, // Step 3.1: it's the "Checkbox" or "Radio Button" and whose checkedness is false. @@ -1769,21 +1769,22 @@ impl Activatable for HTMLInputElement { .unwrap() .filter_map(DomRoot::downcast::<HTMLInputElement>) .filter(|input| { - input.form_owner() == owner && match input.input_type() { - InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Email | - InputType::Password | - InputType::Date | - InputType::Month | - InputType::Week | - InputType::Time | - InputType::DatetimeLocal | - InputType::Number => true, - _ => false, - } + input.form_owner() == owner && + match input.input_type() { + InputType::Text | + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Email | + InputType::Password | + InputType::Date | + InputType::Month | + InputType::Week | + InputType::Time | + InputType::DatetimeLocal | + InputType::Number => true, + _ => false, + } }); if inputs.skip(1).next().is_some() { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 2bde1cf4062..62a24fffede 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -367,15 +367,15 @@ impl HTMLMediaElement { task_source .queue( task!(resolve_pending_play_promises: move || { - let this = this.root(); - if generation_id != this.generation_id.get() { - return; - } + let this = this.root(); + if generation_id != this.generation_id.get() { + return; + } - this.fulfill_in_flight_play_promises(|| { - this.play_media(); - }); - }), + this.fulfill_in_flight_play_promises(|| { + this.play_media(); + }); + }), window.upcast(), ) .unwrap(); @@ -820,8 +820,8 @@ impl HTMLMediaElement { .media_element_task_source() .queue( task!(set_media_delay_load_event_flag_to_false: move || { - this.root().delay_load_event(false); - }), + this.root().delay_load_event(false); + }), window.upcast(), ) .unwrap(); diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 1e827331e53..8aa536c15eb 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -779,8 +779,8 @@ impl VirtualMethods for HTMLScriptElement { if tree_in_doc && !self.parser_inserted.get() { let script = Trusted::new(self); document_from_node(self).add_delayed_task(task!(ScriptDelayedInitialize: move || { - script.root().prepare(); - })); + script.root().prepare(); + })); } } @@ -822,9 +822,9 @@ impl HTMLScriptElementMethods for HTMLScriptElement { // https://html.spec.whatwg.org/multipage/#dom-script-async fn Async(&self) -> bool { - self.non_blocking.get() || self - .upcast::<Element>() - .has_attribute(&local_name!("async")) + self.non_blocking.get() || + self.upcast::<Element>() + .has_attribute(&local_name!("async")) } // https://html.spec.whatwg.org/multipage/#dom-script-async diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index d07f8d315cb..98a0b8226cd 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -44,10 +44,10 @@ struct TableRowFilter { impl CollectionFilter for TableRowFilter { fn filter(&self, elem: &Element, root: &Node) -> bool { elem.is::<HTMLTableRowElement>() && - (root.is_parent_of(elem.upcast()) || self - .sections - .iter() - .any(|ref section| section.is_parent_of(elem.upcast()))) + (root.is_parent_of(elem.upcast()) || + self.sections + .iter() + .any(|ref section| section.is_parent_of(elem.upcast()))) } } @@ -327,7 +327,8 @@ impl HTMLTableElementMethods for HTMLTableElement { .filter_map(DomRoot::downcast::<Element>) .find(|n| { n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody") - }) { + }) + { last_tbody .upcast::<Node>() .AppendChild(new_row.upcast::<Node>()) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index ff6374a8b99..77b7d66cf2d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -4,7 +4,6 @@ //! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. -use app_units::Au; use crate::document_loader::DocumentLoader; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; @@ -55,6 +54,7 @@ use crate::dom::text::Text; use crate::dom::virtualmethods::{vtable_for, VirtualMethods}; use crate::dom::window::Window; use crate::script_thread::ScriptThread; +use app_units::Au; use devtools_traits::NodeInfo; use dom_struct::dom_struct; use euclid::{Point2D, Rect, Size2D, Vector2D}; @@ -1850,10 +1850,9 @@ impl Node { // https://dom.spec.whatwg.org/#concept-node-remove fn remove(node: &Node, parent: &Node, suppress_observers: SuppressObserver) { parent.owner_doc().add_script_and_layout_blocker(); - assert!( - node.GetParentNode() - .map_or(false, |node_parent| &*node_parent == parent) - ); + assert!(node + .GetParentNode() + .map_or(false, |node_parent| &*node_parent == parent)); let cached_index = { if parent.ranges.is_empty() { None @@ -2242,10 +2241,10 @@ impl NodeMethods for Node { // Step 4-5. match node.type_id() { NodeTypeId::CharacterData(CharacterDataTypeId::Text) if self.is::<Document>() => { - return Err(Error::HierarchyRequest) + return Err(Error::HierarchyRequest); }, NodeTypeId::DocumentType if !self.is::<Document>() => { - return Err(Error::HierarchyRequest) + return Err(Error::HierarchyRequest); }, NodeTypeId::Document(_) => return Err(Error::HierarchyRequest), _ => (), @@ -2462,14 +2461,14 @@ impl NodeMethods for Node { NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) if !is_equal_processinginstruction(this, node) => { - return false - }, + return false; + } NodeTypeId::CharacterData(CharacterDataTypeId::Text) | NodeTypeId::CharacterData(CharacterDataTypeId::Comment) if !is_equal_characterdata(this, node) => { - return false - }, + return false; + } // Step 4. NodeTypeId::Element(..) if !is_equal_element_attrs(this, node) => return false, _ => (), diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index 3b6fdabcb16..9454cc36c93 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -2,9 +2,6 @@ * 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 canvas_traits::canvas::CanvasImageData; -use canvas_traits::canvas::CanvasMsg; -use canvas_traits::canvas::FromLayoutMsg; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; @@ -25,6 +22,9 @@ use crate::dom::canvaspattern::CanvasPattern; use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D; use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use crate::dom::workletglobalscope::WorkletGlobalScope; +use canvas_traits::canvas::CanvasImageData; +use canvas_traits::canvas::CanvasMsg; +use canvas_traits::canvas::FromLayoutMsg; use dom_struct::dom_struct; use euclid::Size2D; use euclid::TypedScale; diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 857dbe569b6..852fc45424d 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -72,9 +72,10 @@ impl PerformanceEntryList { .entries .iter() .filter(|e| { - name.as_ref().map_or(true, |name_| *e.name() == *name_) && entry_type - .as_ref() - .map_or(true, |type_| *e.entry_type() == *type_) + name.as_ref().map_or(true, |name_| *e.name() == *name_) && + entry_type + .as_ref() + .map_or(true, |type_| *e.entry_type() == *type_) }) .map(|e| e.clone()) .collect::<Vec<DomRoot<PerformanceEntry>>>(); @@ -92,9 +93,10 @@ impl PerformanceEntryList { entry_type: Option<DOMString>, ) { self.entries.retain(|e| { - name.as_ref().map_or(true, |name_| *e.name() == *name_) && entry_type - .as_ref() - .map_or(true, |type_| *e.entry_type() == *type_) + name.as_ref().map_or(true, |name_| *e.name() == *name_) && + entry_type + .as_ref() + .map_or(true, |type_| *e.entry_type() == *type_) }); } diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs index f5fc47e1054..c224d8f77e8 100644 --- a/components/script/dom/promiserejectionevent.rs +++ b/components/script/dom/promiserejectionevent.rs @@ -76,7 +76,7 @@ impl PromiseRejectionEvent { None => { return Err(Error::Type( "required member promise is undefined.".to_string(), - )) + )); }, }; let bubbles = EventBubbles::from(init.parent.bubbles); diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 74dc526c57f..e30c5601cf7 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -758,11 +758,12 @@ impl RangeMethods for Range { let new_offset = reference_node.r().map_or(parent.len(), |node| node.index()); // Step 11 - let new_offset = new_offset + if node.type_id() == NodeTypeId::DocumentFragment { - node.len() - } else { - 1 - }; + let new_offset = new_offset + + if node.type_id() == NodeTypeId::DocumentFragment { + node.len() + } else { + 1 + }; // Step 12. Node::pre_insert(node, &parent, reference_node.r())?; @@ -874,7 +875,7 @@ impl RangeMethods for Range { // Step 2. match new_parent.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentType | NodeTypeId::DocumentFragment => { - return Err(Error::InvalidNodeType) + return Err(Error::InvalidNodeType); }, _ => (), } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index 438c49a6407..4a7ae2482a4 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -379,12 +379,12 @@ impl Request { HttpMethod::GET => { return Err(Error::Type( "Init's body is non-null, and request method is GET".to_string(), - )) + )); }, HttpMethod::HEAD => { return Err(Error::Type( "Init's body is non-null, and request method is HEAD".to_string(), - )) + )); }, _ => {}, } diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index 7c52934386a..74624ba45b4 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -213,21 +213,21 @@ impl Storage { .dom_manipulation_task_source() .queue( task!(send_storage_notification: move || { - let this = this.root(); - let global = this.global(); - let event = StorageEvent::new( - global.as_window(), - atom!("storage"), - EventBubbles::DoesNotBubble, - EventCancelable::NotCancelable, - key.map(DOMString::from), - old_value.map(DOMString::from), - new_value.map(DOMString::from), - DOMString::from(url.into_string()), - Some(&this), - ); - event.upcast::<Event>().fire(global.upcast()); - }), + let this = this.root(); + let global = this.global(); + let event = StorageEvent::new( + global.as_window(), + atom!("storage"), + EventBubbles::DoesNotBubble, + EventCancelable::NotCancelable, + key.map(DOMString::from), + old_value.map(DOMString::from), + new_value.map(DOMString::from), + DOMString::from(url.into_string()), + Some(&this), + ); + event.upcast::<Event>().fire(global.upcast()); + }), global.upcast(), ) .unwrap(); diff --git a/components/script/dom/testrunner.rs b/components/script/dom/testrunner.rs index 74c1e04537e..69c993a1423 100644 --- a/components/script/dom/testrunner.rs +++ b/components/script/dom/testrunner.rs @@ -2,7 +2,6 @@ * 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 bluetooth_traits::BluetoothRequest; use crate::dom::bindings::codegen::Bindings::TestRunnerBinding; use crate::dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods; use crate::dom::bindings::error::{Error, ErrorResult}; @@ -10,6 +9,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; +use bluetooth_traits::BluetoothRequest; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; use profile_traits::ipc; diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 3fde3c70090..af5437b2516 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -189,8 +189,8 @@ impl TreeWalkerMethods for TreeWalker { // This can happen if the user set the current node to somewhere // outside of the tree rooted at the original root. { - return Ok(None) - }, + return Ok(None); + } Some(n) => node = n, } // "5. Filter node and if the return value is FILTER_ACCEPT, then @@ -321,8 +321,8 @@ impl TreeWalker { Some(ref parent) if self.is_root_node(&parent) || self.is_current_node(&parent) => { - return Ok(None) - }, + return Ok(None); + } // "5. Otherwise, set node to parent." Some(parent) => node = parent, } diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index 4864e7ae4a1..f41dee046be 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -27,7 +27,7 @@ pub enum ValidityStatus { Valid, } -bitflags!{ +bitflags! { pub struct ValidationFlags: u32 { const VALUE_MISSING = 0b0000000001; const TYPE_MISMATCH = 0b0000000010; diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 9785106c252..c02d5439be8 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -2,7 +2,6 @@ * 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 canvas_traits::webgl::{webgl_channel, WebGLReceiver, WebVRCommand}; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::PerformanceMethods; @@ -33,6 +32,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CommonScriptMsg; use crate::script_runtime::ScriptThreadEventCategory::WebVREvent; use crate::task_source::TaskSourceName; +use canvas_traits::webgl::{webgl_channel, WebGLReceiver, WebVRCommand}; use crossbeam_channel::{unbounded, Sender}; use dom_struct::dom_struct; use ipc_channel::ipc::IpcSender; @@ -551,8 +551,8 @@ impl VRDisplay { let this = address.clone(); let sender = raf_sender.clone(); let task = Box::new(task!(handle_vrdisplay_raf: move || { - this.root().handle_raf(&sender); - })); + this.root().handle_raf(&sender); + })); // NOTE: WebVR spec doesn't specify what task source we should use. Is // dom-manipulation a good choice long term? js_sender diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 658df0adc85..2196ae4f693 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -2,8 +2,6 @@ * 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/. */ -/// https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl.idl -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextMethods; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; @@ -31,6 +29,8 @@ use crate::dom::webglshaderprecisionformat::WebGLShaderPrecisionFormat; use crate::dom::webgltexture::WebGLTexture; use crate::dom::webgluniformlocation::WebGLUniformLocation; use crate::dom::window::Window; +/// https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl.idl +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; use euclid::Size2D; use js::jsapi::{JSContext, JSObject}; diff --git a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs index 9b0fca691f7..ddea5daa043 100644 --- a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs +++ b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs @@ -3,13 +3,13 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/extblendminmax.rs b/components/script/dom/webgl_extensions/ext/extblendminmax.rs index 835be6ff540..149ef10b2dc 100644 --- a/components/script/dom/webgl_extensions/ext/extblendminmax.rs +++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs index a3dbf6f53a9..2785fcac2d1 100644 --- a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs @@ -3,12 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webgl_extensions::ext::oestexturehalffloat::OESTextureHalfFloat; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs index c0e363ebcd5..33ea2aa67b8 100644 --- a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs +++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::{is_gles, WebGLVersion}; use crate::dom::bindings::codegen::Bindings::EXTShaderTextureLodBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{is_gles, WebGLVersion}; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs index 3d708f4191f..b8d987c2839 100644 --- a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs +++ b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs @@ -3,12 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs index ecb90afd371..3182ed8699f 100644 --- a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs +++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::{is_gles, WebGLVersion}; use crate::dom::bindings::codegen::Bindings::OESElementIndexUintBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{is_gles, WebGLVersion}; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index 1da30688f67..5505deb543a 100644 --- a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -3,12 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::{is_gles, WebGLVersion}; use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding; use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{is_gles, WebGLVersion}; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index f9c56be9e8c..a0ddf13d987 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -5,11 +5,11 @@ use super::{ constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, }; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::OESTextureFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs index 0418c6756fd..4db4e1a54b2 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs @@ -5,13 +5,13 @@ use super::{ constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, }; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::{ self, OESTextureHalfFloatConstants, }; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs index 56b75e7b0d2..d4f2dda95cb 100644 --- a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs +++ b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{ self, OESVertexArrayObjectMethods, @@ -12,6 +11,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs index 06affa08fd5..0ac480e9344 100644 --- a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs +++ b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs @@ -3,12 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webgl_extensions::ext::oestexturefloat::OESTextureFloat; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webgl_extensions/extension.rs b/components/script/dom/webgl_extensions/extension.rs index fd7cb17ffaf..3854acee122 100644 --- a/components/script/dom/webgl_extensions/extension.rs +++ b/components/script/dom/webgl_extensions/extension.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::WebGLExtensions; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; /// Trait implemented by WebGL extensions. pub trait WebGLExtension: Sized diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index 504f0784d82..aa6d128ae89 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -4,7 +4,6 @@ use super::wrapper::{TypedWebGLExtensionWrapper, WebGLExtensionWrapper}; use super::{ext, WebGLExtension, WebGLExtensionSpec}; -use canvas_traits::webgl::WebGLVersion; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; @@ -18,6 +17,7 @@ use crate::dom::oestexturefloat::OESTextureFloat; use crate::dom::oestexturehalffloat::OESTextureHalfFloat; use crate::dom::webglcolorbufferfloat::WEBGLColorBufferFloat; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::WebGLVersion; use fnv::{FnvHashMap, FnvHashSet}; use gleam::gl::{self, GLenum}; use js::jsapi::JSObject; diff --git a/components/script/dom/webgl_validations/tex_image_2d.rs b/components/script/dom/webgl_validations/tex_image_2d.rs index 7cb192802f3..d9bce435234 100644 --- a/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/components/script/dom/webgl_validations/tex_image_2d.rs @@ -4,10 +4,10 @@ use super::types::TexImageTarget; use super::WebGLValidator; -use canvas_traits::webgl::{TexDataType, TexFormat, WebGLError::*}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webgltexture::WebGLTexture; +use canvas_traits::webgl::{TexDataType, TexFormat, WebGLError::*}; use std::{self, fmt}; /// The errors that the texImage* family of functions can generate. diff --git a/components/script/dom/webgl_validations/types.rs b/components/script/dom/webgl_validations/types.rs index fe5e7e35f59..597e924724a 100644 --- a/components/script/dom/webgl_validations/types.rs +++ b/components/script/dom/webgl_validations/types.rs @@ -2,8 +2,8 @@ * 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 canvas_traits::gl_enums; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants; +use canvas_traits::gl_enums; gl_enums! { pub enum TexImageTarget { diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index f068cd598e5..acf30e28855 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -3,8 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::webgl_channel; -use canvas_traits::webgl::{WebGLBufferId, WebGLCommand, WebGLError, WebGLResult}; use crate::dom::bindings::codegen::Bindings::WebGLBufferBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants; use crate::dom::bindings::inheritance::Castable; @@ -12,6 +10,8 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::webgl_channel; +use canvas_traits::webgl::{WebGLBufferId, WebGLCommand, WebGLError, WebGLResult}; use dom_struct::dom_struct; use ipc_channel::ipc; use std::cell::Cell; diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 5386a3f5df4..86fb30fb8fd 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -3,8 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{webgl_channel, WebGLError, WebGLResult}; -use canvas_traits::webgl::{WebGLCommand, WebGLFramebufferBindingRequest, WebGLFramebufferId}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -15,6 +13,8 @@ use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderbuffer::WebGLRenderbuffer; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webgltexture::WebGLTexture; +use canvas_traits::webgl::{webgl_channel, WebGLError, WebGLResult}; +use canvas_traits::webgl::{WebGLCommand, WebGLFramebufferBindingRequest, WebGLFramebufferId}; use dom_struct::dom_struct; use std::cell::Cell; @@ -531,11 +531,7 @@ impl WebGLFramebuffer { Some(WebGLFramebufferAttachment::Texture { texture: ref att_texture, .. - }) - if texture.id() == att_texture.id() => - { - true - }, + }) if texture.id() == att_texture.id() => true, _ => false, } }; diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 9338ad036cf..5ec0e2949fe 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -3,8 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult}; -use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, WebGLCommand, WebGLError}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGLProgramBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -17,6 +15,8 @@ use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webglshader::WebGLShader; use crate::dom::webgluniformlocation::WebGLUniformLocation; +use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult}; +use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, WebGLCommand, WebGLError}; use dom_struct::dom_struct; use fnv::FnvHashSet; use std::cell::{Cell, Ref}; @@ -247,7 +247,7 @@ impl WebGLProgram { match shader_slot.get() { Some(ref attached_shader) if attached_shader.id() != shader.id() => { - return Err(WebGLError::InvalidOperation) + return Err(WebGLError::InvalidOperation); }, None => return Err(WebGLError::InvalidOperation), _ => {}, diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 663b729286d..d1387b277aa 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -3,9 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{ - is_gles, webgl_channel, WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, -}; use crate::dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding::EXTColorBufferHalfFloatConstants; use crate::dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding::WEBGLColorBufferFloatConstants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants; @@ -16,6 +13,9 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{ + is_gles, webgl_channel, WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, +}; use dom_struct::dom_struct; use std::cell::Cell; diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index c7896b42436..726a59db4ad 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2,15 +2,6 @@ * 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/. */ -#[cfg(feature = "webgl_backtrace")] -use backtrace::Backtrace; -use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::{ - webgl_channel, AlphaTreatment, DOMToTextureCommand, Parameter, TexDataType, TexFormat, - TexParameter, WebGLCommand, WebGLCommandBacktrace, WebGLContextShareMode, WebGLError, - WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, WebGLProgramId, WebGLResult, - WebGLSLVersion, WebGLSender, WebGLVersion, WebVRCommand, YAxisTreatment, -}; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding::EXTBlendMinmaxConstants; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; @@ -55,6 +46,15 @@ use crate::dom::webgltexture::{TexParameterValue, WebGLTexture}; use crate::dom::webgluniformlocation::WebGLUniformLocation; use crate::dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES; use crate::dom::window::Window; +#[cfg(feature = "webgl_backtrace")] +use backtrace::Backtrace; +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{ + webgl_channel, AlphaTreatment, DOMToTextureCommand, Parameter, TexDataType, TexFormat, + TexParameter, WebGLCommand, WebGLCommandBacktrace, WebGLContextShareMode, WebGLError, + WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, WebGLProgramId, WebGLResult, + WebGLSLVersion, WebGLSender, WebGLVersion, WebVRCommand, YAxisTreatment, +}; use dom_struct::dom_struct; use euclid::{Point2D, Rect, Size2D}; use ipc_channel::ipc::{self, IpcSharedMemory}; @@ -1913,9 +1913,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11 fn Clear(&self, mask: u32) { handle_potential_webgl_error!(self, self.validate_framebuffer(), return); - if mask & !(constants::DEPTH_BUFFER_BIT | - constants::STENCIL_BUFFER_BIT | - constants::COLOR_BUFFER_BIT) != + if mask & + !(constants::DEPTH_BUFFER_BIT | + constants::STENCIL_BUFFER_BIT | + constants::COLOR_BUFFER_BIT) != 0 { return self.webgl_error(InvalidValue); diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 0c17aa4e5d5..8f53267b50b 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -3,9 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{webgl_channel, WebGLVersion}; -use canvas_traits::webgl::{WebGLCommand, WebGLError}; -use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLShaderId}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGLShaderBinding; use crate::dom::bindings::inheritance::Castable; @@ -17,6 +14,9 @@ use crate::dom::webgl_extensions::ext::oesstandardderivatives::OESStandardDeriva use crate::dom::webgl_extensions::WebGLExtensions; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{webgl_channel, WebGLVersion}; +use canvas_traits::webgl::{WebGLCommand, WebGLError}; +use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLShaderId}; use dom_struct::dom_struct; use mozangle::shaders::{BuiltInResources, Output, ShaderValidator}; use offscreen_gl_context::GLLimits; diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 626ceb22cf7..261edbe67be 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -4,8 +4,6 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{webgl_channel, TexDataType, TexFormat, WebGLResult, WebGLTextureId}; -use canvas_traits::webgl::{DOMToTextureCommand, WebGLCommand, WebGLError}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -16,6 +14,8 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::webgl_validations::types::TexImageTarget; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{webgl_channel, TexDataType, TexFormat, WebGLResult, WebGLTextureId}; +use canvas_traits::webgl::{DOMToTextureCommand, WebGLCommand, WebGLError}; use dom_struct::dom_struct; use std::cell::Cell; use std::cmp; diff --git a/components/script/dom/webgluniformlocation.rs b/components/script/dom/webgluniformlocation.rs index c1582c40b19..bf142480dc7 100644 --- a/components/script/dom/webgluniformlocation.rs +++ b/components/script/dom/webgluniformlocation.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::WebGLProgramId; use crate::dom::bindings::codegen::Bindings::WebGLUniformLocationBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; +use canvas_traits::webgl::WebGLProgramId; use dom_struct::dom_struct; #[dom_struct] diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index 10103bef8ba..871de741c39 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -2,9 +2,6 @@ * 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 canvas_traits::webgl::{ - ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVertexArrayId, -}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding; @@ -14,6 +11,9 @@ use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use canvas_traits::webgl::{ + ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVertexArrayId, +}; use dom_struct::dom_struct; use ref_filter_map::ref_filter_map; use std::cell::{Cell, Ref}; diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 4ca4e5fbb9d..4344078a017 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -583,14 +583,12 @@ impl TaskOnce for MessageReceivedTask { }, BinaryType::Arraybuffer => { rooted!(in(cx) let mut array_buffer = ptr::null_mut::<JSObject>()); - assert!( - ArrayBuffer::create( - cx, - CreateWith::Slice(&data), - array_buffer.handle_mut() - ) - .is_ok() - ); + assert!(ArrayBuffer::create( + cx, + CreateWith::Slice(&data), + array_buffer.handle_mut() + ) + .is_ok()); (*array_buffer).to_jsval(cx, message.handle_mut()); }, diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 1dbe0fc4c3a..ee637e39ebf 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -2,10 +2,6 @@ * 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 app_units::Au; -use base64; -use bluetooth_traits::BluetoothRequest; -use canvas_traits::webgl::WebGLChan; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ DocumentMethods, DocumentReadyState, @@ -68,6 +64,10 @@ use crate::task_manager::TaskManager; use crate::task_source::TaskSourceName; use crate::timers::{IsInterval, TimerCallback}; use crate::webdriver_handlers::jsval_to_webdriver; +use app_units::Au; +use base64; +use bluetooth_traits::BluetoothRequest; +use canvas_traits::webgl::WebGLChan; use crossbeam_channel::{unbounded, Sender, TryRecvError}; use cssparser::{Parser, ParserInput}; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; @@ -1747,16 +1747,16 @@ impl Window { let old_url = doc.url().into_string(); let new_url = url.clone().into_string(); let task = task!(hashchange_event: move || { - let this = this.root(); - let event = HashChangeEvent::new( - &this, - atom!("hashchange"), - false, - false, - old_url, - new_url); - event.upcast::<Event>().fire(this.upcast::<EventTarget>()); - }); + let this = this.root(); + let event = HashChangeEvent::new( + &this, + atom!("hashchange"), + false, + false, + old_url, + new_url); + event.upcast::<Event>().fire(this.upcast::<EventTarget>()); + }); // FIXME(nox): Why are errors silenced here? let _ = self.script_chan.send(CommonScriptMsg::Task( ScriptThreadEventCategory::DomEvent, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 18628f27f70..7c32c5e9015 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -695,9 +695,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest { for param in mime.params() { if param.0 == mime::CHARSET { if !param.1.as_ref().eq_ignore_ascii_case(encoding) { - let new_params: Vec< - (Name, Name), - > = mime + let new_params: Vec<(Name, Name)> = mime .params() .filter(|p| p.0 != mime::CHARSET) .map(|p| (p.0, p.1)) @@ -829,7 +827,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest { // Step 1 match self.ready_state.get() { XMLHttpRequestState::Loading | XMLHttpRequestState::Done => { - return Err(Error::InvalidState) + return Err(Error::InvalidState); }, _ => {}, } |