diff options
Diffstat (limited to 'components')
776 files changed, 6629 insertions, 6125 deletions
diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index 45a535a6e41..826ce6e8aed 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -7,17 +7,18 @@ #[global_allocator] static ALLOC: Allocator = Allocator; -pub use crate::platform::*; - #[cfg(not(windows))] pub use jemalloc_sys; +pub use crate::platform::*; + #[cfg(not(windows))] mod platform { - use jemalloc_sys as ffi; use std::alloc::{GlobalAlloc, Layout}; use std::os::raw::{c_int, c_void}; + use jemalloc_sys as ffi; + /// Get the size of a heap block. pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { ffi::malloc_usable_size(ptr as *const _) @@ -100,6 +101,7 @@ mod platform { mod platform { pub use std::alloc::System as Allocator; use std::os::raw::c_void; + use winapi::um::heapapi::{GetProcessHeap, HeapSize, HeapValidate}; /// Get the size of a heap block. diff --git a/components/background_hang_monitor/background_hang_monitor.rs b/components/background_hang_monitor/background_hang_monitor.rs index fab2b406ce2..c438541af7b 100644 --- a/components/background_hang_monitor/background_hang_monitor.rs +++ b/components/background_hang_monitor/background_hang_monitor.rs @@ -2,24 +2,23 @@ * 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::sampler::{NativeStack, Sampler}; +use std::cell::Cell; +use std::collections::{HashMap, VecDeque}; +use std::sync::{Arc, Weak}; +use std::thread; +use std::time::{Duration, Instant}; + use crossbeam_channel::{after, never, select, unbounded, Receiver, Sender}; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use log::warn; -use msg::constellation_msg::MonitoredComponentId; -use msg::constellation_msg::{ - BackgroundHangMonitor, BackgroundHangMonitorClone, BackgroundHangMonitorExitSignal, - BackgroundHangMonitorRegister, -}; use msg::constellation_msg::{ - BackgroundHangMonitorControlMsg, HangAlert, HangAnnotation, HangMonitorAlert, + BackgroundHangMonitor, BackgroundHangMonitorClone, BackgroundHangMonitorControlMsg, + BackgroundHangMonitorExitSignal, BackgroundHangMonitorRegister, HangAlert, HangAnnotation, + HangMonitorAlert, MonitoredComponentId, }; -use std::cell::Cell; -use std::collections::{HashMap, VecDeque}; -use std::sync::{Arc, Weak}; -use std::thread; -use std::time::{Duration, Instant}; + +use crate::sampler::{NativeStack, Sampler}; #[derive(Clone)] pub struct HangMonitorRegister { diff --git a/components/background_hang_monitor/sampler.rs b/components/background_hang_monitor/sampler.rs index 3945bd1ccc8..593401a08a5 100644 --- a/components/background_hang_monitor/sampler.rs +++ b/components/background_hang_monitor/sampler.rs @@ -2,9 +2,10 @@ * 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::ptr; + use backtrace; use msg::constellation_msg::{HangProfile, HangProfileSymbol}; -use std::ptr; const MAX_NATIVE_FRAMES: usize = 1024; diff --git a/components/background_hang_monitor/sampler_linux.rs b/components/background_hang_monitor/sampler_linux.rs index b0561c743d6..10fdc447ca9 100644 --- a/components/background_hang_monitor/sampler_linux.rs +++ b/components/background_hang_monitor/sampler_linux.rs @@ -4,20 +4,18 @@ #![allow(unsafe_code)] -use crate::sampler::{NativeStack, Sampler}; -use libc; -use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal}; use std::cell::UnsafeCell; -use std::io; -use std::mem; -use std::process; -use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; -use std::thread; +use std::{io, mem, process, ptr, thread}; + +use libc; +use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal}; use unwind_sys::{ unw_cursor_t, unw_get_reg, unw_init_local, unw_step, UNW_ESUCCESS, UNW_REG_IP, UNW_REG_SP, }; +use crate::sampler::{NativeStack, Sampler}; + // Hack to workaround broken libunwind pkg-config contents for <1.1-3ubuntu.1. // https://bugs.launchpad.net/ubuntu/+source/libunwind/+bug/1336912 #[link(name = "lzma")] diff --git a/components/background_hang_monitor/sampler_mac.rs b/components/background_hang_monitor/sampler_mac.rs index e5a575ca3f3..8121865db7f 100644 --- a/components/background_hang_monitor/sampler_mac.rs +++ b/components/background_hang_monitor/sampler_mac.rs @@ -2,11 +2,11 @@ * 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::{panic, process}; + +use {libc, mach}; + use crate::sampler::{Address, NativeStack, Registers, Sampler}; -use libc; -use mach; -use std::panic; -use std::process; type MonitoredThreadId = mach::mach_types::thread_act_t; diff --git a/components/background_hang_monitor/tests/hang_monitor_tests.rs b/components/background_hang_monitor/tests/hang_monitor_tests.rs index 31ac269a8c1..f98978fea02 100644 --- a/components/background_hang_monitor/tests/hang_monitor_tests.rs +++ b/components/background_hang_monitor/tests/hang_monitor_tests.rs @@ -4,20 +4,18 @@ #![allow(unused_imports)] +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::Duration; + use background_hang_monitor::HangMonitorRegister; use ipc_channel::ipc; -use msg::constellation_msg::ScriptHangAnnotation; -use msg::constellation_msg::TEST_PIPELINE_ID; use msg::constellation_msg::{ BackgroundHangMonitorControlMsg, BackgroundHangMonitorExitSignal, HangAlert, HangAnnotation, - HangMonitorAlert, + HangMonitorAlert, MonitoredComponentId, MonitoredComponentType, ScriptHangAnnotation, + TEST_PIPELINE_ID, }; -use msg::constellation_msg::{MonitoredComponentId, MonitoredComponentType}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use std::sync::Mutex; -use std::thread; -use std::time::Duration; lazy_static::lazy_static! { static ref SERIAL: Mutex<()> = Mutex::new(()); diff --git a/components/bluetooth/lib.rs b/components/bluetooth/lib.rs index 89bfa97404b..e6d7a533a53 100644 --- a/components/bluetooth/lib.rs +++ b/components/bluetooth/lib.rs @@ -4,26 +4,31 @@ pub mod test; +use std::borrow::ToOwned; +use std::collections::{HashMap, HashSet}; +use std::string::String; +use std::thread; +use std::time::Duration; + use bitflags::bitflags; use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; use bluetooth_traits::scanfilter::{ BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions, }; -use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothServiceMsg}; -use bluetooth_traits::{BluetoothDeviceMsg, BluetoothRequest, BluetoothResponse, GATTType}; -use bluetooth_traits::{BluetoothError, BluetoothResponseResult, BluetoothResult}; -use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic}; -use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService}; +use bluetooth_traits::{ + BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothDeviceMsg, BluetoothError, + BluetoothRequest, BluetoothResponse, BluetoothResponseResult, BluetoothResult, + BluetoothServiceMsg, GATTType, +}; +use device::bluetooth::{ + BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic, BluetoothGATTDescriptor, + BluetoothGATTService, +}; use embedder_traits::{EmbedderMsg, EmbedderProxy}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use log::warn; use servo_config::pref; use servo_rand::{self, Rng}; -use std::borrow::ToOwned; -use std::collections::{HashMap, HashSet}; -use std::string::String; -use std::thread; -use std::time::Duration; // A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed. // https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 480) diff --git a/components/bluetooth/test.rs b/components/bluetooth/test.rs index df4f5ed8087..25e4d9cbb7d 100644 --- a/components/bluetooth/test.rs +++ b/components/bluetooth/test.rs @@ -2,18 +2,20 @@ * 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::BluetoothManager; -use device::bluetooth::{BluetoothAdapter, BluetoothDevice}; -use device::bluetooth::{ - BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService, -}; use std::borrow::ToOwned; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::error::Error; use std::string::String; + +use device::bluetooth::{ + BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic, BluetoothGATTDescriptor, + BluetoothGATTService, +}; use uuid::Uuid; +use crate::BluetoothManager; + thread_local!(pub static CACHED_IDS: RefCell<HashSet<Uuid>> = RefCell::new(HashSet::new())); const ADAPTER_ERROR: &'static str = "No adapter found"; diff --git a/components/bluetooth_traits/blocklist.rs b/components/bluetooth_traits/blocklist.rs index 94df49af428..ca413c41a1e 100644 --- a/components/bluetooth_traits/blocklist.rs +++ b/components/bluetooth_traits/blocklist.rs @@ -2,12 +2,13 @@ * 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 embedder_traits::resources::{self, Resource}; -use regex::Regex; use std::cell::RefCell; use std::collections::HashMap; use std::string::String; +use embedder_traits::resources::{self, Resource}; +use regex::Regex; + const EXCLUDE_READS: &str = "exclude-reads"; const EXCLUDE_WRITES: &str = "exclude-writes"; const VALID_UUID_REGEX: &str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; diff --git a/components/bluetooth_traits/lib.rs b/components/bluetooth_traits/lib.rs index a4e54e25808..5910aa3c284 100644 --- a/components/bluetooth_traits/lib.rs +++ b/components/bluetooth_traits/lib.rs @@ -5,10 +5,11 @@ pub mod blocklist; pub mod scanfilter; -use crate::scanfilter::{BluetoothScanfilterSequence, RequestDeviceoptions}; use ipc_channel::ipc::IpcSender; use serde::{Deserialize, Serialize}; +use crate::scanfilter::{BluetoothScanfilterSequence, RequestDeviceoptions}; + #[derive(Debug, Deserialize, Serialize)] pub enum BluetoothError { Type(String), diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index e70602493fb..d75ef2529f0 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -2,8 +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 crate::canvas_paint_thread::{AntialiasMode, ImageUpdate, WebrenderApi}; -use crate::raqote_backend::Repetition; +use std::cell::RefCell; +#[allow(unused_imports)] +use std::marker::PhantomData; +use std::mem; +use std::sync::{Arc, Mutex}; + use canvas_traits::canvas::*; use cssparser::RGBA; use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D}; @@ -20,17 +24,15 @@ use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use log::{debug, error, warn}; use num_traits::ToPrimitive; use servo_arc::Arc as ServoArc; -use std::cell::RefCell; -#[allow(unused_imports)] -use std::marker::PhantomData; -use std::mem; -use std::sync::{Arc, Mutex}; use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font; use style_traits::values::ToCss; use webrender_api::units::{DeviceIntSize, RectExt as RectExt_}; use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey}; +use crate::canvas_paint_thread::{AntialiasMode, ImageUpdate, WebrenderApi}; +use crate::raqote_backend::Repetition; + /// The canvas data stores a state machine for the current status of /// the path data and any relevant transformations that are /// applied to it. The Azure drawing API expects the path to be in diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index f2918f19c4b..7234aaed4ab 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -2,7 +2,10 @@ * 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::canvas_data::*; +use std::borrow::ToOwned; +use std::collections::HashMap; +use std::thread; + use canvas_traits::canvas::*; use canvas_traits::ConstellationCanvasMsg; use crossbeam_channel::{select, unbounded, Sender}; @@ -11,11 +14,10 @@ use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use log::warn; -use std::borrow::ToOwned; -use std::collections::HashMap; -use std::thread; use webrender_api::{ImageData, ImageDescriptor, ImageKey}; +use crate::canvas_data::*; + pub enum AntialiasMode { Default, None, diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 1c81b6ea694..0cc22d410bb 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -2,13 +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 crate::canvas_data; -use crate::canvas_data::{ - Backend, CanvasPaintState, Color, CompositionOp, DrawOptions, ExtendMode, Filter, - GenericDrawTarget, GenericPathBuilder, GradientStop, GradientStops, Path, SourceSurface, - StrokeOptions, SurfaceFormat, -}; -use crate::canvas_paint_thread::AntialiasMode; +use std::marker::PhantomData; + use canvas_traits::canvas::*; use cssparser::RGBA; use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D}; @@ -17,7 +12,14 @@ use font_kit::font::Font; use log::warn; use lyon_geom::Arc; use raqote::PathOp; -use std::marker::PhantomData; + +use crate::canvas_data; +use crate::canvas_data::{ + Backend, CanvasPaintState, Color, CompositionOp, DrawOptions, ExtendMode, Filter, + GenericDrawTarget, GenericPathBuilder, GradientStop, GradientStops, Path, SourceSurface, + StrokeOptions, SurfaceFormat, +}; +use crate::canvas_paint_thread::AntialiasMode; pub struct RaqoteBackend; diff --git a/components/canvas/webgl_limits.rs b/components/canvas/webgl_limits.rs index 803d5525259..94c52bc7934 100644 --- a/components/canvas/webgl_limits.rs +++ b/components/canvas/webgl_limits.rs @@ -4,9 +4,7 @@ use canvas_traits::webgl::{GLLimits, WebGLVersion}; use sparkle::gl; -use sparkle::gl::GLenum; -use sparkle::gl::Gl; -use sparkle::gl::GlType; +use sparkle::gl::{GLenum, Gl, GlType}; pub trait GLLimitsDetect { fn detect(gl: &Gl, webgl_version: WebGLVersion) -> Self; diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs index 3835e414a43..749f0062aeb 100644 --- a/components/canvas/webgl_mode/inprocess.rs +++ b/components/canvas/webgl_mode/inprocess.rs @@ -2,15 +2,14 @@ * 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::webgl_thread::{WebGLThread, WebGLThreadInit, WebXRBridgeInit}; -use canvas_traits::webgl::webgl_channel; -use canvas_traits::webgl::{WebGLContextId, WebGLMsg, WebGLThreads}; +use std::default::Default; +use std::sync::{Arc, Mutex}; + +use canvas_traits::webgl::{webgl_channel, WebGLContextId, WebGLMsg, WebGLThreads}; use euclid::default::Size2D; use fnv::FnvHashMap; use log::debug; use sparkle::gl::GlType; -use std::default::Default; -use std::sync::{Arc, Mutex}; use surfman::chains::{SwapChainAPI, SwapChains, SwapChainsAPI}; use surfman::{Device, SurfaceInfo, SurfaceTexture}; use webrender::RenderApiSender; @@ -22,6 +21,8 @@ use webrender_traits::{ use webxr::SurfmanGL as WebXRSurfman; use webxr_api::LayerGrandManager as WebXRLayerGrandManager; +use crate::webgl_thread::{WebGLThread, WebGLThreadInit, WebXRBridgeInit}; + pub struct WebGLComm { pub webgl_threads: WebGLThreads, pub image_handler: Box<dyn WebrenderExternalImageApi>, diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index e8636debf23..8e1e55f4c91 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -2,87 +2,54 @@ * 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::webgl_limits::GLLimitsDetect; +use std::borrow::Cow; +use std::collections::HashMap; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; +use std::{slice, thread}; + use bitflags::bitflags; use byteorder::{ByteOrder, NativeEndian, WriteBytesExt}; use canvas_traits::webgl; -use canvas_traits::webgl::webgl_channel; -use canvas_traits::webgl::ActiveAttribInfo; -use canvas_traits::webgl::ActiveUniformBlockInfo; -use canvas_traits::webgl::ActiveUniformInfo; -use canvas_traits::webgl::AlphaTreatment; -use canvas_traits::webgl::GLContextAttributes; -use canvas_traits::webgl::GLLimits; -use canvas_traits::webgl::GlType; -use canvas_traits::webgl::InternalFormatIntVec; -use canvas_traits::webgl::ProgramLinkInfo; -use canvas_traits::webgl::TexDataType; -use canvas_traits::webgl::TexFormat; -use canvas_traits::webgl::WebGLBufferId; -use canvas_traits::webgl::WebGLChan; -use canvas_traits::webgl::WebGLCommand; -use canvas_traits::webgl::WebGLCommandBacktrace; -use canvas_traits::webgl::WebGLContextId; -use canvas_traits::webgl::WebGLCreateContextResult; -use canvas_traits::webgl::WebGLFramebufferBindingRequest; -use canvas_traits::webgl::WebGLFramebufferId; -use canvas_traits::webgl::WebGLMsg; -use canvas_traits::webgl::WebGLMsgSender; -use canvas_traits::webgl::WebGLProgramId; -use canvas_traits::webgl::WebGLQueryId; -use canvas_traits::webgl::WebGLReceiver; -use canvas_traits::webgl::WebGLRenderbufferId; -use canvas_traits::webgl::WebGLSLVersion; -use canvas_traits::webgl::WebGLSamplerId; -use canvas_traits::webgl::WebGLSender; -use canvas_traits::webgl::WebGLShaderId; -use canvas_traits::webgl::WebGLSyncId; -use canvas_traits::webgl::WebGLTextureId; -use canvas_traits::webgl::WebGLVersion; -use canvas_traits::webgl::WebGLVertexArrayId; -use canvas_traits::webgl::WebXRCommand; -use canvas_traits::webgl::WebXRLayerManagerId; -use canvas_traits::webgl::YAxisTreatment; +use canvas_traits::webgl::{ + webgl_channel, ActiveAttribInfo, ActiveUniformBlockInfo, ActiveUniformInfo, AlphaTreatment, + GLContextAttributes, GLLimits, GlType, InternalFormatIntVec, ProgramLinkInfo, TexDataType, + TexFormat, WebGLBufferId, WebGLChan, WebGLCommand, WebGLCommandBacktrace, WebGLContextId, + WebGLCreateContextResult, WebGLFramebufferBindingRequest, WebGLFramebufferId, WebGLMsg, + WebGLMsgSender, WebGLProgramId, WebGLQueryId, WebGLReceiver, WebGLRenderbufferId, + WebGLSLVersion, WebGLSamplerId, WebGLSender, WebGLShaderId, WebGLSyncId, WebGLTextureId, + WebGLVersion, WebGLVertexArrayId, WebXRCommand, WebXRLayerManagerId, YAxisTreatment, +}; use euclid::default::Size2D; use fnv::FnvHashMap; use half::f16; use log::{debug, error, trace, warn}; use pixels::{self, PixelFormat}; use sparkle::gl; -use sparkle::gl::GLint; -use sparkle::gl::GLuint; -use sparkle::gl::Gl; -use std::borrow::Cow; -use std::collections::HashMap; -use std::rc::Rc; -use std::slice; -use std::sync::{Arc, Mutex}; -use std::thread; +use sparkle::gl::{GLint, GLuint, Gl}; use surfman::chains::{PreserveBuffer, SwapChains, SwapChainsAPI}; use surfman::{ self, Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device, GLVersion, SurfaceAccess, SurfaceInfo, SurfaceType, }; use webrender::{RenderApi, RenderApiSender, Transaction}; +use webrender_api::units::DeviceIntSize; use webrender_api::{ - units::DeviceIntSize, DirtyRect, DocumentId, ExternalImageData, ExternalImageId, - ExternalImageType, ImageBufferKind, ImageData, ImageDescriptor, ImageDescriptorFlags, - ImageFormat, ImageKey, + DirtyRect, DocumentId, ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind, + ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey, }; use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType}; use webxr::SurfmanGL as WebXRSurfman; -use webxr_api::ContextId as WebXRContextId; -use webxr_api::Error as WebXRError; -use webxr_api::GLContexts as WebXRContexts; -use webxr_api::GLTypes as WebXRTypes; -use webxr_api::LayerGrandManager as WebXRLayerGrandManager; -use webxr_api::LayerGrandManagerAPI as WebXRLayerGrandManagerAPI; -use webxr_api::LayerId as WebXRLayerId; -use webxr_api::LayerInit as WebXRLayerInit; -use webxr_api::LayerManager as WebXRLayerManager; -use webxr_api::LayerManagerAPI as WebXRLayerManagerAPI; -use webxr_api::LayerManagerFactory as WebXRLayerManagerFactory; -use webxr_api::SubImages as WebXRSubImages; +use webxr_api::{ + ContextId as WebXRContextId, Error as WebXRError, GLContexts as WebXRContexts, + GLTypes as WebXRTypes, LayerGrandManager as WebXRLayerGrandManager, + LayerGrandManagerAPI as WebXRLayerGrandManagerAPI, LayerId as WebXRLayerId, + LayerInit as WebXRLayerInit, LayerManager as WebXRLayerManager, + LayerManagerAPI as WebXRLayerManagerAPI, LayerManagerFactory as WebXRLayerManagerFactory, + SubImages as WebXRSubImages, +}; + +use crate::webgl_limits::GLLimitsDetect; #[cfg(feature = "xr-profile")] fn to_ms(ns: u64) -> f64 { diff --git a/components/canvas_traits/canvas.rs b/components/canvas_traits/canvas.rs index 6065b714ce0..ee29d440efb 100644 --- a/components/canvas_traits/canvas.rs +++ b/components/canvas_traits/canvas.rs @@ -2,14 +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::default::Default; +use std::str::FromStr; + use cssparser::RGBA; use euclid::default::{Point2D, Rect, Size2D, Transform2D}; use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMemory}; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use serde_bytes::ByteBuf; -use std::default::Default; -use std::str::FromStr; use style::properties::style_structs::Font as FontStyleStruct; use webrender_api::ImageKey; diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index e7aeef0fb67..e0c4050e7be 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -6,10 +6,11 @@ #![crate_type = "rlib"] #![deny(unsafe_code)] -use crate::canvas::CanvasId; use crossbeam_channel::Sender; use euclid::default::Size2D; +use crate::canvas::CanvasId; + pub mod canvas; #[macro_use] pub mod webgl; diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 914b06e7b9f..2a2e0f0c3b3 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -2,22 +2,22 @@ * 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::borrow::Cow; +use std::fmt; +use std::num::{NonZeroU32, NonZeroU64}; +use std::ops::Deref; + use euclid::default::{Rect, Size2D}; use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory}; use malloc_size_of_derive::MallocSizeOf; use pixels::PixelFormat; use serde::{Deserialize, Serialize}; use sparkle::gl; -use std::borrow::Cow; -use std::fmt; -use std::num::{NonZeroU32, NonZeroU64}; -use std::ops::Deref; use webrender_api::ImageKey; -use webxr_api::ContextId as WebXRContextId; -use webxr_api::Error as WebXRError; -use webxr_api::LayerId as WebXRLayerId; -use webxr_api::LayerInit as WebXRLayerInit; -use webxr_api::SubImages as WebXRSubImages; +use webxr_api::{ + ContextId as WebXRContextId, Error as WebXRError, LayerId as WebXRLayerId, + LayerInit as WebXRLayerInit, SubImages as WebXRSubImages, +}; /// Helper function that creates a WebGL channel (WebGLSender, WebGLReceiver) to be used in WebGLCommands. pub use crate::webgl_channel::webgl_channel; diff --git a/components/canvas_traits/webgl_channel/ipc.rs b/components/canvas_traits/webgl_channel/ipc.rs index 0eb940c440f..be320a69624 100644 --- a/components/canvas_traits/webgl_channel/ipc.rs +++ b/components/canvas_traits/webgl_channel/ipc.rs @@ -2,9 +2,10 @@ * 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 serde::{Deserialize, Serialize}; use std::io; +use serde::{Deserialize, Serialize}; + pub type WebGLSender<T> = ipc_channel::ipc::IpcSender<T>; pub type WebGLReceiver<T> = ipc_channel::ipc::IpcReceiver<T>; diff --git a/components/canvas_traits/webgl_channel/mod.rs b/components/canvas_traits/webgl_channel/mod.rs index 6aa14187699..edfb90c8806 100644 --- a/components/canvas_traits/webgl_channel/mod.rs +++ b/components/canvas_traits/webgl_channel/mod.rs @@ -7,13 +7,15 @@ mod ipc; mod mpsc; -use crate::webgl::WebGLMsg; +use std::fmt; + use ipc_channel::ipc::IpcSender; use ipc_channel::router::ROUTER; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use servo_config::opts; -use std::fmt; + +use crate::webgl::WebGLMsg; lazy_static! { static ref IS_MULTIPROCESS: bool = opts::multiprocess(); diff --git a/components/canvas_traits/webgl_channel/mpsc.rs b/components/canvas_traits/webgl_channel/mpsc.rs index 8e34bda8e9b..b7d0bfcc3da 100644 --- a/components/canvas_traits/webgl_channel/mpsc.rs +++ b/components/canvas_traits/webgl_channel/mpsc.rs @@ -2,8 +2,7 @@ * 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 serde::{Deserialize, Serialize}; -use serde::{Deserializer, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; macro_rules! unreachable_serializable { ($name:ident) => { diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index bf01f6eb606..1ae3d4a4616 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -2,13 +2,13 @@ * 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 = "gl")] -use crate::gl; -use crate::touch::{TouchAction, TouchHandler}; -use crate::windowing::{ - self, EmbedderCoordinates, MouseWindowEvent, WebRenderDebugOption, WindowMethods, -}; -use crate::InitialCompositorState; +use std::collections::HashMap; +use std::env; +use std::fs::{create_dir_all, File}; +use std::io::Write; +use std::num::NonZeroU32; +use std::rc::Rc; + use canvas::canvas_paint_thread::ImageUpdate; use compositing_traits::{ CompositingReason, CompositionPipeline, CompositorMsg, CompositorReceiver, ConstellationMsg, @@ -40,12 +40,6 @@ use script_traits::{ WindowSizeData, WindowSizeType, }; use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength}; -use std::collections::HashMap; -use std::env; -use std::fs::{create_dir_all, File}; -use std::io::Write; -use std::num::NonZeroU32; -use std::rc::Rc; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; use time::{now, precise_time_ns, precise_time_s}; use webrender; @@ -59,6 +53,14 @@ use webrender_api::{ }; use webrender_surfman::WebrenderSurfman; +#[cfg(feature = "gl")] +use crate::gl; +use crate::touch::{TouchAction, TouchHandler}; +use crate::windowing::{ + self, EmbedderCoordinates, MouseWindowEvent, WebRenderDebugOption, WindowMethods, +}; +use crate::InitialCompositorState; + #[derive(Debug, PartialEq)] enum UnableToComposite { NotReadyToPaintImage(NotReadyToPaint), diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 8bf52215c3f..5eb6eeded48 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -4,18 +4,17 @@ #![deny(unsafe_code)] -pub use crate::compositor::IOCompositor; -pub use crate::compositor::ShutdownState; +use std::rc::Rc; use compositing_traits::{CompositorProxy, CompositorReceiver, ConstellationMsg}; use crossbeam_channel::Sender; -use profile_traits::mem; -use profile_traits::time; -use std::rc::Rc; +use profile_traits::{mem, time}; use webrender::RenderApi; use webrender_api::DocumentId; use webrender_surfman::WebrenderSurfman; +pub use crate::compositor::{IOCompositor, ShutdownState}; + mod compositor; #[cfg(feature = "gl")] mod gl; diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index ac8e3690d96..34bb90099e4 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -2,12 +2,13 @@ * 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 self::TouchState::*; use euclid::{Point2D, Scale, Vector2D}; use log::warn; use script_traits::{EventResult, TouchId}; use style_traits::DevicePixel; +use self::TouchState::*; + /// Minimum number of `DeviceIndependentPixel` to begin touch scrolling. const TOUCH_PAN_MIN_SCREEN_PX: f32 = 20.0; diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 1470d6684a6..3aebe8d874c 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -4,6 +4,9 @@ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. +use std::fmt::{Debug, Error, Formatter}; +use std::time::Duration; + use embedder_traits::{EmbedderProxy, EventLoopWaker}; use euclid::Scale; use keyboard_types::KeyboardEvent; @@ -12,10 +15,7 @@ use script_traits::{MediaSessionActionType, MouseButton, TouchEventType, TouchId use servo_geometry::DeviceIndependentPixel; use servo_media::player::context::{GlApi, GlContext, NativeDisplay}; use servo_url::ServoUrl; -use std::fmt::{Debug, Error, Formatter}; -use std::time::Duration; use style_traits::DevicePixel; - use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint}; use webrender_api::ScrollLocation; use webrender_surfman::WebrenderSurfman; diff --git a/components/compositing_traits/constellation_msg.rs b/components/compositing_traits/constellation_msg.rs index baf2c9b1c16..49b7353adfb 100644 --- a/components/compositing_traits/constellation_msg.rs +++ b/components/compositing_traits/constellation_msg.rs @@ -2,24 +2,22 @@ * 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::collections::HashMap; +use std::fmt; +use std::time::Duration; + use embedder_traits::Cursor; use gfx_traits::Epoch; use ipc_channel::ipc::IpcSender; use keyboard_types::KeyboardEvent; -use msg::constellation_msg::PipelineId; -use msg::constellation_msg::TopLevelBrowsingContextId; -use msg::constellation_msg::{BrowsingContextId, TraversalDirection}; -use script_traits::AnimationTickType; -use script_traits::CompositorEvent; -use script_traits::LogEntry; -use script_traits::MediaSessionActionType; -use script_traits::WebDriverCommandMsg; -use script_traits::WindowSizeData; -use script_traits::WindowSizeType; +use msg::constellation_msg::{ + BrowsingContextId, PipelineId, TopLevelBrowsingContextId, TraversalDirection, +}; +use script_traits::{ + AnimationTickType, CompositorEvent, LogEntry, MediaSessionActionType, WebDriverCommandMsg, + WindowSizeData, WindowSizeType, +}; use servo_url::ServoUrl; -use std::collections::HashMap; -use std::fmt; -use std::time::Duration; /// Messages to the constellation. pub enum ConstellationMsg { diff --git a/components/compositing_traits/lib.rs b/components/compositing_traits/lib.rs index cb715337c39..d446a0638d8 100644 --- a/components/compositing_traits/lib.rs +++ b/components/compositing_traits/lib.rs @@ -6,9 +6,10 @@ mod constellation_msg; -pub use constellation_msg::ConstellationMsg; +use std::fmt::{Debug, Error, Formatter}; use canvas::canvas_paint_thread::ImageUpdate; +pub use constellation_msg::ConstellationMsg; use crossbeam_channel::{Receiver, Sender}; use embedder_traits::EventLoopWaker; use euclid::Rect; @@ -21,7 +22,6 @@ use script_traits::{ AnimationState, ConstellationControlMsg, EventResult, LayoutControlMsg, MouseButton, MouseEventType, }; -use std::fmt::{Debug, Error, Formatter}; use style_traits::CSSPixel; use webrender_api::units::{DeviceIntPoint, DeviceIntSize}; use webrender_api::{self, FontInstanceKey, FontKey, ImageKey}; diff --git a/components/config/opts.rs b/components/config/opts.rs index 9d3806d67b5..51aee95c37e 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -5,6 +5,14 @@ //! Configuration options for a single run of the servo application. Created //! from command line arguments. +use std::default::Default; +use std::fs::{self, File}; +use std::io::{self, Read, Write}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{RwLock, RwLockReadGuard}; +use std::{env, process}; + use euclid::Size2D; use getopts::{Matches, Options}; use lazy_static::lazy_static; @@ -12,14 +20,6 @@ use log::error; use serde::{Deserialize, Serialize}; use servo_geometry::DeviceIndependentPixel; use servo_url::ServoUrl; -use std::default::Default; -use std::env; -use std::fs::{self, File}; -use std::io::{self, Read, Write}; -use std::path::{Path, PathBuf}; -use std::process; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{RwLock, RwLockReadGuard}; use url::{self, Url}; use crate::{pref, set_pref}; diff --git a/components/config/pref_util.rs b/components/config/pref_util.rs index a052147e427..08de25cb399 100644 --- a/components/config/pref_util.rs +++ b/components/config/pref_util.rs @@ -2,13 +2,14 @@ * 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 serde::{Deserialize, Serialize}; -use serde_json::Value; use std::collections::HashMap; use std::fmt; use std::str::FromStr; use std::sync::RwLock; +use serde::{Deserialize, Serialize}; +use serde_json::Value; + #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub enum PrefValue { Float(f64), diff --git a/components/config/prefs.rs b/components/config/prefs.rs index 13d8d6753ce..fd6de4dd2fd 100644 --- a/components/config/prefs.rs +++ b/components/config/prefs.rs @@ -2,15 +2,16 @@ * 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::borrow::ToOwned; +use std::collections::HashMap; + use embedder_traits::resources::{self, Resource}; +use gen::Prefs; use lazy_static::lazy_static; use serde_json::{self, Value}; -use std::borrow::ToOwned; -use std::collections::HashMap; use crate::pref_util::Preferences; pub use crate::pref_util::{PrefError, PrefValue}; -use gen::Prefs; lazy_static! { static ref PREFS: Preferences<'static, Prefs> = { diff --git a/components/config/tests/prefs.rs b/components/config/tests/prefs.rs index f19b7e84676..4ff37299a8d 100644 --- a/components/config/tests/prefs.rs +++ b/components/config/tests/prefs.rs @@ -2,14 +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 servo_config::basedir; -use servo_config::pref_util::Preferences; -use servo_config::prefs::{read_prefs_map, PrefValue}; use std::collections::HashMap; use std::error::Error; use std::fs::{self, File}; use std::io::{Read, Write}; +use servo_config::basedir; +use servo_config::pref_util::Preferences; +use servo_config::prefs::{read_prefs_map, PrefValue}; + #[test] fn test_create_prefs_map() { let json_str = "{ diff --git a/components/config_plugins/lib.rs b/components/config_plugins/lib.rs index 658db3bb3ac..608a8a5b0c6 100644 --- a/components/config_plugins/lib.rs +++ b/components/config_plugins/lib.rs @@ -4,14 +4,18 @@ #![feature(proc_macro_diagnostic)] +use std::collections::{hash_map, HashMap}; +use std::fmt::Write; +use std::iter; + use itertools::Itertools; use proc_macro2::{Span, TokenStream}; use quote::*; -use std::collections::{hash_map, HashMap}; -use std::{fmt::Write, iter}; +use syn::parse::Result; +use syn::spanned::Spanned; use syn::{ - parse::Result, parse_macro_input, spanned::Spanned, Attribute, Ident, Lit, LitStr, Meta, - MetaList, MetaNameValue, NestedMeta, Path, + parse_macro_input, Attribute, Ident, Lit, LitStr, Meta, MetaList, MetaNameValue, NestedMeta, + Path, }; mod parse; diff --git a/components/config_plugins/parse.rs b/components/config_plugins/parse.rs index 5d9d9fe1dc4..9fd49490913 100644 --- a/components/config_plugins/parse.rs +++ b/components/config_plugins/parse.rs @@ -4,7 +4,8 @@ use proc_macro2::Span; use syn::parse::{Parse, ParseStream, Result}; -use syn::{braced, punctuated::Punctuated, token, Attribute, Ident, Path, Token, Type}; +use syn::punctuated::Punctuated; +use syn::{braced, token, Attribute, Ident, Path, Token, Type}; #[allow(non_camel_case_types)] mod kw { diff --git a/components/constellation/browsingcontext.rs b/components/constellation/browsingcontext.rs index 71db7487852..c7f43e0d977 100644 --- a/components/constellation/browsingcontext.rs +++ b/components/constellation/browsingcontext.rs @@ -2,15 +2,17 @@ * 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::pipeline::Pipeline; +use std::collections::{HashMap, HashSet}; + use euclid::Size2D; use log::warn; use msg::constellation_msg::{ BrowsingContextGroupId, BrowsingContextId, PipelineId, TopLevelBrowsingContextId, }; -use std::collections::{HashMap, HashSet}; use style_traits::CSSPixel; +use crate::pipeline::Pipeline; + /// Because a browsing context is only constructed once the document that's /// going to be in it becomes active (i.e. not when a pipeline is spawned), some /// values needed in browsing context are not easily available at the point of diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 663549dd2da..2207251de70 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -89,18 +89,15 @@ //! //! See https://github.com/servo/servo/issues/14704 -use crate::browsingcontext::NewBrowsingContextInfo; -use crate::browsingcontext::{ - AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator, -}; -use crate::event_loop::EventLoop; -use crate::network_listener::NetworkListener; -use crate::pipeline::{InitialPipelineState, Pipeline}; -use crate::serviceworker::ServiceWorkerUnprivilegedContent; -use crate::session_history::{ - JointSessionHistory, NeedsToReload, SessionHistoryChange, SessionHistoryDiff, -}; -use crate::timer_scheduler::TimerScheduler; +use std::borrow::{Cow, ToOwned}; +use std::collections::hash_map::Entry; +use std::collections::{HashMap, HashSet, VecDeque}; +use std::marker::PhantomData; +use std::mem::replace; +use std::rc::{Rc, Weak}; +use std::sync::{Arc, Mutex}; +use std::{process, thread}; + use background_hang_monitor::HangMonitorRegister; use bluetooth_traits::BluetoothRequest; use canvas_traits::canvas::{CanvasId, CanvasMsg}; @@ -115,9 +112,11 @@ use devtools_traits::{ ChromeToDevtoolsControlMsg, DevtoolsControlMsg, DevtoolsPageInfo, NavigationState, ScriptToDevtoolsControlMsg, }; -use embedder_traits::{Cursor, EmbedderMsg, EmbedderProxy}; -use embedder_traits::{MediaSessionEvent, MediaSessionPlaybackState}; -use euclid::{default::Size2D as UntypedSize2D, Size2D}; +use embedder_traits::{ + Cursor, EmbedderMsg, EmbedderProxy, MediaSessionEvent, MediaSessionPlaybackState, +}; +use euclid::default::Size2D as UntypedSize2D; +use euclid::Size2D; use gfx::font_cache_thread::FontCacheThread; use gfx_traits::Epoch; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; @@ -129,60 +128,51 @@ use layout_traits::LayoutThreadFactory; use log::{debug, error, info, warn}; use media::{GLPlayerThreads, WindowGLContext}; use msg::constellation_msg::{ - BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, HangMonitorAlert, -}; -use msg::constellation_msg::{ - BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineNamespace, - PipelineNamespaceId, PipelineNamespaceRequest, TraversalDirection, -}; -use msg::constellation_msg::{ - BrowsingContextGroupId, BrowsingContextId, HistoryStateId, PipelineId, - TopLevelBrowsingContextId, + BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, BroadcastChannelRouterId, + BrowsingContextGroupId, BrowsingContextId, HangMonitorAlert, HistoryStateId, MessagePortId, + MessagePortRouterId, PipelineId, PipelineNamespace, PipelineNamespaceId, + PipelineNamespaceRequest, TopLevelBrowsingContextId, TraversalDirection, }; use net_traits::pub_domains::reg_host; use net_traits::request::{Referrer, RequestBuilder}; use net_traits::storage_thread::{StorageThreadMsg, StorageType}; use net_traits::{self, FetchResponseMsg, IpcSend, ResourceThreads}; -use profile_traits::mem; -use profile_traits::time; +use profile_traits::{mem, time}; use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent}; -use script_traits::{webdriver_msg, LogEntry, ScriptToConstellationChan, ServiceWorkerMsg}; use script_traits::{ - AnimationState, AnimationTickType, AuxiliaryBrowsingContextLoadInfo, BroadcastMsg, - CompositorEvent, + webdriver_msg, AnimationState, AnimationTickType, AuxiliaryBrowsingContextLoadInfo, + BroadcastMsg, CompositorEvent, ConstellationControlMsg, DiscardBrowsingContext, + DocumentActivity, DocumentState, HistoryEntryReplacement, IFrameLoadInfo, + IFrameLoadInfoWithData, IFrameSandboxState, IFrameSizeMsg, Job, LayoutControlMsg, + LayoutMsg as FromLayoutMsg, LoadData, LoadOrigin, LogEntry, MediaSessionActionType, + MessagePortMsg, MouseEventType, PortMessageTask, SWManagerMsg, SWManagerSenders, + ScriptMsg as FromScriptMsg, ScriptThreadFactory, ScriptToConstellationChan, + ServiceWorkerManagerFactory, ServiceWorkerMsg, StructuredSerializedData, TimerSchedulerMsg, + UpdatePipelineIdReason, WebDriverCommandMsg, WindowSizeData, WindowSizeType, }; -use script_traits::{ConstellationControlMsg, DiscardBrowsingContext}; -use script_traits::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData, LoadOrigin}; -use script_traits::{HistoryEntryReplacement, IFrameSizeMsg, WindowSizeData, WindowSizeType}; -use script_traits::{ - IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg, -}; -use script_traits::{ - Job, LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory, - ServiceWorkerManagerFactory, -}; -use script_traits::{MediaSessionActionType, MouseEventType}; -use script_traits::{MessagePortMsg, PortMessageTask, StructuredSerializedData}; -use script_traits::{SWManagerMsg, SWManagerSenders, UpdatePipelineIdReason, WebDriverCommandMsg}; use serde::{Deserialize, Serialize}; use servo_config::{opts, pref}; use servo_rand::{random, Rng, ServoRng, SliceRandom}; use servo_url::{Host, ImmutableOrigin, ServoUrl}; -use std::borrow::{Cow, ToOwned}; -use std::collections::hash_map::Entry; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::marker::PhantomData; -use std::mem::replace; -use std::process; -use std::rc::{Rc, Weak}; -use std::sync::{Arc, Mutex}; -use std::thread; use style_traits::CSSPixel; use webgpu::{self, WebGPU, WebGPURequest}; use webrender::{RenderApi, RenderApiSender}; use webrender_api::DocumentId; use webrender_traits::WebrenderExternalImageRegistry; +use crate::browsingcontext::{ + AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator, + NewBrowsingContextInfo, +}; +use crate::event_loop::EventLoop; +use crate::network_listener::NetworkListener; +use crate::pipeline::{InitialPipelineState, Pipeline}; +use crate::serviceworker::ServiceWorkerUnprivilegedContent; +use crate::session_history::{ + JointSessionHistory, NeedsToReload, SessionHistoryChange, SessionHistoryDiff, +}; +use crate::timer_scheduler::TimerScheduler; + type PendingApprovalNavigations = HashMap<PipelineId, (LoadData, HistoryEntryReplacement)>; #[derive(Debug)] diff --git a/components/constellation/event_loop.rs b/components/constellation/event_loop.rs index 1027290cef7..7849cceb9c0 100644 --- a/components/constellation/event_loop.rs +++ b/components/constellation/event_loop.rs @@ -6,11 +6,12 @@ //! view of a script thread. When an `EventLoop` is dropped, an `ExitScriptThread` //! message is sent to the script thread, asking it to shut down. +use std::marker::PhantomData; +use std::rc::Rc; + use ipc_channel::ipc::IpcSender; use ipc_channel::Error; use script_traits::ConstellationControlMsg; -use std::marker::PhantomData; -use std::rc::Rc; /// <https://html.spec.whatwg.org/multipage/#event-loop> pub struct EventLoop { diff --git a/components/constellation/logging.rs b/components/constellation/logging.rs index d47265a62c7..10eed86387d 100644 --- a/components/constellation/logging.rs +++ b/components/constellation/logging.rs @@ -2,6 +2,10 @@ * 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::borrow::ToOwned; +use std::sync::Arc; +use std::thread; + use backtrace::Backtrace; use compositing_traits::ConstellationMsg as FromCompositorMsg; use crossbeam_channel::Sender; @@ -9,9 +13,6 @@ use log::{debug, Level, LevelFilter, Log, Metadata, Record}; use msg::constellation_msg::TopLevelBrowsingContextId; use script_traits::{LogEntry, ScriptMsg as FromScriptMsg, ScriptToConstellationChan}; use servo_remutex::ReentrantMutex; -use std::borrow::ToOwned; -use std::sync::Arc; -use std::thread; /// The constellation uses logging to perform crash reporting. /// The constellation receives all `warn!`, `error!` and `panic!` messages, diff --git a/components/constellation/network_listener.rs b/components/constellation/network_listener.rs index 8e42cc639a2..a153db692de 100644 --- a/components/constellation/network_listener.rs +++ b/components/constellation/network_listener.rs @@ -15,8 +15,10 @@ use msg::constellation_msg::PipelineId; use net::http_loader::{set_default_accept, set_default_accept_language}; use net_traits::request::{Destination, Referrer, RequestBuilder}; use net_traits::response::ResponseInit; -use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg}; -use net_traits::{IpcSend, NetworkError, ResourceThreads}; +use net_traits::{ + CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg, IpcSend, NetworkError, + ResourceThreads, +}; pub struct NetworkListener { res_init: Option<ResponseInit>, diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index adf5ec5ba35..061cf218789 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -2,14 +2,16 @@ * 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::event_loop::EventLoop; -use crate::sandboxing::{spawn_multiprocess, UnprivilegedContent}; +use std::borrow::Cow; +use std::collections::{HashMap, HashSet}; +use std::rc::Rc; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; + use background_hang_monitor::HangMonitorRegister; use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; -use compositing_traits::CompositionPipeline; -use compositing_traits::CompositorMsg; -use compositing_traits::CompositorProxy; +use compositing_traits::{CompositionPipeline, CompositorMsg, CompositorProxy}; use crossbeam_channel::{unbounded, Sender}; use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg}; use embedder_traits::EventLoopWaker; @@ -21,37 +23,30 @@ use layout_traits::LayoutThreadFactory; use log::{debug, error, warn}; use media::WindowGLContext; use metrics::PaintTimeMetrics; -use msg::constellation_msg::TopLevelBrowsingContextId; -use msg::constellation_msg::{ - BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, HangMonitorAlert, -}; -use msg::constellation_msg::{BrowsingContextId, HistoryStateId}; use msg::constellation_msg::{ - PipelineId, PipelineNamespace, PipelineNamespaceId, PipelineNamespaceRequest, + BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, BrowsingContextId, + HangMonitorAlert, HistoryStateId, PipelineId, PipelineNamespace, PipelineNamespaceId, + PipelineNamespaceRequest, TopLevelBrowsingContextId, }; use net::image_cache::ImageCacheImpl; use net_traits::image_cache::ImageCache; use net_traits::ResourceThreads; -use profile_traits::mem as profile_mem; -use profile_traits::time; +use profile_traits::{mem as profile_mem, time}; use script_traits::{ - AnimationState, ConstellationControlMsg, DiscardBrowsingContext, ScriptToConstellationChan, + AnimationState, ConstellationControlMsg, DiscardBrowsingContext, DocumentActivity, + InitialScriptState, LayoutControlMsg, LayoutMsg, LoadData, NewLayoutInfo, SWManagerMsg, + ScriptThreadFactory, ScriptToConstellationChan, TimerSchedulerMsg, WindowSizeData, }; -use script_traits::{DocumentActivity, InitialScriptState}; -use script_traits::{LayoutControlMsg, LayoutMsg, LoadData}; -use script_traits::{NewLayoutInfo, SWManagerMsg}; -use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData}; use serde::{Deserialize, Serialize}; use servo_config::opts::{self, Opts}; -use servo_config::{prefs, prefs::PrefValue}; +use servo_config::prefs; +use servo_config::prefs::PrefValue; use servo_url::ServoUrl; -use std::borrow::Cow; -use std::collections::{HashMap, HashSet}; -use std::rc::Rc; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; use webrender_api::DocumentId; +use crate::event_loop::EventLoop; +use crate::sandboxing::{spawn_multiprocess, UnprivilegedContent}; + /// A `Pipeline` is the constellation's view of a `Document`. Each pipeline has an /// event loop (executed by a script thread) and a layout thread. A script thread /// may be responsible for many pipelines, but a layout thread is only responsible diff --git a/components/constellation/sandboxing.rs b/components/constellation/sandboxing.rs index c12917c6a42..5354d8c8a5d 100644 --- a/components/constellation/sandboxing.rs +++ b/components/constellation/sandboxing.rs @@ -2,8 +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 crate::pipeline::UnprivilegedPipelineContent; -use crate::serviceworker::ServiceWorkerUnprivilegedContent; +use std::collections::HashMap; +#[cfg(not(windows))] +use std::env; +use std::ffi::OsStr; +use std::process; + #[cfg(any( target_os = "macos", all( @@ -19,11 +23,9 @@ use ipc_channel::Error; use serde::{Deserialize, Serialize}; use servo_config::opts::Opts; use servo_config::prefs::PrefValue; -use std::collections::HashMap; -#[cfg(not(windows))] -use std::env; -use std::ffi::OsStr; -use std::process; + +use crate::pipeline::UnprivilegedPipelineContent; +use crate::serviceworker::ServiceWorkerUnprivilegedContent; #[derive(Deserialize, Serialize)] pub enum UnprivilegedContent { @@ -50,9 +52,10 @@ impl UnprivilegedContent { /// Our content process sandbox profile on Mac. As restrictive as possible. #[cfg(target_os = "macos")] pub fn content_process_sandbox_profile() -> Profile { + use std::path::PathBuf; + use embedder_traits::resources; use gaol::platform; - use std::path::PathBuf; let mut operations = vec![ Operation::FileReadAll(PathPattern::Literal(PathBuf::from("/dev/urandom"))), @@ -98,9 +101,10 @@ pub fn content_process_sandbox_profile() -> Profile { not(target_arch = "aarch64") ))] pub fn content_process_sandbox_profile() -> Profile { - use embedder_traits::resources; use std::path::PathBuf; + use embedder_traits::resources; + let mut operations = vec![Operation::FileReadAll(PathPattern::Literal(PathBuf::from( "/dev/urandom", )))]; diff --git a/components/constellation/serviceworker.rs b/components/constellation/serviceworker.rs index f3733cfa238..9db6a8d8281 100644 --- a/components/constellation/serviceworker.rs +++ b/components/constellation/serviceworker.rs @@ -2,14 +2,16 @@ * 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::sandboxing::{spawn_multiprocess, UnprivilegedContent}; +use std::collections::HashMap; + use ipc_channel::Error; use script_traits::{SWManagerSenders, ServiceWorkerManagerFactory}; use serde::{Deserialize, Serialize}; use servo_config::opts::{self, Opts}; use servo_config::prefs::{self, PrefValue}; use servo_url::ImmutableOrigin; -use std::collections::HashMap; + +use crate::sandboxing::{spawn_multiprocess, UnprivilegedContent}; /// Conceptually, this is glue to start an agent-cluster for a service worker agent. /// <https://html.spec.whatwg.org/multipage/#obtain-a-service-worker-agent> diff --git a/components/constellation/session_history.rs b/components/constellation/session_history.rs index 3a3e40fcc9c..9df31bdd15e 100644 --- a/components/constellation/session_history.rs +++ b/components/constellation/session_history.rs @@ -2,7 +2,9 @@ * 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::browsingcontext::NewBrowsingContextInfo; +use std::cmp::PartialEq; +use std::{fmt, mem}; + use euclid::Size2D; use log::debug; use msg::constellation_msg::{ @@ -10,10 +12,10 @@ use msg::constellation_msg::{ }; use script_traits::LoadData; use servo_url::ServoUrl; -use std::cmp::PartialEq; -use std::{fmt, mem}; use style_traits::CSSPixel; +use crate::browsingcontext::NewBrowsingContextInfo; + /// Represents the joint session history /// https://html.spec.whatwg.org/multipage/#joint-session-history #[derive(Debug)] diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs index 4241c3ee41b..f56808b56f1 100644 --- a/components/constellation/timer_scheduler.rs +++ b/components/constellation/timer_scheduler.rs @@ -2,11 +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 script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg}; use std::cmp::{self, Ord}; use std::collections::BinaryHeap; use std::time::{Duration, Instant}; +use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg}; + pub struct TimerScheduler(BinaryHeap<ScheduledEvent>); struct ScheduledEvent { diff --git a/components/deny_public_fields/lib.rs b/components/deny_public_fields/lib.rs index 3f6d8b48cf3..4cf7e51a15a 100644 --- a/components/deny_public_fields/lib.rs +++ b/components/deny_public_fields/lib.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::str::FromStr; + use synstructure::{self, decl_derive}; decl_derive!([DenyPublicFields] => deny_public_fields_derive); diff --git a/components/derive_common/cg.rs b/components/derive_common/cg.rs index 022a589eb58..23165e7b622 100644 --- a/components/derive_common/cg.rs +++ b/components/derive_common/cg.rs @@ -5,11 +5,11 @@ use darling::{FromDeriveInput, FromField, FromVariant}; use proc_macro2::{Span, TokenStream}; use quote::{quote, TokenStreamExt}; -use syn::{self, parse_quote, AngleBracketedGenericArguments, Binding, DeriveInput, Field}; -use syn::{GenericArgument, GenericParam, Ident, Path}; -use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray, TypeGroup}; -use syn::{TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple}; -use syn::{Variant, WherePredicate}; +use syn::{ + self, parse_quote, AngleBracketedGenericArguments, Binding, DeriveInput, Field, + GenericArgument, GenericParam, Ident, Path, PathArguments, PathSegment, QSelf, Type, TypeArray, + TypeGroup, TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple, Variant, WherePredicate, +}; use synstructure::{self, BindStyle, BindingInfo, VariantAst, VariantInfo}; /// Given an input type which has some where clauses already, like: diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index bda4429053f..2f53e87a2ad 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -2,11 +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/. */ -/// General actor system infrastructure. -use crate::StreamId; -use devtools_traits::PreciseTime; -use log::{debug, warn}; -use serde_json::{Map, Value}; use std::any::Any; use std::cell::{Cell, RefCell}; use std::collections::HashMap; @@ -14,6 +9,13 @@ use std::mem::replace; use std::net::TcpStream; use std::sync::{Arc, Mutex}; +use devtools_traits::PreciseTime; +use log::{debug, warn}; +use serde_json::{Map, Value}; + +/// General actor system infrastructure. +use crate::StreamId; + #[derive(PartialEq)] pub enum ActorMessageStatus { Processed, diff --git a/components/devtools/actors/browsing_context.rs b/components/devtools/actors/browsing_context.rs index 3095d442ce1..3b68fd516b3 100644 --- a/components/devtools/actors/browsing_context.rs +++ b/components/devtools/actors/browsing_context.rs @@ -7,6 +7,17 @@ //! Connection point for remote devtools that wish to investigate a particular Browsing Context's contents. //! Supports dynamic attaching and detaching which control notifications of navigation, etc. +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; +use std::net::TcpStream; + +use devtools_traits::DevtoolScriptControlMsg::{self, WantsLiveNotifications}; +use devtools_traits::{DevtoolsPageInfo, NavigationState}; +use ipc_channel::ipc::IpcSender; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::actors::emulation::EmulationActor; use crate::actors::inspector::InspectorActor; @@ -18,16 +29,6 @@ use crate::actors::thread::ThreadActor; use crate::actors::timeline::TimelineActor; use crate::protocol::JsonPacketStream; use crate::StreamId; -use devtools_traits::DevtoolScriptControlMsg::{self, WantsLiveNotifications}; -use devtools_traits::DevtoolsPageInfo; -use devtools_traits::NavigationState; -use ipc_channel::ipc::IpcSender; -use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::cell::{Cell, RefCell}; -use std::collections::HashMap; -use std::net::TcpStream; #[derive(Serialize)] struct BrowsingContextTraits { diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 6700ee66955..16b9512631e 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -7,30 +7,32 @@ //! Mediates interaction between the remote web console and equivalent functionality (object //! inspection, JS evaluation, autocompletion) in Servo. -use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::actors::browsing_context::BrowsingContextActor; -use crate::actors::object::ObjectActor; -use crate::actors::worker::WorkerActor; -use crate::protocol::JsonPacketStream; -use crate::{StreamId, UniqueId}; -use devtools_traits::CachedConsoleMessage; -use devtools_traits::ConsoleMessage; -use devtools_traits::EvaluateJSReply::{ActorValue, BooleanValue, StringValue}; -use devtools_traits::EvaluateJSReply::{NullValue, NumberValue, VoidValue}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::net::TcpStream; + +use devtools_traits::EvaluateJSReply::{ + ActorValue, BooleanValue, NullValue, NumberValue, StringValue, VoidValue, +}; use devtools_traits::{ - CachedConsoleMessageTypes, ConsoleAPI, DevtoolScriptControlMsg, LogLevel, PageError, + CachedConsoleMessage, CachedConsoleMessageTypes, ConsoleAPI, ConsoleMessage, + DevtoolScriptControlMsg, LogLevel, PageError, }; use ipc_channel::ipc::{self, IpcSender}; use log::debug; use msg::constellation_msg::TEST_PIPELINE_ID; use serde::Serialize; use serde_json::{self, Map, Number, Value}; -use std::cell::RefCell; -use std::collections::HashMap; -use std::net::TcpStream; use time::precise_time_ns; use uuid::Uuid; +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::actors::browsing_context::BrowsingContextActor; +use crate::actors::object::ObjectActor; +use crate::actors::worker::WorkerActor; +use crate::protocol::JsonPacketStream; +use crate::{StreamId, UniqueId}; + trait EncodableConsoleMessage { fn encode(&self) -> serde_json::Result<String>; } diff --git a/components/devtools/actors/device.rs b/components/devtools/actors/device.rs index a6defc234b0..9fb0c6a84b9 100644 --- a/components/devtools/actors/device.rs +++ b/components/devtools/actors/device.rs @@ -2,13 +2,14 @@ * 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::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::protocol::JsonPacketStream; -use crate::protocol::{ActorDescription, Method}; -use crate::StreamId; +use std::net::TcpStream; + use serde::Serialize; use serde_json::{Map, Value}; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::protocol::{ActorDescription, JsonPacketStream, Method}; +use crate::StreamId; #[derive(Serialize)] struct GetDescriptionReply { diff --git a/components/devtools/actors/emulation.rs b/components/devtools/actors/emulation.rs index 58f13b16d34..4acfee1048e 100644 --- a/components/devtools/actors/emulation.rs +++ b/components/devtools/actors/emulation.rs @@ -2,10 +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 std::net::TcpStream; + +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; -use serde_json::{Map, Value}; -use std::net::TcpStream; pub struct EmulationActor { pub name: String, diff --git a/components/devtools/actors/framerate.rs b/components/devtools/actors/framerate.rs index e57def1eea9..607222489fa 100644 --- a/components/devtools/actors/framerate.rs +++ b/components/devtools/actors/framerate.rs @@ -2,15 +2,17 @@ * 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::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::actors::timeline::HighResolutionStamp; -use crate::StreamId; +use std::mem; +use std::net::TcpStream; + use devtools_traits::DevtoolScriptControlMsg; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use serde_json::{Map, Value}; -use std::mem; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::actors::timeline::HighResolutionStamp; +use crate::StreamId; pub struct FramerateActor { name: String, diff --git a/components/devtools/actors/inspector.rs b/components/devtools/actors/inspector.rs index 65820fa8c56..f625cc3b998 100644 --- a/components/devtools/actors/inspector.rs +++ b/components/devtools/actors/inspector.rs @@ -5,19 +5,22 @@ //! Liberally derived from the [Firefox JS implementation] //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/inspector.js). -use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::actors::browsing_context::BrowsingContextActor; -use crate::protocol::JsonPacketStream; -use crate::StreamId; -use devtools_traits::DevtoolScriptControlMsg::{GetChildren, GetDocumentElement, GetRootNode}; -use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute}; +use std::cell::RefCell; +use std::net::TcpStream; + +use devtools_traits::DevtoolScriptControlMsg::{ + GetChildren, GetDocumentElement, GetLayout, GetRootNode, ModifyAttribute, +}; use devtools_traits::{ComputedNodeLayout, DevtoolScriptControlMsg, NodeInfo}; use ipc_channel::ipc::{self, IpcSender}; use msg::constellation_msg::PipelineId; use serde::Serialize; use serde_json::{self, Map, Value}; -use std::cell::RefCell; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::actors::browsing_context::BrowsingContextActor; +use crate::protocol::JsonPacketStream; +use crate::StreamId; pub struct InspectorActor { pub name: String, diff --git a/components/devtools/actors/memory.rs b/components/devtools/actors/memory.rs index bcc44da38e7..6bd76ff074d 100644 --- a/components/devtools/actors/memory.rs +++ b/components/devtools/actors/memory.rs @@ -2,11 +2,13 @@ * 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::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::StreamId; +use std::net::TcpStream; + use serde::Serialize; use serde_json::{Map, Value}; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::StreamId; #[derive(Serialize)] pub struct TimelineMemoryReply { diff --git a/components/devtools/actors/network_event.rs b/components/devtools/actors/network_event.rs index ea0ef36ccb2..53c858a680b 100644 --- a/components/devtools/actors/network_event.rs +++ b/components/devtools/actors/network_event.rs @@ -6,18 +6,19 @@ //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). //! Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo. -use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::protocol::JsonPacketStream; -use crate::StreamId; -use devtools_traits::HttpRequest as DevtoolsHttpRequest; -use devtools_traits::HttpResponse as DevtoolsHttpResponse; +use std::net::TcpStream; + +use devtools_traits::{HttpRequest as DevtoolsHttpRequest, HttpResponse as DevtoolsHttpResponse}; use headers::{ContentType, Cookie, HeaderMapExt}; use http::{header, HeaderMap, Method, StatusCode}; use serde::Serialize; use serde_json::{Map, Value}; -use std::net::TcpStream; use time::Tm; +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::protocol::JsonPacketStream; +use crate::StreamId; + struct HttpRequest { url: String, method: Method, diff --git a/components/devtools/actors/object.rs b/components/devtools/actors/object.rs index b10f5e9fd65..4d08cb3c305 100644 --- a/components/devtools/actors/object.rs +++ b/components/devtools/actors/object.rs @@ -2,10 +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 std::net::TcpStream; + +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; -use serde_json::{Map, Value}; -use std::net::TcpStream; pub struct ObjectActor { pub name: String, diff --git a/components/devtools/actors/performance.rs b/components/devtools/actors/performance.rs index 07c04c5f90b..5e8bc2b5738 100644 --- a/components/devtools/actors/performance.rs +++ b/components/devtools/actors/performance.rs @@ -2,12 +2,14 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::protocol::{ActorDescription, JsonPacketStream, Method}; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; pub struct PerformanceActor { name: String, diff --git a/components/devtools/actors/preference.rs b/components/devtools/actors/preference.rs index 49d0b22fb8a..860b476d250 100644 --- a/components/devtools/actors/preference.rs +++ b/components/devtools/actors/preference.rs @@ -2,14 +2,16 @@ * 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::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::protocol::JsonPacketStream; -use crate::StreamId; +use std::net::TcpStream; + use serde::Serialize; use serde_json::{Map, Value}; use servo_config::pref_util::PrefValue; use servo_config::prefs::pref_map; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::protocol::JsonPacketStream; +use crate::StreamId; pub struct PreferenceActor { name: String, diff --git a/components/devtools/actors/process.rs b/components/devtools/actors/process.rs index d89092ca314..115946d7a05 100644 --- a/components/devtools/actors/process.rs +++ b/components/devtools/actors/process.rs @@ -2,12 +2,14 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::protocol::JsonPacketStream; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; #[derive(Serialize)] struct ListWorkersReply { diff --git a/components/devtools/actors/profiler.rs b/components/devtools/actors/profiler.rs index f7d5a338525..7db5f77a284 100644 --- a/components/devtools/actors/profiler.rs +++ b/components/devtools/actors/profiler.rs @@ -2,10 +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 std::net::TcpStream; + +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; -use serde_json::{Map, Value}; -use std::net::TcpStream; pub struct ProfilerActor { name: String, diff --git a/components/devtools/actors/root.rs b/components/devtools/actors/root.rs index c1a65a546aa..384a6022fd8 100644 --- a/components/devtools/actors/root.rs +++ b/components/devtools/actors/root.rs @@ -2,6 +2,11 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + /// Liberally derived from the [Firefox JS implementation] /// (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/root.js). /// Connection point for all new remote devtools interactions, providing lists of know actors @@ -13,9 +18,6 @@ use crate::actors::tab::{TabDescriptorActor, TabDescriptorActorMsg}; use crate::actors::worker::{WorkerActor, WorkerMsg}; use crate::protocol::{ActorDescription, JsonPacketStream}; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; #[derive(Serialize)] struct ActorTraits { diff --git a/components/devtools/actors/stylesheets.rs b/components/devtools/actors/stylesheets.rs index c7937d6f123..fadb16f1f3c 100644 --- a/components/devtools/actors/stylesheets.rs +++ b/components/devtools/actors/stylesheets.rs @@ -2,12 +2,14 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::protocol::JsonPacketStream; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; #[derive(Serialize)] struct GetStyleSheetsReply { diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs index 5b3a09f47ba..6f31b9b79c0 100644 --- a/components/devtools/actors/tab.rs +++ b/components/devtools/actors/tab.rs @@ -2,14 +2,16 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg}; use crate::actors::root::RootActor; use crate::protocol::JsonPacketStream; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; #[derive(Serialize)] pub struct TabDescriptorTraits { diff --git a/components/devtools/actors/thread.rs b/components/devtools/actors/thread.rs index 742c06c0950..353f429ac54 100644 --- a/components/devtools/actors/thread.rs +++ b/components/devtools/actors/thread.rs @@ -2,12 +2,14 @@ * 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::net::TcpStream; + +use serde::Serialize; +use serde_json::{Map, Value}; + use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::protocol::JsonPacketStream; use crate::StreamId; -use serde::Serialize; -use serde_json::{Map, Value}; -use std::net::TcpStream; #[derive(Serialize)] struct ThreadAttached { diff --git a/components/devtools/actors/timeline.rs b/components/devtools/actors/timeline.rs index f200b67c382..9cf9475b141 100644 --- a/components/devtools/actors/timeline.rs +++ b/components/devtools/actors/timeline.rs @@ -2,18 +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 crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::actors::framerate::FramerateActor; -use crate::actors::memory::{MemoryActor, TimelineMemoryReply}; -use crate::protocol::JsonPacketStream; -use crate::StreamId; -use devtools_traits::DevtoolScriptControlMsg; -use devtools_traits::DevtoolScriptControlMsg::{DropTimelineMarkers, SetTimelineMarkers}; -use devtools_traits::{PreciseTime, TimelineMarker, TimelineMarkerType}; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use msg::constellation_msg::PipelineId; -use serde::{Serialize, Serializer}; -use serde_json::{Map, Value}; use std::cell::RefCell; use std::error::Error; use std::net::TcpStream; @@ -21,6 +9,19 @@ use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; +use devtools_traits::DevtoolScriptControlMsg::{DropTimelineMarkers, SetTimelineMarkers}; +use devtools_traits::{DevtoolScriptControlMsg, PreciseTime, TimelineMarker, TimelineMarkerType}; +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use msg::constellation_msg::PipelineId; +use serde::{Serialize, Serializer}; +use serde_json::{Map, Value}; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::actors::framerate::FramerateActor; +use crate::actors::memory::{MemoryActor, TimelineMemoryReply}; +use crate::protocol::JsonPacketStream; +use crate::StreamId; + pub struct TimelineActor { name: String, script_sender: IpcSender<DevtoolScriptControlMsg>, diff --git a/components/devtools/actors/worker.rs b/components/devtools/actors/worker.rs index 4bfa8e76e9b..3daab6d74a1 100644 --- a/components/devtools/actors/worker.rs +++ b/components/devtools/actors/worker.rs @@ -2,9 +2,10 @@ * 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::actor::{Actor, ActorMessageStatus, ActorRegistry}; -use crate::protocol::JsonPacketStream; -use crate::StreamId; +use std::cell::RefCell; +use std::collections::HashMap; +use std::net::TcpStream; + use devtools_traits::DevtoolScriptControlMsg::WantsLiveNotifications; use devtools_traits::{DevtoolScriptControlMsg, WorkerId}; use ipc_channel::ipc::IpcSender; @@ -12,9 +13,10 @@ use msg::constellation_msg::TEST_PIPELINE_ID; use serde::Serialize; use serde_json::{Map, Value}; use servo_url::ServoUrl; -use std::cell::RefCell; -use std::collections::HashMap; -use std::net::TcpStream; + +use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; +use crate::protocol::JsonPacketStream; +use crate::StreamId; #[derive(Clone, Copy)] #[allow(dead_code)] diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 94e0e303028..b75e31b4c45 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -12,6 +12,27 @@ #![allow(non_snake_case)] #![deny(unsafe_code)] +use std::borrow::ToOwned; +use std::collections::hash_map::Entry::{Occupied, Vacant}; +use std::collections::HashMap; +use std::io::Read; +use std::net::{Shutdown, TcpListener, TcpStream}; +use std::sync::{Arc, Mutex}; +use std::thread; + +use crossbeam_channel::{unbounded, Receiver, Sender}; +use devtools_traits::{ + ChromeToDevtoolsControlMsg, ConsoleMessage, DevtoolScriptControlMsg, DevtoolsControlMsg, + DevtoolsPageInfo, LogLevel, NavigationState, NetworkEvent, PageError, + ScriptToDevtoolsControlMsg, WorkerId, +}; +use embedder_traits::{EmbedderMsg, EmbedderProxy, PromptDefinition, PromptOrigin, PromptResult}; +use ipc_channel::ipc::{self, IpcSender}; +use log::{debug, warn}; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use serde::Serialize; +use servo_rand::RngCore; + use crate::actor::{Actor, ActorRegistry}; use crate::actors::browsing_context::BrowsingContextActor; use crate::actors::console::{ConsoleActor, Root}; @@ -25,25 +46,6 @@ use crate::actors::root::RootActor; use crate::actors::thread::ThreadActor; use crate::actors::worker::{WorkerActor, WorkerType}; use crate::protocol::JsonPacketStream; -use crossbeam_channel::{unbounded, Receiver, Sender}; -use devtools_traits::{ChromeToDevtoolsControlMsg, ConsoleMessage, DevtoolsControlMsg}; -use devtools_traits::{ - DevtoolScriptControlMsg, DevtoolsPageInfo, LogLevel, NavigationState, NetworkEvent, -}; -use devtools_traits::{PageError, ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::{EmbedderMsg, EmbedderProxy, PromptDefinition, PromptOrigin, PromptResult}; -use ipc_channel::ipc::{self, IpcSender}; -use log::{debug, warn}; -use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use serde::Serialize; -use servo_rand::RngCore; -use std::borrow::ToOwned; -use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::collections::HashMap; -use std::io::Read; -use std::net::{Shutdown, TcpListener, TcpStream}; -use std::sync::{Arc, Mutex}; -use std::thread; mod actor; /// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/ diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index b2b8ffecec9..2f086746e7a 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -6,13 +6,14 @@ //! [JSON packets] //! (https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets). -use log::debug; -use serde::Serialize; -use serde_json::{self, Value}; use std::error::Error; use std::io::{Read, Write}; use std::net::TcpStream; +use log::debug; +use serde::Serialize; +use serde_json::{self, Value}; + #[derive(Serialize)] pub struct ActorDescription { pub category: &'static str, diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index 1b87f19f293..57e11ad8784 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -11,16 +11,15 @@ #![allow(non_snake_case)] #![deny(unsafe_code)] +use std::net::TcpStream; + use bitflags::bitflags; -use http::HeaderMap; -use http::Method; +use http::{HeaderMap, Method}; use ipc_channel::ipc::IpcSender; use malloc_size_of_derive::MallocSizeOf; use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::net::TcpStream; use time::{self, Duration, Tm}; use uuid::Uuid; diff --git a/components/domobject_derive/lib.rs b/components/domobject_derive/lib.rs index e4d354f1708..f15cc0be971 100644 --- a/components/domobject_derive/lib.rs +++ b/components/domobject_derive/lib.rs @@ -5,8 +5,7 @@ #![recursion_limit = "128"] use proc_macro2; -use quote::quote; -use quote::TokenStreamExt; +use quote::{quote, TokenStreamExt}; use syn::parse_quote; #[proc_macro_derive(DomObject)] diff --git a/components/embedder_traits/lib.rs b/components/embedder_traits/lib.rs index b5154948f48..ecaf57a14bb 100644 --- a/components/embedder_traits/lib.rs +++ b/components/embedder_traits/lib.rs @@ -4,6 +4,8 @@ pub mod resources; +use std::fmt::{Debug, Error, Formatter}; + use crossbeam_channel::{Receiver, Sender}; use ipc_channel::ipc::IpcSender; use keyboard_types::KeyboardEvent; @@ -12,9 +14,7 @@ use msg::constellation_msg::{InputMethodType, PipelineId, TopLevelBrowsingContex use num_derive::FromPrimitive; use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::fmt::{Debug, Error, Formatter}; use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize}; - pub use webxr_api::MainThreadWaker as EventLoopWaker; /// A cursor for the window. This is different from a CSS cursor (see diff --git a/components/embedder_traits/resources.rs b/components/embedder_traits/resources.rs index c51a50d5937..c5b77210d0b 100644 --- a/components/embedder_traits/resources.rs +++ b/components/embedder_traits/resources.rs @@ -2,10 +2,11 @@ * 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 lazy_static::lazy_static; use std::path::PathBuf; use std::sync::{Once, RwLock}; +use lazy_static::lazy_static; + lazy_static! { static ref RES: RwLock<Option<Box<dyn ResourceReaderMethods + Sync + Send>>> = RwLock::new(None); diff --git a/components/geometry/lib.rs b/components/geometry/lib.rs index a594a8613cd..54ccd67d109 100644 --- a/components/geometry/lib.rs +++ b/components/geometry/lib.rs @@ -2,13 +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 std::f32; + use app_units::{Au, MAX_AU, MIN_AU}; -use euclid::{ - default::{Point2D, Rect, Size2D}, - Length, -}; +use euclid::default::{Point2D, Rect, Size2D}; +use euclid::Length; use malloc_size_of_derive::MallocSizeOf; -use std::f32; use webrender_api::units::{FramebufferPixel, LayoutPoint, LayoutRect, LayoutSize}; // Units for use with euclid::length and euclid::scale_factor. diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 3d0bc816fb3..eb5124f408b 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -2,15 +2,14 @@ * 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::font_context::{FontContext, FontSource}; -use crate::font_template::FontTemplateDescriptor; -use crate::platform::font::{FontHandle, FontTable}; -use crate::platform::font_context::FontContextHandle; -pub use crate::platform::font_list::fallback_font_families; -use crate::platform::font_template::FontTemplateData; -use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; -use crate::text::shaping::ShaperMethods; -use crate::text::Shaper; +use std::borrow::ToOwned; +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Arc; +use std::{iter, str}; + use app_units::Au; use bitflags::bitflags; use euclid::default::{Point2D, Rect, Size2D}; @@ -18,20 +17,22 @@ use log::debug; use serde::{Deserialize, Serialize}; use servo_atoms::{atom, Atom}; use smallvec::SmallVec; -use std::borrow::ToOwned; -use std::cell::RefCell; -use std::collections::HashMap; -use std::iter; -use std::rc::Rc; -use std::str; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::Arc; use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight}; use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font::{GenericFontFamily, SingleFontFamily}; use unicode_script::Script; use webrender_api::FontInstanceKey; +use crate::font_context::{FontContext, FontSource}; +use crate::font_template::FontTemplateDescriptor; +use crate::platform::font::{FontHandle, FontTable}; +use crate::platform::font_context::FontContextHandle; +pub use crate::platform::font_list::fallback_font_families; +use crate::platform::font_template::FontTemplateData; +use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; +use crate::text::shaping::ShaperMethods; +use crate::text::Shaper; + #[macro_export] macro_rules! ot_tag { ($t1:expr, $t2:expr, $t3:expr, $t4:expr) => { diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index ad1c5f6026b..0dc80939aef 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -2,15 +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 crate::font::{FontFamilyDescriptor, FontFamilyName, FontSearchScope}; -use crate::font_context::FontSource; -use crate::font_template::{FontTemplate, FontTemplateDescriptor}; -use crate::platform::font_context::FontContextHandle; -use crate::platform::font_list::for_each_available_family; -use crate::platform::font_list::for_each_variation; -use crate::platform::font_list::system_default_family; -use crate::platform::font_list::SANS_SERIF_FONT_FAMILY; -use crate::platform::font_template::FontTemplateData; +use std::borrow::ToOwned; +use std::collections::HashMap; +use std::ops::Deref; +use std::sync::{Arc, Mutex}; +use std::{f32, fmt, mem, thread}; + use app_units::Au; use gfx_traits::{FontData, WebrenderApi}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; @@ -20,15 +17,19 @@ use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg}; use serde::{Deserialize, Serialize}; use servo_atoms::Atom; use servo_url::ServoUrl; -use std::borrow::ToOwned; -use std::collections::HashMap; -use std::ops::Deref; -use std::sync::{Arc, Mutex}; -use std::{f32, fmt, mem, thread}; use style::font_face::{EffectiveSources, Source}; use style::values::computed::font::FamilyName; use webrender_api::{FontInstanceKey, FontKey}; +use crate::font::{FontFamilyDescriptor, FontFamilyName, FontSearchScope}; +use crate::font_context::FontSource; +use crate::font_template::{FontTemplate, FontTemplateDescriptor}; +use crate::platform::font_context::FontContextHandle; +use crate::platform::font_list::{ + for_each_available_family, for_each_variation, system_default_family, SANS_SERIF_FONT_FAMILY, +}; +use crate::platform::font_template::FontTemplateData; + /// A list of font templates that make up a given font family. pub struct FontTemplates { templates: Vec<FontTemplate>, diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 0e6d0ce12e7..d8d43fd508f 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -2,28 +2,30 @@ * 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::font::{ - Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef, -}; -use crate::font_cache_thread::FontTemplateInfo; -use crate::font_template::FontTemplateDescriptor; -use crate::platform::font::FontHandle; -pub use crate::platform::font_context::FontContextHandle; -use app_units::Au; -use fnv::FnvHasher; -use log::debug; -use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -use servo_arc::Arc; use std::cell::RefCell; use std::collections::HashMap; use std::default::Default; use std::hash::{BuildHasherDefault, Hash, Hasher}; use std::rc::Rc; use std::sync::atomic::{AtomicUsize, Ordering}; + +use app_units::Au; +use fnv::FnvHasher; +use log::debug; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; +use servo_arc::Arc; use style::computed_values::font_variant_caps::T as FontVariantCaps; use style::properties::style_structs::Font as FontStyleStruct; use webrender_api::{FontInstanceKey, FontKey}; +use crate::font::{ + Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef, +}; +use crate::font_cache_thread::FontTemplateInfo; +use crate::font_template::FontTemplateDescriptor; +use crate::platform::font::FontHandle; +pub use crate::platform::font_context::FontContextHandle; + static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) /// An epoch for the font context cache. The cache is flushed if the current epoch does not match diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index 25b2e60f117..6de6bb061b3 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -2,20 +2,22 @@ * 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::font::FontHandleMethods; -use crate::platform::font::FontHandle; -use crate::platform::font_context::FontContextHandle; -use crate::platform::font_template::FontTemplateData; -use serde::{Deserialize, Serialize}; -use servo_atoms::Atom; use std::fmt::{Debug, Error, Formatter}; use std::io::Error as IoError; use std::sync::{Arc, Weak}; + +use serde::{Deserialize, Serialize}; +use servo_atoms::Atom; use style::computed_values::font_stretch::T as FontStretch; use style::computed_values::font_style::T as FontStyle; use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font::FontWeight; +use crate::font::FontHandleMethods; +use crate::platform::font::FontHandle; +use crate::platform::font_context::FontContextHandle; +use crate::platform::font_template::FontTemplateData; + /// Describes how to select a font from a given family. This is very basic at the moment and needs /// to be expanded or refactored when we support more of the font styling parameters. /// diff --git a/components/gfx/platform/freetype/android/font_list.rs b/components/gfx/platform/freetype/android/font_list.rs index 9c4570b6cca..8c4b2e38a17 100644 --- a/components/gfx/platform/freetype/android/font_list.rs +++ b/components/gfx/platform/freetype/android/font_list.rs @@ -2,11 +2,13 @@ * 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 super::xml::{Attribute, Node}; -use crate::text::util::is_cjk; use std::path::Path; + use ucd::{Codepoint, UnicodeBlock}; +use super::xml::{Attribute, Node}; +use crate::text::util::is_cjk; + lazy_static! { static ref FONT_LIST: FontList = FontList::new(); } diff --git a/components/gfx/platform/freetype/android/xml.rs b/components/gfx/platform/freetype/android/xml.rs index aa03123006f..42a21a05829 100644 --- a/components/gfx/platform/freetype/android/xml.rs +++ b/components/gfx/platform/freetype/android/xml.rs @@ -2,9 +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 xml::reader::XmlEvent::*; - pub(super) use xml::attribute::OwnedAttribute as Attribute; +use xml::reader::XmlEvent::*; pub(super) enum Node { Element { diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index bbfc94d7e8a..536b223cf2b 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -2,35 +2,36 @@ * 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 super::c_str_to_string; -use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods}; -use crate::font::{FontTableTag, FractionalPixel, GPOS, GSUB, KERN}; -use crate::platform::font_context::FontContextHandle; -use crate::platform::font_template::FontTemplateData; -use crate::text::glyph::GlyphId; -use crate::text::util::fixed_to_float; +use std::ffi::CString; +use std::os::raw::{c_char, c_long}; +use std::sync::Arc; +use std::{mem, ptr}; + use app_units::Au; -use freetype::freetype::FT_Sfnt_Tag; -use freetype::freetype::{FT_Done_Face, FT_New_Face, FT_New_Memory_Face}; -use freetype::freetype::{FT_F26Dot6, FT_Face, FT_FaceRec}; -use freetype::freetype::{FT_Get_Char_Index, FT_Get_Postscript_Name}; -use freetype::freetype::{FT_Get_Kerning, FT_Get_Sfnt_Table, FT_Load_Sfnt_Table}; -use freetype::freetype::{FT_GlyphSlot, FT_Library, FT_Long, FT_ULong}; -use freetype::freetype::{FT_Int32, FT_Kerning_Mode, FT_STYLE_FLAG_ITALIC}; -use freetype::freetype::{FT_Load_Glyph, FT_Set_Char_Size}; -use freetype::freetype::{FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_Vector}; +use freetype::freetype::{ + FT_Done_Face, FT_F26Dot6, FT_Face, FT_FaceRec, FT_Get_Char_Index, FT_Get_Kerning, + FT_Get_Postscript_Name, FT_Get_Sfnt_Table, FT_GlyphSlot, FT_Int32, FT_Kerning_Mode, FT_Library, + FT_Load_Glyph, FT_Load_Sfnt_Table, FT_Long, FT_New_Face, FT_New_Memory_Face, FT_Set_Char_Size, + FT_Sfnt_Tag, FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_ULong, FT_Vector, FT_STYLE_FLAG_ITALIC, +}; use freetype::succeeded; use freetype::tt_os2::TT_OS2; use log::debug; use servo_atoms::Atom; -use std::ffi::CString; -use std::os::raw::{c_char, c_long}; -use std::sync::Arc; -use std::{mem, ptr}; use style::computed_values::font_stretch::T as FontStretch; use style::computed_values::font_weight::T as FontWeight; use style::values::computed::font::FontStyle; +use super::c_str_to_string; +use crate::font::{ + FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, GPOS, GSUB, + KERN, +}; +use crate::platform::font_context::FontContextHandle; +use crate::platform::font_template::FontTemplateData; +use crate::text::glyph::GlyphId; +use crate::text::util::fixed_to_float; + // This constant is not present in the freetype // bindings due to bindgen not handling the way // the macro is defined. diff --git a/components/gfx/platform/freetype/font_context.rs b/components/gfx/platform/freetype/font_context.rs index 4cf491a864b..c5df0598563 100644 --- a/components/gfx/platform/freetype/font_context.rs +++ b/components/gfx/platform/freetype/font_context.rs @@ -2,19 +2,17 @@ * 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 freetype::freetype::FT_Add_Default_Modules; -use freetype::freetype::FT_Done_Library; -use freetype::freetype::FT_Library; -use freetype::freetype::FT_Memory; -use freetype::freetype::FT_MemoryRec_; -use freetype::freetype::FT_New_Library; +use std::os::raw::{c_long, c_void}; +use std::ptr; +use std::rc::Rc; + +use freetype::freetype::{ + FT_Add_Default_Modules, FT_Done_Library, FT_Library, FT_Memory, FT_MemoryRec_, FT_New_Library, +}; use freetype::succeeded; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use servo_allocator::libc_compat::{free, malloc, realloc}; use servo_allocator::usable_size; -use std::os::raw::{c_long, c_void}; -use std::ptr; -use std::rc::Rc; // We pass a |User| struct -- via an opaque |void*| -- to FreeType each time a new instance is // created. FreeType passes it back to the ft_alloc/ft_realloc/ft_free callbacks. We use it to diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs index c0809ece5ed..a5363fc4848 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/gfx/platform/freetype/font_list.rs @@ -2,19 +2,21 @@ * 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 super::c_str_to_string; -use crate::text::util::is_cjk; -use fontconfig_sys::{FcChar8, FcResultMatch, FcSetSystem}; -use fontconfig_sys::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute}; -use fontconfig_sys::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString}; -use fontconfig_sys::{FcFontSetDestroy, FcMatchPattern, FcPatternCreate, FcPatternDestroy}; -use fontconfig_sys::{FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString}; -use fontconfig_sys::{FcObjectSetAdd, FcPatternGetInteger}; -use libc::{c_char, c_int}; -use log::debug; use std::ffi::CString; use std::ptr; +use fontconfig_sys::{ + FcChar8, FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute, FcDefaultSubstitute, + FcFontMatch, FcFontSetDestroy, FcFontSetList, FcMatchPattern, FcNameParse, FcObjectSetAdd, + FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString, FcPatternCreate, FcPatternDestroy, + FcPatternGetInteger, FcPatternGetString, FcResultMatch, FcSetSystem, +}; +use libc::{c_char, c_int}; +use log::debug; + +use super::c_str_to_string; +use crate::text::util::is_cjk; + static FC_FAMILY: &'static [u8] = b"family\0"; static FC_FILE: &'static [u8] = b"file\0"; static FC_INDEX: &'static [u8] = b"index\0"; diff --git a/components/gfx/platform/freetype/font_template.rs b/components/gfx/platform/freetype/font_template.rs index 2524cf9bb69..cb3a1ef3857 100644 --- a/components/gfx/platform/freetype/font_template.rs +++ b/components/gfx/platform/freetype/font_template.rs @@ -2,12 +2,13 @@ * 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 serde::{Deserialize, Serialize}; -use servo_atoms::Atom; use std::fmt; use std::fs::File; use std::io::{Error, Read}; use std::path::PathBuf; + +use serde::{Deserialize, Serialize}; +use servo_atoms::Atom; use webrender_api::NativeFontHandle; /// Platform specific font representation for Linux. diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index ca94c384a78..eaf8c674c87 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -2,13 +2,10 @@ * 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::font::{ - FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, -}; -use crate::font::{GPOS, GSUB, KERN}; -use crate::platform::font_template::FontTemplateData; -use crate::platform::macos::font_context::FontContextHandle; -use crate::text::glyph::GlyphId; +use std::ops::Range; +use std::sync::Arc; +use std::{fmt, ptr}; + /// Implementation of Quartz (CoreGraphics) fonts. use app_units::Au; use byteorder::{BigEndian, ByteOrder}; @@ -18,15 +15,21 @@ use core_foundation::string::UniChar; use core_graphics::font::CGGlyph; use core_graphics::geometry::CGRect; use core_text::font::CTFont; -use core_text::font_descriptor::kCTFontDefaultOrientation; -use core_text::font_descriptor::{SymbolicTraitAccessors, TraitAccessors}; +use core_text::font_descriptor::{ + kCTFontDefaultOrientation, SymbolicTraitAccessors, TraitAccessors, +}; use log::debug; use servo_atoms::Atom; -use std::ops::Range; -use std::sync::Arc; -use std::{fmt, ptr}; use style::values::computed::font::{FontStretch, FontStyle, FontWeight}; +use crate::font::{ + FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, GPOS, GSUB, + KERN, +}; +use crate::platform::font_template::FontTemplateData; +use crate::platform::macos::font_context::FontContextHandle; +use crate::text::glyph::GlyphId; + const KERN_PAIR_LEN: usize = 6; pub struct FontTable { diff --git a/components/gfx/platform/macos/font_list.rs b/components/gfx/platform/macos/font_list.rs index 70d46edd2b0..32b8b93b21f 100644 --- a/components/gfx/platform/macos/font_list.rs +++ b/components/gfx/platform/macos/font_list.rs @@ -2,10 +2,11 @@ * 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::text::util::unicode_plane; use log::debug; use ucd::{Codepoint, UnicodeBlock}; +use crate::text::util::unicode_plane; + pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String), diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index 29310d17d2f..84bea685d48 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -2,6 +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::borrow::ToOwned; +use std::collections::HashMap; +use std::fmt; +use std::fs::{self, File}; +use std::io::{Error as IoError, Read}; +use std::ops::Deref; +use std::path::Path; +use std::sync::{Arc, Mutex, RwLock}; + use app_units::Au; use core_foundation::array::CFArray; use core_foundation::base::{CFType, TCFType}; @@ -10,20 +19,11 @@ use core_foundation::string::CFString; use core_graphics::data_provider::CGDataProvider; use core_graphics::font::CGFont; use core_text::font::CTFont; -use core_text::font_collection; -use core_text::font_descriptor; +use core_text::{font_collection, font_descriptor}; use serde::de::{Error, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use servo_atoms::Atom; use servo_url::ServoUrl; -use std::borrow::ToOwned; -use std::collections::HashMap; -use std::fmt; -use std::fs::{self, File}; -use std::io::{Error as IoError, Read}; -use std::ops::Deref; -use std::path::Path; -use std::sync::{Arc, Mutex, RwLock}; use webrender_api::NativeFontHandle; /// Platform specific font representation for mac. diff --git a/components/gfx/platform/mod.rs b/components/gfx/platform/mod.rs index 5b41d70c9d6..cc4d28ee575 100644 --- a/components/gfx/platform/mod.rs +++ b/components/gfx/platform/mod.rs @@ -4,22 +4,20 @@ #[cfg(any(target_os = "linux", target_os = "android"))] pub use crate::platform::freetype::{font, font_context}; - #[cfg(any(target_os = "linux", target_os = "android"))] pub use crate::platform::freetype::{font_list, font_template}; - -#[cfg(target_os = "windows")] -pub use crate::platform::windows::{font, font_context, font_list, font_template}; - #[cfg(target_os = "macos")] pub use crate::platform::macos::{font, font_context, font_list, font_template}; +#[cfg(target_os = "windows")] +pub use crate::platform::windows::{font, font_context, font_list, font_template}; #[cfg(any(target_os = "linux", target_os = "android"))] mod freetype { - use libc::c_char; use std::ffi::CStr; use std::str; + use libc::c_char; + /// Creates a String from the given null-terminated buffer. /// Panics if the buffer does not contain UTF-8. unsafe fn c_str_to_string(s: *const c_char) -> String { diff --git a/components/gfx/platform/windows/font.rs b/components/gfx/platform/windows/font.rs index 9e371685491..74cfab4ca73 100644 --- a/components/gfx/platform/windows/font.rs +++ b/components/gfx/platform/windows/font.rs @@ -6,20 +6,14 @@ // information for an approach that we'll likely need to take when the // renderer moves to a sandboxed process. -use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods}; -use crate::font::{FontTableTag, FractionalPixel}; -use crate::platform::font_template::FontTemplateData; -use crate::platform::windows::font_context::FontContextHandle; -use crate::platform::windows::font_list::font_from_atom; -use crate::text::glyph::GlyphId; -use app_units::Au; -use dwrote::{Font, FontFace, FontFile}; -use dwrote::{FontStretch, FontStyle}; -use log::debug; -use servo_atoms::Atom; use std::fmt; use std::ops::Deref; use std::sync::Arc; + +use app_units::Au; +use dwrote::{Font, FontFace, FontFile, FontStretch, FontStyle}; +use log::debug; +use servo_atoms::Atom; use style::computed_values::font_stretch::T as StyleFontStretch; use style::computed_values::font_weight::T as StyleFontWeight; use style::values::computed::font::FontStyle as StyleFontStyle; @@ -27,6 +21,14 @@ use style::values::generics::font::FontStyle as GenericFontStyle; use style::values::generics::NonNegative; use style::values::specified::font::FontStretchKeyword; +use crate::font::{ + FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, +}; +use crate::platform::font_template::FontTemplateData; +use crate::platform::windows::font_context::FontContextHandle; +use crate::platform::windows::font_list::font_from_atom; +use crate::text::glyph::GlyphId; + // 1em = 12pt = 16px, assuming 72 points per inch and 96 px per inch fn pt_to_px(pt: f64) -> f64 { pt / 72. * 96. @@ -88,6 +90,7 @@ impl FontInfo { use std::cmp::{max, min}; use std::collections::HashMap; use std::io::Cursor; + use truetype::naming_table::{NameID, NamingTable}; use truetype::{Value, WindowsMetrics}; diff --git a/components/gfx/platform/windows/font_list.rs b/components/gfx/platform/windows/font_list.rs index 9de2073d6b8..bf9c019cf97 100644 --- a/components/gfx/platform/windows/font_list.rs +++ b/components/gfx/platform/windows/font_list.rs @@ -2,15 +2,17 @@ * 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::text::util::unicode_plane; -use dwrote::{Font, FontCollection, FontDescriptor}; -use lazy_static::lazy_static; -use servo_atoms::Atom; use std::collections::HashMap; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; + +use dwrote::{Font, FontCollection, FontDescriptor}; +use lazy_static::lazy_static; +use servo_atoms::Atom; use ucd::{Codepoint, UnicodeBlock}; +use crate::text::util::unicode_plane; + lazy_static! { static ref FONT_ATOM_COUNTER: AtomicUsize = AtomicUsize::new(1); static ref FONT_ATOM_MAP: Mutex<HashMap<Atom, FontDescriptor>> = Mutex::new(HashMap::new()); diff --git a/components/gfx/platform/windows/font_template.rs b/components/gfx/platform/windows/font_template.rs index 96923c77afc..85477d36b36 100644 --- a/components/gfx/platform/windows/font_template.rs +++ b/components/gfx/platform/windows/font_template.rs @@ -2,13 +2,14 @@ * 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::platform::windows::font_list::font_from_atom; +use std::{fmt, io}; + use serde::{Deserialize, Serialize}; use servo_atoms::Atom; -use std::fmt; -use std::io; use webrender_api::NativeFontHandle; +use crate::platform::windows::font_list::font_from_atom; + #[derive(Deserialize, Serialize)] pub struct FontTemplateData { // If you add members here, review the Debug impl below diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index 72dbb7a0bb8..4669b66141b 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -2,6 +2,13 @@ * 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::Cell; +use std::collections::HashMap; +use std::fs::File; +use std::io::prelude::*; +use std::path::PathBuf; +use std::rc::Rc; + use app_units::Au; use gfx::font::{ fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope, @@ -11,18 +18,12 @@ use gfx::font_context::{FontContext, FontContextHandle, FontSource}; use gfx::font_template::FontTemplateDescriptor; use servo_arc::Arc; use servo_atoms::Atom; -use std::cell::Cell; -use std::collections::HashMap; -use std::fs::File; -use std::io::prelude::*; -use std::path::PathBuf; -use std::rc::Rc; use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps; use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font::{ - FamilyName, FontFamily, FontFamilyList, FontFamilyNameSyntax, FontSize, + FamilyName, FontFamily, FontFamilyList, FontFamilyNameSyntax, FontSize, FontStretch, + FontWeight, SingleFontFamily, }; -use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily}; use style::values::generics::font::FontStyle; use webrender_api::{FontInstanceKey, FontKey, IdNamespace}; diff --git a/components/gfx/tests/font_template.rs b/components/gfx/tests/font_template.rs index 2e11f2d1f36..46dbdb88e0d 100644 --- a/components/gfx/tests/font_template.rs +++ b/components/gfx/tests/font_template.rs @@ -6,12 +6,13 @@ #[cfg(not(target_os = "macos"))] #[test] fn test_font_template_descriptor() { - use gfx::font_context::FontContextHandle; - use gfx::font_template::{FontTemplate, FontTemplateDescriptor}; - use servo_atoms::Atom; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; + + use gfx::font_context::FontContextHandle; + use gfx::font_template::{FontTemplate, FontTemplateDescriptor}; + use servo_atoms::Atom; use style::values::computed::font::{FontStretch, FontWeight}; use style::values::computed::Percentage; use style::values::generics::font::FontStyle; diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 373fb48dc86..e136ffe81c7 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -2,16 +2,16 @@ * 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 euclid::default::Point2D; -use log::debug; -use range::{self, EachIndex, Range, RangeIndex}; -use serde::{Deserialize, Serialize}; use std::cmp::{Ordering, PartialOrd}; use std::vec::Vec; use std::{fmt, mem, u16}; +use app_units::Au; +use euclid::default::Point2D; pub use gfx_traits::ByteIndex; +use log::debug; +use range::{self, EachIndex, Range, RangeIndex}; +use serde::{Deserialize, Serialize}; /// GlyphEntry is a port of Gecko's CompressedGlyph scheme for storing glyph data compactly. /// diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 20791a52148..9128c7aab50 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -4,45 +4,33 @@ #![allow(unsafe_code)] -use crate::font::{Font, FontTableMethods, FontTableTag, ShapingFlags, ShapingOptions, KERN}; -use crate::ot_tag; -use crate::platform::font::FontTable; -use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; -use crate::text::shaping::ShaperMethods; -use crate::text::util::{fixed_to_float, float_to_fixed, is_bidi_control}; +use std::os::raw::{c_char, c_int, c_uint, c_void}; +use std::{char, cmp, ptr}; + use app_units::Au; use euclid::default::Point2D; // Eventually we would like the shaper to be pluggable, as many operating systems have their own // shapers. For now, however, HarfBuzz is a hard dependency. use harfbuzz_sys::hb_blob_t; -use harfbuzz_sys::hb_bool_t; -use harfbuzz_sys::hb_buffer_add_utf8; -use harfbuzz_sys::hb_buffer_destroy; -use harfbuzz_sys::hb_buffer_get_glyph_positions; -use harfbuzz_sys::hb_buffer_get_length; -use harfbuzz_sys::hb_face_destroy; -use harfbuzz_sys::hb_feature_t; -use harfbuzz_sys::hb_font_create; -use harfbuzz_sys::hb_font_funcs_create; -use harfbuzz_sys::hb_font_funcs_set_glyph_h_advance_func; -use harfbuzz_sys::hb_font_funcs_set_nominal_glyph_func; -use harfbuzz_sys::hb_font_set_funcs; -use harfbuzz_sys::hb_font_set_ppem; -use harfbuzz_sys::hb_font_set_scale; -use harfbuzz_sys::hb_glyph_info_t; -use harfbuzz_sys::hb_glyph_position_t; -use harfbuzz_sys::{hb_blob_create, hb_face_create_for_tables}; -use harfbuzz_sys::{hb_buffer_create, hb_font_destroy}; -use harfbuzz_sys::{hb_buffer_get_glyph_infos, hb_shape}; -use harfbuzz_sys::{hb_buffer_set_direction, hb_buffer_set_script}; -use harfbuzz_sys::{hb_buffer_t, hb_codepoint_t, hb_font_funcs_t}; -use harfbuzz_sys::{hb_face_t, hb_font_t}; -use harfbuzz_sys::{hb_position_t, hb_tag_t}; -use harfbuzz_sys::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY}; +use harfbuzz_sys::{ + hb_blob_create, hb_bool_t, hb_buffer_add_utf8, hb_buffer_create, hb_buffer_destroy, + hb_buffer_get_glyph_infos, hb_buffer_get_glyph_positions, hb_buffer_get_length, + hb_buffer_set_direction, hb_buffer_set_script, hb_buffer_t, hb_codepoint_t, + hb_face_create_for_tables, hb_face_destroy, hb_face_t, hb_feature_t, hb_font_create, + hb_font_destroy, hb_font_funcs_create, hb_font_funcs_set_glyph_h_advance_func, + hb_font_funcs_set_nominal_glyph_func, hb_font_funcs_t, hb_font_set_funcs, hb_font_set_ppem, + hb_font_set_scale, hb_font_t, hb_glyph_info_t, hb_glyph_position_t, hb_position_t, hb_shape, + hb_tag_t, HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY, +}; use lazy_static::lazy_static; use log::debug; -use std::os::raw::{c_char, c_int, c_uint, c_void}; -use std::{char, cmp, ptr}; + +use crate::font::{Font, FontTableMethods, FontTableTag, ShapingFlags, ShapingOptions, KERN}; +use crate::ot_tag; +use crate::platform::font::FontTable; +use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; +use crate::text::shaping::ShaperMethods; +use crate::text::util::{fixed_to_float, float_to_fixed, is_bidi_control}; const NO_GLYPH: i32 = -1; const LIGA: u32 = ot_tag!('l', 'i', 'g', 'a'); diff --git a/components/gfx/text/shaping/mod.rs b/components/gfx/text/shaping/mod.rs index 538f7b533f1..3862654fe6f 100644 --- a/components/gfx/text/shaping/mod.rs +++ b/components/gfx/text/shaping/mod.rs @@ -7,11 +7,10 @@ //! //! Currently, only harfbuzz bindings are implemented. +pub use self::harfbuzz::Shaper; use crate::font::ShapingOptions; use crate::text::glyph::GlyphStore; -pub use self::harfbuzz::Shaper; - pub mod harfbuzz; pub trait ShaperMethods { diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index f230bbc92a5..4a877c5eb67 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -2,23 +2,24 @@ * 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::font::{Font, FontHandleMethods, FontMetrics, ShapingFlags}; -use crate::font::{RunMetrics, ShapingOptions}; -use crate::platform::font_template::FontTemplateData; -use crate::text::glyph::{ByteIndex, GlyphStore}; -use app_units::Au; -use log::debug; -use range::Range; -use serde::{Deserialize, Serialize}; use std::cell::Cell; use std::cmp::{max, Ordering}; use std::slice::Iter; use std::sync::Arc; + +use app_units::Au; +use log::debug; +use range::Range; +use serde::{Deserialize, Serialize}; use style::str::char_is_whitespace; use unicode_bidi as bidi; use webrender_api::FontInstanceKey; use xi_unicode::LineBreakLeafIter; +use crate::font::{Font, FontHandleMethods, FontMetrics, RunMetrics, ShapingFlags, ShapingOptions}; +use crate::platform::font_template::FontTemplateData; +use crate::text::glyph::{ByteIndex, GlyphStore}; + thread_local! { static INDEX_OF_FIRST_GLYPH_RUN_CACHE: Cell<Option<(*const TextRun, ByteIndex, usize)>> = Cell::new(None) diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 3f27c9280f9..5b7c53d2848 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -8,10 +8,11 @@ pub mod print_tree; +use std::sync::atomic::{AtomicUsize, Ordering}; + use malloc_size_of_derive::MallocSizeOf; use range::{int_range_index, RangeIndex}; use serde::{Deserialize, Serialize}; -use std::sync::atomic::{AtomicUsize, Ordering}; use webrender_api::{Epoch as WebRenderEpoch, FontInstanceKey, FontKey, NativeFontHandle}; /// A newtype struct for denoting the age of messages; prevents race conditions. diff --git a/components/jstraceable_derive/lib.rs b/components/jstraceable_derive/lib.rs index 6fb41604901..68d9f3a7675 100644 --- a/components/jstraceable_derive/lib.rs +++ b/components/jstraceable_derive/lib.rs @@ -3,8 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use syn::parse_quote; -use synstructure::decl_derive; -use synstructure::quote; +use synstructure::{decl_derive, quote}; decl_derive!([JSTraceable, attributes(no_trace, custom_trace)] => /// Implements `JSTraceable` on structs and enums diff --git a/components/layout/block.rs b/components/layout/block.rs index b9614601458..860ee3dca36 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -25,30 +25,10 @@ //! //! http://dev.w3.org/csswg/css-sizing/ -use crate::context::LayoutContext; -use crate::display_list::items::DisplayListSection; -use crate::display_list::{ - BorderPaintingMode, DisplayListBuildState, StackingContextCollectionFlags, - StackingContextCollectionState, -}; -use crate::floats::{ClearType, FloatKind, Floats, PlacementInfo}; -use crate::flow::{ - BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag, GetBaseFlow, -}; -use crate::flow::{ - FlowFlags, FragmentationContext, ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow, -}; -use crate::flow_list::FlowList; -use crate::fragment::{ - CoordinateSystem, Fragment, FragmentBorderBoxIterator, FragmentFlags, Overflow, -}; -use crate::incremental::RelayoutMode; -use crate::model::{ - AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto, -}; -use crate::sequential; -use crate::traversal::PreorderFlowTraversal; -use crate::{layout_debug, layout_debug_scope}; +use std::cmp::{max, min}; +use std::fmt; +use std::sync::Arc; + use app_units::{Au, MAX_AU}; use bitflags::bitflags; use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; @@ -56,9 +36,6 @@ use gfx_traits::print_tree::PrintTree; use log::{debug, trace}; use serde::{Serialize, Serializer}; use servo_geometry::MaxRect; -use std::cmp::{max, min}; -use std::fmt; -use std::sync::Arc; use style::computed_values::box_sizing::T as BoxSizing; use style::computed_values::display::T as Display; use style::computed_values::float::T as Float; @@ -71,6 +48,28 @@ use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; use style::values::computed::{LengthPercentageOrAuto, MaxSize, Size}; +use crate::context::LayoutContext; +use crate::display_list::items::DisplayListSection; +use crate::display_list::{ + BorderPaintingMode, DisplayListBuildState, StackingContextCollectionFlags, + StackingContextCollectionState, +}; +use crate::floats::{ClearType, FloatKind, Floats, PlacementInfo}; +use crate::flow::{ + BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, FlowFlags, ForceNonfloatedFlag, + FragmentationContext, GetBaseFlow, ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow, +}; +use crate::flow_list::FlowList; +use crate::fragment::{ + CoordinateSystem, Fragment, FragmentBorderBoxIterator, FragmentFlags, Overflow, +}; +use crate::incremental::RelayoutMode; +use crate::model::{ + AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto, +}; +use crate::traversal::PreorderFlowTraversal; +use crate::{layout_debug, layout_debug_scope, sequential}; + /// Information specific to floated blocks. #[derive(Clone, Serialize)] pub struct FloatedBlockInfo { diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 5f5caba6fbc..bf1dcd2059f 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -11,32 +11,57 @@ //! maybe it's an absolute or fixed position thing that hasn't found its containing block yet. //! Construction items bubble up the tree from children to parents until they find their homes. +use std::collections::LinkedList; +use std::marker::PhantomData; +use std::mem; +use std::sync::atomic::Ordering; +use std::sync::Arc; + +use html5ever::{local_name, namespace_url, ns}; +use log::debug; +use script_layout_interface::wrapper_traits::{ + PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode, +}; +use script_layout_interface::{LayoutElementType, LayoutNodeType}; +use servo_config::opts; +use servo_url::ServoUrl; +use style::computed_values::caption_side::T as CaptionSide; +use style::computed_values::display::T as Display; +use style::computed_values::empty_cells::T as EmptyCells; +use style::computed_values::float::T as Float; +use style::computed_values::list_style_position::T as ListStylePosition; +use style::computed_values::position::T as Position; +use style::context::SharedStyleContext; +use style::dom::TElement; +use style::logical_geometry::Direction; +use style::properties::ComputedValues; +use style::selector_parser::{PseudoElement, RestyleDamage}; +use style::servo::restyle_damage::ServoRestyleDamage; +use style::values::computed::Image; +use style::values::generics::counters::ContentItem; +use style::LocalName; + use crate::block::BlockFlow; use crate::context::{with_thread_local_font_context, LayoutContext}; use crate::data::{LayoutData, LayoutDataFlags}; use crate::display_list::items::OpaqueNode; use crate::flex::FlexFlow; use crate::floats::FloatKind; -use crate::flow::{AbsoluteDescendants, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils}; -use crate::flow::{FlowFlags, MutableFlowUtils, MutableOwnedFlowUtils}; +use crate::flow::{ + AbsoluteDescendants, Flow, FlowClass, FlowFlags, GetBaseFlow, ImmutableFlowUtils, + MutableFlowUtils, MutableOwnedFlowUtils, +}; use crate::flow_ref::FlowRef; use crate::fragment::{ CanvasFragmentInfo, Fragment, FragmentFlags, GeneratedContentInfo, IframeFragmentInfo, -}; -use crate::fragment::{ ImageFragmentInfo, InlineAbsoluteFragmentInfo, InlineAbsoluteHypotheticalFragmentInfo, -}; -use crate::fragment::{ InlineBlockFragmentInfo, MediaFragmentInfo, SpecificFragmentInfo, SvgFragmentInfo, -}; -use crate::fragment::{ TableColumnFragmentInfo, UnscannedTextFragmentInfo, WhitespaceStrippingResult, }; use crate::inline::{InlineFlow, InlineFragmentNodeFlags, InlineFragmentNodeInfo}; use crate::linked_list::prepend_from; use crate::list_item::{ListItemFlow, ListStyleTypeContent}; use crate::multicol::{MulticolColumnFlow, MulticolFlow}; -use crate::parallel; use crate::table::TableFlow; use crate::table_caption::TableCaptionFlow; use crate::table_cell::TableCellFlow; @@ -47,35 +72,7 @@ use crate::table_wrapper::TableWrapperFlow; use crate::text::TextRunScanner; use crate::traversal::PostorderNodeMutTraversal; use crate::wrapper::{LayoutNodeLayoutData, TextContent, ThreadSafeLayoutNodeHelpers}; -use crate::ServoArc; -use html5ever::{local_name, namespace_url, ns}; -use log::debug; -use script_layout_interface::wrapper_traits::{ - PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{LayoutElementType, LayoutNodeType}; -use servo_config::opts; -use servo_url::ServoUrl; -use std::collections::LinkedList; -use std::marker::PhantomData; -use std::mem; -use std::sync::atomic::Ordering; -use std::sync::Arc; -use style::computed_values::caption_side::T as CaptionSide; -use style::computed_values::display::T as Display; -use style::computed_values::empty_cells::T as EmptyCells; -use style::computed_values::float::T as Float; -use style::computed_values::list_style_position::T as ListStylePosition; -use style::computed_values::position::T as Position; -use style::context::SharedStyleContext; -use style::dom::TElement; -use style::logical_geometry::Direction; -use style::properties::ComputedValues; -use style::selector_parser::{PseudoElement, RestyleDamage}; -use style::servo::restyle_damage::ServoRestyleDamage; -use style::values::computed::Image; -use style::values::generics::counters::ContentItem; -use style::LocalName; +use crate::{parallel, ServoArc}; /// The results of flow construction for a DOM node. #[derive(Clone)] diff --git a/components/layout/context.rs b/components/layout/context.rs index d8d0c8b47a1..4c35f1439ad 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -4,7 +4,12 @@ //! Data needed by the layout thread. -use crate::display_list::items::{OpaqueNode, WebRenderImageInfo}; +use std::cell::{RefCell, RefMut}; +use std::collections::HashMap; +use std::hash::BuildHasherDefault; +use std::sync::{Arc, Mutex}; +use std::thread; + use fnv::FnvHasher; use gfx::font_cache_thread::FontCacheThread; use gfx::font_context::FontContext; @@ -18,13 +23,9 @@ use script_layout_interface::{PendingImage, PendingImageState}; use script_traits::Painter; use servo_atoms::Atom; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::cell::{RefCell, RefMut}; -use std::collections::HashMap; -use std::hash::BuildHasherDefault; -use std::sync::{Arc, Mutex}; -use std::thread; -use style::context::RegisteredSpeculativePainter; -use style::context::SharedStyleContext; +use style::context::{RegisteredSpeculativePainter, SharedStyleContext}; + +use crate::display_list::items::{OpaqueNode, WebRenderImageInfo}; pub type LayoutFontContext = FontContext<FontCacheThread>; diff --git a/components/layout/data.rs b/components/layout/data.rs index 720f168e732..283cea4a724 100644 --- a/components/layout/data.rs +++ b/components/layout/data.rs @@ -2,12 +2,13 @@ * 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::construct::ConstructionResult; use atomic_refcell::AtomicRefCell; use bitflags::bitflags; use script_layout_interface::wrapper_traits::LayoutDataTrait; use script_layout_interface::StyleData; +use crate::construct::ConstructionResult; + pub struct StyleAndLayoutData<'dom> { /// The style data associated with a node. pub style_data: &'dom StyleData, diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 4f37dcf25c3..4c56deabede 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.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 crate::display_list::border; use app_units::Au; use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use style::computed_values::background_attachment::single_value::T as BackgroundAttachment; @@ -13,6 +12,8 @@ use style::values::computed::{BackgroundSize, NonNegativeLengthPercentageOrAuto} use style::values::specified::background::BackgroundRepeatKeyword; use webrender_api::BorderRadius; +use crate::display_list::border; + /// Placment information for both image and gradient backgrounds. #[derive(Clone, Copy, Debug)] pub struct BackgroundPlacement { diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs index 14ca2abe84f..a77c6516155 100644 --- a/components/layout/display_list/border.rs +++ b/components/layout/display_list/border.rs @@ -2,20 +2,22 @@ * 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::display_list::ToLayout; use app_units::Au; use euclid::default::{Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D as UntypedSize2D}; use euclid::{SideOffsets2D, Size2D}; use style::computed_values::border_image_outset::T as BorderImageOutset; use style::properties::style_structs::Border; -use style::values::computed::NumberOrPercentage; -use style::values::computed::{BorderCornerRadius, BorderImageWidth}; -use style::values::computed::{BorderImageSideWidth, NonNegativeLengthOrNumber}; +use style::values::computed::{ + BorderCornerRadius, BorderImageSideWidth, BorderImageWidth, NonNegativeLengthOrNumber, + NumberOrPercentage, +}; use style::values::generics::rect::Rect as StyleRect; use style::values::generics::NonNegative; use webrender_api::units::{LayoutSideOffsets, LayoutSize}; use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, NormalBorder}; +use crate::display_list::ToLayout; + /// Computes a border radius size against the containing size. /// /// Note that percentages in `border-radius` are resolved against the relevant diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index db6b1d92724..6decaf26011 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -8,37 +8,16 @@ //! list building, as the actual painting does not happen here—only deciding *what* we're going to //! paint. -use crate::block::BlockFlow; -use crate::context::LayoutContext; -use crate::display_list::background::{self, get_cyclic}; -use crate::display_list::border; -use crate::display_list::gradient; -use crate::display_list::items::{self, BaseDisplayItem, ClipScrollNode}; -use crate::display_list::items::{ - ClipScrollNodeIndex, ClipScrollNodeType, ClipType, ClippingAndScrolling, -}; -use crate::display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList}; -use crate::display_list::items::{CommonDisplayItem, DisplayListSection}; -use crate::display_list::items::{IframeDisplayItem, OpaqueNode}; -use crate::display_list::items::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem}; -use crate::display_list::items::{StackingContext, StackingContextType, StickyFrameData}; -use crate::display_list::items::{TextOrientation, WebRenderImageInfo}; -use crate::display_list::ToLayout; -use crate::flow::{BaseFlow, Flow, FlowFlags}; -use crate::flow_ref::FlowRef; -use crate::fragment::SpecificFragmentInfo; -use crate::fragment::{CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFragmentInfo}; -use crate::inline::InlineFragmentNodeFlags; -use crate::model::MaybeAuto; -use crate::table_cell::CollapsedBordersForCell; +use std::default::Default; +use std::sync::Arc; +use std::{f32, mem}; + use app_units::{Au, AU_PER_PX}; use bitflags::bitflags; use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg}; use embedder_traits::Cursor; -use euclid::{ - default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D}, - rect, SideOffsets2D, -}; +use euclid::default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D}; +use euclid::{rect, SideOffsets2D}; use fnv::FnvHashMap; use gfx::text::glyph::ByteIndex; use gfx::text::TextRun; @@ -50,10 +29,6 @@ use net_traits::image_cache::UsePlaceholder; use range::Range; use servo_config::opts; use servo_geometry::{self, MaxRect}; -use std::default::Default; -use std::f32; -use std::mem; -use std::sync::Arc; use style::computed_values::border_style::T as BorderStyle; use style::computed_values::overflow_x::T as StyleOverflow; use style::computed_values::pointer_events::T as PointerEvents; @@ -77,6 +52,26 @@ use webrender_api::{ NinePatchBorderSource, NormalBorder, PropertyBinding, ScrollSensitivity, StickyOffsetBounds, }; +use crate::block::BlockFlow; +use crate::context::LayoutContext; +use crate::display_list::background::{self, get_cyclic}; +use crate::display_list::items::{ + self, BaseDisplayItem, ClipScrollNode, ClipScrollNodeIndex, ClipScrollNodeType, ClipType, + ClippingAndScrolling, ClippingRegion, CommonDisplayItem, DisplayItem, DisplayItemMetadata, + DisplayList, DisplayListSection, IframeDisplayItem, OpaqueNode, PopAllTextShadowsDisplayItem, + PushTextShadowDisplayItem, StackingContext, StackingContextType, StickyFrameData, + TextOrientation, WebRenderImageInfo, +}; +use crate::display_list::{border, gradient, ToLayout}; +use crate::flow::{BaseFlow, Flow, FlowFlags}; +use crate::flow_ref::FlowRef; +use crate::fragment::{ + CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFragmentInfo, SpecificFragmentInfo, +}; +use crate::inline::InlineFragmentNodeFlags; +use crate::model::MaybeAuto; +use crate::table_cell::CollapsedBordersForCell; + static THREAD_TINT_COLORS: [ColorF; 8] = [ ColorF { r: 6.0 / 255.0, diff --git a/components/layout/display_list/gradient.rs b/components/layout/display_list/gradient.rs index 4ec54479972..4e732247795 100644 --- a/components/layout/display_list/gradient.rs +++ b/components/layout/display_list/gradient.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 crate::display_list::ToLayout; use app_units::Au; use euclid::default::{Point2D, Size2D, Vector2D}; use style::properties::ComputedValues; @@ -11,6 +10,8 @@ use style::values::computed::{Angle, Color, LengthPercentage, Percentage, Positi use style::values::generics::image::{Circle, ColorStop, Ellipse, GradientItem, ShapeExtent}; use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient}; +use crate::display_list::ToLayout; + /// A helper data structure for gradients. #[derive(Clone, Copy)] struct StopRun { diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 4b892618fb0..58a90447849 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -12,6 +12,10 @@ //! They are therefore not exactly analogous to constructs like Skia pictures, which consist of //! low-level drawing primitives. +use std::cmp::Ordering; +use std::collections::HashMap; +use std::{f32, fmt}; + use embedder_traits::Cursor; use euclid::{SideOffsets2D, Vector2D}; use gfx_traits::print_tree::PrintTree; @@ -21,11 +25,8 @@ use net_traits::image::base::Image; use script_traits::compositor::ScrollTreeNodeId; use serde::Serialize; use servo_geometry::MaxRect; -use std::cmp::Ordering; -use std::collections::HashMap; -use std::f32; -use std::fmt; use style::computed_values::_servo_top_layer::T as InTopLayer; +pub use style::dom::OpaqueNode; use webrender_api as wr; use webrender_api::units::{LayoutPixel, LayoutRect, LayoutTransform}; use webrender_api::{ @@ -34,8 +35,6 @@ use webrender_api::{ PrimitiveFlags, ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle, }; -pub use style::dom::OpaqueNode; - /// The factor that we multiply the blur radius by in order to inflate the boundaries of display /// items that involve a blur. This ensures that the display item boundaries include all the ink. pub static BLUR_INFLATION_FACTOR: i32 = 3; diff --git a/components/layout/display_list/mod.rs b/components/layout/display_list/mod.rs index 0ac0f81e7ee..57fffef5469 100644 --- a/components/layout/display_list/mod.rs +++ b/components/layout/display_list/mod.rs @@ -2,11 +2,10 @@ * 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/. */ -pub use self::builder::BorderPaintingMode; -pub use self::builder::DisplayListBuildState; -pub use self::builder::IndexableText; -pub use self::builder::StackingContextCollectionFlags; -pub use self::builder::StackingContextCollectionState; +pub use self::builder::{ + BorderPaintingMode, DisplayListBuildState, IndexableText, StackingContextCollectionFlags, + StackingContextCollectionState, +}; pub use self::conversions::ToLayout; mod background; diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs index 31fbc4eb3d4..1e584c0c06f 100644 --- a/components/layout/display_list/webrender_helpers.rs +++ b/components/layout/display_list/webrender_helpers.rs @@ -7,8 +7,6 @@ // This might be achieved by sharing types between WR and Servo display lists, or // completely converting layout to directly generate WebRender display lists, for example. -use crate::display_list::items::{BaseDisplayItem, ClipScrollNode, ClipScrollNodeType, ClipType}; -use crate::display_list::items::{DisplayItem, DisplayList, StackingContextType}; use log::trace; use msg::constellation_msg::PipelineId; use script_traits::compositor::{CompositorDisplayListInfo, ScrollTreeNodeId, ScrollableNodeInfo}; @@ -19,6 +17,11 @@ use webrender_api::{ RasterSpace, ReferenceFrameKind, SpaceAndClipInfo, SpatialId, StackingContext, }; +use crate::display_list::items::{ + BaseDisplayItem, ClipScrollNode, ClipScrollNodeType, ClipType, DisplayItem, DisplayList, + StackingContextType, +}; + struct ClipScrollState<'a> { clip_scroll_nodes: &'a mut Vec<ClipScrollNode>, compositor_info: CompositorDisplayListInfo, diff --git a/components/layout/flex.rs b/components/layout/flex.rs index b2517a61cff..a8265e0c2d2 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -4,24 +4,13 @@ //! Layout for elements with a CSS `display` property of `flex`. -use crate::block::{AbsoluteAssignBSizesTraversal, BlockFlow, MarginsMayCollapseFlag}; -use crate::context::LayoutContext; -use crate::display_list::{ - BorderPaintingMode, DisplayListBuildState, StackingContextCollectionState, -}; -use crate::floats::FloatKind; -use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, ImmutableFlowUtils, OpaqueFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::model::{self, AdjoiningMargins, CollapsibleMargins}; -use crate::model::{IntrinsicISizes, MaybeAuto, SizeConstraint}; -use crate::traversal::PreorderFlowTraversal; -use crate::{layout_debug, layout_debug_scope}; +use std::cmp::{max, min}; +use std::ops::Range; + use app_units::{Au, MAX_AU}; use euclid::default::Point2D; use log::debug; use serde::Serialize; -use std::cmp::{max, min}; -use std::ops::Range; use style::computed_values::align_content::T as AlignContent; use style::computed_values::align_self::T as AlignSelf; use style::computed_values::flex_direction::T as FlexDirection; @@ -33,6 +22,20 @@ use style::servo::restyle_damage::ServoRestyleDamage; use style::values::computed::flex::FlexBasis; use style::values::computed::{MaxSize, Size}; +use crate::block::{AbsoluteAssignBSizesTraversal, BlockFlow, MarginsMayCollapseFlag}; +use crate::context::LayoutContext; +use crate::display_list::{ + BorderPaintingMode, DisplayListBuildState, StackingContextCollectionState, +}; +use crate::floats::FloatKind; +use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, ImmutableFlowUtils, OpaqueFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::model::{ + self, AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MaybeAuto, SizeConstraint, +}; +use crate::traversal::PreorderFlowTraversal; +use crate::{layout_debug, layout_debug_scope}; + /// The size of an axis. May be a specified size, a min/max /// constraint, or an unlimited size #[derive(Debug, Serialize)] diff --git a/components/layout/floats.rs b/components/layout/floats.rs index 9e8e698e0b5..8b81b3a320c 100644 --- a/components/layout/floats.rs +++ b/components/layout/floats.rs @@ -2,18 +2,20 @@ * 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::block::FormattingContextType; -use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; -use crate::persistent_list::PersistentList; +use std::cmp::{max, min}; +use std::fmt; + use app_units::{Au, MAX_AU}; use log::debug; use serde::Serialize; -use std::cmp::{max, min}; -use std::fmt; use style::computed_values::float::T as StyleFloat; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::values::computed::Size; +use crate::block::FormattingContextType; +use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; +use crate::persistent_list::PersistentList; + /// The kind of float: left or right. #[derive(Clone, Copy, Debug, Serialize)] pub enum FloatKind { diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 2a2d9a06539..a2e091a9340 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -25,24 +25,11 @@ //! line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and //! similar methods. -use crate::block::{BlockFlow, FormattingContextType}; -use crate::context::LayoutContext; -use crate::display_list::items::ClippingAndScrolling; -use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; -use crate::flex::FlexFlow; -use crate::floats::{Floats, SpeculatedFloatPlacement}; -use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator}; -use crate::flow_ref::{FlowRef, WeakFlowRef}; -use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::inline::InlineFlow; -use crate::model::{CollapsibleMargins, IntrinsicISizes}; -use crate::parallel::FlowParallelInfo; -use crate::table::TableFlow; -use crate::table_cell::TableCellFlow; -use crate::table_colgroup::TableColGroupFlow; -use crate::table_row::TableRowFlow; -use crate::table_rowgroup::TableRowGroupFlow; -use crate::table_wrapper::TableWrapperFlow; +use std::fmt; +use std::slice::IterMut; +use std::sync::atomic::Ordering; +use std::sync::Arc; + use app_units::Au; use bitflags::bitflags; use euclid::default::{Point2D, Rect, Size2D, Vector2D}; @@ -52,10 +39,6 @@ use log::debug; use serde::ser::{SerializeStruct, Serializer}; use serde::Serialize; use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect}; -use std::fmt; -use std::slice::IterMut; -use std::sync::atomic::Ordering; -use std::sync::Arc; use style::computed_values::clear::T as Clear; use style::computed_values::float::T as Float; use style::computed_values::overflow_x::T as StyleOverflow; @@ -68,6 +51,25 @@ use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; use webrender_api::units::LayoutTransform; +use crate::block::{BlockFlow, FormattingContextType}; +use crate::context::LayoutContext; +use crate::display_list::items::ClippingAndScrolling; +use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; +use crate::flex::FlexFlow; +use crate::floats::{Floats, SpeculatedFloatPlacement}; +use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator}; +use crate::flow_ref::{FlowRef, WeakFlowRef}; +use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::inline::InlineFlow; +use crate::model::{CollapsibleMargins, IntrinsicISizes}; +use crate::parallel::FlowParallelInfo; +use crate::table::TableFlow; +use crate::table_cell::TableCellFlow; +use crate::table_colgroup::TableColGroupFlow; +use crate::table_row::TableRowFlow; +use crate::table_rowgroup::TableRowGroupFlow; +use crate::table_wrapper::TableWrapperFlow; + /// This marker trait indicates that a type is a struct with `#[repr(C)]` whose first field /// is of type `BaseFlow` or some type that also implements this trait. /// diff --git a/components/layout/flow_list.rs b/components/layout/flow_list.rs index a27db03920a..36eac0fa666 100644 --- a/components/layout/flow_list.rs +++ b/components/layout/flow_list.rs @@ -2,14 +2,16 @@ * 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::flow::{Flow, FlowClass}; -use crate::flow_ref::FlowRef; -use serde::ser::{Serialize, SerializeSeq, Serializer}; -use serde_json::{to_value, Map, Value}; use std::collections::{linked_list, LinkedList}; use std::ops::Deref; use std::sync::Arc; +use serde::ser::{Serialize, SerializeSeq, Serializer}; +use serde_json::{to_value, Map, Value}; + +use crate::flow::{Flow, FlowClass}; +use crate::flow_ref::FlowRef; + /// This needs to be reworked now that we have dynamically-sized types in Rust. /// Until then, it's just a wrapper around LinkedList. /// diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index f00740aa4ed..2f7ec0f45bb 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -8,10 +8,11 @@ //! be superfluous. This design is largely duplicating logic of Arc<T> and //! Weak<T>; please see comments there for details. -use crate::flow::Flow; use std::ops::Deref; use std::sync::{Arc, Weak}; +use crate::flow::Flow; + #[derive(Clone, Debug)] pub struct FlowRef(Arc<dyn Flow>); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 8df20e18e9d..4890d95910a 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -4,22 +4,12 @@ //! The `Fragment` type, which represents the leaves of the layout tree. -use crate::context::{with_thread_local_font_context, LayoutContext}; -use crate::display_list::items::{ClipScrollNodeIndex, OpaqueNode, BLUR_INFLATION_FACTOR}; -use crate::display_list::ToLayout; -use crate::floats::ClearType; -use crate::flow::{GetBaseFlow, ImmutableFlowUtils}; -use crate::flow_ref::FlowRef; -use crate::inline::{InlineFragmentContext, InlineFragmentNodeFlags, InlineFragmentNodeInfo}; -use crate::inline::{InlineMetrics, LineMetrics}; -#[cfg(debug_assertions)] -use crate::layout_debug; -use crate::model::style_length; -use crate::model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint}; -use crate::text; -use crate::text::TextRunScanner; -use crate::wrapper::ThreadSafeLayoutNodeHelpers; -use crate::ServoArc; +use std::borrow::ToOwned; +use std::cmp::{max, min, Ordering}; +use std::collections::LinkedList; +use std::sync::{Arc, Mutex}; +use std::{f32, fmt}; + use app_units::Au; use bitflags::bitflags; use canvas_traits::canvas::{CanvasId, CanvasMsg}; @@ -41,11 +31,6 @@ use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaDat use serde::ser::{Serialize, SerializeStruct, Serializer}; use servo_url::ServoUrl; use size_of_test::size_of_test; -use std::borrow::ToOwned; -use std::cmp::{max, min, Ordering}; -use std::collections::LinkedList; -use std::sync::{Arc, Mutex}; -use std::{f32, fmt}; use style::computed_values::border_collapse::T as BorderCollapse; use style::computed_values::box_sizing::T as BoxSizing; use style::computed_values::clear::T as Clear; @@ -71,6 +56,25 @@ use style::values::generics::transform; use webrender_api::units::LayoutTransform; use webrender_api::{self, ImageKey}; +use crate::context::{with_thread_local_font_context, LayoutContext}; +use crate::display_list::items::{ClipScrollNodeIndex, OpaqueNode, BLUR_INFLATION_FACTOR}; +use crate::display_list::ToLayout; +use crate::floats::ClearType; +use crate::flow::{GetBaseFlow, ImmutableFlowUtils}; +use crate::flow_ref::FlowRef; +use crate::inline::{ + InlineFragmentContext, InlineFragmentNodeFlags, InlineFragmentNodeInfo, InlineMetrics, + LineMetrics, +}; +#[cfg(debug_assertions)] +use crate::layout_debug; +use crate::model::{ + self, style_length, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint, +}; +use crate::text::TextRunScanner; +use crate::wrapper::ThreadSafeLayoutNodeHelpers; +use crate::{text, ServoArc}; + // From gfxFontConstants.h in Firefox. static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20; static FONT_SUPERSCRIPT_OFFSET_RATIO: f32 = 0.34; diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 4c57e2d77e6..d5c3b47234d 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -8,18 +8,11 @@ //! done in parallel and is therefore a sequential pass that runs on as little of the flow tree //! as possible. -use crate::context::{with_thread_local_font_context, LayoutContext}; -use crate::display_list::items::OpaqueNode; -use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; -use crate::fragment::{ - Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo, -}; -use crate::text::TextRunScanner; -use crate::traversal::InorderFlowTraversal; +use std::collections::{HashMap, LinkedList}; + use lazy_static::lazy_static; use script_layout_interface::wrapper_traits::PseudoElementType; use smallvec::SmallVec; -use std::collections::{HashMap, LinkedList}; use style::computed_values::list_style_type::T as ListStyleType; use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; @@ -27,6 +20,15 @@ use style::servo::restyle_damage::ServoRestyleDamage; use style::values::generics::counters::ContentItem; use style::values::specified::list::{QuotePair, Quotes}; +use crate::context::{with_thread_local_font_context, LayoutContext}; +use crate::display_list::items::OpaqueNode; +use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; +use crate::fragment::{ + Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo, +}; +use crate::text::TextRunScanner; +use crate::traversal::InorderFlowTraversal; + lazy_static! { static ref INITIAL_QUOTES: style::ArcSlice<QuotePair> = style::ArcSlice::from_iter_leaked( vec![ diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 1ffeafc5662..9adc6cfbe9c 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -2,12 +2,13 @@ * 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::flow::{Flow, FlowFlags, GetBaseFlow}; use bitflags::bitflags; use style::computed_values::float::T as Float; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; +use crate::flow::{Flow, FlowFlags, GetBaseFlow}; + /// Used in a flow traversal to indicate whether this re-layout should be incremental or not. #[derive(Clone, Copy, PartialEq)] pub enum RelayoutMode { diff --git a/components/layout/inline.rs b/components/layout/inline.rs index c09e33a7bac..f0d80bdbc82 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -2,24 +2,11 @@ * 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::block::AbsoluteAssignBSizesTraversal; -use crate::context::{LayoutContext, LayoutFontContext}; -use crate::display_list::items::{DisplayListSection, OpaqueNode}; -use crate::display_list::{ - BorderPaintingMode, DisplayListBuildState, StackingContextCollectionState, -}; -use crate::floats::{FloatKind, Floats, PlacementInfo}; -use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag}; -use crate::flow::{EarlyAbsolutePositionInfo, FlowFlags, GetBaseFlow, OpaqueFlow}; -use crate::flow_ref::FlowRef; -use crate::fragment::FragmentFlags; -use crate::fragment::SpecificFragmentInfo; -use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::model::IntrinsicISizesContribution; -use crate::text; -use crate::traversal::PreorderFlowTraversal; -use crate::ServoArc; -use crate::{layout_debug, layout_debug_scope}; +use std::cmp::max; +use std::collections::VecDeque; +use std::sync::Arc; +use std::{fmt, i32, isize, mem}; + use app_units::{Au, MIN_AU}; use bitflags::bitflags; use euclid::default::{Point2D, Rect, Size2D}; @@ -30,10 +17,6 @@ use range::{int_range_index, Range, RangeIndex}; use script_layout_interface::wrapper_traits::PseudoElementType; use serde::Serialize; use servo_geometry::MaxRect; -use std::cmp::max; -use std::collections::VecDeque; -use std::sync::Arc; -use std::{fmt, i32, isize, mem}; use style::computed_values::display::T as Display; use style::computed_values::overflow_x::T as StyleOverflow; use style::computed_values::position::T as Position; @@ -48,6 +31,26 @@ use style::values::generics::box_::VerticalAlignKeyword; use style::values::specified::text::TextOverflowSide; use unicode_bidi as bidi; +use crate::block::AbsoluteAssignBSizesTraversal; +use crate::context::{LayoutContext, LayoutFontContext}; +use crate::display_list::items::{DisplayListSection, OpaqueNode}; +use crate::display_list::{ + BorderPaintingMode, DisplayListBuildState, StackingContextCollectionState, +}; +use crate::floats::{FloatKind, Floats, PlacementInfo}; +use crate::flow::{ + BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, FlowFlags, ForceNonfloatedFlag, + GetBaseFlow, OpaqueFlow, +}; +use crate::flow_ref::FlowRef; +use crate::fragment::{ + CoordinateSystem, Fragment, FragmentBorderBoxIterator, FragmentFlags, Overflow, + SpecificFragmentInfo, +}; +use crate::model::IntrinsicISizesContribution; +use crate::traversal::PreorderFlowTraversal; +use crate::{layout_debug, layout_debug_scope, text, ServoArc}; + /// `Line`s are represented as offsets into the child list, rather than /// as an object that "owns" fragments. Choosing a different set of line /// breaks requires a new list of offsets, and possibly some splitting and diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs index 2753ef84922..00a451b81b5 100644 --- a/components/layout/layout_debug.rs +++ b/components/layout/layout_debug.rs @@ -5,10 +5,6 @@ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to make layout debugging easier. -use crate::flow::GetBaseFlow; -use crate::flow_ref::FlowRef; -use serde::Serialize; -use serde_json::{to_string, to_value, Value}; use std::borrow::ToOwned; use std::cell::RefCell; use std::fs::File; @@ -16,6 +12,12 @@ use std::io::Write; #[cfg(debug_assertions)] use std::sync::atomic::{AtomicUsize, Ordering}; +use serde::Serialize; +use serde_json::{to_string, to_value, Value}; + +use crate::flow::GetBaseFlow; +use crate::flow_ref::FlowRef; + thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None)); #[cfg(debug_assertions)] diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 7e6544e5a8a..3a3e4dc9908 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -40,10 +40,9 @@ pub mod traversal; pub mod wrapper; // For unit tests: -pub use self::data::LayoutData; -pub use crate::fragment::Fragment; -pub use crate::fragment::SpecificFragmentInfo; - // We can't use servo_arc for everything in layout, because the Flow stuff uses // weak references. use servo_arc::Arc as ServoArc; + +pub use self::data::LayoutData; +pub use crate::fragment::{Fragment, SpecificFragmentInfo}; diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index c3e17fdfdc3..e44bdd7406b 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -5,6 +5,14 @@ //! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a //! block and an extra inline fragment for the marker. +use app_units::Au; +use euclid::default::Point2D; +use style::computed_values::list_style_type::T as ListStyleType; +use style::computed_values::position::T as Position; +use style::logical_geometry::LogicalSize; +use style::properties::ComputedValues; +use style::servo::restyle_damage::ServoRestyleDamage; + use crate::block::BlockFlow; use crate::context::{with_thread_local_font_context, LayoutContext}; use crate::display_list::items::DisplayListSection; @@ -13,19 +21,11 @@ use crate::display_list::{ }; use crate::floats::FloatKind; use crate::flow::{Flow, FlowClass, OpaqueFlow}; -use crate::fragment::Overflow; use crate::fragment::{ - CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo, + CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo, Overflow, }; use crate::generated_content; use crate::inline::InlineFlow; -use app_units::Au; -use euclid::default::Point2D; -use style::computed_values::list_style_type::T as ListStyleType; -use style::computed_values::position::T as Position; -use style::logical_geometry::LogicalSize; -use style::properties::ComputedValues; -use style::servo::restyle_damage::ServoRestyleDamage; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for ListItemFlow {} diff --git a/components/layout/model.rs b/components/layout/model.rs index d9719442186..99d1b1b9d3b 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -4,16 +4,17 @@ //! Borders, padding, and margins. -use crate::fragment::Fragment; +use std::cmp::{max, min}; +use std::fmt; + use app_units::Au; use euclid::SideOffsets2D; use serde::Serialize; -use std::cmp::{max, min}; -use std::fmt; use style::logical_geometry::{LogicalMargin, WritingMode}; use style::properties::ComputedValues; -use style::values::computed::MaxSize; -use style::values::computed::{LengthPercentageOrAuto, Size}; +use style::values::computed::{LengthPercentageOrAuto, MaxSize, Size}; + +use crate::fragment::Fragment; /// A collapsible margin. See CSS 2.1 § 8.3.1. #[derive(Clone, Copy, Debug)] diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index e1a0ef92911..85f98795d1a 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -4,20 +4,14 @@ //! CSS Multi-column layout http://dev.w3.org/csswg/css-multicol/ -use crate::block::BlockFlow; -use crate::context::LayoutContext; -use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; -use crate::floats::FloatKind; -use crate::flow::{Flow, FlowClass, FragmentationContext, GetBaseFlow, OpaqueFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::ServoArc; +use std::cmp::{max, min}; +use std::fmt; +use std::sync::Arc; + use app_units::Au; use euclid::default::{Point2D, Vector2D}; use gfx_traits::print_tree::PrintTree; use log::{debug, trace}; -use std::cmp::{max, min}; -use std::fmt; -use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ComputedValues; use style::values::computed::length::{ @@ -25,6 +19,14 @@ use style::values::computed::length::{ }; use style::values::generics::column::ColumnCount; +use crate::block::BlockFlow; +use crate::context::LayoutContext; +use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; +use crate::floats::FloatKind; +use crate::flow::{Flow, FlowClass, FragmentationContext, GetBaseFlow, OpaqueFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::ServoArc; + #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for MulticolFlow {} diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index a5a4a51a5f3..2093992c4d0 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -8,18 +8,20 @@ #![allow(unsafe_code)] +use std::sync::atomic::{AtomicIsize, Ordering}; +use std::{mem, ptr}; + +use profile_traits::time::{self, profile, TimerMetadata}; +use servo_config::opts; +use smallvec::SmallVec; + use crate::block::BlockFlow; use crate::context::LayoutContext; use crate::flow::{Flow, GetBaseFlow}; use crate::flow_ref::FlowRef; -use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes}; -use crate::traversal::{PostorderFlowTraversal, PreorderFlowTraversal}; -use profile_traits::time::{self, profile, TimerMetadata}; -use servo_config::opts; -use smallvec::SmallVec; -use std::mem; -use std::ptr; -use std::sync::atomic::{AtomicIsize, Ordering}; +use crate::traversal::{ + AssignBSizes, AssignISizes, BubbleISizes, PostorderFlowTraversal, PreorderFlowTraversal, +}; /// Traversal chunk size. const CHUNK_SIZE: usize = 16; diff --git a/components/layout/query.rs b/components/layout/query.rs index d54003971f5..a4eba68b947 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -4,35 +4,26 @@ //! Utilities for querying the layout, as needed by the layout thread. -use crate::construct::ConstructionResult; -use crate::context::LayoutContext; -use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap}; -use crate::display_list::IndexableText; -use crate::flow::{Flow, GetBaseFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, FragmentFlags, SpecificFragmentInfo}; -use crate::inline::InlineFragmentNodeFlags; -use crate::sequential; -use crate::wrapper::LayoutNodeLayoutData; +use std::cmp::{max, min}; +use std::ops::Deref; +use std::sync::{Arc, Mutex}; + use app_units::Au; use euclid::default::{Box2D, Point2D, Rect, Size2D, Vector2D}; use euclid::Size2D as TypedSize2D; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; -use script_layout_interface::rpc::TextIndexResponse; -use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; -use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse}; -use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse}; +use script_layout_interface::rpc::{ + ContentBoxResponse, ContentBoxesResponse, LayoutRPC, NodeGeometryResponse, + NodeScrollIdResponse, OffsetParentResponse, ResolvedStyleResponse, TextIndexResponse, +}; use script_layout_interface::wrapper_traits::{ LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, }; use script_layout_interface::{LayoutElementType, LayoutNodeType}; -use script_traits::LayoutMsg as ConstellationMsg; -use script_traits::UntrustedNodeAddress; +use script_traits::{LayoutMsg as ConstellationMsg, UntrustedNodeAddress}; use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; -use std::cmp::{max, min}; -use std::ops::Deref; -use std::sync::{Arc, Mutex}; use style::computed_values::display::T as Display; use style::computed_values::position::T as Position; use style::computed_values::visibility::T as Visibility; @@ -50,6 +41,16 @@ use style::stylesheets::{CssRuleType, Origin}; use style_traits::{CSSPixel, ParsingMode, ToCss}; use webrender_api::ExternalScrollId; +use crate::construct::ConstructionResult; +use crate::context::LayoutContext; +use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap}; +use crate::display_list::IndexableText; +use crate::flow::{Flow, GetBaseFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, FragmentFlags, SpecificFragmentInfo}; +use crate::inline::InlineFragmentNodeFlags; +use crate::sequential; +use crate::wrapper::LayoutNodeLayoutData; + /// Mutable data belonging to the LayoutThread. /// /// This needs to be protected by a mutex so we can do fast RPCs. diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index d8b4f19b430..44067b4a791 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -4,6 +4,13 @@ //! Implements sequential traversals over the DOM and flow trees. +use app_units::Au; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; +use servo_config::opts; +use style::servo::restyle_damage::ServoRestyleDamage; +use webrender_api::units::LayoutPoint; +use webrender_api::{ColorF, PropertyBinding, RectangleDisplayItem}; + use crate::context::LayoutContext; use crate::display_list::conversions::ToLayout; use crate::display_list::items::{self, CommonDisplayItem, DisplayItem, DisplayListSection}; @@ -13,14 +20,10 @@ use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; use crate::fragment::{CoordinateSystem, FragmentBorderBoxIterator}; use crate::generated_content::ResolveGeneratedContent; use crate::incremental::RelayoutMode; -use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList}; -use crate::traversal::{InorderFlowTraversal, PostorderFlowTraversal, PreorderFlowTraversal}; -use app_units::Au; -use euclid::default::{Point2D, Rect, Size2D, Vector2D}; -use servo_config::opts; -use style::servo::restyle_damage::ServoRestyleDamage; -use webrender_api::units::LayoutPoint; -use webrender_api::{ColorF, PropertyBinding, RectangleDisplayItem}; +use crate::traversal::{ + AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList, InorderFlowTraversal, + PostorderFlowTraversal, PreorderFlowTraversal, +}; pub fn resolve_generated_content(root: &mut dyn Flow, layout_context: &LayoutContext) { ResolveGeneratedContent::new(&layout_context).traverse(root, 0); diff --git a/components/layout/table.rs b/components/layout/table.rs index b067b5ffdc4..9be1cda28f0 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -4,8 +4,26 @@ //! CSS table formatting contexts. -use crate::block::{BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer}; -use crate::block::{ISizeConstraintInput, ISizeConstraintSolution}; +use std::{cmp, fmt}; + +use app_units::Au; +use euclid::default::Point2D; +use gfx_traits::print_tree::PrintTree; +use log::{debug, trace}; +use serde::Serialize; +use style::computed_values::{border_collapse, border_spacing, table_layout}; +use style::context::SharedStyleContext; +use style::logical_geometry::LogicalSize; +use style::properties::style_structs::Background; +use style::properties::ComputedValues; +use style::servo::restyle_damage::ServoRestyleDamage; +use style::values::computed::Size; +use style::values::CSSFloat; + +use crate::block::{ + BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer, ISizeConstraintInput, + ISizeConstraintSolution, +}; use crate::context::LayoutContext; use crate::display_list::{ BorderPaintingMode, DisplayListBuildState, StackingContextCollectionFlags, @@ -19,24 +37,12 @@ use crate::flow_list::{FlowListIterator, MutFlowListIterator}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto}; use crate::table_cell::TableCellFlow; -use crate::table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance}; -use crate::table_row::{TableRowFlow, TableRowSizeData}; +use crate::table_row::{ + self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance, TableRowFlow, + TableRowSizeData, +}; use crate::table_wrapper::TableLayout; use crate::{layout_debug, layout_debug_scope}; -use app_units::Au; -use euclid::default::Point2D; -use gfx_traits::print_tree::PrintTree; -use log::{debug, trace}; -use serde::Serialize; -use std::{cmp, fmt}; -use style::computed_values::{border_collapse, border_spacing, table_layout}; -use style::context::SharedStyleContext; -use style::logical_geometry::LogicalSize; -use style::properties::style_structs::Background; -use style::properties::ComputedValues; -use style::servo::restyle_damage::ServoRestyleDamage; -use style::values::computed::Size; -use style::values::CSSFloat; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableFlow {} diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index b538e9758cb..398a43a7dbf 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -4,6 +4,15 @@ //! CSS table formatting contexts. +use std::fmt; + +use app_units::Au; +use euclid::default::Point2D; +use gfx_traits::print_tree::PrintTree; +use log::{debug, trace}; +use style::logical_geometry::LogicalSize; +use style::properties::ComputedValues; + use crate::block::BlockFlow; use crate::context::LayoutContext; use crate::display_list::{ @@ -11,13 +20,6 @@ use crate::display_list::{ }; use crate::flow::{Flow, FlowClass, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use app_units::Au; -use euclid::default::Point2D; -use gfx_traits::print_tree::PrintTree; -use log::{debug, trace}; -use std::fmt; -use style::logical_geometry::LogicalSize; -use style::properties::ComputedValues; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableCaptionFlow {} diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 2ed26c43108..3c7f236c8d5 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -4,23 +4,14 @@ //! CSS table formatting contexts. -use crate::block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag}; -use crate::context::LayoutContext; -use crate::display_list::{ - DisplayListBuildState, StackingContextCollectionFlags, StackingContextCollectionState, -}; -use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::table::InternalTable; -use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance}; -use crate::{layout_debug, layout_debug_scope}; +use std::fmt; + use app_units::Au; use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use gfx_traits::print_tree::PrintTree; use log::{debug, trace}; use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use serde::Serialize; -use std::fmt; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::ComputedValues; use style::values::computed::length::Size; @@ -28,6 +19,17 @@ use style::values::computed::Color; use style::values::generics::box_::{VerticalAlign, VerticalAlignKeyword}; use style::values::specified::BorderStyle; +use crate::block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag}; +use crate::context::LayoutContext; +use crate::display_list::{ + DisplayListBuildState, StackingContextCollectionFlags, StackingContextCollectionState, +}; +use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::table::InternalTable; +use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance}; +use crate::{layout_debug, layout_debug_scope}; + #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableCellFlow {} diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 8d66188e8dc..bf9f189602f 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -4,18 +4,20 @@ //! CSS table formatting contexts. -use crate::context::LayoutContext; -use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; -use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::{layout_debug, layout_debug_scope}; +use std::fmt; + use app_units::Au; use euclid::default::Point2D; -use std::fmt; use style::logical_geometry::LogicalSize; use style::properties::ComputedValues; use style::values::computed::Size; +use crate::context::LayoutContext; +use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; +use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::{layout_debug, layout_debug_scope}; + #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableColGroupFlow {} diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 2a9f140b630..0ccd82c0504 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -4,6 +4,22 @@ //! CSS table formatting contexts. +use std::cmp::max; +use std::fmt; +use std::iter::{Enumerate, IntoIterator, Peekable}; + +use app_units::Au; +use euclid::default::Point2D; +use gfx_traits::print_tree::PrintTree; +use log::{debug, warn}; +use serde::{Serialize, Serializer}; +use style::computed_values::border_collapse::T as BorderCollapse; +use style::computed_values::border_spacing::T as BorderSpacing; +use style::computed_values::border_top_style::T as BorderStyle; +use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; +use style::properties::ComputedValues; +use style::values::computed::{Color, Size}; + use crate::block::{BlockFlow, ISizeAndMarginsComputer}; use crate::context::LayoutContext; use crate::display_list::{ @@ -17,20 +33,6 @@ use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use crate::table_cell::{CollapsedBordersForCell, TableCellFlow}; use crate::{layout_debug, layout_debug_scope}; -use app_units::Au; -use euclid::default::Point2D; -use gfx_traits::print_tree::PrintTree; -use log::{debug, warn}; -use serde::{Serialize, Serializer}; -use std::cmp::max; -use std::fmt; -use std::iter::{Enumerate, IntoIterator, Peekable}; -use style::computed_values::border_collapse::T as BorderCollapse; -use style::computed_values::border_spacing::T as BorderSpacing; -use style::computed_values::border_top_style::T as BorderStyle; -use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; -use style::properties::ComputedValues; -use style::values::computed::{Color, Size}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableRowFlow {} diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 08177322441..dfe664a925a 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -4,6 +4,18 @@ //! CSS table formatting contexts. +use std::fmt; +use std::iter::{IntoIterator, Iterator, Peekable}; + +use app_units::Au; +use euclid::default::Point2D; +use gfx_traits::print_tree::PrintTree; +use log::{debug, trace}; +use serde::{Serialize, Serializer}; +use style::computed_values::{border_collapse, border_spacing}; +use style::logical_geometry::LogicalSize; +use style::properties::ComputedValues; + use crate::block::{BlockFlow, ISizeAndMarginsComputer}; use crate::context::LayoutContext; use crate::display_list::{ @@ -13,16 +25,6 @@ use crate::flow::{Flow, FlowClass, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; use crate::{layout_debug, layout_debug_scope}; -use app_units::Au; -use euclid::default::Point2D; -use gfx_traits::print_tree::PrintTree; -use log::{debug, trace}; -use serde::{Serialize, Serializer}; -use std::fmt; -use std::iter::{IntoIterator, Iterator, Peekable}; -use style::computed_values::{border_collapse, border_spacing}; -use style::logical_geometry::LogicalSize; -use style::properties::ComputedValues; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableRowGroupFlow {} diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 07d4375c678..eecca81b35e 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -11,26 +11,15 @@ //! //! Hereafter this document is referred to as INTRINSIC. -use crate::block::{ - AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput, -}; -use crate::block::{ISizeConstraintSolution, MarginsMayCollapseFlag}; -use crate::context::LayoutContext; -use crate::display_list::StackingContextCollectionState; -use crate::display_list::{DisplayListBuildState, StackingContextCollectionFlags}; -use crate::floats::FloatKind; -use crate::flow::{Flow, FlowClass, FlowFlags, ImmutableFlowUtils, OpaqueFlow}; -use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::model::MaybeAuto; -use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; +use std::cmp::{max, min}; +use std::fmt; +use std::ops::Add; + use app_units::Au; use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use log::{debug, trace}; use serde::Serialize; -use std::cmp::{max, min}; -use std::fmt; -use std::ops::Add; use style::computed_values::{position, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize}; @@ -38,6 +27,20 @@ use style::properties::ComputedValues; use style::values::computed::Size; use style::values::CSSFloat; +use crate::block::{ + AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, + ISizeConstraintInput, ISizeConstraintSolution, MarginsMayCollapseFlag, +}; +use crate::context::LayoutContext; +use crate::display_list::{ + DisplayListBuildState, StackingContextCollectionFlags, StackingContextCollectionState, +}; +use crate::floats::FloatKind; +use crate::flow::{Flow, FlowClass, FlowFlags, ImmutableFlowUtils, OpaqueFlow}; +use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; +use crate::model::MaybeAuto; +use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; + #[derive(Clone, Copy, Debug, Serialize)] pub enum TableLayout { Fixed, diff --git a/components/layout/text.rs b/components/layout/text.rs index 77b52927e6a..4adbe7bbf63 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -4,11 +4,11 @@ //! Text layout. -use crate::context::LayoutFontContext; -use crate::fragment::{Fragment, ScannedTextFlags}; -use crate::fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo}; -use crate::inline::{InlineFragmentNodeFlags, InlineFragments}; -use crate::linked_list::split_off_head; +use std::borrow::ToOwned; +use std::collections::LinkedList; +use std::mem; +use std::sync::Arc; + use app_units::Au; use gfx::font::{self, FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions}; use gfx::text::glyph::ByteIndex; @@ -17,10 +17,6 @@ use gfx::text::util::{self, CompressionMode}; use log::debug; use range::Range; use servo_atoms::Atom; -use std::borrow::ToOwned; -use std::collections::LinkedList; -use std::mem; -use std::sync::Arc; use style::computed_values::text_rendering::T as TextRendering; use style::computed_values::white_space::T as WhiteSpace; use style::computed_values::word_break::T as WordBreak; @@ -33,6 +29,14 @@ use unicode_bidi as bidi; use unicode_script::Script; use xi_unicode::LineBreakLeafIter; +use crate::context::LayoutFontContext; +use crate::fragment::{ + Fragment, ScannedTextFlags, ScannedTextFragmentInfo, SpecificFragmentInfo, + UnscannedTextFragmentInfo, +}; +use crate::inline::{InlineFragmentNodeFlags, InlineFragments}; +use crate::linked_list::split_off_head; + /// Returns the concatenated text of a list of unscanned text fragments. fn text(fragments: &LinkedList<Fragment>) -> String { // FIXME: Some of this work is later duplicated in split_first_fragment_at_newline_if_necessary diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index cf5b4828a5f..a9527f01a67 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -4,12 +4,6 @@ //! Traversals over the DOM and flow trees, running the layout computations. -use crate::construct::FlowConstructor; -use crate::context::LayoutContext; -use crate::display_list::DisplayListBuildState; -use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; -use crate::wrapper::ThreadSafeLayoutNodeHelpers; -use crate::wrapper::{GetStyleAndLayoutData, LayoutNodeLayoutData}; use log::debug; use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use servo_config::opts; @@ -18,8 +12,13 @@ use style::data::ElementData; use style::dom::{NodeInfo, TElement, TNode}; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; -use style::traversal::PerLevelTraversalData; -use style::traversal::{recalc_style_at, DomTraversal}; +use style::traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData}; + +use crate::construct::FlowConstructor; +use crate::context::LayoutContext; +use crate::display_list::DisplayListBuildState; +use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils}; +use crate::wrapper::{GetStyleAndLayoutData, LayoutNodeLayoutData, ThreadSafeLayoutNodeHelpers}; pub struct RecalcStyleAndConstructFlows<'a> { context: LayoutContext<'a>, diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 41e054bbe83..02f345d2661 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -30,15 +30,17 @@ #![allow(unsafe_code)] -use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData}; use atomic_refcell::{AtomicRef, AtomicRefMut}; -use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData; -use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use script_layout_interface::wrapper_traits::{ + GetStyleAndOpaqueLayoutData, ThreadSafeLayoutElement, ThreadSafeLayoutNode, +}; use style::dom::{NodeInfo, TElement, TNode}; use style::selector_parser::RestyleDamage; use style::values::computed::counters::ContentItem; use style::values::generics::counters::Content; +use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData}; + pub trait LayoutNodeLayoutData<'dom> { fn borrow_layout_data(self) -> Option<AtomicRef<'dom, LayoutData>>; fn mutate_layout_data(self) -> Option<AtomicRefMut<'dom, LayoutData>>; diff --git a/components/layout_2020/cell.rs b/components/layout_2020/cell.rs index 8aae377b24c..5c1dd09ff44 100644 --- a/components/layout_2020/cell.rs +++ b/components/layout_2020/cell.rs @@ -2,11 +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 std::fmt; +use std::ops::Deref; + use atomic_refcell::AtomicRefCell; use serde::{Serialize, Serializer}; use servo_arc::Arc; -use std::fmt; -use std::ops::Deref; pub(crate) struct ArcRefCell<T> { value: Arc<AtomicRefCell<T>>, diff --git a/components/layout_2020/context.rs b/components/layout_2020/context.rs index 64e51bc3854..19c35fedbf4 100644 --- a/components/layout_2020/context.rs +++ b/components/layout_2020/context.rs @@ -2,7 +2,9 @@ * 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::display_list::WebRenderImageInfo; +use std::cell::RefCell; +use std::sync::{Arc, Mutex}; + use fnv::FnvHashMap; use gfx::font_cache_thread::FontCacheThread; use gfx::font_context::FontContext; @@ -13,11 +15,11 @@ use net_traits::image_cache::{ use parking_lot::RwLock; use script_layout_interface::{PendingImage, PendingImageState}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::cell::RefCell; -use std::sync::{Arc, Mutex}; use style::context::SharedStyleContext; use style::dom::OpaqueNode; +use crate::display_list::WebRenderImageInfo; + pub struct LayoutContext<'a> { pub id: PipelineId, pub use_rayon: bool, diff --git a/components/layout_2020/display_list/background.rs b/components/layout_2020/display_list/background.rs index c5ad553efb8..a8e5b6cce24 100644 --- a/components/layout_2020/display_list/background.rs +++ b/components/layout_2020/display_list/background.rs @@ -2,17 +2,19 @@ * 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::replaced::IntrinsicSizes; use euclid::{Size2D, Vector2D}; use style::computed_values::background_clip::single_value::T as Clip; use style::computed_values::background_origin::single_value::T as Origin; use style::properties::ComputedValues; use style::values::computed::background::BackgroundSize as Size; use style::values::computed::{Length, LengthPercentage}; -use style::values::specified::background::BackgroundRepeat as RepeatXY; -use style::values::specified::background::BackgroundRepeatKeyword as Repeat; +use style::values::specified::background::{ + BackgroundRepeat as RepeatXY, BackgroundRepeatKeyword as Repeat, +}; use webrender_api::{self as wr, units}; +use crate::replaced::IntrinsicSizes; + pub(super) struct BackgroundLayer { pub common: wr::CommonItemProperties, pub bounds: units::LayoutRect, diff --git a/components/layout_2020/display_list/conversions.rs b/components/layout_2020/display_list/conversions.rs index bcd42df789d..b0022c99cdf 100644 --- a/components/layout_2020/display_list/conversions.rs +++ b/components/layout_2020/display_list/conversions.rs @@ -2,14 +2,14 @@ * 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::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize}; use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode; use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle; use style::computed_values::transform_style::T as ComputedTransformStyle; -use style::values::computed::Filter as ComputedFilter; -use style::values::computed::Length; +use style::values::computed::{Filter as ComputedFilter, Length}; use webrender_api::{units, FilterOp, LineStyle, MixBlendMode, TransformStyle}; +use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize}; + pub trait ToWebRender { type Type; fn to_webrender(&self) -> Self::Type; diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index 4cf11e17485..228aa6df62f 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -2,13 +2,9 @@ * 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::context::LayoutContext; -use crate::display_list::conversions::ToWebRender; -use crate::display_list::stacking_context::StackingContextSection; -use crate::fragment_tree::{BoxFragment, Fragment, FragmentTree, Tag, TextFragment}; -use crate::geom::{PhysicalPoint, PhysicalRect}; -use crate::replaced::IntrinsicSizes; -use crate::style_ext::ComputedValuesExt; +use std::cell::OnceCell; +use std::sync::Arc; + use embedder_traits::Cursor; use euclid::{Point2D, SideOffsets2D, Size2D}; use fnv::FnvHashMap; @@ -16,8 +12,6 @@ use gfx::text::glyph::GlyphStore; use msg::constellation_msg::BrowsingContextId; use net_traits::image_cache::UsePlaceholder; use script_traits::compositor::{CompositorDisplayListInfo, ScrollTreeNodeId}; -use std::cell::OnceCell; -use std::sync::Arc; use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle; use style::dom::OpaqueNode; use style::properties::longhands::visibility::computed_value::T as Visibility; @@ -28,6 +22,14 @@ use style::values::specified::ui::CursorKind; use style_traits::CSSPixel; use webrender_api::{self as wr, units, ClipChainId, ClipId, CommonItemProperties}; +use crate::context::LayoutContext; +use crate::display_list::conversions::ToWebRender; +use crate::display_list::stacking_context::StackingContextSection; +use crate::fragment_tree::{BoxFragment, Fragment, FragmentTree, Tag, TextFragment}; +use crate::geom::{PhysicalPoint, PhysicalRect}; +use crate::replaced::IntrinsicSizes; +use crate::style_ext::ComputedValuesExt; + mod background; mod conversions; mod gradient; diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index 1dfee6741f5..f69e8f6e946 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -2,27 +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 super::DisplayList; -use crate::cell::ArcRefCell; -use crate::display_list::conversions::ToWebRender; -use crate::display_list::DisplayListBuilder; -use crate::fragment_tree::{ - AnonymousFragment, BoxFragment, ContainingBlockManager, Fragment, FragmentTree, -}; -use crate::geom::PhysicalRect; -use crate::style_ext::ComputedValuesExt; +use std::cmp::Ordering; +use std::mem; + use euclid::default::Rect; use script_traits::compositor::{ScrollTreeNodeId, ScrollableNodeInfo}; use servo_arc::Arc as ServoArc; -use std::cmp::Ordering; -use std::mem; use style::computed_values::float::T as ComputedFloat; use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode; use style::computed_values::overflow_x::T as ComputedOverflow; use style::computed_values::position::T as ComputedPosition; use style::properties::ComputedValues; -use style::values::computed::ClipRectOrAuto; -use style::values::computed::Length; +use style::values::computed::{ClipRectOrAuto, Length}; use style::values::generics::box_::Perspective; use style::values::generics::transform; use style::values::specified::box_::DisplayOutside; @@ -30,6 +21,16 @@ use webrender_api as wr; use webrender_api::units::{LayoutPoint, LayoutRect, LayoutTransform, LayoutVector2D}; use webrender_api::ScrollSensitivity; +use super::DisplayList; +use crate::cell::ArcRefCell; +use crate::display_list::conversions::ToWebRender; +use crate::display_list::DisplayListBuilder; +use crate::fragment_tree::{ + AnonymousFragment, BoxFragment, ContainingBlockManager, Fragment, FragmentTree, +}; +use crate::geom::PhysicalRect; +use crate::style_ext::ComputedValuesExt; + #[derive(Clone)] pub(crate) struct ContainingBlock { /// The SpatialId of the spatial node that contains the children diff --git a/components/layout_2020/dom.rs b/components/layout_2020/dom.rs index 527d2c6c31d..fe7e53b437b 100644 --- a/components/layout_2020/dom.rs +++ b/components/layout_2020/dom.rs @@ -2,6 +2,17 @@ * 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::marker::PhantomData; +use std::sync::{Arc, Mutex}; + +use atomic_refcell::{AtomicRefCell, AtomicRefMut}; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use net_traits::image::base::Image as NetImage; +use script_layout_interface::wrapper_traits::{LayoutDataTrait, LayoutNode, ThreadSafeLayoutNode}; +use script_layout_interface::{HTMLCanvasDataSource, StyleData}; +use servo_arc::Arc as ServoArc; +use style::properties::ComputedValues; + use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom_traversal::WhichPseudoElement; @@ -10,15 +21,6 @@ use crate::flow::inline::InlineLevelBox; use crate::flow::BlockLevelBox; use crate::geom::PhysicalSize; use crate::replaced::{CanvasInfo, CanvasSource}; -use atomic_refcell::{AtomicRefCell, AtomicRefMut}; -use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use net_traits::image::base::Image as NetImage; -use script_layout_interface::wrapper_traits::{LayoutDataTrait, LayoutNode, ThreadSafeLayoutNode}; -use script_layout_interface::{HTMLCanvasDataSource, StyleData}; -use servo_arc::Arc as ServoArc; -use std::marker::PhantomData; -use std::sync::{Arc, Mutex}; -use style::properties::ComputedValues; /// The data that is stored in each DOM node that is used by layout. #[derive(Default)] diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs index 711aca27d64..28ef473ef15 100644 --- a/components/layout_2020/dom_traversal.rs +++ b/components/layout_2020/dom_traversal.rs @@ -2,19 +2,20 @@ * 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::context::LayoutContext; -use crate::dom::{BoxSlot, LayoutBox, NodeExt}; -use crate::fragment_tree::{BaseFragmentInfo, FragmentFlags, Tag}; -use crate::replaced::ReplacedContent; -use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside}; +use std::borrow::Cow; + use html5ever::LocalName; use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode}; use servo_arc::Arc as ServoArc; -use std::borrow::Cow; use style::properties::ComputedValues; use style::selector_parser::PseudoElement; -use style::values::generics::counters::Content; -use style::values::generics::counters::ContentItem; +use style::values::generics::counters::{Content, ContentItem}; + +use crate::context::LayoutContext; +use crate::dom::{BoxSlot, LayoutBox, NodeExt}; +use crate::fragment_tree::{BaseFragmentInfo, FragmentFlags, Tag}; +use crate::replaced::ReplacedContent; +use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside}; #[derive(Clone, Copy, Debug)] pub(crate) enum WhichPseudoElement { diff --git a/components/layout_2020/flexbox/construct.rs b/components/layout_2020/flexbox/construct.rs index 1653a4e8606..c775fccd153 100644 --- a/components/layout_2020/flexbox/construct.rs +++ b/components/layout_2020/flexbox/construct.rs @@ -2,6 +2,11 @@ * 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::borrow::Cow; + +use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use style::values::specified::text::TextDecorationLine; + use super::{FlexContainer, FlexLevelBox}; use crate::cell::ArcRefCell; use crate::context::LayoutContext; @@ -10,9 +15,6 @@ use crate::dom_traversal::{Contents, NodeAndStyleInfo, NonReplacedContents, Trav use crate::formatting_contexts::IndependentFormattingContext; use crate::positioned::AbsolutelyPositionedBox; use crate::style_ext::DisplayGeneratingBox; -use rayon::iter::{IntoParallelIterator, ParallelIterator}; -use std::borrow::Cow; -use style::values::specified::text::TextDecorationLine; impl FlexContainer { pub fn construct<'dom>( diff --git a/components/layout_2020/flexbox/geom.rs b/components/layout_2020/flexbox/geom.rs index 2e68508d71b..a229af460ab 100644 --- a/components/layout_2020/flexbox/geom.rs +++ b/components/layout_2020/flexbox/geom.rs @@ -4,9 +4,10 @@ //! https://drafts.csswg.org/css-flexbox/#box-model -use crate::geom::flow_relative::{Rect, Sides, Vec2}; use style::properties::longhands::flex_direction::computed_value::T as FlexDirection; +use crate::geom::flow_relative::{Rect, Sides, Vec2}; + #[derive(Clone, Copy)] pub(super) struct FlexRelativeVec2<T> { pub main: T, diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index f4cc3e2cf4c..c4ef67fb76a 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -2,21 +2,9 @@ * 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 super::geom::{ - FlexAxis, FlexRelativeRect, FlexRelativeSides, FlexRelativeVec2, MainStartCrossStart, -}; -use super::{FlexContainer, FlexLevelBox}; -use crate::context::LayoutContext; -use crate::formatting_contexts::{IndependentFormattingContext, IndependentLayout}; -use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment}; -use crate::geom::flow_relative::{Rect, Sides, Vec2}; -use crate::geom::LengthOrAuto; -use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength}; -use crate::sizing::ContentSizes; -use crate::style_ext::ComputedValuesExt; -use crate::ContainingBlock; -use atomic_refcell::AtomicRefMut; use std::cell::Cell; + +use atomic_refcell::AtomicRefMut; use style::properties::longhands::align_content::computed_value::T as AlignContent; use style::properties::longhands::align_items::computed_value::T as AlignItems; use style::properties::longhands::align_self::computed_value::T as AlignSelf; @@ -30,6 +18,20 @@ use style::values::generics::flex::GenericFlexBasis as FlexBasis; use style::values::CSSFloat; use style::Zero; +use super::geom::{ + FlexAxis, FlexRelativeRect, FlexRelativeSides, FlexRelativeVec2, MainStartCrossStart, +}; +use super::{FlexContainer, FlexLevelBox}; +use crate::context::LayoutContext; +use crate::formatting_contexts::{IndependentFormattingContext, IndependentLayout}; +use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment}; +use crate::geom::flow_relative::{Rect, Sides, Vec2}; +use crate::geom::LengthOrAuto; +use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength}; +use crate::sizing::ContentSizes; +use crate::style_ext::ComputedValuesExt; +use crate::ContainingBlock; + // FIMXE: “Flex items […] `z-index` values other than `auto` create a stacking context // even if `position` is `static` (behaving exactly as if `position` were `relative`).” // https://drafts.csswg.org/css-flexbox/#painting diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index 796974044f5..dbdac0f5c8e 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -2,6 +2,17 @@ * 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::borrow::Cow; +use std::convert::{TryFrom, TryInto}; + +use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use servo_arc::Arc; +use style::computed_values::white_space::T as WhiteSpace; +use style::properties::longhands::list_style_position::computed_value::T as ListStylePosition; +use style::properties::ComputedValues; +use style::selector_parser::PseudoElement; +use style::values::specified::text::TextDecorationLine; + use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom::{BoxSlot, LayoutBox, NodeExt}; @@ -12,15 +23,6 @@ use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox}; use crate::formatting_contexts::IndependentFormattingContext; use crate::positioned::AbsolutelyPositionedBox; use crate::style_ext::{ComputedValuesExt, DisplayGeneratingBox, DisplayInside, DisplayOutside}; -use rayon::iter::{IntoParallelIterator, ParallelIterator}; -use servo_arc::Arc; -use std::borrow::Cow; -use std::convert::{TryFrom, TryInto}; -use style::computed_values::white_space::T as WhiteSpace; -use style::properties::longhands::list_style_position::computed_value::T as ListStylePosition; -use style::properties::ComputedValues; -use style::selector_parser::PseudoElement; -use style::values::specified::text::TextDecorationLine; impl BlockFormattingContext { pub fn construct<'dom, Node>( diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs index db8003835a1..36037c22089 100644 --- a/components/layout_2020/flow/float.rs +++ b/components/layout_2020/flow/float.rs @@ -6,6 +6,19 @@ //! //! See CSS 2.1 § 9.5.1: https://www.w3.org/TR/CSS2/visuren.html#float-position +use std::collections::VecDeque; +use std::fmt::{Debug, Formatter, Result as FmtResult}; +use std::ops::Range; +use std::{f32, mem}; + +use euclid::num::Zero; +use serde::Serialize; +use servo_arc::Arc; +use style::computed_values::float::T as FloatProperty; +use style::properties::ComputedValues; +use style::values::computed::{CSSPixelLength, Clear, Length}; +use style::values::specified::text::TextDecorationLine; + use crate::context::LayoutContext; use crate::dom::NodeExt; use crate::dom_traversal::{Contents, NodeAndStyleInfo}; @@ -15,17 +28,6 @@ use crate::geom::flow_relative::{Rect, Vec2}; use crate::positioned::PositioningContext; use crate::style_ext::{ComputedValuesExt, DisplayInside, PaddingBorderMargin}; use crate::ContainingBlock; -use euclid::num::Zero; -use serde::Serialize; -use servo_arc::Arc; -use std::collections::VecDeque; -use std::fmt::{Debug, Formatter, Result as FmtResult}; -use std::ops::Range; -use std::{f32, mem}; -use style::computed_values::float::T as FloatProperty; -use style::properties::ComputedValues; -use style::values::computed::{CSSPixelLength, Clear, Length}; -use style::values::specified::text::TextDecorationLine; /// A floating box. #[derive(Debug, Serialize)] diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index 4ab0fa31be0..0c9bd4e5d05 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -2,6 +2,24 @@ * 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::OnceCell; + +use app_units::Au; +use atomic_refcell::AtomicRef; +use gfx::text::glyph::GlyphStore; +use gfx::text::text_run::GlyphRun; +use serde::Serialize; +use servo_arc::Arc; +use style::computed_values::white_space::T as WhiteSpace; +use style::logical_geometry::WritingMode; +use style::properties::ComputedValues; +use style::values::computed::Length; +use style::values::generics::text::LineHeight; +use style::values::specified::text::{TextAlignKeyword, TextDecorationLine}; +use style::Zero; +use webrender_api::FontInstanceKey; +use xi_unicode::LineBreakLeafIter; + use super::float::PlacementAmongFloats; use super::CollapsibleWithParentStartMargin; use crate::cell::ArcRefCell; @@ -23,23 +41,6 @@ use crate::style_ext::{ ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside, PaddingBorderMargin, }; use crate::ContainingBlock; -use app_units::Au; -use atomic_refcell::AtomicRef; -use gfx::text::glyph::GlyphStore; -use gfx::text::text_run::GlyphRun; -use serde::Serialize; -use servo_arc::Arc; -use std::cell::OnceCell; -use style::computed_values::white_space::T as WhiteSpace; -use style::logical_geometry::WritingMode; -use style::properties::ComputedValues; -use style::values::computed::Length; -use style::values::generics::text::LineHeight; -use style::values::specified::text::TextAlignKeyword; -use style::values::specified::text::TextDecorationLine; -use style::Zero; -use webrender_api::FontInstanceKey; -use xi_unicode::LineBreakLeafIter; #[derive(Debug, Serialize)] pub(crate) struct InlineFormattingContext { diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index 75a44ac87fb..aae18f6d05d 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -4,6 +4,16 @@ //! Flow layout, also known as block-and-inline layout. +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; +use serde::Serialize; +use servo_arc::Arc; +use style::computed_values::clear::T as Clear; +use style::computed_values::float::T as Float; +use style::logical_geometry::WritingMode; +use style::properties::ComputedValues; +use style::values::computed::{Length, LengthOrAuto}; +use style::Zero; + use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::flow::float::{ @@ -22,15 +32,6 @@ use crate::replaced::ReplacedContent; use crate::sizing::{self, ContentSizes}; use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin}; use crate::ContainingBlock; -use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; -use serde::Serialize; -use servo_arc::Arc; -use style::computed_values::clear::T as Clear; -use style::computed_values::float::T as Float; -use style::logical_geometry::WritingMode; -use style::properties::ComputedValues; -use style::values::computed::{Length, LengthOrAuto}; -use style::Zero; mod construct; pub mod float; diff --git a/components/layout_2020/flow/root.rs b/components/layout_2020/flow/root.rs index 5af9413abfb..e4af794b15f 100644 --- a/components/layout_2020/flow/root.rs +++ b/components/layout_2020/flow/root.rs @@ -2,6 +2,16 @@ * 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 atomic_refcell::AtomicRef; +use script_layout_interface::wrapper_traits::LayoutNode; +use script_layout_interface::{LayoutElementType, LayoutNodeType}; +use serde::Serialize; +use servo_arc::Arc; +use style::dom::OpaqueNode; +use style::properties::ComputedValues; +use style::values::computed::Length; +use style_traits::CSSPixel; + use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom::{LayoutBox, NodeExt}; @@ -14,21 +24,10 @@ use crate::formatting_contexts::IndependentFormattingContext; use crate::fragment_tree::FragmentTree; use crate::geom::flow_relative::Vec2; use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSize}; -use crate::positioned::AbsolutelyPositionedBox; -use crate::positioned::PositioningContext; +use crate::positioned::{AbsolutelyPositionedBox, PositioningContext}; use crate::replaced::ReplacedContent; -use crate::style_ext::ComputedValuesExt; -use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside}; +use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayInside}; use crate::DefiniteContainingBlock; -use atomic_refcell::AtomicRef; -use script_layout_interface::wrapper_traits::LayoutNode; -use script_layout_interface::{LayoutElementType, LayoutNodeType}; -use serde::Serialize; -use servo_arc::Arc; -use style::dom::OpaqueNode; -use style::properties::ComputedValues; -use style::values::computed::Length; -use style_traits::CSSPixel; #[derive(Serialize)] pub struct BoxTree { diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs index 118142d92e0..d13ea240251 100644 --- a/components/layout_2020/formatting_contexts.rs +++ b/components/layout_2020/formatting_contexts.rs @@ -2,6 +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::convert::TryInto; + +use serde::Serialize; +use servo_arc::Arc; +use style::logical_geometry::WritingMode; +use style::properties::ComputedValues; +use style::values::computed::Length; +use style::values::specified::text::TextDecorationLine; + use crate::context::LayoutContext; use crate::dom::NodeExt; use crate::dom_traversal::{Contents, NodeAndStyleInfo}; @@ -13,13 +22,6 @@ use crate::replaced::ReplacedContent; use crate::sizing::{self, ContentSizes}; use crate::style_ext::DisplayInside; use crate::ContainingBlock; -use serde::Serialize; -use servo_arc::Arc; -use std::convert::TryInto; -use style::logical_geometry::WritingMode; -use style::properties::ComputedValues; -use style::values::computed::Length; -use style::values::specified::text::TextDecorationLine; /// https://drafts.csswg.org/css-display/#independent-formatting-context #[derive(Debug, Serialize)] diff --git a/components/layout_2020/fragment_tree/base_fragment.rs b/components/layout_2020/fragment_tree/base_fragment.rs index 6104c9af547..f0921592517 100644 --- a/components/layout_2020/fragment_tree/base_fragment.rs +++ b/components/layout_2020/fragment_tree/base_fragment.rs @@ -2,13 +2,14 @@ * 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::layout_debug::DebugId; use bitflags::bitflags; use gfx_traits::{combine_id_with_fragment_type, FragmentType}; use serde::Serialize; use style::dom::OpaqueNode; use style::selector_parser::PseudoElement; +use crate::layout_debug::DebugId; + /// This data structure stores fields that are common to all non-base /// Fragment types and should generally be the first member of all /// concrete fragments. diff --git a/components/layout_2020/fragment_tree/box_fragment.rs b/components/layout_2020/fragment_tree/box_fragment.rs index 4ba007a79a2..a4a62c8ee64 100644 --- a/components/layout_2020/fragment_tree/box_fragment.rs +++ b/components/layout_2020/fragment_tree/box_fragment.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 super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment}; -use crate::cell::ArcRefCell; -use crate::geom::flow_relative::{Rect, Sides}; -use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize}; use gfx_traits::print_tree::PrintTree; use serde::Serialize; use servo_arc::Arc as ServoArc; @@ -15,6 +11,11 @@ use style::properties::ComputedValues; use style::values::computed::{CSSPixelLength, Length, LengthPercentage, LengthPercentageOrAuto}; use style::Zero; +use super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment}; +use crate::cell::ArcRefCell; +use crate::geom::flow_relative::{Rect, Sides}; +use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize}; + #[derive(Serialize)] pub(crate) struct BoxFragment { pub base: BaseFragment, diff --git a/components/layout_2020/fragment_tree/containing_block.rs b/components/layout_2020/fragment_tree/containing_block.rs index 82a205fd2d5..41b4910bdbf 100644 --- a/components/layout_2020/fragment_tree/containing_block.rs +++ b/components/layout_2020/fragment_tree/containing_block.rs @@ -2,9 +2,10 @@ * 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::fragment_tree::Fragment; use style::computed_values::position::T as ComputedPosition; +use crate::fragment_tree::Fragment; + /// A data structure used to track the containing block when recursing /// through the Fragment tree. It tracks the three types of containing /// blocks (for all descendants, for absolute and fixed position diff --git a/components/layout_2020/fragment_tree/fragment.rs b/components/layout_2020/fragment_tree/fragment.rs index 6b8e788f0f1..bfe9e0358db 100644 --- a/components/layout_2020/fragment_tree/fragment.rs +++ b/components/layout_2020/fragment_tree/fragment.rs @@ -2,18 +2,14 @@ * 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 super::{BaseFragment, BoxFragment, ContainingBlockManager, HoistedSharedFragment, Tag}; -use crate::cell::ArcRefCell; -use crate::geom::flow_relative::{Rect, Sides}; -use crate::geom::PhysicalRect; -use crate::style_ext::ComputedValuesExt; +use std::sync::Arc; + use gfx::font::FontMetrics as GfxFontMetrics; use gfx::text::glyph::GlyphStore; use gfx_traits::print_tree::PrintTree; use msg::constellation_msg::{BrowsingContextId, PipelineId}; use serde::Serialize; use servo_arc::Arc as ServoArc; -use std::sync::Arc; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; use style::values::computed::Length; @@ -21,6 +17,12 @@ use style::values::specified::text::TextDecorationLine; use style::Zero; use webrender_api::{FontInstanceKey, ImageKey}; +use super::{BaseFragment, BoxFragment, ContainingBlockManager, HoistedSharedFragment, Tag}; +use crate::cell::ArcRefCell; +use crate::geom::flow_relative::{Rect, Sides}; +use crate::geom::PhysicalRect; +use crate::style_ext::ComputedValuesExt; + #[derive(Serialize)] pub(crate) enum Fragment { Box(BoxFragment), diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index ce39f05ad01..023344a1b6c 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -2,11 +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 super::{ContainingBlockManager, Fragment, Tag}; -use crate::cell::ArcRefCell; -use crate::display_list::StackingContext; -use crate::flow::CanvasBackground; -use crate::geom::PhysicalRect; use app_units::Au; use euclid::default::{Point2D, Rect, Size2D}; use fxhash::FxHashSet; @@ -17,6 +12,12 @@ use style::dom::OpaqueNode; use style::values::computed::Length; use webrender_api::units; +use super::{ContainingBlockManager, Fragment, Tag}; +use crate::cell::ArcRefCell; +use crate::display_list::StackingContext; +use crate::flow::CanvasBackground; +use crate::geom::PhysicalRect; + #[derive(Serialize)] pub struct FragmentTree { /// Fragments at the top-level of the tree. diff --git a/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs b/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs index 48a90d73c64..41bcc9ddb05 100644 --- a/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs +++ b/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs @@ -2,11 +2,13 @@ * 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 super::Fragment; -use crate::{cell::ArcRefCell, geom::flow_relative::Vec2}; use serde::Serialize; use style::values::computed::{Length, LengthPercentage}; +use super::Fragment; +use crate::cell::ArcRefCell; +use crate::geom::flow_relative::Vec2; + /// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox` /// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position. /// This will be used later in order to paint this hoisted box in tree order. diff --git a/components/layout_2020/geom.rs b/components/layout_2020/geom.rs index 04b1294f917..4d5bb475075 100644 --- a/components/layout_2020/geom.rs +++ b/components/layout_2020/geom.rs @@ -2,16 +2,19 @@ * 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::ContainingBlock; use std::fmt; use std::ops::{Add, AddAssign, Sub}; -use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection}; -use style::logical_geometry::{PhysicalCorner, WritingMode}; + +use style::logical_geometry::{ + BlockFlowDirection, InlineBaseDirection, PhysicalCorner, WritingMode, +}; use style::values::computed::{Length, LengthPercentage}; use style::values::generics::length::GenericLengthPercentageOrAuto as AutoOr; use style::Zero; use style_traits::CSSPixel; +use crate::ContainingBlock; + pub type PhysicalPoint<U> = euclid::Point2D<U, CSSPixel>; pub type PhysicalSize<U> = euclid::Size2D<U, CSSPixel>; pub type PhysicalRect<U> = euclid::Rect<U, CSSPixel>; diff --git a/components/layout_2020/layout_debug.rs b/components/layout_2020/layout_debug.rs index 6720d99e0a2..642e6b8a538 100644 --- a/components/layout_2020/layout_debug.rs +++ b/components/layout_2020/layout_debug.rs @@ -5,18 +5,20 @@ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to make layout debugging easier. -use crate::flow::BoxTree; -use crate::fragment_tree::FragmentTree; -#[cfg(not(debug_assertions))] -use serde::ser::Serializer; -use serde::Serialize; -use serde_json::{to_string, to_value, Value}; use std::cell::RefCell; use std::fs; #[cfg(debug_assertions)] use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +#[cfg(not(debug_assertions))] +use serde::ser::Serializer; +use serde::Serialize; +use serde_json::{to_string, to_value, Value}; + +use crate::flow::BoxTree; +use crate::fragment_tree::FragmentTree; + thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None)); #[cfg(debug_assertions)] diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index 15a6a05f029..0ab0ffa74b4 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -27,11 +27,11 @@ pub mod traversal; pub use flow::BoxTree; pub use fragment_tree::FragmentTree; - -use crate::geom::flow_relative::Vec2; use style::properties::ComputedValues; use style::values::computed::{Length, LengthOrAuto}; +use crate::geom::flow_relative::Vec2; + pub struct ContainingBlock<'a> { inline_size: Length, block_size: LengthOrAuto, diff --git a/components/layout_2020/lists.rs b/components/layout_2020/lists.rs index c58f28b06a8..ace12efa614 100644 --- a/components/layout_2020/lists.rs +++ b/components/layout_2020/lists.rs @@ -2,13 +2,14 @@ * 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 style::properties::longhands::list_style_type::computed_value::T as ListStyleType; +use style::properties::style_structs; +use style::values::computed::Image; + use crate::context::LayoutContext; use crate::dom::NodeExt; use crate::dom_traversal::{NodeAndStyleInfo, PseudoElementContentItem}; use crate::replaced::ReplacedContent; -use style::properties::longhands::list_style_type::computed_value::T as ListStyleType; -use style::properties::style_structs; -use style::values::computed::Image; /// https://drafts.csswg.org/css-lists/#content-property pub(crate) fn make_marker<'dom, Node>( diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index eb1b6b30cf4..2a36b4c67a9 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -2,6 +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 rayon::iter::IntoParallelRefMutIterator; +use rayon::prelude::{IndexedParallelIterator, ParallelIterator}; +use serde::Serialize; +use style::computed_values::position::T as Position; +use style::properties::ComputedValues; +use style::values::computed::{CSSPixelLength, Length}; +use style::values::specified::text::TextDecorationLine; +use style::Zero; + use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom::NodeExt; @@ -14,14 +23,6 @@ use crate::geom::flow_relative::{Rect, Sides, Vec2}; use crate::geom::{LengthOrAuto, LengthPercentageOrAuto}; use crate::style_ext::{ComputedValuesExt, DisplayInside}; use crate::{ContainingBlock, DefiniteContainingBlock}; -use rayon::iter::IntoParallelRefMutIterator; -use rayon::prelude::{IndexedParallelIterator, ParallelIterator}; -use serde::Serialize; -use style::computed_values::position::T as Position; -use style::properties::ComputedValues; -use style::values::computed::{CSSPixelLength, Length}; -use style::values::specified::text::TextDecorationLine; -use style::Zero; #[derive(Debug, Serialize)] pub(crate) struct AbsolutelyPositionedBox { diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs index a4f77076901..e71b5df20ee 100644 --- a/components/layout_2020/query.rs +++ b/components/layout_2020/query.rs @@ -3,40 +3,39 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Utilities for querying the layout, as needed by the layout thread. -use crate::context::LayoutContext; -use crate::fragment_tree::{Fragment, FragmentFlags, FragmentTree, Tag}; +use std::collections::HashMap; +use std::sync::{Arc, Mutex}; + use app_units::Au; use euclid::default::{Point2D, Rect}; -use euclid::Size2D; -use euclid::Vector2D; +use euclid::{Size2D, Vector2D}; use log::warn; use msg::constellation_msg::PipelineId; -use script_layout_interface::rpc::TextIndexResponse; -use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; -use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse}; -use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse}; +use script_layout_interface::rpc::{ + ContentBoxResponse, ContentBoxesResponse, LayoutRPC, NodeGeometryResponse, + NodeScrollIdResponse, OffsetParentResponse, ResolvedStyleResponse, TextIndexResponse, +}; use script_layout_interface::wrapper_traits::{ LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, }; use script_traits::UntrustedNodeAddress; use servo_arc::Arc as ServoArc; -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; use style::computed_values::position::T as Position; use style::context::{StyleContext, ThreadLocalStyleContext}; -use style::dom::OpaqueNode; -use style::dom::TElement; +use style::dom::{OpaqueNode, TElement}; use style::properties::style_structs::Font; use style::properties::{LonghandId, PropertyDeclarationId, PropertyId}; use style::selector_parser::PseudoElement; use style::stylist::RuleInclusion; use style::traversal::resolve_style; use style::values::generics::text::LineHeight; -use style_traits::CSSPixel; -use style_traits::ToCss; +use style_traits::{CSSPixel, ToCss}; use webrender_api::units::LayoutPixel; use webrender_api::{DisplayListBuilder, ExternalScrollId}; +use crate::context::LayoutContext; +use crate::fragment_tree::{Fragment, FragmentFlags, FragmentTree, Tag}; + /// Mutable data belonging to the LayoutThread. /// /// This needs to be protected by a mutex so we can do fast RPCs. diff --git a/components/layout_2020/replaced.rs b/components/layout_2020/replaced.rs index 1ba87c10265..8cfd7b3c422 100644 --- a/components/layout_2020/replaced.rs +++ b/components/layout_2020/replaced.rs @@ -2,14 +2,9 @@ * 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::context::LayoutContext; -use crate::dom::NodeExt; -use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment}; -use crate::geom::flow_relative::{Rect, Vec2}; -use crate::geom::PhysicalSize; -use crate::sizing::ContentSizes; -use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin}; -use crate::ContainingBlock; +use std::fmt; +use std::sync::{Arc, Mutex}; + use canvas_traits::canvas::{CanvasId, CanvasMsg, FromLayoutMsg}; use ipc_channel::ipc::{self, IpcSender}; use msg::constellation_msg::{BrowsingContextId, PipelineId}; @@ -17,8 +12,6 @@ use net_traits::image::base::Image; use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder}; use serde::Serialize; use servo_arc::Arc as ServoArc; -use std::fmt; -use std::sync::{Arc, Mutex}; use style::properties::ComputedValues; use style::servo::url::ComputedUrl; use style::values::computed::image::Image as ComputedImage; @@ -27,6 +20,15 @@ use style::values::CSSFloat; use style::Zero; use webrender_api::ImageKey; +use crate::context::LayoutContext; +use crate::dom::NodeExt; +use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment}; +use crate::geom::flow_relative::{Rect, Vec2}; +use crate::geom::PhysicalSize; +use crate::sizing::ContentSizes; +use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin}; +use crate::ContainingBlock; + #[derive(Debug, Serialize)] pub(crate) struct ReplacedContent { pub kind: ReplacedContentKind, diff --git a/components/layout_2020/sizing.rs b/components/layout_2020/sizing.rs index 9b5671af577..76cc56c7bd7 100644 --- a/components/layout_2020/sizing.rs +++ b/components/layout_2020/sizing.rs @@ -4,7 +4,6 @@ //! https://drafts.csswg.org/css-sizing/ -use crate::style_ext::ComputedValuesExt; use serde::Serialize; use style::logical_geometry::WritingMode; use style::properties::longhands::box_sizing::computed_value::T as BoxSizing; @@ -12,6 +11,8 @@ use style::properties::ComputedValues; use style::values::computed::Length; use style::Zero; +use crate::style_ext::ComputedValuesExt; + #[derive(Clone, Debug, Serialize)] pub(crate) struct ContentSizes { pub min_content: Length, diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs index ce4e510edf1..35c71845f92 100644 --- a/components/layout_2020/style_ext.rs +++ b/components/layout_2020/style_ext.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 crate::geom::flow_relative; -use crate::geom::{LengthOrAuto, LengthPercentageOrAuto, PhysicalSides, PhysicalSize}; -use crate::ContainingBlock; use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode; use style::computed_values::position::T as ComputedPosition; use style::computed_values::transform_style::T as ComputedTransformStyle; @@ -14,14 +11,18 @@ use style::properties::longhands::box_sizing::computed_value::T as BoxSizing; use style::properties::longhands::column_span::computed_value::T as ColumnSpan; use style::properties::ComputedValues; use style::values::computed::image::Image as ComputedImageLayer; -use style::values::computed::{Length, LengthPercentage}; -use style::values::computed::{NonNegativeLengthPercentage, Size}; +use style::values::computed::{Length, LengthPercentage, NonNegativeLengthPercentage, Size}; use style::values::generics::box_::Perspective; use style::values::generics::length::MaxSize; use style::values::specified::box_ as stylo; use style::Zero; use webrender_api as wr; +use crate::geom::{ + flow_relative, LengthOrAuto, LengthPercentageOrAuto, PhysicalSides, PhysicalSize, +}; +use crate::ContainingBlock; + #[derive(Clone, Copy, Eq, PartialEq)] pub(crate) enum Display { None, diff --git a/components/layout_2020/tests/floats.rs b/components/layout_2020/tests/floats.rs index 3b4b91c10b8..2f226f29b0e 100644 --- a/components/layout_2020/tests/floats.rs +++ b/components/layout_2020/tests/floats.rs @@ -4,19 +4,19 @@ //! Property-based randomized testing for the core float layout algorithm. -use lazy_static::lazy_static; +use std::ops::Range; +use std::panic::{self, PanicInfo}; +use std::sync::{Mutex, MutexGuard}; +use std::{f32, thread, u32}; use euclid::num::Zero; -use layout_2020::flow::float::{ContainingBlockPositionInfo, FloatSide, PlacementInfo}; -use layout_2020::flow::float::{FloatBand, FloatBandNode, FloatBandTree, FloatContext}; +use layout_2020::flow::float::{ + ContainingBlockPositionInfo, FloatBand, FloatBandNode, FloatBandTree, FloatContext, FloatSide, + PlacementInfo, +}; use layout_2020::geom::flow_relative::{Rect, Vec2}; +use lazy_static::lazy_static; use quickcheck::{Arbitrary, Gen}; -use std::f32; -use std::ops::Range; -use std::panic::{self, PanicInfo}; -use std::sync::{Mutex, MutexGuard}; -use std::thread; -use std::u32; use style::values::computed::{Clear, Length}; lazy_static! { diff --git a/components/layout_2020/traversal.rs b/components/layout_2020/traversal.rs index 3063319fec6..f5187a41916 100644 --- a/components/layout_2020/traversal.rs +++ b/components/layout_2020/traversal.rs @@ -2,14 +2,14 @@ * 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::context::LayoutContext; -use crate::dom::NodeExt; use script_layout_interface::wrapper_traits::LayoutNode; use style::context::{SharedStyleContext, StyleContext}; use style::data::ElementData; use style::dom::{NodeInfo, TElement, TNode}; -use style::traversal::PerLevelTraversalData; -use style::traversal::{recalc_style_at, DomTraversal}; +use style::traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData}; + +use crate::context::LayoutContext; +use crate::dom::NodeExt; pub struct RecalcStyle<'a> { context: LayoutContext<'a>, diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index dfac9089a69..515648e21e3 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -8,24 +8,32 @@ //! The layout thread. Performs layout on the DOM, builds display lists and sends them to be //! painted. +use std::borrow::ToOwned; +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; +use std::ops::{Deref, DerefMut}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard}; +use std::time::Duration; +use std::{process, thread}; + use app_units::Au; use crossbeam_channel::{select, Receiver, Sender}; use embedder_traits::resources::{self, Resource}; -use euclid::{default::Size2D as UntypedSize2D, Point2D, Rect, Scale, Size2D}; +use euclid::default::Size2D as UntypedSize2D; +use euclid::{Point2D, Rect, Scale, Size2D}; use fnv::FnvHashMap; use fxhash::{FxHashMap, FxHashSet}; -use gfx::font; use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context; +use gfx::{font, font_context}; use gfx_traits::{node_id_from_scroll_id, Epoch}; use histogram::Histogram; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layout::construct::ConstructionResult; -use layout::context::malloc_size_of_persistent_local_context; -use layout::context::LayoutContext; -use layout::context::RegisteredPainter; -use layout::context::RegisteredPainters; +use layout::context::{ + malloc_size_of_persistent_local_context, LayoutContext, RegisteredPainter, RegisteredPainters, +}; use layout::display_list::items::WebRenderImageInfo; use layout::display_list::{IndexableText, ToLayout}; use layout::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils, MutableOwnedFlowUtils}; @@ -38,56 +46,49 @@ use layout::query::{ process_resolved_font_style_request, process_resolved_style_request, LayoutRPCImpl, LayoutThreadData, }; -use layout::sequential; use layout::traversal::{ construct_flows_at_ancestors, ComputeStackingRelativePositions, PreorderFlowTraversal, RecalcStyleAndConstructFlows, }; use layout::wrapper::LayoutNodeLayoutData; -use layout::{layout_debug, LayoutData}; -use layout::{layout_debug_scope, parallel}; +use layout::{layout_debug, layout_debug_scope, parallel, sequential, LayoutData}; use layout_traits::LayoutThreadFactory; use lazy_static::lazy_static; use log::{debug, error, trace, warn}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory, ProgressiveWebMetric}; use msg::constellation_msg::{ - BackgroundHangMonitor, BackgroundHangMonitorRegister, HangAnnotation, + BackgroundHangMonitor, BackgroundHangMonitorRegister, BrowsingContextId, HangAnnotation, + LayoutHangAnnotation, MonitoredComponentId, MonitoredComponentType, PipelineId, + TopLevelBrowsingContextId, }; -use msg::constellation_msg::{BrowsingContextId, MonitoredComponentId, TopLevelBrowsingContextId}; -use msg::constellation_msg::{LayoutHangAnnotation, MonitoredComponentType, PipelineId}; use net_traits::image_cache::{ImageCache, UsePlaceholder}; use parking_lot::RwLock; use profile_traits::mem::{self as profile_mem, Report, ReportKind, ReportsChan}; use profile_traits::path; -use profile_traits::time::{self as profile_time, profile, TimerMetadata}; -use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; +use profile_traits::time::{ + self as profile_time, profile, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType, +}; use script::layout_dom::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNode}; -use script_layout_interface::message::{LayoutThreadInit, Msg, NodesFromPointQueryType, Reflow}; -use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow}; -use script_layout_interface::rpc::TextIndexResponse; -use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse}; +use script_layout_interface::message::{ + LayoutThreadInit, Msg, NodesFromPointQueryType, QueryMsg, Reflow, ReflowComplete, ReflowGoal, + ScriptReflow, +}; +use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse, TextIndexResponse}; use script_layout_interface::wrapper_traits::LayoutNode; -use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; -use script_traits::{DrawAPaintImageResult, IFrameSizeMsg, PaintWorkletError, WindowSizeType}; -use script_traits::{Painter, WebrenderIpcSender}; -use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData}; +use script_traits::{ + ConstellationControlMsg, DrawAPaintImageResult, IFrameSizeMsg, LayoutControlMsg, + LayoutMsg as ConstellationMsg, PaintWorkletError, Painter, ScrollState, UntrustedNodeAddress, + WebrenderIpcSender, WindowSizeData, WindowSizeType, +}; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; use servo_config::opts::{self, DebugOptions}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::borrow::ToOwned; -use std::cell::{Cell, RefCell}; -use std::collections::HashMap; -use std::ops::{Deref, DerefMut}; -use std::process; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex, MutexGuard}; -use std::thread; -use std::time::Duration; use style::animation::{AnimationSetKey, DocumentAnimationSet, ElementAnimationSet}; -use style::context::SharedStyleContext; -use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters}; +use style::context::{ + QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters, SharedStyleContext, +}; use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode}; use style::driver; use style::error_reporting::RustLogReporter; @@ -106,9 +107,7 @@ use style::stylist::Stylist; use style::thread_state::{self, ThreadState}; use style::traversal::DomTraversal; use style::traversal_flags::TraversalFlags; -use style_traits::CSSPixel; -use style_traits::DevicePixel; -use style_traits::SpeculativePainter; +use style_traits::{CSSPixel, DevicePixel, SpeculativePainter}; use webrender_api::{units, ColorF, HitTestFlags}; /// Information needed by the layout thread. diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index ade4ecc4e94..56bbd204e78 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -8,13 +8,19 @@ //! The layout thread. Performs layout on the DOM, builds display lists and sends them to be //! painted. -use lazy_static::lazy_static; -use log::{debug, error, warn}; +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; +use std::ops::{Deref, DerefMut}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard}; +use std::time::Duration; +use std::{process, thread}; use app_units::Au; use crossbeam_channel::{select, Receiver, Sender}; use embedder_traits::resources::{self, Resource}; -use euclid::{default::Size2D as UntypedSize2D, Point2D, Rect, Scale, Size2D}; +use euclid::default::Size2D as UntypedSize2D; +use euclid::{Point2D, Rect, Scale, Size2D}; use fnv::FnvHashMap; use fxhash::FxHashMap; use gfx::font_cache_thread::FontCacheThread; @@ -25,19 +31,17 @@ use ipc_channel::router::ROUTER; use layout::context::LayoutContext; use layout::display_list::{DisplayList, WebRenderImageInfo}; use layout::dom::DOMLayoutData; -use layout::layout_debug; -use layout::query::{ - process_content_box_request, process_content_boxes_request, process_resolved_font_style_query, - LayoutRPCImpl, LayoutThreadData, -}; -use layout::query::{process_element_inner_text_query, process_node_geometry_request}; -use layout::query::{process_node_scroll_area_request, process_node_scroll_id_request}; use layout::query::{ - process_offset_parent_query, process_resolved_style_request, process_text_index_request, + process_content_box_request, process_content_boxes_request, process_element_inner_text_query, + process_node_geometry_request, process_node_scroll_area_request, + process_node_scroll_id_request, process_offset_parent_query, process_resolved_font_style_query, + process_resolved_style_request, process_text_index_request, LayoutRPCImpl, LayoutThreadData, }; use layout::traversal::RecalcStyle; -use layout::{BoxTree, FragmentTree}; +use layout::{layout_debug, BoxTree, FragmentTree}; use layout_traits::LayoutThreadFactory; +use lazy_static::lazy_static; +use log::{debug, error, warn}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory, ProgressiveWebMetric}; use msg::constellation_msg::{ @@ -49,13 +53,15 @@ use net_traits::image_cache::{ImageCache, UsePlaceholder}; use parking_lot::RwLock; use profile_traits::mem::{self as profile_mem, Report, ReportKind, ReportsChan}; use profile_traits::path; -use profile_traits::time::{self as profile_time, profile, TimerMetadata}; -use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; +use profile_traits::time::{ + self as profile_time, profile, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType, +}; use script::layout_dom::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNode}; -use script_layout_interface::message::{LayoutThreadInit, Msg, NodesFromPointQueryType}; -use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow}; -use script_layout_interface::rpc::TextIndexResponse; -use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse}; +use script_layout_interface::message::{ + LayoutThreadInit, Msg, NodesFromPointQueryType, QueryMsg, ReflowComplete, ReflowGoal, + ScriptReflow, +}; +use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse, TextIndexResponse}; use script_traits::{ ConstellationControlMsg, DrawAPaintImageResult, IFrameSizeMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, PaintWorkletError, Painter, ScrollState, UntrustedNodeAddress, @@ -65,14 +71,6 @@ use servo_arc::Arc as ServoArc; use servo_atoms::Atom; use servo_config::opts::{self, DebugOptions}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::cell::{Cell, RefCell}; -use std::collections::HashMap; -use std::ops::{Deref, DerefMut}; -use std::process; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex, MutexGuard}; -use std::thread; -use std::time::Duration; use style::animation::DocumentAnimationSet; use style::context::{ QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters, SharedStyleContext, @@ -92,9 +90,7 @@ use style::stylist::Stylist; use style::thread_state::{self, ThreadState}; use style::traversal::DomTraversal; use style::traversal_flags::TraversalFlags; -use style_traits::CSSPixel; -use style_traits::DevicePixel; -use style_traits::SpeculativePainter; +use style_traits::{CSSPixel, DevicePixel, SpeculativePainter}; use webrender_api::{units, HitTestFlags}; /// Information needed by the layout thread. diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index b10ee62d5c1..1e1783e489f 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -9,21 +9,23 @@ // The traits are here instead of in layout so // that these modules won't have to depend on layout. +use std::sync::atomic::AtomicBool; +use std::sync::Arc; + use crossbeam_channel::{Receiver, Sender}; use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use metrics::PaintTimeMetrics; -use msg::constellation_msg::TopLevelBrowsingContextId; -use msg::constellation_msg::{BackgroundHangMonitorRegister, PipelineId}; +use msg::constellation_msg::{ + BackgroundHangMonitorRegister, PipelineId, TopLevelBrowsingContextId, +}; use net_traits::image_cache::ImageCache; use profile_traits::{mem, time}; -use script_traits::LayoutMsg as ConstellationMsg; use script_traits::{ - ConstellationControlMsg, LayoutControlMsg, WebrenderIpcSender, WindowSizeData, + ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, WebrenderIpcSender, + WindowSizeData, }; use servo_url::ServoUrl; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; // A static method creating a layout thread // Here to remove the compositor -> layout dependency diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 30b16dc3703..9a7be7423e6 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -46,15 +46,15 @@ //! Note: WebRender has a reduced fork of this crate, so that we can avoid //! publishing this crate on crates.io. +use std::hash::{BuildHasher, Hash}; +use std::mem::size_of; +use std::ops::{Deref, DerefMut, Range}; +use std::os::raw::c_void; + #[cfg(feature = "servo")] use content_security_policy as csp; #[cfg(feature = "servo")] use serde_bytes::ByteBuf; -use std::hash::{BuildHasher, Hash}; -use std::mem::size_of; -use std::ops::Range; -use std::ops::{Deref, DerefMut}; -use std::os::raw::c_void; #[cfg(feature = "servo")] use uuid::Uuid; use void::Void; diff --git a/components/media/lib.rs b/components/media/lib.rs index 65e698dcb76..0bbe40378f0 100644 --- a/components/media/lib.rs +++ b/components/media/lib.rs @@ -7,17 +7,19 @@ mod media_channel; mod media_thread; -pub use crate::media_channel::glplayer_channel; -use crate::media_channel::{GLPlayerChan, GLPlayerPipeline, GLPlayerReceiver, GLPlayerSender}; -use crate::media_thread::GLPlayerThread; +use std::sync::{Arc, Mutex}; + use euclid::default::Size2D; use serde::{Deserialize, Serialize}; use servo_media::player::context::{GlApi, GlContext, NativeDisplay, PlayerGLContext}; -use std::sync::{Arc, Mutex}; use webrender_traits::{ WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageSource, }; +pub use crate::media_channel::glplayer_channel; +use crate::media_channel::{GLPlayerChan, GLPlayerPipeline, GLPlayerReceiver, GLPlayerSender}; +use crate::media_thread::GLPlayerThread; + /// These are the messages that the GLPlayer thread will forward to /// the video player which lives in htmlmediaelement #[derive(Debug, Deserialize, Serialize)] diff --git a/components/media/media_channel/ipc.rs b/components/media/media_channel/ipc.rs index 67548a8ddce..a66c697d382 100644 --- a/components/media/media_channel/ipc.rs +++ b/components/media/media_channel/ipc.rs @@ -2,9 +2,10 @@ * 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 serde::{Deserialize, Serialize}; use std::io; +use serde::{Deserialize, Serialize}; + pub type GLPlayerSender<T> = ipc_channel::ipc::IpcSender<T>; pub type GLPlayerReceiver<T> = ipc_channel::ipc::IpcReceiver<T>; diff --git a/components/media/media_channel/mod.rs b/components/media/media_channel/mod.rs index 8997aafce63..21586e0456e 100644 --- a/components/media/media_channel/mod.rs +++ b/components/media/media_channel/mod.rs @@ -7,11 +7,13 @@ mod ipc; mod mpsc; -use crate::GLPlayerMsg; +use std::fmt; + use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use servo_config::opts; -use std::fmt; + +use crate::GLPlayerMsg; lazy_static! { static ref IS_MULTIPROCESS: bool = opts::multiprocess(); diff --git a/components/media/media_channel/mpsc.rs b/components/media/media_channel/mpsc.rs index 8651258c65a..3d5fa61b10b 100644 --- a/components/media/media_channel/mpsc.rs +++ b/components/media/media_channel/mpsc.rs @@ -2,10 +2,10 @@ * 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 serde::{Deserialize, Serialize}; -use serde::{Deserializer, Serializer}; use std::sync::mpsc; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + macro_rules! unreachable_serializable { ($name:ident) => { impl<T> Serialize for $name<T> { diff --git a/components/media/media_thread.rs b/components/media/media_thread.rs index 482762cf607..c6cf45dbe2d 100644 --- a/components/media/media_thread.rs +++ b/components/media/media_thread.rs @@ -2,17 +2,19 @@ * 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::media_channel::{glplayer_channel, GLPlayerSender}; -/// GL player threading API entry point that lives in the -/// constellation. -use crate::{GLPlayerMsg, GLPlayerMsgForward}; -use fnv::FnvHashMap; -use log::{trace, warn}; use std::sync::{Arc, Mutex}; use std::thread; + +use fnv::FnvHashMap; +use log::{trace, warn}; use webrender_api::ExternalImageId; use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType}; +use crate::media_channel::{glplayer_channel, GLPlayerSender}; +/// GL player threading API entry point that lives in the +/// constellation. +use crate::{GLPlayerMsg, GLPlayerMsgForward}; + /// A GLPlayerThread manages the life cycle and message demultiplexing of /// a set of video players with GL render. pub struct GLPlayerThread { diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs index 2d6d1186b83..8393ba36d44 100644 --- a/components/metrics/lib.rs +++ b/components/metrics/lib.rs @@ -2,19 +2,19 @@ * 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::{Cell, RefCell}; +use std::cmp::Ordering; +use std::collections::HashMap; + use gfx_traits::Epoch; use ipc_channel::ipc::IpcSender; use log::warn; use malloc_size_of_derive::MallocSizeOf; use msg::constellation_msg::PipelineId; -use profile_traits::time::TimerMetadata; -use profile_traits::time::{send_profile_data, ProfilerCategory, ProfilerChan}; +use profile_traits::time::{send_profile_data, ProfilerCategory, ProfilerChan, TimerMetadata}; use script_traits::{ConstellationControlMsg, LayoutMsg, ProgressiveWebMetricType}; use servo_config::opts; use servo_url::ServoUrl; -use std::cell::{Cell, RefCell}; -use std::cmp::Ordering; -use std::collections::HashMap; use time::precise_time_ns; pub trait ProfilerMetadataFactory { diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 8f2a04b8cc1..335fffe5f62 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -5,6 +5,12 @@ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling between these two components. +use std::cell::Cell; +use std::num::NonZeroU32; +use std::sync::Arc; +use std::time::Duration; +use std::{fmt, mem}; + use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use lazy_static::lazy_static; use malloc_size_of::malloc_size_of_is_0; @@ -12,14 +18,7 @@ use malloc_size_of_derive::MallocSizeOf; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use size_of_test::size_of_test; -use std::cell::Cell; -use std::fmt; -use std::mem; -use std::num::NonZeroU32; -use std::sync::Arc; -use std::time::Duration; -use webrender_api::ExternalScrollId; -use webrender_api::PipelineId as WebRenderPipelineId; +use webrender_api::{ExternalScrollId, PipelineId as WebRenderPipelineId}; macro_rules! namespace_id_method { ($func_name:ident, $func_return_data_type:ident, $self:ident, $index_name:ident) => { diff --git a/components/net/connector.rs b/components/net/connector.rs index 683cd58f176..103b3ee263b 100644 --- a/components/net/connector.rs +++ b/components/net/connector.rs @@ -2,20 +2,24 @@ * 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::hosts::replace_host; -use crate::http_loader::HANDLE; -use futures::{task::Context, task::Poll, Future}; +use std::collections::hash_map::HashMap; +use std::convert::TryFrom; +use std::sync::{Arc, Mutex}; + +use futures::task::{Context, Poll}; +use futures::Future; use http::uri::{Authority, Uri as Destination}; use hyper::client::HttpConnector as HyperHttpConnector; use hyper::rt::Executor; -use hyper::{service::Service, Body, Client}; +use hyper::service::Service; +use hyper::{Body, Client}; use hyper_rustls::HttpsConnector as HyperRustlsHttpsConnector; use log::warn; use rustls::client::WebPkiVerifier; use rustls::{Certificate, ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName}; -use std::collections::hash_map::HashMap; -use std::convert::TryFrom; -use std::sync::{Arc, Mutex}; + +use crate::hosts::replace_host; +use crate::http_loader::HANDLE; pub const BUF_SIZE: usize = 32768; diff --git a/components/net/cookie.rs b/components/net/cookie.rs index 804bdf4e4fa..d65c98daf18 100644 --- a/components/net/cookie.rs +++ b/components/net/cookie.rs @@ -5,13 +5,14 @@ //! Implementation of cookie creation and matching as specified by //! http://tools.ietf.org/html/rfc6265 +use std::borrow::ToOwned; +use std::net::{Ipv4Addr, Ipv6Addr}; + use hyper_serde::Serde; use net_traits::pub_domains::is_pub_domain; use net_traits::CookieSource; use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::borrow::ToOwned; -use std::net::{Ipv4Addr, Ipv6Addr}; use time::{at, now, Duration, Tm}; /// A stored cookie that wraps the definition in cookie-rs. This is used to implement diff --git a/components/net/cookie_storage.rs b/components/net/cookie_storage.rs index 16508de4d17..e1ee56e0967 100644 --- a/components/net/cookie_storage.rs +++ b/components/net/cookie_storage.rs @@ -5,17 +5,19 @@ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 -use crate::cookie::Cookie; +use std::cmp::Ordering; +use std::collections::hash_map::Entry; +use std::collections::HashMap; + use log::{debug, info}; use net_traits::pub_domains::reg_suffix; use net_traits::CookieSource; use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::cmp::Ordering; -use std::collections::hash_map::Entry; -use std::collections::HashMap; use time::{self, Tm}; +use crate::cookie::Cookie; + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CookieStorage { version: u32, diff --git a/components/net/decoder.rs b/components/net/decoder.rs index d151e08ceec..175ca401281 100644 --- a/components/net/decoder.rs +++ b/components/net/decoder.rs @@ -27,21 +27,22 @@ The following types directly support the gzip compression case: - `Peeked` is a buffer that keeps a few bytes available so `libflate`s `read_exact` calls won't fail */ -use crate::connector::BUF_SIZE; +use std::io::{self, Read}; +use std::pin::Pin; +use std::sync::{Arc, Mutex}; +use std::task::Waker; +use std::{cmp, fmt, mem}; + use brotli::Decompressor; use bytes::{Buf, BufMut, Bytes, BytesMut}; use flate2::read::DeflateDecoder; -use futures::{task::Context, task::Poll, Future, Stream}; +use futures::task::{Context, Poll}; +use futures::{Future, Stream}; use hyper::header::{HeaderValue, CONTENT_ENCODING, TRANSFER_ENCODING}; use hyper::{self, Body, Response}; use libflate::non_blocking::gzip; -use std::cmp; -use std::fmt; -use std::io::{self, Read}; -use std::mem; -use std::pin::Pin; -use std::sync::{Arc, Mutex}; -use std::task::Waker; + +use crate::connector::BUF_SIZE; #[derive(Debug)] pub enum Error { diff --git a/components/net/fetch/headers.rs b/components/net/fetch/headers.rs index 54fbe636f6f..3a29f841d64 100644 --- a/components/net/fetch/headers.rs +++ b/components/net/fetch/headers.rs @@ -2,11 +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 headers::HeaderMap; -use net_traits::fetch::headers::get_value_from_header_list; use std::iter::Peekable; use std::str::Chars; +use headers::HeaderMap; +use net_traits::fetch::headers::get_value_from_header_list; + /// <https://fetch.spec.whatwg.org/#http-tab-or-space> const HTTP_TAB_OR_SPACE: &[char] = &['\u{0009}', '\u{0020}']; diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 1cac2297921..5c5f6942f54 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -2,21 +2,22 @@ * 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::data_loader::decode; -use crate::fetch::cors_cache::CorsCache; -use crate::fetch::headers::determine_nosniff; -use crate::filemanager_thread::{FileManager, FILE_CHUNK_SIZE}; -use crate::http_loader::{determine_requests_referrer, http_fetch, HttpState}; -use crate::http_loader::{set_default_accept, set_default_accept_language}; -use crate::subresource_integrity::is_response_integrity_valid; -use base64::{engine::general_purpose, Engine as _}; +use std::borrow::Cow; +use std::fs::File; +use std::io::{self, BufReader, Seek, SeekFrom}; +use std::ops::Bound; +use std::sync::atomic::Ordering; +use std::sync::{Arc, Mutex}; +use std::{mem, str}; + +use base64::engine::general_purpose; +use base64::Engine as _; use content_security_policy as csp; use crossbeam_channel::Sender; use devtools_traits::DevtoolsControlMsg; use headers::{AccessControlExposeHeaders, ContentType, HeaderMapExt, Range}; use http::header::{self, HeaderMap, HeaderName}; -use http::Method; -use http::StatusCode; +use http::{Method, StatusCode}; use ipc_channel::ipc::{self, IpcReceiver}; use lazy_static::lazy_static; use log::{debug, warn}; @@ -24,31 +25,33 @@ use mime::{self, Mime}; use net_traits::blob_url_store::{parse_blob_url, BlobURLStoreError}; use net_traits::filemanager_thread::{FileTokenCheck, RelativePos}; use net_traits::request::{ - is_cors_safelisted_method, is_cors_safelisted_request_header, Origin, ResponseTainting, Window, -}; -use net_traits::request::{ - BodyChunkRequest, BodyChunkResponse, CredentialsMode, Destination, Referrer, Request, - RequestMode, + is_cors_safelisted_method, is_cors_safelisted_request_header, BodyChunkRequest, + BodyChunkResponse, CredentialsMode, Destination, Origin, Referrer, Request, RequestMode, + ResponseTainting, Window, }; use net_traits::response::{Response, ResponseBody, ResponseType}; -use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceFetchTiming}; -use net_traits::{ResourceAttribute, ResourceTimeValue, ResourceTimingType}; +use net_traits::{ + FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceAttribute, ResourceFetchTiming, + ResourceTimeValue, ResourceTimingType, +}; use rustls::Certificate; use serde::{Deserialize, Serialize}; use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; -use std::borrow::Cow; -use std::fs::File; -use std::io::{self, BufReader, Seek, SeekFrom}; -use std::mem; -use std::ops::Bound; -use std::str; -use std::sync::atomic::Ordering; -use std::sync::{Arc, Mutex}; use tokio::sync::mpsc::{ unbounded_channel, UnboundedReceiver as TokioReceiver, UnboundedSender as TokioSender, }; +use crate::data_loader::decode; +use crate::fetch::cors_cache::CorsCache; +use crate::fetch::headers::determine_nosniff; +use crate::filemanager_thread::{FileManager, FILE_CHUNK_SIZE}; +use crate::http_loader::{ + determine_requests_referrer, http_fetch, set_default_accept, set_default_accept_language, + HttpState, +}; +use crate::subresource_integrity::is_response_integrity_valid; + lazy_static! { static ref X_CONTENT_TYPE_OPTIONS: HeaderName = HeaderName::from_static("x-content-type-options"); diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs index db4ce200bdd..90af2f37c87 100644 --- a/components/net/filemanager_thread.rs +++ b/components/net/filemanager_thread.rs @@ -2,8 +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 crate::fetch::methods::{CancellationListener, Data, RangeRequestBounds}; -use crate::resource_thread::CoreResourceThreadPool; +use std::collections::{HashMap, HashSet}; +use std::fs::File; +use std::io::{BufRead, BufReader, Read, Seek, SeekFrom}; +use std::mem; +use std::ops::Index; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, RwLock, Weak}; + use embedder_traits::{EmbedderMsg, EmbedderProxy, FilterPattern}; use headers::{ContentLength, ContentType, HeaderMap, HeaderMapExt}; use http::header::{self, HeaderValue}; @@ -12,27 +19,20 @@ use log::warn; use mime::{self, Mime}; use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError}; use net_traits::filemanager_thread::{ - FileManagerResult, FileManagerThreadMsg, FileOrigin, FileTokenCheck, -}; -use net_traits::filemanager_thread::{ - FileManagerThreadError, ReadFileProgress, RelativePos, SelectedFile, + FileManagerResult, FileManagerThreadError, FileManagerThreadMsg, FileOrigin, FileTokenCheck, + ReadFileProgress, RelativePos, SelectedFile, }; use net_traits::http_percent_encode; use net_traits::response::{Response, ResponseBody}; use servo_arc::Arc as ServoArc; use servo_config::pref; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::{BufRead, BufReader, Read, Seek, SeekFrom}; -use std::mem; -use std::ops::Index; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex, RwLock, Weak}; use tokio::sync::mpsc::UnboundedSender as TokioSender; use url::Url; use uuid::Uuid; +use crate::fetch::methods::{CancellationListener, Data, RangeRequestBounds}; +use crate::resource_thread::CoreResourceThreadPool; + pub const FILE_CHUNK_SIZE: usize = 32768; //32 KB /// FileManagerStore's entry diff --git a/components/net/hosts.rs b/components/net/hosts.rs index 7f869c30fb7..8261c91415c 100644 --- a/components/net/hosts.rs +++ b/components/net/hosts.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 lazy_static::lazy_static; use std::borrow::Cow; use std::collections::HashMap; use std::env; @@ -11,6 +10,8 @@ use std::io::{BufReader, Read}; use std::net::{IpAddr, Ipv4Addr}; use std::sync::Mutex; +use lazy_static::lazy_static; + lazy_static! { static ref HOST_TABLE: Mutex<Option<HashMap<String, IpAddr>>> = Mutex::new(create_host_table()); } diff --git a/components/net/hsts.rs b/components/net/hsts.rs index 4ebe0262064..681e754fd76 100644 --- a/components/net/hsts.rs +++ b/components/net/hsts.rs @@ -2,6 +2,9 @@ * 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::collections::HashMap; +use std::net::{Ipv4Addr, Ipv6Addr}; + use embedder_traits::resources::{self, Resource}; use headers::{HeaderMapExt, StrictTransportSecurity}; use http::HeaderMap; @@ -11,8 +14,6 @@ use net_traits::IncludeSubdomains; use serde::{Deserialize, Serialize}; use servo_config::pref; use servo_url::{Host, ServoUrl}; -use std::collections::HashMap; -use std::net::{Ipv4Addr, Ipv6Addr}; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct HstsEntry { diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs index 09aabc473e3..11d83fe1644 100644 --- a/components/net/http_cache.rs +++ b/components/net/http_cache.rs @@ -7,16 +7,21 @@ //! A memory cache implementing the logic specified in <http://tools.ietf.org/html/rfc7234> //! and <http://tools.ietf.org/html/rfc7232>. -use crate::fetch::methods::{Data, DoneChannel}; +use std::collections::HashMap; +use std::ops::Bound; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Mutex; +use std::time::SystemTime; + use headers::{ CacheControl, ContentRange, Expires, HeaderMapExt, LastModified, Pragma, Range, Vary, }; use http::header::HeaderValue; use http::{header, HeaderMap, Method, StatusCode}; use log::debug; -use malloc_size_of::Measurable; use malloc_size_of::{ MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf, MallocUnconditionalSizeOf, + Measurable, }; use malloc_size_of_derive::MallocSizeOf; use net_traits::request::Request; @@ -25,14 +30,11 @@ use net_traits::{FetchMetadata, Metadata, ResourceFetchTiming}; use servo_arc::Arc; use servo_config::pref; use servo_url::ServoUrl; -use std::collections::HashMap; -use std::ops::Bound; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Mutex; -use std::time::SystemTime; use time::{Duration, Timespec, Tm}; use tokio::sync::mpsc::{unbounded_channel as unbounded, UnboundedSender as TokioSender}; +use crate::fetch::methods::{Data, DoneChannel}; + /// The key used to differentiate requests in the cache. #[derive(Clone, Eq, Hash, MallocSizeOf, PartialEq)] pub struct CacheKey { diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 188038ccc38..79b2c63dc44 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -2,35 +2,28 @@ * 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::connector::{ - create_http_client, create_tls_config, CACertificates, CertificateErrorOverrideManager, - Connector, -}; -use crate::cookie; -use crate::cookie_storage::CookieStorage; -use crate::decoder::Decoder; -use crate::fetch::cors_cache::CorsCache; -use crate::fetch::methods::{main_fetch, Data, DoneChannel, FetchContext, Target}; -use crate::hsts::HstsList; -use crate::http_cache::{CacheKey, HttpCache}; -use crate::resource_thread::AuthCache; -use async_recursion::async_recursion; use core::convert::Infallible; +use std::collections::{HashMap, HashSet}; +use std::iter::FromIterator; +use std::mem; +use std::ops::Deref; +use std::sync::{Arc as StdArc, Condvar, Mutex, RwLock}; +use std::time::{Duration, SystemTime}; + +use async_recursion::async_recursion; use crossbeam_channel::Sender; use devtools_traits::{ ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest, + HttpResponse as DevtoolsHttpResponse, NetworkEvent, }; -use devtools_traits::{HttpResponse as DevtoolsHttpResponse, NetworkEvent}; use futures::{future, StreamExt, TryFutureExt, TryStreamExt}; use headers::authorization::Basic; -use headers::{AccessControlAllowCredentials, AccessControlAllowHeaders, HeaderMapExt}; use headers::{ - AccessControlAllowMethods, AccessControlRequestHeaders, AccessControlRequestMethod, - Authorization, + AccessControlAllowCredentials, AccessControlAllowHeaders, AccessControlAllowMethods, + AccessControlAllowOrigin, AccessControlMaxAge, AccessControlRequestHeaders, + AccessControlRequestMethod, Authorization, CacheControl, ContentEncoding, ContentLength, + HeaderMapExt, IfModifiedSince, LastModified, Origin as HyperOrigin, Pragma, Referer, UserAgent, }; -use headers::{AccessControlAllowOrigin, AccessControlMaxAge}; -use headers::{CacheControl, ContentEncoding, ContentLength}; -use headers::{IfModifiedSince, LastModified, Origin as HyperOrigin, Pragma, Referer, UserAgent}; use http::header::{ self, HeaderValue, ACCEPT, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LOCATION, CONTENT_TYPE, }; @@ -48,27 +41,17 @@ use net_traits::quality::{quality_to_value, Quality, QualityItem}; use net_traits::request::Origin::Origin as SpecificOrigin; use net_traits::request::{ get_cors_unsafe_header_names, is_cors_non_wildcard_request_header_name, - is_cors_safelisted_method, is_cors_safelisted_request_header, + is_cors_safelisted_method, is_cors_safelisted_request_header, BodyChunkRequest, + BodyChunkResponse, CacheMode, CredentialsMode, Destination, Origin, RedirectMode, Referrer, + Request, RequestBuilder, RequestMode, ResponseTainting, ServiceWorkersMode, }; -use net_traits::request::{ - BodyChunkRequest, BodyChunkResponse, RedirectMode, Referrer, Request, RequestBuilder, - RequestMode, -}; -use net_traits::request::{CacheMode, CredentialsMode, Destination, Origin}; -use net_traits::request::{ResponseTainting, ServiceWorkersMode}; use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType}; -use net_traits::{CookieSource, FetchMetadata, NetworkError, ReferrerPolicy}; use net_traits::{ - RedirectEndValue, RedirectStartValue, ResourceAttribute, ResourceFetchTiming, ResourceTimeValue, + CookieSource, FetchMetadata, NetworkError, RedirectEndValue, RedirectStartValue, + ReferrerPolicy, ResourceAttribute, ResourceFetchTiming, ResourceTimeValue, }; use servo_arc::Arc; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::collections::{HashMap, HashSet}; -use std::iter::FromIterator; -use std::mem; -use std::ops::Deref; -use std::sync::{Arc as StdArc, Condvar, Mutex, RwLock}; -use std::time::{Duration, SystemTime}; use time::{self, Tm}; use tokio::runtime::Runtime; use tokio::sync::mpsc::{ @@ -77,6 +60,19 @@ use tokio::sync::mpsc::{ }; use tokio_stream::wrappers::ReceiverStream; +use crate::connector::{ + create_http_client, create_tls_config, CACertificates, CertificateErrorOverrideManager, + Connector, +}; +use crate::cookie; +use crate::cookie_storage::CookieStorage; +use crate::decoder::Decoder; +use crate::fetch::cors_cache::CorsCache; +use crate::fetch::methods::{main_fetch, Data, DoneChannel, FetchContext, Target}; +use crate::hsts::HstsList; +use crate::http_cache::{CacheKey, HttpCache}; +use crate::resource_thread::AuthCache; + lazy_static! { pub static ref HANDLE: Mutex<Option<Runtime>> = Mutex::new(Some(Runtime::new().unwrap())); } diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs index 22c5179ff7c..36750205053 100644 --- a/components/net/image_cache.rs +++ b/components/net/image_cache.rs @@ -2,30 +2,28 @@ * 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::collections::hash_map::Entry::{Occupied, Vacant}; +use std::collections::HashMap; +use std::sync::{Arc, Mutex}; +use std::{mem, thread}; + use embedder_traits::resources::{self, Resource}; use imsz::imsz_from_reader; use ipc_channel::ipc::IpcSender; use log::{debug, warn}; use net_traits::image::base::{load_from_memory, Image, ImageMetadata}; use net_traits::image_cache::{ - CorsStatus, ImageCache, ImageCacheResult, ImageResponder, PendingImageResponse, + CorsStatus, ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponder, + ImageResponse, PendingImageId, PendingImageResponse, UsePlaceholder, }; -use net_traits::image_cache::{ImageOrMetadataAvailable, ImageResponse}; -use net_traits::image_cache::{PendingImageId, UsePlaceholder}; use net_traits::request::CorsSettings; use net_traits::{ FetchMetadata, FetchResponseMsg, FilteredMetadata, NetworkError, WebrenderIpcSender, }; use pixels::PixelFormat; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::collections::HashMap; -use std::mem; -use std::sync::{Arc, Mutex}; -use std::thread; -use webrender_api::{ - units::DeviceIntSize, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, -}; +use webrender_api::units::DeviceIntSize; +use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat}; /// /// TODO(gw): Remaining work on image cache: diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index aa3f342cea1..642b158260d 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -4,19 +4,17 @@ //! A thread that takes a URL and streams back the binary data. -use crate::connector::{ - create_http_client, create_tls_config, CACertificates, CertificateErrorOverrideManager, -}; -use crate::cookie; -use crate::cookie_storage::CookieStorage; -use crate::fetch::cors_cache::CorsCache; -use crate::fetch::methods::{fetch, CancellationListener, FetchContext}; -use crate::filemanager_thread::FileManager; -use crate::hsts::HstsList; -use crate::http_cache::HttpCache; -use crate::http_loader::{http_redirect_fetch, HttpState, HANDLE}; -use crate::storage_thread::StorageThreadFactory; -use crate::websocket_loader; +use std::borrow::{Cow, ToOwned}; +use std::collections::HashMap; +use std::fs::File; +use std::io::prelude::*; +use std::io::{self, BufReader}; +use std::ops::Deref; +use std::path::{Path, PathBuf}; +use std::sync::{Arc, Mutex, RwLock}; +use std::thread; +use std::time::Duration; + use crossbeam_channel::Sender; use devtools_traits::DevtoolsControlMsg; use embedder_traits::EmbedderProxy; @@ -29,30 +27,31 @@ use net_traits::filemanager_thread::FileTokenCheck; use net_traits::request::{Destination, RequestBuilder}; use net_traits::response::{Response, ResponseInit}; use net_traits::storage_thread::StorageThreadMsg; -use net_traits::DiscardFetch; -use net_traits::FetchTaskTarget; -use net_traits::WebSocketNetworkEvent; -use net_traits::{CookieSource, CoreResourceMsg, CoreResourceThread}; -use net_traits::{CustomResponseMediator, FetchChannels}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use net_traits::{ResourceThreads, WebSocketDomAction}; -use profile_traits::mem::ProfilerChan as MemProfilerChan; -use profile_traits::mem::{Report, ReportKind, ReportsChan}; +use net_traits::{ + CookieSource, CoreResourceMsg, CoreResourceThread, CustomResponseMediator, DiscardFetch, + FetchChannels, FetchTaskTarget, ResourceFetchTiming, ResourceThreads, ResourceTimingType, + WebSocketDomAction, WebSocketNetworkEvent, +}; +use profile_traits::mem::{ProfilerChan as MemProfilerChan, Report, ReportKind, ReportsChan}; use profile_traits::path; use profile_traits::time::ProfilerChan; use rustls::RootCertStore; use serde::{Deserialize, Serialize}; use servo_arc::Arc as ServoArc; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::borrow::{Cow, ToOwned}; -use std::collections::HashMap; -use std::fs::File; -use std::io::{self, prelude::*, BufReader}; -use std::ops::Deref; -use std::path::{Path, PathBuf}; -use std::sync::{Arc, Mutex, RwLock}; -use std::thread; -use std::time::Duration; + +use crate::connector::{ + create_http_client, create_tls_config, CACertificates, CertificateErrorOverrideManager, +}; +use crate::cookie_storage::CookieStorage; +use crate::fetch::cors_cache::CorsCache; +use crate::fetch::methods::{fetch, CancellationListener, FetchContext}; +use crate::filemanager_thread::FileManager; +use crate::hsts::HstsList; +use crate::http_cache::HttpCache; +use crate::http_loader::{http_redirect_fetch, HttpState, HANDLE}; +use crate::storage_thread::StorageThreadFactory; +use crate::{cookie, websocket_loader}; /// Load a file with CA certificate and produce a RootCertStore with the results. fn load_root_cert_store_from_file(file_path: String) -> io::Result<RootCertStore> { diff --git a/components/net/storage_thread.rs b/components/net/storage_thread.rs index cd066eef9a0..07516540db9 100644 --- a/components/net/storage_thread.rs +++ b/components/net/storage_thread.rs @@ -2,16 +2,17 @@ * 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::resource_thread; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use net_traits::storage_thread::{StorageThreadMsg, StorageType}; -use servo_url::ServoUrl; use std::borrow::ToOwned; -use std::collections::BTreeMap; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::path::PathBuf; use std::thread; +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use net_traits::storage_thread::{StorageThreadMsg, StorageType}; +use servo_url::ServoUrl; + +use crate::resource_thread; + const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024; pub trait StorageThreadFactory { diff --git a/components/net/subresource_integrity.rs b/components/net/subresource_integrity.rs index b0c8a431972..23604d98907 100644 --- a/components/net/subresource_integrity.rs +++ b/components/net/subresource_integrity.rs @@ -2,13 +2,14 @@ * 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::iter::Filter; +use std::str::Split; +use std::sync::MutexGuard; + use base64::Engine; use generic_array::ArrayLength; use net_traits::response::{Response, ResponseBody, ResponseType}; use sha2::{Digest, Sha256, Sha384, Sha512}; -use std::iter::Filter; -use std::str::Split; -use std::sync::MutexGuard; const SUPPORTED_ALGORITHM: &'static [&'static str] = &["sha256", "sha384", "sha512"]; pub type StaticCharVec = &'static [char]; diff --git a/components/net/tests/data_loader.rs b/components/net/tests/data_loader.rs index 9490c818384..198fe19709c 100644 --- a/components/net/tests/data_loader.rs +++ b/components/net/tests/data_loader.rs @@ -2,7 +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 crate::fetch; +use std::ops::Deref; + use headers::{ContentType, HeaderMapExt}; use hyper_serde::Serde; use mime::{self, Mime}; @@ -10,7 +11,8 @@ use net_traits::request::{Origin, Referrer, Request}; use net_traits::response::{HttpsState, ResponseBody}; use net_traits::{FetchMetadata, FilteredMetadata, NetworkError}; use servo_url::ServoUrl; -use std::ops::Deref; + +use crate::fetch; #[cfg(test)] fn assert_parse( diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs index b5c34a91f3b..ab05a954e9e 100644 --- a/components/net/tests/fetch.rs +++ b/components/net/tests/fetch.rs @@ -4,24 +4,23 @@ #![cfg(not(target_os = "windows"))] -use crate::fetch_with_context; -use crate::fetch_with_cors_cache; -use crate::http_loader::{expect_devtools_http_request, expect_devtools_http_response}; -use crate::{ - create_embedder_proxy, fetch, make_server, make_ssl_server, new_fetch_context, - DEFAULT_USER_AGENT, -}; +use std::fs; +use std::iter::FromIterator; +use std::path::Path; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, Weak}; +use std::time::{Duration, SystemTime}; + use crossbeam_channel::{unbounded, Sender}; -use devtools_traits::HttpRequest as DevtoolsHttpRequest; -use devtools_traits::HttpResponse as DevtoolsHttpResponse; -use headers::StrictTransportSecurity; -use headers::{AccessControlAllowCredentials, AccessControlAllowHeaders, AccessControlAllowOrigin}; -use headers::{AccessControlAllowMethods, AccessControlMaxAge, HeaderMapExt}; -use headers::{CacheControl, ContentLength, ContentType, Expires, LastModified, Pragma, UserAgent}; +use devtools_traits::{HttpRequest as DevtoolsHttpRequest, HttpResponse as DevtoolsHttpResponse}; +use headers::{ + AccessControlAllowCredentials, AccessControlAllowHeaders, AccessControlAllowMethods, + AccessControlAllowOrigin, AccessControlMaxAge, CacheControl, ContentLength, ContentType, + Expires, HeaderMapExt, LastModified, Pragma, StrictTransportSecurity, UserAgent, +}; use http::header::{self, HeaderMap, HeaderName, HeaderValue}; use http::{Method, StatusCode}; -use hyper::Body; -use hyper::{Request as HyperRequest, Response as HyperResponse}; +use hyper::{Body, Request as HyperRequest, Response as HyperResponse}; use mime::{self, Mime}; use msg::constellation_msg::TEST_PIPELINE_ID; use net::fetch::cors_cache::CorsCache; @@ -41,15 +40,15 @@ use net_traits::{ }; use servo_arc::Arc as ServoArc; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::fs; -use std::iter::FromIterator; -use std::path::Path; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex, Weak}; -use std::time::{Duration, SystemTime}; use tokio_test::block_on; use uuid::Uuid; +use crate::http_loader::{expect_devtools_http_request, expect_devtools_http_response}; +use crate::{ + create_embedder_proxy, fetch, fetch_with_context, fetch_with_cors_cache, make_server, + make_ssl_server, new_fetch_context, DEFAULT_USER_AGENT, +}; + // TODO write a struct that impls Handler for storing test values #[test] diff --git a/components/net/tests/file_loader.rs b/components/net/tests/file_loader.rs index f37a90dabcd..0dbf8303318 100644 --- a/components/net/tests/file_loader.rs +++ b/components/net/tests/file_loader.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::env; + use url::Url; #[test] diff --git a/components/net/tests/filemanager_thread.rs b/components/net/tests/filemanager_thread.rs index 3cda5a2f2d1..8cead55ba53 100644 --- a/components/net/tests/filemanager_thread.rs +++ b/components/net/tests/filemanager_thread.rs @@ -2,7 +2,11 @@ * 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::create_embedder_proxy; +use std::fs::File; +use std::io::Read; +use std::path::PathBuf; +use std::sync::Arc; + use embedder_traits::FilterPattern; use ipc_channel::ipc; use net::filemanager_thread::FileManager; @@ -12,10 +16,8 @@ use net_traits::filemanager_thread::{ FileManagerThreadError, FileManagerThreadMsg, ReadFileProgress, }; use servo_config::set_pref; -use std::fs::File; -use std::io::Read; -use std::path::PathBuf; -use std::sync::Arc; + +use crate::create_embedder_proxy; #[test] fn test_filemanager() { diff --git a/components/net/tests/hsts.rs b/components/net/tests/hsts.rs index 044287da159..a3bebb67fcf 100644 --- a/components/net/tests/hsts.rs +++ b/components/net/tests/hsts.rs @@ -2,9 +2,10 @@ * 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::collections::HashMap; + use net::hsts::{HstsEntry, HstsList}; use net_traits::IncludeSubdomains; -use std::collections::HashMap; #[test] fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() { diff --git a/components/net/tests/http_loader.rs b/components/net/tests/http_loader.rs index e84b0ec3fc5..b60ac325d0a 100644 --- a/components/net/tests/http_loader.rs +++ b/components/net/tests/http_loader.rs @@ -4,15 +4,19 @@ #![cfg(not(target_os = "windows"))] -use crate::fetch; -use crate::fetch_with_context; -use crate::make_server; -use crate::new_fetch_context; +use std::collections::HashMap; +use std::io::Write; +use std::str; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex, RwLock}; +use std::time::Duration; + use cookie_rs::Cookie as CookiePair; use crossbeam_channel::{unbounded, Receiver}; -use devtools_traits::HttpRequest as DevtoolsHttpRequest; -use devtools_traits::HttpResponse as DevtoolsHttpResponse; -use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, NetworkEvent}; +use devtools_traits::{ + ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest, + HttpResponse as DevtoolsHttpResponse, NetworkEvent, +}; use flate2::write::{DeflateEncoder, GzEncoder}; use flate2::Compression; use headers::authorization::Basic; @@ -22,8 +26,7 @@ use headers::{ use http::header::{self, HeaderMap, HeaderValue}; use http::uri::Authority; use http::{Method, StatusCode}; -use hyper::Body; -use hyper::{Request as HyperRequest, Response as HyperResponse}; +use hyper::{Body, Request as HyperRequest, Response as HyperResponse}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use msg::constellation_msg::TEST_PIPELINE_ID; @@ -39,12 +42,8 @@ use net_traits::request::{ use net_traits::response::ResponseBody; use net_traits::{CookieSource, NetworkError, ReferrerPolicy}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::collections::HashMap; -use std::io::Write; -use std::str; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex, RwLock}; -use std::time::Duration; + +use crate::{fetch, fetch_with_context, make_server, new_fetch_context}; fn mock_origin() -> ImmutableOrigin { ServoUrl::parse("http://servo.org").unwrap().origin() diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index 675dc4ec7af..c5eb5c7b6ff 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -19,6 +19,12 @@ mod resource_thread; mod subresource_integrity; use core::convert::Infallible; +use std::fs::File; +use std::io::{self, BufReader}; +use std::net::TcpListener as StdTcpListener; +use std::path::{Path, PathBuf}; +use std::sync::{Arc, Mutex, Weak}; + use crossbeam_channel::{unbounded, Sender}; use devtools_traits::DevtoolsControlMsg; use embedder_traits::{EmbedderProxy, EventLoopWaker}; @@ -42,13 +48,7 @@ use rustls::{self, Certificate, PrivateKey}; use rustls_pemfile::{certs, pkcs8_private_keys}; use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; -use std::fs::File; -use std::io::{self, BufReader}; -use std::net::TcpListener as StdTcpListener; -use std::path::{Path, PathBuf}; -use std::sync::{Arc, Mutex, Weak}; -use tokio::net::TcpListener; -use tokio::net::TcpStream; +use tokio::net::{TcpListener, TcpStream}; use tokio::runtime::{Builder, Runtime}; use tokio_rustls::{self, TlsAcceptor}; use tokio_stream::wrappers::TcpListenerStream; diff --git a/components/net/tests/mime_classifier.rs b/components/net/tests/mime_classifier.rs index 0fac4a027e2..7301673ce16 100644 --- a/components/net/tests/mime_classifier.rs +++ b/components/net/tests/mime_classifier.rs @@ -2,14 +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 mime::{self, Mime}; -use net::mime_classifier::{ApacheBugFlag, MimeClassifier, Mp4Matcher, NoSniffFlag}; -use net_traits::LoadContext; use std::env; use std::fs::File; use std::io::{self, Read}; use std::path::{self, PathBuf}; +use mime::{self, Mime}; +use net::mime_classifier::{ApacheBugFlag, MimeClassifier, Mp4Matcher, NoSniffFlag}; +use net_traits::LoadContext; + fn read_file(path: &path::Path) -> io::Result<Vec<u8>> { let mut file = File::open(path)?; let mut buffer = Vec::new(); diff --git a/components/net/tests/resource_thread.rs b/components/net/tests/resource_thread.rs index 11aac7efc49..9a32143d715 100644 --- a/components/net/tests/resource_thread.rs +++ b/components/net/tests/resource_thread.rs @@ -2,7 +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 crate::create_embedder_proxy; +use std::net::IpAddr; + use ipc_channel::ipc; use net::connector::CACertificates; use net::resource_thread::new_core_resource_thread; @@ -10,7 +11,8 @@ use net::test::parse_hostsfile; use net_traits::CoreResourceMsg; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan; -use std::net::IpAddr; + +use crate::create_embedder_proxy; fn ip(s: &str) -> IpAddr { s.parse().unwrap() diff --git a/components/net/tests/subresource_integrity.rs b/components/net/tests/subresource_integrity.rs index ff6ca3d67ad..b6063a7528d 100644 --- a/components/net/tests/subresource_integrity.rs +++ b/components/net/tests/subresource_integrity.rs @@ -2,8 +2,10 @@ * 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 net::subresource_integrity::{get_prioritized_hash_function, get_strongest_metadata, SriEntry}; -use net::subresource_integrity::{is_response_integrity_valid, parsed_metadata}; +use net::subresource_integrity::{ + get_prioritized_hash_function, get_strongest_metadata, is_response_integrity_valid, + parsed_metadata, SriEntry, +}; use net_traits::response::{Response, ResponseBody}; use net_traits::{ResourceFetchTiming, ResourceTimingType}; use servo_url::ServoUrl; diff --git a/components/net/websocket_loader.rs b/components/net/websocket_loader.rs index af2e9565eba..6ac7c99b6e1 100644 --- a/components/net/websocket_loader.rs +++ b/components/net/websocket_loader.rs @@ -11,11 +11,9 @@ //! over events from the network and events from the DOM, using async/await to avoid //! the need for a dedicated thread per websocket. -use crate::connector::{create_tls_config, CACertificates, TlsConfig}; -use crate::cookie::Cookie; -use crate::fetch::methods::should_be_blocked_due_to_bad_port; -use crate::hosts::replace_host; -use crate::http_loader::HttpState; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; + use async_tungstenite::tokio::{client_async_tls_with_connector_and_config, ConnectStream}; use async_tungstenite::WebSocketStream; use base64::Engine; @@ -28,23 +26,25 @@ use ipc_channel::router::ROUTER; use lazy_static::lazy_static; use log::{debug, trace, warn}; use net_traits::request::{RequestBuilder, RequestMode}; -use net_traits::{CookieSource, MessageData}; -use net_traits::{WebSocketDomAction, WebSocketNetworkEvent}; +use net_traits::{CookieSource, MessageData, WebSocketDomAction, WebSocketNetworkEvent}; use servo_url::ServoUrl; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio::select; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver}; use tokio_rustls::TlsConnector; -use tungstenite::error::Result as WebSocketResult; -use tungstenite::error::{Error, ProtocolError, UrlError}; +use tungstenite::error::{Error, ProtocolError, Result as WebSocketResult, UrlError}; use tungstenite::handshake::client::{Request, Response}; use tungstenite::protocol::CloseFrame; use tungstenite::Message; use url::Url; +use crate::connector::{create_tls_config, CACertificates, TlsConfig}; +use crate::cookie::Cookie; +use crate::fetch::methods::should_be_blocked_due_to_bad_port; +use crate::hosts::replace_host; +use crate::http_loader::HttpState; + // Websockets get their own tokio runtime that's independent of the one used for // HTTP connections, otherwise a large number of websockets could occupy all workers // and starve other network traffic. diff --git a/components/net_traits/blob_url_store.rs b/components/net_traits/blob_url_store.rs index 92d7f1f7360..ab853b702c9 100644 --- a/components/net_traits/blob_url_store.rs +++ b/components/net_traits/blob_url_store.rs @@ -2,13 +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 crate::filemanager_thread::FileOrigin; +use std::str::FromStr; + use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::str::FromStr; use url::Url; use uuid::Uuid; +use crate::filemanager_thread::FileOrigin; + /// Errors returned to Blob URL Store request #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub enum BlobURLStoreError { diff --git a/components/net_traits/filemanager_thread.rs b/components/net_traits/filemanager_thread.rs index 79b85e7d59d..ee18e295393 100644 --- a/components/net_traits/filemanager_thread.rs +++ b/components/net_traits/filemanager_thread.rs @@ -2,17 +2,19 @@ * 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::blob_url_store::{BlobBuf, BlobURLStoreError}; +use std::cmp::{max, min}; +use std::ops::Range; +use std::path::PathBuf; + use embedder_traits::FilterPattern; use ipc_channel::ipc::IpcSender; use malloc_size_of_derive::MallocSizeOf; use num_traits::ToPrimitive; use serde::{Deserialize, Serialize}; -use std::cmp::{max, min}; -use std::ops::Range; -use std::path::PathBuf; use uuid::Uuid; +use crate::blob_url_store::{BlobBuf, BlobURLStoreError}; + // HACK: Not really process-safe now, we should send Origin // directly instead of this in future, blocked on #11722 /// File manager store entry's origin diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs index d34610cf9c5..74e2d8823dc 100644 --- a/components/net_traits/image/base.rs +++ b/components/net_traits/image/base.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 crate::image_cache::CorsStatus; +use std::fmt; + use image::ImageFormat; use ipc_channel::ipc::IpcSharedMemory; use log::debug; use malloc_size_of_derive::MallocSizeOf; use pixels::PixelFormat; use serde::{Deserialize, Serialize}; -use std::fmt; use webrender_api::ImageKey; +use crate::image_cache::CorsStatus; + #[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct Image { pub width: u32, diff --git a/components/net_traits/image_cache.rs b/components/net_traits/image_cache.rs index ee30738c77d..81d34964db4 100644 --- a/components/net_traits/image_cache.rs +++ b/components/net_traits/image_cache.rs @@ -2,16 +2,17 @@ * 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::image::base::{Image, ImageMetadata}; -use crate::request::CorsSettings; -use crate::FetchResponseMsg; -use crate::WebrenderIpcSender; +use std::sync::Arc; + use ipc_channel::ipc::IpcSender; use log::debug; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::sync::Arc; + +use crate::image::base::{Image, ImageMetadata}; +use crate::request::CorsSettings; +use crate::{FetchResponseMsg, WebrenderIpcSender}; // ====================================================================== // Aux structs and enums. diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 0ba5e6c9a56..9bce0185969 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -4,14 +4,9 @@ #![deny(unsafe_code)] -use crate::filemanager_thread::FileManagerThreadMsg; -use crate::request::{Request, RequestBuilder}; -use crate::response::{HttpsState, Response, ResponseInit}; -use crate::storage_thread::StorageThreadMsg; use cookie::Cookie; use headers::{ContentType, HeaderMapExt, ReferrerPolicy as ReferrerPolicyHeader}; -use http::StatusCode; -use http::{Error as HttpError, HeaderMap}; +use http::{Error as HttpError, HeaderMap, StatusCode}; use hyper::Error as HyperError; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; @@ -30,6 +25,11 @@ use servo_url::{ImmutableOrigin, ServoUrl}; use time::precise_time_ns; use webrender_api::{ImageData, ImageDescriptor, ImageKey}; +use crate::filemanager_thread::FileManagerThreadMsg; +use crate::request::{Request, RequestBuilder}; +use crate::response::{HttpsState, Response, ResponseInit}; +use crate::storage_thread::StorageThreadMsg; + pub mod blob_url_store; pub mod filemanager_thread; pub mod image_cache; diff --git a/components/net_traits/pub_domains.rs b/components/net_traits/pub_domains.rs index f5cbbcea7cc..1efb8faf56d 100644 --- a/components/net_traits/pub_domains.rs +++ b/components/net_traits/pub_domains.rs @@ -14,11 +14,12 @@ //! we don't need to make the code more complex for it. The `mach` update command makes sure that //! those cases are not present. +use std::collections::HashSet; +use std::iter::FromIterator; + use embedder_traits::resources::{self, Resource}; use lazy_static::lazy_static; use servo_url::{Host, ImmutableOrigin, ServoUrl}; -use std::collections::HashSet; -use std::iter::FromIterator; #[derive(Clone, Debug)] pub struct PubDomainRules { diff --git a/components/net_traits/quality.rs b/components/net_traits/quality.rs index e5e9fcc42cd..095cd121bad 100644 --- a/components/net_traits/quality.rs +++ b/components/net_traits/quality.rs @@ -6,9 +6,10 @@ // This is copy pasted from the old hyper headers to avoid hardcoding everything // (I would probably also make some silly mistakes while migrating...) +use std::{fmt, str}; + use http::header::HeaderValue; use mime::Mime; -use std::{fmt, str}; /// A quality value, as specified in [RFC7231]. /// diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs index 8466cc9bbfd..1f9f0abf986 100644 --- a/components/net_traits/request.rs +++ b/components/net_traits/request.rs @@ -2,21 +2,20 @@ * 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::response::HttpsState; -use crate::ReferrerPolicy; -use crate::ResourceTimingType; +use std::sync::{Arc, Mutex}; + use content_security_policy::{self as csp, CspList}; use http::header::{HeaderName, AUTHORIZATION}; -use http::HeaderMap; -use http::Method; +use http::{HeaderMap, Method}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use malloc_size_of_derive::MallocSizeOf; use mime::Mime; use msg::constellation_msg::PipelineId; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::sync::{Arc, Mutex}; + +use crate::response::HttpsState; +use crate::{ReferrerPolicy, ResourceTimingType}; /// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator) #[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs index f6ea9fe3064..552c0057c50 100644 --- a/components/net_traits/response.rs +++ b/components/net_traits/response.rs @@ -4,8 +4,9 @@ //! The [Response](https://fetch.spec.whatwg.org/#responses) object //! resulting from a [fetch operation](https://fetch.spec.whatwg.org/#concept-fetch) -use crate::{FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy}; -use crate::{ResourceFetchTiming, ResourceTimingType}; +use std::sync::atomic::AtomicBool; +use std::sync::Mutex; + use headers::{ContentType, HeaderMapExt}; use http::{HeaderMap, StatusCode}; use hyper_serde::Serde; @@ -13,8 +14,11 @@ use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use servo_arc::Arc; use servo_url::ServoUrl; -use std::sync::atomic::AtomicBool; -use std::sync::Mutex; + +use crate::{ + FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, + ResourceTimingType, +}; /// [Response type](https://fetch.spec.whatwg.org/#concept-response-type) #[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] diff --git a/components/pixels/lib.rs b/components/pixels/lib.rs index 46a567d78e9..d9a7fcc39d0 100644 --- a/components/pixels/lib.rs +++ b/components/pixels/lib.rs @@ -2,10 +2,11 @@ * 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::borrow::Cow; + use euclid::default::{Point2D, Rect, Size2D}; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; -use std::borrow::Cow; #[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum PixelFormat { diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 5bdd8a09e09..67c896d819f 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -4,18 +4,21 @@ //! Memory profiling functions. -use crate::time::duration_from_seconds; -use ipc_channel::ipc::{self, IpcReceiver}; -use ipc_channel::router::ROUTER; -use profile_traits::mem::ReportsChan; -use profile_traits::mem::{ProfilerChan, ProfilerMsg, ReportKind, Reporter, ReporterRequest}; -use profile_traits::path; use std::borrow::ToOwned; use std::cmp::Ordering; use std::collections::HashMap; use std::thread; use std::time::Instant; +use ipc_channel::ipc::{self, IpcReceiver}; +use ipc_channel::router::ROUTER; +use profile_traits::mem::{ + ProfilerChan, ProfilerMsg, ReportKind, Reporter, ReporterRequest, ReportsChan, +}; +use profile_traits::path; + +use crate::time::duration_from_seconds; + pub struct Profiler { /// The port through which messages are received. pub port: IpcReceiver<ProfilerMsg>, @@ -384,22 +387,24 @@ impl ReportsForest { //--------------------------------------------------------------------------- mod system_reporter { - use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR}; - #[cfg(target_os = "linux")] - use libc::c_int; - #[cfg(not(target_os = "windows"))] - use libc::{c_void, size_t}; - use profile_traits::mem::{Report, ReportKind, ReporterRequest}; - use profile_traits::path; #[cfg(not(target_os = "windows"))] use std::ffi::CString; #[cfg(not(target_os = "windows"))] use std::mem::size_of; #[cfg(not(target_os = "windows"))] use std::ptr::null_mut; + + #[cfg(target_os = "linux")] + use libc::c_int; + #[cfg(not(target_os = "windows"))] + use libc::{c_void, size_t}; + use profile_traits::mem::{Report, ReportKind, ReporterRequest}; + use profile_traits::path; #[cfg(target_os = "macos")] use task_info::task_basic_info::{resident_size, virtual_size}; + use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR}; + /// Collects global measurements from the OS and heap allocators. pub fn collect_reports(request: ReporterRequest) { let mut reports = vec![]; @@ -599,12 +604,13 @@ mod system_reporter { #[cfg(target_os = "linux")] fn resident_segments() -> Vec<(String, usize)> { - use regex::Regex; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; + use regex::Regex; + // The first line of an entry in /proc/<pid>/smaps looks just like an entry // in /proc/<pid>/maps: // diff --git a/components/profile/time.rs b/components/profile/time.rs index 68fe11e4d13..e54542b9a8a 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -4,13 +4,6 @@ //! Timing functions. -use crate::trace_dump::TraceDump; -use ipc_channel::ipc::{self, IpcReceiver}; -use profile_traits::time::{ - ProfilerCategory, ProfilerChan, ProfilerData, ProfilerMsg, TimerMetadata, -}; -use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; -use servo_config::opts::OutputOptions; use std::borrow::ToOwned; use std::collections::{BTreeMap, HashMap}; use std::fs::File; @@ -19,6 +12,15 @@ use std::path::Path; use std::time::Duration; use std::{f64, thread, u32, u64}; +use ipc_channel::ipc::{self, IpcReceiver}; +use profile_traits::time::{ + ProfilerCategory, ProfilerChan, ProfilerData, ProfilerMsg, TimerMetadata, + TimerMetadataFrameType, TimerMetadataReflowType, +}; +use servo_config::opts::OutputOptions; + +use crate::trace_dump::TraceDump; + pub trait Formattable { fn format(&self, output: &Option<OutputOptions>) -> String; } diff --git a/components/profile/trace_dump.rs b/components/profile/trace_dump.rs index 79dd3faeda0..3051e08ee11 100644 --- a/components/profile/trace_dump.rs +++ b/components/profile/trace_dump.rs @@ -4,11 +4,11 @@ //! A module for writing time profiler traces out to a self contained HTML file. +use std::io::{self, Write}; +use std::{fs, path}; + use profile_traits::time::{ProfilerCategory, TimerMetadata}; use serde::Serialize; -use std::fs; -use std::io::{self, Write}; -use std::path; /// An RAII class for writing the HTML trace dump. #[derive(Debug)] diff --git a/components/profile_traits/ipc.rs b/components/profile_traits/ipc.rs index 5da5ef3e592..7a005939a98 100644 --- a/components/profile_traits/ipc.rs +++ b/components/profile_traits/ipc.rs @@ -2,12 +2,13 @@ * 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::time; -use crate::time::ProfilerCategory; -use crate::time::ProfilerChan; +use std::io::Error; + use ipc_channel::ipc; use serde::{Deserialize, Serialize}; -use std::io::Error; + +use crate::time; +use crate::time::{ProfilerCategory, ProfilerChan}; pub struct IpcReceiver<T> where diff --git a/components/profile_traits/mem.rs b/components/profile_traits/mem.rs index ab76b774f77..87b6f26597c 100644 --- a/components/profile_traits/mem.rs +++ b/components/profile_traits/mem.rs @@ -6,12 +6,13 @@ #![deny(missing_docs)] +use std::marker::Send; + use crossbeam_channel::Sender; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use log::warn; use serde::{Deserialize, Serialize}; -use std::marker::Send; /// A trait to abstract away the various kinds of message senders we use. pub trait OpaqueSender<T> { diff --git a/components/rand/lib.rs b/components/rand/lib.rs index 0fb17a5f8ab..260ff2c259a 100644 --- a/components/rand/lib.rs +++ b/components/rand/lib.rs @@ -2,6 +2,11 @@ * 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::rc::Rc; +use std::sync::Mutex; +use std::u64; + use lazy_static::lazy_static; use log::trace; /// A random number generator which shares one instance of an `OsRng`. @@ -19,10 +24,6 @@ use rand::rngs::OsRng; pub use rand::seq::SliceRandom; pub use rand::{Rng, RngCore, SeedableRng}; use rand_isaac::isaac::IsaacCore; -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::Mutex; -use std::u64; use uuid::{Builder, Uuid}; // The shared RNG which may hold on to a file descriptor diff --git a/components/range/lib.rs b/components/range/lib.rs index 9c904f630df..6b98b68a658 100644 --- a/components/range/lib.rs +++ b/components/range/lib.rs @@ -4,11 +4,11 @@ #![deny(unsafe_code)] +use std::cmp::{self, max, min}; +use std::{fmt, ops}; + use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; -use std::cmp::{self, max, min}; -use std::fmt; -use std::ops; pub trait Int: Copy + ops::Add<Self, Output = Self> + ops::Sub<Self, Output = Self> + cmp::Ord diff --git a/components/remutex/tests/smoke.rs b/components/remutex/tests/smoke.rs index 5c095ea703f..6d253e48501 100644 --- a/components/remutex/tests/smoke.rs +++ b/components/remutex/tests/smoke.rs @@ -10,11 +10,12 @@ // These tests came from https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs -use servo_remutex::{ReentrantMutex, ReentrantMutexGuard}; use std::cell::RefCell; use std::sync::Arc; use std::thread; +use servo_remutex::{ReentrantMutex, ReentrantMutexGuard}; + #[test] fn smoke() { let m = ReentrantMutex::new(()); diff --git a/components/script/animations.rs b/components/script/animations.rs index 752deb5c9b4..674ec7afcaa 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -4,6 +4,21 @@ //! The set of animations for a document. +use std::cell::Cell; + +use cssparser::ToCss; +use fxhash::{FxHashMap, FxHashSet}; +use libc::c_void; +use msg::constellation_msg::PipelineId; +use script_traits::{AnimationState as AnimationsPresentState, ScriptMsg, UntrustedNodeAddress}; +use serde::{Deserialize, Serialize}; +use style::animation::{ + Animation, AnimationSetKey, AnimationState, DocumentAnimationSet, ElementAnimationSet, + KeyframesIterationState, Transition, +}; +use style::dom::OpaqueNode; +use style::selector_parser::PseudoElement; + use crate::dom::animationevent::AnimationEvent; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AnimationEventBinding::AnimationEventInit; @@ -18,19 +33,6 @@ use crate::dom::event::Event; use crate::dom::node::{from_untrusted_node_address, window_from_node, Node, NodeDamage}; use crate::dom::transitionevent::TransitionEvent; use crate::dom::window::Window; -use cssparser::ToCss; -use fxhash::{FxHashMap, FxHashSet}; -use libc::c_void; -use msg::constellation_msg::PipelineId; -use script_traits::{AnimationState as AnimationsPresentState, ScriptMsg, UntrustedNodeAddress}; -use serde::{Deserialize, Serialize}; -use std::cell::Cell; -use style::animation::{ - Animation, AnimationSetKey, AnimationState, DocumentAnimationSet, ElementAnimationSet, - KeyframesIterationState, Transition, -}; -use style::dom::OpaqueNode; -use style::selector_parser::PseudoElement; /// The set of animations for a document. #[derive(Default, JSTraceable, MallocSizeOf)] diff --git a/components/script/body.rs b/components/script/body.rs index baa4011062e..b5072c10b26 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -2,6 +2,24 @@ * 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::rc::Rc; +use std::{ptr, str}; + +use encoding_rs::UTF_8; +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use ipc_channel::router::ROUTER; +use js::jsapi::{Heap, JSObject, JS_ClearPendingException, Value as JSValue}; +use js::jsval::{JSVal, UndefinedValue}; +use js::rust::wrappers::{JS_GetPendingException, JS_ParseJSON}; +use js::rust::HandleValue; +use js::typedarray::{ArrayBuffer, CreateWith}; +use mime::{self, Mime}; +use net_traits::request::{ + BodyChunkRequest, BodyChunkResponse, BodySource as NetBodySource, RequestBody, +}; +use script_traits::serializable::BlobImpl; +use url::form_urlencoded; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; @@ -24,30 +42,7 @@ use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext; use crate::task::TaskCanceller; use crate::task_source::networking::NetworkingTaskSource; -use crate::task_source::TaskSource; -use crate::task_source::TaskSourceName; -use encoding_rs::UTF_8; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use ipc_channel::router::ROUTER; -use js::jsapi::Heap; -use js::jsapi::JSObject; -use js::jsapi::JS_ClearPendingException; -use js::jsapi::Value as JSValue; -use js::jsval::JSVal; -use js::jsval::UndefinedValue; -use js::rust::wrappers::JS_GetPendingException; -use js::rust::wrappers::JS_ParseJSON; -use js::rust::HandleValue; -use js::typedarray::{ArrayBuffer, CreateWith}; -use mime::{self, Mime}; -use net_traits::request::{ - BodyChunkRequest, BodyChunkResponse, BodySource as NetBodySource, RequestBody, -}; -use script_traits::serializable::BlobImpl; -use std::ptr; -use std::rc::Rc; -use std::str; -use url::form_urlencoded; +use crate::task_source::{TaskSource, TaskSourceName}; /// The Dom object, or ReadableStream, that is the source of a body. /// <https://fetch.spec.whatwg.org/#concept-body-source> diff --git a/components/script/build.rs b/components/script/build.rs index ea39b698257..3fabbeee1fa 100644 --- a/components/script/build.rs +++ b/components/script/build.rs @@ -2,15 +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 phf_shared::{self, FmtConst}; -use serde_json::{self, Value}; -use std::env; -use std::fmt; use std::fs::File; use std::io::Write; use std::path::PathBuf; use std::process::Command; use std::time::Instant; +use std::{env, fmt}; + +use phf_shared::{self, FmtConst}; +use serde_json::{self, Value}; fn main() { let start = Instant::now(); diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs index fc1eff7df8b..a376a56b737 100644 --- a/components/script/canvas_state.rs +++ b/components/script/canvas_state.rs @@ -2,14 +2,37 @@ * 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::Cell; +use std::fmt; +use std::str::FromStr; +use std::sync::Arc; + +use canvas_traits::canvas::{ + Canvas2dMsg, CanvasId, CanvasMsg, CompositionOrBlending, Direction, FillOrStrokeStyle, + FillRule, LineCapStyle, LineJoinStyle, LinearGradientStyle, RadialGradientStyle, + RepetitionStyle, TextAlign, TextBaseline, +}; +use cssparser::{Color as CSSColor, Parser, ParserInput, RGBA}; +use euclid::default::{Point2D, Rect, Size2D, Transform2D}; +use euclid::vec2; +use ipc_channel::ipc::{self, IpcSender}; +use net_traits::image_cache::{ImageCache, ImageResponse}; +use net_traits::request::CorsSettings; +use pixels::PixelFormat; +use profile_traits::ipc as profiled_ipc; +use script_traits::ScriptMsg; +use serde_bytes::ByteBuf; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps; +use style::properties::style_structs::Font; +use style::values::computed::font::FontStyle; +use style_traits::values::ToCss; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasDirection; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextAlign; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextBaseline; +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{ + CanvasDirection, CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin, + CanvasTextAlign, CanvasTextBaseline, +}; use crate::dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -20,8 +43,7 @@ use crate::dom::bindings::str::DOMString; use crate::dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle}; use crate::dom::canvaspattern::CanvasPattern; use crate::dom::dommatrix::DOMMatrix; -use crate::dom::element::cors_setting_for_element; -use crate::dom::element::Element; +use crate::dom::element::{cors_setting_for_element, Element}; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlcanvaselement::{CanvasContext, HTMLCanvasElement}; use crate::dom::imagedata::ImageData; @@ -30,32 +52,6 @@ use crate::dom::offscreencanvas::{OffscreenCanvas, OffscreenCanvasContext}; use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use crate::dom::textmetrics::TextMetrics; use crate::unpremultiplytable::UNPREMULTIPLY_TABLE; -use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg, Direction, TextAlign, TextBaseline}; -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 euclid::{ - default::{Point2D, Rect, Size2D, Transform2D}, - vec2, -}; -use ipc_channel::ipc::{self, IpcSender}; -use net_traits::image_cache::{ImageCache, ImageResponse}; -use net_traits::request::CorsSettings; -use pixels::PixelFormat; -use profile_traits::ipc as profiled_ipc; -use script_traits::ScriptMsg; -use serde_bytes::ByteBuf; -use servo_url::{ImmutableOrigin, ServoUrl}; -use std::cell::Cell; -use std::fmt; -use std::str::FromStr; -use std::sync::Arc; -use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps; -use style::properties::style_structs::Font; -use style::values::computed::font::FontStyle; -use style_traits::values::ToCss; #[unrooted_must_root_lint::must_root] #[derive(Clone, JSTraceable, MallocSizeOf)] diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 8ff911a6b78..b5b7afe598c 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -2,6 +2,19 @@ * 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::rc::Rc; +use std::str; + +use devtools_traits::{ + AutoMargins, ComputedNodeLayout, EvaluateJSReply, Modification, NodeInfo, TimelineMarker, + TimelineMarkerType, +}; +use ipc_channel::ipc::IpcSender; +use js::jsval::UndefinedValue; +use js::rust::ToString; +use msg::constellation_msg::PipelineId; +use uuid::Uuid; + use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; @@ -19,15 +32,6 @@ use crate::dom::node::{window_from_node, Node, ShadowIncluding}; use crate::realms::enter_realm; use crate::script_module::ScriptFetchOptions; use crate::script_thread::Documents; -use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType}; -use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker}; -use ipc_channel::ipc::IpcSender; -use js::jsval::UndefinedValue; -use js::rust::ToString; -use msg::constellation_msg::PipelineId; -use std::rc::Rc; -use std::str; -use uuid::Uuid; #[allow(unsafe_code)] pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<EvaluateJSReply>) { diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index 7dc2d6201fb..02a33a0ce74 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -6,15 +6,15 @@ //! //! <https://html.spec.whatwg.org/multipage/#the-end> -use crate::dom::bindings::root::Dom; -use crate::dom::document::Document; -use crate::fetch::FetchCanceller; use ipc_channel::ipc::IpcSender; use net_traits::request::RequestBuilder; -use net_traits::{CoreResourceMsg, FetchChannels, FetchResponseMsg}; -use net_traits::{IpcSend, ResourceThreads}; +use net_traits::{CoreResourceMsg, FetchChannels, FetchResponseMsg, IpcSend, ResourceThreads}; use servo_url::ServoUrl; +use crate::dom::bindings::root::Dom; +use crate::dom::document::Document; +use crate::fetch::FetchCanceller; + #[derive(Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum LoadType { Image(#[no_trace] ServoUrl), diff --git a/components/script/dom/abstractworker.rs b/components/script/dom/abstractworker.rs index 36ff18fe01b..c3ef855599e 100644 --- a/components/script/dom/abstractworker.rs +++ b/components/script/dom/abstractworker.rs @@ -2,11 +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 script_traits::StructuredSerializedData; +use servo_url::ImmutableOrigin; + use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; use crate::script_runtime::CommonScriptMsg; -use script_traits::StructuredSerializedData; -use servo_url::ImmutableOrigin; /// Messages used to control the worker event loops pub enum WorkerScriptMsg { diff --git a/components/script/dom/abstractworkerglobalscope.rs b/components/script/dom/abstractworkerglobalscope.rs index 0261c82996c..b0c580df7e4 100644 --- a/components/script/dom/abstractworkerglobalscope.rs +++ b/components/script/dom/abstractworkerglobalscope.rs @@ -2,6 +2,9 @@ * 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 crossbeam_channel::{select, Receiver, Sender}; +use devtools_traits::DevtoolScriptControlMsg; + use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::conversions::DerivedFrom; use crate::dom::bindings::reflector::DomObject; @@ -12,8 +15,6 @@ use crate::dom::workerglobalscope::WorkerGlobalScope; use crate::realms::enter_realm; use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort}; use crate::task_queue::{QueuedTaskConversion, TaskQueue}; -use crossbeam_channel::{select, Receiver, Sender}; -use devtools_traits::DevtoolScriptControlMsg; /// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with /// common event loop messages. While this SendableWorkerScriptChan is alive, the associated diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs index 4e6ac769885..0880d1fdb64 100644 --- a/components/script/dom/activation.rs +++ b/components/script/dom/activation.rs @@ -2,13 +2,14 @@ * 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 script_layout_interface::message::ReflowGoal; + use crate::dom::element::Element; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlinputelement::InputActivationState; use crate::dom::node::window_from_node; use crate::dom::window::ReflowReason; -use script_layout_interface::message::ReflowGoal; /// Trait for elements with defined activation behavior pub trait Activatable { diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 7a83ca0052e..237a0e79fb6 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -2,6 +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 dom_struct::dom_struct; +use ipc_channel::ipc::{self, IpcReceiver}; +use ipc_channel::router::ROUTER; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{Float32Array, Uint8Array}; +use servo_media::audio::analyser_node::AnalysisEngine; +use servo_media::audio::block::Block; +use servo_media::audio::node::AudioNodeInit; + use crate::dom::audionode::AudioNode; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::cell::DomRefCell; @@ -18,14 +27,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use ipc_channel::ipc::{self, IpcReceiver}; -use ipc_channel::router::ROUTER; -use js::rust::{CustomAutoRooterGuard, HandleObject}; -use js::typedarray::{Float32Array, Uint8Array}; -use servo_media::audio::analyser_node::AnalysisEngine; -use servo_media::audio::block::Block; -use servo_media::audio::node::AudioNodeInit; #[dom_struct] pub struct AnalyserNode { diff --git a/components/script/dom/animationevent.rs b/components/script/dom/animationevent.rs index 053801631c5..648ed52690f 100644 --- a/components/script/dom/animationevent.rs +++ b/components/script/dom/animationevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::AnimationEventBinding::{ AnimationEventInit, AnimationEventMethods, }; @@ -13,9 +17,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct AnimationEvent { diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index e8fce0493bc..976831d1cc6 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -2,6 +2,16 @@ * 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::borrow::ToOwned; +use std::mem; + +use devtools_traits::AttrInfo; +use dom_struct::dom_struct; +use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix}; +use servo_atoms::Atom; +use style::attr::{AttrIdentifier, AttrValue}; +use style::values::GenericAtomIdent; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::inheritance::Castable; @@ -14,14 +24,6 @@ use crate::dom::mutationobserver::{Mutation, MutationObserver}; use crate::dom::node::Node; use crate::dom::virtualmethods::vtable_for; use crate::script_thread::ScriptThread; -use devtools_traits::AttrInfo; -use dom_struct::dom_struct; -use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix}; -use servo_atoms::Atom; -use std::borrow::ToOwned; -use std::mem; -use style::attr::{AttrIdentifier, AttrValue}; -use style::values::GenericAtomIdent; // https://dom.spec.whatwg.org/#interface-attr #[dom_struct] diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index 29623fee6a2..81943ca25f5 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -2,6 +2,16 @@ * 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::cmp::min; +use std::ptr::{self, NonNull}; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject, JS_GetArrayBufferViewBuffer}; +use js::rust::wrappers::DetachArrayBuffer; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{CreateWith, Float32Array}; +use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer; + use crate::dom::audionode::MAX_CHANNEL_COUNT; use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{ @@ -15,16 +25,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::realms::enter_realm; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::JS_GetArrayBufferViewBuffer; -use js::jsapi::{Heap, JSObject}; -use js::rust::wrappers::DetachArrayBuffer; -use js::rust::CustomAutoRooterGuard; -use js::rust::HandleObject; -use js::typedarray::{CreateWith, Float32Array}; -use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer; -use std::cmp::min; -use std::ptr::{self, NonNull}; // Spec mandates at least [8000, 96000], we use [8000, 192000] to match Firefox // https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs index ce1880bccd9..efa0008491f 100644 --- a/components/script/dom/audiobuffersourcenode.rs +++ b/components/script/dom/audiobuffersourcenode.rs @@ -2,12 +2,24 @@ * 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::Cell; +use std::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::buffer_source_node::{ + AudioBufferSourceNodeMessage, AudioBufferSourceNodeOptions, +}; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; +use servo_media::audio::param::ParamType; + use crate::dom::audiobuffer::AudioBuffer; use crate::dom::audioparam::AudioParam; use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; -use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceNodeMethods; -use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; +use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::{ + AudioBufferSourceNodeMethods, AudioBufferSourceOptions, +}; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use crate::dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -16,14 +28,6 @@ use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::buffer_source_node::AudioBufferSourceNodeMessage; -use servo_media::audio::buffer_source_node::AudioBufferSourceNodeOptions; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; -use servo_media::audio::param::ParamType; -use std::cell::Cell; -use std::f32; #[dom_struct] pub struct AudioBufferSourceNode { diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index 914323509a2..1c0c99c205a 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -2,12 +2,16 @@ * 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::rc::Rc; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use msg::constellation_msg::PipelineId; +use servo_media::audio::context::{LatencyCategory, ProcessingState, RealTimeAudioContextOptions}; + use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions}; use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{ - AudioContextLatencyCategory, AudioContextMethods, -}; -use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{ - AudioContextOptions, AudioTimestamp, + AudioContextLatencyCategory, AudioContextMethods, AudioContextOptions, AudioTimestamp, }; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState; @@ -30,11 +34,6 @@ use crate::dom::promise::Promise; use crate::dom::window::Window; use crate::realms::InRealm; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use msg::constellation_msg::PipelineId; -use servo_media::audio::context::{LatencyCategory, ProcessingState, RealTimeAudioContextOptions}; -use std::rc::Rc; #[dom_struct] pub struct AudioContext { diff --git a/components/script/dom/audiodestinationnode.rs b/components/script/dom/audiodestinationnode.rs index 7e820240b63..ec1beb116bb 100644 --- a/components/script/dom/audiodestinationnode.rs +++ b/components/script/dom/audiodestinationnode.rs @@ -2,17 +2,17 @@ * 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 dom_struct::dom_struct; + use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT}; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioDestinationNodeBinding::AudioDestinationNodeMethods; -use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ - ChannelCountMode, ChannelInterpretation, + AudioNodeOptions, ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; #[dom_struct] pub struct AudioDestinationNode { diff --git a/components/script/dom/audiolistener.rs b/components/script/dom/audiolistener.rs index 2256efaf558..d6c7b8151c3 100644 --- a/components/script/dom/audiolistener.rs +++ b/components/script/dom/audiolistener.rs @@ -2,21 +2,23 @@ * 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::f32; + +use dom_struct::dom_struct; +use servo_media::audio::param::{ParamDir, ParamType}; + use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioListenerBinding::AudioListenerMethods; -use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; +use crate::dom::bindings::codegen::Bindings::AudioParamBinding::{ + AudioParamMethods, AutomationRate, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AudioParamMethods; -use dom_struct::dom_struct; -use servo_media::audio::param::{ParamDir, ParamType}; -use std::f32; - #[dom_struct] pub struct AudioListener { reflector_: Reflector, diff --git a/components/script/dom/audionode.rs b/components/script/dom/audionode.rs index 5df6d7a76b1..65d1973ebab 100644 --- a/components/script/dom/audionode.rs +++ b/components/script/dom/audionode.rs @@ -2,13 +2,19 @@ * 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::Cell; + +use dom_struct::dom_struct; +use servo_media::audio::graph::NodeId; +use servo_media::audio::node::{ + AudioNodeInit, AudioNodeMessage, ChannelCountMode as ServoMediaChannelCountMode, ChannelInfo, + ChannelInterpretation as ServoMediaChannelInterpretation, +}; + use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ - AudioNodeMethods, AudioNodeOptions, -}; -use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ - ChannelCountMode, ChannelInterpretation, + AudioNodeMethods, AudioNodeOptions, ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::InheritTypes::{ AudioNodeTypeId, AudioScheduledSourceNodeTypeId, EventTargetTypeId, @@ -17,12 +23,6 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::eventtarget::EventTarget; -use dom_struct::dom_struct; -use servo_media::audio::graph::NodeId; -use servo_media::audio::node::ChannelCountMode as ServoMediaChannelCountMode; -use servo_media::audio::node::ChannelInterpretation as ServoMediaChannelInterpretation; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage, ChannelInfo}; -use std::cell::Cell; // 32 is the minimum required by the spec for createBuffer() and the deprecated // createScriptProcessor() and matches what is used by Blink and Gecko. diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 99f64d765f6..3d1ca25c77f 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -2,6 +2,14 @@ * 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::Cell; +use std::sync::mpsc; + +use dom_struct::dom_struct; +use servo_media::audio::graph::NodeId; +use servo_media::audio::node::AudioNodeMessage; +use servo_media::audio::param::{ParamRate, ParamType, RampKind, UserAutomationEvent}; + use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::{ AudioParamMethods, AutomationRate, @@ -11,12 +19,6 @@ use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_media::audio::graph::NodeId; -use servo_media::audio::node::AudioNodeMessage; -use servo_media::audio::param::{ParamRate, ParamType, RampKind, UserAutomationEvent}; -use std::cell::Cell; -use std::sync::mpsc; #[dom_struct] pub struct AudioParam { diff --git a/components/script/dom/audioscheduledsourcenode.rs b/components/script/dom/audioscheduledsourcenode.rs index ab23b5660b7..3337bb4c5cb 100644 --- a/components/script/dom/audioscheduledsourcenode.rs +++ b/components/script/dom/audioscheduledsourcenode.rs @@ -2,6 +2,13 @@ * 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::Cell; + +use dom_struct::dom_struct; +use servo_media::audio::node::{ + AudioNodeInit, AudioNodeMessage, AudioScheduledSourceNodeMessage, OnEndedCallback, +}; + use crate::dom::audionode::{AudioNode, UnwrappedAudioNodeOptions}; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeMethods; @@ -11,10 +18,6 @@ use crate::dom::bindings::num::Finite; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use servo_media::audio::node::OnEndedCallback; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage, AudioScheduledSourceNodeMessage}; -use std::cell::Cell; #[dom_struct] pub struct AudioScheduledSourceNode { diff --git a/components/script/dom/audiotrack.rs b/components/script/dom/audiotrack.rs index 19bc6d0a6cd..829ed9b7207 100644 --- a/components/script/dom/audiotrack.rs +++ b/components/script/dom/audiotrack.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::audiotracklist::AudioTrackList; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AudioTrackBinding::AudioTrackMethods; @@ -9,8 +13,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct AudioTrack { diff --git a/components/script/dom/audiotracklist.rs b/components/script/dom/audiotracklist.rs index 6a7fd3b4ebb..27311de360b 100644 --- a/components/script/dom/audiotracklist.rs +++ b/components/script/dom/audiotracklist.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::audiotrack::AudioTrack; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AudioTrackListBinding::AudioTrackListMethods; @@ -14,7 +16,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; #[dom_struct] pub struct AudioTrackList { diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 20180d8a939..9e0581c48e3 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -2,6 +2,26 @@ * 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::Cell; +use std::collections::hash_map::Entry; +use std::collections::{HashMap, VecDeque}; +use std::mem; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; + +use dom_struct::dom_struct; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::ArrayBuffer; +use msg::constellation_msg::PipelineId; +use servo_media::audio::context::{ + AudioContext, AudioContextOptions, OfflineAudioContextOptions, ProcessingState, + RealTimeAudioContextOptions, +}; +use servo_media::audio::decoder::AudioDecoderCallbacks; +use servo_media::audio::graph::NodeId; +use servo_media::{ClientContextId, ServoMedia}; +use uuid::Uuid; + use crate::dom::analysernode::AnalyserNode; use crate::dom::audiobuffer::AudioBuffer; use crate::dom::audiobuffersourcenode::AudioBufferSourceNode; @@ -12,14 +32,12 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AnalyserNodeBinding::AnalyserOptions; use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; -use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ - ChannelCountMode, ChannelInterpretation, + AudioNodeOptions, ChannelCountMode, ChannelInterpretation, +}; +use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::{ + AudioContextState, BaseAudioContextMethods, DecodeErrorCallback, DecodeSuccessCallback, }; -use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState; -use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextMethods; -use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::DecodeErrorCallback; -use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::DecodeSuccessCallback; use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterOptions; use crate::dom::bindings::codegen::Bindings::ChannelMergerNodeBinding::ChannelMergerOptions; use crate::dom::bindings::codegen::Bindings::ChannelSplitterNodeBinding::ChannelSplitterOptions; @@ -48,22 +66,6 @@ use crate::dom::stereopannernode::StereoPannerNode; use crate::dom::window::Window; use crate::realms::InRealm; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use js::rust::CustomAutoRooterGuard; -use js::typedarray::ArrayBuffer; -use msg::constellation_msg::PipelineId; -use servo_media::audio::context::{AudioContext, AudioContextOptions, ProcessingState}; -use servo_media::audio::context::{OfflineAudioContextOptions, RealTimeAudioContextOptions}; -use servo_media::audio::decoder::AudioDecoderCallbacks; -use servo_media::audio::graph::NodeId; -use servo_media::{ClientContextId, ServoMedia}; -use std::cell::Cell; -use std::collections::hash_map::Entry; -use std::collections::{HashMap, VecDeque}; -use std::mem; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; -use uuid::Uuid; #[allow(dead_code)] pub enum BaseAudioContextOptions { diff --git a/components/script/dom/beforeunloadevent.rs b/components/script/dom/beforeunloadevent.rs index d4e27e94b32..6a30336afe8 100644 --- a/components/script/dom/beforeunloadevent.rs +++ b/components/script/dom/beforeunloadevent.rs @@ -4,6 +4,9 @@ #![allow(dead_code)] +use dom_struct::dom_struct; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -13,8 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#beforeunloadevent #[dom_struct] 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 { diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs index 197afaef36b..f730da15651 100644 --- a/components/script/dom/biquadfilternode.rs +++ b/components/script/dom/biquadfilternode.rs @@ -2,6 +2,17 @@ * 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::Cell; +use std::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::biquad_filter_node::{ + BiquadFilterNodeMessage, BiquadFilterNodeOptions, FilterType, +}; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; +use servo_media::audio::param::ParamType; + use crate::dom::audionode::AudioNode; use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; @@ -9,21 +20,13 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; -use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterNodeMethods; -use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterOptions; -use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterType; +use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::{ + BiquadFilterNodeMethods, BiquadFilterOptions, BiquadFilterType, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::biquad_filter_node::BiquadFilterNodeMessage; -use servo_media::audio::biquad_filter_node::{BiquadFilterNodeOptions, FilterType}; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; -use servo_media::audio::param::ParamType; -use std::cell::Cell; -use std::f32; #[dom_struct] pub struct BiquadFilterNode { diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index a6599d3ac99..1b710124368 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -2,6 +2,20 @@ * 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::collections::HashMap; +use std::num::NonZeroU32; +use std::ptr::NonNull; +use std::rc::Rc; + +use dom_struct::dom_struct; +use encoding_rs::UTF_8; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use msg::constellation_msg::{BlobId, BlobIndex, PipelineNamespaceId}; +use net_traits::filemanager_thread::RelativePos; +use script_traits::serializable::BlobImpl; +use uuid::Uuid; + use crate::body::{run_array_buffer_data_algorithm, FetchedData}; use crate::dom::bindings::codegen::Bindings::BlobBinding; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; @@ -17,18 +31,6 @@ use crate::dom::promise::Promise; use crate::dom::readablestream::ReadableStream; use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use encoding_rs::UTF_8; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use msg::constellation_msg::{BlobId, BlobIndex, PipelineNamespaceId}; -use net_traits::filemanager_thread::RelativePos; -use script_traits::serializable::BlobImpl; -use std::collections::HashMap; -use std::num::NonZeroU32; -use std::ptr::NonNull; -use std::rc::Rc; -use uuid::Uuid; // https://w3c.github.io/FileAPI/#blob #[dom_struct] diff --git a/components/script/dom/bluetoothadvertisingevent.rs b/components/script/dom/bluetoothadvertisingevent.rs index cc667e75a4b..09a9ff07d4f 100644 --- a/components/script/dom/bluetoothadvertisingevent.rs +++ b/components/script/dom/bluetoothadvertisingevent.rs @@ -2,8 +2,13 @@ * 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::BluetoothAdvertisingEventBinding::BluetoothAdvertisingEventInit; -use crate::dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::BluetoothAdvertisingEventMethods; +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + +use crate::dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::{ + BluetoothAdvertisingEventInit, BluetoothAdvertisingEventMethods, +}; use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; @@ -14,9 +19,6 @@ use crate::dom::bluetoothdevice::BluetoothDevice; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingevent #[dom_struct] diff --git a/components/script/dom/bluetoothcharacteristicproperties.rs b/components/script/dom/bluetoothcharacteristicproperties.rs index f48eb52772c..3f1a765d234 100644 --- a/components/script/dom/bluetoothcharacteristicproperties.rs +++ b/components/script/dom/bluetoothcharacteristicproperties.rs @@ -2,11 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; // https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties #[dom_struct] diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index 2d96efb3e05..a2b9ecc330e 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -2,11 +2,22 @@ * 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::Cell; +use std::collections::HashMap; +use std::rc::Rc; + +use bluetooth_traits::{ + BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothRequest, BluetoothResponse, + BluetoothServiceMsg, +}; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use profile_traits::ipc; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::ErrorResult; +use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -21,14 +32,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::realms::InRealm; -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; -use std::cell::Cell; -use std::collections::HashMap; -use std::rc::Rc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice #[dom_struct] diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs index 0f7266e0443..fb228033e0b 100644 --- a/components/script/dom/bluetoothpermissionresult.rs +++ b/components/script/dom/bluetoothpermissionresult.rs @@ -2,6 +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 std::rc::Rc; + +use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::BluetoothPermissionResultMethods; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods; @@ -19,10 +25,6 @@ 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; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothpermissionresult #[dom_struct] diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index a3c4b826bd7..71c54461b8a 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -2,6 +2,13 @@ * 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::rc::Rc; + +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 crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods; @@ -23,11 +30,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::realms::InRealm; -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; // Maximum length of an attribute value. // https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 2169) diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index 0e60170857e..6134e42b6a0 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -2,6 +2,13 @@ * 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::rc::Rc; + +use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist}; +use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods; @@ -19,11 +26,6 @@ use crate::dom::bluetoothremotegattcharacteristic::{ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::realms::InRealm; -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; // http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor #[dom_struct] diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index c5ffecb100b..79fa65bd35d 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -2,10 +2,16 @@ * 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::Cell; +use std::rc::Rc; + +use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; + use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::ErrorResult; +use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bluetooth::{get_gatt_children, response_async, AsyncBluetoothListener}; @@ -14,11 +20,6 @@ use crate::dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID}; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::realms::InRealm; -use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; -use std::cell::Cell; -use std::rc::Rc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver #[dom_struct] diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index 62b46a8b9bd..650ba5151d1 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -2,6 +2,11 @@ * 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::rc::Rc; + +use bluetooth_traits::{BluetoothResponse, GATTType}; +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use crate::dom::bindings::error::Error; @@ -14,9 +19,6 @@ 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; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice #[dom_struct] diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index 70c0c28550a..f37fa166032 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -2,14 +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 dom_struct::dom_struct; +use regex::Regex; + use crate::dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use crate::dom::bindings::error::Error::Type; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; -use dom_struct::dom_struct; -use regex::Regex; pub type UUID = DOMString; pub type BluetoothServiceUUID = StringOrUnsignedLong; diff --git a/components/script/dom/broadcastchannel.rs b/components/script/dom/broadcastchannel.rs index dd5149c1203..0140836fade 100644 --- a/components/script/dom/broadcastchannel.rs +++ b/components/script/dom/broadcastchannel.rs @@ -2,6 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::cell::Cell; + +use dom_struct::dom_struct; +use js::rust::{HandleObject, HandleValue}; +use script_traits::BroadcastMsg; +use uuid::Uuid; + use crate::dom::bindings::codegen::Bindings::BroadcastChannelBinding::BroadcastChannelMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; @@ -11,11 +18,6 @@ use crate::dom::bindings::structuredclone; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext as SafeJSContext; -use dom_struct::dom_struct; -use js::rust::{HandleObject, HandleValue}; -use script_traits::BroadcastMsg; -use std::cell::Cell; -use uuid::Uuid; #[dom_struct] pub struct BroadcastChannel { diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index e404998b004..f6a4a1a7bfd 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -2,6 +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::{ + CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle, +}; +use cssparser::{Color as CSSColor, Parser, ParserInput, RGBA}; +use dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods; use crate::dom::bindings::error::{Error, ErrorResult}; @@ -10,12 +16,6 @@ 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; // https://html.spec.whatwg.org/multipage/#canvasgradient #[dom_struct] diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs index 5472598ea28..d63bc938d19 100644 --- a/components/script/dom/canvaspattern.rs +++ b/components/script/dom/canvaspattern.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use euclid::default::Size2D; + 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::default::Size2D; // https://html.spec.whatwg.org/multipage/#canvaspattern #[dom_struct] diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 3ebf8f130d9..d531826652d 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -2,15 +2,19 @@ * 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::mem; + +use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg}; +use dom_struct::dom_struct; +use euclid::default::{Point2D, Rect, Size2D}; +use ipc_channel::ipc::IpcSender; +use servo_url::ServoUrl; + use crate::canvas_state::CanvasState; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasDirection; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextAlign; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextBaseline; +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{ + CanvasDirection, CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin, + CanvasRenderingContext2DMethods, CanvasTextAlign, CanvasTextBaseline, +}; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use crate::dom::bindings::error::{ErrorResult, Fallible}; use crate::dom::bindings::num::Finite; @@ -24,12 +28,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::imagedata::ImageData; use crate::dom::textmetrics::TextMetrics; -use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg}; -use dom_struct::dom_struct; -use euclid::default::{Point2D, Rect, Size2D}; -use ipc_channel::ipc::IpcSender; -use servo_url::ServoUrl; -use std::mem; // https://html.spec.whatwg.org/multipage/#canvasrenderingcontext2d #[dom_struct] diff --git a/components/script/dom/cdatasection.rs b/components/script/dom/cdatasection.rs index 7e026bb7673..6fbe4d1e4b7 100644 --- a/components/script/dom/cdatasection.rs +++ b/components/script/dom/cdatasection.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::node::Node; use crate::dom::text::Text; -use dom_struct::dom_struct; #[dom_struct] pub struct CDATASection { diff --git a/components/script/dom/channelmergernode.rs b/components/script/dom/channelmergernode.rs index 7cafb8b44b6..241e711c290 100644 --- a/components/script/dom/channelmergernode.rs +++ b/components/script/dom/channelmergernode.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::channel_node::ChannelNodeOptions; +use servo_media::audio::node::AudioNodeInit; + use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT}; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ @@ -12,10 +17,6 @@ use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::channel_node::ChannelNodeOptions; -use servo_media::audio::node::AudioNodeInit; #[dom_struct] pub struct ChannelMergerNode { diff --git a/components/script/dom/channelsplitternode.rs b/components/script/dom/channelsplitternode.rs index 077b256ffd8..f6412242215 100644 --- a/components/script/dom/channelsplitternode.rs +++ b/components/script/dom/channelsplitternode.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::AudioNodeInit; + use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT}; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ @@ -12,9 +16,6 @@ use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::AudioNodeInit; #[dom_struct] pub struct ChannelSplitterNode { diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index cbaa847e8ee..3ce66725c7f 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -4,6 +4,8 @@ //! DOM bindings for `CharacterData`. +use dom_struct::dom_struct; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; @@ -23,7 +25,6 @@ use crate::dom::node::{ChildrenMutation, Node, NodeDamage}; use crate::dom::processinginstruction::ProcessingInstruction; use crate::dom::text::Text; use crate::dom::virtualmethods::vtable_for; -use dom_struct::dom_struct; // https://dom.spec.whatwg.org/#characterdata #[dom_struct] diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs index 178f6bfba8c..d8e382e750d 100644 --- a/components/script/dom/client.rs +++ b/components/script/dom/client.rs @@ -2,17 +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 crate::dom::bindings::codegen::Bindings::ClientBinding::ClientMethods; -use crate::dom::bindings::codegen::Bindings::ClientBinding::FrameType; +use std::default::Default; + +use dom_struct::dom_struct; +use servo_url::ServoUrl; +use uuid::Uuid; + +use crate::dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, FrameType}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::serviceworker::ServiceWorker; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_url::ServoUrl; -use std::default::Default; -use uuid::Uuid; #[dom_struct] pub struct Client { diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs index 62a0a066f61..4f136ebe905 100644 --- a/components/script/dom/closeevent.rs +++ b/components/script/dom/closeevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::CloseEventBinding; use crate::dom::bindings::codegen::Bindings::CloseEventBinding::CloseEventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -12,9 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct CloseEvent { diff --git a/components/script/dom/comment.rs b/components/script/dom/comment.rs index 4c5ca9d488e..955b6bab6f6 100644 --- a/components/script/dom/comment.rs +++ b/components/script/dom/comment.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::root::DomRoot; @@ -10,8 +13,6 @@ use crate::dom::characterdata::CharacterData; use crate::dom::document::Document; use crate::dom::node::Node; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; /// An HTML comment. #[dom_struct] diff --git a/components/script/dom/compositionevent.rs b/components/script/dom/compositionevent.rs index 05058a3a0cf..0cf25b22e59 100644 --- a/components/script/dom/compositionevent.rs +++ b/components/script/dom/compositionevent.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::CompositionEventBinding::{ self, CompositionEventMethods, }; @@ -12,8 +15,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct CompositionEvent { diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index 329e4c93c50..77000e25a34 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -2,13 +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::io; + +use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; +use js::rust::describe_scripted_caller; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::workerglobalscope::WorkerGlobalScope; -use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; -use js::rust::describe_scripted_caller; -use std::io; // https://developer.mozilla.org/en-US/docs/Web/API/Console pub struct Console(()); diff --git a/components/script/dom/constantsourcenode.rs b/components/script/dom/constantsourcenode.rs index cbde279923d..4b9b8668706 100644 --- a/components/script/dom/constantsourcenode.rs +++ b/components/script/dom/constantsourcenode.rs @@ -2,22 +2,25 @@ * 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::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::constant_source_node::ConstantSourceNodeOptions as ServoMediaConstantSourceOptions; +use servo_media::audio::node::AudioNodeInit; +use servo_media::audio::param::ParamType; + use crate::dom::audioparam::AudioParam; use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; -use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::ConstantSourceNodeMethods; -use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::ConstantSourceOptions; +use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::{ + ConstantSourceNodeMethods, ConstantSourceOptions, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::constant_source_node::ConstantSourceNodeOptions as ServoMediaConstantSourceOptions; -use servo_media::audio::node::AudioNodeInit; -use servo_media::audio::param::ParamType; -use std::f32; #[dom_struct] pub struct ConstantSourceNode { diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs index 48064fe2f3e..c53bf3516cf 100644 --- a/components/script/dom/create.rs +++ b/components/script/dom/create.rs @@ -2,6 +2,10 @@ * 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 html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; +use js::rust::HandleObject; +use servo_config::pref; + use crate::dom::bindings::error::{report_pending_exception, throw_dom_exception}; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::DomRoot; @@ -34,8 +38,7 @@ use crate::dom::htmlformelement::HTMLFormElement; use crate::dom::htmlframeelement::HTMLFrameElement; use crate::dom::htmlframesetelement::HTMLFrameSetElement; use crate::dom::htmlheadelement::HTMLHeadElement; -use crate::dom::htmlheadingelement::HTMLHeadingElement; -use crate::dom::htmlheadingelement::HeadingLevel; +use crate::dom::htmlheadingelement::{HTMLHeadingElement, HeadingLevel}; use crate::dom::htmlhrelement::HTMLHRElement; use crate::dom::htmlhtmlelement::HTMLHtmlElement; use crate::dom::htmliframeelement::HTMLIFrameElement; @@ -84,9 +87,6 @@ use crate::dom::svgelement::SVGElement; use crate::dom::svgsvgelement::SVGSVGElement; use crate::realms::{enter_realm, InRealm}; use crate::script_thread::ScriptThread; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; -use js::rust::HandleObject; -use servo_config::pref; fn create_svg_element( name: QualName, diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index 3fdcb93a9ec..8005c9e7f7a 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -2,6 +2,14 @@ * 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::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::{JSObject, Type}; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::ArrayBufferView; +use servo_rand::{RngCore, ServoRng}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -9,13 +17,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::JSObject; -use js::jsapi::Type; -use js::rust::CustomAutoRooterGuard; -use js::typedarray::ArrayBufferView; -use servo_rand::{RngCore, ServoRng}; -use std::ptr::NonNull; // https://developer.mozilla.org/en-US/docs/Web/API/Crypto #[dom_struct] diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 8c9600549c5..367f56a5656 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -2,13 +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 crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::Reflector; -use crate::dom::bindings::root::DomRoot; -use crate::dom::bindings::str::DOMString; -use crate::dom::window::Window; -use crate::dom::worklet::Worklet; use cssparser::{serialize_identifier, Parser, ParserInput}; use dom_struct::dom_struct; use style::context::QuirksMode; @@ -17,6 +10,14 @@ use style::stylesheets::supports_rule::{parse_condition_or_declaration, Declarat use style::stylesheets::{CssRuleType, Origin}; use style_traits::ParsingMode; +use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; +use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::reflector::Reflector; +use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::str::DOMString; +use crate::dom::window::Window; +use crate::dom::worklet::Worklet; + #[dom_struct] pub struct CSS { reflector_: Reflector, diff --git a/components/script/dom/cssconditionrule.rs b/components/script/dom/cssconditionrule.rs index 86010eba4e9..1a587c3f290 100644 --- a/components/script/dom/cssconditionrule.rs +++ b/components/script/dom/cssconditionrule.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, SharedRwLock}; +use style::stylesheets::CssRules as StyleCssRules; + use crate::dom::bindings::codegen::Bindings::CSSConditionRuleBinding::CSSConditionRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::str::DOMString; @@ -9,10 +14,6 @@ use crate::dom::cssgroupingrule::CSSGroupingRule; use crate::dom::cssmediarule::CSSMediaRule; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::csssupportsrule::CSSSupportsRule; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, SharedRwLock}; -use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] pub struct CSSConditionRule { diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index 679ec525383..edd175753c0 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -2,16 +2,17 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::FontFaceRule; + use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::FontFaceRule; #[dom_struct] pub struct CSSFontFaceRule { diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs index f89f58126de..c3fa70de189 100644 --- a/components/script/dom/cssgroupingrule.rs +++ b/components/script/dom/cssgroupingrule.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, SharedRwLock}; +use style::stylesheets::CssRules as StyleCssRules; + use crate::dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods; use crate::dom::bindings::error::{ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -11,10 +16,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::cssrule::CSSRule; use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::cssstylesheet::CSSStyleSheet; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, SharedRwLock}; -use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] pub struct CSSGroupingRule { diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index e2da2a04378..857c5cd2909 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -2,16 +2,17 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::ImportRule; + use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::ImportRule; #[dom_struct] pub struct CSSImportRule { diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index 9ab465e79a4..743df167b68 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::keyframes_rule::Keyframe; + use crate::dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::CSSKeyframeRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -11,10 +16,6 @@ use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::keyframes_rule::Keyframe; #[dom_struct] pub struct CSSKeyframeRule { diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 52a25a52dd0..51a63c557e8 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -2,6 +2,13 @@ * 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 cssparser::{Parser, ParserInput}; +use dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesRule}; +use style::values::KeyframesName; + use crate::dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods; use crate::dom::bindings::error::ErrorResult; use crate::dom::bindings::inheritance::Castable; @@ -13,12 +20,6 @@ use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::window::Window; -use cssparser::{Parser, ParserInput}; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesRule}; -use style::values::KeyframesName; #[dom_struct] pub struct CSSKeyframesRule { diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index cc18fc46797..79662f9c637 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -2,6 +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 cssparser::{Parser, ParserInput}; +use dom_struct::dom_struct; +use servo_arc::Arc; +use style::media_queries::MediaList as StyleMediaList; +use style::parser::ParserContext; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::{CssRuleType, MediaRule, Origin}; +use style_traits::{ParsingMode, ToCss}; + use crate::dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -12,14 +21,6 @@ use crate::dom::cssrule::SpecificCSSRule; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::medialist::MediaList; use crate::dom::window::Window; -use cssparser::{Parser, ParserInput}; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::media_queries::MediaList as StyleMediaList; -use style::parser::ParserContext; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::{CssRuleType, MediaRule, Origin}; -use style_traits::{ParsingMode, ToCss}; #[dom_struct] pub struct CSSMediaRule { diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index d03da04b116..173adc54a1a 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::NamespaceRule; + use crate::dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -9,10 +14,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::NamespaceRule; #[dom_struct] pub struct CSSNamespaceRule { diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs index b9cc5c19dbd..7b2858e7986 100644 --- a/components/script/dom/cssrule.rs +++ b/components/script/dom/cssrule.rs @@ -2,6 +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 std::cell::Cell; + +use dom_struct::dom_struct; +use style::shared_lock::SharedRwLock; +use style::stylesheets::CssRule as StyleCssRule; + use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::Reflector; @@ -17,10 +23,6 @@ use crate::dom::cssstylerule::CSSStyleRule; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::csssupportsrule::CSSSupportsRule; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; -use style::shared_lock::SharedRwLock; -use style::stylesheets::CssRule as StyleCssRule; #[dom_struct] pub struct CSSRule { diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index df0ab6134e9..feaf9e819ba 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -4,6 +4,14 @@ #![allow(unsafe_code)] +use dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::Locked; +use style::stylesheets::{ + AllowImportRules, CssRules, CssRulesHelpers, KeyframesRule, RulesMutateError, + StylesheetLoader as StyleStylesheetLoader, +}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -15,13 +23,6 @@ use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::htmlelement::HTMLElement; use crate::dom::window::Window; use crate::stylesheet_loader::StylesheetLoader; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::shared_lock::Locked; -use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; -use style::stylesheets::{ - AllowImportRules, CssRules, CssRulesHelpers, KeyframesRule, RulesMutateError, -}; unsafe_no_jsmanaged_fields!(RulesSource); diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 0e4e541ecf2..c9bc453fe06 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -2,33 +2,32 @@ * 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::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; -use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::str::DOMString; -use crate::dom::cssrule::CSSRule; -use crate::dom::element::Element; -use crate::dom::node::{document_from_node, stylesheets_owner_from_node, window_from_node, Node}; -use crate::dom::window::Window; use dom_struct::dom_struct; use html5ever::local_name; use servo_arc::Arc; use servo_url::ServoUrl; use style::attr::AttrValue; use style::properties::{ - parse_one_declaration_into, parse_style_attribute, SourcePropertyDeclaration, -}; -use style::properties::{ - Importance, LonghandId, PropertyDeclarationBlock, PropertyId, ShorthandId, + parse_one_declaration_into, parse_style_attribute, Importance, LonghandId, + PropertyDeclarationBlock, PropertyId, ShorthandId, SourcePropertyDeclaration, }; use style::selector_parser::PseudoElement; use style::shared_lock::Locked; use style::stylesheets::{CssRuleType, Origin}; use style_traits::ParsingMode; +use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; +use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; +use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::str::DOMString; +use crate::dom::cssrule::CSSRule; +use crate::dom::element::Element; +use crate::dom::node::{document_from_node, stylesheets_owner_from_node, window_from_node, Node}; +use crate::dom::window::Window; + // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface #[dom_struct] pub struct CSSStyleDeclaration { diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index 007a98a7592..bf40c952e2f 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -2,6 +2,16 @@ * 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::mem; + +use cssparser::{Parser as CssParser, ParserInput as CssParserInput, ToCss}; +use dom_struct::dom_struct; +use selectors::parser::SelectorList; +use servo_arc::Arc; +use style::selector_parser::SelectorParser; +use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylesheets::{Origin, StyleRule}; + use crate::dom::bindings::codegen::Bindings::CSSStyleRuleBinding::CSSStyleRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -12,15 +22,6 @@ use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::node::{stylesheets_owner_from_node, Node}; use crate::dom::window::Window; -use cssparser::ToCss; -use cssparser::{Parser as CssParser, ParserInput as CssParserInput}; -use dom_struct::dom_struct; -use selectors::parser::SelectorList; -use servo_arc::Arc; -use std::mem; -use style::selector_parser::SelectorParser; -use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::{Origin, StyleRule}; #[dom_struct] pub struct CSSStyleRule { diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index e8de2ef3add..b7bf410ed36 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -2,6 +2,13 @@ * 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::Cell; + +use dom_struct::dom_struct; +use servo_arc::Arc; +use style::shared_lock::SharedRwLock; +use style::stylesheets::Stylesheet as StyleStyleSheet; + use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -14,11 +21,6 @@ use crate::dom::medialist::MediaList; use crate::dom::node::{stylesheets_owner_from_node, Node}; use crate::dom::stylesheet::StyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use std::cell::Cell; -use style::shared_lock::SharedRwLock; -use style::stylesheets::Stylesheet as StyleStyleSheet; #[dom_struct] pub struct CSSStyleSheet { diff --git a/components/script/dom/cssstylevalue.rs b/components/script/dom/cssstylevalue.rs index f272b34e945..d440c055025 100644 --- a/components/script/dom/cssstylevalue.rs +++ b/components/script/dom/cssstylevalue.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 cssparser::{Parser, ParserInput}; +use dom_struct::dom_struct; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSSStyleValueMethods; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::Reflector; +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 cssparser::Parser; -use cssparser::ParserInput; -use dom_struct::dom_struct; -use servo_url::ServoUrl; #[dom_struct] pub struct CSSStyleValue { diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 0eaa1f9d53a..c321ac88091 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -2,14 +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 crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; -use crate::dom::bindings::root::DomRoot; -use crate::dom::bindings::str::DOMString; -use crate::dom::cssconditionrule::CSSConditionRule; -use crate::dom::cssrule::SpecificCSSRule; -use crate::dom::cssstylesheet::CSSStyleSheet; -use crate::dom::window::Window; use cssparser::{Parser, ParserInput}; use dom_struct::dom_struct; use servo_arc::Arc; @@ -19,6 +11,15 @@ use style::stylesheets::supports_rule::SupportsCondition; use style::stylesheets::{CssRuleType, Origin, SupportsRule}; use style_traits::{ParsingMode, ToCss}; +use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; +use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::str::DOMString; +use crate::dom::cssconditionrule::CSSConditionRule; +use crate::dom::cssrule::SpecificCSSRule; +use crate::dom::cssstylesheet::CSSStyleSheet; +use crate::dom::window::Window; + #[dom_struct] pub struct CSSSupportsRule { cssconditionrule: CSSConditionRule, diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 9439e7e95bc..cc1afce2e48 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -2,11 +2,27 @@ * 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::Cell; +use std::collections::VecDeque; +use std::ops::Deref; +use std::rc::Rc; +use std::{mem, ptr}; + +use dom_struct::dom_struct; +use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix}; +use js::conversions::ToJSValConvertible; +use js::glue::UnwrapObjectStatic; +use js::jsapi::{HandleValueArray, Heap, IsCallable, IsConstructor, JSAutoRealm, JSObject}; +use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue}; +use js::rust::wrappers::{Construct1, JS_GetProperty, SameValue}; +use js::rust::{HandleObject, HandleValue, MutableHandleValue}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::callback::{CallbackContainer, ExceptionHandling}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementConstructor; -use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementRegistryMethods; -use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::ElementDefinitionOptions; +use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::{ + CustomElementConstructor, CustomElementRegistryMethods, ElementDefinitionOptions, +}; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; @@ -33,23 +49,6 @@ use crate::microtask::Microtask; use crate::realms::{enter_realm, InRealm}; use crate::script_runtime::JSContext; use crate::script_thread::ScriptThread; -use dom_struct::dom_struct; -use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix}; -use js::conversions::ToJSValConvertible; -use js::glue::UnwrapObjectStatic; -use js::jsapi::{HandleValueArray, Heap, IsCallable, IsConstructor}; -use js::jsapi::{JSAutoRealm, JSObject}; -use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue}; -use js::rust::wrappers::{Construct1, JS_GetProperty, SameValue}; -use js::rust::{HandleObject, HandleValue, MutableHandleValue}; -use std::cell::Cell; -use std::collections::VecDeque; -use std::mem; -use std::ops::Deref; -use std::ptr; -use std::rc::Rc; - -use super::bindings::trace::HashMapTracedValues; /// <https://dom.spec.whatwg.org/#concept-element-custom-element-state> #[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)] diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index 4004adebd82..312cfc399de 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::CustomEventBinding; use crate::dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -14,12 +20,6 @@ use crate::dom::bindings::trace::RootedTraceableBox; use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::HandleObject; -use js::rust::HandleValue; -use servo_atoms::Atom; // https://dom.spec.whatwg.org/#interface-customevent #[dom_struct] diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 956634856ce..22bd6195389 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -2,10 +2,36 @@ * 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::mem::replace; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; +use std::thread::{self, JoinHandle}; + +use crossbeam_channel::{unbounded, Receiver, Sender}; +use devtools_traits::DevtoolScriptControlMsg; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcReceiver; +use ipc_channel::router::ROUTER; +use js::jsapi::{Heap, JSContext, JSObject, JS_AddInterruptCallback}; +use js::jsval::UndefinedValue; +use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; +use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; +use net_traits::image_cache::ImageCache; +use net_traits::request::{ + CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder, RequestMode, +}; +use net_traits::IpcSend; +use parking_lot::Mutex; +use script_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; +use servo_rand::random; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style::thread_state::{self, ThreadState}; + use crate::devtools; use crate::dom::abstractworker::{SimpleWorkerErrorHandler, WorkerScriptMsg}; -use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods}; -use crate::dom::abstractworkerglobalscope::{SendableWorkerScriptChan, WorkerThreadWorkerChan}; +use crate::dom::abstractworkerglobalscope::{ + run_worker_event_loop, SendableWorkerScriptChan, WorkerEventLoopMethods, WorkerThreadWorkerChan, +}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding; use crate::dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods; @@ -36,29 +62,6 @@ use crate::script_runtime::{ use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::TaskSourceName; -use crossbeam_channel::{unbounded, Receiver, Sender}; -use devtools_traits::DevtoolScriptControlMsg; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcReceiver; -use ipc_channel::router::ROUTER; -use js::jsapi::JS_AddInterruptCallback; -use js::jsapi::{Heap, JSContext, JSObject}; -use js::jsval::UndefinedValue; -use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; -use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; -use net_traits::image_cache::ImageCache; -use net_traits::request::{CredentialsMode, Destination, ParserMetadata}; -use net_traits::request::{Referrer, RequestBuilder, RequestMode}; -use net_traits::IpcSend; -use parking_lot::Mutex; -use script_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; -use servo_rand::random; -use servo_url::{ImmutableOrigin, ServoUrl}; -use std::mem::replace; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; -use std::thread::{self, JoinHandle}; -use style::thread_state::{self, ThreadState}; /// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular /// value for the duration of this object's lifetime. This ensures that the related Worker diff --git a/components/script/dom/dissimilaroriginlocation.rs b/components/script/dom/dissimilaroriginlocation.rs index d1c466bb781..cae89941ce6 100644 --- a/components/script/dom/dissimilaroriginlocation.rs +++ b/components/script/dom/dissimilaroriginlocation.rs @@ -2,15 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding::DissimilarOriginLocationMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::Reflector; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::str::DOMString; -use crate::dom::bindings::str::USVString; +use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::dissimilaroriginwindow::DissimilarOriginWindow; -use dom_struct::dom_struct; /// Represents a dissimilar-origin `Location` that exists in another script thread. /// diff --git a/components/script/dom/dissimilaroriginwindow.rs b/components/script/dom/dissimilaroriginwindow.rs index 13d836114c6..cd38216d0ca 100644 --- a/components/script/dom/dissimilaroriginwindow.rs +++ b/components/script/dom/dissimilaroriginwindow.rs @@ -2,6 +2,14 @@ * 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 dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; +use js::jsval::{JSVal, UndefinedValue}; +use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; +use msg::constellation_msg::PipelineId; +use script_traits::{ScriptMsg, StructuredSerializedData}; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding; use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowPostMessageOptions; @@ -14,13 +22,6 @@ use crate::dom::dissimilaroriginlocation::DissimilarOriginLocation; use crate::dom::globalscope::GlobalScope; use crate::dom::windowproxy::WindowProxy; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use js::jsval::{JSVal, UndefinedValue}; -use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; -use msg::constellation_msg::PipelineId; -use script_traits::{ScriptMsg, StructuredSerializedData}; -use servo_url::ServoUrl; /// Represents a dissimilar-origin `Window` that exists in another script thread. /// diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index c34ed1128d0..070d8b0d906 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2,6 +2,75 @@ * 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::borrow::Cow; +use std::cell::Cell; +use std::cmp::Ordering; +use std::collections::hash_map::Entry::{Occupied, Vacant}; +use std::collections::{HashMap, HashSet, VecDeque}; +use std::default::Default; +use std::mem; +use std::ptr::NonNull; +use std::rc::Rc; +use std::slice::from_ref; +use std::time::{Duration, Instant}; + +use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg}; +use content_security_policy::{self as csp, CspList}; +use cookie::Cookie; +use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; +use devtools_traits::ScriptToDevtoolsControlMsg; +use dom_struct::dom_struct; +use embedder_traits::EmbedderMsg; +use encoding_rs::{Encoding, UTF_8}; +use euclid::default::{Point2D, Rect, Size2D}; +use html5ever::{local_name, namespace_url, ns, LocalName, Namespace, QualName}; +use hyper_serde::Serde; +use ipc_channel::ipc::{self, IpcSender}; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use keyboard_types::{Code, Key, KeyState}; +use lazy_static::lazy_static; +use metrics::{ + InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, + ProgressiveWebMetric, +}; +use mime::{self, Mime}; +use msg::constellation_msg::BrowsingContextId; +use net_traits::pub_domains::is_pub_domain; +use net_traits::request::RequestBuilder; +use net_traits::response::HttpsState; +use net_traits::CookieSource::NonHTTP; +use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl}; +use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy}; +use num_traits::ToPrimitive; +use percent_encoding::percent_decode; +use profile_traits::ipc as profile_ipc; +use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; +use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal}; +use script_layout_interface::TrustedNodeAddress; +use script_traits::{ + AnimationState, DocumentActivity, MouseButton, MouseEventType, MsDuration, ScriptMsg, + TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta, +}; +use servo_arc::Arc; +use servo_atoms::Atom; +use servo_config::pref; +use servo_media::{ClientContextId, ServoMedia}; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; +use style::attr::AttrValue; +use style::context::QuirksMode; +use style::invalidation::element::restyle_hints::RestyleHint; +use style::media_queries::{Device, MediaType}; +use style::selector_parser::Snapshot; +use style::shared_lock::SharedRwLock as StyleSharedRwLock; +use style::str::{split_html_space_chars, str_join}; +use style::stylesheet_set::DocumentStylesheetSet; +use style::stylesheets::{Origin, OriginSet, Stylesheet}; +use url::Host; +use uuid::Uuid; +use webrender_api::units::DeviceIntRect; + +use super::bindings::trace::{HashMapTracedValues, NoTrace}; use crate::animation_timeline::AnimationTimeline; use crate::animations::Animations; use crate::document_loader::{DocumentLoader, LoadType}; @@ -48,9 +117,9 @@ use crate::dom::documentfragment::DocumentFragment; use crate::dom::documentorshadowroot::{DocumentOrShadowRoot, StyleSheetInDocument}; use crate::dom::documenttype::DocumentType; use crate::dom::domimplementation::DOMImplementation; -use crate::dom::element::CustomElementCreationMode; use crate::dom::element::{ - Element, ElementCreator, ElementPerformFullscreenEnter, ElementPerformFullscreenExit, + CustomElementCreationMode, Element, ElementCreator, ElementPerformFullscreenEnter, + ElementPerformFullscreenExit, }; use crate::dom::event::{Event, EventBubbles, EventCancelable, EventDefault, EventStatus}; use crate::dom::eventtarget::EventTarget; @@ -78,8 +147,10 @@ use crate::dom::keyboardevent::KeyboardEvent; use crate::dom::location::Location; use crate::dom::messageevent::MessageEvent; use crate::dom::mouseevent::MouseEvent; -use crate::dom::node::{self, document_from_node, window_from_node, CloneChildrenFlag}; -use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding}; +use crate::dom::node::{ + self, document_from_node, window_from_node, CloneChildrenFlag, Node, NodeDamage, NodeFlags, + ShadowIncluding, +}; use crate::dom::nodeiterator::NodeIterator; use crate::dom::nodelist::NodeList; use crate::dom::pagetransitionevent::PageTransitionEvent; @@ -104,81 +175,12 @@ use crate::dom::window::{ReflowReason, Window}; use crate::dom::windowproxy::WindowProxy; use crate::fetch::FetchCanceller; use crate::realms::{AlreadyInRealm, InRealm}; -use crate::script_runtime::JSContext; -use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; +use crate::script_runtime::{CommonScriptMsg, JSContext, ScriptThreadEventCategory}; use crate::script_thread::{MainThreadScriptMsg, ScriptThread}; use crate::stylesheet_set::StylesheetSetRef; use crate::task::TaskBox; use crate::task_source::{TaskSource, TaskSourceName}; use crate::timers::OneshotTimerCallback; -use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg}; -use content_security_policy::{self as csp, CspList}; -use cookie::Cookie; -use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; -use devtools_traits::ScriptToDevtoolsControlMsg; -use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; -use encoding_rs::{Encoding, UTF_8}; -use euclid::default::{Point2D, Rect, Size2D}; -use html5ever::{local_name, namespace_url, ns, LocalName, Namespace, QualName}; -use hyper_serde::Serde; -use ipc_channel::ipc::{self, IpcSender}; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use keyboard_types::{Code, Key, KeyState}; -use lazy_static::lazy_static; -use metrics::{ - InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, - ProgressiveWebMetric, -}; -use mime::{self, Mime}; -use msg::constellation_msg::BrowsingContextId; -use net_traits::pub_domains::is_pub_domain; -use net_traits::request::RequestBuilder; -use net_traits::response::HttpsState; -use net_traits::CookieSource::NonHTTP; -use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl}; -use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy}; -use num_traits::ToPrimitive; -use percent_encoding::percent_decode; -use profile_traits::ipc as profile_ipc; -use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; -use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal}; -use script_layout_interface::TrustedNodeAddress; -use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType}; -use script_traits::{ - MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta, -}; -use servo_arc::Arc; -use servo_atoms::Atom; -use servo_config::pref; -use servo_media::{ClientContextId, ServoMedia}; -use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; -use std::borrow::Cow; -use std::cell::Cell; -use std::cmp::Ordering; -use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::default::Default; -use std::mem; -use std::ptr::NonNull; -use std::rc::Rc; -use std::slice::from_ref; -use std::time::{Duration, Instant}; -use style::attr::AttrValue; -use style::context::QuirksMode; -use style::invalidation::element::restyle_hints::RestyleHint; -use style::media_queries::{Device, MediaType}; -use style::selector_parser::Snapshot; -use style::shared_lock::SharedRwLock as StyleSharedRwLock; -use style::str::{split_html_space_chars, str_join}; -use style::stylesheet_set::DocumentStylesheetSet; -use style::stylesheets::{Origin, OriginSet, Stylesheet}; -use url::Host; -use uuid::Uuid; -use webrender_api::units::DeviceIntRect; - -use super::bindings::trace::{HashMapTracedValues, NoTrace}; /// The number of times we are allowed to see spurious `requestAnimationFrame()` calls before /// falling back to fake ones. diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs index f2455f61130..c9999ba4f44 100644 --- a/components/script/dom/documentfragment.rs +++ b/components/script/dom/documentfragment.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -16,11 +21,6 @@ use crate::dom::htmlcollection::HTMLCollection; use crate::dom::node::{window_from_node, Node}; use crate::dom::nodelist::NodeList; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; - -use super::bindings::trace::HashMapTracedValues; // https://dom.spec.whatwg.org/#documentfragment #[dom_struct] diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 14e4774c55b..3e87132f03e 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -2,28 +2,29 @@ * 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::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::num::Finite; -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::element::Element; -use crate::dom::htmlelement::HTMLElement; -use crate::dom::node::{self, Node, VecPreOrderInsertionHelper}; -use crate::dom::window::Window; -use crate::stylesheet_set::StylesheetSetRef; +use std::fmt; + use euclid::default::Point2D; use script_layout_interface::message::{NodesFromPointQueryType, QueryMsg}; use script_traits::UntrustedNodeAddress; use servo_arc::Arc; use servo_atoms::Atom; -use std::fmt; use style::invalidation::media_queries::{MediaListKey, ToMediaListKey}; use style::media_queries::MediaList; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard}; use style::stylesheets::{Stylesheet, StylesheetContents}; use super::bindings::trace::HashMapTracedValues; +use crate::dom::bindings::cell::DomRefCell; +use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::num::Finite; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::element::Element; +use crate::dom::htmlelement::HTMLElement; +use crate::dom::node::{self, Node, VecPreOrderInsertionHelper}; +use crate::dom::window::Window; +use crate::stylesheet_set::StylesheetSetRef; #[derive(Clone, JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index f323cd63d63..f55eaac6c8f 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods; use crate::dom::bindings::codegen::UnionTypes::NodeOrString; use crate::dom::bindings::error::ErrorResult; @@ -10,7 +12,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::node::Node; -use dom_struct::dom_struct; // https://dom.spec.whatwg.org/#documenttype /// The `DOCTYPE` tag. diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index e5462fa4376..c058136a8b5 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -2,8 +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 crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants; -use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods; +use dom_struct::dom_struct; +use js::rust::HandleObject; + +use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::{ + DOMExceptionConstants, DOMExceptionMethods, +}; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{ reflect_dom_object, reflect_dom_object_with_proto, Reflector, @@ -11,8 +15,6 @@ use crate::dom::bindings::reflector::{ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[repr(u16)] #[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index 95a62b19efa..37712dd3d05 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns}; +use script_traits::DocumentActivity; + use crate::document_loader::DocumentLoader; use crate::dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementationMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ @@ -15,8 +19,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name}; -use crate::dom::document::DocumentSource; -use crate::dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; +use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; use crate::dom::documenttype::DocumentType; use crate::dom::htmlbodyelement::HTMLBodyElement; use crate::dom::htmlheadelement::HTMLHeadElement; @@ -25,9 +28,6 @@ use crate::dom::htmltitleelement::HTMLTitleElement; use crate::dom::node::Node; use crate::dom::text::Text; use crate::dom::xmldocument::XMLDocument; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns}; -use script_traits::DocumentActivity; // https://dom.spec.whatwg.org/#domimplementation #[dom_struct] diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index c37ba3dfc79..dd6aff6ea0f 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use euclid::default::Transform3D; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{Float32Array, Float64Array}; + use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrUnrestrictedDoubleSequence; @@ -15,10 +20,6 @@ use crate::dom::dommatrixreadonly::{ }; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use euclid::default::Transform3D; -use js::rust::{CustomAutoRooterGuard, HandleObject}; -use js::typedarray::{Float32Array, Float64Array}; #[dom_struct] pub struct DOMMatrix { diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index f6cc458b618..a20c935ee89 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -2,6 +2,19 @@ * 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::Cell; +use std::ptr::NonNull; +use std::{f64, ptr}; + +use cssparser::{Parser, ParserInput}; +use dom_struct::dom_struct; +use euclid::default::Transform3D; +use euclid::Angle; +use js::jsapi::JSObject; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{CreateWith, Float32Array, Float64Array}; +use style::parser::ParserContext; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; @@ -17,18 +30,6 @@ use crate::dom::dompoint::DOMPoint; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::script_runtime::JSContext; -use cssparser::{Parser, ParserInput}; -use dom_struct::dom_struct; -use euclid::{default::Transform3D, Angle}; -use js::jsapi::JSObject; -use js::rust::{CustomAutoRooterGuard, HandleObject}; -use js::typedarray::CreateWith; -use js::typedarray::{Float32Array, Float64Array}; -use std::cell::Cell; -use std::f64; -use std::ptr; -use std::ptr::NonNull; -use style::parser::ParserContext; #[dom_struct] #[allow(non_snake_case)] diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index 9562a32d844..6bfb195ee46 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -2,26 +2,25 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use script_traits::DocumentActivity; + use crate::document_loader::DocumentLoader; use crate::dom::bindings::codegen::Bindings::DOMParserBinding; use crate::dom::bindings::codegen::Bindings::DOMParserBinding::DOMParserMethods; -use crate::dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Application_xhtml_xml; -use crate::dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Application_xml; -use crate::dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Text_html; -use crate::dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Text_xml; +use crate::dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::{ + Application_xhtml_xml, Application_xml, Text_html, Text_xml, +}; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; -use crate::dom::document::DocumentSource; -use crate::dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; +use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; use crate::dom::servoparser::ServoParser; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use script_traits::DocumentActivity; #[dom_struct] pub struct DOMParser { diff --git a/components/script/dom/dompoint.rs b/components/script/dom/dompoint.rs index 1398712076b..31835f08cbd 100644 --- a/components/script/dom/dompoint.rs +++ b/components/script/dom/dompoint.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods}; use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use crate::dom::bindings::error::Fallible; @@ -9,8 +12,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods}; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; // http://dev.w3.org/fxtf/geometry/Overview.html#dompoint #[dom_struct] diff --git a/components/script/dom/dompointreadonly.rs b/components/script/dom/dompointreadonly.rs index 2e5386a367d..a782d6b5180 100644 --- a/components/script/dom/dompointreadonly.rs +++ b/components/script/dom/dompointreadonly.rs @@ -2,15 +2,17 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::cell::Cell; // http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly #[dom_struct] diff --git a/components/script/dom/domquad.rs b/components/script/dom/domquad.rs index f015b09ee1c..ce824911eb2 100644 --- a/components/script/dom/domquad.rs +++ b/components/script/dom/domquad.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods}; use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods}; use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit; @@ -11,8 +14,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::dompoint::DOMPoint; use crate::dom::domrect::DOMRect; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; // https://drafts.fxtf.org/geometry/#DOMQuad #[dom_struct] diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index 5fa5db8a606..86dc264a650 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use crate::dom::bindings::error::Fallible; @@ -9,8 +12,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::domrectreadonly::DOMRectReadOnly; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct DOMRect { diff --git a/components/script/dom/domrectreadonly.rs b/components/script/dom/domrectreadonly.rs index 09461954285..8deb6fd5c5c 100644 --- a/components/script/dom/domrectreadonly.rs +++ b/components/script/dom/domrectreadonly.rs @@ -2,14 +2,16 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::cell::Cell; #[dom_struct] pub struct DOMRectReadOnly { diff --git a/components/script/dom/domstringlist.rs b/components/script/dom/domstringlist.rs index a1592faca79..25c770f1e4d 100644 --- a/components/script/dom/domstringlist.rs +++ b/components/script/dom/domstringlist.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::DOMStringListBinding::DOMStringListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct DOMStringList { diff --git a/components/script/dom/domstringmap.rs b/components/script/dom/domstringmap.rs index 9ff1071e85b..28998e0ba01 100644 --- a/components/script/dom/domstringmap.rs +++ b/components/script/dom/domstringmap.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods; use crate::dom::bindings::error::ErrorResult; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,7 +11,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::window_from_node; -use dom_struct::dom_struct; #[dom_struct] pub struct DOMStringMap { diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 0d8b4908f53..d448d3dce58 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{namespace_url, ns, LocalName}; +use servo_atoms::Atom; +use style::str::HTML_SPACE_CHARACTERS; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -10,10 +15,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::element::Element; use crate::dom::node::window_from_node; -use dom_struct::dom_struct; -use html5ever::{namespace_url, ns, LocalName}; -use servo_atoms::Atom; -use style::str::HTML_SPACE_CHARACTERS; #[dom_struct] pub struct DOMTokenList { diff --git a/components/script/dom/dynamicmoduleowner.rs b/components/script/dom/dynamicmoduleowner.rs index 67f83442d8f..28bd0636d3a 100644 --- a/components/script/dom/dynamicmoduleowner.rs +++ b/components/script/dom/dynamicmoduleowner.rs @@ -2,14 +2,16 @@ * 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::rc::Rc; + +use dom_struct::dom_struct; +use uuid::Uuid; + use crate::dom::bindings::codegen::Bindings::DynamicModuleOwnerBinding::DynamicModuleOwnerMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; -use dom_struct::dom_struct; -use std::rc::Rc; -use uuid::Uuid; /// An unique id for dynamic module #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index ecbc3c8c097..31ea2701c82 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -4,6 +4,66 @@ //! Element nodes. +use std::borrow::Cow; +use std::cell::Cell; +use std::default::Default; +use std::ops::Deref; +use std::rc::Rc; +use std::str::FromStr; +use std::{fmt, mem}; + +use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; +use devtools_traits::AttrInfo; +use dom_struct::dom_struct; +use euclid::default::{Rect, Size2D}; +use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; +use html5ever::serialize::{SerializeOpts, TraversalScope}; +use html5ever::{ + local_name, namespace_prefix, namespace_url, ns, serialize, LocalName, Namespace, Prefix, + QualName, +}; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::HandleObject; +use msg::constellation_msg::InputMethodType; +use net_traits::request::CorsSettings; +use net_traits::ReferrerPolicy; +use script_layout_interface::message::ReflowGoal; +use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; +use selectors::matching::{ElementSelectorFlags, MatchingContext}; +use selectors::sink::Push; +use selectors::Element as SelectorsElement; +use servo_arc::Arc; +use servo_atoms::Atom; +use style::applicable_declarations::ApplicableDeclarationBlock; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; +use style::context::QuirksMode; +use style::element_state::ElementState; +use style::invalidation::element::restyle_hints::RestyleHint; +use style::properties::longhands::{ + self, background_image, border_spacing, font_family, font_size, +}; +use style::properties::{ + parse_style_attribute, ComputedValues, Importance, PropertyDeclaration, + PropertyDeclarationBlock, +}; +use style::rule_tree::CascadeLevel; +use style::selector_parser::{ + extended_filtering, NonTSPseudoClass, PseudoElement, RestyleDamage, SelectorImpl, + SelectorParser, +}; +use style::shared_lock::{Locked, SharedRwLock}; +use style::stylesheets::layer_rule::LayerOrder; +use style::stylesheets::CssRuleType; +use style::values::generics::NonNegative; +use style::values::{computed, specified, AtomIdent, AtomString, CSSFloat}; +use style::{dom_apis, thread_state, CaseSensitivityExt}; +use xml5ever::serialize as xmlSerialize; +use xml5ever::serialize::TraversalScope::{ + ChildrenOnly as XmlChildrenOnly, IncludeNode as XmlIncludeNode, +}; +use xml5ever::serialize::{SerializeOpts as XmlSerializeOpts, TraversalScope as XmlTraversalScope}; + use crate::dom::activation::Activatable; use crate::dom::attr::{Attr, AttrHelpersForLayout}; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut}; @@ -14,8 +74,9 @@ use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootBinding::ShadowRootMethods; -use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions}; +use crate::dom::bindings::codegen::Bindings::WindowBinding::{ + ScrollBehavior, ScrollToOptions, WindowMethods, +}; use crate::dom::bindings::codegen::UnionTypes::NodeOrString; use crate::dom::bindings::conversions::DerivedFrom; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -69,9 +130,10 @@ use crate::dom::htmltemplateelement::HTMLTemplateElement; use crate::dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers}; use crate::dom::mutationobserver::{Mutation, MutationObserver}; use crate::dom::namednodemap::NamedNodeMap; -use crate::dom::node::{document_from_node, window_from_node}; -use crate::dom::node::{BindContext, NodeDamage, NodeFlags, UnbindContext}; -use crate::dom::node::{ChildrenMutation, LayoutNodeHelpers, Node, ShadowIncluding}; +use crate::dom::node::{ + document_from_node, window_from_node, BindContext, ChildrenMutation, LayoutNodeHelpers, Node, + NodeDamage, NodeFlags, ShadowIncluding, UnbindContext, +}; use crate::dom::nodelist::NodeList; use crate::dom::promise::Promise; use crate::dom::raredata::ElementRareData; @@ -84,67 +146,6 @@ use crate::dom::window::ReflowReason; use crate::script_thread::ScriptThread; use crate::stylesheet_loader::StylesheetOwner; use crate::task::TaskOnce; -use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; -use devtools_traits::AttrInfo; -use dom_struct::dom_struct; -use euclid::default::Rect; -use euclid::default::Size2D; -use html5ever::serialize; -use html5ever::serialize::SerializeOpts; -use html5ever::serialize::TraversalScope; -use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; -use html5ever::{ - local_name, namespace_prefix, namespace_url, ns, LocalName, Namespace, Prefix, QualName, -}; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::HandleObject; -use msg::constellation_msg::InputMethodType; -use net_traits::request::CorsSettings; -use net_traits::ReferrerPolicy; -use script_layout_interface::message::ReflowGoal; -use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; -use selectors::matching::{ElementSelectorFlags, MatchingContext}; -use selectors::sink::Push; -use selectors::Element as SelectorsElement; -use servo_arc::Arc; -use servo_atoms::Atom; -use std::borrow::Cow; -use std::cell::Cell; -use std::default::Default; -use std::fmt; -use std::mem; -use std::ops::Deref; -use std::rc::Rc; -use std::str::FromStr; -use style::applicable_declarations::ApplicableDeclarationBlock; -use style::attr::{AttrValue, LengthOrPercentageOrAuto}; -use style::context::QuirksMode; -use style::dom_apis; -use style::element_state::ElementState; -use style::invalidation::element::restyle_hints::RestyleHint; -use style::properties::longhands::{ - self, background_image, border_spacing, font_family, font_size, -}; -use style::properties::{parse_style_attribute, PropertyDeclarationBlock}; -use style::properties::{ComputedValues, Importance, PropertyDeclaration}; -use style::rule_tree::CascadeLevel; -use style::selector_parser::extended_filtering; -use style::selector_parser::{ - NonTSPseudoClass, PseudoElement, RestyleDamage, SelectorImpl, SelectorParser, -}; -use style::shared_lock::{Locked, SharedRwLock}; -use style::stylesheets::layer_rule::LayerOrder; -use style::stylesheets::CssRuleType; -use style::thread_state; -use style::values::generics::NonNegative; -use style::values::{computed, specified, AtomIdent, AtomString, CSSFloat}; -use style::CaseSensitivityExt; -use xml5ever::serialize as xmlSerialize; -use xml5ever::serialize::SerializeOpts as XmlSerializeOpts; -use xml5ever::serialize::TraversalScope as XmlTraversalScope; -use xml5ever::serialize::TraversalScope::ChildrenOnly as XmlChildrenOnly; -use xml5ever::serialize::TraversalScope::IncludeNode as XmlIncludeNode; // TODO: Update focus state when the top-level browsing context gains or loses system focus, // and when the element enters or leaves a browsing context container. diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index cc8664849df..c144ca258a7 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -2,6 +2,14 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ErrorEventBinding; use crate::dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods; @@ -15,12 +23,6 @@ use crate::dom::bindings::trace::RootedTraceableBox; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; -use std::cell::Cell; #[dom_struct] pub struct ErrorEvent { diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 78a409ce507..aaf913fea8e 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -2,6 +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::Cell; +use std::default::Default; + +use devtools_traits::{TimelineMarker, TimelineMarkerType}; +use dom_struct::dom_struct; +use js::rust::HandleObject; +use metrics::ToMs; +use servo_atoms::Atom; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding; @@ -26,13 +35,6 @@ use crate::dom::performance::reduce_timing_resolution; use crate::dom::virtualmethods::vtable_for; use crate::dom::window::Window; use crate::task::TaskOnce; -use devtools_traits::{TimelineMarker, TimelineMarkerType}; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use metrics::ToMs; -use servo_atoms::Atom; -use std::cell::Cell; -use std::default::Default; #[dom_struct] pub struct Event { diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs index 57d8a84df8b..7827175bb96 100644 --- a/components/script/dom/eventsource.rs +++ b/components/script/dom/eventsource.rs @@ -2,6 +2,30 @@ * 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::Cell; +use std::mem; +use std::str::{Chars, FromStr}; +use std::sync::{Arc, Mutex}; + +use dom_struct::dom_struct; +use euclid::Length; +use headers::ContentType; +use http::header::{self, HeaderName, HeaderValue}; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::conversions::ToJSValConvertible; +use js::jsval::UndefinedValue; +use js::rust::HandleObject; +use mime::{self, Mime}; +use net_traits::request::{CacheMode, CorsSettings, Destination, RequestBuilder}; +use net_traits::{ + CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, FetchResponseMsg, + FilteredMetadata, NetworkError, ResourceFetchTiming, ResourceTimingType, +}; +use servo_atoms::Atom; +use servo_url::ServoUrl; +use utf8; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{ EventSourceInit, EventSourceMethods, @@ -22,27 +46,6 @@ use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingLi use crate::realms::enter_realm; use crate::task_source::{TaskSource, TaskSourceName}; use crate::timers::OneshotTimerCallback; -use dom_struct::dom_struct; -use euclid::Length; -use headers::ContentType; -use http::header::{self, HeaderName, HeaderValue}; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::conversions::ToJSValConvertible; -use js::jsval::UndefinedValue; -use js::rust::HandleObject; -use mime::{self, Mime}; -use net_traits::request::{CacheMode, CorsSettings, Destination, RequestBuilder}; -use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FilteredMetadata}; -use net_traits::{FetchResponseListener, FetchResponseMsg, NetworkError}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use servo_atoms::Atom; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::mem; -use std::str::{Chars, FromStr}; -use std::sync::{Arc, Mutex}; -use utf8; const DEFAULT_RECONNECTION_TIME: u64 = 5000; diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 83180485ec1..d291eaba747 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -2,23 +2,44 @@ * 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::collections::hash_map::Entry::{Occupied, Vacant}; +use std::default::Default; +use std::ffi::CString; +use std::hash::BuildHasherDefault; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::rc::Rc; + +use deny_public_fields::DenyPublicFields; +use dom_struct::dom_struct; +use fnv::FnvHasher; +use js::jsapi::JS_GetFunctionObject; +use js::rust::wrappers::CompileFunction; +use js::rust::{ + transform_u16_to_source_text, CompileOptionsWrapper, HandleObject, RootedObjectVectorWrapper, +}; +use libc::c_char; +use servo_atoms::Atom; +use servo_url::ServoUrl; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::beforeunloadevent::BeforeUnloadEvent; use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use crate::dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; -use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnBeforeUnloadEventHandlerNonNull; -use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull; +use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::{ + EventHandlerNonNull, OnBeforeUnloadEventHandlerNonNull, OnErrorEventHandlerNonNull, +}; use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; +use crate::dom::bindings::codegen::Bindings::EventTargetBinding::{ + AddEventListenerOptions, EventListenerOptions, EventTargetMethods, +}; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::UnionTypes::AddEventListenerOptionsOrBoolean; -use crate::dom::bindings::codegen::UnionTypes::EventListenerOptionsOrBoolean; -use crate::dom::bindings::codegen::UnionTypes::EventOrString; +use crate::dom::bindings::codegen::UnionTypes::{ + AddEventListenerOptionsOrBoolean, EventListenerOptionsOrBoolean, EventOrString, +}; use crate::dom::bindings::error::{report_pending_exception, Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; @@ -34,25 +55,6 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::dom::window::Window; use crate::dom::workerglobalscope::WorkerGlobalScope; use crate::realms::{enter_realm, InRealm}; -use deny_public_fields::DenyPublicFields; -use dom_struct::dom_struct; -use fnv::FnvHasher; -use js::jsapi::JS_GetFunctionObject; -use js::rust::transform_u16_to_source_text; -use js::rust::wrappers::CompileFunction; -use js::rust::{CompileOptionsWrapper, HandleObject, RootedObjectVectorWrapper}; -use libc::c_char; -use servo_atoms::Atom; -use servo_url::ServoUrl; -use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::default::Default; -use std::ffi::CString; -use std::hash::BuildHasherDefault; -use std::mem; -use std::ops::{Deref, DerefMut}; -use std::rc::Rc; - -use super::bindings::trace::HashMapTracedValues; #[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] pub enum CommonEventHandler { diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs index 2ba241a8b8a..fa9a570be83 100644 --- a/components/script/dom/extendableevent.rs +++ b/components/script/dom/extendableevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::{self, EventMethods}; use crate::dom::bindings::codegen::Bindings::ExtendableEventBinding; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -12,9 +16,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; // https://w3c.github.io/ServiceWorker/#extendable-event #[dom_struct] diff --git a/components/script/dom/extendablemessageevent.rs b/components/script/dom/extendablemessageevent.rs index 8c5812f9d91..892769bf14b 100644 --- a/components/script/dom/extendablemessageevent.rs +++ b/components/script/dom/extendablemessageevent.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ExtendableMessageEventBinding; use crate::dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableMessageEventMethods; @@ -19,11 +25,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::messageport::MessagePort; use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; #[dom_struct] #[allow(non_snake_case)] diff --git a/components/script/dom/fakexrdevice.rs b/components/script/dom/fakexrdevice.rs index a1905965bc3..17d3a192fc3 100644 --- a/components/script/dom/fakexrdevice.rs +++ b/components/script/dom/fakexrdevice.rs @@ -2,6 +2,19 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; +use euclid::{Point2D, Point3D, Rect, RigidTransform3D, Rotation3D, Size2D, Transform3D, Vector3D}; +use ipc_channel::ipc::IpcSender; +use ipc_channel::router::ROUTER; +use profile_traits::ipc; +use webxr_api::{ + EntityType, Handedness, InputId, InputSource, MockDeviceMsg, MockInputInit, MockRegion, + MockViewInit, MockViewsInit, MockWorld, TargetRayMode, Triangle, Visibility, +}; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{ FakeXRDeviceMethods, FakeXRRegionType, FakeXRRigidTransformInit, FakeXRViewInit, @@ -21,18 +34,6 @@ use crate::dom::fakexrinputcontroller::FakeXRInputController; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use euclid::{Point2D, Rect, Size2D}; -use euclid::{Point3D, RigidTransform3D, Rotation3D, Transform3D, Vector3D}; -use ipc_channel::ipc::IpcSender; -use ipc_channel::router::ROUTER; -use profile_traits::ipc; -use std::cell::Cell; -use std::rc::Rc; -use webxr_api::{ - EntityType, Handedness, InputId, InputSource, MockDeviceMsg, MockInputInit, MockRegion, - MockViewInit, MockViewsInit, MockWorld, TargetRayMode, Triangle, Visibility, -}; #[dom_struct] pub struct FakeXRDevice { diff --git a/components/script/dom/fakexrinputcontroller.rs b/components/script/dom/fakexrinputcontroller.rs index 047729b96f6..bdeaefb450f 100644 --- a/components/script/dom/fakexrinputcontroller.rs +++ b/components/script/dom/fakexrinputcontroller.rs @@ -2,6 +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 dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use webxr_api::{ + Handedness, InputId, MockDeviceMsg, MockInputMsg, SelectEvent, SelectKind, TargetRayMode, +}; + use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit; use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputControllerMethods; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ @@ -13,11 +19,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::fakexrdevice::get_origin; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; -use webxr_api::{ - Handedness, InputId, MockDeviceMsg, MockInputMsg, SelectEvent, SelectKind, TargetRayMode, -}; #[dom_struct] pub struct FakeXRInputController { diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 53ca5fafb02..2e041e2112c 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use net_traits::filemanager_thread::SelectedFile; +use script_traits::serializable::BlobImpl; + use crate::dom::bindings::codegen::Bindings::FileBinding; use crate::dom::bindings::codegen::Bindings::FileBinding::FileMethods; use crate::dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferViewOrBlobOrString; @@ -13,10 +18,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::blob::{blob_parts_to_bytes, normalize_type_string, Blob}; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use net_traits::filemanager_thread::SelectedFile; -use script_traits::serializable::BlobImpl; #[dom_struct] pub struct File { diff --git a/components/script/dom/filelist.rs b/components/script/dom/filelist.rs index de83ccb9db6..6b26bf2d722 100644 --- a/components/script/dom/filelist.rs +++ b/components/script/dom/filelist.rs @@ -2,13 +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::slice::Iter; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::file::File; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::slice::Iter; // https://w3c.github.io/FileAPI/#dfn-filelist #[dom_struct] diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 5e0740c557f..37add7d61f4 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -2,6 +2,19 @@ * 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::Cell; +use std::ptr; + +use base64::Engine; +use dom_struct::dom_struct; +use encoding_rs::{Encoding, UTF_8}; +use js::jsapi::{Heap, JSObject}; +use js::jsval::{self, JSVal}; +use js::rust::HandleObject; +use js::typedarray::{ArrayBuffer, CreateWith}; +use mime::{self, Mime}; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{ @@ -25,18 +38,6 @@ use crate::realms::enter_realm; use crate::script_runtime::JSContext; use crate::task_source::file_reading::FileReadingTask; use crate::task_source::{TaskSource, TaskSourceName}; -use base64::Engine; -use dom_struct::dom_struct; -use encoding_rs::{Encoding, UTF_8}; -use js::jsapi::Heap; -use js::jsapi::JSObject; -use js::jsval::{self, JSVal}; -use js::rust::HandleObject; -use js::typedarray::{ArrayBuffer, CreateWith}; -use mime::{self, Mime}; -use servo_atoms::Atom; -use std::cell::Cell; -use std::ptr; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum FileReaderFunction { diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index a2f375ef80a..b8700173177 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -2,6 +2,14 @@ * 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::ptr; +use std::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use js::typedarray::{ArrayBuffer, CreateWith}; + use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FileReaderSyncBinding::FileReaderSyncMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -12,12 +20,6 @@ use crate::dom::blob::Blob; use crate::dom::filereader::FileReaderSharedFunctionality; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use js::typedarray::{ArrayBuffer, CreateWith}; -use std::ptr; -use std::ptr::NonNull; #[dom_struct] pub struct FileReaderSync { diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index d980ea6ed49..cb064b3fb1e 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -2,6 +2,11 @@ * 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::default::Default; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::FocusEventBinding; use crate::dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods; use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; @@ -14,9 +19,6 @@ use crate::dom::event::{EventBubbles, EventCancelable}; use crate::dom::eventtarget::EventTarget; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::default::Default; #[dom_struct] pub struct FocusEvent { diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index aa889522f5e..f0283695825 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -2,6 +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 dom_struct::dom_struct; +use html5ever::LocalName; +use js::rust::HandleObject; +use script_traits::serializable::BlobImpl; + +use super::bindings::trace::NoTrace; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; use crate::dom::bindings::codegen::UnionTypes::FileOrUSVString; @@ -15,12 +21,6 @@ use crate::dom::blob::Blob; use crate::dom::file::File; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlformelement::{FormDatum, FormDatumValue, HTMLFormElement}; -use dom_struct::dom_struct; -use html5ever::LocalName; -use js::rust::HandleObject; -use script_traits::serializable::BlobImpl; - -use super::bindings::trace::NoTrace; #[dom_struct] pub struct FormData { diff --git a/components/script/dom/formdataevent.rs b/components/script/dom/formdataevent.rs index 1b78bd1af9c..6a3317a9092 100644 --- a/components/script/dom/formdataevent.rs +++ b/components/script/dom/formdataevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::FormDataEventBinding; use crate::dom::bindings::codegen::Bindings::FormDataEventBinding::FormDataEventMethods; @@ -10,14 +14,10 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; -use crate::dom::event::Event; -use crate::dom::event::{EventBubbles, EventCancelable}; +use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::formdata::FormData; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct FormDataEvent { diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index f5d8a8f793f..5bcb5cdff6f 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -2,6 +2,14 @@ * 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::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::gain_node::GainNodeOptions; +use servo_media::audio::node::AudioNodeInit; +use servo_media::audio::param::ParamType; + use crate::dom::audionode::AudioNode; use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; @@ -14,12 +22,6 @@ use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::gain_node::GainNodeOptions; -use servo_media::audio::node::AudioNodeInit; -use servo_media::audio::param::ParamType; -use std::f32; #[dom_struct] pub struct GainNode { diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index b81d6a7b228..e24f0848222 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -2,8 +2,13 @@ * 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::GamepadBinding::GamepadHand; -use crate::dom::bindings::codegen::Bindings::GamepadBinding::GamepadMethods; +use std::cell::Cell; +use std::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; + +use crate::dom::bindings::codegen::Bindings::GamepadBinding::{GamepadHand, GamepadMethods}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{DomObject, Reflector}; @@ -15,10 +20,6 @@ use crate::dom::gamepadbuttonlist::GamepadButtonList; use crate::dom::gamepadevent::{GamepadEvent, GamepadEventType}; use crate::dom::gamepadpose::GamepadPose; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use std::cell::Cell; -use std::ptr::NonNull; #[dom_struct] pub struct Gamepad { diff --git a/components/script/dom/gamepadbutton.rs b/components/script/dom/gamepadbutton.rs index e40e7fb4f05..a739dbebcf4 100644 --- a/components/script/dom/gamepadbutton.rs +++ b/components/script/dom/gamepadbutton.rs @@ -2,13 +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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::GamepadButtonBinding::GamepadButtonMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct GamepadButton { diff --git a/components/script/dom/gamepadbuttonlist.rs b/components/script/dom/gamepadbuttonlist.rs index 4d9e86c45ef..07bf5118f51 100644 --- a/components/script/dom/gamepadbuttonlist.rs +++ b/components/script/dom/gamepadbuttonlist.rs @@ -2,11 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::gamepadbutton::GamepadButton; -use dom_struct::dom_struct; // https://w3c.github.io/gamepad/#gamepadbutton-interface #[dom_struct] diff --git a/components/script/dom/gamepadevent.rs b/components/script/dom/gamepadevent.rs index ec6da6ba302..b71e9e01871 100644 --- a/components/script/dom/gamepadevent.rs +++ b/components/script/dom/gamepadevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::GamepadEventBinding; use crate::dom::bindings::codegen::Bindings::GamepadEventBinding::GamepadEventMethods; @@ -14,9 +18,6 @@ use crate::dom::event::Event; use crate::dom::gamepad::Gamepad; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct GamepadEvent { diff --git a/components/script/dom/gamepadlist.rs b/components/script/dom/gamepadlist.rs index ed551df4c35..d293281389b 100644 --- a/components/script/dom/gamepadlist.rs +++ b/components/script/dom/gamepadlist.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::gamepad::Gamepad; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; // https://www.w3.org/TR/gamepad/ #[dom_struct] diff --git a/components/script/dom/gamepadpose.rs b/components/script/dom/gamepadpose.rs index 10d770ea68a..073a326dc0a 100644 --- a/components/script/dom/gamepadpose.rs +++ b/components/script/dom/gamepadpose.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 std::ptr; +use std::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; +use js::typedarray::{CreateWith, Float32Array}; + use crate::dom::bindings::codegen::Bindings::GamepadPoseBinding::GamepadPoseMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use js::typedarray::{CreateWith, Float32Array}; -use std::ptr; -use std::ptr::NonNull; #[dom_struct] pub struct GamepadPose { diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 2ac4aacd70f..be59afbf437 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -2,6 +2,64 @@ * 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::borrow::Cow; +use std::cell::Cell; +use std::collections::hash_map::Entry; +use std::collections::{HashMap, VecDeque}; +use std::ops::Index; +use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::thread::JoinHandle; +use std::{mem, ptr}; + +use content_security_policy::CspList; +use crossbeam_channel::Sender; +use devtools_traits::{PageError, ScriptToDevtoolsControlMsg}; +use dom_struct::dom_struct; +use embedder_traits::EmbedderMsg; +use ipc_channel::ipc::{self, IpcSender}; +use ipc_channel::router::ROUTER; +use js::glue::{IsWrapper, UnwrapObjectDynamic}; +use js::jsapi::{ + Compile1, CurrentGlobalOrNull, GetNonCCWObjectGlobal, HandleObject, Heap, + InstantiateGlobalStencil, InstantiateOptions, JSContext, JSObject, JSScript, SetScriptPrivate, +}; +use js::jsval::{JSVal, PrivateValue, UndefinedValue}; +use js::panic::maybe_resume_unwind; +use js::rust::wrappers::{JS_ExecuteScript, JS_GetScriptPrivate}; +use js::rust::{ + get_object_class, transform_str_to_source_text, CompileOptionsWrapper, HandleValue, + MutableHandleValue, ParentRuntime, Runtime, +}; +use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; +use msg::constellation_msg::{ + BlobId, BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineId, + ServiceWorkerId, ServiceWorkerRegistrationId, +}; +use net_traits::blob_url_store::{get_blob_origin, BlobBuf}; +use net_traits::filemanager_thread::{ + FileManagerResult, FileManagerThreadMsg, ReadFileProgress, RelativePos, +}; +use net_traits::image_cache::ImageCache; +use net_traits::request::Referrer; +use net_traits::response::HttpsState; +use net_traits::{CoreResourceMsg, CoreResourceThread, IpcSend, ResourceThreads}; +use parking_lot::Mutex; +use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time}; +use script_traits::serializable::{BlobData, BlobImpl, FileBlob}; +use script_traits::transferable::MessagePortImpl; +use script_traits::{ + BroadcastMsg, MessagePortMsg, MsDuration, PortMessageTask, ScriptMsg, + ScriptToConstellationChan, TimerEvent, TimerEventId, TimerSchedulerMsg, TimerSource, +}; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; +use time::{get_time, Timespec}; +use uuid::Uuid; +use webgpu::identity::WebGPUOpResult; +use webgpu::{ErrorScopeId, WebGPUDevice}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::cell::{DomRefCell, RefMut}; use crate::dom::bindings::codegen::Bindings::BroadcastChannelBinding::BroadcastChannelMethods; use crate::dom::bindings::codegen::Bindings::EventSourceBinding::EventSourceBinding::EventSourceMethods; @@ -52,8 +110,7 @@ use crate::dom::workerglobalscope::WorkerGlobalScope; use crate::dom::workletglobalscope::WorkletGlobalScope; use crate::microtask::{Microtask, MicrotaskQueue, UserMicrotask}; use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; -use crate::script_module::{DynamicModuleList, ModuleTree}; -use crate::script_module::{ModuleScript, ScriptFetchOptions}; +use crate::script_module::{DynamicModuleList, ModuleScript, ModuleTree, ScriptFetchOptions}; use crate::script_runtime::{ CommonScriptMsg, ContextForRequestInterrupt, JSContext as SafeJSContext, ScriptChan, ScriptPort, }; @@ -67,69 +124,10 @@ use crate::task_source::port_message::PortMessageQueue; use crate::task_source::remote_event::RemoteEventTaskSource; use crate::task_source::timer::TimerTaskSource; use crate::task_source::websocket::WebsocketTaskSource; -use crate::task_source::TaskSource; -use crate::task_source::TaskSourceName; -use crate::timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle}; -use crate::timers::{OneshotTimers, TimerCallback}; -use content_security_policy::CspList; -use crossbeam_channel::Sender; -use devtools_traits::{PageError, ScriptToDevtoolsControlMsg}; -use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; -use ipc_channel::ipc::{self, IpcSender}; -use ipc_channel::router::ROUTER; -use js::glue::{IsWrapper, UnwrapObjectDynamic}; -use js::jsapi::Compile1; -use js::jsapi::SetScriptPrivate; -use js::jsapi::{CurrentGlobalOrNull, GetNonCCWObjectGlobal}; -use js::jsapi::{HandleObject, Heap, InstantiateGlobalStencil, InstantiateOptions}; -use js::jsapi::{JSContext, JSObject, JSScript}; -use js::jsval::PrivateValue; -use js::jsval::{JSVal, UndefinedValue}; -use js::panic::maybe_resume_unwind; -use js::rust::transform_str_to_source_text; -use js::rust::wrappers::{JS_ExecuteScript, JS_GetScriptPrivate}; -use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime}; -use js::rust::{HandleValue, MutableHandleValue}; -use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; -use msg::constellation_msg::{ - BlobId, BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineId, - ServiceWorkerId, ServiceWorkerRegistrationId, +use crate::task_source::{TaskSource, TaskSourceName}; +use crate::timers::{ + IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers, TimerCallback, }; -use net_traits::blob_url_store::{get_blob_origin, BlobBuf}; -use net_traits::filemanager_thread::{ - FileManagerResult, FileManagerThreadMsg, ReadFileProgress, RelativePos, -}; -use net_traits::image_cache::ImageCache; -use net_traits::request::Referrer; -use net_traits::response::HttpsState; -use net_traits::{CoreResourceMsg, CoreResourceThread, IpcSend, ResourceThreads}; -use parking_lot::Mutex; -use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time}; -use script_traits::serializable::{BlobData, BlobImpl, FileBlob}; -use script_traits::transferable::MessagePortImpl; -use script_traits::{ - BroadcastMsg, MessagePortMsg, MsDuration, PortMessageTask, ScriptMsg, - ScriptToConstellationChan, TimerEvent, -}; -use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource}; -use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; -use std::borrow::Cow; -use std::cell::Cell; -use std::collections::hash_map::Entry; -use std::collections::{HashMap, VecDeque}; -use std::mem; -use std::ops::Index; -use std::ptr; -use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use std::thread::JoinHandle; -use time::{get_time, Timespec}; -use uuid::Uuid; -use webgpu::{identity::WebGPUOpResult, ErrorScopeId, WebGPUDevice}; - -use super::bindings::trace::HashMapTracedValues; #[derive(JSTraceable)] pub struct AutoCloseWorker { diff --git a/components/script/dom/gpu.rs b/components/script/dom/gpu.rs index 11f98909abe..0785ec47171 100644 --- a/components/script/dom/gpu.rs +++ b/components/script/dom/gpu.rs @@ -2,8 +2,20 @@ * 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::GPUBinding::GPURequestAdapterOptions; -use crate::dom::bindings::codegen::Bindings::GPUBinding::{GPUMethods, GPUPowerPreference}; +use std::rc::Rc; + +use dom_struct::dom_struct; +use ipc_channel::ipc::{self, IpcSender}; +use ipc_channel::router::ROUTER; +use js::jsapi::Heap; +use script_traits::ScriptMsg; +use webgpu::wgt::PowerPreference; +use webgpu::{wgpu, WebGPUResponse, WebGPUResponseResult}; + +use super::bindings::codegen::Bindings::GPUTextureBinding::GPUTextureFormat; +use crate::dom::bindings::codegen::Bindings::GPUBinding::{ + GPUMethods, GPUPowerPreference, GPURequestAdapterOptions, +}; use crate::dom::bindings::error::Error; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -14,16 +26,6 @@ use crate::dom::gpuadapter::GPUAdapter; use crate::dom::promise::Promise; use crate::realms::InRealm; use crate::task_source::{TaskSource, TaskSourceName}; -use dom_struct::dom_struct; -use ipc_channel::ipc::{self, IpcSender}; -use ipc_channel::router::ROUTER; -use js::jsapi::Heap; -use script_traits::ScriptMsg; -use std::rc::Rc; -use webgpu::wgt::PowerPreference; -use webgpu::{wgpu, WebGPUResponse, WebGPUResponseResult}; - -use super::bindings::codegen::Bindings::GPUTextureBinding::GPUTextureFormat; #[dom_struct] pub struct GPU { diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs index db5be259375..ae0eb83b397 100644 --- a/components/script/dom/gpuadapter.rs +++ b/components/script/dom/gpuadapter.rs @@ -2,6 +2,14 @@ * 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::convert::TryFrom; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; +use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse, WebGPUResponseResult}; + +use super::types::{GPUAdapterInfo, GPUSupportedLimits}; use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::{ GPUAdapterMethods, GPUDeviceDescriptor, GPUFeatureName, }; @@ -10,18 +18,10 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; -use crate::dom::gpu::response_async; -use crate::dom::gpu::AsyncWGPUListener; +use crate::dom::gpu::{response_async, AsyncWGPUListener}; use crate::dom::gpudevice::GPUDevice; use crate::dom::promise::Promise; use crate::realms::InRealm; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use std::convert::TryFrom; -use std::rc::Rc; -use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse, WebGPUResponseResult}; - -use super::types::{GPUAdapterInfo, GPUSupportedLimits}; #[dom_struct] pub struct GPUAdapter { diff --git a/components/script/dom/gpuadapterinfo.rs b/components/script/dom/gpuadapterinfo.rs index b3fe29b10fa..01f878cc66a 100644 --- a/components/script/dom/gpuadapterinfo.rs +++ b/components/script/dom/gpuadapterinfo.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::wgt::AdapterInfo; + use super::bindings::codegen::Bindings::GPUAdapterInfoBinding::GPUAdapterInfoMethods; use super::bindings::reflector::reflect_dom_object; use super::bindings::root::DomRoot; use crate::dom::bindings::reflector::Reflector; use crate::dom::globalscope::GlobalScope; use crate::test::DOMString; -use dom_struct::dom_struct; -use webgpu::wgt::AdapterInfo; #[dom_struct] pub struct GPUAdapterInfo { diff --git a/components/script/dom/gpubindgroup.rs b/components/script/dom/gpubindgroup.rs index 41f20999175..4b835c86049 100644 --- a/components/script/dom/gpubindgroup.rs +++ b/components/script/dom/gpubindgroup.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use webgpu::{WebGPUBindGroup, WebGPUDevice}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::GPUBindGroupMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,8 +12,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; use crate::dom::gpubindgrouplayout::GPUBindGroupLayout; -use dom_struct::dom_struct; -use webgpu::{WebGPUBindGroup, WebGPUDevice}; #[dom_struct] pub struct GPUBindGroup { diff --git a/components/script/dom/gpubindgrouplayout.rs b/components/script/dom/gpubindgrouplayout.rs index 89862358211..b9bc483450d 100644 --- a/components/script/dom/gpubindgrouplayout.rs +++ b/components/script/dom/gpubindgrouplayout.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::WebGPUBindGroupLayout; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::GPUBindGroupLayoutMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::WebGPUBindGroupLayout; #[dom_struct] pub struct GPUBindGroupLayout { diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs index b1789405fa3..f57faac9ab6 100644 --- a/components/script/dom/gpubuffer.rs +++ b/components/script/dom/gpubuffer.rs @@ -2,6 +2,20 @@ * 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::{Cell, RefCell}; +use std::ffi::c_void; +use std::ops::Range; +use std::ptr::NonNull; +use std::rc::Rc; +use std::string::String; + +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSharedMemory; +use js::jsapi::{DetachArrayBuffer, Heap, JSObject, NewExternalArrayBuffer}; +use webgpu::identity::WebGPUOpResult; +use webgpu::wgpu::device::HostMap; +use webgpu::{WebGPU, WebGPUBuffer, WebGPURequest, WebGPUResponse, WebGPUResponseResult}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{GPUBufferMethods, GPUSize64}; use crate::dom::bindings::codegen::Bindings::GPUMapModeBinding::GPUMapModeConstants; @@ -15,21 +29,6 @@ use crate::dom::gpudevice::GPUDevice; use crate::dom::promise::Promise; use crate::realms::InRealm; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSharedMemory; -use js::jsapi::DetachArrayBuffer; -use js::jsapi::NewExternalArrayBuffer; -use js::jsapi::{Heap, JSObject}; -use std::cell::{Cell, RefCell}; -use std::ffi::c_void; -use std::ops::Range; -use std::ptr::NonNull; -use std::rc::Rc; -use std::string::String; -use webgpu::{ - identity::WebGPUOpResult, wgpu::device::HostMap, WebGPU, WebGPUBuffer, WebGPURequest, - WebGPUResponse, WebGPUResponseResult, -}; const RANGE_OFFSET_ALIGN_MASK: u64 = 8; const RANGE_SIZE_ALIGN_MASK: u64 = 4; diff --git a/components/script/dom/gpubufferusage.rs b/components/script/dom/gpubufferusage.rs index 9b3a97d26fd..b35768d25d5 100644 --- a/components/script/dom/gpubufferusage.rs +++ b/components/script/dom/gpubufferusage.rs @@ -2,9 +2,10 @@ * 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::reflector::Reflector; use dom_struct::dom_struct; +use crate::dom::bindings::reflector::Reflector; + #[dom_struct] pub struct GPUBufferUsage { reflector_: Reflector, diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs index 121a84f6473..a91f0f5a9bd 100644 --- a/components/script/dom/gpucanvascontext.rs +++ b/components/script/dom/gpucanvascontext.rs @@ -2,29 +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 crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::{ - GPUCanvasConfiguration, GPUCanvasContextMethods, -}; -use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::GPUDeviceBinding::GPUDeviceMethods; -use crate::dom::bindings::codegen::Bindings::GPUObjectBaseBinding::GPUObjectDescriptorBase; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ - GPUExtent3D, GPUExtent3DDict, GPUTextureDescriptor, GPUTextureDimension, GPUTextureFormat, -}; -use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementBinding::HTMLCanvasElementMethods; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; -use crate::dom::bindings::root::{DomRoot, LayoutDom}; -use crate::dom::globalscope::GlobalScope; -use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutCanvasRenderingContextHelpers}; -use crate::dom::node::{document_from_node, Node, NodeDamage}; +use std::cell::Cell; + use arrayvec::ArrayVec; use dom_struct::dom_struct; use euclid::default::Size2D; use ipc_channel::ipc; use script_layout_interface::HTMLCanvasDataSource; -use std::cell::Cell; -use webgpu::WebGPUTexture; -use webgpu::{wgpu::id, wgt, WebGPU, WebGPURequest, PRESENTATION_BUFFER_COUNT}; +use webgpu::wgpu::id; +use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, PRESENTATION_BUFFER_COUNT}; use webrender_api::{ units, ExternalImageData, ExternalImageId, ExternalImageType, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey, @@ -35,6 +21,21 @@ use super::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas; use super::bindings::error::{Error, Fallible}; use super::bindings::root::MutNullableDom; use super::gputexture::GPUTexture; +use crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::{ + GPUCanvasConfiguration, GPUCanvasContextMethods, +}; +use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::GPUDeviceBinding::GPUDeviceMethods; +use crate::dom::bindings::codegen::Bindings::GPUObjectBaseBinding::GPUObjectDescriptorBase; +use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ + GPUExtent3D, GPUExtent3DDict, GPUTextureDescriptor, GPUTextureDimension, GPUTextureFormat, +}; +use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementBinding::HTMLCanvasElementMethods; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use crate::dom::bindings::root::{DomRoot, LayoutDom}; +use crate::dom::globalscope::GlobalScope; +use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutCanvasRenderingContextHelpers}; +use crate::dom::node::{document_from_node, Node, NodeDamage}; #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub struct WebGPUContextId(pub u64); diff --git a/components/script/dom/gpucolorwrite.rs b/components/script/dom/gpucolorwrite.rs index c34799d9982..29e19826342 100644 --- a/components/script/dom/gpucolorwrite.rs +++ b/components/script/dom/gpucolorwrite.rs @@ -2,9 +2,10 @@ * 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::reflector::Reflector; use dom_struct::dom_struct; +use crate::dom::bindings::reflector::Reflector; + #[dom_struct] pub struct GPUColorWrite { reflector_: Reflector, diff --git a/components/script/dom/gpucommandbuffer.rs b/components/script/dom/gpucommandbuffer.rs index babaf3cb089..32bc4fee487 100644 --- a/components/script/dom/gpucommandbuffer.rs +++ b/components/script/dom/gpucommandbuffer.rs @@ -2,18 +2,19 @@ * 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::collections::HashSet; +use std::hash::{Hash, Hasher}; + +use dom_struct::dom_struct; +use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest}; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; use crate::dom::gpubuffer::GPUBuffer; -use dom_struct::dom_struct; -use std::collections::HashSet; -use std::hash::{Hash, Hasher}; -use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest}; impl Eq for DomRoot<GPUBuffer> {} impl Hash for DomRoot<GPUBuffer> { diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs index 4e7102eec69..be8dbe73803 100644 --- a/components/script/dom/gpucommandencoder.rs +++ b/components/script/dom/gpucommandencoder.rs @@ -2,6 +2,20 @@ * 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::borrow::Cow; +use std::cell::Cell; +use std::collections::HashSet; + +use dom_struct::dom_struct; +use webgpu::wgpu::command as wgpu_com; +use webgpu::{self, wgt, WebGPU, WebGPURequest}; + +use super::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferDescriptor; +use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ + GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, GPULoadOp, +}; +use super::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureAspect; +use super::bindings::codegen::UnionTypes::DoubleSequenceOrGPUColorDict; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUSize64; use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ @@ -10,8 +24,7 @@ use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ }; use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::GPUExtent3D; use crate::dom::bindings::num::Finite; -use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; @@ -20,19 +33,6 @@ use crate::dom::gpucommandbuffer::GPUCommandBuffer; use crate::dom::gpucomputepassencoder::GPUComputePassEncoder; use crate::dom::gpudevice::{convert_texture_size_to_dict, convert_texture_size_to_wgt, GPUDevice}; use crate::dom::gpurenderpassencoder::GPURenderPassEncoder; -use dom_struct::dom_struct; -use std::borrow::Cow; -use std::cell::Cell; -use std::collections::HashSet; -use webgpu::wgpu::command as wgpu_com; -use webgpu::{self, wgt, WebGPU, WebGPURequest}; - -use super::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferDescriptor; -use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, GPULoadOp, -}; -use super::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureAspect; -use super::bindings::codegen::UnionTypes::DoubleSequenceOrGPUColorDict; // TODO(sagudev): this is different now // https://gpuweb.github.io/gpuweb/#enumdef-encoder-state diff --git a/components/script/dom/gpucompilationinfo.rs b/components/script/dom/gpucompilationinfo.rs index e7cbb705b31..9e8d69df9c2 100644 --- a/components/script/dom/gpucompilationinfo.rs +++ b/components/script/dom/gpucompilationinfo.rs @@ -2,15 +2,14 @@ * 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::reflector::Reflector; -use crate::script_runtime::JSContext; use dom_struct::dom_struct; - use js::jsval::JSVal; use super::bindings::codegen::Bindings::GPUCompilationInfoBinding::GPUCompilationInfoMethods; use super::bindings::root::Dom; use super::types::GPUCompilationMessage; +use crate::dom::bindings::reflector::Reflector; +use crate::script_runtime::JSContext; #[dom_struct] pub struct GPUCompilationInfo { diff --git a/components/script/dom/gpucompilationmessage.rs b/components/script/dom/gpucompilationmessage.rs index 83912e43ee1..5dab738439f 100644 --- a/components/script/dom/gpucompilationmessage.rs +++ b/components/script/dom/gpucompilationmessage.rs @@ -4,8 +4,6 @@ #![allow(dead_code)] // this file is stub as wgpu does not provide info -use crate::dom::bindings::reflector::Reflector; -use crate::test::DOMString; use dom_struct::dom_struct; use super::bindings::codegen::Bindings::GPUCompilationMessageBinding::{ @@ -13,7 +11,8 @@ use super::bindings::codegen::Bindings::GPUCompilationMessageBinding::{ }; use super::bindings::root::DomRoot; use super::types::GlobalScope; -use crate::dom::bindings::reflector::reflect_dom_object; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::test::DOMString; #[dom_struct] pub struct GPUCompilationMessage { diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs index e3b9383cfeb..e58193bcf40 100644 --- a/components/script/dom/gpucomputepassencoder.rs +++ b/components/script/dom/gpucomputepassencoder.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use webgpu::wgpu::command::{compute_ffi as wgpu_comp, ComputePass}; +use webgpu::{WebGPU, WebGPURequest}; + +use super::bindings::error::Fallible; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::GPUComputePassEncoderMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -12,13 +17,6 @@ use crate::dom::gpubindgroup::GPUBindGroup; use crate::dom::gpubuffer::GPUBuffer; use crate::dom::gpucommandencoder::{GPUCommandEncoder, GPUCommandEncoderState}; use crate::dom::gpucomputepipeline::GPUComputePipeline; -use dom_struct::dom_struct; -use webgpu::{ - wgpu::command::{compute_ffi as wgpu_comp, ComputePass}, - WebGPU, WebGPURequest, -}; - -use super::bindings::error::Fallible; #[dom_struct] pub struct GPUComputePassEncoder { diff --git a/components/script/dom/gpucomputepipeline.rs b/components/script/dom/gpucomputepipeline.rs index 518e826a4af..2795e6fa253 100644 --- a/components/script/dom/gpucomputepipeline.rs +++ b/components/script/dom/gpucomputepipeline.rs @@ -2,6 +2,11 @@ * 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::string::String; + +use dom_struct::dom_struct; +use webgpu::{WebGPUBindGroupLayout, WebGPUComputePipeline}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -11,9 +16,6 @@ use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; use crate::dom::gpubindgrouplayout::GPUBindGroupLayout; use crate::dom::gpudevice::GPUDevice; -use dom_struct::dom_struct; -use std::string::String; -use webgpu::{WebGPUBindGroupLayout, WebGPUComputePipeline}; #[dom_struct] pub struct GPUComputePipeline { diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs index 4668871a755..2678ad4fb3b 100644 --- a/components/script/dom/gpudevice.rs +++ b/components/script/dom/gpudevice.rs @@ -4,6 +4,32 @@ #![allow(unsafe_code)] +use std::borrow::Cow; +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; +use std::num::NonZeroU64; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; +use webgpu::identity::WebGPUOpResult; +use webgpu::wgpu::id::{BindGroupLayoutId, PipelineLayoutId}; +use webgpu::wgpu::{ + binding_model as wgpu_bind, command as wgpu_com, pipeline as wgpu_pipe, resource as wgpu_res, +}; +use webgpu::{self, wgt, ErrorScopeId, WebGPU, WebGPURequest}; + +use super::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{ + GPUBufferBindingType, GPUSamplerBindingType, GPUStorageTextureAccess, GPUTextureSampleType, +}; +use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; +use super::bindings::codegen::Bindings::GPURenderPipelineBinding::{ + GPUBlendComponent, GPUPrimitiveState, GPUVertexStepMode, +}; +use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode; +use super::bindings::error::Fallible; +use super::gpudevicelostinfo::GPUDeviceLostInfo; +use super::gpusupportedlimits::GPUSupportedLimits; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventInit; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; @@ -61,31 +87,6 @@ use crate::dom::gpuuncapturederrorevent::GPUUncapturedErrorEvent; use crate::dom::gpuvalidationerror::GPUValidationError; use crate::dom::promise::Promise; use crate::realms::InRealm; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; -use std::collections::HashMap; -use std::num::NonZeroU64; -use std::rc::Rc; -use webgpu::wgpu::{ - binding_model as wgpu_bind, command as wgpu_com, - id::{BindGroupLayoutId, PipelineLayoutId}, - pipeline as wgpu_pipe, resource as wgpu_res, -}; -use webgpu::{self, identity::WebGPUOpResult, wgt, ErrorScopeId, WebGPU, WebGPURequest}; - -use super::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{ - GPUBufferBindingType, GPUSamplerBindingType, GPUStorageTextureAccess, GPUTextureSampleType, -}; -use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::{ - GPUBlendComponent, GPUPrimitiveState, GPUVertexStepMode, -}; -use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode; -use super::bindings::error::Fallible; -use super::gpudevicelostinfo::GPUDeviceLostInfo; -use super::gpusupportedlimits::GPUSupportedLimits; #[derive(JSTraceable, MallocSizeOf)] struct ErrorScopeInfo { diff --git a/components/script/dom/gpudevicelostinfo.rs b/components/script/dom/gpudevicelostinfo.rs index 40915bd1ebd..98dcc85d62f 100644 --- a/components/script/dom/gpudevicelostinfo.rs +++ b/components/script/dom/gpudevicelostinfo.rs @@ -4,14 +4,14 @@ #![allow(dead_code)] +use dom_struct::dom_struct; + +use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; use crate::dom::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostInfoMethods; 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 dom_struct::dom_struct; - -use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; #[dom_struct] pub struct GPUDeviceLostInfo { diff --git a/components/script/dom/gpumapmode.rs b/components/script/dom/gpumapmode.rs index b216d3f839d..4db3455483d 100644 --- a/components/script/dom/gpumapmode.rs +++ b/components/script/dom/gpumapmode.rs @@ -2,9 +2,10 @@ * 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::reflector::Reflector; use dom_struct::dom_struct; +use crate::dom::bindings::reflector::Reflector; + #[dom_struct] pub struct GPUMapMode { reflector_: Reflector, diff --git a/components/script/dom/gpuoutofmemoryerror.rs b/components/script/dom/gpuoutofmemoryerror.rs index c7ba07b1e6e..539cbe59f57 100644 --- a/components/script/dom/gpuoutofmemoryerror.rs +++ b/components/script/dom/gpuoutofmemoryerror.rs @@ -2,11 +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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct GPUOutOfMemoryError { diff --git a/components/script/dom/gpupipelinelayout.rs b/components/script/dom/gpupipelinelayout.rs index 8f8fc550151..88ef939f931 100644 --- a/components/script/dom/gpupipelinelayout.rs +++ b/components/script/dom/gpupipelinelayout.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::{WebGPUBindGroupLayout, WebGPUPipelineLayout}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::{WebGPUBindGroupLayout, WebGPUPipelineLayout}; #[dom_struct] pub struct GPUPipelineLayout { diff --git a/components/script/dom/gpuqueryset.rs b/components/script/dom/gpuqueryset.rs index 097d23ac5ea..e62d0ca4dcb 100644 --- a/components/script/dom/gpuqueryset.rs +++ b/components/script/dom/gpuqueryset.rs @@ -4,11 +4,11 @@ #![allow(dead_code)] // this file is stub -use crate::dom::bindings::reflector::Reflector; use dom_struct::dom_struct; use super::bindings::codegen::Bindings::GPUQuerySetBinding::GPUQuerySetMethods; use super::bindings::str::USVString; +use crate::dom::bindings::reflector::Reflector; #[dom_struct] pub struct GPUQuerySet { diff --git a/components/script/dom/gpuqueue.rs b/components/script/dom/gpuqueue.rs index 04dee0821eb..3061211f20f 100644 --- a/components/script/dom/gpuqueue.rs +++ b/components/script/dom/gpuqueue.rs @@ -2,6 +2,14 @@ * 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 dom_struct::dom_struct; +use ipc_channel::ipc::IpcSharedMemory; +use webgpu::identity::WebGPUOpResult; +use webgpu::{wgt, WebGPU, WebGPUQueue, WebGPURequest}; + +use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ + GPUImageCopyTexture, GPUImageDataLayout, +}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUSize64; use crate::dom::bindings::codegen::Bindings::GPUQueueBinding::GPUQueueMethods; @@ -16,13 +24,6 @@ use crate::dom::gpubuffer::{GPUBuffer, GPUBufferState}; use crate::dom::gpucommandbuffer::GPUCommandBuffer; use crate::dom::gpucommandencoder::{convert_ic_texture, convert_image_data_layout}; use crate::dom::gpudevice::{convert_texture_size_to_dict, convert_texture_size_to_wgt, GPUDevice}; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSharedMemory; -use webgpu::{identity::WebGPUOpResult, wgt, WebGPU, WebGPUQueue, WebGPURequest}; - -use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - GPUImageCopyTexture, GPUImageDataLayout, -}; #[dom_struct] pub struct GPUQueue { diff --git a/components/script/dom/gpurenderbundle.rs b/components/script/dom/gpurenderbundle.rs index 2b1a742f60e..17f72d41dd8 100644 --- a/components/script/dom/gpurenderbundle.rs +++ b/components/script/dom/gpurenderbundle.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPURenderBundleBinding::GPURenderBundleMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle}; #[dom_struct] pub struct GPURenderBundle { diff --git a/components/script/dom/gpurenderbundleencoder.rs b/components/script/dom/gpurenderbundleencoder.rs index 0303a9c76c7..ab6f8aae3a4 100644 --- a/components/script/dom/gpurenderbundleencoder.rs +++ b/components/script/dom/gpurenderbundleencoder.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use webgpu::wgpu::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder}; +use webgpu::{wgt, WebGPU, WebGPURenderBundle, WebGPURequest}; + +use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPURenderBundleBinding::GPURenderBundleDescriptor; use crate::dom::bindings::codegen::Bindings::GPURenderBundleEncoderBinding::GPURenderBundleEncoderMethods; @@ -14,13 +19,6 @@ use crate::dom::gpubuffer::GPUBuffer; use crate::dom::gpudevice::{convert_label, GPUDevice}; use crate::dom::gpurenderbundle::GPURenderBundle; use crate::dom::gpurenderpipeline::GPURenderPipeline; -use dom_struct::dom_struct; -use webgpu::{ - wgpu::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder}, - wgt, WebGPU, WebGPURenderBundle, WebGPURequest, -}; - -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; #[dom_struct] pub struct GPURenderBundleEncoder { diff --git a/components/script/dom/gpurenderpassencoder.rs b/components/script/dom/gpurenderpassencoder.rs index 2a1f3d371ea..7827e090c10 100644 --- a/components/script/dom/gpurenderpassencoder.rs +++ b/components/script/dom/gpurenderpassencoder.rs @@ -2,6 +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 dom_struct::dom_struct; +use webgpu::wgpu::command::{render_ffi as wgpu_render, RenderPass}; +use webgpu::{wgt, WebGPU, WebGPURequest}; + +use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; +use super::bindings::error::Fallible; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::GPUColor; use crate::dom::bindings::codegen::Bindings::GPURenderPassEncoderBinding::GPURenderPassEncoderMethods; @@ -15,14 +21,6 @@ use crate::dom::gpubuffer::GPUBuffer; use crate::dom::gpucommandencoder::{GPUCommandEncoder, GPUCommandEncoderState}; use crate::dom::gpurenderbundle::GPURenderBundle; use crate::dom::gpurenderpipeline::GPURenderPipeline; -use dom_struct::dom_struct; -use webgpu::{ - wgpu::command::{render_ffi as wgpu_render, RenderPass}, - wgt, WebGPU, WebGPURequest, -}; - -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; -use super::bindings::error::Fallible; #[dom_struct] pub struct GPURenderPassEncoder { diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs index c52ab141206..7cd11632707 100644 --- a/components/script/dom/gpurenderpipeline.rs +++ b/components/script/dom/gpurenderpipeline.rs @@ -2,6 +2,11 @@ * 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::string::String; + +use dom_struct::dom_struct; +use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPURenderPipelineBinding::GPURenderPipelineMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -11,9 +16,6 @@ use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; use crate::dom::gpubindgrouplayout::GPUBindGroupLayout; use crate::dom::gpudevice::GPUDevice; -use dom_struct::dom_struct; -use std::string::String; -use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline}; #[dom_struct] pub struct GPURenderPipeline { diff --git a/components/script/dom/gpusampler.rs b/components/script/dom/gpusampler.rs index 9574be119bf..670d3fec896 100644 --- a/components/script/dom/gpusampler.rs +++ b/components/script/dom/gpusampler.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::{WebGPUDevice, WebGPUSampler}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUSamplerBinding::GPUSamplerMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::{WebGPUDevice, WebGPUSampler}; #[dom_struct] pub struct GPUSampler { diff --git a/components/script/dom/gpushadermodule.rs b/components/script/dom/gpushadermodule.rs index 05621688d16..28a0a885506 100644 --- a/components/script/dom/gpushadermodule.rs +++ b/components/script/dom/gpushadermodule.rs @@ -4,17 +4,17 @@ use std::rc::Rc; +use dom_struct::dom_struct; +use webgpu::WebGPUShaderModule; + +use super::bindings::error::Fallible; +use super::promise::Promise; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::WebGPUShaderModule; - -use super::bindings::error::Fallible; -use super::promise::Promise; #[dom_struct] pub struct GPUShaderModule { diff --git a/components/script/dom/gpushaderstage.rs b/components/script/dom/gpushaderstage.rs index a9cd1d90589..611ffb12283 100644 --- a/components/script/dom/gpushaderstage.rs +++ b/components/script/dom/gpushaderstage.rs @@ -2,9 +2,10 @@ * 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::reflector::Reflector; use dom_struct::dom_struct; +use crate::dom::bindings::reflector::Reflector; + #[dom_struct] pub struct GPUShaderStage { reflector_: Reflector, diff --git a/components/script/dom/gpusupportedlimits.rs b/components/script/dom/gpusupportedlimits.rs index 72d36cb3c2d..163139c856b 100644 --- a/components/script/dom/gpusupportedlimits.rs +++ b/components/script/dom/gpusupportedlimits.rs @@ -2,14 +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 dom_struct::dom_struct; +use webgpu::wgt::Limits; +use GPUSupportedLimitsBinding::GPUSupportedLimitsMethods; + use super::bindings::codegen::Bindings::GPUSupportedLimitsBinding::GPUSupportedLimitsBinding; use super::bindings::reflector::reflect_dom_object; use super::bindings::root::DomRoot; use crate::dom::bindings::reflector::Reflector; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use webgpu::wgt::Limits; -use GPUSupportedLimitsBinding::GPUSupportedLimitsMethods; #[dom_struct] pub struct GPUSupportedLimits { diff --git a/components/script/dom/gputexture.rs b/components/script/dom/gputexture.rs index 23f944dd2b1..5b420276d47 100644 --- a/components/script/dom/gputexture.rs +++ b/components/script/dom/gputexture.rs @@ -2,6 +2,14 @@ * 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::Cell; +use std::string::String; + +use dom_struct::dom_struct; +use webgpu::identity::WebGPUOpResult; +use webgpu::wgpu::resource; +use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ GPUExtent3DDict, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods, @@ -17,13 +25,6 @@ use crate::dom::gpudevice::{ convert_label, convert_texture_format, convert_texture_view_dimension, GPUDevice, }; use crate::dom::gputextureview::GPUTextureView; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::string::String; -use webgpu::{ - identity::WebGPUOpResult, wgpu::resource, wgt, WebGPU, WebGPURequest, WebGPUTexture, - WebGPUTextureView, -}; #[dom_struct] pub struct GPUTexture { diff --git a/components/script/dom/gputextureusage.rs b/components/script/dom/gputextureusage.rs index ae426bed3ba..f2d9645364b 100644 --- a/components/script/dom/gputextureusage.rs +++ b/components/script/dom/gputextureusage.rs @@ -2,9 +2,10 @@ * 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::reflector::Reflector; use dom_struct::dom_struct; +use crate::dom::bindings::reflector::Reflector; + #[dom_struct] pub struct GPUTextureUsage { reflector_: Reflector, diff --git a/components/script/dom/gputextureview.rs b/components/script/dom/gputextureview.rs index a4b3b4e8f99..b18130f01d9 100644 --- a/components/script/dom/gputextureview.rs +++ b/components/script/dom/gputextureview.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use webgpu::WebGPUTextureView; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,8 +12,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; use crate::dom::globalscope::GlobalScope; use crate::dom::gputexture::GPUTexture; -use dom_struct::dom_struct; -use webgpu::WebGPUTextureView; #[dom_struct] pub struct GPUTextureView { diff --git a/components/script/dom/gpuuncapturederrorevent.rs b/components/script/dom/gpuuncapturederrorevent.rs index e5c590fdd68..6989241d279 100644 --- a/components/script/dom/gpuuncapturederrorevent.rs +++ b/components/script/dom/gpuuncapturederrorevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::GPUUncapturedErrorEventBinding::{ GPUUncapturedErrorEventInit, GPUUncapturedErrorEventMethods, @@ -12,9 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct GPUUncapturedErrorEvent { diff --git a/components/script/dom/gpuvalidationerror.rs b/components/script/dom/gpuvalidationerror.rs index 4e139c85edb..0153399f449 100644 --- a/components/script/dom/gpuvalidationerror.rs +++ b/components/script/dom/gpuvalidationerror.rs @@ -2,15 +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 dom_struct::dom_struct; +use js::rust::HandleObject; + +use super::bindings::error::Fallible; use crate::dom::bindings::codegen::Bindings::GPUValidationErrorBinding::GPUValidationErrorMethods; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; - -use super::bindings::error::Fallible; #[dom_struct] pub struct GPUValidationError { diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index e93f8a94476..ca3b05a58d1 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::HashChangeEventBinding; use crate::dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods; @@ -12,9 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::event::Event; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#hashchangeevent #[dom_struct] diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 32d0ed36d40..11363e07638 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -2,6 +2,16 @@ * 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::Cell; +use std::str::{self, FromStr}; + +use data_url::mime::Mime as DataUrlMime; +use dom_struct::dom_struct; +use http::header::{HeaderMap as HyperHeaders, HeaderName, HeaderValue}; +use js::rust::HandleObject; +use net_traits::fetch::headers::get_value_from_header_list; +use net_traits::request::is_cors_safelisted_request_header; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -10,15 +20,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::{is_token, ByteString}; use crate::dom::globalscope::GlobalScope; -use data_url::mime::Mime as DataUrlMime; -use dom_struct::dom_struct; -use http::header::{HeaderMap as HyperHeaders, HeaderName, HeaderValue}; -use js::rust::HandleObject; -use net_traits::{ - fetch::headers::get_value_from_header_list, request::is_cors_safelisted_request_header, -}; -use std::cell::Cell; -use std::str::{self, FromStr}; #[dom_struct] pub struct Headers { diff --git a/components/script/dom/history.rs b/components/script/dom/history.rs index f527d38a915..dcb00c9430e 100644 --- a/components/script/dom/history.rs +++ b/components/script/dom/history.rs @@ -2,6 +2,19 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::{JSVal, NullValue, UndefinedValue}; +use js::rust::HandleValue; +use msg::constellation_msg::{HistoryStateId, TraversalDirection}; +use net_traits::{CoreResourceMsg, IpcSend}; +use profile_traits::ipc; +use profile_traits::ipc::channel; +use script_traits::{ScriptMsg, StructuredSerializedData}; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods; use crate::dom::bindings::codegen::Bindings::LocationBinding::LocationBinding::LocationMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -18,17 +31,6 @@ use crate::dom::hashchangeevent::HashChangeEvent; use crate::dom::popstateevent::PopStateEvent; use crate::dom::window::Window; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::{JSVal, NullValue, UndefinedValue}; -use js::rust::HandleValue; -use msg::constellation_msg::{HistoryStateId, TraversalDirection}; -use net_traits::{CoreResourceMsg, IpcSend}; -use profile_traits::ipc; -use profile_traits::ipc::channel; -use script_traits::{ScriptMsg, StructuredSerializedData}; -use servo_url::ServoUrl; -use std::cell::Cell; enum PushOrReplace { Push, diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index c16b55b88fb..ecae87f2d07 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -2,6 +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 std::default::Default; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use net_traits::request::Referrer; +use num_traits::ToPrimitive; +use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; +use servo_atoms::Atom; +use servo_url::ServoUrl; +use style::attr::AttrValue; + use crate::dom::activation::Activatable; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; @@ -27,16 +39,6 @@ use crate::dom::node::{document_from_node, Node}; use crate::dom::urlhelper::UrlHelper; use crate::dom::virtualmethods::VirtualMethods; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use net_traits::request::Referrer; -use num_traits::ToPrimitive; -use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; -use servo_atoms::Atom; -use servo_url::ServoUrl; -use std::default::Default; -use style::attr::AttrValue; #[dom_struct] pub struct HTMLAnchorElement { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 5a3a3e645b4..3f6306812b4 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -2,6 +2,17 @@ * 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::default::Default; +use std::{f32, str}; + +use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; +use dom_struct::dom_struct; +use euclid::default::Point2D; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; +use servo_atoms::Atom; +use style::attr::AttrValue; + use crate::dom::activation::Activatable; use crate::dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -16,16 +27,6 @@ use crate::dom::htmlanchorelement::follow_hyperlink; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; -use dom_struct::dom_struct; -use euclid::default::Point2D; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use servo_atoms::Atom; -use std::default::Default; -use std::f32; -use std::str; -use style::attr::AttrValue; #[derive(Debug, PartialEq)] pub enum Area { diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index 7040dd80b59..e636df1da39 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::Fallible; @@ -13,9 +17,6 @@ use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator}; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::node::Node; use crate::dom::window::Window; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLAudioElement { diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 72e8ab85a08..30e6ca7851a 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use servo_url::ServoUrl; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLBaseElementBinding::HTMLBaseElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -12,10 +17,6 @@ use crate::dom::element::{AttributeMutation, Element}; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{document_from_node, BindContext, Node, UnbindContext}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use servo_url::ServoUrl; #[dom_struct] pub struct HTMLBaseElement { diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 28587611603..c70b716bbf4 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -2,6 +2,14 @@ * 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 cssparser::RGBA; +use dom_struct::dom_struct; +use embedder_traits::EmbedderMsg; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use servo_url::ServoUrl; +use style::attr::AttrValue; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -14,13 +22,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{document_from_node, window_from_node, BindContext, Node}; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use servo_url::ServoUrl; -use style::attr::AttrValue; /// How long we should wait before performing the initial reflow after `<body>` is parsed, in /// nanoseconds. diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs index 9e0d64dbc51..129aef7d4c3 100644 --- a/components/script/dom/htmlbrelement.rs +++ b/components/script/dom/htmlbrelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLBRElement { diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 59abe891603..d324c10a953 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -2,6 +2,14 @@ * 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::Cell; +use std::default::Default; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, LocalName, Prefix}; +use js::rust::HandleObject; +use style::element_state::ElementState; + use crate::dom::activation::Activatable; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; @@ -14,20 +22,15 @@ use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlfieldsetelement::HTMLFieldSetElement; -use crate::dom::htmlformelement::HTMLFormElement; -use crate::dom::htmlformelement::{FormControl, FormDatum, FormDatumValue}; -use crate::dom::htmlformelement::{FormSubmitter, ResetFrom, SubmittedFrom}; +use crate::dom::htmlformelement::{ + FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement, ResetFrom, + SubmittedFrom, +}; use crate::dom::node::{window_from_node, BindContext, Node, UnbindContext}; use crate::dom::nodelist::NodeList; use crate::dom::validation::{is_barred_by_datalist_ancestor, Validatable}; use crate::dom::validitystate::{ValidationFlags, ValidityState}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, LocalName, Prefix}; -use js::rust::HandleObject; -use std::cell::Cell; -use std::default::Default; -use style::element_state::ElementState; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] enum ButtonType { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 03c4061938e..4f82a54e5bd 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -2,6 +2,23 @@ * 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::{CanvasId, CanvasMsg, FromScriptMsg}; +use canvas_traits::webgl::{GLContextAttributes, WebGLVersion}; +use dom_struct::dom_struct; +use euclid::default::{Rect, Size2D}; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use image::codecs::png::PngEncoder; +use image::{ColorType, ImageEncoder}; +use ipc_channel::ipc::{self as ipcchan, IpcSharedMemory}; +use js::error::throw_type_error; +use js::rust::{HandleObject, HandleValue}; +use profile_traits::ipc; +use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource}; +use script_traits::ScriptMsg; +use servo_media::streams::registry::MediaStreamId; +use servo_media::streams::MediaStreamType; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; + use crate::dom::attr::Attr; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{ @@ -31,22 +48,6 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::dom::webgl2renderingcontext::WebGL2RenderingContext; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::JSContext; -use canvas_traits::canvas::{CanvasId, CanvasMsg, FromScriptMsg}; -use canvas_traits::webgl::{GLContextAttributes, WebGLVersion}; -use dom_struct::dom_struct; -use euclid::default::{Rect, Size2D}; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use image::codecs::png::PngEncoder; -use image::{ColorType, ImageEncoder}; -use ipc_channel::ipc::{self as ipcchan, IpcSharedMemory}; -use js::error::throw_type_error; -use js::rust::{HandleObject, HandleValue}; -use profile_traits::ipc; -use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource}; -use script_traits::ScriptMsg; -use servo_media::streams::registry::MediaStreamId; -use servo_media::streams::MediaStreamType; -use style::attr::{AttrValue, LengthOrPercentageOrAuto}; const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; @@ -486,11 +487,12 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes { } pub mod utils { - use crate::dom::window::Window; use net_traits::image_cache::ImageResponse; use net_traits::request::CorsSettings; use servo_url::ServoUrl; + use crate::dom::window::Window; + pub fn request_image_from_cache( window: &Window, url: ServoUrl, diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 8bf1135ed73..560ea052392 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -2,6 +2,13 @@ * 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::Cell; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, QualName}; +use servo_atoms::Atom; +use style::str::split_html_space_chars; + use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -12,11 +19,6 @@ use crate::dom::bindings::xmlname::namespace_from_domstring; use crate::dom::element::Element; use crate::dom::node::{document_from_node, Node}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, QualName}; -use servo_atoms::Atom; -use std::cell::Cell; -use style::str::split_html_space_chars; pub trait CollectionFilter: JSTraceable { fn filter<'a>(&self, elem: &'a Element, root: &'a Node) -> bool; diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs index 70fdb2f95fd..725bdd4abcc 100644 --- a/components/script/dom/htmldataelement.rs +++ b/components/script/dom/htmldataelement.rs @@ -2,15 +2,16 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding::HTMLDataElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDataElement { diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index 9323a627c15..311d1909f17 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLDataListElementBinding::HTMLDataListElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -11,9 +15,6 @@ use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection}; use crate::dom::htmlelement::HTMLElement; use crate::dom::htmloptionelement::HTMLOptionElement; use crate::dom::node::{window_from_node, Node}; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDataListElement { diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index bec0e4dbbf6..7d10b1c91f3 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -2,6 +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 std::cell::Cell; + +use dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -14,10 +20,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{window_from_node, Node, NodeDamage}; use crate::dom::virtualmethods::VirtualMethods; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use std::cell::Cell; #[dom_struct] pub struct HTMLDetailsElement { diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index 88d4cc545f5..18d9eac65a0 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLDialogElementBinding::HTMLDialogElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -12,9 +16,6 @@ use crate::dom::element::Element; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{window_from_node, Node}; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDialogElement { diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs index 697607e8336..552d5572728 100644 --- a/components/script/dom/htmldirectoryelement.rs +++ b/components/script/dom/htmldirectoryelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDirectoryElement { diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs index 284e1af3690..d16ac4c6057 100644 --- a/components/script/dom/htmldivelement.rs +++ b/components/script/dom/htmldivelement.rs @@ -2,15 +2,16 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLDivElementBinding::HTMLDivElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDivElement { diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs index 1477c95668c..970db5a221b 100644 --- a/components/script/dom/htmldlistelement.rs +++ b/components/script/dom/htmldlistelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLDListElement { diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index abfcb4f6151..03560848965 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -2,17 +2,28 @@ * 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::collections::HashSet; +use std::default::Default; +use std::rc::Rc; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use script_layout_interface::message::QueryMsg; +use style::attr::AttrValue; +use style::element_state::*; + use crate::dom::activation::Activatable; use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; -use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull; +use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::{ + EventHandlerNonNull, OnErrorEventHandlerNonNull, +}; use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult}; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId}; +use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; @@ -30,19 +41,9 @@ use crate::dom::htmlhtmlelement::HTMLHtmlElement; use crate::dom::htmlinputelement::{HTMLInputElement, InputType}; use crate::dom::htmllabelelement::HTMLLabelElement; use crate::dom::htmltextareaelement::HTMLTextAreaElement; -use crate::dom::node::{document_from_node, window_from_node}; -use crate::dom::node::{Node, ShadowIncluding}; +use crate::dom::node::{document_from_node, window_from_node, Node, ShadowIncluding}; use crate::dom::text::Text; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use script_layout_interface::message::QueryMsg; -use std::collections::HashSet; -use std::default::Default; -use std::rc::Rc; -use style::attr::AttrValue; -use style::element_state::*; #[dom_struct] pub struct HTMLElement { diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs index ac7097e0331..ddfbc8675cd 100644 --- a/components/script/dom/htmlembedelement.rs +++ b/components/script/dom/htmlembedelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLEmbedElement { diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 881bf0d64b4..a0e95ed9ca0 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -2,6 +2,13 @@ * 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::default::Default; + +use dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; +use style::element_state::ElementState; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods; use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; @@ -17,11 +24,6 @@ use crate::dom::node::{window_from_node, Node, ShadowIncluding}; use crate::dom::validation::Validatable; use crate::dom::validitystate::ValidityState; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use std::default::Default; -use style::element_state::ElementState; #[dom_struct] pub struct HTMLFieldSetElement { diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 453a1d5c96f..9d228516d38 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -2,6 +2,14 @@ * 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 cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use servo_atoms::Atom; +use style::attr::AttrValue; +use style::str::{read_numbers, HTML_SPACE_CHARACTERS}; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -12,13 +20,6 @@ use crate::dom::element::{Element, LayoutElementHelpers}; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use servo_atoms::Atom; -use style::attr::AttrValue; -use style::str::{read_numbers, HTML_SPACE_CHARACTERS}; #[dom_struct] pub struct HTMLFontElement { diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs index f687870b058..098ddf55465 100644 --- a/components/script/dom/htmlformcontrolscollection.rs +++ b/components/script/dom/htmlformcontrolscollection.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; @@ -16,8 +19,6 @@ use crate::dom::htmlformelement::HTMLFormElement; use crate::dom::node::Node; use crate::dom::radionodelist::RadioNodeList; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_atoms::Atom; #[dom_struct] pub struct HTMLFormControlsCollection { diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 5ec6e76ae80..6003ae66b06 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -2,6 +2,27 @@ * 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::borrow::ToOwned; +use std::cell::Cell; + +use dom_struct::dom_struct; +use encoding_rs::{Encoding, UTF_8}; +use headers::{ContentType, HeaderMapExt}; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use http::Method; +use js::rust::HandleObject; +use mime::{self, Mime}; +use net_traits::http_percent_encode; +use net_traits::request::Referrer; +use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; +use servo_atoms::Atom; +use servo_rand::random; +use style::attr::AttrValue; +use style::element_state::ElementState; +use style::str::split_html_space_chars; +use time::{now, Duration, Tm}; + +use super::bindings::trace::{HashMapTracedValues, NoTrace}; use crate::body::Extractable; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrBinding::AttrMethods; @@ -14,8 +35,10 @@ use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding:: use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; +use crate::dom::bindings::codegen::Bindings::NodeBinding::{NodeConstants, NodeMethods}; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; +use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use crate::dom::bindings::refcounted::Trusted; @@ -47,9 +70,10 @@ use crate::dom::htmlobjectelement::HTMLObjectElement; use crate::dom::htmloutputelement::HTMLOutputElement; use crate::dom::htmlselectelement::HTMLSelectElement; use crate::dom::htmltextareaelement::HTMLTextAreaElement; -use crate::dom::node::{document_from_node, window_from_node}; -use crate::dom::node::{Node, NodeFlags}; -use crate::dom::node::{UnbindContext, VecPreOrderInsertionHelper}; +use crate::dom::node::{ + document_from_node, window_from_node, Node, NodeFlags, UnbindContext, + VecPreOrderInsertionHelper, +}; use crate::dom::nodelist::{NodeList, RadioListMode}; use crate::dom::radionodelist::RadioNodeList; use crate::dom::submitevent::SubmitEvent; @@ -57,30 +81,6 @@ use crate::dom::validitystate::ValidationFlags; use crate::dom::virtualmethods::VirtualMethods; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use encoding_rs::{Encoding, UTF_8}; -use headers::{ContentType, HeaderMapExt}; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use http::Method; -use js::rust::HandleObject; -use mime::{self, Mime}; -use net_traits::http_percent_encode; -use net_traits::request::Referrer; -use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; -use servo_atoms::Atom; -use servo_rand::random; -use std::borrow::ToOwned; -use std::cell::Cell; -use style::attr::AttrValue; -use style::element_state::ElementState; -use style::str::split_html_space_chars; - -use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement; -use time::{now, Duration, Tm}; - -use crate::dom::bindings::codegen::Bindings::NodeBinding::{NodeConstants, NodeMethods}; - -use super::bindings::trace::{HashMapTracedValues, NoTrace}; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct GenerationId(u32); diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs index 4128a50841c..8dae2d38ce5 100644 --- a/components/script/dom/htmlframeelement.rs +++ b/components/script/dom/htmlframeelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLFrameElement { diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs index 0b7f209c677..db1ab1c314c 100644 --- a/components/script/dom/htmlframesetelement.rs +++ b/components/script/dom/htmlframesetelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding::HTMLFrameSetElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::inheritance::Castable; @@ -9,9 +13,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{document_from_node, Node}; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLFrameSetElement { diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index cbb22801fef..92e21e1efa5 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -12,9 +16,6 @@ use crate::dom::htmlmetaelement::HTMLMetaElement; use crate::dom::node::{document_from_node, BindContext, Node, ShadowIncluding}; use crate::dom::userscripts::load_script; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLHeadElement { diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index f990883498e..b701b5d7d7f 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[derive(JSTraceable, MallocSizeOf)] pub enum HeadingLevel { diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 13ab5786be9..6bc4c4a73d7 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -2,6 +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 cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; + use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; @@ -11,11 +17,6 @@ use crate::dom::element::{Element, LayoutElementHelpers}; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::{AttrValue, LengthOrPercentageOrAuto}; #[dom_struct] pub struct HTMLHRElement { diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs index 171a071ee8d..c6c4566a605 100644 --- a/components/script/dom/htmlhtmlelement.rs +++ b/components/script/dom/htmlhtmlelement.rs @@ -2,14 +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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLHtmlElement { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index a16aaa9abfa..4c57c8523b0 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -2,6 +2,25 @@ * 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::Cell; + +use bitflags::bitflags; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use ipc_channel::ipc; +use js::rust::HandleObject; +use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; +use profile_traits::ipc as ProfiledIpc; +use script_layout_interface::message::ReflowGoal; +use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; +use script_traits::{ + HistoryEntryReplacement, IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData, + LoadOrigin, NewLayoutInfo, ScriptMsg, UpdatePipelineIdReason, WindowSizeData, +}; +use servo_atoms::Atom; +use servo_url::ServoUrl; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; + use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; @@ -25,24 +44,6 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::dom::window::ReflowReason; use crate::dom::windowproxy::WindowProxy; use crate::script_thread::ScriptThread; -use bitflags::bitflags; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use ipc_channel::ipc; -use js::rust::HandleObject; -use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; -use profile_traits::ipc as ProfiledIpc; -use script_layout_interface::message::ReflowGoal; -use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; -use script_traits::{ - HistoryEntryReplacement, IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData, - LoadOrigin, UpdatePipelineIdReason, WindowSizeData, -}; -use script_traits::{NewLayoutInfo, ScriptMsg}; -use servo_atoms::Atom; -use servo_url::ServoUrl; -use std::cell::Cell; -use style::attr::{AttrValue, LengthOrPercentageOrAuto}; #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] struct SandboxAllowance(u8); diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index d02a850ccb8..65846d59ab4 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -2,6 +2,50 @@ * 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::Cell; +use std::collections::HashSet; +use std::default::Default; +use std::sync::{Arc, Mutex}; +use std::{char, i32, mem}; + +use app_units::{Au, AU_PER_PX}; +use cssparser::{Parser, ParserInput}; +use dom_struct::dom_struct; +use euclid::Point2D; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; +use ipc_channel::ipc; +use ipc_channel::ipc::IpcSender; +use ipc_channel::router::ROUTER; +use js::jsapi::JSAutoRealm; +use js::rust::HandleObject; +use mime::{self, Mime}; +use msg::constellation_msg::PipelineId; +use net_traits::image::base::{Image, ImageMetadata}; +use net_traits::image_cache::{ + CorsStatus, ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, + PendingImageId, PendingImageResponse, UsePlaceholder, +}; +use net_traits::request::{CorsSettings, Destination, Initiator, Referrer, RequestBuilder}; +use net_traits::{ + FetchMetadata, FetchResponseListener, FetchResponseMsg, NetworkError, ReferrerPolicy, + ResourceFetchTiming, ResourceTimingType, +}; +use num_traits::ToPrimitive; +use servo_url::origin::{ImmutableOrigin, MutableOrigin}; +use servo_url::ServoUrl; +use style::attr::{ + parse_double, parse_length, parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto, +}; +use style::context::QuirksMode; +use style::media_queries::MediaList; +use style::parser::ParserContext; +use style::str::is_ascii_digit; +use style::stylesheets::{CssRuleType, Origin}; +use style::values::specified::length::{Length, NoCalcLength}; +use style::values::specified::source_size_list::SourceSizeList; +use style::values::specified::AbsoluteLength; +use style_traits::ParsingMode; + use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::activation::Activatable; use crate::dom::attr::Attr; @@ -19,10 +63,10 @@ use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::document::{determine_policy_for_token, Document}; -use crate::dom::element::{cors_setting_for_element, referrer_policy_for_element}; -use crate::dom::element::{reflect_cross_origin_attribute, set_cross_origin_attribute}; use crate::dom::element::{ - AttributeMutation, CustomElementCreationMode, Element, ElementCreator, LayoutElementHelpers, + cors_setting_for_element, referrer_policy_for_element, reflect_cross_origin_attribute, + set_cross_origin_attribute, AttributeMutation, CustomElementCreationMode, Element, + ElementCreator, LayoutElementHelpers, }; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; @@ -34,9 +78,9 @@ use crate::dom::htmlmapelement::HTMLMapElement; use crate::dom::htmlpictureelement::HTMLPictureElement; use crate::dom::htmlsourceelement::HTMLSourceElement; use crate::dom::mouseevent::MouseEvent; -use crate::dom::node::UnbindContext; use crate::dom::node::{ document_from_node, window_from_node, BindContext, Node, NodeDamage, ShadowIncluding, + UnbindContext, }; use crate::dom::performanceresourcetiming::InitiatorType; use crate::dom::values::UNSIGNED_LONG_MAX; @@ -49,48 +93,6 @@ use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingLi use crate::realms::enter_realm; 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; -use euclid::Point2D; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; -use ipc_channel::ipc; -use ipc_channel::ipc::IpcSender; -use ipc_channel::router::ROUTER; -use js::jsapi::JSAutoRealm; -use js::rust::HandleObject; -use mime::{self, Mime}; -use msg::constellation_msg::PipelineId; -use net_traits::image::base::{Image, ImageMetadata}; -use net_traits::image_cache::{ - CorsStatus, ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, - PendingImageId, PendingImageResponse, UsePlaceholder, -}; -use net_traits::request::{CorsSettings, Destination, Initiator, Referrer, RequestBuilder}; -use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg, NetworkError}; -use net_traits::{ReferrerPolicy, ResourceFetchTiming, ResourceTimingType}; -use num_traits::ToPrimitive; -use servo_url::origin::ImmutableOrigin; -use servo_url::origin::MutableOrigin; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::char; -use std::collections::HashSet; -use std::default::Default; -use std::i32; -use std::mem; -use std::sync::{Arc, Mutex}; -use style::attr::{ - parse_double, parse_length, parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto, -}; -use style::context::QuirksMode; -use style::media_queries::MediaList; -use style::parser::ParserContext; -use style::str::is_ascii_digit; -use style::stylesheets::{CssRuleType, Origin}; -use style::values::specified::length::{Length, NoCalcLength}; -use style::values::specified::{source_size_list::SourceSizeList, AbsoluteLength}; -use style_traits::ParsingMode; enum ParseState { InDescriptor, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 2e6911203ea..931882082ad 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -2,6 +2,39 @@ * 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::borrow::Cow; +use std::cell::Cell; +use std::ops::Range; +use std::ptr::NonNull; +use std::{f64, ptr}; + +use chrono::naive::{NaiveDate, NaiveDateTime}; +use chrono::{Datelike, Weekday}; +use dom_struct::dom_struct; +use embedder_traits::FilterPattern; +use encoding_rs::Encoding; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::jsapi::{ + ClippedTime, DateGetMsecSinceEpoch, Handle, JSObject, JS_ClearPendingException, NewDateObject, + NewUCRegExpObject, ObjectIsDate, RegExpFlag_Unicode, RegExpFlags, +}; +use js::jsval::UndefinedValue; +use js::rust::jsapi_wrapped::{ExecuteRegExpNoStatics, ObjectIsRegExp}; +use js::rust::{HandleObject, MutableHandleObject}; +use msg::constellation_msg::InputMethodType; +use net_traits::blob_url_store::get_blob_origin; +use net_traits::filemanager_thread::FileManagerThreadMsg; +use net_traits::{CoreResourceMsg, IpcSend}; +use profile_traits::ipc; +use script_layout_interface::rpc::TextIndexResponse; +use script_traits::ScriptToConstellationChan; +use servo_atoms::Atom; +use style::attr::AttrValue; +use style::element_state::ElementState; +use style::str::{split_commas, str_join}; +use unicode_bidi::{bidi_class, BidiClass}; +use url::Url; + use crate::dom::activation::Activatable; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; @@ -28,14 +61,14 @@ use crate::dom::htmldatalistelement::HTMLDataListElement; use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlfieldsetelement::HTMLFieldSetElement; use crate::dom::htmlformelement::{ - FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement, + FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement, ResetFrom, + SubmittedFrom, }; -use crate::dom::htmlformelement::{ResetFrom, SubmittedFrom}; use crate::dom::keyboardevent::KeyboardEvent; use crate::dom::mouseevent::MouseEvent; -use crate::dom::node::{document_from_node, window_from_node}; use crate::dom::node::{ - BindContext, CloneChildrenFlag, Node, NodeDamage, ShadowIncluding, UnbindContext, + document_from_node, window_from_node, BindContext, CloneChildrenFlag, Node, NodeDamage, + ShadowIncluding, UnbindContext, }; use crate::dom::nodelist::NodeList; use crate::dom::textcontrol::{TextControlElement, TextControlSelection}; @@ -49,38 +82,6 @@ use crate::textinput::KeyReaction::{ }; use crate::textinput::Lines::Single; use crate::textinput::{Direction, SelectionDirection, TextInput, UTF16CodeUnits, UTF8Bytes}; -use chrono::naive::{NaiveDate, NaiveDateTime}; -use chrono::{Datelike, Weekday}; -use dom_struct::dom_struct; -use embedder_traits::FilterPattern; -use encoding_rs::Encoding; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::jsapi::{ - ClippedTime, DateGetMsecSinceEpoch, Handle, JSObject, JS_ClearPendingException, NewDateObject, - NewUCRegExpObject, ObjectIsDate, RegExpFlag_Unicode, RegExpFlags, -}; -use js::jsval::UndefinedValue; -use js::rust::jsapi_wrapped::{ExecuteRegExpNoStatics, ObjectIsRegExp}; -use js::rust::{HandleObject, MutableHandleObject}; -use msg::constellation_msg::InputMethodType; -use net_traits::blob_url_store::get_blob_origin; -use net_traits::filemanager_thread::FileManagerThreadMsg; -use net_traits::{CoreResourceMsg, IpcSend}; -use profile_traits::ipc; -use script_layout_interface::rpc::TextIndexResponse; -use script_traits::ScriptToConstellationChan; -use servo_atoms::Atom; -use std::borrow::Cow; -use std::cell::Cell; -use std::f64; -use std::ops::Range; -use std::ptr; -use std::ptr::NonNull; -use style::attr::AttrValue; -use style::element_state::ElementState; -use style::str::{split_commas, str_join}; -use unicode_bidi::{bidi_class, BidiClass}; -use url::Url; const DEFAULT_SUBMIT_VALUE: &'static str = "Submit"; const DEFAULT_RESET_VALUE: &'static str = "Reset"; diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index 07de5963ee1..40d871e3415 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::AttrValue; + use crate::dom::activation::Activatable; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; @@ -20,10 +25,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlformelement::{FormControl, FormControlElementHelpers, HTMLFormElement}; use crate::dom::node::{Node, ShadowIncluding}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::AttrValue; #[dom_struct] pub struct HTMLLabelElement { diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index 32fa5e88808..2fd26acec77 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -2,6 +2,10 @@ // 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLLegendElementBinding::HTMLLegendElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -13,9 +17,6 @@ use crate::dom::htmlfieldsetelement::HTMLFieldSetElement; use crate::dom::htmlformelement::{FormControl, HTMLFormElement}; use crate::dom::node::{BindContext, Node, UnbindContext}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLLegendElement { diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index 1ba7237b76f..58219171d3c 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::AttrValue; + use crate::dom::bindings::codegen::Bindings::HTMLLIElementBinding::HTMLLIElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -10,10 +15,6 @@ use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::AttrValue; #[dom_struct] pub struct HTMLLIElement { diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index c6d03721c46..c240f4da17c 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -2,6 +2,25 @@ * 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::borrow::ToOwned; +use std::cell::Cell; +use std::default::Default; + +use cssparser::{Parser as CssParser, ParserInput}; +use dom_struct::dom_struct; +use embedder_traits::EmbedderMsg; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use net_traits::ReferrerPolicy; +use servo_arc::Arc; +use servo_atoms::Atom; +use style::attr::AttrValue; +use style::media_queries::MediaList; +use style::parser::ParserContext as CssParserContext; +use style::str::HTML_SPACE_CHARACTERS; +use style::stylesheets::{CssRuleType, Origin, Stylesheet}; +use style_traits::ParsingMode; + use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListBinding::DOMTokenListMethods; @@ -14,9 +33,8 @@ use crate::dom::document::Document; use crate::dom::domtokenlist::DOMTokenList; use crate::dom::element::{ cors_setting_for_element, reflect_cross_origin_attribute, reflect_referrer_policy_attribute, - set_cross_origin_attribute, + set_cross_origin_attribute, AttributeMutation, Element, ElementCreator, }; -use crate::dom::element::{AttributeMutation, Element, ElementCreator}; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{ document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node, @@ -25,23 +43,6 @@ use crate::dom::node::{ use crate::dom::stylesheet::StyleSheet as DOMStyleSheet; use crate::dom::virtualmethods::VirtualMethods; use crate::stylesheet_loader::{StylesheetContextSource, StylesheetLoader, StylesheetOwner}; -use cssparser::{Parser as CssParser, ParserInput}; -use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use net_traits::ReferrerPolicy; -use servo_arc::Arc; -use servo_atoms::Atom; -use std::borrow::ToOwned; -use std::cell::Cell; -use std::default::Default; -use style::attr::AttrValue; -use style::media_queries::MediaList; -use style::parser::ParserContext as CssParserContext; -use style::str::HTML_SPACE_CHARACTERS; -use style::stylesheets::{CssRuleType, Origin, Stylesheet}; -use style_traits::ParsingMode; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct RequestGenerationId(u32); diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs index 3e1b19be48a..7367f188de7 100644 --- a/components/script/dom/htmlmapelement.rs +++ b/components/script/dom/htmlmapelement.rs @@ -2,15 +2,16 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlareaelement::HTMLAreaElement; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{Node, ShadowIncluding}; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLMapElement { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 90b9509f4f0..acd15800935 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -2,15 +2,52 @@ * 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::Cell; +use std::collections::VecDeque; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; +use std::{f64, mem}; + +use dom_struct::dom_struct; +use embedder_traits::resources::{self, Resource as EmbedderResource}; +use embedder_traits::{MediaPositionState, MediaSessionEvent, MediaSessionPlaybackState}; +use euclid::default::Size2D; +use headers::{ContentLength, ContentRange, HeaderMapExt}; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use http::header::{self, HeaderMap, HeaderValue}; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::jsapi::JSAutoRealm; +use media::{glplayer_channel, GLPlayerMsg, GLPlayerMsgForward, WindowGLContext}; +use net_traits::image::base::Image; +use net_traits::request::Destination; +use net_traits::{ + CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata, NetworkError, + ResourceFetchTiming, ResourceTimingType, +}; +use script_layout_interface::HTMLMediaData; +use script_traits::{ImageUpdate, WebrenderIpcSender}; +use servo_config::pref; +use servo_media::player::audio::AudioRenderer; +use servo_media::player::video::{VideoFrame, VideoFrameRenderer}; +use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, SeekLock, StreamType}; +use servo_media::{ClientContextId, ServoMedia, SupportsMediaType}; +use servo_url::ServoUrl; +use time::{self, Duration, Timespec}; +use webrender_api::{ + ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind, ImageData, + ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey, +}; + use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::attr::Attr; use crate::dom::audiotrack::AudioTrack; use crate::dom::audiotracklist::AudioTrackList; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; -use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::CanPlayTypeResult; -use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementConstants; -use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods; +use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::{ + CanPlayTypeResult, HTMLMediaElementConstants, HTMLMediaElementMethods, +}; use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods; use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*; use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods; @@ -18,8 +55,9 @@ use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding: use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{TextTrackKind, TextTrackMode}; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId}; -use crate::dom::bindings::codegen::InheritTypes::{HTMLMediaElementTypeId, NodeTypeId}; +use crate::dom::bindings::codegen::InheritTypes::{ + ElementTypeId, HTMLElementTypeId, HTMLMediaElementTypeId, NodeTypeId, +}; use crate::dom::bindings::codegen::UnionTypes::{ MediaStreamOrBlob, VideoTrackOrAudioTrackOrTextTrack, }; @@ -34,8 +72,8 @@ use crate::dom::blob::Blob; use crate::dom::document::Document; use crate::dom::element::{ cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute, + AttributeMutation, Element, ElementCreator, }; -use crate::dom::element::{AttributeMutation, Element, ElementCreator}; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; @@ -65,39 +103,6 @@ use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingLi use crate::realms::{enter_realm, InRealm}; use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use embedder_traits::resources::{self, Resource as EmbedderResource}; -use embedder_traits::{MediaPositionState, MediaSessionEvent, MediaSessionPlaybackState}; -use euclid::default::Size2D; -use headers::{ContentLength, ContentRange, HeaderMapExt}; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use http::header::{self, HeaderMap, HeaderValue}; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::jsapi::JSAutoRealm; -use media::{glplayer_channel, GLPlayerMsg, GLPlayerMsgForward, WindowGLContext}; -use net_traits::image::base::Image; -use net_traits::request::Destination; -use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata}; -use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType}; -use script_layout_interface::HTMLMediaData; -use script_traits::{ImageUpdate, WebrenderIpcSender}; -use servo_config::pref; -use servo_media::player::audio::AudioRenderer; -use servo_media::player::video::{VideoFrame, VideoFrameRenderer}; -use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, SeekLock, StreamType}; -use servo_media::{ClientContextId, ServoMedia, SupportsMediaType}; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::collections::VecDeque; -use std::f64; -use std::mem; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; -use time::{self, Duration, Timespec}; -use webrender_api::ImageKey; -use webrender_api::{ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind}; -use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat}; #[derive(PartialEq)] enum FrameStatus { diff --git a/components/script/dom/htmlmenuelement.rs b/components/script/dom/htmlmenuelement.rs index 9698a058fb1..10ab5116f75 100644 --- a/components/script/dom/htmlmenuelement.rs +++ b/components/script/dom/htmlmenuelement.rs @@ -2,14 +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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLMenuElementBinding::HTMLMenuElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLMenuElement { diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 204a67bf27c..4000035b0ca 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; +use style::str::HTML_SPACE_CHARACTERS; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -14,10 +19,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlheadelement::HTMLHeadElement; use crate::dom::node::{BindContext, Node, UnbindContext}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; -use style::str::HTML_SPACE_CHARACTERS; #[dom_struct] pub struct HTMLMetaElement { diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs index 42fb531614c..03859ee9689 100644 --- a/components/script/dom/htmlmeterelement.rs +++ b/components/script/dom/htmlmeterelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLMeterElementBinding::HTMLMeterElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -9,9 +13,6 @@ use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::nodelist::NodeList; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLMeterElement { diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs index f271c0e25d1..68c731c189e 100644 --- a/components/script/dom/htmlmodelement.rs +++ b/components/script/dom/htmlmodelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLModElement { diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 447d40b6a78..06509e66497 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -2,6 +2,14 @@ * 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::default::Default; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use net_traits::image::base::Image; +use servo_arc::Arc; + use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods; @@ -16,12 +24,6 @@ use crate::dom::node::{window_from_node, Node}; use crate::dom::validation::Validatable; use crate::dom::validitystate::ValidityState; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use net_traits::image::base::Image; -use servo_arc::Arc; -use std::default::Default; #[dom_struct] pub struct HTMLObjectElement { diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs index 05f8bb69bba..cba1baad27d 100644 --- a/components/script/dom/htmlolistelement.rs +++ b/components/script/dom/htmlolistelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLOListElement { diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index 499f88aa93b..58c943a5fb3 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; +use style::element_state::ElementState; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods; use crate::dom::bindings::inheritance::Castable; @@ -15,10 +20,6 @@ use crate::dom::node::{BindContext, Node, ShadowIncluding, UnbindContext}; use crate::dom::validation::Validatable; use crate::dom::validitystate::ValidationFlags; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use style::element_state::ElementState; #[dom_struct] pub struct HTMLOptGroupElement { diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 3d5abc655c0..50cedb749da 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -2,6 +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::Cell; +use std::convert::TryInto; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; +use js::rust::HandleObject; +use style::element_state::ElementState; +use style::str::{split_html_space_chars, str_join}; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods; @@ -26,13 +35,6 @@ use crate::dom::validation::Validatable; use crate::dom::validitystate::ValidationFlags; use crate::dom::virtualmethods::VirtualMethods; use crate::dom::window::Window; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix, QualName}; -use js::rust::HandleObject; -use std::cell::Cell; -use std::convert::TryInto; -use style::element_state::ElementState; -use style::str::{split_html_space_chars, str_join}; #[dom_struct] pub struct HTMLOptionElement { diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 4c826eb8ce4..8099c69e817 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use html5ever::local_name; + use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods; @@ -21,8 +24,6 @@ use crate::dom::htmloptionelement::HTMLOptionElement; use crate::dom::htmlselectelement::HTMLSelectElement; use crate::dom::node::{document_from_node, Node}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use html5ever::local_name; #[dom_struct] pub struct HTMLOptionsCollection { diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 6d8033fe299..e444a19c60d 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLOutputElementBinding::HTMLOutputElementMethods; @@ -17,9 +21,6 @@ use crate::dom::nodelist::NodeList; use crate::dom::validation::Validatable; use crate::dom::validitystate::ValidityState; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLOutputElement { diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index 82defe4113b..0609f355575 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLParagraphElement { diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs index a2b30e7ecd1..4b550346877 100644 --- a/components/script/dom/htmlparamelement.rs +++ b/components/script/dom/htmlparamelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLParamElement { diff --git a/components/script/dom/htmlpictureelement.rs b/components/script/dom/htmlpictureelement.rs index 62de53ef704..51b93857bfe 100644 --- a/components/script/dom/htmlpictureelement.rs +++ b/components/script/dom/htmlpictureelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLPictureElement { diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs index 0243be8d4ae..9eb27ebd820 100644 --- a/components/script/dom/htmlpreelement.rs +++ b/components/script/dom/htmlpreelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLPreElement { diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs index dc19a7a63f9..79d73b2e338 100644 --- a/components/script/dom/htmlprogresselement.rs +++ b/components/script/dom/htmlprogresselement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLProgressElementBinding::HTMLProgressElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; @@ -11,9 +15,6 @@ use crate::dom::element::Element; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::nodelist::NodeList; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLProgressElement { diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs index f6f42dc4231..acd8c3521be 100644 --- a/components/script/dom/htmlquoteelement.rs +++ b/components/script/dom/htmlquoteelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLQuoteElement { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 30c6ad7fb47..9f0ad234662 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -2,6 +2,43 @@ * 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 core::ffi::c_void; +use std::cell::Cell; +use std::fs::{create_dir_all, read_to_string, File}; +use std::io::{Read, Seek, Write}; +use std::mem::replace; +use std::path::PathBuf; +use std::process::Command; +use std::ptr; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; + +use content_security_policy as csp; +use dom_struct::dom_struct; +use encoding_rs::Encoding; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::jsapi::{CanCompileOffThread, CompileToStencilOffThread1, OffThreadToken}; +use js::jsval::UndefinedValue; +use js::rust::{ + transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, HandleObject, + Stencil, +}; +use msg::constellation_msg::PipelineId; +use net_traits::request::{ + CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder, +}; +use net_traits::{ + FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming, + ResourceTimingType, +}; +use servo_atoms::Atom; +use servo_config::pref; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style::str::{StaticStringVec, HTML_SPACE_CHARACTERS}; +use uuid::Uuid; + use crate::document_loader::LoadType; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; @@ -17,61 +54,26 @@ use crate::dom::bindings::trace::NoTrace; use crate::dom::document::Document; use crate::dom::element::{ cors_setting_for_element, referrer_policy_for_element, reflect_cross_origin_attribute, - reflect_referrer_policy_attribute, set_cross_origin_attribute, + reflect_referrer_policy_attribute, set_cross_origin_attribute, AttributeMutation, Element, + ElementCreator, }; -use crate::dom::element::{AttributeMutation, Element, ElementCreator}; use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlelement::HTMLElement; -use crate::dom::node::{document_from_node, window_from_node}; -use crate::dom::node::{BindContext, ChildrenMutation, CloneChildrenFlag, Node}; +use crate::dom::node::{ + document_from_node, window_from_node, BindContext, ChildrenMutation, CloneChildrenFlag, Node, +}; use crate::dom::performanceresourcetiming::InitiatorType; use crate::dom::virtualmethods::VirtualMethods; use crate::fetch::create_a_potential_cors_request; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; use crate::realms::enter_realm; -use crate::script_module::fetch_inline_module_script; -use crate::script_module::{fetch_external_module_script, ModuleOwner, ScriptFetchOptions}; +use crate::script_module::{ + fetch_external_module_script, fetch_inline_module_script, ModuleOwner, ScriptFetchOptions, +}; use crate::task::TaskCanceller; use crate::task_source::dom_manipulation::DOMManipulationTaskSource; -use crate::task_source::TaskSource; -use crate::task_source::TaskSourceName; -use content_security_policy as csp; -use core::ffi::c_void; -use dom_struct::dom_struct; -use encoding_rs::Encoding; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::jsapi::{CanCompileOffThread, CompileToStencilOffThread1, OffThreadToken}; -use js::jsval::UndefinedValue; -use js::rust::{ - transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, HandleObject, - Stencil, -}; -use msg::constellation_msg::PipelineId; -use net_traits::request::{ - CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder, -}; -use net_traits::{ - FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming, - ResourceTimingType, -}; -use servo_atoms::Atom; -use servo_config::pref; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::fs::{create_dir_all, read_to_string, File}; -use std::io::{Read, Seek, Write}; -use std::mem::replace; -use std::path::PathBuf; -use std::process::Command; -use std::ptr; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; -use style::str::{StaticStringVec, HTML_SPACE_CHARACTERS}; -use uuid::Uuid; +use crate::task_source::{TaskSource, TaskSourceName}; pub struct OffThreadCompilationContext { script_element: Trusted<HTMLScriptElement>, diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 04d52ae695d..a7eb1ea6060 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -2,6 +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::default::Default; +use std::iter; + +use dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::AttrValue; +use style::element_state::ElementState; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; @@ -9,8 +18,9 @@ use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptio use crate::dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::UnionTypes::HTMLElementOrLong; -use crate::dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement; +use crate::dom::bindings::codegen::UnionTypes::{ + HTMLElementOrLong, HTMLOptionElementOrHTMLOptGroupElement, +}; use crate::dom::bindings::error::ErrorResult; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -29,13 +39,6 @@ use crate::dom::nodelist::NodeList; use crate::dom::validation::{is_barred_by_datalist_ancestor, Validatable}; use crate::dom::validitystate::{ValidationFlags, ValidityState}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; -use std::default::Default; -use std::iter; -use style::attr::AttrValue; -use style::element_state::ElementState; #[derive(JSTraceable, MallocSizeOf)] struct OptionsFilter; diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index 91e33e1ea9a..19a27837d87 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -2,12 +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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::root::DomRoot; -use crate::dom::bindings::root::{Dom, Root}; +use crate::dom::bindings::root::{Dom, DomRoot, Root}; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::element::AttributeMutation; @@ -16,9 +19,6 @@ use crate::dom::htmlimageelement::HTMLImageElement; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::node::{BindContext, Node, UnbindContext}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLSourceElement { diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs index ac9a711d716..1d323a65556 100644 --- a/components/script/dom/htmlspanelement.rs +++ b/components/script/dom/htmlspanelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLSpanElement { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 846c1ccf59e..8df9901eb1c 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -2,6 +2,19 @@ * 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::Cell; + +use cssparser::{Parser as CssParser, ParserInput}; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use net_traits::ReferrerPolicy; +use servo_arc::Arc; +use style::media_queries::MediaList; +use style::parser::ParserContext as CssParserContext; +use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet}; +use style_traits::ParsingMode; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLStyleElementBinding::HTMLStyleElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -18,17 +31,6 @@ use crate::dom::node::{ use crate::dom::stylesheet::StyleSheet as DOMStyleSheet; use crate::dom::virtualmethods::VirtualMethods; use crate::stylesheet_loader::{StylesheetLoader, StylesheetOwner}; -use cssparser::{Parser as CssParser, ParserInput}; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use net_traits::ReferrerPolicy; -use servo_arc::Arc; -use std::cell::Cell; -use style::media_queries::MediaList; -use style::parser::ParserContext as CssParserContext; -use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet}; -use style_traits::ParsingMode; #[dom_struct] pub struct HTMLStyleElement { diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs index c7c91ae359e..c856c53c18a 100644 --- a/components/script/dom/htmltablecaptionelement.rs +++ b/components/script/dom/htmltablecaptionelement.rs @@ -2,14 +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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLTableCaptionElement { diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 9db63e6ffe0..a6ab78177dc 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -2,11 +2,17 @@ * 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 cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; +use style::context::QuirksMode; + use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::root::DomRoot; -use crate::dom::bindings::root::LayoutDom; +use crate::dom::bindings::root::{DomRoot, LayoutDom}; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::element::{Element, LayoutElementHelpers}; @@ -14,12 +20,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmltablerowelement::HTMLTableRowElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::{AttrValue, LengthOrPercentageOrAuto}; -use style::context::QuirksMode; const DEFAULT_COLSPAN: u32 = 1; const DEFAULT_ROWSPAN: u32 = 1; diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs index 2700defb19a..d2b9e1f9421 100644 --- a/components/script/dom/htmltablecolelement.rs +++ b/components/script/dom/htmltablecolelement.rs @@ -2,14 +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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLTableColElement { diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 189eac21a17..25c75e1820f 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -2,6 +2,14 @@ * 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::Cell; + +use cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::{parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto}; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; @@ -20,12 +28,6 @@ use crate::dom::htmltablerowelement::HTMLTableRowElement; use crate::dom::htmltablesectionelement::HTMLTableSectionElement; use crate::dom::node::{document_from_node, window_from_node, Node}; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use std::cell::Cell; -use style::attr::{parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto}; #[dom_struct] pub struct HTMLTableElement { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 43006a85757..79f154c4256 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -2,6 +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 cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::AttrValue; + use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::HTMLTableRowElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods; @@ -19,11 +25,6 @@ use crate::dom::htmltableelement::HTMLTableElement; use crate::dom::htmltablesectionelement::HTMLTableSectionElement; use crate::dom::node::{window_from_node, Node}; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::AttrValue; #[derive(JSTraceable)] struct CellsFilter; diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index ccaf409e10a..24a85fb1b1a 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -2,6 +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 cssparser::RGBA; +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::attr::AttrValue; + use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::error::{ErrorResult, Fallible}; @@ -15,11 +21,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmltablerowelement::HTMLTableRowElement; use crate::dom::node::{window_from_node, Node}; use crate::dom::virtualmethods::VirtualMethods; -use cssparser::RGBA; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::attr::AttrValue; #[dom_struct] pub struct HTMLTableSectionElement { diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 1a542171ef0..4938c25a14d 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -12,9 +16,6 @@ use crate::dom::documentfragment::DocumentFragment; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{document_from_node, CloneChildrenFlag, Node}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLTemplateElement { diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 2220058db98..93cc3c6d292 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -2,6 +2,17 @@ * 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::Cell; +use std::default::Default; +use std::ops::Range; + +use dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use script_traits::ScriptToConstellationChan; +use style::attr::AttrValue; +use style::element_state::ElementState; + use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -14,8 +25,7 @@ use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::compositionevent::CompositionEvent; use crate::dom::document::Document; -use crate::dom::element::LayoutElementHelpers; -use crate::dom::element::{AttributeMutation, Element}; +use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers}; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlelement::HTMLElement; @@ -23,9 +33,9 @@ use crate::dom::htmlfieldsetelement::HTMLFieldSetElement; use crate::dom::htmlformelement::{FormControl, HTMLFormElement}; use crate::dom::htmlinputelement::HTMLInputElement; use crate::dom::keyboardevent::KeyboardEvent; -use crate::dom::node::window_from_node; use crate::dom::node::{ - BindContext, ChildrenMutation, CloneChildrenFlag, Node, NodeDamage, UnbindContext, + window_from_node, BindContext, ChildrenMutation, CloneChildrenFlag, Node, NodeDamage, + UnbindContext, }; use crate::dom::nodelist::NodeList; use crate::dom::textcontrol::{TextControlElement, TextControlSelection}; @@ -35,15 +45,6 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::textinput::{ Direction, KeyReaction, Lines, SelectionDirection, TextInput, UTF16CodeUnits, UTF8Bytes, }; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use script_traits::ScriptToConstellationChan; -use std::cell::Cell; -use std::default::Default; -use std::ops::Range; -use style::attr::AttrValue; -use style::element_state::ElementState; #[dom_struct] pub struct HTMLTextAreaElement { diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs index 712983f8460..4af4acfc888 100644 --- a/components/script/dom/htmltimeelement.rs +++ b/components/script/dom/htmltimeelement.rs @@ -2,15 +2,16 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLTimeElement { diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index 464bbaab2e0..24572c0f7e1 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding::HTMLTitleElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -11,9 +15,6 @@ use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{BindContext, ChildrenMutation, Node}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLTitleElement { diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs index 08e450aea52..841ac42c1b0 100644 --- a/components/script/dom/htmltrackelement.rs +++ b/components/script/dom/htmltrackelement.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use html5ever::{local_name, LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::HTMLTrackElementBinding::{ HTMLTrackElementConstants, HTMLTrackElementMethods, }; @@ -13,9 +17,6 @@ use crate::dom::element::Element; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::texttrack::TextTrack; -use dom_struct::dom_struct; -use html5ever::{local_name, LocalName, Prefix}; -use js::rust::HandleObject; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] #[repr(u16)] diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs index 73704e70418..f0820c0f3ae 100644 --- a/components/script/dom/htmlulistelement.rs +++ b/components/script/dom/htmlulistelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLUListElement { diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs index c59b4d81e8c..c87c104d66b 100644 --- a/components/script/dom/htmlunknownelement.rs +++ b/components/script/dom/htmlunknownelement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use js::rust::HandleObject; + use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use js::rust::HandleObject; #[dom_struct] pub struct HTMLUnknownElement { diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index 828f8d6f4a8..39bfabfb6d0 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -2,6 +2,27 @@ * 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::Cell; +use std::sync::{Arc, Mutex}; + +use dom_struct::dom_struct; +use euclid::default::Size2D; +use html5ever::{local_name, LocalName, Prefix}; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::rust::HandleObject; +use net_traits::image_cache::{ + ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, PendingImageId, + UsePlaceholder, +}; +use net_traits::request::{CredentialsMode, Destination, RequestBuilder}; +use net_traits::{ + CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, FetchResponseMsg, + NetworkError, ResourceFetchTiming, ResourceTimingType, +}; +use servo_media::player::video::VideoFrame; +use servo_url::ServoUrl; + use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; @@ -21,25 +42,6 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::fetch::FetchCanceller; use crate::image_listener::{generate_cache_listener_for_element, ImageCacheListener}; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; -use dom_struct::dom_struct; -use euclid::default::Size2D; -use html5ever::{local_name, LocalName, Prefix}; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::rust::HandleObject; -use net_traits::image_cache::{ - ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, PendingImageId, - UsePlaceholder, -}; -use net_traits::request::{CredentialsMode, Destination, RequestBuilder}; -use net_traits::{ - CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, FetchResponseMsg, -}; -use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType}; -use servo_media::player::video::VideoFrame; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::sync::{Arc, Mutex}; const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; diff --git a/components/script/dom/identityhub.rs b/components/script/dom/identityhub.rs index 49822b3d729..19890d56025 100644 --- a/components/script/dom/identityhub.rs +++ b/components/script/dom/identityhub.rs @@ -3,14 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use smallvec::SmallVec; -use webgpu::wgpu::{ - id::{ - AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId, - DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId, - TextureId, TextureViewId, - }, - identity::IdentityManager, +use webgpu::wgpu::id::{ + AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId, + DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId, + TextureId, TextureViewId, }; +use webgpu::wgpu::identity::IdentityManager; use webgpu::wgt::Backend; #[derive(Debug)] diff --git a/components/script/dom/imagebitmap.rs b/components/script/dom/imagebitmap.rs index 72b4871490f..36b845b64e4 100644 --- a/components/script/dom/imagebitmap.rs +++ b/components/script/dom/imagebitmap.rs @@ -2,18 +2,17 @@ * 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::cell::DomRefCell; +use std::cell::Cell; +use std::vec::Vec; -use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::ImageBitmapMethods; -use crate::dom::bindings::root::DomRoot; -use crate::dom::globalscope::GlobalScope; +use dom_struct::dom_struct; +use crate::dom::bindings::cell::DomRefCell; +use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::ImageBitmapMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; -use dom_struct::dom_struct; - -use std::cell::Cell; -use std::vec::Vec; +use crate::dom::bindings::root::DomRoot; +use crate::dom::globalscope::GlobalScope; #[dom_struct] pub struct ImageBitmap { diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 434b2f20252..78d0b56546c 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -2,23 +2,25 @@ * 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::ImageDataBinding::ImageDataMethods; -use crate::dom::bindings::error::{Error, Fallible}; -use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; -use crate::dom::bindings::root::DomRoot; -use crate::dom::globalscope::GlobalScope; -use crate::script_runtime::JSContext; +use std::borrow::Cow; +use std::default::Default; +use std::ptr; +use std::ptr::NonNull; +use std::vec::Vec; + use dom_struct::dom_struct; use euclid::default::{Rect, Size2D}; use ipc_channel::ipc::IpcSharedMemory; use js::jsapi::{Heap, JSObject}; use js::rust::{HandleObject, Runtime}; use js::typedarray::{CreateWith, Uint8ClampedArray}; -use std::borrow::Cow; -use std::default::Default; -use std::ptr; -use std::ptr::NonNull; -use std::vec::Vec; + +use crate::dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; +use crate::dom::bindings::error::{Error, Fallible}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; +use crate::dom::bindings::root::DomRoot; +use crate::dom::globalscope::GlobalScope; +use crate::script_runtime::JSContext; #[dom_struct] pub struct ImageData { diff --git a/components/script/dom/inputevent.rs b/components/script/dom/inputevent.rs index d96f64327b6..4ba00220aef 100644 --- a/components/script/dom/inputevent.rs +++ b/components/script/dom/inputevent.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods}; use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods; use crate::dom::bindings::error::Fallible; @@ -10,8 +13,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct InputEvent { diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index f2f8084ce1d..d973f78315c 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -2,6 +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 std::cell::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use keyboard_types::{Key, Modifiers}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding; use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding::KeyboardEventMethods; @@ -14,10 +20,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use keyboard_types::{Key, Modifiers}; -use std::cell::Cell; #[dom_struct] pub struct KeyboardEvent { diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 6f1fc477f3a..70556eaa101 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use net_traits::request::Referrer; +use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; +use servo_url::{MutableOrigin, ServoUrl}; + use crate::dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -12,10 +17,6 @@ use crate::dom::document::Document; use crate::dom::globalscope::GlobalScope; use crate::dom::urlhelper::UrlHelper; use crate::dom::window::Window; -use dom_struct::dom_struct; -use net_traits::request::Referrer; -use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin}; -use servo_url::{MutableOrigin, ServoUrl}; #[derive(PartialEq)] enum NavigationType { diff --git a/components/script/dom/mediadeviceinfo.rs b/components/script/dom/mediadeviceinfo.rs index 29d63027952..c07be051076 100644 --- a/components/script/dom/mediadeviceinfo.rs +++ b/components/script/dom/mediadeviceinfo.rs @@ -2,14 +2,16 @@ * 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::MediaDeviceInfoBinding::MediaDeviceInfoMethods; -use crate::dom::bindings::codegen::Bindings::MediaDeviceInfoBinding::MediaDeviceKind; +use dom_struct::dom_struct; +use servo_media::streams::device_monitor::MediaDeviceKind as ServoMediaDeviceKind; + +use crate::dom::bindings::codegen::Bindings::MediaDeviceInfoBinding::{ + MediaDeviceInfoMethods, MediaDeviceKind, +}; 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 dom_struct::dom_struct; -use servo_media::streams::device_monitor::MediaDeviceKind as ServoMediaDeviceKind; #[dom_struct] pub struct MediaDeviceInfo { diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs index 9a88ed2e3a2..dc7b6820448 100644 --- a/components/script/dom/mediadevices.rs +++ b/components/script/dom/mediadevices.rs @@ -2,13 +2,21 @@ * 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::MediaDevicesBinding::MediaDevicesMethods; -use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaStreamConstraints; -use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints; -use crate::dom::bindings::codegen::UnionTypes::ClampedUnsignedLongOrConstrainULongRange as ConstrainULong; -use crate::dom::bindings::codegen::UnionTypes::DoubleOrConstrainDoubleRange as ConstrainDouble; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::DomObject; +use std::rc::Rc; + +use dom_struct::dom_struct; +use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet}; +use servo_media::streams::MediaStreamType; +use servo_media::ServoMedia; + +use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{ + MediaDevicesMethods, MediaStreamConstraints, +}; +use crate::dom::bindings::codegen::UnionTypes::{ + BooleanOrMediaTrackConstraints, ClampedUnsignedLongOrConstrainULongRange as ConstrainULong, + DoubleOrConstrainDoubleRange as ConstrainDouble, +}; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; @@ -17,11 +25,6 @@ use crate::dom::mediastream::MediaStream; use crate::dom::mediastreamtrack::MediaStreamTrack; use crate::dom::promise::Promise; use crate::realms::{AlreadyInRealm, InRealm}; -use dom_struct::dom_struct; -use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet}; -use servo_media::streams::MediaStreamType; -use servo_media::ServoMedia; -use std::rc::Rc; #[dom_struct] pub struct MediaDevices { diff --git a/components/script/dom/mediaelementaudiosourcenode.rs b/components/script/dom/mediaelementaudiosourcenode.rs index 79746215559..4efc43e0418 100644 --- a/components/script/dom/mediaelementaudiosourcenode.rs +++ b/components/script/dom/mediaelementaudiosourcenode.rs @@ -2,20 +2,23 @@ * 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::sync::mpsc; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::media_element_source_node::MediaElementSourceNodeMessage; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; + use crate::dom::audiocontext::AudioContext; use crate::dom::audionode::AudioNode; -use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding::MediaElementAudioSourceNodeMethods; -use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding::MediaElementAudioSourceOptions; +use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding::{ + MediaElementAudioSourceNodeMethods, MediaElementAudioSourceOptions, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::media_element_source_node::MediaElementSourceNodeMessage; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; -use std::sync::mpsc; #[dom_struct] pub struct MediaElementAudioSourceNode { diff --git a/components/script/dom/mediaerror.rs b/components/script/dom/mediaerror.rs index ace68e43583..d427d3846c7 100644 --- a/components/script/dom/mediaerror.rs +++ b/components/script/dom/mediaerror.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct MediaError { diff --git a/components/script/dom/mediafragmentparser.rs b/components/script/dom/mediafragmentparser.rs index 2e9de4b0f8c..0f64a80fa4e 100644 --- a/components/script/dom/mediafragmentparser.rs +++ b/components/script/dom/mediafragmentparser.rs @@ -2,11 +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 chrono::NaiveDateTime; -use servo_url::ServoUrl; use std::borrow::Cow; use std::collections::VecDeque; use std::str::FromStr; + +use chrono::NaiveDateTime; +use servo_url::ServoUrl; use url::{form_urlencoded, Position, Url}; #[derive(Clone, Copy, Debug, Eq, PartialEq)] diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index 87a318ddbe2..208f3a7aed0 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -2,23 +2,23 @@ * 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::MediaListBinding::MediaListMethods; -use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::str::DOMString; -use crate::dom::cssstylesheet::CSSStyleSheet; -use crate::dom::window::Window; use cssparser::{Parser, ParserInput}; use dom_struct::dom_struct; use servo_arc::Arc; -use style::media_queries::MediaList as StyleMediaList; -use style::media_queries::MediaQuery; +use style::media_queries::{MediaList as StyleMediaList, MediaQuery}; use style::parser::ParserContext; use style::shared_lock::{Locked, SharedRwLock}; use style::stylesheets::{CssRuleType, Origin}; use style_traits::{ParsingMode, ToCss}; +use crate::dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods; +use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::str::DOMString; +use crate::dom::cssstylesheet::CSSStyleSheet; +use crate::dom::window::Window; + #[dom_struct] pub struct MediaList { reflector_: Reflector, diff --git a/components/script/dom/mediametadata.rs b/components/script/dom/mediametadata.rs index 8e931dd0b4b..d5452680157 100644 --- a/components/script/dom/mediametadata.rs +++ b/components/script/dom/mediametadata.rs @@ -2,17 +2,19 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataInit; -use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataMethods; +use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::{ + MediaMetadataInit, MediaMetadataMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::mediasession::MediaSession; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct MediaMetadata { diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index 57140c8cb6f..a7ac80a395c 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -2,9 +2,17 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; +use style::media_queries::MediaList; +use style_traits::ToCss; + use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions; +use crate::dom::bindings::codegen::Bindings::EventTargetBinding::{ + AddEventListenerOptions, EventListenerOptions, +}; use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; @@ -12,11 +20,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::eventtarget::EventTarget; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::rc::Rc; -use style::media_queries::MediaList; -use style_traits::ToCss; pub enum MediaQueryListMatchState { Same(bool), diff --git a/components/script/dom/mediaquerylistevent.rs b/components/script/dom/mediaquerylistevent.rs index c58dd3aee5c..9856cf8f39d 100644 --- a/components/script/dom/mediaquerylistevent.rs +++ b/components/script/dom/mediaquerylistevent.rs @@ -2,9 +2,16 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryListEventInit; -use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryListEventMethods; +use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding::{ + MediaQueryListEventInit, MediaQueryListEventMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; @@ -13,10 +20,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; -use std::cell::Cell; // https://drafts.csswg.org/cssom-view/#dom-mediaquerylistevent-mediaquerylistevent #[dom_struct] diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs index edd73158acc..14ca4c14494 100644 --- a/components/script/dom/mediasession.rs +++ b/components/script/dom/mediasession.rs @@ -2,16 +2,23 @@ * 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::rc::Rc; + +use dom_struct::dom_struct; +use embedder_traits::{MediaMetadata as EmbedderMediaMetadata, MediaSessionEvent}; +use script_traits::{MediaSessionActionType, ScriptMsg}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods; -use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataInit; -use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataMethods; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaPositionState; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionAction; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionActionHandler; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionMethods; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionPlaybackState; +use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::{ + MediaMetadataInit, MediaMetadataMethods, +}; +use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::{ + MediaPositionState, MediaSessionAction, MediaSessionActionHandler, MediaSessionMethods, + MediaSessionPlaybackState, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -21,14 +28,6 @@ use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::mediametadata::MediaMetadata; use crate::dom::window::Window; use crate::realms::{enter_realm, InRealm}; -use dom_struct::dom_struct; -use embedder_traits::MediaMetadata as EmbedderMediaMetadata; -use embedder_traits::MediaSessionEvent; -use script_traits::MediaSessionActionType; -use script_traits::ScriptMsg; -use std::rc::Rc; - -use super::bindings::trace::HashMapTracedValues; #[dom_struct] pub struct MediaSession { diff --git a/components/script/dom/mediastream.rs b/components/script/dom/mediastream.rs index 5e1b1dc5970..55da06cc74a 100644 --- a/components/script/dom/mediastream.rs +++ b/components/script/dom/mediastream.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::streams::registry::MediaStreamId; +use servo_media::streams::MediaStreamType; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::MediaStreamMethods; use crate::dom::bindings::error::Fallible; @@ -12,10 +17,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::mediastreamtrack::MediaStreamTrack; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::streams::registry::MediaStreamId; -use servo_media::streams::MediaStreamType; #[dom_struct] pub struct MediaStream { diff --git a/components/script/dom/mediastreamaudiodestinationnode.rs b/components/script/dom/mediastreamaudiodestinationnode.rs index c7d060fb6a6..7409cfa98e2 100644 --- a/components/script/dom/mediastreamaudiodestinationnode.rs +++ b/components/script/dom/mediastreamaudiodestinationnode.rs @@ -2,11 +2,16 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::AudioNodeInit; +use servo_media::streams::MediaStreamType; +use servo_media::ServoMedia; + use crate::dom::audiocontext::AudioContext; use crate::dom::audionode::AudioNode; -use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ - ChannelCountMode, ChannelInterpretation, + AudioNodeOptions, ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::MediaStreamAudioDestinationNodeBinding::MediaStreamAudioDestinationNodeMethods; use crate::dom::bindings::error::Fallible; @@ -15,11 +20,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::mediastream::MediaStream; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::AudioNodeInit; -use servo_media::streams::MediaStreamType; -use servo_media::ServoMedia; #[dom_struct] pub struct MediaStreamAudioDestinationNode { diff --git a/components/script/dom/mediastreamaudiosourcenode.rs b/components/script/dom/mediastreamaudiosourcenode.rs index 4ac4e8cf9b4..c56851912db 100644 --- a/components/script/dom/mediastreamaudiosourcenode.rs +++ b/components/script/dom/mediastreamaudiosourcenode.rs @@ -2,6 +2,11 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::AudioNodeInit; +use servo_media::streams::MediaStreamType; + use crate::dom::audiocontext::AudioContext; use crate::dom::audionode::AudioNode; use crate::dom::bindings::codegen::Bindings::MediaStreamAudioSourceNodeBinding::{ @@ -13,10 +18,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::mediastream::MediaStream; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::AudioNodeInit; -use servo_media::streams::MediaStreamType; #[dom_struct] pub struct MediaStreamAudioSourceNode { diff --git a/components/script/dom/mediastreamtrack.rs b/components/script/dom/mediastreamtrack.rs index 729dbfc5cce..06950d5350e 100644 --- a/components/script/dom/mediastreamtrack.rs +++ b/components/script/dom/mediastreamtrack.rs @@ -2,15 +2,16 @@ * 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 dom_struct::dom_struct; +use servo_media::streams::registry::MediaStreamId; +use servo_media::streams::MediaStreamType; + use crate::dom::bindings::codegen::Bindings::MediaStreamTrackBinding::MediaStreamTrackMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use servo_media::streams::registry::MediaStreamId; -use servo_media::streams::MediaStreamType; #[dom_struct] pub struct MediaStreamTrack { diff --git a/components/script/dom/mediastreamtrackaudiosourcenode.rs b/components/script/dom/mediastreamtrackaudiosourcenode.rs index c5023d24abc..fa8b480764d 100644 --- a/components/script/dom/mediastreamtrackaudiosourcenode.rs +++ b/components/script/dom/mediastreamtrackaudiosourcenode.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::AudioNodeInit; + use crate::dom::audiocontext::AudioContext; use crate::dom::audionode::AudioNode; use crate::dom::bindings::codegen::Bindings::MediaStreamTrackAudioSourceNodeBinding::MediaStreamTrackAudioSourceOptions; @@ -11,9 +15,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::mediastreamtrack::MediaStreamTrack; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::AudioNodeInit; #[dom_struct] pub struct MediaStreamTrackAudioSourceNode { diff --git a/components/script/dom/messagechannel.rs b/components/script/dom/messagechannel.rs index 0b74c0e60d8..ca3d8738143 100644 --- a/components/script/dom/messagechannel.rs +++ b/components/script/dom/messagechannel.rs @@ -2,13 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::MessageChannelBinding::MessageChannelMethods; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::messageport::MessagePort; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct MessageChannel { diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index 2e9f17cc31b..d398f67a309 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::MessageEventBinding; @@ -21,11 +27,6 @@ use crate::dom::messageport::MessagePort; use crate::dom::serviceworker::ServiceWorker; use crate::dom::windowproxy::WindowProxy; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; #[unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/messageport.rs b/components/script/dom/messageport.rs index 3035cc5bcd4..f0de3a48e94 100644 --- a/components/script/dom/messageport.rs +++ b/components/script/dom/messageport.rs @@ -2,6 +2,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; +use std::convert::TryInto; +use std::num::NonZeroU32; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject, MutableHandleObject}; +use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; +use msg::constellation_msg::{MessagePortId, MessagePortIndex, PipelineNamespaceId}; +use script_traits::PortMessageTask; + use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::{ MessagePortMethods, PostMessageOptions, @@ -17,17 +29,6 @@ use crate::dom::bindings::transferable::Transferable; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext as SafeJSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsapi::{JSObject, MutableHandleObject}; -use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; -use msg::constellation_msg::{MessagePortId, MessagePortIndex, PipelineNamespaceId}; -use script_traits::PortMessageTask; -use std::cell::{Cell, RefCell}; -use std::collections::HashMap; -use std::convert::TryInto; -use std::num::NonZeroU32; -use std::rc::Rc; #[dom_struct] /// The MessagePort used in the DOM. diff --git a/components/script/dom/mimetype.rs b/components/script/dom/mimetype.rs index 5e4db84fe27..437f2bd4fe9 100644 --- a/components/script/dom/mimetype.rs +++ b/components/script/dom/mimetype.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::MimeTypeBinding::MimeTypeMethods; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::plugin::Plugin; -use dom_struct::dom_struct; #[dom_struct] pub struct MimeType { diff --git a/components/script/dom/mimetypearray.rs b/components/script/dom/mimetypearray.rs index 9bbda92e231..0495a8d187e 100644 --- a/components/script/dom/mimetypearray.rs +++ b/components/script/dom/mimetypearray.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods; 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 crate::dom::mimetype::MimeType; -use dom_struct::dom_struct; #[dom_struct] pub struct MimeTypeArray { diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 670b058b0ba..ad8f9516fa4 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -2,6 +2,14 @@ * 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::Cell; +use std::default::Default; + +use dom_struct::dom_struct; +use euclid::default::Point2D; +use js::rust::HandleObject; +use servo_config::pref; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::MouseEventBinding; use crate::dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; @@ -16,12 +24,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::node::Node; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use euclid::default::Point2D; -use js::rust::HandleObject; -use servo_config::pref; -use std::cell::Cell; -use std::default::Default; #[dom_struct] pub struct MouseEvent { diff --git a/components/script/dom/mutationobserver.rs b/components/script/dom/mutationobserver.rs index 8c558408d86..f52a80a6776 100644 --- a/components/script/dom/mutationobserver.rs +++ b/components/script/dom/mutationobserver.rs @@ -2,11 +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 std::rc::Rc; + +use dom_struct::dom_struct; +use html5ever::{namespace_url, ns, LocalName, Namespace}; +use js::rust::HandleObject; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationCallback; use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverBinding::MutationObserverMethods; -use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverInit; +use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::{ + MutationCallback, MutationObserverInit, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -16,10 +23,6 @@ use crate::dom::node::{Node, ShadowIncluding}; use crate::dom::window::Window; use crate::microtask::Microtask; use crate::script_thread::ScriptThread; -use dom_struct::dom_struct; -use html5ever::{namespace_url, ns, LocalName, Namespace}; -use js::rust::HandleObject; -use std::rc::Rc; #[dom_struct] pub struct MutationObserver { diff --git a/components/script/dom/mutationrecord.rs b/components/script/dom/mutationrecord.rs index d880f44a8ae..4523958ae85 100644 --- a/components/script/dom/mutationrecord.rs +++ b/components/script/dom/mutationrecord.rs @@ -2,14 +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 dom_struct::dom_struct; +use html5ever::{LocalName, Namespace}; + use crate::dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding::MutationRecordMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::node::{window_from_node, Node}; use crate::dom::nodelist::NodeList; -use dom_struct::dom_struct; -use html5ever::{LocalName, Namespace}; #[dom_struct] pub struct MutationRecord { diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs index a7c3e4fef86..d7121d2815d 100644 --- a/components/script/dom/namednodemap.rs +++ b/components/script/dom/namednodemap.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use html5ever::LocalName; + use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods; @@ -12,8 +15,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::bindings::xmlname::namespace_from_domstring; use crate::dom::element::Element; use crate::dom::window::Window; -use dom_struct::dom_struct; -use html5ever::LocalName; #[dom_struct] pub struct NamedNodeMap { diff --git a/components/script/dom/navigationpreloadmanager.rs b/components/script/dom/navigationpreloadmanager.rs index c8d74403fcd..011ad438f5c 100644 --- a/components/script/dom/navigationpreloadmanager.rs +++ b/components/script/dom/navigationpreloadmanager.rs @@ -2,8 +2,14 @@ * 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::NavigationPreloadManagerBinding::NavigationPreloadManagerMethods; -use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::NavigationPreloadState; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsval::UndefinedValue; + +use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::{ + NavigationPreloadManagerMethods, NavigationPreloadState, +}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::ByteString; @@ -12,9 +18,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::dom::serviceworkerregistration::ServiceWorkerRegistration; use crate::realms::InRealm; -use dom_struct::dom_struct; -use js::jsval::UndefinedValue; -use std::rc::Rc; #[dom_struct] pub struct NavigationPreloadManager { diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 07abebe667f..1271dd7bed3 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::jsval::JSVal; + use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -20,8 +23,6 @@ use crate::dom::serviceworkercontainer::ServiceWorkerContainer; use crate::dom::window::Window; use crate::dom::xrsystem::XRSystem; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsval::JSVal; #[dom_struct] pub struct Navigator { diff --git a/components/script/dom/navigatorinfo.rs b/components/script/dom/navigatorinfo.rs index e674834f14b..5450677cb9b 100644 --- a/components/script/dom/navigatorinfo.rs +++ b/components/script/dom/navigatorinfo.rs @@ -2,9 +2,10 @@ * 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::str::DOMString; use std::borrow::Cow; +use crate::dom::bindings::str::DOMString; + #[allow(non_snake_case)] pub fn Product() -> DOMString { DOMString::from("Gecko") diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 39655064bdd..4758c28717d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -4,6 +4,46 @@ //! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. +use std::borrow::Cow; +use std::cell::{Cell, UnsafeCell}; +use std::default::Default; +use std::ops::Range; +use std::slice::from_ref; +use std::sync::Arc as StdArc; +use std::{cmp, iter, mem}; + +use app_units::Au; +use bitflags::bitflags; +use devtools_traits::NodeInfo; +use dom_struct::dom_struct; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; +use html5ever::{namespace_url, ns, Namespace, Prefix, QualName}; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use libc::{self, c_void, uintptr_t}; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use net_traits::image::base::{Image, ImageMetadata}; +use script_layout_interface::message::QueryMsg; +use script_layout_interface::{ + HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, SVGSVGData, + StyleAndOpaqueLayoutData, TrustedNodeAddress, +}; +use script_traits::{DocumentActivity, UntrustedNodeAddress}; +use selectors::matching::{ + matches_selector_list, MatchingContext, MatchingMode, NeedsSelectorFlags, +}; +use selectors::parser::SelectorList; +use servo_arc::Arc; +use servo_url::ServoUrl; +use smallvec::SmallVec; +use style::context::QuirksMode; +use style::dom::OpaqueNode; +use style::properties::ComputedValues; +use style::selector_parser::{SelectorImpl, SelectorParser}; +use style::stylesheets::Stylesheet; +use uuid::Uuid; + use crate::document_loader::DocumentLoader; use crate::dom::attr::Attr; use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut}; @@ -23,9 +63,10 @@ use crate::dom::bindings::codegen::InheritTypes::DocumentFragmentTypeId; use crate::dom::bindings::codegen::UnionTypes::NodeOrString; use crate::dom::bindings::conversions::{self, DerivedFrom}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; -use crate::dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId}; -use crate::dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId}; -use crate::dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId, TextTypeId}; +use crate::dom::bindings::inheritance::{ + Castable, CharacterDataTypeId, ElementTypeId, EventTargetTypeId, HTMLElementTypeId, NodeTypeId, + SVGElementTypeId, SVGGraphicsElementTypeId, TextTypeId, +}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, DomObjectWrap}; use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; @@ -63,46 +104,6 @@ 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 bitflags::bitflags; -use devtools_traits::NodeInfo; -use dom_struct::dom_struct; -use euclid::default::{Point2D, Rect, Size2D, Vector2D}; -use html5ever::{namespace_url, ns, Namespace, Prefix, QualName}; -use js::jsapi::JSObject; - -use js::rust::HandleObject; -use libc::{self, c_void, uintptr_t}; -use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use net_traits::image::base::{Image, ImageMetadata}; -use script_layout_interface::message::QueryMsg; -use script_layout_interface::{HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType}; -use script_layout_interface::{SVGSVGData, StyleAndOpaqueLayoutData, TrustedNodeAddress}; -use script_traits::DocumentActivity; -use script_traits::UntrustedNodeAddress; -use selectors::matching::{ - matches_selector_list, MatchingContext, MatchingMode, NeedsSelectorFlags, -}; -use selectors::parser::SelectorList; -use servo_arc::Arc; -use servo_url::ServoUrl; -use smallvec::SmallVec; -use std::borrow::Cow; -use std::cell::{Cell, UnsafeCell}; -use std::cmp; -use std::default::Default; -use std::iter; -use std::mem; -use std::ops::Range; -use std::slice::from_ref; -use std::sync::Arc as StdArc; -use style::context::QuirksMode; -use style::dom::OpaqueNode; -use style::properties::ComputedValues; -use style::selector_parser::{SelectorImpl, SelectorParser}; -use style::stylesheets::Stylesheet; -use uuid::Uuid; // // The basic Node structure diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index a141785a85d..1680a5dd3cd 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -2,19 +2,20 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; + use crate::dom::bindings::callback::ExceptionHandling::Rethrow; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; -use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; +use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::{NodeFilter, NodeFilterConstants}; use crate::dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutDom}; use crate::dom::document::Document; use crate::dom::node::Node; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::rc::Rc; #[dom_struct] pub struct NodeIterator { diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index b8286e5f0ea..64140f98222 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use dom_struct::dom_struct; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -12,9 +17,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmlformelement::HTMLFormElement; use crate::dom::node::{ChildrenMutation, Node}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_atoms::Atom; -use std::cell::Cell; #[derive(JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] diff --git a/components/script/dom/offlineaudiocompletionevent.rs b/components/script/dom/offlineaudiocompletionevent.rs index f5c39d5bfd4..2a3d9774b62 100644 --- a/components/script/dom/offlineaudiocompletionevent.rs +++ b/components/script/dom/offlineaudiocompletionevent.rs @@ -2,10 +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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::audiobuffer::AudioBuffer; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding::OfflineAudioCompletionEventInit; -use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding::OfflineAudioCompletionEventMethods; +use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding::{ + OfflineAudioCompletionEventInit, OfflineAudioCompletionEventMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; @@ -13,9 +18,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct OfflineAudioCompletionEvent { diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 29e3335eeae..994e1f79adb 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -2,13 +2,24 @@ * 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::Cell; +use std::rc::Rc; +use std::sync::{mpsc, Arc, Mutex}; +use std::thread::Builder; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use msg::constellation_msg::PipelineId; +use servo_media::audio::context::OfflineAudioContextOptions as ServoMediaOfflineAudioContextOptions; + use crate::dom::audiobuffer::{AudioBuffer, MAX_SAMPLE_RATE, MIN_SAMPLE_RATE}; use crate::dom::audionode::MAX_CHANNEL_COUNT; use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextBinding::BaseAudioContextMethods; -use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding::OfflineAudioContextMethods; -use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding::OfflineAudioContextOptions; +use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding::{ + OfflineAudioContextMethods, OfflineAudioContextOptions, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; @@ -21,15 +32,6 @@ use crate::dom::promise::Promise; use crate::dom::window::Window; use crate::realms::InRealm; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use msg::constellation_msg::PipelineId; -use servo_media::audio::context::OfflineAudioContextOptions as ServoMediaOfflineAudioContextOptions; -use std::cell::Cell; -use std::rc::Rc; -use std::sync::mpsc; -use std::sync::{Arc, Mutex}; -use std::thread::Builder; #[dom_struct] pub struct OfflineAudioContext { diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs index 0a03f91c4cc..9f1ce7333b6 100644 --- a/components/script/dom/offscreencanvas.rs +++ b/components/script/dom/offscreencanvas.rs @@ -2,13 +2,21 @@ * 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::Cell; + +use canvas_traits::canvas::{CanvasMsg, FromScriptMsg}; +use dom_struct::dom_struct; +use euclid::default::Size2D; +use ipc_channel::ipc::IpcSharedMemory; +use js::rust::{HandleObject, HandleValue}; +use profile_traits::ipc; + use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{ OffscreenCanvasMethods, OffscreenRenderingContext, }; use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::DomObject; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::eventtarget::EventTarget; @@ -16,13 +24,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D; use crate::script_runtime::JSContext; -use canvas_traits::canvas::{CanvasMsg, FromScriptMsg}; -use dom_struct::dom_struct; -use euclid::default::Size2D; -use ipc_channel::ipc::IpcSharedMemory; -use js::rust::{HandleObject, HandleValue}; -use profile_traits::ipc; -use std::cell::Cell; #[unrooted_must_root_lint::must_root] #[derive(Clone, JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 8c3deb001f4..fe178fb462c 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -2,18 +2,19 @@ * 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 dom_struct::dom_struct; +use euclid::default::Size2D; +use ipc_channel::ipc::IpcSender; + use crate::canvas_state::CanvasState; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasDirection; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextAlign; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasTextBaseline; +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{ + CanvasDirection, CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin, + CanvasTextAlign, CanvasTextBaseline, +}; use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; -use crate::dom::bindings::error::ErrorResult; -use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::error::{ErrorResult, Fallible}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -26,10 +27,6 @@ use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::imagedata::ImageData; use crate::dom::offscreencanvas::OffscreenCanvas; use crate::dom::textmetrics::TextMetrics; -use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg}; -use dom_struct::dom_struct; -use euclid::default::Size2D; -use ipc_channel::ipc::IpcSender; #[dom_struct] pub struct OffscreenCanvasRenderingContext2D { diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index 4f7c59a2e4d..15d6c875b1d 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -2,6 +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 std::cell::Cell; +use std::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; +use servo_media::audio::oscillator_node::{ + OscillatorNodeMessage, OscillatorNodeOptions as ServoMediaOscillatorOptions, + OscillatorType as ServoMediaOscillatorType, +}; +use servo_media::audio::param::ParamType; + use crate::dom::audioparam::AudioParam; use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; @@ -9,23 +21,13 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; -use crate::dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorNodeMethods; use crate::dom::bindings::codegen::Bindings::OscillatorNodeBinding::{ - OscillatorOptions, OscillatorType, + OscillatorNodeMethods, OscillatorOptions, OscillatorType, }; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; -use servo_media::audio::oscillator_node::OscillatorNodeMessage; -use servo_media::audio::oscillator_node::OscillatorNodeOptions as ServoMediaOscillatorOptions; -use servo_media::audio::oscillator_node::OscillatorType as ServoMediaOscillatorType; -use servo_media::audio::param::ParamType; -use std::cell::Cell; -use std::f32; #[dom_struct] pub struct OscillatorNode { diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs index c924c70c475..5eae74c24f6 100644 --- a/components/script/dom/pagetransitionevent.rs +++ b/components/script/dom/pagetransitionevent.rs @@ -2,6 +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 std::cell::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::PageTransitionEventBinding; use crate::dom::bindings::codegen::Bindings::PageTransitionEventBinding::PageTransitionEventMethods; @@ -12,10 +18,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; -use std::cell::Cell; // https://html.spec.whatwg.org/multipage/#pagetransitionevent #[dom_struct] diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index bdda5fc934e..316110b0fcd 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -2,15 +2,22 @@ * 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::CanvasRenderingContext2DBinding::CanvasFillRule; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods; +use std::cell::Cell; + +use canvas_traits::canvas::{CanvasImageData, CanvasMsg, FromLayoutMsg}; +use dom_struct::dom_struct; +use euclid::{Scale, Size2D}; +use ipc_channel::ipc::IpcSender; +use servo_url::ServoUrl; +use style_traits::{CSSPixel, DevicePixel}; + +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{ + CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin, + CanvasRenderingContext2DMethods, +}; use crate::dom::bindings::codegen::Bindings::PaintRenderingContext2DBinding::PaintRenderingContext2DMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; -use crate::dom::bindings::error::ErrorResult; -use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::error::{ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; @@ -21,16 +28,6 @@ use crate::dom::canvaspattern::CanvasPattern; use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D; use crate::dom::dommatrix::DOMMatrix; use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; -use canvas_traits::canvas::CanvasImageData; -use canvas_traits::canvas::CanvasMsg; -use canvas_traits::canvas::FromLayoutMsg; -use dom_struct::dom_struct; -use euclid::{Scale, Size2D}; -use ipc_channel::ipc::IpcSender; -use servo_url::ServoUrl; -use std::cell::Cell; -use style_traits::CSSPixel; -use style_traits::DevicePixel; #[dom_struct] pub struct PaintRenderingContext2D { diff --git a/components/script/dom/paintsize.rs b/components/script/dom/paintsize.rs index 5f6d0260096..900cfd8c6aa 100644 --- a/components/script/dom/paintsize.rs +++ b/components/script/dom/paintsize.rs @@ -2,15 +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 dom_struct::dom_struct; +use euclid::Size2D; +use style_traits::CSSPixel; + use crate::dom::bindings::codegen::Bindings::PaintSizeBinding::PaintSizeMethods; use crate::dom::bindings::num::Finite; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::Reflector; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; -use dom_struct::dom_struct; -use euclid::Size2D; -use style_traits::CSSPixel; #[dom_struct] pub struct PaintSize { diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index ab16d75a672..bfd67470b19 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -2,15 +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 std::cell::Cell; +use std::collections::hash_map::Entry; +use std::ptr::null_mut; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{unbounded, Sender}; +use dom_struct::dom_struct; +use euclid::{Scale, Size2D}; +use js::jsapi::{ + HandleValueArray, Heap, IsCallable, IsConstructor, JSAutoRealm, JSObject, + JS_ClearPendingException, JS_IsExceptionPending, NewArrayObject, +}; +use js::jsval::{JSVal, ObjectValue, UndefinedValue}; +use js::rust::wrappers::{Call, Construct1}; +use js::rust::{HandleValue, Runtime}; +use msg::constellation_msg::PipelineId; +use net_traits::image_cache::ImageCache; +use pixels::PixelFormat; +use profile_traits::ipc; +use script_traits::{DrawAPaintImageResult, PaintWorkletError, Painter}; +use servo_atoms::Atom; +use servo_config::pref; +use servo_url::ServoUrl; +use style_traits::{CSSPixel, DevicePixel, SpeculativePainter}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::callback::CallbackContainer; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PaintWorkletGlobalScopeBinding; use crate::dom::bindings::codegen::Bindings::PaintWorkletGlobalScopeBinding::PaintWorkletGlobalScopeMethods; use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction; -use crate::dom::bindings::conversions::get_property; -use crate::dom::bindings::conversions::get_property_jsval; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::conversions::{get_property, get_property_jsval}; +use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -20,52 +47,8 @@ use crate::dom::paintrenderingcontext2d::PaintRenderingContext2D; use crate::dom::paintsize::PaintSize; use crate::dom::stylepropertymapreadonly::StylePropertyMapReadOnly; use crate::dom::worklet::WorkletExecutor; -use crate::dom::workletglobalscope::WorkletGlobalScope; -use crate::dom::workletglobalscope::WorkletGlobalScopeInit; -use crate::dom::workletglobalscope::WorkletTask; +use crate::dom::workletglobalscope::{WorkletGlobalScope, WorkletGlobalScopeInit, WorkletTask}; use crate::script_runtime::JSContext; -use crossbeam_channel::{unbounded, Sender}; -use dom_struct::dom_struct; -use euclid::Scale; -use euclid::Size2D; -use js::jsapi::HandleValueArray; -use js::jsapi::Heap; -use js::jsapi::IsCallable; -use js::jsapi::IsConstructor; -use js::jsapi::JSAutoRealm; -use js::jsapi::JSObject; -use js::jsapi::JS_ClearPendingException; -use js::jsapi::JS_IsExceptionPending; -use js::jsapi::NewArrayObject; -use js::jsval::JSVal; -use js::jsval::ObjectValue; -use js::jsval::UndefinedValue; -use js::rust::wrappers::Call; -use js::rust::wrappers::Construct1; -use js::rust::HandleValue; -use js::rust::Runtime; -use msg::constellation_msg::PipelineId; -use net_traits::image_cache::ImageCache; -use pixels::PixelFormat; -use profile_traits::ipc; -use script_traits::Painter; -use script_traits::{DrawAPaintImageResult, PaintWorkletError}; -use servo_atoms::Atom; -use servo_config::pref; -use servo_url::ServoUrl; -use std::cell::Cell; -use std::collections::hash_map::Entry; -use std::ptr::null_mut; -use std::rc::Rc; -use std::sync::Arc; -use std::sync::Mutex; -use std::thread; -use std::time::Duration; -use style_traits::CSSPixel; -use style_traits::DevicePixel; -use style_traits::SpeculativePainter; - -use super::bindings::trace::HashMapTracedValues; /// <https://drafts.css-houdini.org/css-paint-api/#paintworkletglobalscope> #[dom_struct] diff --git a/components/script/dom/pannernode.rs b/components/script/dom/pannernode.rs index 48b572da260..3a617e50e70 100644 --- a/components/script/dom/pannernode.rs +++ b/components/script/dom/pannernode.rs @@ -2,6 +2,17 @@ * 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::Cell; +use std::f32; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; +use servo_media::audio::panner_node::{ + DistanceModel, PannerNodeMessage, PannerNodeOptions, PanningModel, +}; +use servo_media::audio::param::{ParamDir, ParamType}; + use crate::dom::audionode::AudioNode; use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; @@ -12,10 +23,7 @@ use crate::dom::bindings::codegen::Bindings::AudioParamBinding::{ AudioParamMethods, AutomationRate, }; use crate::dom::bindings::codegen::Bindings::PannerNodeBinding::{ - DistanceModelType, PanningModelType, -}; -use crate::dom::bindings::codegen::Bindings::PannerNodeBinding::{ - PannerNodeMethods, PannerOptions, + DistanceModelType, PannerNodeMethods, PannerOptions, PanningModelType, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -23,14 +31,6 @@ use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; -use servo_media::audio::panner_node::PannerNodeMessage; -use servo_media::audio::panner_node::{DistanceModel, PannerNodeOptions, PanningModel}; -use servo_media::audio::param::{ParamDir, ParamType}; -use std::cell::Cell; -use std::f32; #[dom_struct] pub struct PannerNode { diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index c707160f66a..178f30a2a89 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -2,10 +2,16 @@ * 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::Cell; +use std::cmp::Ordering; +use std::collections::VecDeque; + +use dom_struct::dom_struct; +use metrics::ToMs; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::{ - DOMHighResTimeStamp, PerformanceMethods, + DOMHighResTimeStamp, PerformanceEntryList as DOMPerformanceEntryList, PerformanceMethods, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -22,11 +28,6 @@ use crate::dom::performancenavigation::PerformanceNavigation; use crate::dom::performancenavigationtiming::PerformanceNavigationTiming; use crate::dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver; use crate::dom::window::Window; -use dom_struct::dom_struct; -use metrics::ToMs; -use std::cell::Cell; -use std::cmp::Ordering; -use std::collections::VecDeque; const INVALID_ENTRY_NAMES: &'static [&'static str] = &[ "navigationStart", diff --git a/components/script/dom/performanceentry.rs b/components/script/dom/performanceentry.rs index 8197deb8976..326cc7f4311 100644 --- a/components/script/dom/performanceentry.rs +++ b/components/script/dom/performanceentry.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; use crate::dom::bindings::codegen::Bindings::PerformanceEntryBinding::PerformanceEntryMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,7 +11,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::performance::reduce_timing_resolution; -use dom_struct::dom_struct; #[dom_struct] pub struct PerformanceEntry { diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs index f52250b815c..9c07111d115 100644 --- a/components/script/dom/performancenavigation.rs +++ b/components/script/dom/performancenavigation.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PerformanceNavigationBinding::{ PerformanceNavigationConstants, PerformanceNavigationMethods, }; @@ -9,7 +11,6 @@ use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::Windo use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; #[dom_struct] pub struct PerformanceNavigation { diff --git a/components/script/dom/performancenavigationtiming.rs b/components/script/dom/performancenavigationtiming.rs index 5562427f1c9..631a711bbb5 100644 --- a/components/script/dom/performancenavigationtiming.rs +++ b/components/script/dom/performancenavigationtiming.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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; -use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::NavigationType; -use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::PerformanceNavigationTimingMethods; +use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::{ + NavigationType, PerformanceNavigationTimingMethods, +}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::document::Document; use crate::dom::globalscope::GlobalScope; use crate::dom::performanceresourcetiming::{InitiatorType, PerformanceResourceTiming}; -use dom_struct::dom_struct; #[dom_struct] // https://w3c.github.io/navigation-timing/#dom-performancenavigationtiming diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index ca83fe7d361..067dd19a32a 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -2,12 +2,19 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsval::JSVal; +use js::rust::HandleObject; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; -use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverCallback; -use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverInit; -use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverMethods; +use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::{ + PerformanceObserverCallback, PerformanceObserverInit, PerformanceObserverMethods, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -18,11 +25,6 @@ use crate::dom::performance::PerformanceEntryList; use crate::dom::performanceentry::PerformanceEntry; use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsval::JSVal; -use js::rust::HandleObject; -use std::cell::Cell; -use std::rc::Rc; /// List of allowed performance entry types, in alphabetical order. pub const VALID_ENTRY_TYPES: &'static [&'static str] = &[ diff --git a/components/script/dom/performanceobserverentrylist.rs b/components/script/dom/performanceobserverentrylist.rs index f96e063153e..913592b5ed4 100644 --- a/components/script/dom/performanceobserverentrylist.rs +++ b/components/script/dom/performanceobserverentrylist.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding::PerformanceObserverEntryListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -10,7 +12,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::performance::PerformanceEntryList; use crate::dom::performanceentry::PerformanceEntry; -use dom_struct::dom_struct; #[dom_struct] pub struct PerformanceObserverEntryList { diff --git a/components/script/dom/performancepainttiming.rs b/components/script/dom/performancepainttiming.rs index 2dd3c27f1f1..a18a962b952 100644 --- a/components/script/dom/performancepainttiming.rs +++ b/components/script/dom/performancepainttiming.rs @@ -2,14 +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 dom_struct::dom_struct; +use metrics::ToMs; +use script_traits::ProgressiveWebMetricType; + use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::performanceentry::PerformanceEntry; -use dom_struct::dom_struct; -use metrics::ToMs; -use script_traits::ProgressiveWebMetricType; #[dom_struct] pub struct PerformancePaintTiming { diff --git a/components/script/dom/performanceresourcetiming.rs b/components/script/dom/performanceresourcetiming.rs index c98b5140f60..4146528f185 100644 --- a/components/script/dom/performanceresourcetiming.rs +++ b/components/script/dom/performanceresourcetiming.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use net_traits::ResourceFetchTiming; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; use crate::dom::bindings::codegen::Bindings::PerformanceResourceTimingBinding::PerformanceResourceTimingMethods; use crate::dom::bindings::reflector::reflect_dom_object; @@ -10,9 +14,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::performance::reduce_timing_resolution; use crate::dom::performanceentry::PerformanceEntry; -use dom_struct::dom_struct; -use net_traits::ResourceFetchTiming; -use servo_url::ServoUrl; // TODO UA may choose to limit how many resources are included as PerformanceResourceTiming objects // recommended minimum is 150, can be changed by setResourceTimingBufferSize in performance diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs index 2d7cd549cc2..adf071e5f38 100644 --- a/components/script/dom/permissions.rs +++ b/components/script/dom/permissions.rs @@ -2,10 +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 crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionDescriptor; -use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods; +use std::rc::Rc; + +use dom_struct::dom_struct; +use embedder_traits::{self, EmbedderMsg, PermissionPrompt, PermissionRequest}; +use ipc_channel::ipc; +use js::conversions::ConversionResult; +use js::jsapi::JSObject; +use js::jsval::{ObjectValue, UndefinedValue}; +use servo_config::pref; + use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{ - PermissionName, PermissionState, + PermissionDescriptor, PermissionName, PermissionState, PermissionStatusMethods, }; use crate::dom::bindings::codegen::Bindings::PermissionsBinding::PermissionsMethods; use crate::dom::bindings::error::Error; @@ -18,14 +26,6 @@ use crate::dom::permissionstatus::PermissionStatus; use crate::dom::promise::Promise; use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use embedder_traits::{self, EmbedderMsg, PermissionPrompt, PermissionRequest}; -use ipc_channel::ipc; -use js::conversions::ConversionResult; -use js::jsapi::JSObject; -use js::jsval::{ObjectValue, UndefinedValue}; -use servo_config::pref; -use std::rc::Rc; pub trait PermissionAlgorithm { type Descriptor; diff --git a/components/script/dom/permissionstatus.rs b/components/script/dom/permissionstatus.rs index 8f8b96f23de..e210b5087fc 100644 --- a/components/script/dom/permissionstatus.rs +++ b/components/script/dom/permissionstatus.rs @@ -2,18 +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 crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState; -use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods; +use std::cell::Cell; +use std::fmt::{self, Display, Formatter}; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{ - PermissionDescriptor, PermissionName, + PermissionDescriptor, PermissionName, PermissionState, PermissionStatusMethods, }; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::fmt::{self, Display, Formatter}; // https://w3c.github.io/permissions/#permissionstatus #[dom_struct] diff --git a/components/script/dom/plugin.rs b/components/script/dom/plugin.rs index 83c8e252556..4b23191ff22 100644 --- a/components/script/dom/plugin.rs +++ b/components/script/dom/plugin.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PluginBinding::PluginMethods; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::mimetype::MimeType; -use dom_struct::dom_struct; #[dom_struct] pub struct Plugin { diff --git a/components/script/dom/pluginarray.rs b/components/script/dom/pluginarray.rs index b063d55fb02..a0afeb1f102 100644 --- a/components/script/dom/pluginarray.rs +++ b/components/script/dom/pluginarray.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::PluginArrayBinding::PluginArrayMethods; 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 crate::dom::plugin::Plugin; -use dom_struct::dom_struct; #[dom_struct] pub struct PluginArray { diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 9d6b2c24c7f..ca6363cdec1 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::PopStateEventBinding; use crate::dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods; @@ -15,11 +21,6 @@ use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::window::Window; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; // https://html.spec.whatwg.org/multipage/#the-popstateevent-interface #[dom_struct] diff --git a/components/script/dom/processinginstruction.rs b/components/script/dom/processinginstruction.rs index 9edbf1a0a29..756335eb37c 100644 --- a/components/script/dom/processinginstruction.rs +++ b/components/script/dom/processinginstruction.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::characterdata::CharacterData; use crate::dom::document::Document; use crate::dom::node::Node; -use dom_struct::dom_struct; /// An HTML processing instruction node. #[dom_struct] diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index 93e687e53b3..edae658756b 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::ProgressEventBinding; use crate::dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods; @@ -12,9 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct ProgressEvent { diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 2ba29d20db6..ce84609f79a 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -11,6 +11,25 @@ //! native Promise values that refer to the same JS value yet are distinct native objects //! (ie. address equality for the native objects is meaningless). +use std::ptr; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::conversions::ToJSValConvertible; +use js::jsapi::{ + AddRawValueRoot, CallArgs, GetFunctionNativeReserved, Heap, JSAutoRealm, JSContext, JSObject, + JS_ClearPendingException, JS_GetFunctionObject, JS_NewFunction, NewFunctionWithReserved, + PromiseState, PromiseUserInputEventHandlingState, RemoveRawValueRoot, + SetFunctionNativeReserved, +}; +use js::jsval::{Int32Value, JSVal, ObjectValue, UndefinedValue}; +use js::rust::wrappers::{ + AddPromiseReactions, CallOriginalPromiseReject, CallOriginalPromiseResolve, GetPromiseState, + IsPromiseObject, NewPromiseObject, RejectPromise, ResolvePromise, + SetPromiseUserInputEventHandlingState, +}; +use js::rust::{HandleObject, HandleValue, MutableHandleObject, Runtime}; + use crate::dom::bindings::conversions::root_from_object; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; @@ -21,23 +40,6 @@ use crate::dom::promisenativehandler::PromiseNativeHandler; use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; use crate::script_thread::ScriptThread; -use dom_struct::dom_struct; -use js::conversions::ToJSValConvertible; -use js::jsapi::{AddRawValueRoot, CallArgs, GetFunctionNativeReserved}; -use js::jsapi::{Heap, JS_ClearPendingException}; -use js::jsapi::{JSAutoRealm, JSContext, JSObject, JS_GetFunctionObject}; -use js::jsapi::{JS_NewFunction, NewFunctionWithReserved}; -use js::jsapi::{PromiseState, PromiseUserInputEventHandlingState}; -use js::jsapi::{RemoveRawValueRoot, SetFunctionNativeReserved}; -use js::jsval::{Int32Value, JSVal, ObjectValue, UndefinedValue}; -use js::rust::wrappers::{ - AddPromiseReactions, CallOriginalPromiseReject, CallOriginalPromiseResolve, -}; -use js::rust::wrappers::{GetPromiseState, IsPromiseObject, NewPromiseObject, RejectPromise}; -use js::rust::wrappers::{ResolvePromise, SetPromiseUserInputEventHandlingState}; -use js::rust::{HandleObject, HandleValue, MutableHandleObject, Runtime}; -use std::ptr; -use std::rc::Rc; #[dom_struct] #[unrooted_must_root_lint::allow_unrooted_in_rc] diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index a5039d1f0b6..16dd520137d 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -2,16 +2,17 @@ * 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 dom_struct::dom_struct; +use js::jsapi::JSContext; +use js::rust::HandleValue; +use malloc_size_of::MallocSizeOf; + use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; use crate::dom::globalscope::GlobalScope; use crate::realms::InRealm; use crate::script_runtime::JSContext as SafeJSContext; -use dom_struct::dom_struct; -use js::jsapi::JSContext; -use js::rust::HandleValue; -use malloc_size_of::MallocSizeOf; pub trait Callback: JSTraceable + MallocSizeOf { fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm); diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs index 0ac02f8c439..334ed691b0a 100644 --- a/components/script/dom/promiserejectionevent.rs +++ b/components/script/dom/promiserejectionevent.rs @@ -2,6 +2,14 @@ * 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::rc::Rc; + +use dom_struct::dom_struct; +use js::jsapi::Heap; +use js::jsval::JSVal; +use js::rust::{HandleObject, HandleValue}; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding; use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods; @@ -15,12 +23,6 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::Heap; -use js::jsval::JSVal; -use js::rust::{HandleObject, HandleValue}; -use servo_atoms::Atom; -use std::rc::Rc; #[dom_struct] pub struct PromiseRejectionEvent { diff --git a/components/script/dom/radionodelist.rs b/components/script/dom/radionodelist.rs index 958652da9f7..9ada855850a 100644 --- a/components/script/dom/radionodelist.rs +++ b/components/script/dom/radionodelist.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods; @@ -14,8 +17,6 @@ use crate::dom::htmlinputelement::{HTMLInputElement, InputType}; use crate::dom::node::Node; use crate::dom::nodelist::{NodeList, NodeListType, RadioList, RadioListMode}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_atoms::Atom; #[dom_struct] pub struct RadioNodeList { diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index edcac751212..9e25ab29016 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -2,18 +2,24 @@ * 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::{Cell, UnsafeCell}; +use std::cmp::{Ord, Ordering, PartialEq, PartialOrd}; + +use deny_public_fields::DenyPublicFields; +use dom_struct::dom_struct; +use js::jsapi::JSTracer; +use js::rust::HandleObject; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; -use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeConstants; -use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; +use crate::dom::bindings::codegen::Bindings::NodeBinding::{NodeConstants, NodeMethods}; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; -use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeConstants; -use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeMethods; +use crate::dom::bindings::codegen::Bindings::RangeBinding::{RangeConstants, RangeMethods}; use crate::dom::bindings::codegen::Bindings::TextBinding::TextMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; +use crate::dom::bindings::inheritance::{Castable, CharacterDataTypeId, NodeTypeId}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutDom}; use crate::dom::bindings::str::DOMString; @@ -28,13 +34,6 @@ use crate::dom::node::{Node, ShadowIncluding, UnbindContext}; use crate::dom::selection::Selection; use crate::dom::text::Text; use crate::dom::window::Window; -use deny_public_fields::DenyPublicFields; -use dom_struct::dom_struct; -use js::jsapi::JSTracer; -use js::rust::HandleObject; -use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -use std::cell::{Cell, UnsafeCell}; -use std::cmp::{Ord, Ordering, PartialEq, PartialOrd}; #[dom_struct] pub struct Range { diff --git a/components/script/dom/raredata.rs b/components/script/dom/raredata.rs index 1a4916f1694..54f46250530 100644 --- a/components/script/dom/raredata.rs +++ b/components/script/dom/raredata.rs @@ -2,6 +2,11 @@ * 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::rc::Rc; + +use euclid::default::Rect; +use servo_atoms::Atom; + use crate::dom::bindings::root::Dom; use crate::dom::customelementregistry::{ CustomElementDefinition, CustomElementReaction, CustomElementState, @@ -10,9 +15,6 @@ use crate::dom::mutationobserver::RegisteredObserver; use crate::dom::node::UniqueId; use crate::dom::shadowroot::ShadowRoot; use crate::dom::window::LayoutValue; -use euclid::default::Rect; -use servo_atoms::Atom; -use std::rc::Rc; //XXX(ferjm) Ideally merge NodeRareData and ElementRareData so they share // storage. diff --git a/components/script/dom/readablestream.rs b/components/script/dom/readablestream.rs index 746f094045c..563ba5ce977 100644 --- a/components/script/dom/readablestream.rs +++ b/components/script/dom/readablestream.rs @@ -2,6 +2,28 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::cell::{Cell, RefCell}; +use std::os::raw::c_void; +use std::ptr::{self, NonNull}; +use std::rc::Rc; +use std::slice; + +use dom_struct::dom_struct; +use js::glue::{ + CreateReadableStreamUnderlyingSource, DeleteReadableStreamUnderlyingSource, + ReadableStreamUnderlyingSourceTraps, +}; +use js::jsapi::{ + AutoRequireNoGC, HandleObject, HandleValue, Heap, IsReadableStream, JSContext, JSObject, + JS_GetArrayBufferViewData, NewReadableExternalSourceStreamObject, ReadableStreamClose, + ReadableStreamDefaultReaderRead, ReadableStreamError, ReadableStreamGetReader, + ReadableStreamIsDisturbed, ReadableStreamIsLocked, ReadableStreamIsReadable, + ReadableStreamReaderMode, ReadableStreamReaderReleaseLock, ReadableStreamUnderlyingSource, + ReadableStreamUpdateDataAvailableFromSource, UnwrapReadableStream, +}; +use js::jsval::{JSVal, UndefinedValue}; +use js::rust::{HandleValue as SafeHandleValue, IntoHandle}; + use crate::dom::bindings::conversions::{ConversionBehavior, ConversionResult}; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -13,29 +35,6 @@ use crate::dom::promise::Promise; use crate::js::conversions::FromJSValConvertible; use crate::realms::{enter_realm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; -use dom_struct::dom_struct; -use js::glue::{ - CreateReadableStreamUnderlyingSource, DeleteReadableStreamUnderlyingSource, - ReadableStreamUnderlyingSourceTraps, -}; -use js::jsapi::{ - AutoRequireNoGC, IsReadableStream, JS_GetArrayBufferViewData, - NewReadableExternalSourceStreamObject, ReadableStreamClose, ReadableStreamDefaultReaderRead, - ReadableStreamError, ReadableStreamGetReader, ReadableStreamIsDisturbed, - ReadableStreamIsLocked, ReadableStreamIsReadable, ReadableStreamReaderMode, - ReadableStreamReaderReleaseLock, ReadableStreamUnderlyingSource, - ReadableStreamUpdateDataAvailableFromSource, UnwrapReadableStream, -}; -use js::jsapi::{HandleObject, HandleValue, Heap, JSContext, JSObject}; -use js::jsval::JSVal; -use js::jsval::UndefinedValue; -use js::rust::HandleValue as SafeHandleValue; -use js::rust::IntoHandle; -use std::cell::{Cell, RefCell}; -use std::os::raw::c_void; -use std::ptr::{self, NonNull}; -use std::rc::Rc; -use std::slice; static UNDERLYING_SOURCE_TRAPS: ReadableStreamUnderlyingSourceTraps = ReadableStreamUnderlyingSourceTraps { diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index a2699351674..dbbfad8af1a 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -2,19 +2,33 @@ * 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::body::Extractable; -use crate::body::{consume_body, BodyMixin, BodyType}; +use std::ptr::NonNull; +use std::rc::Rc; +use std::str::FromStr; + +use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; +use dom_struct::dom_struct; +use http::header::{HeaderName, HeaderValue}; +use http::method::InvalidMethod; +use http::Method as HttpMethod; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use net_traits::request::{ + CacheMode as NetTraitsRequestCache, CredentialsMode as NetTraitsRequestCredentials, + Destination as NetTraitsRequestDestination, Origin, RedirectMode as NetTraitsRequestRedirect, + Referrer as NetTraitsRequestReferrer, Request as NetTraitsRequest, + RequestMode as NetTraitsRequestMode, Window, +}; +use net_traits::ReferrerPolicy as MsgReferrerPolicy; +use servo_url::ServoUrl; + +use crate::body::{consume_body, BodyMixin, BodyType, Extractable}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; -use crate::dom::bindings::codegen::Bindings::RequestBinding::ReferrerPolicy; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCache; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestDestination; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestMethods; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestMode; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect; +use crate::dom::bindings::codegen::Bindings::RequestBinding::{ + ReferrerPolicy, RequestCache, RequestCredentials, RequestDestination, RequestInfo, RequestInit, + RequestMethods, RequestMode, RequestRedirect, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -25,26 +39,6 @@ use crate::dom::headers::{Guard, Headers}; use crate::dom::promise::Promise; use crate::dom::readablestream::ReadableStream; use crate::script_runtime::JSContext as SafeJSContext; -use cssparser::{_cssparser_internal_to_lowercase, match_ignore_ascii_case}; -use dom_struct::dom_struct; -use http::header::{HeaderName, HeaderValue}; -use http::method::InvalidMethod; -use http::Method as HttpMethod; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use net_traits::request::CacheMode as NetTraitsRequestCache; -use net_traits::request::CredentialsMode as NetTraitsRequestCredentials; -use net_traits::request::Destination as NetTraitsRequestDestination; -use net_traits::request::RedirectMode as NetTraitsRequestRedirect; -use net_traits::request::Referrer as NetTraitsRequestReferrer; -use net_traits::request::Request as NetTraitsRequest; -use net_traits::request::RequestMode as NetTraitsRequestMode; -use net_traits::request::{Origin, Window}; -use net_traits::ReferrerPolicy as MsgReferrerPolicy; -use servo_url::ServoUrl; -use std::ptr::NonNull; -use std::rc::Rc; -use std::str::FromStr; #[dom_struct] pub struct Request { diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index bf4d858c9c3..068729c9509 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -2,8 +2,20 @@ * 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::body::{consume_body, BodyMixin, BodyType}; -use crate::body::{Extractable, ExtractedBody}; +use std::ptr::NonNull; +use std::rc::Rc; +use std::str::FromStr; + +use dom_struct::dom_struct; +use http::header::HeaderMap as HyperHeaders; +use http::StatusCode; +use hyper_serde::Serde; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use servo_url::ServoUrl; +use url::Position; + +use crate::body::{consume_body, BodyMixin, BodyType, Extractable, ExtractedBody}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HeadersBinding::HeadersMethods; use crate::dom::bindings::codegen::Bindings::ResponseBinding; @@ -16,23 +28,10 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::{ByteString, USVString}; use crate::dom::globalscope::GlobalScope; -use crate::dom::headers::{is_obs_text, is_vchar}; -use crate::dom::headers::{Guard, Headers}; +use crate::dom::headers::{is_obs_text, is_vchar, Guard, Headers}; use crate::dom::promise::Promise; use crate::dom::readablestream::{ExternalUnderlyingSource, ReadableStream}; -use crate::script_runtime::JSContext as SafeJSContext; -use crate::script_runtime::StreamConsumer; -use dom_struct::dom_struct; -use http::header::HeaderMap as HyperHeaders; -use http::StatusCode; -use hyper_serde::Serde; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use servo_url::ServoUrl; -use std::ptr::NonNull; -use std::rc::Rc; -use std::str::FromStr; -use url::Position; +use crate::script_runtime::{JSContext as SafeJSContext, StreamConsumer}; #[dom_struct] pub struct Response { diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs index 6fefea60812..50be50a573b 100644 --- a/components/script/dom/rtcdatachannel.rs +++ b/components/script/dom/rtcdatachannel.rs @@ -2,10 +2,24 @@ * 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::Cell; +use std::ptr; + +use dom_struct::dom_struct; +use js::conversions::ToJSValConvertible; +use js::jsapi::{JSAutoRealm, JSObject}; +use js::jsval::UndefinedValue; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; +use script_traits::serializable::BlobImpl; +use servo_media::webrtc::{ + DataChannelId, DataChannelInit, DataChannelMessage, DataChannelState, WebRtcError, +}; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit; -use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelMethods; -use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelState; +use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::{ + RTCDataChannelInit, RTCDataChannelMethods, RTCDataChannelState, +}; use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::{RTCErrorDetailType, RTCErrorInit}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -20,18 +34,6 @@ use crate::dom::messageevent::MessageEvent; use crate::dom::rtcerror::RTCError; use crate::dom::rtcerrorevent::RTCErrorEvent; use crate::dom::rtcpeerconnection::RTCPeerConnection; -use dom_struct::dom_struct; -use js::conversions::ToJSValConvertible; -use js::jsapi::{JSAutoRealm, JSObject}; -use js::jsval::UndefinedValue; -use js::rust::CustomAutoRooterGuard; -use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; -use script_traits::serializable::BlobImpl; -use servo_media::webrtc::{ - DataChannelId, DataChannelInit, DataChannelMessage, DataChannelState, WebRtcError, -}; -use std::cell::Cell; -use std::ptr; #[dom_struct] pub struct RTCDataChannel { diff --git a/components/script/dom/rtcdatachannelevent.rs b/components/script/dom/rtcdatachannelevent.rs index 7008f4f630e..d104315d103 100644 --- a/components/script/dom/rtcdatachannelevent.rs +++ b/components/script/dom/rtcdatachannelevent.rs @@ -2,9 +2,14 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::RTCDataChannelEventBinding::RTCDataChannelEventInit; -use crate::dom::bindings::codegen::Bindings::RTCDataChannelEventBinding::RTCDataChannelEventMethods; +use crate::dom::bindings::codegen::Bindings::RTCDataChannelEventBinding::{ + RTCDataChannelEventInit, RTCDataChannelEventMethods, +}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -13,9 +18,6 @@ use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::rtcdatachannel::RTCDataChannel; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct RTCDataChannelEvent { diff --git a/components/script/dom/rtcerror.rs b/components/script/dom/rtcerror.rs index bb1bb9c1225..d4cb4d454af 100644 --- a/components/script/dom/rtcerror.rs +++ b/components/script/dom/rtcerror.rs @@ -2,17 +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 crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorDetailType; -use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorInit; -use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorMethods; +use dom_struct::dom_struct; +use js::rust::HandleObject; + +use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::{ + RTCErrorDetailType, RTCErrorInit, RTCErrorMethods, +}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::domexception::{DOMErrorName, DOMException}; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct RTCError { diff --git a/components/script/dom/rtcerrorevent.rs b/components/script/dom/rtcerrorevent.rs index de95817e759..0cf9a4ed196 100644 --- a/components/script/dom/rtcerrorevent.rs +++ b/components/script/dom/rtcerrorevent.rs @@ -2,9 +2,14 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::RTCErrorEventBinding::RTCErrorEventInit; -use crate::dom::bindings::codegen::Bindings::RTCErrorEventBinding::RTCErrorEventMethods; +use crate::dom::bindings::codegen::Bindings::RTCErrorEventBinding::{ + RTCErrorEventInit, RTCErrorEventMethods, +}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -13,9 +18,6 @@ use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::rtcerror::RTCError; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct RTCErrorEvent { diff --git a/components/script/dom/rtcicecandidate.rs b/components/script/dom/rtcicecandidate.rs index 0346224d19b..8d190662723 100644 --- a/components/script/dom/rtcicecandidate.rs +++ b/components/script/dom/rtcicecandidate.rs @@ -2,17 +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 crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit; -use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateMethods; +use dom_struct::dom_struct; +use js::rust::HandleObject; + +use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::{ + RTCIceCandidateInit, RTCIceCandidateMethods, +}; use crate::dom::bindings::error::{Error, Fallible}; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::{DomObject, Reflector}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct RTCIceCandidate { diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 93600b4f209..86d11209369 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -2,24 +2,37 @@ * 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::Cell; +use std::collections::HashMap; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::streams::registry::MediaStreamId; +use servo_media::streams::MediaStreamType; +use servo_media::webrtc::{ + BundlePolicy, DataChannelEvent, DataChannelId, DataChannelState, GatheringState, IceCandidate, + IceConnectionState, SdpType, SessionDescription, SignalingState, WebRtcController, + WebRtcSignaller, +}; +use servo_media::ServoMedia; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit; use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit; -use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCPeerConnectionMethods; use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::{ RTCAnswerOptions, RTCBundlePolicy, RTCConfiguration, RTCIceConnectionState, - RTCIceGatheringState, RTCOfferOptions, RTCRtpTransceiverInit, RTCSignalingState, + RTCIceGatheringState, RTCOfferOptions, RTCPeerConnectionMethods, RTCRtpTransceiverInit, + RTCSignalingState, }; use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::{ RTCSdpType, RTCSessionDescriptionInit, }; use crate::dom::bindings::codegen::UnionTypes::{MediaStreamTrackOrString, StringOrStringSequence}; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::DomObject; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::USVString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; @@ -40,20 +53,6 @@ use crate::realms::{enter_realm, InRealm}; use crate::task::TaskCanceller; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::streams::registry::MediaStreamId; -use servo_media::streams::MediaStreamType; -use servo_media::webrtc::{ - BundlePolicy, DataChannelEvent, DataChannelId, DataChannelState, GatheringState, IceCandidate, - IceConnectionState, SdpType, SessionDescription, SignalingState, WebRtcController, - WebRtcSignaller, -}; -use servo_media::ServoMedia; - -use std::cell::Cell; -use std::collections::HashMap; -use std::rc::Rc; #[dom_struct] pub struct RTCPeerConnection { diff --git a/components/script/dom/rtcpeerconnectioniceevent.rs b/components/script/dom/rtcpeerconnectioniceevent.rs index e0cae1d6bb6..2a77fd70d84 100644 --- a/components/script/dom/rtcpeerconnectioniceevent.rs +++ b/components/script/dom/rtcpeerconnectioniceevent.rs @@ -2,22 +2,23 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding::RTCPeerConnectionIceEventInit; -use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding::RTCPeerConnectionIceEventMethods; +use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding::{ + RTCPeerConnectionIceEventInit, RTCPeerConnectionIceEventMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::DomObject; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::rtcicecandidate::RTCIceCandidate; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct RTCPeerConnectionIceEvent { diff --git a/components/script/dom/rtcrtpsender.rs b/components/script/dom/rtcrtpsender.rs index 10be5a6d79a..0526ec06303 100644 --- a/components/script/dom/rtcrtpsender.rs +++ b/components/script/dom/rtcrtpsender.rs @@ -2,17 +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 crate::dom::bindings::codegen::Bindings::RTCRtpSenderBinding::RTCRtpSenderMethods; +use std::rc::Rc; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::RTCRtpSenderBinding::{ - RTCRtcpParameters, RTCRtpParameters, RTCRtpSendParameters, + RTCRtcpParameters, RTCRtpParameters, RTCRtpSendParameters, RTCRtpSenderMethods, }; 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 crate::dom::promise::Promise; -use dom_struct::dom_struct; -use std::rc::Rc; #[dom_struct] pub struct RTCRtpSender { diff --git a/components/script/dom/rtcrtptransceiver.rs b/components/script/dom/rtcrtptransceiver.rs index 5c041bb1ae6..ebf7cac6375 100644 --- a/components/script/dom/rtcrtptransceiver.rs +++ b/components/script/dom/rtcrtptransceiver.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::RTCRtpTransceiverBinding::{ RTCRtpTransceiverDirection, RTCRtpTransceiverMethods, }; @@ -9,8 +13,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::rtcrtpsender::RTCRtpSender; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct RTCRtpTransceiver { diff --git a/components/script/dom/rtcsessiondescription.rs b/components/script/dom/rtcsessiondescription.rs index 07feb795d7f..46de2c33873 100644 --- a/components/script/dom/rtcsessiondescription.rs +++ b/components/script/dom/rtcsessiondescription.rs @@ -2,19 +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 crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionMethods; +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::{ - RTCSdpType, RTCSessionDescriptionInit, + RTCSdpType, RTCSessionDescriptionInit, RTCSessionDescriptionMethods, }; use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::{DomObject, Reflector}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct RTCSessionDescription { diff --git a/components/script/dom/rtctrackevent.rs b/components/script/dom/rtctrackevent.rs index 74eebf49e97..55523607faa 100644 --- a/components/script/dom/rtctrackevent.rs +++ b/components/script/dom/rtctrackevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::RTCTrackEventBinding::{self, RTCTrackEventMethods}; use crate::dom::bindings::error::Fallible; @@ -13,9 +17,6 @@ use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::mediastreamtrack::MediaStreamTrack; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct RTCTrackEvent { diff --git a/components/script/dom/screen.rs b/components/script/dom/screen.rs index 18e137346e5..8ee40adff25 100644 --- a/components/script/dom/screen.rs +++ b/components/script/dom/screen.rs @@ -2,14 +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 crate::dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::num::Finite; -use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::globalscope::GlobalScope; -use crate::dom::window::Window; use dom_struct::dom_struct; use euclid::Size2D; use profile_traits::ipc; @@ -17,6 +9,14 @@ use script_traits::ScriptMsg; use style_traits::CSSPixel; use webrender_api::units::DeviceIntSize; +use crate::dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::num::Finite; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::globalscope::GlobalScope; +use crate::dom::window::Window; + #[dom_struct] pub struct Screen { reflector_: Reflector, diff --git a/components/script/dom/selection.rs b/components/script/dom/selection.rs index 75348556ba0..ade8b3eff9f 100644 --- a/components/script/dom/selection.rs +++ b/components/script/dom/selection.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeMethods; use crate::dom::bindings::codegen::Bindings::SelectionBinding::SelectionMethods; @@ -16,8 +20,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::node::{window_from_node, Node}; use crate::dom::range::Range; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use std::cell::Cell; #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] enum Direction { diff --git a/components/script/dom/serviceworker.rs b/components/script/dom/serviceworker.rs index b01fc2a1d97..021192a95fa 100644 --- a/components/script/dom/serviceworker.rs +++ b/components/script/dom/serviceworker.rs @@ -2,6 +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::Cell; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject}; +use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; +use msg::constellation_msg::ServiceWorkerId; +use script_traits::{DOMMessage, ScriptMsg}; +use servo_url::ServoUrl; + use crate::dom::abstractworker::SimpleWorkerErrorHandler; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions; @@ -20,13 +29,6 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; use crate::task::TaskOnce; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue}; -use msg::constellation_msg::ServiceWorkerId; -use script_traits::{DOMMessage, ScriptMsg}; -use servo_url::ServoUrl; -use std::cell::Cell; pub type TrustedServiceWorkerAddress = Trusted<ServiceWorker>; diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index b02b72e2c5b..f1a76b58493 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -2,8 +2,17 @@ * 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::ServiceWorkerContainerBinding::RegistrationOptions; -use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::ServiceWorkerContainerMethods; +use std::default::Default; +use std::rc::Rc; + +use dom_struct::dom_struct; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use script_traits::{Job, JobError, JobResult, JobResultValue, JobType, ScriptMsg}; + +use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ + RegistrationOptions, ServiceWorkerContainerMethods, +}; use crate::dom::bindings::error::Error; use crate::dom::bindings::refcounted::TrustedPromise; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -15,18 +24,10 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::dom::serviceworker::ServiceWorker; use crate::dom::serviceworkerregistration::ServiceWorkerRegistration; -use crate::realms::enter_realm; -use crate::realms::InRealm; +use crate::realms::{enter_realm, InRealm}; use crate::task::TaskCanceller; use crate::task_source::dom_manipulation::DOMManipulationTaskSource; -use crate::task_source::TaskSource; -use crate::task_source::TaskSourceName; -use dom_struct::dom_struct; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use script_traits::{Job, JobError, JobResult, JobResultValue, JobType, ScriptMsg}; -use std::default::Default; -use std::rc::Rc; +use crate::task_source::{TaskSource, TaskSourceName}; #[dom_struct] pub struct ServiceWorkerContainer { diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index f5221e04be3..cbbb63ea998 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -2,6 +2,28 @@ * 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::sync::atomic::AtomicBool; +use std::sync::Arc; +use std::thread::{self, JoinHandle}; +use std::time::{Duration, Instant}; + +use crossbeam_channel::{after, unbounded, Receiver, Sender}; +use devtools_traits::DevtoolScriptControlMsg; +use dom_struct::dom_struct; +use ipc_channel::ipc::{IpcReceiver, IpcSender}; +use ipc_channel::router::ROUTER; +use js::jsapi::{JSContext, JS_AddInterruptCallback}; +use js::jsval::UndefinedValue; +use msg::constellation_msg::PipelineId; +use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder}; +use net_traits::{CustomResponseMediator, IpcSend}; +use parking_lot::Mutex; +use script_traits::{ScopeThings, ServiceWorkerMsg, WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; +use servo_config::pref; +use servo_rand::random; +use servo_url::ServoUrl; +use style::thread_state::{self, ThreadState}; + use crate::devtools; use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods}; @@ -29,26 +51,6 @@ use crate::script_runtime::{ }; use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; use crate::task_source::TaskSourceName; -use crossbeam_channel::{after, unbounded, Receiver, Sender}; -use devtools_traits::DevtoolScriptControlMsg; -use dom_struct::dom_struct; -use ipc_channel::ipc::{IpcReceiver, IpcSender}; -use ipc_channel::router::ROUTER; -use js::jsapi::{JSContext, JS_AddInterruptCallback}; -use js::jsval::UndefinedValue; -use msg::constellation_msg::PipelineId; -use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder}; -use net_traits::{CustomResponseMediator, IpcSend}; -use parking_lot::Mutex; -use script_traits::{ScopeThings, ServiceWorkerMsg, WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; -use servo_config::pref; -use servo_rand::random; -use servo_url::ServoUrl; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; -use std::thread::{self, JoinHandle}; -use std::time::{Duration, Instant}; -use style::thread_state::{self, ThreadState}; /// Messages used to control service worker event loop pub enum ServiceWorkerScriptMsg { diff --git a/components/script/dom/serviceworkerregistration.rs b/components/script/dom/serviceworkerregistration.rs index d9438880f7b..6134979343b 100644 --- a/components/script/dom/serviceworkerregistration.rs +++ b/components/script/dom/serviceworkerregistration.rs @@ -2,9 +2,19 @@ * 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::Cell; + +use devtools_traits::WorkerId; +use dom_struct::dom_struct; +use msg::constellation_msg::ServiceWorkerRegistrationId; +use script_traits::{ScopeThings, WorkerScriptLoadOrigin}; +use servo_url::ServoUrl; +use uuid::Uuid; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::ServiceWorkerRegistrationMethods; -use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::ServiceWorkerUpdateViaCache; +use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::{ + ServiceWorkerRegistrationMethods, ServiceWorkerUpdateViaCache, +}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::{ByteString, USVString}; @@ -13,13 +23,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::navigationpreloadmanager::NavigationPreloadManager; use crate::dom::serviceworker::ServiceWorker; use crate::dom::workerglobalscope::prepare_workerscope_init; -use devtools_traits::WorkerId; -use dom_struct::dom_struct; -use msg::constellation_msg::ServiceWorkerRegistrationId; -use script_traits::{ScopeThings, WorkerScriptLoadOrigin}; -use servo_url::ServoUrl; -use std::cell::Cell; -use uuid::Uuid; #[dom_struct] pub struct ServiceWorkerRegistration { diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index 5b063dcc78a..a06749a7fd0 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -4,6 +4,27 @@ #![allow(unrooted_must_root)] +use std::borrow::Cow; +use std::cell::Cell; +use std::collections::vec_deque::VecDeque; +use std::collections::HashMap; +use std::thread; + +use crossbeam_channel::{unbounded, Receiver, Sender}; +use html5ever::buffer_queue::BufferQueue; +use html5ever::tendril::fmt::UTF8; +use html5ever::tendril::{SendTendril, StrTendril, Tendril}; +use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; +use html5ever::tree_builder::{ + ElementFlags, NextParserState, NodeOrText as HtmlNodeOrText, QuirksMode, TreeBuilder, + TreeBuilderOpts, TreeSink, +}; +use html5ever::{ + local_name, namespace_url, ns, Attribute as HtmlAttribute, ExpandedName, QualName, +}; +use servo_url::ServoUrl; +use style::context::QuirksMode as ServoQuirksMode; + use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -20,25 +41,6 @@ use crate::dom::node::Node; use crate::dom::processinginstruction::ProcessingInstruction; use crate::dom::servoparser::{create_element_for_token, ElementAttribute, ParsingAlgorithm}; use crate::dom::virtualmethods::vtable_for; -use crossbeam_channel::{unbounded, Receiver, Sender}; -use html5ever::buffer_queue::BufferQueue; -use html5ever::tendril::fmt::UTF8; -use html5ever::tendril::{SendTendril, StrTendril, Tendril}; -use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; -use html5ever::tree_builder::{ - ElementFlags, NextParserState, NodeOrText as HtmlNodeOrText, QuirksMode, TreeSink, -}; -use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts}; -use html5ever::{ - local_name, namespace_url, ns, Attribute as HtmlAttribute, ExpandedName, QualName, -}; -use servo_url::ServoUrl; -use std::borrow::Cow; -use std::cell::Cell; -use std::collections::vec_deque::VecDeque; -use std::collections::HashMap; -use std::thread; -use style::context::QuirksMode as ServoQuirksMode; type ParseNodeId = usize; diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index 3d1daad5424..cb98ca785a0 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -4,6 +4,17 @@ #![allow(unrooted_must_root)] +use std::io; + +use html5ever::buffer_queue::BufferQueue; +use html5ever::serialize::TraversalScope::IncludeNode; +use html5ever::serialize::{AttrRef, Serialize, Serializer, TraversalScope}; +use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; +use html5ever::tree_builder::{Tracer as HtmlTracer, TreeBuilder, TreeBuilderOpts}; +use html5ever::QualName; +use js::jsapi::JSTracer; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::inheritance::{Castable, CharacterDataTypeId, NodeTypeId}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -18,16 +29,6 @@ use crate::dom::htmltemplateelement::HTMLTemplateElement; use crate::dom::node::Node; use crate::dom::processinginstruction::ProcessingInstruction; use crate::dom::servoparser::{ParsingAlgorithm, Sink}; -use html5ever::buffer_queue::BufferQueue; -use html5ever::serialize::TraversalScope; -use html5ever::serialize::TraversalScope::IncludeNode; -use html5ever::serialize::{AttrRef, Serialize, Serializer}; -use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; -use html5ever::tree_builder::{Tracer as HtmlTracer, TreeBuilder, TreeBuilderOpts}; -use html5ever::QualName; -use js::jsapi::JSTracer; -use servo_url::ServoUrl; -use std::io; #[derive(JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index db5aed41962..ce99735e8b3 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -2,6 +2,38 @@ * 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::borrow::Cow; +use std::cell::Cell; +use std::mem; + +use base64::engine::general_purpose; +use base64::Engine as _; +use content_security_policy::{self as csp, CspList}; +use dom_struct::dom_struct; +use embedder_traits::resources::{self, Resource}; +use encoding_rs::Encoding; +use html5ever::buffer_queue::BufferQueue; +use html5ever::tendril::fmt::UTF8; +use html5ever::tendril::{ByteTendril, StrTendril, TendrilSink}; +use html5ever::tokenizer::TokenizerResult; +use html5ever::tree_builder::{ElementFlags, NextParserState, NodeOrText, QuirksMode, TreeSink}; +use html5ever::{local_name, namespace_url, ns, Attribute, ExpandedName, LocalName, QualName}; +use hyper_serde::Serde; +use mime::{self, Mime}; +use msg::constellation_msg::PipelineId; +use net_traits::{ + FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming, + ResourceTimingType, +}; +use profile_traits::time::{ + profile, ProfilerCategory, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType, +}; +use script_traits::DocumentActivity; +use servo_config::pref; +use servo_url::ServoUrl; +use style::context::QuirksMode as ServoQuirksMode; +use tendril::stream::LossyDecoder; + use crate::document_loader::{DocumentLoader, LoadType}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ @@ -36,33 +68,6 @@ use crate::dom::virtualmethods::vtable_for; use crate::network_listener::PreInvoke; use crate::realms::enter_realm; use crate::script_thread::ScriptThread; -use base64::{engine::general_purpose, Engine as _}; -use content_security_policy::{self as csp, CspList}; -use dom_struct::dom_struct; -use embedder_traits::resources::{self, Resource}; -use encoding_rs::Encoding; -use html5ever::buffer_queue::BufferQueue; -use html5ever::tendril::fmt::UTF8; -use html5ever::tendril::{ByteTendril, StrTendril, TendrilSink}; -use html5ever::tokenizer::TokenizerResult; -use html5ever::tree_builder::{ElementFlags, NextParserState, NodeOrText, QuirksMode, TreeSink}; -use html5ever::{local_name, namespace_url, ns, Attribute, ExpandedName, LocalName, QualName}; -use hyper_serde::Serde; -use mime::{self, Mime}; -use msg::constellation_msg::PipelineId; -use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use profile_traits::time::{ - profile, ProfilerCategory, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType, -}; -use script_traits::DocumentActivity; -use servo_config::pref; -use servo_url::ServoUrl; -use std::borrow::Cow; -use std::cell::Cell; -use std::mem; -use style::context::QuirksMode as ServoQuirksMode; -use tendril::stream::LossyDecoder; mod async_html; mod html; diff --git a/components/script/dom/servoparser/prefetch.rs b/components/script/dom/servoparser/prefetch.rs index 73db542984c..65c103e66df 100644 --- a/components/script/dom/servoparser/prefetch.rs +++ b/components/script/dom/servoparser/prefetch.rs @@ -2,6 +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 html5ever::buffer_queue::BufferQueue; +use html5ever::tokenizer::states::RawKind; +use html5ever::tokenizer::{ + Tag, TagKind, Token, TokenSink, TokenSinkResult, Tokenizer as HtmlTokenizer, TokenizerResult, +}; +use html5ever::{local_name, Attribute, LocalName}; +use js::jsapi::JSTracer; +use msg::constellation_msg::PipelineId; +use net_traits::request::{CorsSettings, CredentialsMode, ParserMetadata, Referrer}; +use net_traits::{CoreResourceMsg, FetchChannels, IpcSend, ReferrerPolicy, ResourceThreads}; +use servo_url::{ImmutableOrigin, ServoUrl}; + use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::trace::{CustomTraceable, JSTraceable}; use crate::dom::document::{determine_policy_for_token, Document}; @@ -9,30 +21,6 @@ use crate::dom::htmlimageelement::{image_fetch_request, FromPictureOrSrcSet}; use crate::dom::htmlscriptelement::script_fetch_request; use crate::script_module::ScriptFetchOptions; use crate::stylesheet_loader::stylesheet_fetch_request; -use html5ever::buffer_queue::BufferQueue; -use html5ever::tokenizer::states::RawKind; -use html5ever::tokenizer::Tag; -use html5ever::tokenizer::TagKind; -use html5ever::tokenizer::Token; -use html5ever::tokenizer::TokenSink; -use html5ever::tokenizer::TokenSinkResult; -use html5ever::tokenizer::Tokenizer as HtmlTokenizer; -use html5ever::tokenizer::TokenizerResult; -use html5ever::Attribute; -use html5ever::{local_name, LocalName}; -use js::jsapi::JSTracer; -use msg::constellation_msg::PipelineId; -use net_traits::request::CorsSettings; -use net_traits::request::CredentialsMode; -use net_traits::request::ParserMetadata; -use net_traits::request::Referrer; -use net_traits::CoreResourceMsg; -use net_traits::FetchChannels; -use net_traits::IpcSend; -use net_traits::ReferrerPolicy; -use net_traits::ResourceThreads; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; #[derive(JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index 6ee1b464a6d..583c90fba61 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -4,12 +4,6 @@ #![allow(unrooted_must_root)] -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::trace::{CustomTraceable, JSTraceable}; -use crate::dom::document::Document; -use crate::dom::htmlscriptelement::HTMLScriptElement; -use crate::dom::node::Node; -use crate::dom::servoparser::{ParsingAlgorithm, Sink}; use html5ever::tokenizer::TokenizerResult; use js::jsapi::JSTracer; use servo_url::ServoUrl; @@ -17,6 +11,13 @@ use xml5ever::buffer_queue::BufferQueue; use xml5ever::tokenizer::XmlTokenizer; use xml5ever::tree_builder::{Tracer as XmlTracer, XmlTreeBuilder}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::trace::{CustomTraceable, JSTraceable}; +use crate::dom::document::Document; +use crate::dom::htmlscriptelement::HTMLScriptElement; +use crate::dom::node::Node; +use crate::dom::servoparser::{ParsingAlgorithm, Sink}; + #[derive(JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] pub struct Tokenizer { diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 24441391f94..084a83650a4 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -2,6 +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 dom_struct::dom_struct; +use servo_arc::Arc; +use servo_atoms::Atom; +use style::author_styles::AuthorStyles; +use style::dom::TElement; +use style::shared_lock::SharedRwLockReadGuard; +use style::stylesheets::Stylesheet; +use style::stylist::{CascadeData, Stylist}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootBinding::ShadowRootMethods; use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootMode; @@ -18,14 +27,6 @@ use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding, UnbindConte use crate::dom::stylesheetlist::{StyleSheetList, StyleSheetListOwner}; use crate::dom::window::Window; use crate::stylesheet_set::StylesheetSetRef; -use dom_struct::dom_struct; -use servo_arc::Arc; -use servo_atoms::Atom; -use style::author_styles::AuthorStyles; -use style::dom::TElement; -use style::shared_lock::SharedRwLockReadGuard; -use style::stylesheets::Stylesheet; -use style::stylist::{CascadeData, Stylist}; /// Whether a shadow root hosts an User Agent widget. #[derive(JSTraceable, MallocSizeOf, PartialEq)] diff --git a/components/script/dom/stereopannernode.rs b/components/script/dom/stereopannernode.rs index 96d5e8014bc..e8cd8701572 100644 --- a/components/script/dom/stereopannernode.rs +++ b/components/script/dom/stereopannernode.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_media::audio::node::AudioNodeInit; +use servo_media::audio::param::ParamType; +use servo_media::audio::stereo_panner::StereoPannerOptions as ServoMediaStereoPannerOptions; + use crate::dom::audioparam::AudioParam; use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; @@ -9,17 +15,13 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; -use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::StereoPannerNodeMethods; -use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::StereoPannerOptions; +use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::{ + StereoPannerNodeMethods, StereoPannerOptions, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_media::audio::node::AudioNodeInit; -use servo_media::audio::param::ParamType; -use servo_media::audio::stereo_panner::StereoPannerOptions as ServoMediaStereoPannerOptions; #[dom_struct] pub struct StereoPannerNode { diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index 10746abe10b..7e02c2f1ca4 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -2,6 +2,14 @@ * 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 dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use net_traits::storage_thread::{StorageThreadMsg, StorageType}; +use net_traits::IpcSend; +use profile_traits::ipc; +use script_traits::ScriptMsg; +use servo_url::ServoUrl; + use crate::dom::bindings::codegen::Bindings::StorageBinding::StorageMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::inheritance::Castable; @@ -13,13 +21,6 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::storageevent::StorageEvent; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; -use net_traits::storage_thread::{StorageThreadMsg, StorageType}; -use net_traits::IpcSend; -use profile_traits::ipc; -use script_traits::ScriptMsg; -use servo_url::ServoUrl; #[dom_struct] pub struct Storage { diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index e9bc8e73063..eb17166d395 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::StorageEventBinding; @@ -14,9 +18,6 @@ use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::storage::Storage; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct StorageEvent { diff --git a/components/script/dom/stylepropertymapreadonly.rs b/components/script/dom/stylepropertymapreadonly.rs index f64c9cfc54a..d2c84b1fecb 100644 --- a/components/script/dom/stylepropertymapreadonly.rs +++ b/components/script/dom/stylepropertymapreadonly.rs @@ -2,20 +2,20 @@ * 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::StylePropertyMapReadOnlyBinding::StylePropertyMapReadOnlyMethods; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::Reflector; -use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::str::DOMString; -use crate::dom::cssstylevalue::CSSStyleValue; -use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use servo_atoms::Atom; use std::cmp::Ordering; use std::iter::Iterator; + +use dom_struct::dom_struct; +use servo_atoms::Atom; use style::custom_properties; use super::bindings::trace::HashMapTracedValues; +use crate::dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::StylePropertyMapReadOnlyMethods; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::str::DOMString; +use crate::dom::cssstylevalue::CSSStyleValue; +use crate::dom::globalscope::GlobalScope; #[dom_struct] pub struct StylePropertyMapReadOnly { diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs index c03776dc7f6..d48356e4b92 100644 --- a/components/script/dom/stylesheet.rs +++ b/components/script/dom/stylesheet.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::Reflector; @@ -10,7 +12,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::element::Element; use crate::dom::medialist::MediaList; -use dom_struct::dom_struct; #[dom_struct] pub struct StyleSheet { diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs index 7bd115f5084..4d561aa56fd 100644 --- a/components/script/dom/stylesheetlist.rs +++ b/components/script/dom/stylesheetlist.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use servo_arc::Arc; +use style::stylesheets::Stylesheet; + use crate::dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -11,9 +15,6 @@ use crate::dom::element::Element; use crate::dom::shadowroot::ShadowRoot; use crate::dom::stylesheet::StyleSheet; use crate::dom::window::Window; -use dom_struct::dom_struct; -use servo_arc::Arc; -use style::stylesheets::Stylesheet; #[unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/submitevent.rs b/components/script/dom/submitevent.rs index 01db87705b3..524b8a883ba 100644 --- a/components/script/dom/submitevent.rs +++ b/components/script/dom/submitevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::SubmitEventBinding; use crate::dom::bindings::codegen::Bindings::SubmitEventBinding::SubmitEventMethods; @@ -13,9 +17,6 @@ use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlelement::HTMLElement; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] #[allow(non_snake_case)] diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs index dc1620f2598..c4975d1178c 100644 --- a/components/script/dom/svgelement.rs +++ b/components/script/dom/svgelement.rs @@ -2,19 +2,19 @@ * 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 dom_struct::dom_struct; +use html5ever::{namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use style::element_state::ElementState; + use crate::dom::bindings::codegen::Bindings::SVGElementBinding::SVGElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; use crate::dom::document::Document; use crate::dom::element::Element; -use crate::dom::node::window_from_node; -use crate::dom::node::Node; +use crate::dom::node::{window_from_node, Node}; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use style::element_state::ElementState; #[dom_struct] pub struct SVGElement { diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs index f3322f98888..4ba18af76aa 100644 --- a/components/script/dom/svggraphicselement.rs +++ b/components/script/dom/svggraphicselement.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use html5ever::{LocalName, Prefix}; +use style::element_state::ElementState; + use crate::dom::bindings::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::SVGElement; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; -use style::element_state::ElementState; #[dom_struct] pub struct SVGGraphicsElement { diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index f903c3b2735..4240b3aa657 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -2,6 +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 dom_struct::dom_struct; +use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; +use js::rust::HandleObject; +use script_layout_interface::SVGSVGData; +use style::attr::AttrValue; + use crate::dom::attr::Attr; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; @@ -11,11 +17,6 @@ use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers}; use crate::dom::node::Node; use crate::dom::svggraphicselement::SVGGraphicsElement; use crate::dom::virtualmethods::VirtualMethods; -use dom_struct::dom_struct; -use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; -use js::rust::HandleObject; -use script_layout_interface::SVGSVGData; -use style::attr::AttrValue; const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 369b9a8a058..071bccdec75 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -4,37 +4,35 @@ // check-tidy: no specs after this line +use std::borrow::ToOwned; +use std::ptr; +use std::ptr::NonNull; +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSObject, JS_NewPlainObject, JS_NewUint8ClampedArray}; +use js::jsval::{JSVal, NullValue}; +use js::rust::{CustomAutoRooterGuard, HandleObject, HandleValue}; +use js::typedarray; +use script_traits::serializable::BlobImpl; +use script_traits::MsDuration; +use servo_config::prefs; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; -use crate::dom::bindings::codegen::Bindings::TestBindingBinding::SimpleCallback; -use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestDictionaryParent; -use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestDictionaryWithParent; use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{ - TestBindingMethods, TestDictionary, -}; -use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{ - TestDictionaryDefaults, TestEnum, TestURLLike, + SimpleCallback, TestBindingMethods, TestDictionary, TestDictionaryDefaults, + TestDictionaryParent, TestDictionaryWithParent, TestEnum, TestURLLike, }; use crate::dom::bindings::codegen::UnionTypes; use crate::dom::bindings::codegen::UnionTypes::{ - BlobOrBlobSequence, BlobOrBoolean, LongOrLongSequenceSequence, -}; -use crate::dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString}; -use crate::dom::bindings::codegen::UnionTypes::{ - ByteStringOrLong, ByteStringSequenceOrLongOrString, -}; -use crate::dom::bindings::codegen::UnionTypes::{ByteStringSequenceOrLong, DocumentOrTestTypedef}; -use crate::dom::bindings::codegen::UnionTypes::{ - EventOrUSVString, HTMLElementOrLong, LongSequenceOrTestTypedef, -}; -use crate::dom::bindings::codegen::UnionTypes::{ - HTMLElementOrUnsignedLongOrStringOrBoolean, LongSequenceOrBoolean, -}; -use crate::dom::bindings::codegen::UnionTypes::{StringOrBoolean, UnsignedLongOrBoolean}; -use crate::dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence}; -use crate::dom::bindings::codegen::UnionTypes::{ - StringOrUnsignedLong, StringSequenceOrUnsignedLong, + BlobOrBlobSequence, BlobOrBoolean, BlobOrString, BlobOrUnsignedLong, ByteStringOrLong, + ByteStringSequenceOrLong, ByteStringSequenceOrLongOrString, DocumentOrTestTypedef, + EventOrString, EventOrUSVString, HTMLElementOrLong, HTMLElementOrUnsignedLongOrStringOrBoolean, + LongOrLongSequenceSequence, LongSequenceOrBoolean, LongSequenceOrTestTypedef, StringOrBoolean, + StringOrLongSequence, StringOrStringSequence, StringOrUnsignedLong, + StringSequenceOrUnsignedLong, UnsignedLongOrBoolean, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::num::Finite; @@ -54,20 +52,6 @@ use crate::dom::url::URL; use crate::realms::InRealm; use crate::script_runtime::JSContext as SafeJSContext; use crate::timers::OneshotTimerCallback; -use dom_struct::dom_struct; -use js::jsapi::{Heap, JSObject}; -use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray}; -use js::jsval::{JSVal, NullValue}; -use js::rust::CustomAutoRooterGuard; -use js::rust::{HandleObject, HandleValue}; -use js::typedarray; -use script_traits::serializable::BlobImpl; -use script_traits::MsDuration; -use servo_config::prefs; -use std::borrow::ToOwned; -use std::ptr; -use std::ptr::NonNull; -use std::rc::Rc; #[dom_struct] pub struct TestBinding { diff --git a/components/script/dom/testbindingiterable.rs b/components/script/dom/testbindingiterable.rs index bfbc4478cc2..a60569f5510 100644 --- a/components/script/dom/testbindingiterable.rs +++ b/components/script/dom/testbindingiterable.rs @@ -4,6 +4,9 @@ // check-tidy: no specs after this line +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TestBindingIterableBinding::TestBindingIterableMethods; use crate::dom::bindings::error::Fallible; @@ -11,8 +14,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct TestBindingIterable { diff --git a/components/script/dom/testbindingmaplike.rs b/components/script/dom/testbindingmaplike.rs index 83ebcce4646..19dbcf9da8f 100644 --- a/components/script/dom/testbindingmaplike.rs +++ b/components/script/dom/testbindingmaplike.rs @@ -4,6 +4,11 @@ // check-tidy: no specs after this line +use dom_struct::dom_struct; +use indexmap::IndexMap; +use js::rust::HandleObject; + +use super::bindings::error::Error; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TestBindingMaplikeBinding::TestBindingMaplikeMethods; use crate::dom::bindings::error::Fallible; @@ -13,11 +18,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::maplike; -use dom_struct::dom_struct; -use indexmap::IndexMap; -use js::rust::HandleObject; - -use super::bindings::error::Error; /// maplike<DOMString, long> #[dom_struct] diff --git a/components/script/dom/testbindingpairiterable.rs b/components/script/dom/testbindingpairiterable.rs index 4f394ce84bb..15ff3c2c752 100644 --- a/components/script/dom/testbindingpairiterable.rs +++ b/components/script/dom/testbindingpairiterable.rs @@ -4,6 +4,9 @@ // check-tidy: no specs after this line +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods; use crate::dom::bindings::error::Fallible; @@ -12,8 +15,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct TestBindingPairIterable { diff --git a/components/script/dom/testbindingproxy.rs b/components/script/dom/testbindingproxy.rs index 3b352acb097..55be0bfc28b 100644 --- a/components/script/dom/testbindingproxy.rs +++ b/components/script/dom/testbindingproxy.rs @@ -4,10 +4,11 @@ // check-tidy: no specs after this line +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TestBindingProxyBinding::TestBindingProxyMethods; use crate::dom::bindings::str::DOMString; use crate::dom::testbinding::TestBinding; -use dom_struct::dom_struct; #[dom_struct] pub struct TestBindingProxy { diff --git a/components/script/dom/testbindingsetlike.rs b/components/script/dom/testbindingsetlike.rs index 9d62afaf653..f39e8f69514 100644 --- a/components/script/dom/testbindingsetlike.rs +++ b/components/script/dom/testbindingsetlike.rs @@ -4,6 +4,11 @@ // check-tidy: no specs after this line +use dom_struct::dom_struct; +use indexmap::IndexSet; +use js::rust::HandleObject; + +use super::bindings::like::Setlike; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TestBindingSetlikeBinding::TestBindingSetlikeMethods; use crate::dom::bindings::error::Fallible; @@ -12,11 +17,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::setlike; -use dom_struct::dom_struct; -use indexmap::IndexSet; -use js::rust::HandleObject; - -use super::bindings::like::Setlike; // setlike<DOMString> #[dom_struct] diff --git a/components/script/dom/testrunner.rs b/components/script/dom/testrunner.rs index ac354905d25..6d9a68c9db4 100644 --- a/components/script/dom/testrunner.rs +++ b/components/script/dom/testrunner.rs @@ -2,16 +2,17 @@ * 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 dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use profile_traits::ipc; + use crate::dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods; use crate::dom::bindings::error::{Error, ErrorResult}; 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; // https://webbluetoothcg.github.io/web-bluetooth/tests#test-runner #[dom_struct] diff --git a/components/script/dom/testworklet.rs b/components/script/dom/testworklet.rs index f9d5591758a..fbc25a06dea 100644 --- a/components/script/dom/testworklet.rs +++ b/components/script/dom/testworklet.rs @@ -3,24 +3,24 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // check-tidy: no specs after this line +use std::rc::Rc; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::TestWorkletMethods; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::Reflector; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; -use crate::dom::bindings::str::DOMString; -use crate::dom::bindings::str::USVString; +use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::promise::Promise; use crate::dom::window::Window; use crate::dom::worklet::Worklet; use crate::dom::workletglobalscope::WorkletGlobalScopeType; use crate::realms::InRealm; use crate::script_thread::ScriptThread; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::rc::Rc; #[dom_struct] pub struct TestWorklet { diff --git a/components/script/dom/testworkletglobalscope.rs b/components/script/dom/testworkletglobalscope.rs index c67e1536457..71c20ad9966 100644 --- a/components/script/dom/testworkletglobalscope.rs +++ b/components/script/dom/testworkletglobalscope.rs @@ -2,21 +2,22 @@ * 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::collections::HashMap; + +use crossbeam_channel::Sender; +use dom_struct::dom_struct; +use js::rust::Runtime; +use msg::constellation_msg::PipelineId; +use servo_url::ServoUrl; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding; use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding::TestWorkletGlobalScopeMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::worklet::WorkletExecutor; -use crate::dom::workletglobalscope::WorkletGlobalScope; -use crate::dom::workletglobalscope::WorkletGlobalScopeInit; +use crate::dom::workletglobalscope::{WorkletGlobalScope, WorkletGlobalScopeInit}; use crate::script_runtime::JSContext; -use crossbeam_channel::Sender; -use dom_struct::dom_struct; -use js::rust::Runtime; -use msg::constellation_msg::PipelineId; -use servo_url::ServoUrl; -use std::collections::HashMap; // check-tidy: no specs after this line diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs index bc436517cd2..cdacdb85024 100644 --- a/components/script/dom/text.rs +++ b/components/script/dom/text.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -15,8 +18,6 @@ use crate::dom::characterdata::CharacterData; use crate::dom::document::Document; use crate::dom::node::Node; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; /// An HTML text node. #[dom_struct] diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs index 0f215b4cbc8..38ffb5eccf6 100644 --- a/components/script/dom/textcontrol.rs +++ b/components/script/dom/textcontrol.rs @@ -7,6 +7,8 @@ //! //! https://html.spec.whatwg.org/multipage/#textFieldSelection +use script_traits::ScriptToConstellationChan; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::SelectionMode; use crate::dom::bindings::conversions::DerivedFrom; @@ -16,7 +18,6 @@ use crate::dom::event::{EventBubbles, EventCancelable}; use crate::dom::eventtarget::EventTarget; use crate::dom::node::{window_from_node, Node, NodeDamage}; use crate::textinput::{SelectionDirection, SelectionState, TextInput, UTF8Bytes}; -use script_traits::ScriptToConstellationChan; pub trait TextControlElement: DerivedFrom<EventTarget> + DerivedFrom<Node> { fn selection_api_applies(&self) -> bool; diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs index dad1568a293..5a5eaeeb7a1 100644 --- a/components/script/dom/textdecoder.rs +++ b/components/script/dom/textdecoder.rs @@ -2,6 +2,13 @@ * 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::borrow::ToOwned; +use std::cell::{Cell, RefCell}; + +use dom_struct::dom_struct; +use encoding_rs::{Decoder, DecoderResult, Encoding}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::TextDecoderBinding::{ TextDecodeOptions, TextDecoderMethods, @@ -12,11 +19,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use encoding_rs::{Decoder, DecoderResult, Encoding}; -use js::rust::HandleObject; -use std::borrow::ToOwned; -use std::cell::{Cell, RefCell}; #[dom_struct] #[allow(non_snake_case)] diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 3956683c0e4..f81679fe298 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -2,6 +2,14 @@ * 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::ptr; +use std::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::JSObject; +use js::rust::HandleObject; +use js::typedarray::{CreateWith, Uint8Array}; + use crate::dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; @@ -9,12 +17,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::JSObject; -use js::rust::HandleObject; -use js::typedarray::{CreateWith, Uint8Array}; -use std::ptr; -use std::ptr::NonNull; #[dom_struct] pub struct TextEncoder { diff --git a/components/script/dom/textmetrics.rs b/components/script/dom/textmetrics.rs index 675fcf1aa1d..665588b86f1 100644 --- a/components/script/dom/textmetrics.rs +++ b/components/script/dom/textmetrics.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TextMetricsBinding::TextMetricsMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; #[dom_struct] #[allow(non_snake_case)] diff --git a/components/script/dom/texttrack.rs b/components/script/dom/texttrack.rs index 0e6cd2e48c7..be76479feb6 100644 --- a/components/script/dom/texttrack.rs +++ b/components/script/dom/texttrack.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{ TextTrackKind, TextTrackMethods, TextTrackMode, @@ -15,8 +19,6 @@ use crate::dom::texttrackcue::TextTrackCue; use crate::dom::texttrackcuelist::TextTrackCueList; use crate::dom::texttracklist::TextTrackList; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct TextTrack { diff --git a/components/script/dom/texttrackcue.rs b/components/script/dom/texttrackcue.rs index 7a219f0f417..5a0f7f3abef 100644 --- a/components/script/dom/texttrackcue.rs +++ b/components/script/dom/texttrackcue.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackCueBinding::TextTrackCueMethods; use crate::dom::bindings::num::Finite; @@ -11,8 +15,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::eventtarget::EventTarget; use crate::dom::texttrack::TextTrack; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct TextTrackCue { diff --git a/components/script/dom/texttrackcuelist.rs b/components/script/dom/texttrackcuelist.rs index a51b95a965f..912faff815a 100644 --- a/components/script/dom/texttrackcuelist.rs +++ b/components/script/dom/texttrackcuelist.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackCueListBinding::TextTrackCueListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,7 +11,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::texttrackcue::TextTrackCue; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct TextTrackCueList { diff --git a/components/script/dom/texttracklist.rs b/components/script/dom/texttracklist.rs index faeb9f0cd6d..b86b5b213d8 100644 --- a/components/script/dom/texttracklist.rs +++ b/components/script/dom/texttracklist.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackListBinding::TextTrackListMethods; use crate::dom::bindings::codegen::UnionTypes::VideoTrackOrAudioTrackOrTextTrack; @@ -16,7 +18,6 @@ use crate::dom::texttrack::TextTrack; use crate::dom::trackevent::TrackEvent; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; #[dom_struct] pub struct TextTrackList { diff --git a/components/script/dom/timeranges.rs b/components/script/dom/timeranges.rs index 7a60210b0e0..21476f3fcd3 100644 --- a/components/script/dom/timeranges.rs +++ b/components/script/dom/timeranges.rs @@ -2,14 +2,16 @@ * 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::fmt; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TimeRangesBinding::TimeRangesMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::fmt; #[derive(Clone, JSTraceable, MallocSizeOf)] struct TimeRange { diff --git a/components/script/dom/touch.rs b/components/script/dom/touch.rs index 60e69a48ca3..2d257ee2107 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{DomRoot, MutDom}; use crate::dom::eventtarget::EventTarget; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct Touch { diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs index 4dfbed55147..02fc3533442 100644 --- a/components/script/dom/touchevent.rs +++ b/components/script/dom/touchevent.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods; use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use crate::dom::bindings::inheritance::Castable; @@ -12,8 +16,6 @@ use crate::dom::event::{EventBubbles, EventCancelable}; use crate::dom::touchlist::TouchList; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct TouchEvent { diff --git a/components/script/dom/touchlist.rs b/components/script/dom/touchlist.rs index 46400df8ca1..ede60a456ce 100644 --- a/components/script/dom/touchlist.rs +++ b/components/script/dom/touchlist.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::TouchListBinding::TouchListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::touch::Touch; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct TouchList { diff --git a/components/script/dom/trackevent.rs b/components/script/dom/trackevent.rs index f8766b766f8..45223666a04 100644 --- a/components/script/dom/trackevent.rs +++ b/components/script/dom/trackevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::audiotrack::AudioTrack; use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::TrackEventBinding; @@ -17,9 +21,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::texttrack::TextTrack; use crate::dom::videotrack::VideoTrack; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/transitionevent.rs b/components/script/dom/transitionevent.rs index cba2856b57e..217d4297f0f 100644 --- a/components/script/dom/transitionevent.rs +++ b/components/script/dom/transitionevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::TransitionEventBinding::{ TransitionEventInit, TransitionEventMethods, @@ -14,9 +18,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct TransitionEvent { diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 2cd8de9fdb3..a3e5e399222 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -2,19 +2,20 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; + use crate::dom::bindings::callback::ExceptionHandling::Rethrow; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; -use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; +use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::{NodeFilter, NodeFilterConstants}; use crate::dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutDom}; use crate::dom::document::Document; use crate::dom::node::Node; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::rc::Rc; // https://dom.spec.whatwg.org/#interface-treewalker #[dom_struct] diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 57950f6bf87..b28bda898e7 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -2,6 +2,13 @@ * 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::Cell; +use std::default::Default; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::UIEventBinding; use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; @@ -12,11 +19,6 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; -use std::cell::Cell; -use std::default::Default; // https://w3c.github.io/uievents/#interface-uievent #[dom_struct] diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 9868ba0655b..31fef976678 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -2,6 +2,17 @@ * 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::default::Default; + +use dom_struct::dom_struct; +use js::rust::HandleObject; +use net_traits::blob_url_store::{get_blob_origin, parse_blob_url}; +use net_traits::filemanager_thread::FileManagerThreadMsg; +use net_traits::{CoreResourceMsg, IpcSend}; +use profile_traits::ipc; +use servo_url::ServoUrl; +use uuid::Uuid; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::URLBinding::URLMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -12,15 +23,6 @@ use crate::dom::blob::Blob; use crate::dom::globalscope::GlobalScope; use crate::dom::urlhelper::UrlHelper; use crate::dom::urlsearchparams::URLSearchParams; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use net_traits::blob_url_store::{get_blob_origin, parse_blob_url}; -use net_traits::filemanager_thread::FileManagerThreadMsg; -use net_traits::{CoreResourceMsg, IpcSend}; -use profile_traits::ipc; -use servo_url::ServoUrl; -use std::default::Default; -use uuid::Uuid; // https://url.spec.whatwg.org/#url #[dom_struct] diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index 834d7e20d18..03a3c3150ae 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -2,11 +2,13 @@ * 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::str::USVString; -use servo_url::ServoUrl; use std::borrow::ToOwned; + +use servo_url::ServoUrl; use url::quirks; +use crate::dom::bindings::str::USVString; + #[derive(MallocSizeOf)] pub struct UrlHelper; diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index f23991ab098..4df702981de 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use url::form_urlencoded; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods; use crate::dom::bindings::codegen::UnionTypes::USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString; @@ -13,9 +17,6 @@ use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::bindings::weakref::MutableWeakRef; use crate::dom::globalscope::GlobalScope; use crate::dom::url::URL; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use url::form_urlencoded; // https://url.spec.whatwg.org/#interface-urlsearchparams #[dom_struct] diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs index 047b3345b0c..2b64c606b06 100644 --- a/components/script/dom/userscripts.rs +++ b/components/script/dom/userscripts.rs @@ -2,6 +2,13 @@ * 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::fs::{read_dir, File}; +use std::io::Read; +use std::path::PathBuf; +use std::rc::Rc; + +use js::jsval::UndefinedValue; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::str::DOMString; @@ -10,11 +17,6 @@ use crate::dom::htmlheadelement::HTMLHeadElement; use crate::dom::htmlscriptelement::SourceCode; use crate::dom::node::document_from_node; use crate::script_module::ScriptFetchOptions; -use js::jsval::UndefinedValue; -use std::fs::{read_dir, File}; -use std::io::Read; -use std::path::PathBuf; -use std::rc::Rc; pub fn load_script(head: &HTMLHeadElement) { let doc = document_from_node(head); diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index 38f700ea542..6d71181a426 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -2,6 +2,14 @@ * 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::Cell; +use std::fmt; + +use bitflags::bitflags; +use dom_struct::dom_struct; +use itertools::Itertools; +use style::element_state::ElementState; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::ValidityStateBinding::ValidityStateMethods; use crate::dom::bindings::inheritance::Castable; @@ -13,12 +21,6 @@ use crate::dom::htmlfieldsetelement::HTMLFieldSetElement; use crate::dom::htmlformelement::FormControlElementHelpers; use crate::dom::node::Node; use crate::dom::window::Window; -use bitflags::bitflags; -use dom_struct::dom_struct; -use itertools::Itertools; -use std::cell::Cell; -use std::fmt; -use style::element_state::ElementState; // https://html.spec.whatwg.org/multipage/#validity-states #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index eef71e32a86..4021fe49e5f 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.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 std::cell::Cell; + +use canvas_traits::webgl::{ + ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVersion, WebGLVertexArrayId, +}; + use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants2; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::root::{Dom, MutNullableDom}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{ - ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVersion, WebGLVertexArrayId, -}; -use std::cell::Cell; #[derive(JSTraceable, MallocSizeOf)] #[unrooted_must_root_lint::must_root] diff --git a/components/script/dom/videotrack.rs b/components/script/dom/videotrack.rs index 8f904284fd9..f0decb69c82 100644 --- a/components/script/dom/videotrack.rs +++ b/components/script/dom/videotrack.rs @@ -2,6 +2,10 @@ * 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::Cell; + +use dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::VideoTrackBinding::VideoTrackMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -9,8 +13,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::videotracklist::VideoTrackList; use crate::dom::window::Window; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct VideoTrack { diff --git a/components/script/dom/videotracklist.rs b/components/script/dom/videotracklist.rs index a56e29d1470..cf19e0d17bf 100644 --- a/components/script/dom/videotracklist.rs +++ b/components/script/dom/videotracklist.rs @@ -2,20 +2,20 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::VideoTrackListBinding::VideoTrackListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::videotrack::VideoTrack; use crate::dom::window::Window; use crate::task_source::TaskSource; -use dom_struct::dom_struct; #[dom_struct] pub struct VideoTrackList { diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 9f175d8d621..889eab07380 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -2,14 +2,14 @@ * 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 html5ever::LocalName; +use style::attr::AttrValue; + use crate::dom::attr::Attr; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::inheritance::ElementTypeId; -use crate::dom::bindings::inheritance::HTMLElementTypeId; -use crate::dom::bindings::inheritance::HTMLMediaElementTypeId; -use crate::dom::bindings::inheritance::NodeTypeId; -use crate::dom::bindings::inheritance::SVGElementTypeId; -use crate::dom::bindings::inheritance::SVGGraphicsElementTypeId; +use crate::dom::bindings::inheritance::{ + Castable, ElementTypeId, HTMLElementTypeId, HTMLMediaElementTypeId, NodeTypeId, + SVGElementTypeId, SVGGraphicsElementTypeId, +}; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::element::{AttributeMutation, Element}; @@ -54,8 +54,6 @@ use crate::dom::htmlvideoelement::HTMLVideoElement; use crate::dom::node::{BindContext, ChildrenMutation, CloneChildrenFlag, Node, UnbindContext}; use crate::dom::svgelement::SVGElement; use crate::dom::svgsvgelement::SVGSVGElement; -use html5ever::LocalName; -use style::attr::AttrValue; /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common /// behaviours. Replicates the effect of C++ virtual methods. diff --git a/components/script/dom/vttcue.rs b/components/script/dom/vttcue.rs index fa84fae363b..a4740fd3e30 100644 --- a/components/script/dom/vttcue.rs +++ b/components/script/dom/vttcue.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::VTTCueBinding::{ self, AlignSetting, AutoKeyword, DirectionSetting, LineAlignSetting, PositionAlignSetting, @@ -17,9 +22,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::texttrackcue::TextTrackCue; use crate::dom::vttregion::VTTRegion; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::cell::Cell; #[dom_struct] pub struct VTTCue { diff --git a/components/script/dom/vttregion.rs b/components/script/dom/vttregion.rs index 24069ded2cd..87482b8b97e 100644 --- a/components/script/dom/vttregion.rs +++ b/components/script/dom/vttregion.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::VTTRegionBinding::{ScrollSetting, VTTRegionMethods}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -11,9 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::cell::Cell; #[dom_struct] pub struct VTTRegion { diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index b438056e622..bca22a9931f 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -2,18 +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::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextMethods; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; -use crate::dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer; -use crate::dom::bindings::codegen::UnionTypes::Float32ArrayOrUnrestrictedFloatSequence; -use crate::dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement; -use crate::dom::bindings::codegen::UnionTypes::Int32ArrayOrLongSequence; -use crate::dom::bindings::codegen::UnionTypes::Uint32ArrayOrUnsignedLongSequence; +use std::cell::Cell; +use std::cmp; +use std::ptr::{self, NonNull}; + +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{ + webgl_channel, GLContextAttributes, InternalFormatParameter, WebGLCommand, WebGLResult, + WebGLVersion, +}; +use dom_struct::dom_struct; +use euclid::default::{Point2D, Rect, Size2D}; +use ipc_channel::ipc::{self, IpcSharedMemory}; +use js::jsapi::{JSObject, Type}; +use js::jsval::{ + BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, ObjectValue, UInt32Value, + UndefinedValue, +}; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{ArrayBufferView, CreateWith, Float32, Int32Array, Uint32, Uint32Array}; +use script_layout_interface::HTMLCanvasDataSource; +use servo_config::pref; +use url::Host; + +use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::{ + WebGL2RenderingContextConstants as constants, WebGL2RenderingContextMethods, +}; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{ + WebGLContextAttributes, WebGLRenderingContextMethods, +}; +use crate::dom::bindings::codegen::UnionTypes::{ + ArrayBufferViewOrArrayBuffer, Float32ArrayOrUnrestrictedFloatSequence, + ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement, Int32ArrayOrLongSequence, + Uint32ArrayOrUnsignedLongSequence, +}; use crate::dom::bindings::error::{ErrorResult, Fallible}; -use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; @@ -43,25 +67,6 @@ use crate::dom::webglvertexarrayobject::WebGLVertexArrayObject; use crate::dom::window::Window; use crate::js::conversions::ToJSValConvertible; use crate::script_runtime::JSContext; -use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::{ - webgl_channel, GLContextAttributes, InternalFormatParameter, WebGLCommand, WebGLResult, - WebGLVersion, -}; -use dom_struct::dom_struct; -use euclid::default::{Point2D, Rect, Size2D}; -use ipc_channel::ipc::{self, IpcSharedMemory}; -use js::jsapi::{JSObject, Type}; -use js::jsval::{BooleanValue, DoubleValue, Int32Value, UInt32Value}; -use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue}; -use js::rust::{CustomAutoRooterGuard, HandleObject}; -use js::typedarray::{ArrayBufferView, CreateWith, Float32, Int32Array, Uint32, Uint32Array}; -use script_layout_interface::HTMLCanvasDataSource; -use servo_config::pref; -use std::cell::Cell; -use std::cmp; -use std::ptr::{self, NonNull}; -use url::Host; #[unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs index 4d03f25781b..5c79a692adb 100644 --- a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs +++ b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs @@ -2,14 +2,16 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; -use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysMethods; +use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::{ + ANGLEInstancedArraysConstants, 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] pub struct ANGLEInstancedArrays { diff --git a/components/script/dom/webgl_extensions/ext/extblendminmax.rs b/components/script/dom/webgl_extensions/ext/extblendminmax.rs index 122aac6c861..97c4a642f9b 100644 --- a/components/script/dom/webgl_extensions/ext/extblendminmax.rs +++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs @@ -2,12 +2,13 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct EXTBlendMinmax { diff --git a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs index bb4a630d537..48d69b78ab4 100644 --- a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs @@ -2,13 +2,14 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct EXTColorBufferHalfFloat { diff --git a/components/script/dom/webgl_extensions/ext/extfragdepth.rs b/components/script/dom/webgl_extensions/ext/extfragdepth.rs index 182b30bf754..056286137a4 100644 --- a/components/script/dom/webgl_extensions/ext/extfragdepth.rs +++ b/components/script/dom/webgl_extensions/ext/extfragdepth.rs @@ -2,12 +2,13 @@ * 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::{WebGLSLVersion, WebGLVersion}; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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::{WebGLSLVersion, WebGLVersion}; -use dom_struct::dom_struct; #[dom_struct] pub struct EXTFragDepth { diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs index ea68b518dac..65c39edb6a2 100644 --- a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs +++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs @@ -2,12 +2,13 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct EXTShaderTextureLod { diff --git a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs index 89a4d3ed6a4..c5de4cea880 100644 --- a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs +++ b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs @@ -2,13 +2,14 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct EXTTextureFilterAnisotropic { diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs index 096c22d3dc5..77ba300caef 100644 --- a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs +++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs @@ -2,12 +2,13 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct OESElementIndexUint { diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index dfafa7051a5..9a552216cc4 100644 --- a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -2,13 +2,14 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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::WebGLVersion; -use dom_struct::dom_struct; #[dom_struct] pub struct OESStandardDerivatives { diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index e286095b7c7..b7d87594a42 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -2,12 +2,13 @@ * 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::{TexFormat, WebGLVersion}; +use dom_struct::dom_struct; + use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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::{TexFormat, WebGLVersion}; -use dom_struct::dom_struct; #[dom_struct] pub struct OESTextureFloat { diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs index 9e5c021f0ef..eee682a4327 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs @@ -2,11 +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 dom_struct::dom_struct; + use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; -use dom_struct::dom_struct; #[dom_struct] pub struct OESTextureFloatLinear { diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs index 4f2ef41c651..49724a1aa21 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs @@ -2,13 +2,14 @@ * 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::{TexFormat, WebGLVersion}; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::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::{TexFormat, WebGLVersion}; -use dom_struct::dom_struct; #[dom_struct] pub struct OESTextureHalfFloat { diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs index a1e5f3bf15d..c25bf855b6e 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs @@ -2,12 +2,13 @@ * 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 dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; -use dom_struct::dom_struct; #[dom_struct] pub struct OESTextureHalfFloatLinear { diff --git a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs index 57a68142609..4ddb5c2fb52 100644 --- a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs +++ b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs @@ -2,15 +2,17 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; -use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectMethods; +use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{ + OESVertexArrayObjectConstants, OESVertexArrayObjectMethods, +}; 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] pub struct OESVertexArrayObject { diff --git a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs index c0d8dc13776..30466b49cdc 100644 --- a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs +++ b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs @@ -2,13 +2,14 @@ * 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::WebGLVersion; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; 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] pub struct WEBGLColorBufferFloat { diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs index 749c38abd82..c04dceebca0 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs @@ -2,13 +2,14 @@ * 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::{TexFormat, WebGLVersion}; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webgltexture::{TexCompression, TexCompressionValidation}; -use canvas_traits::webgl::{TexFormat, WebGLVersion}; -use dom_struct::dom_struct; #[dom_struct] pub struct WEBGLCompressedTextureETC1 { diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs index 362dbe67117..22d9899db43 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs @@ -2,13 +2,14 @@ * 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::{TexFormat, WebGLVersion}; +use dom_struct::dom_struct; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webgltexture::{TexCompression, TexCompressionValidation}; -use canvas_traits::webgl::{TexFormat, WebGLVersion}; -use dom_struct::dom_struct; #[dom_struct] pub struct WEBGLCompressedTextureS3TC { diff --git a/components/script/dom/webgl_extensions/extension.rs b/components/script/dom/webgl_extensions/extension.rs index 3854acee122..876b19cb8a9 100644 --- a/components/script/dom/webgl_extensions/extension.rs +++ b/components/script/dom/webgl_extensions/extension.rs @@ -2,12 +2,13 @@ * 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::WebGLVersion; + use super::WebGLExtensions; 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 4873b3638e8..4c1bf37d0e4 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -2,6 +2,16 @@ * 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::collections::HashMap; +use std::iter::FromIterator; +use std::ptr::NonNull; + +use canvas_traits::webgl::{GlType, TexFormat, WebGLSLVersion, WebGLVersion}; +use fnv::{FnvHashMap, FnvHashSet}; +use js::jsapi::JSObject; +use malloc_size_of::MallocSizeOf; +use sparkle::gl::{self, GLenum}; + use super::wrapper::{TypedWebGLExtensionWrapper, WebGLExtensionWrapper}; use super::{ext, WebGLExtension, WebGLExtensionSpec}; use crate::dom::bindings::cell::DomRefCell; @@ -18,14 +28,6 @@ use crate::dom::oestexturehalffloat::OESTextureHalfFloat; use crate::dom::webglcolorbufferfloat::WEBGLColorBufferFloat; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::webgltexture::TexCompression; -use canvas_traits::webgl::{GlType, TexFormat, WebGLSLVersion, WebGLVersion}; -use fnv::{FnvHashMap, FnvHashSet}; -use js::jsapi::JSObject; -use malloc_size_of::MallocSizeOf; -use sparkle::gl::{self, GLenum}; -use std::collections::HashMap; -use std::iter::FromIterator; -use std::ptr::NonNull; // Data types that are implemented for texImage2D and texSubImage2D in a WebGL 1.0 context // but must trigger a InvalidValue error until the related WebGL Extensions are enabled. diff --git a/components/script/dom/webgl_extensions/mod.rs b/components/script/dom/webgl_extensions/mod.rs index aa6dfd1c752..df91a5e00d1 100644 --- a/components/script/dom/webgl_extensions/mod.rs +++ b/components/script/dom/webgl_extensions/mod.rs @@ -7,6 +7,5 @@ mod extension; mod extensions; mod wrapper; -pub use self::extension::WebGLExtension; -pub use self::extension::WebGLExtensionSpec; +pub use self::extension::{WebGLExtension, WebGLExtensionSpec}; pub use self::extensions::WebGLExtensions; diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index bf8db31418c..84338640835 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -2,15 +2,17 @@ * 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::any::Any; +use std::ptr::NonNull; + +use js::jsapi::JSObject; +use malloc_size_of::MallocSizeOf; + use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::MutNullableDom; use crate::dom::bindings::trace::JSTraceable; use crate::dom::webglrenderingcontext::WebGLRenderingContext; -use js::jsapi::JSObject; -use malloc_size_of::MallocSizeOf; -use std::any::Any; -use std::ptr::NonNull; /// Trait used internally by WebGLExtensions to store and /// handle the different WebGL extensions in a common list. diff --git a/components/script/dom/webgl_validations/tex_image_2d.rs b/components/script/dom/webgl_validations/tex_image_2d.rs index dece682d377..31ad93adbbf 100644 --- a/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/components/script/dom/webgl_validations/tex_image_2d.rs @@ -2,14 +2,16 @@ * 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::{self, cmp, fmt}; + +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{TexDataType, TexFormat}; + use super::types::TexImageTarget; use super::WebGLValidator; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; -use crate::dom::webgltexture::{ImageInfo, WebGLTexture}; -use crate::dom::webgltexture::{TexCompression, TexCompressionValidation}; -use canvas_traits::webgl::{TexDataType, TexFormat, WebGLError::*}; -use std::{self, cmp, fmt}; +use crate::dom::webgltexture::{ImageInfo, TexCompression, TexCompressionValidation, WebGLTexture}; /// The errors that the texImage* family of functions can generate. #[derive(Debug)] diff --git a/components/script/dom/webgl_validations/types.rs b/components/script/dom/webgl_validations/types.rs index b28664843e9..7e0164c9738 100644 --- a/components/script/dom/webgl_validations/types.rs +++ b/components/script/dom/webgl_validations/types.rs @@ -2,10 +2,11 @@ * 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::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use canvas_traits::gl_enums; use serde::{Deserialize, Serialize}; +use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; + gl_enums! { pub enum TexImageTarget { Texture2D = constants::TEXTURE_2D, diff --git a/components/script/dom/webglactiveinfo.rs b/components/script/dom/webglactiveinfo.rs index 93cc0274f35..b63dc713389 100644 --- a/components/script/dom/webglactiveinfo.rs +++ b/components/script/dom/webglactiveinfo.rs @@ -3,12 +3,13 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::WebGLActiveInfoBinding::WebGLActiveInfoMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLActiveInfo { diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index 7deb030e6c6..8817a06c505 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -3,6 +3,12 @@ * 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 std::cell::Cell; + +use canvas_traits::webgl::{webgl_channel, WebGLBufferId, WebGLCommand, WebGLError, WebGLResult}; +use dom_struct::dom_struct; +use ipc_channel::ipc; + use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants; use crate::dom::bindings::inheritance::Castable; @@ -10,11 +16,6 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, 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; fn target_is_copy_buffer(target: u32) -> bool { target == WebGL2RenderingContextConstants::COPY_READ_BUFFER || diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs index cd3924c4da5..af970133f9f 100644 --- a/components/script/dom/webglcontextevent.rs +++ b/components/script/dom/webglcontextevent.rs @@ -2,9 +2,14 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventInit; -use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods; +use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding::{ + WebGLContextEventInit, WebGLContextEventMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; @@ -12,9 +17,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct WebGLContextEvent { diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 021ebb0fd0c..541795dc6ce 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -3,6 +3,16 @@ * 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 std::cell::Cell; + +use canvas_traits::webgl::{ + webgl_channel, WebGLCommand, WebGLError, WebGLFramebufferBindingRequest, WebGLFramebufferId, + WebGLRenderbufferId, WebGLResult, WebGLTextureId, WebGLVersion, +}; +use dom_struct::dom_struct; +use euclid::Size2D; +use webxr_api::Viewport; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; @@ -13,14 +23,6 @@ use crate::dom::webglrenderbuffer::WebGLRenderbuffer; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::webgltexture::WebGLTexture; use crate::dom::xrsession::XRSession; -use canvas_traits::webgl::WebGLFramebufferId; -use canvas_traits::webgl::{webgl_channel, WebGLError, WebGLResult, WebGLVersion}; -use canvas_traits::webgl::{WebGLCommand, WebGLFramebufferBindingRequest}; -use canvas_traits::webgl::{WebGLRenderbufferId, WebGLTextureId}; -use dom_struct::dom_struct; -use euclid::Size2D; -use std::cell::Cell; -use webxr_api::Viewport; pub enum CompleteForRendering { Complete, diff --git a/components/script/dom/webglobject.rs b/components/script/dom/webglobject.rs index 999c7797b10..fd6fe082c08 100644 --- a/components/script/dom/webglobject.rs +++ b/components/script/dom/webglobject.rs @@ -3,10 +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 dom_struct::dom_struct; + use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::Dom; use crate::dom::webglrenderingcontext::WebGLRenderingContext; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLObject { diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 3ea2e6afef4..486c8b4449a 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -3,6 +3,15 @@ * 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 std::cell::Cell; + +use canvas_traits::webgl::{ + webgl_channel, ActiveAttribInfo, ActiveUniformBlockInfo, ActiveUniformInfo, WebGLCommand, + WebGLError, WebGLProgramId, WebGLResult, +}; +use dom_struct::dom_struct; +use fnv::FnvHashSet; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants2; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -15,13 +24,6 @@ use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::webglshader::WebGLShader; use crate::dom::webgluniformlocation::WebGLUniformLocation; -use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult}; -use canvas_traits::webgl::{ - ActiveAttribInfo, ActiveUniformBlockInfo, ActiveUniformInfo, WebGLCommand, WebGLError, -}; -use dom_struct::dom_struct; -use fnv::FnvHashSet; -use std::cell::Cell; #[dom_struct] pub struct WebGLProgram { diff --git a/components/script/dom/webglquery.rs b/components/script/dom/webglquery.rs index c971d8442ff..1c890d23760 100644 --- a/components/script/dom/webglquery.rs +++ b/components/script/dom/webglquery.rs @@ -2,6 +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 std::cell::Cell; + +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLQueryId}; +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -10,10 +16,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::task_source::TaskSource; -use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLQueryId}; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct WebGLQuery { diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 6fe3d06d7fd..3afb4955040 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -3,6 +3,14 @@ * 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 std::cell::Cell; + +use canvas_traits::webgl::{ + webgl_channel, GlType, InternalFormatIntVec, WebGLCommand, WebGLError, WebGLRenderbufferId, + WebGLResult, WebGLVersion, +}; +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding::EXTColorBufferHalfFloatConstants; use crate::dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding::WEBGLColorBufferFloatConstants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; @@ -12,12 +20,6 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::webglframebuffer::WebGLFramebuffer; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{ - webgl_channel, GlType, InternalFormatIntVec, WebGLCommand, WebGLError, WebGLRenderbufferId, - WebGLResult, WebGLVersion, -}; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct WebGLRenderbuffer { diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 8127f8c5f3a..dc71cf3912a 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2,18 +2,54 @@ * 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::Cell; +use std::cmp; +use std::ptr::{self, NonNull}; +use std::rc::Rc; + +#[cfg(feature = "webgl_backtrace")] +use backtrace::Backtrace; +use bitflags::bitflags; +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{ + webgl_channel, AlphaTreatment, GLContextAttributes, GLLimits, GlType, Parameter, SizedDataType, + TexDataType, TexFormat, TexParameter, WebGLChan, WebGLCommand, WebGLCommandBacktrace, + WebGLContextId, WebGLError, WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, + WebGLProgramId, WebGLResult, WebGLSLVersion, WebGLSendResult, WebGLSender, WebGLVersion, + YAxisTreatment, +}; +use dom_struct::dom_struct; +use euclid::default::{Point2D, Rect, Size2D}; +use ipc_channel::ipc::{self, IpcSharedMemory}; +use js::jsapi::{JSContext, JSObject, Type}; +use js::jsval::{ + BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, ObjectValue, UInt32Value, + UndefinedValue, +}; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::{ + ArrayBufferView, CreateWith, Float32, Float32Array, Int32, Int32Array, TypedArray, + TypedArrayElementCreator, Uint32Array, +}; +use net_traits::image_cache::ImageResponse; +use pixels::{self, PixelFormat}; +use script_layout_interface::HTMLCanvasDataSource; +use serde::{Deserialize, Serialize}; +use servo_config::pref; +use webrender_api::ImageKey; + use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut}; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding::EXTBlendMinmaxConstants; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::TexImageSource; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; -use crate::dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer; -use crate::dom::bindings::codegen::UnionTypes::Float32ArrayOrUnrestrictedFloatSequence; -use crate::dom::bindings::codegen::UnionTypes::Int32ArrayOrLongSequence; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{ + TexImageSource, WebGLContextAttributes, WebGLRenderingContextConstants as constants, + WebGLRenderingContextMethods, +}; +use crate::dom::bindings::codegen::UnionTypes::{ + ArrayBufferViewOrArrayBuffer, Float32ArrayOrUnrestrictedFloatSequence, Int32ArrayOrLongSequence, +}; use crate::dom::bindings::conversions::{DerivedFrom, ToJSValConvertible}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -22,8 +58,9 @@ use crate::dom::bindings::root::{Dom, DomOnceCell, DomRoot, LayoutDom, MutNullab use crate::dom::bindings::str::DOMString; use crate::dom::element::cors_setting_for_element; use crate::dom::event::{Event, EventBubbles, EventCancelable}; -use crate::dom::htmlcanvaselement::utils as canvas_utils; -use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutCanvasRenderingContextHelpers}; +use crate::dom::htmlcanvaselement::{ + utils as canvas_utils, HTMLCanvasElement, LayoutCanvasRenderingContextHelpers, +}; use crate::dom::node::{document_from_node, window_from_node, Node, NodeDamage}; use crate::dom::promise::Promise; use crate::dom::vertexarrayobject::VertexAttribData; @@ -52,38 +89,6 @@ use crate::dom::webglvertexarrayobject::WebGLVertexArrayObject; use crate::dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES; use crate::dom::window::Window; use crate::script_runtime::JSContext as SafeJSContext; -#[cfg(feature = "webgl_backtrace")] -use backtrace::Backtrace; -use bitflags::bitflags; -use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::{ - webgl_channel, AlphaTreatment, GLContextAttributes, GLLimits, GlType, Parameter, SizedDataType, - TexDataType, TexFormat, TexParameter, WebGLChan, WebGLCommand, WebGLCommandBacktrace, - WebGLContextId, WebGLError, WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, - WebGLProgramId, WebGLResult, WebGLSLVersion, WebGLSendResult, WebGLSender, WebGLVersion, - YAxisTreatment, -}; -use dom_struct::dom_struct; -use euclid::default::{Point2D, Rect, Size2D}; -use ipc_channel::ipc::{self, IpcSharedMemory}; -use js::jsapi::{JSContext, JSObject, Type}; -use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, UInt32Value}; -use js::jsval::{NullValue, ObjectValue, UndefinedValue}; -use js::rust::CustomAutoRooterGuard; -use js::typedarray::{ - ArrayBufferView, CreateWith, Float32, Float32Array, Int32, Int32Array, Uint32Array, -}; -use js::typedarray::{TypedArray, TypedArrayElementCreator}; -use net_traits::image_cache::ImageResponse; -use pixels::{self, PixelFormat}; -use script_layout_interface::HTMLCanvasDataSource; -use serde::{Deserialize, Serialize}; -use servo_config::pref; -use std::cell::Cell; -use std::cmp; -use std::ptr::{self, NonNull}; -use std::rc::Rc; -use webrender_api::ImageKey; // From the GLES 2.0.25 spec, page 85: // diff --git a/components/script/dom/webglsampler.rs b/components/script/dom/webglsampler.rs index ec68328fab9..37147d3d261 100644 --- a/components/script/dom/webglsampler.rs +++ b/components/script/dom/webglsampler.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 std::cell::Cell; + +use canvas_traits::webgl::WebGLError::*; +use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSamplerId}; +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSamplerId}; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct WebGLSampler { diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index ad61db47a5a..98afb686593 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -3,6 +3,17 @@ * 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 std::cell::Cell; +use std::os::raw::c_int; +use std::sync::Once; + +use canvas_traits::webgl::{ + webgl_channel, GLLimits, GlType, WebGLCommand, WebGLError, WebGLResult, WebGLSLVersion, + WebGLShaderId, WebGLVersion, +}; +use dom_struct::dom_struct; +use mozangle::shaders::{ffi, BuiltInResources, Output, ShaderValidator}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -14,14 +25,6 @@ use crate::dom::webgl_extensions::ext::oesstandardderivatives::OESStandardDeriva use crate::dom::webgl_extensions::WebGLExtensions; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{webgl_channel, GlType, WebGLVersion}; -use canvas_traits::webgl::{GLLimits, WebGLCommand, WebGLError}; -use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLShaderId}; -use dom_struct::dom_struct; -use mozangle::shaders::{ffi, BuiltInResources, Output, ShaderValidator}; -use std::cell::Cell; -use std::os::raw::c_int; -use std::sync::Once; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum ShaderCompilationStatus { diff --git a/components/script/dom/webglshaderprecisionformat.rs b/components/script/dom/webglshaderprecisionformat.rs index e1a7202ff8d..97c6f3fc22a 100644 --- a/components/script/dom/webglshaderprecisionformat.rs +++ b/components/script/dom/webglshaderprecisionformat.rs @@ -5,11 +5,12 @@ #![allow(dead_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding::WebGLShaderPrecisionFormatMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLShaderPrecisionFormat { diff --git a/components/script/dom/webglsync.rs b/components/script/dom/webglsync.rs index c26eb839eed..dd94e8090e8 100644 --- a/components/script/dom/webglsync.rs +++ b/components/script/dom/webglsync.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSyncId}; +use dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -10,9 +15,6 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::task_source::TaskSource; -use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSyncId}; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct WebGLSync { diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index fc1610281c8..ccae44da729 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -4,26 +4,26 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl +use std::cell::Cell; +use std::cmp; + +use canvas_traits::webgl::{ + webgl_channel, TexDataType, TexFormat, TexParameter, TexParameterBool, TexParameterInt, + WebGLCommand, WebGLError, WebGLResult, WebGLTextureId, +}; +use dom_struct::dom_struct; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::{DomRoot, MutNullableDom}; +use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::webgl_validations::types::TexImageTarget; use crate::dom::webglframebuffer::WebGLFramebuffer; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::xrsession::XRSession; -use canvas_traits::webgl::{ - webgl_channel, TexDataType, TexFormat, TexParameter, TexParameterBool, TexParameterInt, - WebGLResult, WebGLTextureId, -}; -use canvas_traits::webgl::{WebGLCommand, WebGLError}; -use dom_struct::dom_struct; -use std::cell::Cell; -use std::cmp; pub enum TexParameterValue { Float(f32), diff --git a/components/script/dom/webgltransformfeedback.rs b/components/script/dom/webgltransformfeedback.rs index 3b0b2abf0a2..37c1f5117af 100644 --- a/components/script/dom/webgltransformfeedback.rs +++ b/components/script/dom/webgltransformfeedback.rs @@ -2,14 +2,16 @@ * 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::Cell; + +use canvas_traits::webgl::{webgl_channel, WebGLCommand}; +use dom_struct::dom_struct; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{webgl_channel, WebGLCommand}; -use dom_struct::dom_struct; -use std::cell::Cell; #[dom_struct] pub struct WebGLTransformFeedback { diff --git a/components/script/dom/webgluniformlocation.rs b/components/script/dom/webgluniformlocation.rs index a579743399b..509a42b1b6d 100644 --- a/components/script/dom/webgluniformlocation.rs +++ b/components/script/dom/webgluniformlocation.rs @@ -3,12 +3,12 @@ * 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::{WebGLContextId, WebGLProgramId}; +use dom_struct::dom_struct; + use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; -use canvas_traits::webgl::WebGLContextId; -use canvas_traits::webgl::WebGLProgramId; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLUniformLocation { diff --git a/components/script/dom/webglvertexarrayobject.rs b/components/script/dom/webglvertexarrayobject.rs index 07f53af0316..867513c5459 100644 --- a/components/script/dom/webglvertexarrayobject.rs +++ b/components/script/dom/webglvertexarrayobject.rs @@ -2,6 +2,9 @@ * 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, WebGLResult, WebGLVertexArrayId}; +use dom_struct::dom_struct; + use crate::dom::bindings::cell::Ref; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -9,8 +12,6 @@ use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{ActiveAttribInfo, WebGLResult, WebGLVertexArrayId}; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLVertexArrayObject { diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index 215d39c1a5a..f0e551e753b 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -2,6 +2,9 @@ * 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, WebGLResult, WebGLVertexArrayId}; +use dom_struct::dom_struct; + use crate::dom::bindings::cell::Ref; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -9,8 +12,6 @@ use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; -use canvas_traits::webgl::{ActiveAttribInfo, WebGLResult, WebGLVertexArrayId}; -use dom_struct::dom_struct; #[dom_struct] pub struct WebGLVertexArrayObjectOES { diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 75b30001d21..5486587ce90 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -2,6 +2,25 @@ * 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::borrow::ToOwned; +use std::cell::Cell; +use std::ptr; + +use dom_struct::dom_struct; +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use ipc_channel::router::ROUTER; +use js::jsapi::{JSAutoRealm, JSObject}; +use js::jsval::UndefinedValue; +use js::rust::{CustomAutoRooterGuard, HandleObject}; +use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; +use net_traits::request::{Referrer, RequestBuilder, RequestMode}; +use net_traits::{ + CoreResourceMsg, FetchChannels, MessageData, WebSocketDomAction, WebSocketNetworkEvent, +}; +use profile_traits::ipc as ProfiledIpc; +use script_traits::serializable::BlobImpl; +use servo_url::{ImmutableOrigin, ServoUrl}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMethods}; @@ -24,23 +43,6 @@ use crate::script_runtime::ScriptThreadEventCategory::WebSocketEvent; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::websocket::WebsocketTaskSource; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use ipc_channel::router::ROUTER; -use js::jsapi::{JSAutoRealm, JSObject}; -use js::jsval::UndefinedValue; -use js::rust::{CustomAutoRooterGuard, HandleObject}; -use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; -use net_traits::request::{Referrer, RequestBuilder, RequestMode}; -use net_traits::MessageData; -use net_traits::{CoreResourceMsg, FetchChannels}; -use net_traits::{WebSocketDomAction, WebSocketNetworkEvent}; -use profile_traits::ipc as ProfiledIpc; -use script_traits::serializable::BlobImpl; -use servo_url::{ImmutableOrigin, ServoUrl}; -use std::borrow::ToOwned; -use std::cell::Cell; -use std::ptr; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] enum WebSocketRequestState { diff --git a/components/script/dom/wheelevent.rs b/components/script/dom/wheelevent.rs index 33418a6f868..7cefd845ad4 100644 --- a/components/script/dom/wheelevent.rs +++ b/components/script/dom/wheelevent.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use crate::dom::bindings::codegen::Bindings::WheelEventBinding; use crate::dom::bindings::codegen::Bindings::WheelEventBinding::WheelEventMethods; @@ -14,9 +19,6 @@ use crate::dom::bindings::str::DOMString; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::mouseevent::MouseEvent; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use std::cell::Cell; #[dom_struct] pub struct WheelEvent { diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index b1b3399d823..ce7306e8e1b 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -2,6 +2,84 @@ * 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::borrow::{Cow, ToOwned}; +use std::cell::Cell; +use std::collections::hash_map::Entry; +use std::collections::{HashMap, HashSet}; +use std::default::Default; +use std::io::{stderr, stdout, Write}; +use std::ptr::NonNull; +use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; +use std::{cmp, env, mem}; + +use app_units::Au; +use backtrace::Backtrace; +use base64::Engine; +use bluetooth_traits::BluetoothRequest; +use canvas_traits::webgl::WebGLChan; +use crossbeam_channel::{unbounded, Sender, TryRecvError}; +use cssparser::{Parser, ParserInput, SourceLocation}; +use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; +use dom_struct::dom_struct; +use embedder_traits::{EmbedderMsg, PromptDefinition, PromptOrigin, PromptResult}; +use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect}; +use euclid::{Point2D, Rect, Scale, Size2D, Vector2D}; +use ipc_channel::ipc::IpcSender; +use ipc_channel::router::ROUTER; +use js::conversions::ToJSValConvertible; +use js::jsapi::{GCReason, Heap, JSAutoRealm, JSObject, StackFormat, JSPROP_ENUMERATE, JS_GC}; +use js::jsval::{JSVal, NullValue, UndefinedValue}; +use js::rust::wrappers::JS_DefineProperty; +use js::rust::{ + CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue, MutableHandleObject, +}; +use malloc_size_of::MallocSizeOf; +use media::WindowGLContext; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use net_traits::image_cache::{ + ImageCache, ImageResponder, ImageResponse, PendingImageId, PendingImageResponse, +}; +use net_traits::storage_thread::StorageType; +use net_traits::ResourceThreads; +use num_traits::ToPrimitive; +use parking_lot::Mutex as ParkMutex; +use profile_traits::ipc as ProfiledIpc; +use profile_traits::mem::ProfilerChan as MemProfilerChan; +use profile_traits::time::{ProfilerChan as TimeProfilerChan, ProfilerMsg}; +use script_layout_interface::message::{Msg, QueryMsg, Reflow, ReflowGoal, ScriptReflow}; +use script_layout_interface::rpc::{ + ContentBoxResponse, ContentBoxesResponse, LayoutRPC, NodeScrollIdResponse, + ResolvedStyleResponse, TextIndexResponse, +}; +use script_layout_interface::{PendingImageState, TrustedNodeAddress}; +use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; +use script_traits::{ + ConstellationControlMsg, DocumentState, HistoryEntryReplacement, LoadData, ScriptMsg, + ScriptToConstellationChan, ScrollState, StructuredSerializedData, TimerEventId, + TimerSchedulerMsg, WebrenderIpcSender, WindowSizeData, WindowSizeType, +}; +use selectors::attr::CaseSensitivity; +use servo_arc::Arc as ServoArc; +use servo_atoms::Atom; +use servo_geometry::{f32_rect_to_au_rect, MaxRect}; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; +use style::dom::OpaqueNode; +use style::error_reporting::{ContextualParseError, ParseErrorReporter}; +use style::media_queries; +use style::parser::ParserContext as CssParserContext; +use style::properties::style_structs::Font; +use style::properties::{PropertyId, ShorthandId}; +use style::selector_parser::PseudoElement; +use style::str::HTML_SPACE_CHARACTERS; +use style::stylesheets::{CssRuleType, Origin}; +use style_traits::{CSSPixel, DevicePixel, ParsingMode}; +use url::Position; +use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel}; +use webrender_api::{DocumentId, ExternalScrollId}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ DocumentMethods, DocumentReadyState, @@ -15,9 +93,9 @@ use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryLi use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit; use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction; use crate::dom::bindings::codegen::Bindings::WindowBinding::{ - self, FrameRequestCallback, WindowMethods, WindowPostMessageOptions, + self, FrameRequestCallback, ScrollBehavior, ScrollToOptions, WindowMethods, + WindowPostMessageOptions, }; -use crate::dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions}; use crate::dom::bindings::codegen::UnionTypes::{RequestOrUSVString, StringOrFunction}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; @@ -60,104 +138,21 @@ use crate::dom::webglrenderingcontext::WebGLCommandSender; use crate::dom::windowproxy::WindowProxy; use crate::dom::worklet::Worklet; use crate::dom::workletglobalscope::WorkletGlobalScopeType; -use crate::fetch; use crate::layout_image::fetch_image_for_layout; use crate::microtask::MicrotaskQueue; use crate::realms::InRealm; use crate::script_runtime::{ CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptPort, ScriptThreadEventCategory, }; -use crate::script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg}; -use crate::script_thread::{ScriptThread, SendableMainThreadScriptChan}; +use crate::script_thread::{ + ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg, ScriptThread, + SendableMainThreadScriptChan, +}; use crate::task_manager::TaskManager; use crate::task_source::{TaskSource, TaskSourceName}; use crate::timers::{IsInterval, TimerCallback}; use crate::webdriver_handlers::jsval_to_webdriver; -use crate::window_named_properties; -use app_units::Au; -use backtrace::Backtrace; -use base64::Engine; -use bluetooth_traits::BluetoothRequest; -use canvas_traits::webgl::WebGLChan; -use crossbeam_channel::{unbounded, Sender, TryRecvError}; -use cssparser::{Parser, ParserInput, SourceLocation}; -use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; -use dom_struct::dom_struct; -use embedder_traits::{EmbedderMsg, PromptDefinition, PromptOrigin, PromptResult}; -use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect}; -use euclid::{Point2D, Rect, Scale, Size2D, Vector2D}; -use ipc_channel::ipc::IpcSender; -use ipc_channel::router::ROUTER; -use js::conversions::ToJSValConvertible; -use js::jsapi::Heap; -use js::jsapi::JSAutoRealm; -use js::jsapi::JSObject; -use js::jsapi::JSPROP_ENUMERATE; -use js::jsapi::{GCReason, StackFormat, JS_GC}; -use js::jsval::UndefinedValue; -use js::jsval::{JSVal, NullValue}; -use js::rust::wrappers::JS_DefineProperty; -use js::rust::{ - CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue, MutableHandleObject, -}; -use malloc_size_of::MallocSizeOf; -use media::WindowGLContext; -use msg::constellation_msg::{BrowsingContextId, PipelineId}; -use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse}; -use net_traits::image_cache::{PendingImageId, PendingImageResponse}; -use net_traits::storage_thread::StorageType; -use net_traits::ResourceThreads; -use num_traits::ToPrimitive; -use parking_lot::Mutex as ParkMutex; -use profile_traits::ipc as ProfiledIpc; -use profile_traits::mem::ProfilerChan as MemProfilerChan; -use profile_traits::time::{ProfilerChan as TimeProfilerChan, ProfilerMsg}; -use script_layout_interface::message::{Msg, QueryMsg, Reflow, ReflowGoal, ScriptReflow}; -use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; -use script_layout_interface::rpc::{ - NodeScrollIdResponse, ResolvedStyleResponse, TextIndexResponse, -}; -use script_layout_interface::{PendingImageState, TrustedNodeAddress}; -use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; -use script_traits::{ConstellationControlMsg, DocumentState, HistoryEntryReplacement, LoadData}; -use script_traits::{ - ScriptMsg, ScriptToConstellationChan, ScrollState, StructuredSerializedData, TimerEventId, -}; -use script_traits::{TimerSchedulerMsg, WebrenderIpcSender, WindowSizeData, WindowSizeType}; -use selectors::attr::CaseSensitivity; -use servo_arc::Arc as ServoArc; -use servo_atoms::Atom; -use servo_geometry::{f32_rect_to_au_rect, MaxRect}; -use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; -use std::borrow::Cow; -use std::borrow::ToOwned; -use std::cell::Cell; -use std::cmp; -use std::collections::hash_map::Entry; -use std::collections::{HashMap, HashSet}; -use std::default::Default; -use std::env; -use std::io::{stderr, stdout, Write}; -use std::mem; -use std::ptr::NonNull; -use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; -use style::dom::OpaqueNode; -use style::error_reporting::{ContextualParseError, ParseErrorReporter}; -use style::media_queries; -use style::parser::ParserContext as CssParserContext; -use style::properties::style_structs::Font; -use style::properties::{PropertyId, ShorthandId}; -use style::selector_parser::PseudoElement; -use style::str::HTML_SPACE_CHARACTERS; -use style::stylesheets::{CssRuleType, Origin}; -use style_traits::{CSSPixel, DevicePixel, ParsingMode}; -use url::Position; -use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel}; -use webrender_api::{DocumentId, ExternalScrollId}; - -use super::bindings::trace::HashMapTracedValues; +use crate::{fetch, window_named_properties}; /// Current state of the window object #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index f4aae865000..2d023e02f8a 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -2,6 +2,41 @@ * 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::Cell; +use std::ptr; + +use dom_struct::dom_struct; +use embedder_traits::EmbedderMsg; +use html5ever::local_name; +use indexmap::map::IndexMap; +use ipc_channel::ipc; +use js::glue::{ + CreateWrapperProxyHandler, GetProxyPrivate, GetProxyReservedSlot, ProxyTraps, + SetProxyReservedSlot, +}; +use js::jsapi::{ + GCContext, Handle as RawHandle, HandleId as RawHandleId, HandleObject as RawHandleObject, + HandleValue as RawHandleValue, JSAutoRealm, JSContext, JSErrNum, JSObject, JSTracer, + JS_DefinePropertyById, JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo, + JS_GetOwnPropertyDescriptorById, JS_HasOwnPropertyById, JS_HasPropertyById, + JS_IsExceptionPending, MutableHandle as RawMutableHandle, + MutableHandleObject as RawMutableHandleObject, MutableHandleValue as RawMutableHandleValue, + ObjectOpResult, PropertyDescriptor, JSPROP_ENUMERATE, JSPROP_READONLY, +}; +use js::jsval::{JSVal, NullValue, PrivateValue, UndefinedValue}; +use js::rust::wrappers::{JS_TransplantObject, NewWindowProxy, SetWindowProxy}; +use js::rust::{get_object_class, Handle, MutableHandle}; +use js::JSCLASS_IS_GLOBAL; +use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; +use net_traits::request::Referrer; +use script_traits::{ + AuxiliaryBrowsingContextLoadInfo, HistoryEntryReplacement, LoadData, LoadOrigin, NewLayoutInfo, + ScriptMsg, +}; +use serde::{Deserialize, Serialize}; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style::attr::parse_integer; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::conversions::{root_from_handleobject, ToJSValConvertible}; use crate::dom::bindings::error::{throw_dom_exception, Error, Fallible}; @@ -20,44 +55,6 @@ use crate::dom::window::Window; use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; use crate::script_thread::ScriptThread; -use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; -use html5ever::local_name; -use indexmap::map::IndexMap; -use ipc_channel::ipc; -use js::glue::{CreateWrapperProxyHandler, ProxyTraps}; -use js::glue::{GetProxyPrivate, GetProxyReservedSlot, SetProxyReservedSlot}; -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::MutableHandle as RawMutableHandle; -use js::jsapi::MutableHandleObject as RawMutableHandleObject; -use js::jsapi::MutableHandleValue as RawMutableHandleValue; -use js::jsapi::{GCContext, JSAutoRealm, JSContext, JSErrNum, JSObject}; -use js::jsapi::{JSTracer, JS_DefinePropertyById, JSPROP_ENUMERATE, JSPROP_READONLY}; -use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo}; -use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_IsExceptionPending}; -use js::jsapi::{JS_HasOwnPropertyById, JS_HasPropertyById}; -use js::jsapi::{ObjectOpResult, PropertyDescriptor}; -use js::jsval::{JSVal, NullValue, PrivateValue, UndefinedValue}; -use js::rust::get_object_class; -use js::rust::wrappers::{JS_TransplantObject, NewWindowProxy, SetWindowProxy}; -use js::rust::{Handle, MutableHandle}; -use js::JSCLASS_IS_GLOBAL; -use msg::constellation_msg::BrowsingContextId; -use msg::constellation_msg::PipelineId; -use msg::constellation_msg::TopLevelBrowsingContextId; -use net_traits::request::Referrer; -use script_traits::{ - AuxiliaryBrowsingContextLoadInfo, HistoryEntryReplacement, LoadData, LoadOrigin, -}; -use script_traits::{NewLayoutInfo, ScriptMsg}; -use serde::{Deserialize, Serialize}; -use servo_url::{ImmutableOrigin, ServoUrl}; -use std::cell::Cell; -use std::ptr; -use style::attr::parse_integer; #[dom_struct] // NOTE: the browsing context for a window is managed in two places: diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 321474f31ee..7899da4b471 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -2,8 +2,21 @@ * 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::abstractworker::SimpleWorkerErrorHandler; -use crate::dom::abstractworker::WorkerScriptMsg; +use std::cell::Cell; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +use crossbeam_channel::{unbounded, Sender}; +use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg, WorkerId}; +use dom_struct::dom_struct; +use ipc_channel::ipc; +use js::jsapi::{Heap, JSObject}; +use js::jsval::UndefinedValue; +use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue}; +use script_traits::{StructuredSerializedData, WorkerScriptLoadOrigin}; +use uuid::Uuid; + +use crate::dom::abstractworker::{SimpleWorkerErrorHandler, WorkerScriptMsg}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions; use crate::dom::bindings::codegen::Bindings::WorkerBinding::{WorkerMethods, WorkerOptions}; @@ -26,18 +39,6 @@ use crate::dom::workerglobalscope::prepare_workerscope_init; use crate::realms::enter_realm; use crate::script_runtime::{ContextForRequestInterrupt, JSContext}; use crate::task::TaskOnce; -use crossbeam_channel::{unbounded, Sender}; -use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg, WorkerId}; -use dom_struct::dom_struct; -use ipc_channel::ipc; -use js::jsapi::{Heap, JSObject}; -use js::jsval::UndefinedValue; -use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue}; -use script_traits::{StructuredSerializedData, WorkerScriptLoadOrigin}; -use std::cell::Cell; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use uuid::Uuid; pub type TrustedWorkerAddress = Trusted<Worker>; diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index a41946926db..eb9b200a935 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -2,6 +2,29 @@ * 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::default::Default; +use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +use crossbeam_channel::Receiver; +use devtools_traits::{DevtoolScriptControlMsg, WorkerId}; +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use js::jsval::UndefinedValue; +use js::panic::maybe_resume_unwind; +use js::rust::{HandleValue, ParentRuntime}; +use msg::constellation_msg::{PipelineId, PipelineNamespace}; +use net_traits::request::{ + CredentialsMode, Destination, ParserMetadata, RequestBuilder as NetRequestInit, +}; +use net_traits::IpcSend; +use parking_lot::Mutex; +use script_traits::WorkerGlobalScopeInit; +use servo_url::{MutableOrigin, ServoUrl}; +use time::precise_time_ns; +use uuid::Uuid; + use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::{ ImageBitmapOptions, ImageBitmapSource, @@ -30,8 +53,10 @@ use crate::dom::workerlocation::WorkerLocation; use crate::dom::workernavigator::WorkerNavigator; use crate::fetch; use crate::realms::{enter_realm, InRealm}; -use crate::script_runtime::{get_reports, CommonScriptMsg, Runtime, ScriptChan, ScriptPort}; -use crate::script_runtime::{ContextForRequestInterrupt, JSContext}; +use crate::script_runtime::{ + get_reports, CommonScriptMsg, ContextForRequestInterrupt, JSContext, Runtime, ScriptChan, + ScriptPort, +}; use crate::task::TaskCanceller; use crate::task_source::dom_manipulation::DOMManipulationTaskSource; use crate::task_source::file_reading::FileReadingTaskSource; @@ -42,27 +67,6 @@ use crate::task_source::remote_event::RemoteEventTaskSource; use crate::task_source::timer::TimerTaskSource; use crate::task_source::websocket::WebsocketTaskSource; use crate::timers::{IsInterval, TimerCallback}; -use crossbeam_channel::Receiver; -use devtools_traits::{DevtoolScriptControlMsg, WorkerId}; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; -use js::jsval::UndefinedValue; -use js::panic::maybe_resume_unwind; -use js::rust::{HandleValue, ParentRuntime}; -use msg::constellation_msg::{PipelineId, PipelineNamespace}; -use net_traits::request::{ - CredentialsMode, Destination, ParserMetadata, RequestBuilder as NetRequestInit, -}; -use net_traits::IpcSend; -use parking_lot::Mutex; -use script_traits::WorkerGlobalScopeInit; -use servo_url::{MutableOrigin, ServoUrl}; -use std::default::Default; -use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use time::precise_time_ns; -use uuid::Uuid; pub fn prepare_workerscope_init( global: &GlobalScope, diff --git a/components/script/dom/workerlocation.rs b/components/script/dom/workerlocation.rs index cbe7996899c..a592dfe0154 100644 --- a/components/script/dom/workerlocation.rs +++ b/components/script/dom/workerlocation.rs @@ -2,14 +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 dom_struct::dom_struct; +use servo_url::{ImmutableOrigin, ServoUrl}; + use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; use crate::dom::urlhelper::UrlHelper; use crate::dom::workerglobalscope::WorkerGlobalScope; -use dom_struct::dom_struct; -use servo_url::{ImmutableOrigin, ServoUrl}; // https://html.spec.whatwg.org/multipage/#worker-locations #[dom_struct] diff --git a/components/script/dom/workernavigator.rs b/components/script/dom/workernavigator.rs index 7f7b656068f..ba7da3fa783 100644 --- a/components/script/dom/workernavigator.rs +++ b/components/script/dom/workernavigator.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use js::jsval::JSVal; + use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -12,8 +15,6 @@ use crate::dom::navigatorinfo; use crate::dom::permissions::Permissions; use crate::dom::workerglobalscope::WorkerGlobalScope; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsval::JSVal; // https://html.spec.whatwg.org/multipage/#workernavigator #[dom_struct] diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index 75acc13c650..67c0f053dbb 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -10,62 +10,48 @@ //! thread pool implementation, which only performs GC or code loading on //! a backup thread, not on the primary worklet thread. +use std::cmp::max; +use std::collections::{hash_map, HashMap}; +use std::rc::Rc; +use std::sync::atomic::{AtomicIsize, Ordering}; +use std::sync::Arc; +use std::thread; + +use crossbeam_channel::{unbounded, Receiver, Sender}; +use dom_struct::dom_struct; +use js::jsapi::{GCReason, JSGCParamKey, JSTracer, JS_GetGCParameter, JS_GC}; +use malloc_size_of::malloc_size_of_is_0; +use msg::constellation_msg::PipelineId; +use net_traits::request::{Destination, RequestBuilder, RequestMode}; +use net_traits::IpcSend; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style::thread_state::{self, ThreadState}; +use swapper::{swapper, Swapper}; +use uuid::Uuid; + use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletMethods; -use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; +use crate::dom::bindings::codegen::Bindings::WorkletBinding::{WorkletMethods, WorkletOptions}; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::TrustedPromise; -use crate::dom::bindings::reflector::reflect_dom_object; -use crate::dom::bindings::reflector::Reflector; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, RootCollection, ThreadLocalStackRoots}; use crate::dom::bindings::str::USVString; -use crate::dom::bindings::trace::JSTraceable; -use crate::dom::bindings::trace::RootedTraceableBox; +use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox}; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::dom::testworkletglobalscope::TestWorkletTask; use crate::dom::window::Window; -use crate::dom::workletglobalscope::WorkletGlobalScope; -use crate::dom::workletglobalscope::WorkletGlobalScopeInit; -use crate::dom::workletglobalscope::WorkletGlobalScopeType; -use crate::dom::workletglobalscope::WorkletTask; +use crate::dom::workletglobalscope::{ + WorkletGlobalScope, WorkletGlobalScopeInit, WorkletGlobalScopeType, WorkletTask, +}; use crate::fetch::load_whole_resource; use crate::realms::InRealm; -use crate::script_runtime::new_rt_and_cx; -use crate::script_runtime::CommonScriptMsg; -use crate::script_runtime::Runtime; -use crate::script_runtime::ScriptThreadEventCategory; +use crate::script_runtime::{new_rt_and_cx, CommonScriptMsg, Runtime, ScriptThreadEventCategory}; use crate::script_thread::{MainThreadScriptMsg, ScriptThread}; use crate::task::TaskBox; use crate::task_source::TaskSourceName; -use crossbeam_channel::{unbounded, Receiver, Sender}; -use dom_struct::dom_struct; -use js::jsapi::JSGCParamKey; -use js::jsapi::JSTracer; -use js::jsapi::JS_GetGCParameter; -use js::jsapi::{GCReason, JS_GC}; -use malloc_size_of::malloc_size_of_is_0; -use msg::constellation_msg::PipelineId; -use net_traits::request::Destination; -use net_traits::request::RequestBuilder; -use net_traits::request::RequestMode; -use net_traits::IpcSend; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; -use std::cmp::max; -use std::collections::hash_map; -use std::collections::HashMap; -use std::rc::Rc; -use std::sync::atomic::AtomicIsize; -use std::sync::atomic::Ordering; -use std::sync::Arc; -use std::thread; -use style::thread_state::{self, ThreadState}; -use swapper::swapper; -use swapper::Swapper; -use uuid::Uuid; // Magic numbers const WORKLET_THREAD_POOL_SIZE: u32 = 3; diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index 888a2058bc3..0e9a31a57a4 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -2,18 +2,9 @@ * 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::inheritance::Castable; -use crate::dom::bindings::root::DomRoot; -use crate::dom::globalscope::GlobalScope; -use crate::dom::identityhub::Identities; -use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; -use crate::dom::paintworkletglobalscope::PaintWorkletTask; -use crate::dom::testworkletglobalscope::TestWorkletGlobalScope; -use crate::dom::testworkletglobalscope::TestWorkletTask; -use crate::dom::worklet::WorkletExecutor; -use crate::script_module::ScriptFetchOptions; -use crate::script_runtime::JSContext; -use crate::script_thread::MainThreadScriptMsg; +use std::borrow::Cow; +use std::sync::Arc; + use crossbeam_channel::Sender; use devtools_traits::ScriptToDevtoolsControlMsg; use dom_struct::dom_struct; @@ -24,16 +15,21 @@ use msg::constellation_msg::PipelineId; use net_traits::image_cache::ImageCache; use net_traits::ResourceThreads; use parking_lot::Mutex; -use profile_traits::mem; -use profile_traits::time; -use script_traits::{Painter, ScriptMsg}; -use script_traits::{ScriptToConstellationChan, TimerSchedulerMsg}; +use profile_traits::{mem, time}; +use script_traits::{Painter, ScriptMsg, ScriptToConstellationChan, TimerSchedulerMsg}; use servo_atoms::Atom; -use servo_url::ImmutableOrigin; -use servo_url::MutableOrigin; -use servo_url::ServoUrl; -use std::borrow::Cow; -use std::sync::Arc; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; + +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::root::DomRoot; +use crate::dom::globalscope::GlobalScope; +use crate::dom::identityhub::Identities; +use crate::dom::paintworkletglobalscope::{PaintWorkletGlobalScope, PaintWorkletTask}; +use crate::dom::testworkletglobalscope::{TestWorkletGlobalScope, TestWorkletTask}; +use crate::dom::worklet::WorkletExecutor; +use crate::script_module::ScriptFetchOptions; +use crate::script_runtime::JSContext; +use crate::script_thread::MainThreadScriptMsg; #[dom_struct] /// <https://drafts.css-houdini.org/worklets/#workletglobalscope> diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs index f4908922ec3..389a1aa9cd4 100644 --- a/components/script/dom/xmldocument.rs +++ b/components/script/dom/xmldocument.rs @@ -2,6 +2,14 @@ * 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::ptr::NonNull; + +use dom_struct::dom_struct; +use js::jsapi::JSObject; +use mime::Mime; +use script_traits::DocumentActivity; +use servo_url::{MutableOrigin, ServoUrl}; + use crate::document_loader::DocumentLoader; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::XMLDocumentMethods; @@ -14,12 +22,6 @@ use crate::dom::location::Location; use crate::dom::node::Node; use crate::dom::window::Window; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsapi::JSObject; -use mime::Mime; -use script_traits::DocumentActivity; -use servo_url::{MutableOrigin, ServoUrl}; -use std::ptr::NonNull; // https://dom.spec.whatwg.org/#xmldocument #[dom_struct] diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 669edfb1c71..48c55d44717 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -2,12 +2,50 @@ * 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::borrow::ToOwned; +use std::cell::Cell; +use std::default::Default; +use std::ptr::NonNull; +use std::str::{self, FromStr}; +use std::sync::{Arc, Mutex}; +use std::{cmp, ptr, slice}; + +use dom_struct::dom_struct; +use encoding_rs::{Encoding, UTF_8}; +use euclid::Length; +use headers::{ContentLength, ContentType, HeaderMapExt}; +use html5ever::serialize; +use html5ever::serialize::SerializeOpts; +use http::header::{self, HeaderMap, HeaderName, HeaderValue}; +use http::Method; +use hyper_serde::Serde; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::jsapi::{Heap, JSObject, JS_ClearPendingException}; +use js::jsval::{JSVal, NullValue, UndefinedValue}; +use js::rust::wrappers::JS_ParseJSON; +use js::rust::HandleObject; +use js::typedarray::{ArrayBuffer, CreateWith}; +use mime::{self, Mime, Name}; +use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder, RequestMode}; +use net_traits::CoreResourceMsg::Fetch; +use net_traits::{ + trim_http_whitespace, FetchChannels, FetchMetadata, FetchResponseListener, FilteredMetadata, + NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceTimingType, +}; +use script_traits::serializable::BlobImpl; +use script_traits::DocumentActivity; +use servo_atoms::Atom; +use servo_url::ServoUrl; +use url::Position; + use crate::body::{BodySource, Extractable, ExtractedBody}; use crate::document_loader::DocumentLoader; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestMethods; -use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestResponseType; +use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::{ + XMLHttpRequestMethods, XMLHttpRequestResponseType, +}; use crate::dom::bindings::codegen::UnionTypes::DocumentOrXMLHttpRequestBodyInit; use crate::dom::bindings::conversions::ToJSValConvertible; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -17,8 +55,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::{is_token, ByteString, DOMString, USVString}; use crate::dom::blob::{normalize_type_string, Blob}; -use crate::dom::document::DocumentSource; -use crate::dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; +use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; @@ -38,44 +75,6 @@ use crate::script_runtime::JSContext; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::TaskSourceName; use crate::timers::{OneshotTimerCallback, OneshotTimerHandle}; -use dom_struct::dom_struct; -use encoding_rs::{Encoding, UTF_8}; -use euclid::Length; -use headers::{ContentLength, ContentType, HeaderMapExt}; -use html5ever::serialize; -use html5ever::serialize::SerializeOpts; -use http::header::{self, HeaderMap, HeaderName, HeaderValue}; -use http::Method; -use hyper_serde::Serde; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::jsapi::JS_ClearPendingException; -use js::jsapi::{Heap, JSObject}; -use js::jsval::{JSVal, NullValue, UndefinedValue}; -use js::rust::wrappers::JS_ParseJSON; -use js::rust::HandleObject; -use js::typedarray::{ArrayBuffer, CreateWith}; -use mime::{self, Mime, Name}; -use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder, RequestMode}; -use net_traits::trim_http_whitespace; -use net_traits::CoreResourceMsg::Fetch; -use net_traits::{FetchChannels, FetchMetadata, FilteredMetadata}; -use net_traits::{FetchResponseListener, NetworkError, ReferrerPolicy}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use script_traits::serializable::BlobImpl; -use script_traits::DocumentActivity; -use servo_atoms::Atom; -use servo_url::ServoUrl; -use std::borrow::ToOwned; -use std::cell::Cell; -use std::cmp; -use std::default::Default; -use std::ptr; -use std::ptr::NonNull; -use std::slice; -use std::str::{self, FromStr}; -use std::sync::{Arc, Mutex}; -use url::Position; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] enum XMLHttpRequestState { diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 44f0fb7c1fc..af33da13b0c 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -2,9 +2,10 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::XMLHttpRequestEventTargetBinding::XMLHttpRequestEventTargetMethods; use crate::dom::eventtarget::EventTarget; -use dom_struct::dom_struct; #[dom_struct] pub struct XMLHttpRequestEventTarget { diff --git a/components/script/dom/xmlhttprequestupload.rs b/components/script/dom/xmlhttprequestupload.rs index 7e7b5893395..47ebae74a5a 100644 --- a/components/script/dom/xmlhttprequestupload.rs +++ b/components/script/dom/xmlhttprequestupload.rs @@ -2,11 +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 dom_struct::dom_struct; + use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget; -use dom_struct::dom_struct; #[dom_struct] pub struct XMLHttpRequestUpload { diff --git a/components/script/dom/xmlserializer.rs b/components/script/dom/xmlserializer.rs index 55f0753d8f4..dfbd49e306d 100644 --- a/components/script/dom/xmlserializer.rs +++ b/components/script/dom/xmlserializer.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use xml5ever::serialize::{serialize, SerializeOpts, TraversalScope}; + use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding::XMLSerializerMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; @@ -9,9 +13,6 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::node::Node; use crate::dom::window::Window; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use xml5ever::serialize::{serialize, SerializeOpts, TraversalScope}; #[dom_struct] pub struct XMLSerializer { diff --git a/components/script/dom/xrcompositionlayer.rs b/components/script/dom/xrcompositionlayer.rs index 5a4aa85d2fa..fbb71149716 100644 --- a/components/script/dom/xrcompositionlayer.rs +++ b/components/script/dom/xrcompositionlayer.rs @@ -2,9 +2,10 @@ * 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::xrlayer::XRLayer; use dom_struct::dom_struct; +use crate::dom::xrlayer::XRLayer; + #[dom_struct] pub struct XRCompositionLayer { xr_layer: XRLayer, diff --git a/components/script/dom/xrcubelayer.rs b/components/script/dom/xrcubelayer.rs index 71296ddc238..587d088e88b 100644 --- a/components/script/dom/xrcubelayer.rs +++ b/components/script/dom/xrcubelayer.rs @@ -2,9 +2,10 @@ * 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::xrcompositionlayer::XRCompositionLayer; use dom_struct::dom_struct; +use crate::dom::xrcompositionlayer::XRCompositionLayer; + #[dom_struct] pub struct XRCubeLayer { composition_layer: XRCompositionLayer, diff --git a/components/script/dom/xrcylinderlayer.rs b/components/script/dom/xrcylinderlayer.rs index 2abe935f525..f468380bb36 100644 --- a/components/script/dom/xrcylinderlayer.rs +++ b/components/script/dom/xrcylinderlayer.rs @@ -2,9 +2,10 @@ * 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::xrcompositionlayer::XRCompositionLayer; use dom_struct::dom_struct; +use crate::dom::xrcompositionlayer::XRCompositionLayer; + #[dom_struct] pub struct XRCylinderLayer { composition_layer: XRCompositionLayer, diff --git a/components/script/dom/xrequirectlayer.rs b/components/script/dom/xrequirectlayer.rs index d6da61a5a9c..25cc04595ef 100644 --- a/components/script/dom/xrequirectlayer.rs +++ b/components/script/dom/xrequirectlayer.rs @@ -2,9 +2,10 @@ * 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::xrcompositionlayer::XRCompositionLayer; use dom_struct::dom_struct; +use crate::dom::xrcompositionlayer::XRCompositionLayer; + #[dom_struct] pub struct XREquirectLayer { composition_layer: XRCompositionLayer, diff --git a/components/script/dom/xrframe.rs b/components/script/dom/xrframe.rs index 6274ca78387..7afb14d6453 100644 --- a/components/script/dom/xrframe.rs +++ b/components/script/dom/xrframe.rs @@ -2,6 +2,11 @@ * 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::Cell; + +use dom_struct::dom_struct; +use webxr_api::{Frame, LayerId, SubImages}; + use crate::dom::bindings::codegen::Bindings::XRFrameBinding::XRFrameMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; @@ -17,11 +22,6 @@ use crate::dom::xrreferencespace::XRReferenceSpace; use crate::dom::xrsession::{ApiPose, XRSession}; use crate::dom::xrspace::XRSpace; use crate::dom::xrviewerpose::XRViewerPose; -use dom_struct::dom_struct; -use std::cell::Cell; -use webxr_api::Frame; -use webxr_api::LayerId; -use webxr_api::SubImages; #[dom_struct] pub struct XRFrame { diff --git a/components/script/dom/xrhand.rs b/components/script/dom/xrhand.rs index 1d04083c7aa..6d232587f2e 100644 --- a/components/script/dom/xrhand.rs +++ b/components/script/dom/xrhand.rs @@ -2,14 +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 dom_struct::dom_struct; +use webxr_api::{FingerJoint, Hand, Joint}; + use crate::dom::bindings::codegen::Bindings::XRHandBinding::{XRHandConstants, XRHandMethods}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrjointspace::XRJointSpace; -use dom_struct::dom_struct; -use webxr_api::{FingerJoint, Hand, Joint}; #[dom_struct] pub struct XRHand { diff --git a/components/script/dom/xrhittestresult.rs b/components/script/dom/xrhittestresult.rs index dd35043e187..e7e6c9713b4 100644 --- a/components/script/dom/xrhittestresult.rs +++ b/components/script/dom/xrhittestresult.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use webxr_api::HitTestResult; + use crate::dom::bindings::codegen::Bindings::XRHitTestResultBinding::XRHitTestResultMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -9,8 +12,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::xrframe::XRFrame; use crate::dom::xrpose::XRPose; use crate::dom::xrspace::XRSpace; -use dom_struct::dom_struct; -use webxr_api::HitTestResult; #[dom_struct] pub struct XRHitTestResult { diff --git a/components/script/dom/xrhittestsource.rs b/components/script/dom/xrhittestsource.rs index 913193cfae3..d816a4415db 100644 --- a/components/script/dom/xrhittestsource.rs +++ b/components/script/dom/xrhittestsource.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use webxr_api::HitTestId; + use crate::dom::bindings::codegen::Bindings::XRHitTestSourceBinding::XRHitTestSourceMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::xrsession::XRSession; -use dom_struct::dom_struct; -use webxr_api::HitTestId; #[dom_struct] pub struct XRHitTestSource { diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs index 8b3f3f793e4..3317c2a014d 100644 --- a/components/script/dom/xrinputsource.rs +++ b/components/script/dom/xrinputsource.rs @@ -2,6 +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 dom_struct::dom_struct; +use js::conversions::ToJSValConvertible; +use js::jsapi::Heap; +use js::jsval::{JSVal, UndefinedValue}; +use webxr_api::{Handedness, InputId, InputSource, TargetRayMode}; + use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ XRHandedness, XRInputSourceMethods, XRTargetRayMode, }; @@ -13,11 +19,6 @@ use crate::dom::xrsession::XRSession; use crate::dom::xrspace::XRSpace; use crate::realms::enter_realm; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::conversions::ToJSValConvertible; -use js::jsapi::Heap; -use js::jsval::{JSVal, UndefinedValue}; -use webxr_api::{Handedness, InputId, InputSource, TargetRayMode}; #[dom_struct] pub struct XRInputSource { diff --git a/components/script/dom/xrinputsourcearray.rs b/components/script/dom/xrinputsourcearray.rs index b26f7bd3da7..c293aad549a 100644 --- a/components/script/dom/xrinputsourcearray.rs +++ b/components/script/dom/xrinputsourcearray.rs @@ -2,6 +2,9 @@ * 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 dom_struct::dom_struct; +use webxr_api::{InputId, InputSource}; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::XRInputSourceArrayBinding::XRInputSourceArrayMethods; use crate::dom::bindings::inheritance::Castable; @@ -12,8 +15,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrinputsourceschangeevent::XRInputSourcesChangeEvent; use crate::dom::xrsession::XRSession; -use dom_struct::dom_struct; -use webxr_api::{InputId, InputSource}; #[dom_struct] pub struct XRInputSourceArray { diff --git a/components/script/dom/xrinputsourceevent.rs b/components/script/dom/xrinputsourceevent.rs index 836aa8f981e..aff56aa59e7 100644 --- a/components/script/dom/xrinputsourceevent.rs +++ b/components/script/dom/xrinputsourceevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::XRInputSourceEventBinding::{ self, XRInputSourceEventMethods, @@ -16,9 +20,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::dom::xrframe::XRFrame; use crate::dom::xrinputsource::XRInputSource; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct XRInputSourceEvent { diff --git a/components/script/dom/xrinputsourceschangeevent.rs b/components/script/dom/xrinputsourceschangeevent.rs index ae2fcdfa45f..16a47cca8dc 100644 --- a/components/script/dom/xrinputsourceschangeevent.rs +++ b/components/script/dom/xrinputsourceschangeevent.rs @@ -2,6 +2,13 @@ * 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 dom_struct::dom_struct; +use js::conversions::ToJSValConvertible; +use js::jsapi::Heap; +use js::jsval::{JSVal, UndefinedValue}; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::XRInputSourcesChangeEventBinding::{ self, XRInputSourcesChangeEventMethods, @@ -17,12 +24,6 @@ use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrsession::XRSession; use crate::realms::enter_realm; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::conversions::ToJSValConvertible; -use js::jsapi::Heap; -use js::jsval::{JSVal, UndefinedValue}; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct XRInputSourcesChangeEvent { diff --git a/components/script/dom/xrjointpose.rs b/components/script/dom/xrjointpose.rs index c4b610b3327..d889cb7bb14 100644 --- a/components/script/dom/xrjointpose.rs +++ b/components/script/dom/xrjointpose.rs @@ -2,6 +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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::XRJointPoseBinding::XRJointPoseMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; @@ -10,7 +12,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::xrpose::XRPose; use crate::dom::xrrigidtransform::XRRigidTransform; use crate::dom::xrsession::ApiRigidTransform; -use dom_struct::dom_struct; #[dom_struct] pub struct XRJointPose { diff --git a/components/script/dom/xrjointspace.rs b/components/script/dom/xrjointspace.rs index 57b0b88f761..34750b7814b 100644 --- a/components/script/dom/xrjointspace.rs +++ b/components/script/dom/xrjointspace.rs @@ -2,14 +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 dom_struct::dom_struct; +use euclid::RigidTransform3D; +use webxr_api::{BaseSpace, Frame, InputId, Joint, JointFrame, Space}; + use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::dom::xrsession::{ApiPose, XRSession}; use crate::dom::xrspace::XRSpace; -use dom_struct::dom_struct; -use euclid::RigidTransform3D; -use webxr_api::{BaseSpace, Frame, InputId, Joint, JointFrame, Space}; #[dom_struct] pub struct XRJointSpace { diff --git a/components/script/dom/xrlayer.rs b/components/script/dom/xrlayer.rs index 7319eb482dd..3dc3b4dfeea 100644 --- a/components/script/dom/xrlayer.rs +++ b/components/script/dom/xrlayer.rs @@ -2,6 +2,10 @@ * 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::WebGLContextId; +use dom_struct::dom_struct; +use webxr_api::LayerId; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::Dom; use crate::dom::eventtarget::EventTarget; @@ -9,9 +13,6 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::xrframe::XRFrame; use crate::dom::xrsession::XRSession; use crate::dom::xrwebgllayer::XRWebGLLayer; -use canvas_traits::webgl::WebGLContextId; -use dom_struct::dom_struct; -use webxr_api::LayerId; #[dom_struct] pub struct XRLayer { diff --git a/components/script/dom/xrlayerevent.rs b/components/script/dom/xrlayerevent.rs index 6671a4d1f10..c2f15ee3959 100644 --- a/components/script/dom/xrlayerevent.rs +++ b/components/script/dom/xrlayerevent.rs @@ -2,19 +2,20 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::XRLayerEventBinding::XRLayerEventInit; -use crate::dom::bindings::codegen::Bindings::XRLayerEventBinding::XRLayerEventMethods; +use crate::dom::bindings::codegen::Bindings::XRLayerEventBinding::{ + XRLayerEventInit, XRLayerEventMethods, +}; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; use crate::dom::window::Window; use crate::dom::xrlayer::XRLayer; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; // https://w3c.github.io/uievents/#interface-uievent #[dom_struct] diff --git a/components/script/dom/xrmediabinding.rs b/components/script/dom/xrmediabinding.rs index 045d4812c1c..c65ce882c65 100644 --- a/components/script/dom/xrmediabinding.rs +++ b/components/script/dom/xrmediabinding.rs @@ -2,22 +2,20 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::XRMediaBindingBinding::XRMediaBindingBinding::XRMediaBindingMethods; use crate::dom::bindings::codegen::Bindings::XRMediaBindingBinding::XRMediaLayerInit; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::Reflector; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::error::{Error, Fallible}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::htmlvideoelement::HTMLVideoElement; use crate::dom::window::Window; use crate::dom::xrcylinderlayer::XRCylinderLayer; use crate::dom::xrequirectlayer::XREquirectLayer; use crate::dom::xrquadlayer::XRQuadLayer; use crate::dom::xrsession::XRSession; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct XRMediaBinding { diff --git a/components/script/dom/xrpose.rs b/components/script/dom/xrpose.rs index bc9fb3a4be5..90b9629757e 100644 --- a/components/script/dom/xrpose.rs +++ b/components/script/dom/xrpose.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::XRPoseBinding::XRPoseMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::xrrigidtransform::XRRigidTransform; use crate::dom::xrsession::ApiRigidTransform; -use dom_struct::dom_struct; #[dom_struct] pub struct XRPose { diff --git a/components/script/dom/xrprojectionlayer.rs b/components/script/dom/xrprojectionlayer.rs index f5d6f68de67..489c3a9e706 100644 --- a/components/script/dom/xrprojectionlayer.rs +++ b/components/script/dom/xrprojectionlayer.rs @@ -2,9 +2,10 @@ * 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::xrcompositionlayer::XRCompositionLayer; use dom_struct::dom_struct; +use crate::dom::xrcompositionlayer::XRCompositionLayer; + #[dom_struct] pub struct XRProjectionLayer { composition_layer: XRCompositionLayer, diff --git a/components/script/dom/xrquadlayer.rs b/components/script/dom/xrquadlayer.rs index 86358a7d7b5..dd93aea9c0a 100644 --- a/components/script/dom/xrquadlayer.rs +++ b/components/script/dom/xrquadlayer.rs @@ -2,9 +2,10 @@ * 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::xrcompositionlayer::XRCompositionLayer; use dom_struct::dom_struct; +use crate::dom::xrcompositionlayer::XRCompositionLayer; + #[dom_struct] pub struct XRQuadLayer { composition_layer: XRCompositionLayer, diff --git a/components/script/dom/xrray.rs b/components/script/dom/xrray.rs index 1847e985362..1bb925a03a1 100644 --- a/components/script/dom/xrray.rs +++ b/components/script/dom/xrray.rs @@ -2,6 +2,14 @@ * 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::ptr::NonNull; + +use dom_struct::dom_struct; +use euclid::{Angle, RigidTransform3D, Rotation3D, Vector3D}; +use js::jsapi::{Heap, JSObject}; +use js::rust::HandleObject; +use webxr_api::{ApiSpace, Ray}; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use crate::dom::bindings::codegen::Bindings::XRRayBinding::{XRRayDirectionInit, XRRayMethods}; use crate::dom::bindings::error::{Error, Fallible}; @@ -13,12 +21,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::dom::xrrigidtransform::XRRigidTransform; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use euclid::{Angle, RigidTransform3D, Rotation3D, Vector3D}; -use js::jsapi::{Heap, JSObject}; -use js::rust::HandleObject; -use std::ptr::NonNull; -use webxr_api::{ApiSpace, Ray}; #[dom_struct] pub struct XRRay { diff --git a/components/script/dom/xrreferencespace.rs b/components/script/dom/xrreferencespace.rs index 1bd368c5834..52dab15f7bb 100644 --- a/components/script/dom/xrreferencespace.rs +++ b/components/script/dom/xrreferencespace.rs @@ -2,8 +2,13 @@ * 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::XRReferenceSpaceBinding::XRReferenceSpaceMethods; -use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType; +use dom_struct::dom_struct; +use euclid::RigidTransform3D; +use webxr_api::{self, Frame, Space}; + +use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::{ + XRReferenceSpaceMethods, XRReferenceSpaceType, +}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -11,9 +16,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::xrrigidtransform::XRRigidTransform; use crate::dom::xrsession::{cast_transform, ApiPose, BaseTransform, XRSession}; use crate::dom::xrspace::XRSpace; -use dom_struct::dom_struct; -use euclid::RigidTransform3D; -use webxr_api::{self, Frame, Space}; #[dom_struct] pub struct XRReferenceSpace { diff --git a/components/script/dom/xrrenderstate.rs b/components/script/dom/xrrenderstate.rs index 71e6d873814..efbb5c43b34 100644 --- a/components/script/dom/xrrenderstate.rs +++ b/components/script/dom/xrrenderstate.rs @@ -2,21 +2,22 @@ * 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::Cell; + +use dom_struct::dom_struct; +use js::jsval::JSVal; +use webxr_api::SubImages; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::{DomRoot, MutNullableDom}; +use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::utils::to_frozen_array; use crate::dom::globalscope::GlobalScope; use crate::dom::xrlayer::XRLayer; use crate::dom::xrwebgllayer::XRWebGLLayer; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use js::jsval::JSVal; -use std::cell::Cell; -use webxr_api::SubImages; #[dom_struct] pub struct XRRenderState { diff --git a/components/script/dom/xrrigidtransform.rs b/components/script/dom/xrrigidtransform.rs index 1ee7f4304ea..3fabb23a297 100644 --- a/components/script/dom/xrrigidtransform.rs +++ b/components/script/dom/xrrigidtransform.rs @@ -2,12 +2,17 @@ * 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::ptr::NonNull; + +use dom_struct::dom_struct; +use euclid::{RigidTransform3D, Rotation3D, Vector3D}; +use js::jsapi::{Heap, JSObject}; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; +use crate::dom::bindings::error::{Error, Fallible}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::utils::create_typed_array; use crate::dom::dompointreadonly::DOMPointReadOnly; @@ -15,11 +20,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::dom::xrsession::ApiRigidTransform; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use euclid::{RigidTransform3D, Rotation3D, Vector3D}; -use js::jsapi::{Heap, JSObject}; -use js::rust::HandleObject; -use std::ptr::NonNull; #[dom_struct] pub struct XRRigidTransform { diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 0afa821211f..dec495b2c82 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -2,19 +2,38 @@ * 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::Cell; +use std::f64::consts::{FRAC_PI_2, PI}; +use std::mem; +use std::rc::Rc; + +use dom_struct::dom_struct; +use euclid::{RigidTransform3D, Transform3D, Vector3D}; +use ipc_channel::ipc::IpcReceiver; +use ipc_channel::router::ROUTER; +use metrics::ToMs; +use profile_traits::ipc; +use webxr_api::{ + self, util, ApiSpace, ContextId as WebXRContextId, Display, EntityTypes, EnvironmentBlendMode, + Event as XREvent, Frame, FrameUpdateEvent, HitTestId, HitTestSource, Ray, SelectEvent, + SelectKind, Session, SessionId, View, Viewer, Visibility, +}; + +use super::bindings::trace::HashMapTracedValues; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::Bindings::XRHitTestSourceBinding::XRHitTestOptionsInit; -use crate::dom::bindings::codegen::Bindings::XRHitTestSourceBinding::XRHitTestTrackableType; +use crate::dom::bindings::codegen::Bindings::XRHitTestSourceBinding::{ + XRHitTestOptionsInit, XRHitTestTrackableType, +}; use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType; -use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateInit; -use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateMethods; -use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XREnvironmentBlendMode; -use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCallback; -use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods; -use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState; +use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::{ + XRRenderStateInit, XRRenderStateMethods, +}; +use crate::dom::bindings::codegen::Bindings::XRSessionBinding::{ + XREnvironmentBlendMode, XRFrameRequestCallback, XRSessionMethods, XRVisibilityState, +}; use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionMode; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::inheritance::Castable; @@ -36,24 +55,6 @@ use crate::dom::xrsessionevent::XRSessionEvent; use crate::dom::xrspace::XRSpace; use crate::realms::InRealm; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use euclid::{RigidTransform3D, Transform3D, Vector3D}; -use ipc_channel::ipc::IpcReceiver; -use ipc_channel::router::ROUTER; -use metrics::ToMs; -use profile_traits::ipc; -use std::cell::Cell; -use std::f64::consts::{FRAC_PI_2, PI}; -use std::mem; -use std::rc::Rc; -use webxr_api::ContextId as WebXRContextId; -use webxr_api::{ - self, util, ApiSpace, Display, EntityTypes, EnvironmentBlendMode, Event as XREvent, Frame, - FrameUpdateEvent, HitTestId, HitTestSource, Ray, SelectEvent, SelectKind, Session, SessionId, - View, Viewer, Visibility, -}; - -use super::bindings::trace::HashMapTracedValues; #[dom_struct] pub struct XRSession { diff --git a/components/script/dom/xrsessionevent.rs b/components/script/dom/xrsessionevent.rs index 68eb1903c82..1dd503de606 100644 --- a/components/script/dom/xrsessionevent.rs +++ b/components/script/dom/xrsessionevent.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; +use servo_atoms::Atom; + use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::XRSessionEventBinding::{self, XRSessionEventMethods}; use crate::dom::bindings::error::Fallible; @@ -13,9 +17,6 @@ use crate::dom::event::Event; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::dom::xrsession::XRSession; -use dom_struct::dom_struct; -use js::rust::HandleObject; -use servo_atoms::Atom; #[dom_struct] pub struct XRSessionEvent { diff --git a/components/script/dom/xrspace.rs b/components/script/dom/xrspace.rs index 66dd5b44e70..d810d5c07f0 100644 --- a/components/script/dom/xrspace.rs +++ b/components/script/dom/xrspace.rs @@ -2,6 +2,10 @@ * 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 dom_struct::dom_struct; +use euclid::RigidTransform3D; +use webxr_api::{BaseSpace, Frame, Space}; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -11,9 +15,6 @@ use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrjointspace::XRJointSpace; use crate::dom::xrreferencespace::XRReferenceSpace; use crate::dom::xrsession::{cast_transform, ApiPose, XRSession}; -use dom_struct::dom_struct; -use euclid::RigidTransform3D; -use webxr_api::{BaseSpace, Frame, Space}; #[dom_struct] pub struct XRSpace { diff --git a/components/script/dom/xrsubimage.rs b/components/script/dom/xrsubimage.rs index 2be59d48d3b..a5265a3aa76 100644 --- a/components/script/dom/xrsubimage.rs +++ b/components/script/dom/xrsubimage.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 dom_struct::dom_struct; + use crate::dom::bindings::codegen::Bindings::XRSubImageBinding::XRSubImageBinding::XRSubImageMethods; use crate::dom::bindings::reflector::Reflector; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::xrviewport::XRViewport; -use dom_struct::dom_struct; #[dom_struct] pub struct XRSubImage { diff --git a/components/script/dom/xrsystem.rs b/components/script/dom/xrsystem.rs index 907aa2935d1..e4e158605e0 100644 --- a/components/script/dom/xrsystem.rs +++ b/components/script/dom/xrsystem.rs @@ -2,9 +2,21 @@ * 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::Cell; +use std::rc::Rc; + +use dom_struct::dom_struct; +use ipc_channel::ipc::{self as ipc_crate, IpcReceiver}; +use ipc_channel::router::ROUTER; +use msg::constellation_msg::PipelineId; +use profile_traits::ipc; +use servo_config::pref; +use webxr_api::{Error as XRError, Frame, Session, SessionInit, SessionMode}; + use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionInit; -use crate::dom::bindings::codegen::Bindings::XRSystemBinding::{XRSessionMode, XRSystemMethods}; +use crate::dom::bindings::codegen::Bindings::XRSystemBinding::{ + XRSessionInit, XRSessionMode, XRSystemMethods, +}; use crate::dom::bindings::conversions::{ConversionResult, FromJSValConvertible}; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; @@ -22,15 +34,6 @@ use crate::dom::xrtest::XRTest; use crate::realms::InRealm; use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use ipc_channel::ipc::{self as ipc_crate, IpcReceiver}; -use ipc_channel::router::ROUTER; -use msg::constellation_msg::PipelineId; -use profile_traits::ipc; -use servo_config::pref; -use std::cell::Cell; -use std::rc::Rc; -use webxr_api::{Error as XRError, Frame, Session, SessionInit, SessionMode}; #[dom_struct] pub struct XRSystem { diff --git a/components/script/dom/xrtest.rs b/components/script/dom/xrtest.rs index 37707c3ce8e..7327154e79d 100644 --- a/components/script/dom/xrtest.rs +++ b/components/script/dom/xrtest.rs @@ -6,6 +6,14 @@ * 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::rc::Rc; + +use dom_struct::dom_struct; +use ipc_channel::ipc::IpcSender; +use ipc_channel::router::ROUTER; +use profile_traits::ipc; +use webxr_api::{self, Error as XRError, MockDeviceInit, MockDeviceMsg}; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; @@ -19,12 +27,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; -use dom_struct::dom_struct; -use ipc_channel::ipc::IpcSender; -use ipc_channel::router::ROUTER; -use profile_traits::ipc; -use std::rc::Rc; -use webxr_api::{self, Error as XRError, MockDeviceInit, MockDeviceMsg}; #[dom_struct] pub struct XRTest { diff --git a/components/script/dom/xrview.rs b/components/script/dom/xrview.rs index ec3edde82e0..747bee2fd8f 100644 --- a/components/script/dom/xrview.rs +++ b/components/script/dom/xrview.rs @@ -2,6 +2,13 @@ * 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::ptr::NonNull; + +use dom_struct::dom_struct; +use euclid::RigidTransform3D; +use js::jsapi::{Heap, JSObject}; +use webxr_api::{ApiSpace, View}; + use crate::dom::bindings::codegen::Bindings::XRViewBinding::{XREye, XRViewMethods}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -10,11 +17,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::xrrigidtransform::XRRigidTransform; use crate::dom::xrsession::{cast_transform, BaseSpace, BaseTransform, XRSession}; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use euclid::RigidTransform3D; -use js::jsapi::{Heap, JSObject}; -use std::ptr::NonNull; -use webxr_api::{ApiSpace, View}; #[dom_struct] pub struct XRView { diff --git a/components/script/dom/xrviewerpose.rs b/components/script/dom/xrviewerpose.rs index e9b072e5e5d..7105d593737 100644 --- a/components/script/dom/xrviewerpose.rs +++ b/components/script/dom/xrviewerpose.rs @@ -2,6 +2,13 @@ * 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 dom_struct::dom_struct; +use euclid::RigidTransform3D; +use js::conversions::ToJSValConvertible; +use js::jsapi::Heap; +use js::jsval::{JSVal, UndefinedValue}; +use webxr_api::{Viewer, ViewerPose, Views}; + use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye; use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding::XRViewerPoseMethods; use crate::dom::bindings::reflector::reflect_dom_object; @@ -13,12 +20,6 @@ use crate::dom::xrsession::{cast_transform, BaseSpace, BaseTransform, XRSession} use crate::dom::xrview::XRView; use crate::realms::enter_realm; use crate::script_runtime::JSContext; -use dom_struct::dom_struct; -use euclid::RigidTransform3D; -use js::conversions::ToJSValConvertible; -use js::jsapi::Heap; -use js::jsval::{JSVal, UndefinedValue}; -use webxr_api::{Viewer, ViewerPose, Views}; #[dom_struct] pub struct XRViewerPose { diff --git a/components/script/dom/xrviewport.rs b/components/script/dom/xrviewport.rs index 968cb573264..d9c90505034 100644 --- a/components/script/dom/xrviewport.rs +++ b/components/script/dom/xrviewport.rs @@ -2,13 +2,14 @@ * 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 dom_struct::dom_struct; +use euclid::Rect; +use webxr_api::Viewport; + use crate::dom::bindings::codegen::Bindings::XRViewportBinding::XRViewportMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use dom_struct::dom_struct; -use euclid::Rect; -use webxr_api::Viewport; #[dom_struct] pub struct XRViewport { diff --git a/components/script/dom/xrwebglbinding.rs b/components/script/dom/xrwebglbinding.rs index 60e2d1be6b4..4ff845b055a 100644 --- a/components/script/dom/xrwebglbinding.rs +++ b/components/script/dom/xrwebglbinding.rs @@ -2,21 +2,19 @@ * 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 dom_struct::dom_struct; +use js::rust::HandleObject; + use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCubeLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCylinderLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XREquirectLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRQuadLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRTextureType; use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRWebGLBindingBinding::XRWebGLBindingMethods; +use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::{ + XRCubeLayerInit, XRCylinderLayerInit, XREquirectLayerInit, XRProjectionLayerInit, + XRQuadLayerInit, XRTextureType, +}; use crate::dom::bindings::codegen::UnionTypes::WebGLRenderingContextOrWebGL2RenderingContext; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::reflect_dom_object_with_proto; -use crate::dom::bindings::reflector::Reflector; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::error::{Error, Fallible}; +use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; +use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::window::Window; use crate::dom::xrcompositionlayer::XRCompositionLayer; @@ -29,8 +27,6 @@ use crate::dom::xrquadlayer::XRQuadLayer; use crate::dom::xrsession::XRSession; use crate::dom::xrview::XRView; use crate::dom::xrwebglsubimage::XRWebGLSubImage; -use dom_struct::dom_struct; -use js::rust::HandleObject; #[dom_struct] pub struct XRWebGLBinding { diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index 1e414d95779..b876fa0b7ce 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -2,13 +2,20 @@ * 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::convert::TryInto; + +use canvas_traits::webgl::{WebGLCommand, WebGLContextId, WebGLTextureId}; +use dom_struct::dom_struct; +use euclid::{Rect, Size2D}; +use js::rust::HandleObject; +use webxr_api::{ContextId as WebXRContextId, LayerId, LayerInit, Viewport}; + use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; -use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerInit; -use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods; -use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLRenderingContext; -use crate::dom::bindings::error::Error; -use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{ + XRWebGLLayerInit, XRWebGLLayerMethods, XRWebGLRenderingContext, +}; +use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -23,17 +30,6 @@ use crate::dom::xrlayer::XRLayer; use crate::dom::xrsession::XRSession; use crate::dom::xrview::XRView; use crate::dom::xrviewport::XRViewport; -use canvas_traits::webgl::WebGLCommand; -use canvas_traits::webgl::WebGLContextId; -use canvas_traits::webgl::WebGLTextureId; -use dom_struct::dom_struct; -use euclid::{Rect, Size2D}; -use js::rust::HandleObject; -use std::convert::TryInto; -use webxr_api::ContextId as WebXRContextId; -use webxr_api::LayerId; -use webxr_api::LayerInit; -use webxr_api::Viewport; impl<'a> From<&'a XRWebGLLayerInit> for LayerInit { fn from(init: &'a XRWebGLLayerInit) -> LayerInit { diff --git a/components/script/dom/xrwebglsubimage.rs b/components/script/dom/xrwebglsubimage.rs index d9d5420dfe3..0bed4a51906 100644 --- a/components/script/dom/xrwebglsubimage.rs +++ b/components/script/dom/xrwebglsubimage.rs @@ -2,15 +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 crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImageBinding::XRWebGLSubImageMethods; -use crate::dom::bindings::root::Dom; -use crate::dom::bindings::root::DomRoot; -use crate::dom::webgltexture::WebGLTexture; -use crate::dom::xrsubimage::XRSubImage; use dom_struct::dom_struct; use euclid::Size2D; use webxr_api::Viewport; +use crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImageBinding::XRWebGLSubImageMethods; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::webgltexture::WebGLTexture; +use crate::dom::xrsubimage::XRSubImage; + #[dom_struct] pub struct XRWebGLSubImage { xr_sub_image: XRSubImage, diff --git a/components/script/fetch.rs b/components/script/fetch.rs index b3db51d2a1d..bb4b517a065 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -2,8 +2,24 @@ * 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::RequestBinding::RequestInfo; -use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; + +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use net_traits::request::{ + CorsSettings, CredentialsMode, Destination, Referrer, Request as NetTraitsRequest, + RequestBuilder, RequestMode, ServiceWorkersMode, +}; +use net_traits::CoreResourceMsg::Fetch as NetTraitsFetch; +use net_traits::{ + CoreResourceMsg, CoreResourceThread, FetchChannels, FetchMetadata, FetchResponseListener, + FetchResponseMsg, FilteredMetadata, Metadata, NetworkError, ResourceFetchTiming, + ResourceTimingType, +}; +use servo_url::ServoUrl; + +use crate::dom::bindings::codegen::Bindings::RequestBinding::{RequestInfo, RequestInit}; use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::ResponseMethods; use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseType as DOMResponseType; use crate::dom::bindings::error::Error; @@ -24,20 +40,6 @@ use crate::network_listener::{ }; use crate::realms::{enter_realm, InRealm}; use crate::task_source::TaskSourceName; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use net_traits::request::{ - CorsSettings, CredentialsMode, Destination, RequestBuilder, RequestMode, -}; -use net_traits::request::{Referrer, Request as NetTraitsRequest, ServiceWorkersMode}; -use net_traits::CoreResourceMsg::Fetch as NetTraitsFetch; -use net_traits::{CoreResourceMsg, CoreResourceThread, FetchResponseMsg}; -use net_traits::{FetchChannels, FetchResponseListener, NetworkError}; -use net_traits::{FetchMetadata, FilteredMetadata, Metadata}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use servo_url::ServoUrl; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; struct FetchContext { fetch_promise: Option<TrustedPromise>, diff --git a/components/script/image_listener.rs b/components/script/image_listener.rs index 7bf81c80d76..d43ac12e6b7 100644 --- a/components/script/image_listener.rs +++ b/components/script/image_listener.rs @@ -2,15 +2,16 @@ * 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 ipc_channel::ipc; +use ipc_channel::ipc::IpcSender; +use ipc_channel::router::ROUTER; +use net_traits::image_cache::{ImageResponse, PendingImageResponse}; + use crate::dom::bindings::conversions::DerivedFrom; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; use crate::dom::node::{window_from_node, Node}; use crate::task_source::TaskSource; -use ipc_channel::ipc; -use ipc_channel::ipc::IpcSender; -use ipc_channel::router::ROUTER; -use net_traits::image_cache::{ImageResponse, PendingImageResponse}; pub trait ImageCacheListener { fn generation_id(&self) -> u32; diff --git a/components/script/init.rs b/components/script/init.rs index 8fd59592f01..8cd93fe2aa0 100644 --- a/components/script/init.rs +++ b/components/script/init.rs @@ -2,12 +2,13 @@ * 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::jsapi::JSObject; + use crate::dom::bindings::codegen::RegisterBindings; use crate::dom::bindings::conversions::is_dom_proxy; use crate::dom::bindings::proxyhandler; use crate::dom::bindings::utils::is_platform_object_static; use crate::script_runtime::JSEngineSetup; -use js::jsapi::JSObject; #[cfg(target_os = "linux")] #[allow(unsafe_code)] diff --git a/components/script/layout_dom/document.rs b/components/script/layout_dom/document.rs index 392c1686f97..f068600a005 100644 --- a/components/script/layout_dom/document.rs +++ b/components/script/layout_dom/document.rs @@ -2,21 +2,21 @@ * 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::root::LayoutDom; -use crate::dom::document::{Document, LayoutDocumentHelpers}; -use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags}; -use crate::layout_dom::ServoLayoutElement; -use crate::layout_dom::ServoLayoutNode; -use crate::layout_dom::ServoShadowRoot; +use std::marker::PhantomData; + use script_layout_interface::wrapper_traits::LayoutDataTrait; use selectors::matching::QuirksMode; -use std::marker::PhantomData; use style::dom::{TDocument, TNode}; use style::shared_lock::{ SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard as StyleSharedRwLockReadGuard, }; use style::stylist::Stylist; +use crate::dom::bindings::root::LayoutDom; +use crate::dom::document::{Document, LayoutDocumentHelpers}; +use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags}; +use crate::layout_dom::{ServoLayoutElement, ServoLayoutNode, ServoShadowRoot}; + // A wrapper around documents that ensures ayout can only ever access safe properties. pub struct ServoLayoutDocument<'dom, LayoutDataType: LayoutDataTrait> { /// The wrapped private DOM Document diff --git a/components/script/layout_dom/element.rs b/components/script/layout_dom/element.rs index 2b1c199cbaa..b923cdb12f8 100644 --- a/components/script/layout_dom/element.rs +++ b/components/script/layout_dom/element.rs @@ -2,15 +2,11 @@ * 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::attr::AttrHelpersForLayout; -use crate::dom::bindings::inheritance::{ - CharacterDataTypeId, DocumentFragmentTypeId, ElementTypeId, -}; -use crate::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId, TextTypeId}; -use crate::dom::bindings::root::LayoutDom; -use crate::dom::characterdata::LayoutCharacterDataHelpers; -use crate::dom::element::{Element, LayoutElementHelpers}; -use crate::dom::node::{LayoutNodeHelpers, NodeFlags}; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::marker::PhantomData; +use std::sync::atomic::Ordering; + use atomic_refcell::{AtomicRef, AtomicRefMut}; use html5ever::{local_name, namespace_url, ns, LocalName, Namespace}; use script_layout_interface::wrapper_traits::{ @@ -23,10 +19,6 @@ use selectors::matching::{ElementSelectorFlags, MatchingContext, VisitedHandling use selectors::sink::Push; use servo_arc::{Arc, ArcBorrow}; use servo_atoms::Atom; -use std::fmt; -use std::hash::{Hash, Hasher}; -use std::marker::PhantomData; -use std::sync::atomic::Ordering; use style::animation::AnimationSetKey; use style::applicable_declarations::ApplicableDeclarationBlock; use style::attr::AttrValue; @@ -43,9 +35,16 @@ use style::shared_lock::Locked as StyleLocked; use style::values::{AtomIdent, AtomString}; use style::CaseSensitivityExt; -use crate::layout_dom::ServoLayoutNode; -use crate::layout_dom::ServoShadowRoot; -use crate::layout_dom::ServoThreadSafeLayoutNode; +use crate::dom::attr::AttrHelpersForLayout; +use crate::dom::bindings::inheritance::{ + CharacterDataTypeId, DocumentFragmentTypeId, ElementTypeId, HTMLElementTypeId, NodeTypeId, + TextTypeId, +}; +use crate::dom::bindings::root::LayoutDom; +use crate::dom::characterdata::LayoutCharacterDataHelpers; +use crate::dom::element::{Element, LayoutElementHelpers}; +use crate::dom::node::{LayoutNodeHelpers, NodeFlags}; +use crate::layout_dom::{ServoLayoutNode, ServoShadowRoot, ServoThreadSafeLayoutNode}; /// A wrapper around elements that ensures layout can only ever access safe properties. pub struct ServoLayoutElement<'dom, LayoutDataType: LayoutDataTrait> { diff --git a/components/script/layout_dom/node.rs b/components/script/layout_dom/node.rs index 7674a10e743..521e20957f7 100644 --- a/components/script/layout_dom/node.rs +++ b/components/script/layout_dom/node.rs @@ -4,17 +4,11 @@ #![allow(unsafe_code)] -use super::ServoLayoutDocument; -use super::ServoLayoutElement; -use super::ServoShadowRoot; -use super::ServoThreadSafeLayoutElement; -use crate::dom::bindings::inheritance::CharacterDataTypeId; -use crate::dom::bindings::inheritance::{NodeTypeId, TextTypeId}; -use crate::dom::bindings::root::LayoutDom; -use crate::dom::characterdata::LayoutCharacterDataHelpers; -use crate::dom::element::{Element, LayoutElementHelpers}; -use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags}; -use crate::dom::text::Text; +use std::borrow::Cow; +use std::fmt; +use std::marker::PhantomData; +use std::sync::Arc as StdArc; + use atomic_refcell::AtomicRefCell; use gfx_traits::ByteIndex; use html5ever::{local_name, namespace_url, ns}; @@ -31,16 +25,22 @@ use script_layout_interface::{ }; use servo_arc::Arc; use servo_url::ServoUrl; -use std::borrow::Cow; -use std::fmt; -use std::marker::PhantomData; -use std::sync::Arc as StdArc; use style; use style::context::SharedStyleContext; use style::dom::{NodeInfo, TElement, TNode, TShadowRoot}; use style::properties::ComputedValues; use style::str::is_whitespace; +use super::{ + ServoLayoutDocument, ServoLayoutElement, ServoShadowRoot, ServoThreadSafeLayoutElement, +}; +use crate::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId, TextTypeId}; +use crate::dom::bindings::root::LayoutDom; +use crate::dom::characterdata::LayoutCharacterDataHelpers; +use crate::dom::element::{Element, LayoutElementHelpers}; +use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags}; +use crate::dom::text::Text; + /// A wrapper around a `LayoutDom<Node>` which provides a safe interface that /// can be used during layout. This implements the `LayoutNode` trait as well as /// several style and selectors traits for use during layout. This version diff --git a/components/script/layout_dom/shadow_root.rs b/components/script/layout_dom/shadow_root.rs index 19336befe74..7bd57a8ee84 100644 --- a/components/script/layout_dom/shadow_root.rs +++ b/components/script/layout_dom/shadow_root.rs @@ -2,17 +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 crate::dom::bindings::root::LayoutDom; -use crate::dom::shadowroot::{LayoutShadowRootHelpers, ShadowRoot}; -use crate::layout_dom::ServoLayoutElement; -use crate::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::LayoutDataTrait; use std::fmt; use std::marker::PhantomData; + +use script_layout_interface::wrapper_traits::LayoutDataTrait; use style::dom::TShadowRoot; use style::shared_lock::SharedRwLockReadGuard as StyleSharedRwLockReadGuard; use style::stylist::{CascadeData, Stylist}; +use crate::dom::bindings::root::LayoutDom; +use crate::dom::shadowroot::{LayoutShadowRootHelpers, ShadowRoot}; +use crate::layout_dom::{ServoLayoutElement, ServoLayoutNode}; + pub struct ServoShadowRoot<'dom, LayoutDataType: LayoutDataTrait> { /// The wrapped private DOM ShadowRoot. shadow_root: LayoutDom<'dom, ShadowRoot>, diff --git a/components/script/layout_image.rs b/components/script/layout_image.rs index 68ece467ad7..a7e1d6fa06c 100644 --- a/components/script/layout_image.rs +++ b/components/script/layout_image.rs @@ -7,6 +7,18 @@ //! no guarantee that the responsible nodes will still exist in the future if the //! layout thread holds on to them during asynchronous operations. +use std::sync::{Arc, Mutex}; + +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use net_traits::image_cache::{ImageCache, PendingImageId}; +use net_traits::request::{Destination, RequestBuilder as FetchRequestInit}; +use net_traits::{ + FetchMetadata, FetchResponseListener, FetchResponseMsg, NetworkError, ResourceFetchTiming, + ResourceTimingType, +}; +use servo_url::ServoUrl; + use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::DomRoot; @@ -15,14 +27,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::node::{document_from_node, Node}; use crate::dom::performanceresourcetiming::InitiatorType; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use net_traits::image_cache::{ImageCache, PendingImageId}; -use net_traits::request::{Destination, RequestBuilder as FetchRequestInit}; -use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg, NetworkError}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use servo_url::ServoUrl; -use std::sync::{Arc, Mutex}; struct LayoutImageContext { id: PendingImageId, diff --git a/components/script/mem.rs b/components/script/mem.rs index 6762c56a237..56401d8a51e 100644 --- a/components/script/mem.rs +++ b/components/script/mem.rs @@ -4,9 +4,10 @@ //! Routines for handling measuring the memory usage of arbitrary DOM nodes. -use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use std::os::raw::c_void; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; + /// Used by codegen to include the pointer to the `MallocSizeOf` implementation of each /// IDL interface. This way we don't have to find the most-derived interface of DOM /// objects by hand in code. diff --git a/components/script/microtask.rs b/components/script/microtask.rs index 4a810fd0cfd..904925fc9db 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -6,6 +6,13 @@ //! microtask queues. It is up to implementations of event loops to store a queue and //! perform checkpoints at appropriate times, as well as enqueue microtasks as required. +use std::cell::Cell; +use std::mem; +use std::rc::Rc; + +use js::jsapi::{JSAutoRealm, JobQueueIsEmpty, JobQueueMayNotBeEmpty}; +use msg::constellation_msg::PipelineId; + use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; @@ -18,11 +25,6 @@ use crate::dom::mutationobserver::MutationObserver; use crate::realms::enter_realm; use crate::script_runtime::{notify_about_rejected_promises, JSContext}; use crate::script_thread::ScriptThread; -use js::jsapi::{JSAutoRealm, JobQueueIsEmpty, JobQueueMayNotBeEmpty}; -use msg::constellation_msg::PipelineId; -use std::cell::Cell; -use std::mem; -use std::rc::Rc; /// A collection of microtasks in FIFO order. #[derive(Default, JSTraceable, MallocSizeOf)] diff --git a/components/script/network_listener.rs b/components/script/network_listener.rs index 29c43450aac..08fd3a2c88b 100644 --- a/components/script/network_listener.rs +++ b/components/script/network_listener.rs @@ -2,6 +2,13 @@ * 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::sync::{Arc, Mutex}; + +use net_traits::{ + Action, FetchResponseListener, FetchResponseMsg, ResourceFetchTiming, ResourceTimingType, +}; +use servo_url::ServoUrl; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; @@ -10,11 +17,6 @@ use crate::dom::performanceresourcetiming::{InitiatorType, PerformanceResourceTi use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::TaskSource; -use net_traits::{ - Action, FetchResponseListener, FetchResponseMsg, ResourceFetchTiming, ResourceTimingType, -}; -use servo_url::ServoUrl; -use std::sync::{Arc, Mutex}; /// An off-thread sink for async network event tasks. All such events are forwarded to /// a target thread, where they are invoked on the provided context object. diff --git a/components/script/realms.rs b/components/script/realms.rs index 48b141aae56..37ed21366a3 100644 --- a/components/script/realms.rs +++ b/components/script/realms.rs @@ -2,10 +2,11 @@ * 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::jsapi::{GetCurrentRealmOrNull, JSAutoRealm}; + use crate::dom::bindings::reflector::DomObject; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm}; pub struct AlreadyInRealm(()); diff --git a/components/script/script_module.rs b/components/script/script_module.rs index ad36507c3a3..ac829e244b7 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -5,12 +5,52 @@ //! The script module mod contains common traits and structs //! related to `type=module` for script thread or worker threads. +use std::collections::{HashMap, HashSet}; +use std::rc::Rc; +use std::str::FromStr; +use std::sync::{Arc, Mutex}; +use std::{mem, ptr}; + +use encoding_rs::UTF_8; +use html5ever::local_name; +use hyper_serde::Serde; +use indexmap::IndexSet; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; +use js::jsapi::{ + CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport, GetModuleRequestSpecifier, + GetModuleResolveHook, GetRequestedModules, Handle as RawHandle, HandleObject, + HandleValue as RawHandleValue, Heap, JSAutoRealm, JSContext, JSObject, JSRuntime, JSString, + JS_ClearPendingException, JS_DefineProperty4, JS_IsExceptionPending, JS_NewStringCopyN, + ModuleErrorBehaviour, ModuleEvaluate, ModuleLink, MutableHandleValue, + SetModuleDynamicImportHook, SetModuleMetadataHook, SetModulePrivate, SetModuleResolveHook, + SetScriptPrivateReferenceHooks, ThrowOnModuleEvaluationFailure, Value, JSPROP_ENUMERATE, +}; +use js::jsval::{JSVal, PrivateValue, UndefinedValue}; +use js::rust::jsapi_wrapped::{ + GetArrayLength, GetRequestedModuleSpecifier, JS_GetElement, JS_GetPendingException, +}; +use js::rust::wrappers::JS_SetPendingException; +use js::rust::{ + transform_str_to_source_text, CompileOptionsWrapper, Handle, HandleValue, IntoHandle, +}; +use mime::Mime; +use net_traits::request::{ + CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder, RequestMode, +}; +use net_traits::{ + CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, IpcSend, Metadata, + NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceTimingType, +}; +use servo_url::ServoUrl; +use url::ParseError as UrlParseError; +use uuid::Uuid; + use crate::document_loader::LoadType; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::conversions::jsstring_to_str; -use crate::dom::bindings::error::report_pending_exception; -use crate::dom::bindings::error::Error; +use crate::dom::bindings::error::{report_pending_exception, Error}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; @@ -22,63 +62,20 @@ use crate::dom::document::Document; use crate::dom::dynamicmoduleowner::{DynamicModuleId, DynamicModuleOwner}; use crate::dom::element::Element; use crate::dom::globalscope::GlobalScope; -use crate::dom::htmlscriptelement::{HTMLScriptElement, ScriptId}; -use crate::dom::htmlscriptelement::{ScriptOrigin, ScriptType, SCRIPT_JS_MIMES}; +use crate::dom::htmlscriptelement::{ + HTMLScriptElement, ScriptId, ScriptOrigin, ScriptType, SCRIPT_JS_MIMES, +}; use crate::dom::node::document_from_node; use crate::dom::performanceresourcetiming::InitiatorType; use crate::dom::promise::Promise; use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler}; use crate::dom::window::Window; use crate::dom::worker::TrustedWorkerAddress; -use crate::network_listener::{self, NetworkListener}; -use crate::network_listener::{PreInvoke, ResourceTimingListener}; +use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; use crate::task::TaskBox; use crate::task_source::TaskSourceName; -use encoding_rs::UTF_8; -use html5ever::local_name; -use hyper_serde::Serde; -use indexmap::IndexSet; -use ipc_channel::ipc; -use ipc_channel::router::ROUTER; -use js::jsapi::Handle as RawHandle; -use js::jsapi::HandleObject; -use js::jsapi::HandleValue as RawHandleValue; -use js::jsapi::MutableHandleValue; -use js::jsapi::Value; -use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport}; -use js::jsapi::{GetModuleRequestSpecifier, GetRequestedModules, SetModuleMetadataHook}; -use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook}; -use js::jsapi::{Heap, JSContext, JS_ClearPendingException, SetModulePrivate}; -use js::jsapi::{JSAutoRealm, JSObject, JSString}; -use js::jsapi::{JS_DefineProperty4, JS_IsExceptionPending, JS_NewStringCopyN, JSPROP_ENUMERATE}; -use js::jsapi::{ModuleErrorBehaviour, ModuleEvaluate, ModuleLink, ThrowOnModuleEvaluationFailure}; -use js::jsapi::{SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks}; -use js::jsval::{JSVal, PrivateValue, UndefinedValue}; -use js::rust::jsapi_wrapped::{GetArrayLength, JS_GetElement}; -use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException}; -use js::rust::transform_str_to_source_text; -use js::rust::wrappers::JS_SetPendingException; -use js::rust::CompileOptionsWrapper; -use js::rust::{Handle, HandleValue, IntoHandle}; -use mime::Mime; -use net_traits::request::{CredentialsMode, Destination, ParserMetadata}; -use net_traits::request::{Referrer, RequestBuilder, RequestMode}; -use net_traits::IpcSend; -use net_traits::{CoreResourceMsg, FetchChannels}; -use net_traits::{FetchMetadata, Metadata, ReferrerPolicy}; -use net_traits::{FetchResponseListener, NetworkError}; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; -use servo_url::ServoUrl; -use std::collections::{HashMap, HashSet}; -use std::mem; -use std::ptr; -use std::rc::Rc; -use std::str::FromStr; -use std::sync::{Arc, Mutex}; -use url::ParseError as UrlParseError; -use uuid::Uuid; #[allow(unsafe_code)] unsafe fn gen_type_error(global: &GlobalScope, string: String) -> RethrowError { diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 3d88c50a671..239c056a99d 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -7,23 +7,68 @@ #![allow(dead_code)] +use core::ffi::c_char; +use std::cell::Cell; +use std::ffi::CString; +use std::io::{stdout, Write}; +use std::ops::Deref; +use std::os::raw::c_void; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; +use std::time::Duration; +use std::{fmt, os, ptr, thread}; + +use js::glue::{ + CollectServoSizes, CreateJobQueue, DeleteJobQueue, DispatchableRun, JobQueueTraps, + RUST_js_GetErrorMessage, SetBuildId, StreamConsumerConsumeChunk, + StreamConsumerNoteResponseURLs, StreamConsumerStreamEnd, StreamConsumerStreamError, +}; +use js::jsapi::{ + BuildIdCharVector, ContextOptionsRef, DisableIncrementalGC, Dispatchable as JSRunnable, + Dispatchable_MaybeShuttingDown, GCDescription, GCOptions, GCProgress, GCReason, + GetPromiseUserInputEventHandlingState, HandleObject, Heap, InitConsumeStreamCallback, + InitDispatchToEventLoop, JSContext as RawJSContext, JSGCParamKey, JSGCStatus, + JSJitCompilerOption, JSObject, JSSecurityCallbacks, JSTracer, JS_AddExtraGCRootsTracer, + JS_InitDestroyPrincipalsCallback, JS_RequestInterruptCallback, JS_SetGCCallback, + JS_SetGCParameter, JS_SetGlobalJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, + JS_SetParallelParsingEnabled, JS_SetSecurityCallbacks, JobQueue, MimeType, + PromiseRejectionHandlingState, PromiseUserInputEventHandlingState, SetDOMCallbacks, + SetGCSliceCallback, SetJobQueue, SetPreserveWrapperCallbacks, SetProcessBuildIdOp, + SetPromiseRejectionTrackerCallback, StreamConsumer as JSStreamConsumer, +}; +use js::jsval::UndefinedValue; +use js::panic::wrap_panic; +use js::rust::wrappers::{GetPromiseIsHandled, JS_GetPromiseResult}; +use js::rust::{ + Handle, HandleObject as RustHandleObject, IntoHandle, JSEngine, JSEngineHandle, ParentRuntime, + Runtime as RustRuntime, +}; +use lazy_static::lazy_static; +use malloc_size_of::MallocSizeOfOps; +use msg::constellation_msg::PipelineId; +use profile_traits::mem::{Report, ReportKind, ReportsChan}; +use profile_traits::path; +use servo_config::{opts, pref}; +use style::thread_state::{self, ThreadState}; +use time::{now, Tm}; + use crate::body::BodyMixin; use crate::dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::ResponseMethods; use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseType as DOMResponseType; -use crate::dom::bindings::conversions::get_dom_class; -use crate::dom::bindings::conversions::private_from_object; -use crate::dom::bindings::conversions::root_from_handleobject; +use crate::dom::bindings::conversions::{ + get_dom_class, private_from_object, root_from_handleobject, +}; use crate::dom::bindings::error::{throw_dom_exception, Error}; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::principals; -use crate::dom::bindings::refcounted::{trace_refcounted_objects, LiveDOMReferences}; -use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; +use crate::dom::bindings::refcounted::{ + trace_refcounted_objects, LiveDOMReferences, Trusted, TrustedPromise, +}; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::root::trace_roots; -use crate::dom::bindings::settings_stack; use crate::dom::bindings::trace::JSTraceable; use crate::dom::bindings::utils::DOM_CALLBACKS; +use crate::dom::bindings::{principals, settings_stack}; use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; @@ -37,64 +82,6 @@ use crate::script_thread::trace_thread; use crate::task::TaskBox; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::{TaskSource, TaskSourceName}; -use core::ffi::c_char; -use js::glue::{CollectServoSizes, CreateJobQueue, DeleteJobQueue, DispatchableRun}; -use js::glue::{JobQueueTraps, RUST_js_GetErrorMessage, SetBuildId, StreamConsumerConsumeChunk}; -use js::glue::{ - StreamConsumerNoteResponseURLs, StreamConsumerStreamEnd, StreamConsumerStreamError, -}; -use js::jsapi::ContextOptionsRef; -use js::jsapi::GetPromiseUserInputEventHandlingState; -use js::jsapi::InitConsumeStreamCallback; -use js::jsapi::InitDispatchToEventLoop; -use js::jsapi::MimeType; -use js::jsapi::PromiseUserInputEventHandlingState; -use js::jsapi::StreamConsumer as JSStreamConsumer; -use js::jsapi::{BuildIdCharVector, DisableIncrementalGC, GCDescription, GCProgress}; -use js::jsapi::{Dispatchable as JSRunnable, Dispatchable_MaybeShuttingDown}; -use js::jsapi::{ - GCOptions, GCReason, JSGCStatus, JS_AddExtraGCRootsTracer, JS_RequestInterruptCallback, - JS_SetGCCallback, -}; -use js::jsapi::{HandleObject, Heap, JobQueue}; -use js::jsapi::{JSContext as RawJSContext, JSTracer, SetDOMCallbacks, SetGCSliceCallback}; -use js::jsapi::{JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompilerOption}; -use js::jsapi::{ - JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled, -}; -use js::jsapi::{JSObject, PromiseRejectionHandlingState, SetPreserveWrapperCallbacks}; -use js::jsapi::{JSSecurityCallbacks, JS_InitDestroyPrincipalsCallback, JS_SetSecurityCallbacks}; -use js::jsapi::{SetJobQueue, SetProcessBuildIdOp, SetPromiseRejectionTrackerCallback}; -use js::jsval::UndefinedValue; -use js::panic::wrap_panic; -use js::rust::wrappers::{GetPromiseIsHandled, JS_GetPromiseResult}; -use js::rust::Handle; -use js::rust::HandleObject as RustHandleObject; -use js::rust::IntoHandle; -use js::rust::ParentRuntime; -use js::rust::Runtime as RustRuntime; -use js::rust::{JSEngine, JSEngineHandle}; -use lazy_static::lazy_static; -use malloc_size_of::MallocSizeOfOps; -use msg::constellation_msg::PipelineId; -use profile_traits::mem::{Report, ReportKind, ReportsChan}; -use profile_traits::path; -use servo_config::opts; -use servo_config::pref; -use std::cell::Cell; -use std::ffi::CString; -use std::fmt; -use std::io::{stdout, Write}; -use std::ops::Deref; -use std::os; -use std::os::raw::c_void; -use std::ptr; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; -use std::thread; -use std::time::Duration; -use style::thread_state::{self, ThreadState}; -use time::{now, Tm}; static JOB_QUEUE_TRAPS: JobQueueTraps = JobQueueTraps { getIncumbentGlobal: Some(get_incumbent_global), diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index be456b8d1f7..4ded0c6632a 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -17,7 +17,86 @@ //! a page runs its course and the script thread returns to processing events in the main event //! loop. -use crate::devtools; +use std::borrow::Cow; +use std::cell::{Cell, RefCell}; +use std::collections::{hash_map, HashMap, HashSet}; +use std::default::Default; +use std::ops::Deref; +use std::option::Option; +use std::rc::Rc; +use std::result::Result; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::time::{Duration, SystemTime}; +use std::{ptr, thread}; + +use bluetooth_traits::BluetoothRequest; +use canvas_traits::webgl::WebGLPipeline; +use crossbeam_channel::{select, unbounded, Receiver, Sender}; +use devtools_traits::{ + CSSError, DevtoolScriptControlMsg, DevtoolsPageInfo, NavigationState, + ScriptToDevtoolsControlMsg, WorkerId, +}; +use embedder_traits::EmbedderMsg; +use euclid::default::{Point2D, Rect}; +use euclid::Vector2D; +use headers::{HeaderMapExt, LastModified, ReferrerPolicy as ReferrerPolicyHeader}; +use html5ever::{local_name, namespace_url, ns}; +use hyper_serde::Serde; +use ipc_channel::ipc::{self, IpcSender}; +use ipc_channel::router::ROUTER; +use js::glue::GetWindowProxyClass; +use js::jsapi::{ + JSContext as UnsafeJSContext, JSTracer, JS_AddInterruptCallback, SetWindowProxyClass, +}; +use js::jsval::UndefinedValue; +use js::rust::ParentRuntime; +use media::WindowGLContext; +use metrics::{PaintTimeMetrics, MAX_TASK_NS}; +use mime::{self, Mime}; +use msg::constellation_msg::{ + BackgroundHangMonitor, BackgroundHangMonitorExitSignal, BackgroundHangMonitorRegister, + BrowsingContextId, HangAnnotation, HistoryStateId, MonitoredComponentId, + MonitoredComponentType, PipelineId, PipelineNamespace, ScriptHangAnnotation, + TopLevelBrowsingContextId, +}; +use net_traits::image_cache::{ImageCache, PendingImageResponse}; +use net_traits::request::{CredentialsMode, Destination, RedirectMode, RequestBuilder}; +use net_traits::storage_thread::StorageType; +use net_traits::{ + FetchMetadata, FetchResponseListener, FetchResponseMsg, Metadata, NetworkError, ReferrerPolicy, + ResourceFetchTiming, ResourceThreads, ResourceTimingType, +}; +use parking_lot::Mutex; +use percent_encoding::percent_decode; +use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan}; +use profile_traits::time::{self as profile_time, profile, ProfilerCategory}; +use script_layout_interface::message::{self, LayoutThreadInit, Msg, ReflowGoal}; +use script_traits::webdriver_msg::WebDriverScriptCommand; +use script_traits::CompositorEvent::{ + CompositionEvent, IMEDismissedEvent, KeyboardEvent, MouseButtonEvent, MouseMoveEvent, + ResizeEvent, TouchEvent, WheelEvent, +}; +use script_traits::{ + AnimationTickType, CompositorEvent, ConstellationControlMsg, DiscardBrowsingContext, + DocumentActivity, EventResult, HistoryEntryReplacement, InitialScriptState, JsEvalResult, + LayoutMsg, LoadData, LoadOrigin, MediaSessionActionType, MouseButton, MouseEventType, + NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptMsg, ScriptThreadFactory, + ScriptToConstellationChan, StructuredSerializedData, TimerSchedulerMsg, TouchEventType, + TouchId, UntrustedNodeAddress, UpdatePipelineIdReason, WebrenderIpcSender, WheelDelta, + WindowSizeData, WindowSizeType, +}; +use servo_atoms::Atom; +use servo_config::opts; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; +use style::dom::OpaqueNode; +use style::thread_state::{self, ThreadState}; +use time::{at_utc, get_time, precise_time_ns, Timespec}; +use url::Position; +use webgpu::identity::WebGPUMsg; +use webrender_api::units::LayoutPixel; +use webrender_api::DocumentId; + use crate::document_loader::DocumentLoader; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ @@ -31,8 +110,9 @@ use crate::dom::bindings::conversions::{ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::root::ThreadLocalStackRoots; -use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootCollection}; +use crate::dom::bindings::root::{ + Dom, DomRoot, MutNullableDom, RootCollection, ThreadLocalStackRoots, +}; use crate::dom::bindings::str::DOMString; use crate::dom::bindings::trace::{HashMapTracedValues, JSTraceable}; use crate::dom::customelementregistry::{ @@ -64,9 +144,9 @@ use crate::microtask::{Microtask, MicrotaskQueue}; use crate::realms::enter_realm; use crate::script_module::ScriptFetchOptions; use crate::script_runtime::{ - get_reports, new_rt_and_cx, ContextForRequestInterrupt, JSContext, Runtime, ScriptPort, + get_reports, new_rt_and_cx, CommonScriptMsg, ContextForRequestInterrupt, JSContext, Runtime, + ScriptChan, ScriptPort, ScriptThreadEventCategory, }; -use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task_manager::TaskManager; use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; use crate::task_source::dom_manipulation::DOMManipulationTaskSource; @@ -80,91 +160,8 @@ use crate::task_source::remote_event::RemoteEventTaskSource; use crate::task_source::timer::TimerTaskSource; use crate::task_source::user_interaction::UserInteractionTaskSource; use crate::task_source::websocket::WebsocketTaskSource; -use crate::task_source::TaskSource; -use crate::task_source::TaskSourceName; -use crate::webdriver_handlers; -use bluetooth_traits::BluetoothRequest; -use canvas_traits::webgl::WebGLPipeline; -use crossbeam_channel::{select, unbounded, Receiver, Sender}; -use devtools_traits::CSSError; -use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo}; -use devtools_traits::{NavigationState, ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::EmbedderMsg; -use euclid::default::{Point2D, Rect}; -use euclid::Vector2D; -use headers::ReferrerPolicy as ReferrerPolicyHeader; -use headers::{HeaderMapExt, LastModified}; -use html5ever::{local_name, namespace_url, ns}; -use hyper_serde::Serde; -use ipc_channel::ipc::{self, IpcSender}; -use ipc_channel::router::ROUTER; -use js::glue::GetWindowProxyClass; -use js::jsapi::{ - JSContext as UnsafeJSContext, JSTracer, JS_AddInterruptCallback, SetWindowProxyClass, -}; -use js::jsval::UndefinedValue; -use js::rust::ParentRuntime; -use media::WindowGLContext; -use metrics::{PaintTimeMetrics, MAX_TASK_NS}; -use mime::{self, Mime}; -use msg::constellation_msg::{ - BackgroundHangMonitor, BackgroundHangMonitorExitSignal, BackgroundHangMonitorRegister, - ScriptHangAnnotation, -}; -use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId}; -use msg::constellation_msg::{HangAnnotation, MonitoredComponentId, MonitoredComponentType}; -use msg::constellation_msg::{PipelineNamespace, TopLevelBrowsingContextId}; -use net_traits::image_cache::{ImageCache, PendingImageResponse}; -use net_traits::request::{CredentialsMode, Destination, RedirectMode, RequestBuilder}; -use net_traits::storage_thread::StorageType; -use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg}; -use net_traits::{ - Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceThreads, - ResourceTimingType, -}; -use parking_lot::Mutex; -use percent_encoding::percent_decode; -use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan}; -use profile_traits::time::{self as profile_time, profile, ProfilerCategory}; -use script_layout_interface::message::{self, LayoutThreadInit, Msg, ReflowGoal}; -use script_traits::webdriver_msg::WebDriverScriptCommand; -use script_traits::CompositorEvent::{ - CompositionEvent, IMEDismissedEvent, KeyboardEvent, MouseButtonEvent, MouseMoveEvent, - ResizeEvent, TouchEvent, WheelEvent, -}; -use script_traits::{ - AnimationTickType, CompositorEvent, ConstellationControlMsg, DiscardBrowsingContext, - DocumentActivity, EventResult, HistoryEntryReplacement, InitialScriptState, JsEvalResult, - LayoutMsg, LoadData, LoadOrigin, MediaSessionActionType, MouseButton, MouseEventType, - NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptMsg, ScriptThreadFactory, - ScriptToConstellationChan, StructuredSerializedData, TimerSchedulerMsg, TouchEventType, - TouchId, UntrustedNodeAddress, UpdatePipelineIdReason, WebrenderIpcSender, WheelDelta, - WindowSizeData, WindowSizeType, -}; -use servo_atoms::Atom; -use servo_config::opts; -use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; -use std::borrow::Cow; -use std::cell::Cell; -use std::cell::RefCell; -use std::collections::{hash_map, HashMap, HashSet}; -use std::default::Default; -use std::ops::Deref; -use std::option::Option; -use std::ptr; -use std::rc::Rc; -use std::result::Result; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use std::thread; -use std::time::{Duration, SystemTime}; -use style::dom::OpaqueNode; -use style::thread_state::{self, ThreadState}; -use time::{at_utc, get_time, precise_time_ns, Timespec}; -use url::Position; -use webgpu::identity::WebGPUMsg; -use webrender_api::units::LayoutPixel; -use webrender_api::DocumentId; +use crate::task_source::{TaskSource, TaskSourceName}; +use crate::{devtools, webdriver_handlers}; pub type ImageCacheMsg = (PipelineId, PendingImageResponse); @@ -1457,9 +1454,8 @@ impl ScriptThread { /// Handle incoming control messages. fn handle_msgs(&self) -> bool { - use self::MixedMessage::FromScript; use self::MixedMessage::{ - FromConstellation, FromDevtools, FromImageCache, FromWebGPUServer, + FromConstellation, FromDevtools, FromImageCache, FromScript, FromWebGPUServer, }; // Handle pending resize events. diff --git a/components/script/serviceworker_manager.rs b/components/script/serviceworker_manager.rs index 7b222546bd8..4bb28c65d56 100644 --- a/components/script/serviceworker_manager.rs +++ b/components/script/serviceworker_manager.rs @@ -7,29 +7,29 @@ //! If an active service worker timeouts, then it removes the descriptor entry from its //! active_workers map -use crate::dom::abstractworker::WorkerScriptMsg; -use crate::dom::serviceworkerglobalscope::{ - ServiceWorkerControlMsg, ServiceWorkerGlobalScope, ServiceWorkerScriptMsg, -}; -use crate::dom::serviceworkerregistration::longest_prefix_match; -use crate::script_runtime::ContextForRequestInterrupt; +use std::collections::HashMap; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::thread::{self, JoinHandle}; + use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender}; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; -use msg::constellation_msg::PipelineNamespace; -use msg::constellation_msg::{ServiceWorkerId, ServiceWorkerRegistrationId}; +use msg::constellation_msg::{PipelineNamespace, ServiceWorkerId, ServiceWorkerRegistrationId}; use net_traits::{CoreResourceMsg, CustomResponseMediator}; use script_traits::{ DOMMessage, Job, JobError, JobResult, JobResultValue, JobType, SWManagerMsg, SWManagerSenders, ScopeThings, ServiceWorkerManagerFactory, ServiceWorkerMsg, }; use servo_config::pref; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; -use std::collections::HashMap; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use std::thread::{self, JoinHandle}; +use servo_url::{ImmutableOrigin, ServoUrl}; + +use crate::dom::abstractworker::WorkerScriptMsg; +use crate::dom::serviceworkerglobalscope::{ + ServiceWorkerControlMsg, ServiceWorkerGlobalScope, ServiceWorkerScriptMsg, +}; +use crate::dom::serviceworkerregistration::longest_prefix_match; +use crate::script_runtime::ContextForRequestInterrupt; enum Message { FromResource(CustomResponseMediator), diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index b7f47b1fcfd..d045f4b52df 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -2,22 +2,10 @@ * 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::document_loader::LoadType; -use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::refcounted::Trusted; -use crate::dom::bindings::reflector::DomObject; -use crate::dom::bindings::root::DomRoot; -use crate::dom::document::Document; -use crate::dom::element::Element; -use crate::dom::eventtarget::EventTarget; -use crate::dom::globalscope::GlobalScope; -use crate::dom::htmlelement::HTMLElement; -use crate::dom::htmllinkelement::{HTMLLinkElement, RequestGenerationId}; -use crate::dom::node::{containing_shadow_root, document_from_node, window_from_node}; -use crate::dom::performanceresourcetiming::InitiatorType; -use crate::dom::shadowroot::ShadowRoot; -use crate::fetch::create_a_potential_cors_request; -use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; +use std::mem; +use std::sync::atomic::AtomicBool; +use std::sync::Mutex; + use cssparser::SourceLocation; use encoding_rs::UTF_8; use ipc_channel::ipc; @@ -27,22 +15,37 @@ use msg::constellation_msg::PipelineId; use net_traits::request::{CorsSettings, Destination, Referrer, RequestBuilder}; use net_traits::{ FetchMetadata, FetchResponseListener, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy, + ResourceFetchTiming, ResourceTimingType, }; -use net_traits::{ResourceFetchTiming, ResourceTimingType}; use servo_arc::Arc; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; -use std::mem; -use std::sync::atomic::AtomicBool; -use std::sync::Mutex; +use servo_url::{ImmutableOrigin, ServoUrl}; use style::media_queries::MediaList; use style::parser::ParserContext; use style::shared_lock::{Locked, SharedRwLock}; use style::stylesheets::import_rule::{ImportLayer, ImportSheet}; -use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; -use style::stylesheets::{CssRules, ImportRule, Origin, Stylesheet, StylesheetContents}; +use style::stylesheets::{ + CssRules, ImportRule, Origin, Stylesheet, StylesheetContents, + StylesheetLoader as StyleStylesheetLoader, +}; use style::values::CssUrl; +use crate::document_loader::LoadType; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::refcounted::Trusted; +use crate::dom::bindings::reflector::DomObject; +use crate::dom::bindings::root::DomRoot; +use crate::dom::document::Document; +use crate::dom::element::Element; +use crate::dom::eventtarget::EventTarget; +use crate::dom::globalscope::GlobalScope; +use crate::dom::htmlelement::HTMLElement; +use crate::dom::htmllinkelement::{HTMLLinkElement, RequestGenerationId}; +use crate::dom::node::{containing_shadow_root, document_from_node, window_from_node}; +use crate::dom::performanceresourcetiming::InitiatorType; +use crate::dom::shadowroot::ShadowRoot; +use crate::fetch::create_a_potential_cors_request; +use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; + pub trait StylesheetOwner { /// Returns whether this element was inserted by the parser (i.e., it should /// trigger a document-load-blocking load). diff --git a/components/script/task_manager.rs b/components/script/task_manager.rs index 184b427cfcb..a64355b6882 100644 --- a/components/script/task_manager.rs +++ b/components/script/task_manager.rs @@ -2,6 +2,10 @@ * 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::collections::HashMap; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; + use crate::dom::bindings::cell::DomRefCell; use crate::task::TaskCanceller; use crate::task_source::dom_manipulation::DOMManipulationTaskSource; @@ -16,9 +20,6 @@ use crate::task_source::timer::TimerTaskSource; use crate::task_source::user_interaction::UserInteractionTaskSource; use crate::task_source::websocket::WebsocketTaskSource; use crate::task_source::TaskSourceName; -use std::collections::HashMap; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; macro_rules! task_source_functions { ($self:ident,$with_canceller:ident,$task_source:ident,$task_source_type:ident,$task_source_name:ident) => { diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index 3ed835563a3..38acc7ed04b 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -4,17 +4,19 @@ //! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue). +use std::cell::Cell; +use std::collections::{HashMap, HashSet, VecDeque}; +use std::default::Default; + +use crossbeam_channel::{self, Receiver, Sender}; +use msg::constellation_msg::PipelineId; + use crate::dom::bindings::cell::DomRefCell; use crate::dom::worker::TrustedWorkerAddress; use crate::script_runtime::ScriptThreadEventCategory; use crate::script_thread::ScriptThread; use crate::task::TaskBox; use crate::task_source::TaskSourceName; -use crossbeam_channel::{self, Receiver, Sender}; -use msg::constellation_msg::PipelineId; -use std::cell::Cell; -use std::collections::{HashMap, HashSet, VecDeque}; -use std::default::Default; pub type QueuedTask = ( Option<TrustedWorkerAddress>, diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index 68316b79fe3..64c2b3a33c6 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -2,6 +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 std::fmt; +use std::result::Result; + +use msg::constellation_msg::PipelineId; +use servo_atoms::Atom; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask}; @@ -10,10 +16,6 @@ use crate::dom::window::Window; use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; -use servo_atoms::Atom; -use std::fmt; -use std::result::Result; #[derive(JSTraceable)] pub struct DOMManipulationTaskSource(pub Box<dyn ScriptChan + Send>, #[no_trace] pub PipelineId); diff --git a/components/script/task_source/file_reading.rs b/components/script/task_source/file_reading.rs index 646778ffea5..ebf37249b59 100644 --- a/components/script/task_source/file_reading.rs +++ b/components/script/task_source/file_reading.rs @@ -2,12 +2,13 @@ * 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 msg::constellation_msg::PipelineId; + use crate::dom::domexception::DOMErrorName; use crate::dom::filereader::{FileReader, GenerationId, ReadMetaData, TrustedFileReader}; use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] pub struct FileReadingTaskSource( diff --git a/components/script/task_source/history_traversal.rs b/components/script/task_source/history_traversal.rs index ecabbddfa55..1676461fa99 100644 --- a/components/script/task_source/history_traversal.rs +++ b/components/script/task_source/history_traversal.rs @@ -2,12 +2,13 @@ * 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 crossbeam_channel::Sender; +use msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use crate::script_thread::MainThreadScriptMsg; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use crossbeam_channel::Sender; -use msg::constellation_msg::PipelineId; #[derive(Clone, JSTraceable)] pub struct HistoryTraversalTaskSource( diff --git a/components/script/task_source/media_element.rs b/components/script/task_source/media_element.rs index 16922a0ec87..64d2f6c2764 100644 --- a/components/script/task_source/media_element.rs +++ b/components/script/task_source/media_element.rs @@ -2,6 +2,13 @@ * 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::fmt; +use std::result::Result; + +use crossbeam_channel::Sender; +use msg::constellation_msg::PipelineId; +use servo_atoms::Atom; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::event::SimpleEventTask; @@ -11,11 +18,6 @@ use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use crate::script_thread::MainThreadScriptMsg; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use crossbeam_channel::Sender; -use msg::constellation_msg::PipelineId; -use servo_atoms::Atom; -use std::fmt; -use std::result::Result; #[derive(Clone, JSTraceable)] pub struct MediaElementTaskSource( diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index 7defd922779..b67b87c8caf 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -14,10 +14,12 @@ pub mod timer; pub mod user_interaction; pub mod websocket; +use std::result::Result; + +use enum_iterator::IntoEnumIterator; + use crate::dom::globalscope::GlobalScope; use crate::task::{TaskCanceller, TaskOnce}; -use enum_iterator::IntoEnumIterator; -use std::result::Result; // The names of all task sources, used to differentiate TaskCancellers. // Note: When adding a task source, update this enum. diff --git a/components/script/task_source/networking.rs b/components/script/task_source/networking.rs index 0193cb22839..b95e20aa9fe 100644 --- a/components/script/task_source/networking.rs +++ b/components/script/task_source/networking.rs @@ -2,10 +2,11 @@ * 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 msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] pub struct NetworkingTaskSource( diff --git a/components/script/task_source/performance_timeline.rs b/components/script/task_source/performance_timeline.rs index 58e2660e6fd..b66f1c496b8 100644 --- a/components/script/task_source/performance_timeline.rs +++ b/components/script/task_source/performance_timeline.rs @@ -6,14 +6,16 @@ // a low priority task and it should be processed during idle periods. // We are currently treating this task queue as a normal priority queue. +use std::fmt; +use std::result::Result; + +use msg::constellation_msg::PipelineId; + use crate::dom::bindings::refcounted::Trusted; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; -use std::fmt; -use std::result::Result; #[derive(JSTraceable)] pub struct PerformanceTimelineTaskSource( diff --git a/components/script/task_source/port_message.rs b/components/script/task_source/port_message.rs index e21230f8099..30fe007cbf4 100644 --- a/components/script/task_source/port_message.rs +++ b/components/script/task_source/port_message.rs @@ -2,11 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::fmt; + +use msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; -use std::fmt; #[derive(JSTraceable)] pub struct PortMessageQueue( diff --git a/components/script/task_source/remote_event.rs b/components/script/task_source/remote_event.rs index 91e132ed719..061558af6c9 100644 --- a/components/script/task_source/remote_event.rs +++ b/components/script/task_source/remote_event.rs @@ -2,10 +2,11 @@ * 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 msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] pub struct RemoteEventTaskSource( diff --git a/components/script/task_source/timer.rs b/components/script/task_source/timer.rs index 9c4d03bdda5..f5bfdbb8f52 100644 --- a/components/script/task_source/timer.rs +++ b/components/script/task_source/timer.rs @@ -2,11 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::fmt; + +use msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; -use std::fmt; #[derive(JSTraceable)] /// https://html.spec.whatwg.org/multipage/#timer-task-source diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs index 1f543d88cfd..a16277f2781 100644 --- a/components/script/task_source/user_interaction.rs +++ b/components/script/task_source/user_interaction.rs @@ -2,6 +2,13 @@ * 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::fmt; +use std::result::Result; + +use crossbeam_channel::Sender; +use msg::constellation_msg::PipelineId; +use servo_atoms::Atom; + use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::event::{EventBubbles, EventCancelable, EventTask}; @@ -11,11 +18,6 @@ use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use crate::script_thread::MainThreadScriptMsg; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use crossbeam_channel::Sender; -use msg::constellation_msg::PipelineId; -use servo_atoms::Atom; -use std::fmt; -use std::result::Result; #[derive(Clone, JSTraceable)] pub struct UserInteractionTaskSource( diff --git a/components/script/task_source/websocket.rs b/components/script/task_source/websocket.rs index 843a9632a8a..ec5e263fe09 100644 --- a/components/script/task_source/websocket.rs +++ b/components/script/task_source/websocket.rs @@ -2,10 +2,11 @@ * 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 msg::constellation_msg::PipelineId; + use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use crate::task::{TaskCanceller, TaskOnce}; use crate::task_source::{TaskSource, TaskSourceName}; -use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] pub struct WebsocketTaskSource( diff --git a/components/script/test.rs b/components/script/test.rs index 247acb80940..406190b0717 100644 --- a/components/script/test.rs +++ b/components/script/test.rs @@ -2,13 +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/. */ -pub use crate::dom::bindings::str::{ByteString, DOMString}; -pub use crate::dom::headers::normalize_value; - // For compile-fail tests only. pub use crate::dom::bindings::cell::DomRefCell; pub use crate::dom::bindings::refcounted::TrustedPromise; pub use crate::dom::bindings::root::Dom; +pub use crate::dom::bindings::str::{ByteString, DOMString}; +pub use crate::dom::headers::normalize_value; pub use crate::dom::node::Node; pub mod area { @@ -17,6 +16,8 @@ pub mod area { #[allow(non_snake_case)] pub mod size_of { + use std::mem::size_of; + use crate::dom::characterdata::CharacterData; use crate::dom::element::Element; use crate::dom::eventtarget::EventTarget; @@ -25,7 +26,6 @@ pub mod size_of { use crate::dom::htmlspanelement::HTMLSpanElement; use crate::dom::node::Node; use crate::dom::text::Text; - use std::mem::size_of; pub fn CharacterData() -> usize { size_of::<CharacterData>() diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 623085ccd19..758d620badd 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -4,18 +4,20 @@ //! Common handling of keyboard input and state management for text input controls -use crate::clipboard_provider::ClipboardProvider; -use crate::dom::bindings::str::DOMString; -use crate::dom::compositionevent::CompositionEvent; -use crate::dom::keyboardevent::KeyboardEvent; -use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher}; use std::borrow::ToOwned; use std::cmp::min; use std::default::Default; use std::ops::{Add, AddAssign, Range}; use std::usize; + +use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher}; use unicode_segmentation::UnicodeSegmentation; +use crate::clipboard_provider::ClipboardProvider; +use crate::dom::bindings::str::DOMString; +use crate::dom::compositionevent::CompositionEvent; +use crate::dom::keyboardevent::KeyboardEvent; + #[derive(Clone, Copy, PartialEq)] pub enum Selection { Selected, diff --git a/components/script/timers.rs b/components/script/timers.rs index c7c2d15ef38..2289c9aac8c 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -2,6 +2,24 @@ * 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::Cell; +use std::cmp::{self, Ord, Ordering}; +use std::collections::HashMap; +use std::default::Default; +use std::rc::Rc; + +use deny_public_fields::DenyPublicFields; +use euclid::Length; +use ipc_channel::ipc::IpcSender; +use js::jsapi::Heap; +use js::jsval::{JSVal, UndefinedValue}; +use js::rust::HandleValue; +use script_traits::{ + precise_time_ms, MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSchedulerMsg, + TimerSource, +}; +use servo_config::pref; + use crate::dom::bindings::callback::ExceptionHandling::Report; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; @@ -14,21 +32,6 @@ use crate::dom::testbinding::TestBindingCallback; use crate::dom::xmlhttprequest::XHRTimeoutCallback; use crate::script_module::ScriptFetchOptions; use crate::script_thread::ScriptThread; -use deny_public_fields::DenyPublicFields; -use euclid::Length; -use ipc_channel::ipc::IpcSender; -use js::jsapi::Heap; -use js::jsval::{JSVal, UndefinedValue}; -use js::rust::HandleValue; -use script_traits::{precise_time_ms, MsDuration}; -use script_traits::{TimerEvent, TimerEventId, TimerEventRequest}; -use script_traits::{TimerSchedulerMsg, TimerSource}; -use servo_config::pref; -use std::cell::Cell; -use std::cmp::{self, Ord, Ordering}; -use std::collections::HashMap; -use std::default::Default; -use std::rc::Rc; #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub struct OneshotTimerHandle(i32); diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index d1b2471777b..a4014a699d9 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -2,6 +2,29 @@ * 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::cmp; +use std::collections::HashMap; +use std::ffi::CString; + +use cookie::Cookie; +use euclid::default::{Point2D, Rect, Size2D}; +use hyper_serde::Serde; +use ipc_channel::ipc::{self, IpcSender}; +use js::jsapi::{HandleValueArray, JSAutoRealm, JSContext, JSType, JS_IsExceptionPending}; +use js::jsval::UndefinedValue; +use js::rust::wrappers::{JS_CallFunctionName, JS_GetProperty, JS_HasOwnProperty, JS_TypeOfValue}; +use js::rust::{HandleObject, HandleValue}; +use msg::constellation_msg::{BrowsingContextId, PipelineId}; +use net_traits::CookieSource::{NonHTTP, HTTP}; +use net_traits::CoreResourceMsg::{DeleteCookies, GetCookiesDataForUrl, SetCookieForUrl}; +use net_traits::IpcSend; +use script_traits::webdriver_msg::{ + WebDriverCookieError, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue, +}; +use servo_url::ServoUrl; +use webdriver::common::{WebElement, WebFrame, WebWindow}; +use webdriver::error::ErrorStatus; + use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; @@ -14,10 +37,8 @@ use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, N use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding::XMLSerializerMethods; use crate::dom::bindings::conversions::{ - get_property, get_property_jsval, is_array_like, root_from_object, -}; -use crate::dom::bindings::conversions::{ - ConversionBehavior, ConversionResult, FromJSValConvertible, StringificationBehavior, + get_property, get_property_jsval, is_array_like, root_from_object, ConversionBehavior, + ConversionResult, FromJSValConvertible, StringificationBehavior, }; use crate::dom::bindings::error::{throw_dom_exception, Error}; use crate::dom::bindings::inheritance::Castable; @@ -41,29 +62,6 @@ use crate::realms::enter_realm; use crate::script_module::ScriptFetchOptions; use crate::script_runtime::JSContext as SafeJSContext; use crate::script_thread::{Documents, ScriptThread}; -use cookie::Cookie; -use euclid::default::{Point2D, Rect, Size2D}; -use hyper_serde::Serde; -use ipc_channel::ipc::{self, IpcSender}; -use js::jsapi::{HandleValueArray, JSAutoRealm, JSContext, JSType, JS_IsExceptionPending}; -use js::jsval::UndefinedValue; -use js::rust::wrappers::{JS_CallFunctionName, JS_GetProperty, JS_HasOwnProperty, JS_TypeOfValue}; -use js::rust::{HandleObject, HandleValue}; -use msg::constellation_msg::BrowsingContextId; -use msg::constellation_msg::PipelineId; -use net_traits::CookieSource::{NonHTTP, HTTP}; -use net_traits::CoreResourceMsg::{DeleteCookies, GetCookiesDataForUrl, SetCookieForUrl}; -use net_traits::IpcSend; -use script_traits::webdriver_msg::WebDriverCookieError; -use script_traits::webdriver_msg::{ - WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue, -}; -use servo_url::ServoUrl; -use std::cmp; -use std::collections::HashMap; -use std::ffi::CString; -use webdriver::common::{WebElement, WebFrame, WebWindow}; -use webdriver::error::ErrorStatus; fn find_node_by_unique_id( documents: &Documents, diff --git a/components/script/window_named_properties.rs b/components/script/window_named_properties.rs index 0a133d2cd34..0140bd7c46e 100644 --- a/components/script/window_named_properties.rs +++ b/components/script/window_named_properties.rs @@ -2,6 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use std::ptr; + +use js::conversions::jsstr_to_string; +use js::glue::{AppendToIdVector, CreateProxyHandler, NewProxyObject, ProxyTraps}; +use js::jsapi::{ + GetWellKnownSymbol, Handle, HandleId, HandleObject, JSClass, JSClass_NON_NATIVE, JSContext, + JSErrNum, JS_SetImmutablePrototype, MutableHandle, MutableHandleIdVector, MutableHandleObject, + ObjectOpResult, PropertyDescriptor, ProxyClassExtension, ProxyClassOps, ProxyObjectOps, + SymbolCode, UndefinedHandleValue, JSCLASS_DELAY_METADATA_BUILDER, JSCLASS_IS_PROXY, + JSCLASS_RESERVED_SLOTS_MASK, JSCLASS_RESERVED_SLOTS_SHIFT, JSPROP_READONLY, +}; +use js::jsid::SymbolId; +use js::jsval::UndefinedValue; +use js::rust::{ + Handle as RustHandle, HandleObject as RustHandleObject, IntoHandle, + MutableHandle as RustMutableHandle, MutableHandleObject as RustMutableHandleObject, +}; +use libc; + use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::proxyhandler::set_property_descriptor; use crate::dom::bindings::root::Root; @@ -10,25 +29,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use crate::js::conversions::ToJSValConvertible; use crate::script_runtime::JSContext as SafeJSContext; -use js::conversions::jsstr_to_string; -use js::glue::{AppendToIdVector, CreateProxyHandler, NewProxyObject, ProxyTraps}; -use js::jsapi::{GetWellKnownSymbol, JS_SetImmutablePrototype, SymbolCode, JSPROP_READONLY}; -use js::jsapi::{ - Handle, HandleObject, JSClass, JSContext, JSErrNum, MutableHandleObject, UndefinedHandleValue, -}; -use js::jsapi::{ - HandleId, JSClass_NON_NATIVE, MutableHandle, MutableHandleIdVector, ObjectOpResult, - PropertyDescriptor, ProxyClassExtension, ProxyClassOps, ProxyObjectOps, - JSCLASS_DELAY_METADATA_BUILDER, JSCLASS_IS_PROXY, JSCLASS_RESERVED_SLOTS_MASK, - JSCLASS_RESERVED_SLOTS_SHIFT, -}; -use js::jsid::SymbolId; -use js::jsval::UndefinedValue; -use js::rust::IntoHandle; -use js::rust::{Handle as RustHandle, MutableHandle as RustMutableHandle}; -use js::rust::{HandleObject as RustHandleObject, MutableHandleObject as RustMutableHandleObject}; -use libc; -use std::ptr; struct SyncWrapper(*const libc::c_void); #[allow(unsafe_code)] diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 9b8fbd7e26f..0db42229678 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -12,6 +12,9 @@ pub mod message; pub mod rpc; pub mod wrapper_traits; +use std::any::Any; +use std::sync::atomic::AtomicIsize; + use atomic_refcell::AtomicRefCell; use canvas_traits::canvas::{CanvasId, CanvasMsg}; use ipc_channel::ipc::IpcSender; @@ -20,8 +23,6 @@ use malloc_size_of_derive::MallocSizeOf; use net_traits::image_cache::PendingImageId; use script_traits::UntrustedNodeAddress; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::any::Any; -use std::sync::atomic::AtomicIsize; use style::data::ElementData; use webrender_api::ImageKey; diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index b20c92d870e..5aeadef6894 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -2,8 +2,9 @@ * 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::rpc::LayoutRPC; -use crate::{PendingImage, TrustedNodeAddress}; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; + use app_units::Au; use crossbeam_channel::{Receiver, Sender}; use euclid::default::{Point2D, Rect}; @@ -14,16 +15,13 @@ use metrics::PaintTimeMetrics; use msg::constellation_msg::{BackgroundHangMonitorRegister, BrowsingContextId, PipelineId}; use net_traits::image_cache::ImageCache; use profile_traits::mem::ReportsChan; -use script_traits::Painter; use script_traits::{ - ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, ScrollState, + ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, Painter, ScrollState, WindowSizeData, }; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; use servo_url::{ImmutableOrigin, ServoUrl}; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; use style::animation::DocumentAnimationSet; use style::context::QuirksMode; use style::dom::OpaqueNode; @@ -32,6 +30,9 @@ use style::properties::PropertyId; use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot}; use style::stylesheets::Stylesheet; +use crate::rpc::LayoutRPC; +use crate::{PendingImage, TrustedNodeAddress}; + /// Asynchronous messages that script can send to layout. pub enum Msg { /// Adds the given stylesheet to the document. The second stylesheet is the diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 3f9710dea9b..1cc20c5f6ab 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -4,35 +4,29 @@ #![allow(unsafe_code)] -use crate::HTMLCanvasData; -use crate::HTMLMediaData; -use crate::LayoutNodeType; -use crate::SVGSVGData; -use crate::StyleAndOpaqueLayoutData; +use std::borrow::Cow; +use std::fmt::Debug; +use std::sync::Arc as StdArc; + use atomic_refcell::AtomicRef; use gfx_traits::{combine_id_with_fragment_type, ByteIndex, FragmentType}; -use html5ever::local_name; -use html5ever::namespace_url; -use html5ever::ns; -use html5ever::{LocalName, Namespace}; +use html5ever::{local_name, namespace_url, ns, LocalName, Namespace}; use msg::constellation_msg::{BrowsingContextId, PipelineId}; use net_traits::image::base::{Image, ImageMetadata}; use range::Range; use servo_arc::Arc; use servo_url::ServoUrl; -use std::borrow::Cow; -use std::fmt::Debug; -use std::sync::Arc as StdArc; use style::attr::AttrValue; use style::context::SharedStyleContext; use style::data::ElementData; -use style::dom::OpaqueNode; -use style::dom::{LayoutIterator, NodeInfo, TElement, TNode}; +use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, TElement, TNode}; use style::properties::ComputedValues; use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl}; use style::stylist::RuleInclusion; use webrender_api::ExternalScrollId; +use crate::{HTMLCanvasData, HTMLMediaData, LayoutNodeType, SVGSVGData, StyleAndOpaqueLayoutData}; + pub trait LayoutDataTrait: Default + Send + Sync + 'static {} #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs index 30fa2dd67b9..4d475637ee8 100644 --- a/components/script_plugins/lib.rs +++ b/components/script_plugins/lib.rs @@ -28,16 +28,13 @@ use rustc_ast::Mutability; use rustc_driver::plugin::Registry; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; -use rustc_hir::PrimTy; -use rustc_hir::{ImplItemRef, ItemKind, Node, OwnerId, TraitItemRef}; +use rustc_hir::{ImplItemRef, ItemKind, Node, OwnerId, PrimTy, TraitItemRef}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; -use rustc_middle::ty::TyCtxt; -use rustc_middle::ty::{self, GenericArg, ParamEnv, Ty, TypeVisitable}; +use rustc_middle::ty::{self, GenericArg, ParamEnv, Ty, TyCtxt, TypeVisitable}; use rustc_span::source_map::{ExpnKind, MacroKind, Span}; -use rustc_span::symbol::Ident; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{Ident, Symbol}; use rustc_span::DUMMY_SP; use rustc_trait_selection::infer::InferCtxtExt; use rustc_type_ir::{FloatTy, IntTy, UintTy}; diff --git a/components/script_plugins/trace_in_no_trace.rs b/components/script_plugins/trace_in_no_trace.rs index fa5b9ef0444..50349cfcfbd 100644 --- a/components/script_plugins/trace_in_no_trace.rs +++ b/components/script_plugins/trace_in_no_trace.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 crate::{get_trait_def_id, implements_trait, symbols}; - use rustc_ast::ast::{AttrKind, Attribute}; use rustc_ast::token::TokenKind; use rustc_ast::tokenstream::TokenTree; @@ -16,6 +14,8 @@ use rustc_middle::ty; use rustc_session::declare_lint; use rustc_span::symbol::Symbol; +use crate::{get_trait_def_id, implements_trait, symbols}; + declare_lint!( TRACE_IN_NO_TRACE, Deny, diff --git a/components/script_plugins/unrooted_must_root.rs b/components/script_plugins/unrooted_must_root.rs index 4e7b57c26a1..90728d64cfa 100644 --- a/components/script_plugins/unrooted_must_root.rs +++ b/components/script_plugins/unrooted_must_root.rs @@ -2,19 +2,17 @@ * 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::{in_derive_expn, match_def_path, symbols}; - use rustc_ast::ast::{AttrKind, Attribute}; use rustc_driver::plugin::Registry; -use rustc_hir::intravisit as visit; -use rustc_hir::{self as hir, ExprKind}; +use rustc_hir::{self as hir, intravisit as visit, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass}; use rustc_middle::ty; use rustc_session::declare_lint; use rustc_span::def_id::LocalDefId; use rustc_span::source_map; -use rustc_span::symbol::sym; -use rustc_span::symbol::Symbol; +use rustc_span::symbol::{sym, Symbol}; + +use crate::{in_derive_expn, match_def_path, symbols}; declare_lint!( UNROOTED_MUST_ROOT, diff --git a/components/script_traits/compositor.rs b/components/script_traits/compositor.rs index 251f6a0c9dc..43ab572e3bc 100644 --- a/components/script_traits/compositor.rs +++ b/components/script_traits/compositor.rs @@ -6,8 +6,8 @@ use embedder_traits::Cursor; use serde::{Deserialize, Serialize}; +use webrender_api::units::{LayoutSize, LayoutVector2D}; use webrender_api::{ - units::{LayoutSize, LayoutVector2D}, Epoch, ExternalScrollId, PipelineId, ScrollLocation, ScrollSensitivity, SpatialId, }; diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c5f4dad9f86..64c213955c2 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -15,15 +15,12 @@ pub mod serializable; pub mod transferable; pub mod webdriver_msg; -use crate::compositor::CompositorDisplayListInfo; -pub use crate::script_msg::{ - DOMMessage, EventResult, HistoryEntryReplacement, IFrameSizeMsg, Job, JobError, JobResult, - JobResultValue, JobType, LayoutMsg, LogEntry, SWManagerMsg, SWManagerSenders, ScopeThings, - ScriptMsg, ServiceWorkerMsg, -}; -use crate::serializable::{BlobData, BlobImpl}; -use crate::transferable::MessagePortImpl; -use crate::webdriver_msg::{LoadStatus, WebDriverScriptCommand}; +use std::borrow::Cow; +use std::collections::{HashMap, VecDeque}; +use std::fmt; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; + use bitflags::bitflags; use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; @@ -31,10 +28,10 @@ use compositor::ScrollTreeNodeId; use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::Cursor; -use euclid::{default::Point2D, Length, Rect, Scale, Size2D, UnknownUnit, Vector2D}; +use euclid::default::Point2D; +use euclid::{Length, Rect, Scale, Size2D, UnknownUnit, Vector2D}; use gfx_traits::Epoch; -use http::HeaderMap; -use http::Method; +use http::{HeaderMap, Method}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::Error as IpcError; use keyboard_types::webdriver::Event as WebDriverInputEvent; @@ -44,30 +41,21 @@ use log::warn; use malloc_size_of::malloc_size_of_is_0; use malloc_size_of_derive::MallocSizeOf; use media::WindowGLContext; -use msg::constellation_msg::BackgroundHangMonitorRegister; use msg::constellation_msg::{ - BlobId, BrowsingContextId, HistoryStateId, MessagePortId, PipelineId, + BackgroundHangMonitorRegister, BlobId, BrowsingContextId, HistoryStateId, MessagePortId, + PipelineId, PipelineNamespaceId, TopLevelBrowsingContextId, }; -use msg::constellation_msg::{PipelineNamespaceId, TopLevelBrowsingContextId}; use net_traits::image::base::Image; use net_traits::image_cache::ImageCache; use net_traits::request::{Referrer, RequestBody}; use net_traits::storage_thread::StorageType; use net_traits::{FetchResponseMsg, ReferrerPolicy, ResourceThreads}; use pixels::PixelFormat; -use profile_traits::mem; -use profile_traits::time as profile_time; +use profile_traits::{mem, time as profile_time}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use servo_atoms::Atom; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; -use std::borrow::Cow; -use std::collections::{HashMap, VecDeque}; -use std::fmt; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; -use style_traits::CSSPixel; -use style_traits::SpeculativePainter; +use servo_url::{ImmutableOrigin, ServoUrl}; +use style_traits::{CSSPixel, SpeculativePainter}; use webgpu::identity::WebGPUMsg; use webrender_api::units::{DeviceIntSize, DevicePixel, LayoutPixel, LayoutPoint, WorldPoint}; use webrender_api::{ @@ -75,6 +63,16 @@ use webrender_api::{ HitTestFlags, ImageData, ImageDescriptor, ImageKey, PipelineId as WebRenderPipelineId, }; +use crate::compositor::CompositorDisplayListInfo; +pub use crate::script_msg::{ + DOMMessage, EventResult, HistoryEntryReplacement, IFrameSizeMsg, Job, JobError, JobResult, + JobResultValue, JobType, LayoutMsg, LogEntry, SWManagerMsg, SWManagerSenders, ScopeThings, + ScriptMsg, ServiceWorkerMsg, +}; +use crate::serializable::{BlobData, BlobImpl}; +use crate::transferable::MessagePortImpl; +use crate::webdriver_msg::{LoadStatus, WebDriverScriptCommand}; + /// The address of a node. Layout sends these back. They must be validated via /// `from_untrusted_node_address` before they can be used, because we do not trust layout. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 2a840325ce9..42be2685ccf 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -2,19 +2,9 @@ * 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::AnimationState; -use crate::AuxiliaryBrowsingContextLoadInfo; -use crate::BroadcastMsg; -use crate::DocumentState; -use crate::IFrameLoadInfoWithData; -use crate::LayoutControlMsg; -use crate::LoadData; -use crate::MessagePortMsg; -use crate::PortMessageTask; -use crate::StructuredSerializedData; -use crate::WindowSizeType; -use crate::WorkerGlobalScopeInit; -use crate::WorkerScriptLoadOrigin; +use std::collections::{HashMap, VecDeque}; +use std::fmt; + use canvas_traits::canvas::{CanvasId, CanvasMsg}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::{EmbedderMsg, MediaSessionEvent}; @@ -23,25 +13,26 @@ use euclid::Size2D; use gfx_traits::Epoch; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::{ - BroadcastChannelRouterId, BrowsingContextId, MessagePortId, MessagePortRouterId, PipelineId, - TopLevelBrowsingContextId, + BroadcastChannelRouterId, BrowsingContextId, HistoryStateId, MessagePortId, + MessagePortRouterId, PipelineId, ServiceWorkerId, ServiceWorkerRegistrationId, + TopLevelBrowsingContextId, TraversalDirection, }; -use msg::constellation_msg::{HistoryStateId, TraversalDirection}; -use msg::constellation_msg::{ServiceWorkerId, ServiceWorkerRegistrationId}; use net_traits::request::RequestBuilder; use net_traits::storage_thread::StorageType; use net_traits::CoreResourceMsg; -use serde::Deserialize; -use serde::Serialize; -use servo_url::ImmutableOrigin; -use servo_url::ServoUrl; +use serde::{Deserialize, Serialize}; +use servo_url::{ImmutableOrigin, ServoUrl}; use smallvec::SmallVec; -use std::collections::{HashMap, VecDeque}; -use std::fmt; use style_traits::CSSPixel; use webgpu::{wgpu, WebGPU, WebGPUResponseResult}; use webrender_api::units::{DeviceIntPoint, DeviceIntSize}; +use crate::{ + AnimationState, AuxiliaryBrowsingContextLoadInfo, BroadcastMsg, DocumentState, + IFrameLoadInfoWithData, LayoutControlMsg, LoadData, MessagePortMsg, PortMessageTask, + StructuredSerializedData, WindowSizeType, WorkerGlobalScopeInit, WorkerScriptLoadOrigin, +}; + /// An iframe sizing operation. #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct IFrameSizeMsg { diff --git a/components/script_traits/serializable.rs b/components/script_traits/serializable.rs index 8919b634a04..1b19201a73b 100644 --- a/components/script_traits/serializable.rs +++ b/components/script_traits/serializable.rs @@ -8,12 +8,13 @@ //! so that the other modules involved in the serialization don't have //! to depend on script. +use std::cell::RefCell; +use std::path::PathBuf; + use malloc_size_of_derive::MallocSizeOf; use msg::constellation_msg::BlobId; use net_traits::filemanager_thread::RelativePos; use serde::{Deserialize, Serialize}; -use std::cell::RefCell; -use std::path::PathBuf; use uuid::Uuid; /// File-based blob diff --git a/components/script_traits/tests/compositor.rs b/components/script_traits/tests/compositor.rs index e937d3c2cad..a6685c3a76c 100644 --- a/components/script_traits/tests/compositor.rs +++ b/components/script_traits/tests/compositor.rs @@ -4,10 +4,8 @@ use euclid::Size2D; use script_traits::compositor::{ScrollTree, ScrollTreeNodeId, ScrollableNodeInfo}; -use webrender_api::{ - units::LayoutVector2D, ExternalScrollId, PipelineId, ScrollLocation, ScrollSensitivity, - SpatialId, -}; +use webrender_api::units::LayoutVector2D; +use webrender_api::{ExternalScrollId, PipelineId, ScrollLocation, ScrollSensitivity, SpatialId}; fn add_mock_scroll_node(tree: &mut ScrollTree) -> ScrollTreeNodeId { let pipeline_id = PipelineId(0, 0); diff --git a/components/script_traits/transferable.rs b/components/script_traits/transferable.rs index 86ec33af996..1b579899b61 100644 --- a/components/script_traits/transferable.rs +++ b/components/script_traits/transferable.rs @@ -7,11 +7,13 @@ //! so that the other modules involved in the transfer don't have //! to depend on script. -use crate::PortMessageTask; +use std::collections::VecDeque; + use malloc_size_of_derive::MallocSizeOf; use msg::constellation_msg::MessagePortId; use serde::{Deserialize, Serialize}; -use std::collections::VecDeque; + +use crate::PortMessageTask; #[derive(Debug, Deserialize, MallocSizeOf, Serialize)] enum MessagePortState { diff --git a/components/script_traits/webdriver_msg.rs b/components/script_traits/webdriver_msg.rs index 33588406bec..d72d93b61cb 100644 --- a/components/script_traits/webdriver_msg.rs +++ b/components/script_traits/webdriver_msg.rs @@ -4,6 +4,8 @@ #![allow(missing_docs)] +use std::collections::HashMap; + use cookie::Cookie; use euclid::default::Rect; use hyper_serde::Serde; @@ -11,7 +13,6 @@ use ipc_channel::ipc::IpcSender; use msg::constellation_msg::BrowsingContextId; use serde::{Deserialize, Serialize}; use servo_url::ServoUrl; -use std::collections::HashMap; use webdriver::common::{WebElement, WebFrame, WebWindow}; use webdriver::error::ErrorStatus; diff --git a/components/servo/build.rs b/components/servo/build.rs index 278afb641eb..6920fbcfbb1 100644 --- a/components/servo/build.rs +++ b/components/servo/build.rs @@ -2,10 +2,9 @@ * 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::env; -use std::fs; use std::path::Path; use std::process::Command; +use std::{env, fs}; fn main() { println!("cargo:rerun-if-changed=../../python/servo/gstreamer.py"); diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 175bc33777a..baa59a06df8 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -17,44 +17,12 @@ //! `Servo` is fed events from a generic type that implements the //! `WindowMethods` trait. -pub use background_hang_monitor; -pub use bluetooth; -pub use bluetooth_traits; -pub use canvas; -pub use canvas_traits; -pub use compositing; -pub use constellation; -pub use devtools; -pub use devtools_traits; -pub use embedder_traits; -pub use euclid; -pub use gfx; -pub use gleam::gl; -pub use ipc_channel; -pub use keyboard_types; -pub use layout_thread_2013; -pub use layout_thread_2020; -pub use media; -pub use msg; -pub use msg::constellation_msg::TopLevelBrowsingContextId as BrowserId; -pub use net; -pub use net_traits; -pub use profile; -pub use profile_traits; -pub use script; -pub use script_layout_interface; -pub use script_traits; -pub use servo_config as config; -pub use servo_config; -pub use servo_geometry; -pub use servo_url as url; -pub use servo_url; -pub use style; -pub use style_traits; -pub use webgpu; -pub use webrender_api; -pub use webrender_surfman; -pub use webrender_traits; +use std::borrow::Cow; +use std::cmp::max; +use std::collections::HashMap; +use std::path::PathBuf; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; use bluetooth::BluetoothThreadFactory; use bluetooth_traits::BluetoothRequest; @@ -75,8 +43,10 @@ use compositing_traits::{ not(target_arch = "aarch64") ))] use constellation::content_process_sandbox_profile; -use constellation::{Constellation, InitialConstellationState, UnprivilegedContent}; -use constellation::{FromCompositorLogger, FromScriptLogger}; +use constellation::{ + Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState, + UnprivilegedContent, +}; use crossbeam_channel::{unbounded, Sender}; use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker}; use env_logger::Builder as EnvLoggerBuilder; @@ -90,36 +60,36 @@ use euclid::Scale; ))] use gaol::sandbox::{ChildSandbox, ChildSandboxMethods}; use gfx::font_cache_thread::FontCacheThread; +pub use gleam::gl; use ipc_channel::ipc::{self, IpcSender}; use log::{error, warn, Log, Metadata, Record}; use media::{GLPlayerThreads, WindowGLContext}; +pub use msg::constellation_msg::TopLevelBrowsingContextId as BrowserId; use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId}; use net::resource_thread::new_resource_threads; use net_traits::IpcSend; -use profile::mem as profile_mem; -use profile::time as profile_time; -use profile_traits::mem; -use profile_traits::time; +use profile::{mem as profile_mem, time as profile_time}; +use profile_traits::{mem, time}; use script::serviceworker_manager::ServiceWorkerManager; use script::JSEngineSetup; use script_traits::{ScriptToConstellationChan, WindowSizeData}; -use servo_config::opts; -use servo_config::{pref, prefs}; +use servo_config::{opts, pref, prefs}; use servo_media::player::context::GlContext; use servo_media::ServoMedia; -use std::borrow::Cow; -use std::cmp::max; -use std::collections::HashMap; -use std::path::PathBuf; -use std::rc::Rc; -use std::sync::Arc; -use std::sync::Mutex; use surfman::GLApi; use webrender::{RenderApiSender, ShaderPrecacheFlags}; use webrender_api::{DocumentId, FontInstanceKey, FontKey, ImageKey}; -use webrender_traits::WebrenderExternalImageHandlers; -use webrender_traits::WebrenderExternalImageRegistry; -use webrender_traits::WebrenderImageHandlerType; +use webrender_traits::{ + WebrenderExternalImageHandlers, WebrenderExternalImageRegistry, WebrenderImageHandlerType, +}; +pub use { + background_hang_monitor, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing, + constellation, devtools, devtools_traits, embedder_traits, euclid, gfx, ipc_channel, + keyboard_types, layout_thread_2013, layout_thread_2020, media, msg, net, net_traits, profile, + profile_traits, script, script_layout_interface, script_traits, servo_config as config, + servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu, + webrender_api, webrender_surfman, webrender_traits, +}; #[cfg(feature = "webdriver")] fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) { @@ -136,9 +106,10 @@ mod media_platform { include!(concat!(env!("OUT_DIR"), "/gstreamer_plugins.rs")); } - use super::ServoMedia; use servo_media_gstreamer::GStreamerBackend; + use super::ServoMedia; + #[cfg(any(windows, target_os = "macos"))] pub fn init() { let mut plugin_dir = std::env::current_exe().unwrap(); diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index fccbde99c6e..7e11c70f4e6 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -25,27 +25,23 @@ // duplicate those here. #![allow(missing_docs)] -use nodrop::NoDrop; -#[cfg(feature = "servo")] -use serde::{Deserialize, Serialize}; -use stable_deref_trait::{CloneStableDeref, StableDeref}; use std::alloc::{self, Layout}; -use std::borrow; use std::cmp::Ordering; use std::convert::From; -use std::fmt; use std::hash::{Hash, Hasher}; use std::iter::{ExactSizeIterator, Iterator}; use std::marker::PhantomData; use std::mem::{self, align_of, size_of}; use std::ops::{Deref, DerefMut}; use std::os::raw::c_void; -use std::process; -use std::ptr; -use std::slice; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; -use std::{isize, usize}; +use std::{borrow, fmt, isize, process, ptr, slice, usize}; + +use nodrop::NoDrop; +#[cfg(feature = "servo")] +use serde::{Deserialize, Serialize}; +use stable_deref_trait::{CloneStableDeref, StableDeref}; /// A soft limit on the amount of references that may be made to an `Arc`. /// @@ -1430,12 +1426,13 @@ impl<A: fmt::Debug, B: fmt::Debug> fmt::Debug for ArcUnion<A, B> { #[cfg(test)] mod tests { - use super::{Arc, HeaderWithLength, ThinArc}; use std::clone::Clone; use std::ops::Drop; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, SeqCst}; + use super::{Arc, HeaderWithLength, ThinArc}; + #[derive(PartialEq)] struct Canary(*mut atomic::AtomicUsize); diff --git a/components/style_traits/arc_slice.rs b/components/style_traits/arc_slice.rs index e55861d183b..baa2798923d 100644 --- a/components/style_traits/arc_slice.rs +++ b/components/style_traits/arc_slice.rs @@ -4,16 +4,16 @@ //! A thin atomically-reference-counted slice. -use lazy_static::lazy_static; -use serde::de::{Deserialize, Deserializer}; -use serde::ser::{Serialize, Serializer}; -use servo_arc::ThinArc; use std::ops::Deref; use std::ptr::NonNull; use std::{iter, mem}; -use to_shmem_derive::ToShmem; +use lazy_static::lazy_static; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalSizeOf}; +use serde::de::{Deserialize, Deserializer}; +use serde::ser::{Serialize, Serializer}; +use servo_arc::ThinArc; +use to_shmem_derive::ToShmem; /// A canary that we stash in ArcSlices. /// diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index addf538d754..1fe46743293 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -11,17 +11,16 @@ #![deny(unsafe_code, missing_docs)] use bitflags::bitflags; +use cssparser::{CowRcStr, Token}; use malloc_size_of_derive::MallocSizeOf; +use selectors::parser::SelectorParseErrorKind; use serde::{Deserialize, Serialize}; +#[cfg(feature = "servo")] +use servo_atoms::Atom; use size_of_test::size_of_test; #[cfg(feature = "servo")] pub use webrender_api::units::DevicePixel; -use cssparser::{CowRcStr, Token}; -use selectors::parser::SelectorParseErrorKind; -#[cfg(feature = "servo")] -use servo_atoms::Atom; - /// One hardware pixel. /// /// This unit corresponds to the smallest addressable element of the display hardware. diff --git a/components/style_traits/owned_slice.rs b/components/style_traits/owned_slice.rs index 36ba3162e59..5a1b1006ccd 100644 --- a/components/style_traits/owned_slice.rs +++ b/components/style_traits/owned_slice.rs @@ -6,13 +6,14 @@ //! A replacement for `Box<[T]>` that cbindgen can understand. -use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps}; -use serde::de::{Deserialize, Deserializer}; -use serde::ser::{Serialize, Serializer}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::ptr::NonNull; use std::{fmt, iter, mem, slice}; + +use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps}; +use serde::de::{Deserialize, Deserializer}; +use serde::ser::{Serialize, Serializer}; use to_shmem::{self, SharedMemoryBuilder, ToShmem}; /// A struct that basically replaces a `Box<[T]>`, but which cbindgen can diff --git a/components/style_traits/owned_str.rs b/components/style_traits/owned_str.rs index 05a3738ac4d..b7f1f29b8a9 100644 --- a/components/style_traits/owned_str.rs +++ b/components/style_traits/owned_str.rs @@ -6,12 +6,14 @@ //! A replacement for `Box<str>` that has a defined layout for FFI. -use crate::owned_slice::OwnedSlice; -use malloc_size_of_derive::MallocSizeOf; use std::fmt; use std::ops::{Deref, DerefMut}; + +use malloc_size_of_derive::MallocSizeOf; use to_shmem_derive::ToShmem; +use crate::owned_slice::OwnedSlice; + /// A struct that basically replaces a Box<str>, but with a defined layout, /// suitable for FFI. #[repr(C)] diff --git a/components/style_traits/specified_value_info.rs b/components/style_traits/specified_value_info.rs index 1dd368d36e9..e1555758ee9 100644 --- a/components/style_traits/specified_value_info.rs +++ b/components/style_traits/specified_value_info.rs @@ -4,12 +4,14 @@ //! Value information for devtools. -use crate::arc_slice::ArcSlice; -use crate::owned_slice::OwnedSlice; -use servo_arc::Arc; use std::ops::Range; use std::sync::Arc as StdArc; +use servo_arc::Arc; + +use crate::arc_slice::ArcSlice; +use crate::owned_slice::OwnedSlice; + /// Type of value that a property supports. This is used by Gecko's /// devtools to make sense about value it parses, and types listed /// here should match InspectorPropertyType in InspectorUtils.webidl. diff --git a/components/style_traits/values.rs b/components/style_traits/values.rs index 3bae5d2553b..4cfcd131493 100644 --- a/components/style_traits/values.rs +++ b/components/style_traits/values.rs @@ -4,11 +4,13 @@ //! Helper types and traits for the handling of CSS values. +use std::fmt::{self, Write}; + use app_units::Au; -use cssparser::ToCss as CssparserToCss; -use cssparser::{serialize_string, ParseError, Parser, Token, UnicodeRange}; +use cssparser::{ + serialize_string, ParseError, Parser, ToCss as CssparserToCss, Token, UnicodeRange, +}; use servo_arc::Arc; -use std::fmt::{self, Write}; /// Serialises a value according to its CSS representation. /// @@ -562,10 +564,11 @@ macro_rules! define_css_keyword_enum { /// Helper types for the handling of specified values. pub mod specified { - use crate::ParsingMode; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; + use crate::ParsingMode; + /// Whether to allow negative lengths or not. #[repr(u8)] #[derive( diff --git a/components/style_traits/viewport.rs b/components/style_traits/viewport.rs index 4f59f74a764..c5b25293188 100644 --- a/components/style_traits/viewport.rs +++ b/components/style_traits/viewport.rs @@ -4,14 +4,16 @@ //! Helper types for the `@viewport` rule. -use crate::{CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; +use std::fmt::{self, Write}; + use cssparser::*; use euclid::Size2D; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Write}; use to_shmem_derive::ToShmem; +use crate::{CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; + define_css_keyword_enum! { pub enum UserZoom { Zoom = "zoom", diff --git a/components/to_shmem/lib.rs b/components/to_shmem/lib.rs index 6de65ff440e..cab0fba3748 100644 --- a/components/to_shmem/lib.rs +++ b/components/to_shmem/lib.rs @@ -12,16 +12,12 @@ #![crate_name = "to_shmem"] #![crate_type = "rlib"] -use servo_arc::{Arc, ThinArc}; -use smallbitvec::{InternalStorage, SmallBitVec}; -use smallvec::{Array, SmallVec}; use std::alloc::Layout; #[cfg(debug_assertions)] use std::any::TypeId; #[cfg(debug_assertions)] use std::collections::HashSet; use std::ffi::CString; -use std::isize; use std::marker::PhantomData; use std::mem::{self, ManuallyDrop}; use std::num::Wrapping; @@ -30,8 +26,11 @@ use std::os::raw::c_char; #[cfg(debug_assertions)] use std::os::raw::c_void; use std::ptr::{self, NonNull}; -use std::slice; -use std::str; +use std::{isize, slice, str}; + +use servo_arc::{Arc, ThinArc}; +use smallbitvec::{InternalStorage, SmallBitVec}; +use smallvec::{Array, SmallVec}; /// Result type for ToShmem::to_shmem. /// diff --git a/components/url/lib.rs b/components/url/lib.rs index 6d2fbff9f9d..4b664235513 100644 --- a/components/url/lib.rs +++ b/components/url/lib.rs @@ -8,10 +8,6 @@ pub mod origin; -pub use crate::origin::{ImmutableOrigin, MutableOrigin, OpaqueOrigin}; - -use malloc_size_of_derive::MallocSizeOf; -use serde::{Deserialize, Serialize}; use std::collections::hash_map::DefaultHasher; use std::fmt; use std::hash::Hasher; @@ -19,10 +15,14 @@ use std::net::IpAddr; use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo}; use std::path::Path; use std::sync::Arc; + +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; use to_shmem::{SharedMemoryBuilder, ToShmem}; +pub use url::Host; use url::{Position, Url}; -pub use url::Host; +pub use crate::origin::{ImmutableOrigin, MutableOrigin, OpaqueOrigin}; #[derive(Clone, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct ServoUrl(#[ignore_malloc_size_of = "Arc"] Arc<Url>); diff --git a/components/url/origin.rs b/components/url/origin.rs index 77abef4c349..ce557eade60 100644 --- a/components/url/origin.rs +++ b/components/url/origin.rs @@ -2,11 +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 std::cell::RefCell; +use std::rc::Rc; + use malloc_size_of::malloc_size_of_is_0; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; -use std::cell::RefCell; -use std::rc::Rc; use url::{Host, Origin}; use uuid::Uuid; diff --git a/components/webdriver_server/actions.rs b/components/webdriver_server/actions.rs index f84f3dc141b..435d9a13dba 100644 --- a/components/webdriver_server/actions.rs +++ b/components/webdriver_server/actions.rs @@ -2,24 +2,24 @@ * 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::Handler; +use std::collections::HashSet; +use std::time::{Duration, Instant}; +use std::{cmp, thread}; + use compositing_traits::ConstellationMsg; use ipc_channel::ipc; use keyboard_types::webdriver::KeyInputState; use script_traits::webdriver_msg::WebDriverScriptCommand; use script_traits::{MouseButton, MouseEventType, WebDriverCommandMsg}; -use std::cmp; -use std::collections::HashSet; -use std::thread; -use std::time::{Duration, Instant}; -use webdriver::actions::{ActionSequence, ActionsType, GeneralAction, NullActionItem}; -use webdriver::actions::{KeyAction, KeyActionItem, KeyDownAction, KeyUpAction}; use webdriver::actions::{ - PointerAction, PointerActionItem, PointerActionParameters, PointerDownAction, + ActionSequence, ActionsType, GeneralAction, KeyAction, KeyActionItem, KeyDownAction, + KeyUpAction, NullActionItem, PointerAction, PointerActionItem, PointerActionParameters, + PointerDownAction, PointerMoveAction, PointerOrigin, PointerType, PointerUpAction, }; -use webdriver::actions::{PointerMoveAction, PointerOrigin, PointerType, PointerUpAction}; use webdriver::error::ErrorStatus; +use crate::Handler; + // Interval between pointerMove increments in ms, based on common vsync static POINTERMOVE_INTERVAL: u64 = 17; diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 3dc69e6b581..1c2682ded5f 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -9,7 +9,13 @@ mod actions; mod capabilities; -use crate::actions::{InputSourceState, PointerInputState}; +use std::borrow::ToOwned; +use std::collections::{BTreeMap, HashMap}; +use std::io::Cursor; +use std::net::{SocketAddr, SocketAddrV4}; +use std::time::Duration; +use std::{fmt, mem, thread}; + use base64::Engine; use capabilities::ServoCapabilities; use compositing_traits::ConstellationMsg; @@ -24,25 +30,18 @@ use log::{debug, info}; use msg::constellation_msg::{BrowsingContextId, TopLevelBrowsingContextId, TraversalDirection}; use net_traits::request::Referrer; use pixels::PixelFormat; -use script_traits::webdriver_msg::{LoadStatus, WebDriverCookieError, WebDriverFrameId}; use script_traits::webdriver_msg::{ - WebDriverJSError, WebDriverJSResult, WebDriverJSValue, WebDriverScriptCommand, + LoadStatus, WebDriverCookieError, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, + WebDriverJSValue, WebDriverScriptCommand, }; use script_traits::{LoadData, LoadOrigin, WebDriverCommandMsg}; use serde::de::{Deserializer, MapAccess, Visitor}; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use servo_config::{prefs, prefs::PrefValue}; +use servo_config::prefs; +use servo_config::prefs::PrefValue; use servo_url::ServoUrl; -use std::borrow::ToOwned; -use std::collections::{BTreeMap, HashMap}; -use std::fmt; -use std::io::Cursor; -use std::mem; -use std::net::{SocketAddr, SocketAddrV4}; -use std::thread; -use std::time::Duration; use style_traits::CSSPixel; use uuid::Uuid; use webdriver::actions::{ @@ -50,24 +49,23 @@ use webdriver::actions::{ PointerUpAction, }; use webdriver::capabilities::{Capabilities, CapabilitiesMatching}; -use webdriver::command::{ActionsParameters, SwitchToWindowParameters}; use webdriver::command::{ - AddCookieParameters, GetParameters, JavascriptCommandParameters, LocatorParameters, -}; -use webdriver::command::{ - NewSessionParameters, SendKeysParameters, SwitchToFrameParameters, TimeoutsParameters, -}; -use webdriver::command::{ - WebDriverCommand, WebDriverExtensionCommand, WebDriverMessage, WindowRectParameters, + ActionsParameters, AddCookieParameters, GetParameters, JavascriptCommandParameters, + LocatorParameters, NewSessionParameters, SendKeysParameters, SwitchToFrameParameters, + SwitchToWindowParameters, TimeoutsParameters, WebDriverCommand, WebDriverExtensionCommand, + WebDriverMessage, WindowRectParameters, }; use webdriver::common::{Cookie, Date, LocatorStrategy, Parameters, WebElement}; use webdriver::error::{ErrorStatus, WebDriverError, WebDriverResult}; use webdriver::httpapi::WebDriverExtensionRoute; -use webdriver::response::{CookieResponse, CookiesResponse}; -use webdriver::response::{ElementRectResponse, NewSessionResponse, ValueResponse}; -use webdriver::response::{TimeoutsResponse, WebDriverResponse, WindowRectResponse}; +use webdriver::response::{ + CookieResponse, CookiesResponse, ElementRectResponse, NewSessionResponse, TimeoutsResponse, + ValueResponse, WebDriverResponse, WindowRectResponse, +}; use webdriver::server::{self, Session, SessionTeardownKind, WebDriverHandler}; +use crate::actions::{InputSourceState, PointerInputState}; + fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> { return vec![ ( diff --git a/components/webgpu/identity.rs b/components/webgpu/identity.rs index 64647a5c186..4f4121a6652 100644 --- a/components/webgpu/identity.rs +++ b/components/webgpu/identity.rs @@ -2,20 +2,21 @@ * 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::wgpu::{ - id::{ - AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId, - DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId, - ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId, TypedId, - }, - identity::{GlobalIdentityHandlerFactory, IdentityHandler, IdentityHandlerFactory}, -}; -use crate::wgt::Backend; -use crate::{ErrorScopeId, WebGPUDevice, WebGPURequest}; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use serde::{Deserialize, Serialize}; +use crate::wgpu::id::{ + AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId, + DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId, + ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId, TypedId, +}; +use crate::wgpu::identity::{ + GlobalIdentityHandlerFactory, IdentityHandler, IdentityHandlerFactory, +}; +use crate::wgt::Backend; +use crate::{ErrorScopeId, WebGPUDevice, WebGPURequest}; + #[derive(Clone, Debug, Deserialize, Serialize)] pub enum WebGPUOpResult { ValidationError(String), diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs index 9c228c70435..443190fced7 100644 --- a/components/webgpu/lib.rs +++ b/components/webgpu/lib.rs @@ -4,11 +4,19 @@ use log::{error, warn}; use wgpu::gfx_select; -pub use wgpu_core as wgpu; -pub use wgpu_types as wgt; +pub use {wgpu_core as wgpu, wgpu_types as wgt}; pub mod identity; +use std::borrow::Cow; +use std::cell::RefCell; +use std::collections::HashMap; +use std::num::NonZeroU64; +use std::rc::Rc; +use std::slice; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + use arrayvec::ArrayVec; use euclid::default::Size2D; use identity::{IdentityRecyclerFactory, WebGPUMsg, WebGPUOpResult}; @@ -18,37 +26,26 @@ use msg::constellation_msg::PipelineId; use serde::{Deserialize, Serialize}; use servo_config::pref; use smallvec::SmallVec; -use std::borrow::Cow; -use std::cell::RefCell; -use std::collections::HashMap; -use std::num::NonZeroU64; -use std::rc::Rc; -use std::slice; -use std::sync::{Arc, Mutex}; -use std::time::{Duration, Instant}; use webrender::{RenderApi, RenderApiSender, Transaction}; use webrender_api::{DirtyRect, DocumentId, ExternalImageId, ImageData, ImageDescriptor, ImageKey}; use webrender_traits::{ WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageHandlerType, WebrenderImageSource, }; -use wgpu::device::DeviceDescriptor; -use wgpu::pipeline::ShaderModuleDescriptor; -use wgpu::resource::{BufferMapCallback, BufferMapCallbackC}; -use wgpu::{ - binding_model::{BindGroupDescriptor, BindGroupLayoutDescriptor, PipelineLayoutDescriptor}, - command::{ - ComputePass, ImageCopyBuffer, ImageCopyTexture, RenderBundleDescriptor, - RenderBundleEncoder, RenderPass, - }, - device::{HostMap, ImplicitPipelineIds}, - id, - instance::RequestAdapterOptions, - pipeline::{ComputePipelineDescriptor, RenderPipelineDescriptor}, - resource::{ - BufferDescriptor, BufferMapAsyncStatus, BufferMapOperation, SamplerDescriptor, - TextureDescriptor, TextureViewDescriptor, - }, +use wgpu::binding_model::{ + BindGroupDescriptor, BindGroupLayoutDescriptor, PipelineLayoutDescriptor, +}; +use wgpu::command::{ + ComputePass, ImageCopyBuffer, ImageCopyTexture, RenderBundleDescriptor, RenderBundleEncoder, + RenderPass, +}; +use wgpu::device::{DeviceDescriptor, HostMap, ImplicitPipelineIds}; +use wgpu::id; +use wgpu::instance::RequestAdapterOptions; +use wgpu::pipeline::{ComputePipelineDescriptor, RenderPipelineDescriptor, ShaderModuleDescriptor}; +use wgpu::resource::{ + BufferDescriptor, BufferMapAsyncStatus, BufferMapCallback, BufferMapCallbackC, + BufferMapOperation, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor, }; use wgt::{Dx12Compiler, InstanceDescriptor}; diff --git a/components/webrender_surfman/lib.rs b/components/webrender_surfman/lib.rs index 004bf9e048c..4d2d4346d2c 100644 --- a/components/webrender_surfman/lib.rs +++ b/components/webrender_surfman/lib.rs @@ -4,11 +4,11 @@ #![deny(unsafe_code)] -use euclid::default::Size2D; - use std::cell::RefCell; use std::ffi::c_void; use std::rc::Rc; + +use euclid::default::Size2D; use surfman::chains::{PreserveBuffer, SwapChain}; use surfman::{ Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device, Error, GLApi, diff --git a/components/webrender_traits/lib.rs b/components/webrender_traits/lib.rs index d30853d19d4..8e48d94e439 100644 --- a/components/webrender_traits/lib.rs +++ b/components/webrender_traits/lib.rs @@ -4,9 +4,10 @@ #![deny(unsafe_code)] -use euclid::default::Size2D; use std::collections::HashMap; use std::sync::{Arc, Mutex}; + +use euclid::default::Size2D; use webrender_api::units::TexelRect; use webrender_api::{ ExternalImage, ExternalImageHandler, ExternalImageId, ExternalImageSource, ImageRendering, |