diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-11-01 21:43:04 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-11-08 09:28:00 +0100 |
commit | 2012be4a8bd97f2fd69f986c8fffb1af1eec21dc (patch) | |
tree | c9f1ef91146253f72987cb1436866523880965e0 | |
parent | b1fd6237d1304f3d57abdafd3e6e738c1ece9f83 (diff) | |
download | servo-2012be4a8bd97f2fd69f986c8fffb1af1eec21dc.tar.gz servo-2012be4a8bd97f2fd69f986c8fffb1af1eec21dc.zip |
`cargo fix --edition-idioms`
203 files changed, 665 insertions, 1281 deletions
diff --git a/Cargo.lock b/Cargo.lock index 75170722149..845335f733f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2925,13 +2925,13 @@ dependencies = [ "heartbeats-simple 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "influent 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "profile_traits 0.0.1", "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_allocator 0.0.1", "servo_config 0.0.1", "task_info 0.0.1", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2945,7 +2945,6 @@ dependencies = [ "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile 0.0.1", "profile_traits 0.0.1", - "servo_allocator 0.0.1", "servo_config 0.0.1", ] diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index 963ff5f759b..3ce50be8b22 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -10,9 +10,11 @@ static ALLOC: Allocator = Allocator; pub use crate::platform::*; #[cfg(not(windows))] -mod platform { - extern crate jemalloc_sys as ffi; +pub use jemalloc_sys; +#[cfg(not(windows))] +mod platform { + use jemalloc_sys as ffi; use std::alloc::{GlobalAlloc, Layout}; use std::os::raw::{c_int, c_void}; @@ -96,9 +98,7 @@ mod platform { #[cfg(windows)] mod platform { - extern crate kernel32; - - use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate}; + use kernel32::{GetProcessHeap, HeapSize, HeapValidate}; pub use std::alloc::System as Allocator; use std::os::raw::c_void; diff --git a/components/atoms/build.rs b/components/atoms/build.rs index 245440b06e5..6cfdfe2e7d7 100644 --- a/components/atoms/build.rs +++ b/components/atoms/build.rs @@ -2,12 +2,11 @@ * 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/. */ -extern crate string_cache_codegen; - use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; +use string_cache_codegen; fn main() { let static_atoms = diff --git a/components/atoms/lib.rs b/components/atoms/lib.rs index c1da7167bde..87009b13b67 100644 --- a/components/atoms/lib.rs +++ b/components/atoms/lib.rs @@ -2,6 +2,4 @@ * 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/. */ -extern crate string_cache; - include!(concat!(env!("OUT_DIR"), "/atom.rs")); diff --git a/components/bluetooth/lib.rs b/components/bluetooth/lib.rs index 8d9f7bd0af5..e563c8fd8a4 100644 --- a/components/bluetooth/lib.rs +++ b/components/bluetooth/lib.rs @@ -4,15 +4,8 @@ #[macro_use] extern crate bitflags; -extern crate bluetooth_traits; -extern crate device; -extern crate embedder_traits; -extern crate ipc_channel; #[macro_use] extern crate log; -extern crate servo_config; -extern crate servo_rand; -extern crate uuid; pub mod test; @@ -29,7 +22,7 @@ use embedder_traits::{EmbedderMsg, EmbedderProxy}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use servo_config::opts; use servo_config::prefs::PREFS; -use servo_rand::Rng; +use servo_rand::{self, Rng}; use std::borrow::ToOwned; use std::collections::{HashMap, HashSet}; use std::string::String; diff --git a/components/bluetooth/test.rs b/components/bluetooth/test.rs index 6138bbdb35e..0056f06767c 100644 --- a/components/bluetooth/test.rs +++ b/components/bluetooth/test.rs @@ -137,7 +137,7 @@ fn generate_id() -> Uuid { } // Set the adapter's name, is_powered and is_discoverable attributes -fn set_adapter(adapter: &BluetoothAdapter, adapter_name: String) -> Result<(), Box<Error>> { +fn set_adapter(adapter: &BluetoothAdapter, adapter_name: String) -> Result<(), Box<dyn Error>> { adapter.set_name(adapter_name)?; adapter.set_powered(true)?; adapter.set_discoverable(true)?; @@ -149,7 +149,7 @@ fn create_device( adapter: &BluetoothAdapter, name: String, address: String, -) -> Result<BluetoothDevice, Box<Error>> { +) -> Result<BluetoothDevice, Box<dyn Error>> { let device = BluetoothDevice::create_mock_device(adapter.clone(), generate_id().to_string())?; device.set_name(Some(name))?; device.set_address(address)?; @@ -163,7 +163,7 @@ fn create_device_with_uuids( name: String, address: String, uuids: Vec<String>, -) -> Result<BluetoothDevice, Box<Error>> { +) -> Result<BluetoothDevice, Box<dyn Error>> { let device = create_device(adapter, name, address)?; device.set_uuids(uuids)?; Ok(device) @@ -173,7 +173,7 @@ fn create_device_with_uuids( fn create_service( device: &BluetoothDevice, uuid: String, -) -> Result<BluetoothGATTService, Box<Error>> { +) -> Result<BluetoothGATTService, Box<dyn Error>> { let service = BluetoothGATTService::create_mock_service(device.clone(), generate_id().to_string())?; service.set_uuid(uuid)?; @@ -184,7 +184,7 @@ fn create_service( fn create_characteristic( service: &BluetoothGATTService, uuid: String, -) -> Result<BluetoothGATTCharacteristic, Box<Error>> { +) -> Result<BluetoothGATTCharacteristic, Box<dyn Error>> { let characteristic = BluetoothGATTCharacteristic::create_mock_characteristic( service.clone(), generate_id().to_string(), @@ -198,7 +198,7 @@ fn create_characteristic_with_value( service: &BluetoothGATTService, uuid: String, value: Vec<u8>, -) -> Result<BluetoothGATTCharacteristic, Box<Error>> { +) -> Result<BluetoothGATTCharacteristic, Box<dyn Error>> { let characteristic = create_characteristic(service, uuid)?; characteristic.set_value(value)?; Ok(characteristic) @@ -208,7 +208,7 @@ fn create_characteristic_with_value( fn create_descriptor( characteristic: &BluetoothGATTCharacteristic, uuid: String, -) -> Result<BluetoothGATTDescriptor, Box<Error>> { +) -> Result<BluetoothGATTDescriptor, Box<dyn Error>> { let descriptor = BluetoothGATTDescriptor::create_mock_descriptor( characteristic.clone(), generate_id().to_string(), @@ -222,7 +222,7 @@ fn create_descriptor_with_value( characteristic: &BluetoothGATTCharacteristic, uuid: String, value: Vec<u8>, -) -> Result<BluetoothGATTDescriptor, Box<Error>> { +) -> Result<BluetoothGATTDescriptor, Box<dyn Error>> { let descriptor = create_descriptor(characteristic, uuid)?; descriptor.set_value(value)?; Ok(descriptor) @@ -231,7 +231,7 @@ fn create_descriptor_with_value( fn create_heart_rate_service( device: &BluetoothDevice, empty: bool, -) -> Result<BluetoothGATTService, Box<Error>> { +) -> Result<BluetoothGATTService, Box<dyn Error>> { // Heart Rate Service let heart_rate_service = create_service(device, HEART_RATE_SERVICE_UUID.to_owned())?; @@ -274,7 +274,7 @@ fn create_heart_rate_service( fn create_generic_access_service( device: &BluetoothDevice, empty: bool, -) -> Result<BluetoothGATTService, Box<Error>> { +) -> Result<BluetoothGATTService, Box<dyn Error>> { // Generic Access Service let generic_access_service = create_service(device, GENERIC_ACCESS_SERVICE_UUID.to_owned())?; @@ -335,7 +335,7 @@ fn create_generic_access_service( fn create_heart_rate_device( adapter: &BluetoothAdapter, empty: bool, -) -> Result<BluetoothDevice, Box<Error>> { +) -> Result<BluetoothDevice, Box<dyn Error>> { // Heart Rate Device let heart_rate_device = create_device_with_uuids( adapter, @@ -362,7 +362,7 @@ fn create_heart_rate_device( fn create_missing_characterisitc_heart_rate_device( adapter: &BluetoothAdapter, -) -> Result<(), Box<Error>> { +) -> Result<(), Box<dyn Error>> { let heart_rate_device_empty = create_heart_rate_device(adapter, true)?; let _generic_access_service_empty = @@ -375,7 +375,7 @@ fn create_missing_characterisitc_heart_rate_device( fn create_missing_descriptor_heart_rate_device( adapter: &BluetoothAdapter, -) -> Result<(), Box<Error>> { +) -> Result<(), Box<dyn Error>> { let heart_rate_device_empty = create_heart_rate_device(adapter, true)?; let generic_access_service_empty = @@ -399,7 +399,7 @@ fn create_missing_descriptor_heart_rate_device( Ok(()) } -fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> { +fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> { let heart_rate_device_empty = create_heart_rate_device(adapter, true)?; heart_rate_device_empty.set_uuids(vec![ @@ -435,7 +435,7 @@ fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<( Ok(()) } -fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> { +fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> { let connectable_device = create_device_with_uuids( adapter, CONNECTABLE_DEVICE_NAME.to_owned(), @@ -490,7 +490,7 @@ fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error Ok(()) } -fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> { +fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> { let glucose_devie = create_device_with_uuids( adapter, GLUCOSE_DEVICE_NAME.to_owned(), @@ -517,7 +517,7 @@ fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), B Ok(()) } -pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), Box<Error>> { +pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), Box<dyn Error>> { let may_existing_adapter = manager.get_or_create_adapter(); let adapter = match may_existing_adapter.as_ref() { Some(adapter) => adapter, diff --git a/components/bluetooth_traits/lib.rs b/components/bluetooth_traits/lib.rs index bc77d885050..4733937d105 100644 --- a/components/bluetooth_traits/lib.rs +++ b/components/bluetooth_traits/lib.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 http://mozilla.org/MPL/2.0/. */ -extern crate embedder_traits; -extern crate ipc_channel; -extern crate regex; #[macro_use] extern crate serde; diff --git a/components/canvas/gl_context.rs b/components/canvas/gl_context.rs index 077ea3b7f9f..9f8aeb2fe31 100644 --- a/components/canvas/gl_context.rs +++ b/components/canvas/gl_context.rs @@ -169,7 +169,7 @@ impl GLContextWrapper { } } - pub fn gl(&self) -> &gl::Gl { + pub fn gl(&self) -> &dyn gl::Gl { match *self { GLContextWrapper::Native(ref ctx) => ctx.gl(), GLContextWrapper::OSMesa(ref ctx) => ctx.gl(), @@ -236,7 +236,7 @@ impl MainThreadDispatcher { } } impl GLContextDispatcher for MainThreadDispatcher { - fn dispatch(&self, f: Box<Fn() + Send>) { + fn dispatch(&self, f: Box<dyn Fn() + Send>) { self.compositor_proxy .lock() .unwrap() diff --git a/components/canvas/lib.rs b/components/canvas/lib.rs index 2e42b7e1902..ab785a5620c 100644 --- a/components/canvas/lib.rs +++ b/components/canvas/lib.rs @@ -4,23 +4,8 @@ #![deny(unsafe_code)] -extern crate azure; -extern crate canvas_traits; -extern crate compositing; -extern crate cssparser; -extern crate euclid; -extern crate fnv; -extern crate gleam; -extern crate ipc_channel; #[macro_use] extern crate log; -extern crate num_traits; -extern crate offscreen_gl_context; -extern crate pixels; -extern crate serde_bytes; -extern crate servo_config; -extern crate webrender; -extern crate webrender_api; pub mod canvas_data; pub mod canvas_paint_thread; diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs index 1f7ade4eb56..bed3692268f 100644 --- a/components/canvas/webgl_mode/inprocess.rs +++ b/components/canvas/webgl_mode/inprocess.rs @@ -23,13 +23,13 @@ impl WebGLThreads { /// Creates a new WebGLThreads object pub fn new( gl_factory: GLContextFactory, - webrender_gl: Rc<gl::Gl>, + webrender_gl: Rc<dyn gl::Gl>, webrender_api_sender: webrender_api::RenderApiSender, - webvr_compositor: Option<Box<WebVRRenderHandler>>, + webvr_compositor: Option<Box<dyn WebVRRenderHandler>>, ) -> ( WebGLThreads, - Box<webrender::ExternalImageHandler>, - Option<Box<webrender::OutputImageHandler>>, + Box<dyn webrender::ExternalImageHandler>, + Option<Box<dyn webrender::OutputImageHandler>>, ) { // This implementation creates a single `WebGLThread` for all the pipelines. let channel = WebGLThread::start( @@ -70,7 +70,7 @@ impl WebGLThreads { /// Bridge between the webrender::ExternalImage callbacks and the WebGLThreads. struct WebGLExternalImages { - webrender_gl: Rc<gl::Gl>, + webrender_gl: Rc<dyn gl::Gl>, webgl_channel: WebGLSender<WebGLMsg>, // Used to avoid creating a new channel on each received WebRender request. lock_channel: ( @@ -80,7 +80,7 @@ struct WebGLExternalImages { } impl WebGLExternalImages { - fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self { + fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self { Self { webrender_gl, webgl_channel: channel, @@ -111,7 +111,7 @@ impl WebGLExternalImageApi for WebGLExternalImages { } /// Wrapper to send WebVR commands used in `WebGLThread`. -struct WebVRRenderWrapper(Box<WebVRRenderHandler>); +struct WebVRRenderWrapper(Box<dyn WebVRRenderHandler>); impl WebVRRenderHandler for WebVRRenderWrapper { fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>) { @@ -122,7 +122,7 @@ impl WebVRRenderHandler for WebVRRenderWrapper { /// struct used to implement DOMToTexture feature and webrender::OutputImageHandler trait. type OutputHandlerData = Option<(u32, Size2D<i32>)>; struct OutputHandler { - webrender_gl: Rc<gl::Gl>, + webrender_gl: Rc<dyn gl::Gl>, webgl_channel: WebGLSender<WebGLMsg>, // Used to avoid creating a new channel on each received WebRender request. lock_channel: ( @@ -133,7 +133,7 @@ struct OutputHandler { } impl OutputHandler { - fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self { + fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self { Self { webrender_gl, webgl_channel: channel, diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index e47bfffdbcc..c40f4e1b169 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -1364,7 +1364,7 @@ impl WebGLImpl { } fn initialize_framebuffer( - gl: &gl::Gl, + gl: &dyn gl::Gl, state: &GLState, color: bool, depth: bool, @@ -1424,7 +1424,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn link_program(gl: &gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo { + fn link_program(gl: &dyn gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo { gl.link_program(program.get()); let mut linked = [0]; unsafe { @@ -1497,13 +1497,13 @@ impl WebGLImpl { } } - fn finish(gl: &gl::Gl, chan: &WebGLSender<()>) { + fn finish(gl: &dyn gl::Gl, chan: &WebGLSender<()>) { gl.finish(); chan.send(()).unwrap(); } fn shader_precision_format( - gl: &gl::Gl, + gl: &dyn gl::Gl, shader_type: u32, precision_type: u32, chan: &WebGLSender<(i32, i32, i32)>, @@ -1512,13 +1512,13 @@ impl WebGLImpl { chan.send(result).unwrap(); } - fn get_extensions(gl: &gl::Gl, chan: &WebGLSender<String>) { + fn get_extensions(gl: &dyn gl::Gl, chan: &WebGLSender<String>) { chan.send(gl.get_string(gl::EXTENSIONS)).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 fn get_framebuffer_attachment_parameter( - gl: &gl::Gl, + gl: &dyn gl::Gl, target: u32, attachment: u32, pname: u32, @@ -1529,13 +1529,18 @@ impl WebGLImpl { } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7 - fn get_renderbuffer_parameter(gl: &gl::Gl, target: u32, pname: u32, chan: &WebGLSender<i32>) { + fn get_renderbuffer_parameter( + gl: &dyn gl::Gl, + target: u32, + pname: u32, + chan: &WebGLSender<i32>, + ) { let parameter = gl.get_renderbuffer_parameter_iv(target, pname); chan.send(parameter).unwrap(); } fn uniform_location( - gl: &gl::Gl, + gl: &dyn gl::Gl, program_id: WebGLProgramId, name: &str, chan: &WebGLSender<i32>, @@ -1545,18 +1550,18 @@ impl WebGLImpl { chan.send(location).unwrap(); } - fn shader_info_log(gl: &gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) { + fn shader_info_log(gl: &dyn gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) { let log = gl.get_shader_info_log(shader_id.get()); chan.send(log).unwrap(); } - fn program_info_log(gl: &gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) { + fn program_info_log(gl: &dyn gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) { let log = gl.get_program_info_log(program_id.get()); chan.send(log).unwrap(); } #[allow(unsafe_code)] - fn create_buffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) { + fn create_buffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) { let buffer = gl.gen_buffers(1)[0]; let buffer = if buffer == 0 { None @@ -1567,7 +1572,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_framebuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) { + fn create_framebuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) { let framebuffer = gl.gen_framebuffers(1)[0]; let framebuffer = if framebuffer == 0 { None @@ -1578,7 +1583,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_renderbuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) { + fn create_renderbuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) { let renderbuffer = gl.gen_renderbuffers(1)[0]; let renderbuffer = if renderbuffer == 0 { None @@ -1589,7 +1594,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_texture(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) { + fn create_texture(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) { let texture = gl.gen_textures(1)[0]; let texture = if texture == 0 { None @@ -1600,7 +1605,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_program(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) { + fn create_program(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) { let program = gl.create_program(); let program = if program == 0 { None @@ -1611,7 +1616,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_shader(gl: &gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) { + fn create_shader(gl: &dyn gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) { let shader = gl.create_shader(shader_type); let shader = if shader == 0 { None @@ -1622,7 +1627,7 @@ impl WebGLImpl { } #[allow(unsafe_code)] - fn create_vertex_array(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) { + fn create_vertex_array(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) { let vao = gl.gen_vertex_arrays(1)[0]; let vao = if vao == 0 { None @@ -1634,7 +1639,7 @@ impl WebGLImpl { #[inline] fn bind_framebuffer<Native: NativeGLContextMethods>( - gl: &gl::Gl, + gl: &dyn gl::Gl, target: u32, request: WebGLFramebufferBindingRequest, ctx: &GLContext<Native>, @@ -1650,7 +1655,7 @@ impl WebGLImpl { } #[inline] - fn compile_shader(gl: &gl::Gl, shader_id: WebGLShaderId, source: &str) { + fn compile_shader(gl: &dyn gl::Gl, shader_id: WebGLShaderId, source: &str) { gl.shader_source(shader_id.get(), &[source.as_bytes()]); gl.compile_shader(shader_id.get()); } diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 2c386b944ef..2e11d1704c6 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -6,21 +6,12 @@ #![crate_type = "rlib"] #![deny(unsafe_code)] -extern crate cssparser; -extern crate euclid; -extern crate gleam; -extern crate ipc_channel; #[macro_use] extern crate lazy_static; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate offscreen_gl_context; #[macro_use] extern crate serde; -extern crate serde_bytes; -extern crate servo_config; -extern crate webrender_api; pub mod canvas; pub mod webgl; diff --git a/components/channel/lib.rs b/components/channel/lib.rs index fd8dc7e5824..3e286ef7f98 100644 --- a/components/channel/lib.rs +++ b/components/channel/lib.rs @@ -2,16 +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/. */ -extern crate crossbeam_channel; -extern crate ipc_channel; -extern crate serde; - pub mod base_channel { pub use crossbeam_channel::*; } // Needed to re-export the select macro. pub use crossbeam_channel::*; +use crossbeam_channel; use ipc_channel::ipc::IpcReceiver; use ipc_channel::router::ROUTER; use serde::{Deserialize, Serialize}; diff --git a/components/compositing/build.rs b/components/compositing/build.rs index 54532276222..c9b97801f51 100644 --- a/components/compositing/build.rs +++ b/components/compositing/build.rs @@ -2,12 +2,11 @@ * 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/. */ -extern crate toml; - use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; +use toml; fn main() { let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index c3974c7fd01..f357f6522ee 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -263,7 +263,7 @@ impl RenderNotifier { } impl webrender_api::RenderNotifier for RenderNotifier { - fn clone(&self) -> Box<webrender_api::RenderNotifier> { + fn clone(&self) -> Box<dyn webrender_api::RenderNotifier> { Box::new(RenderNotifier::new(self.compositor_proxy.clone())) } diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs index a897f141fed..a4859d58f79 100644 --- a/components/compositing/compositor_thread.rs +++ b/components/compositing/compositor_thread.rs @@ -23,7 +23,7 @@ use webrender_api::{self, DeviceIntPoint, DeviceUintSize}; /// Sends messages to the compositor. pub struct CompositorProxy { pub sender: Sender<Msg>, - pub event_loop_waker: Box<EventLoopWaker>, + pub event_loop_waker: Box<dyn EventLoopWaker>, } impl CompositorProxy { @@ -98,7 +98,7 @@ pub enum Msg { /// Runs a closure in the compositor thread. /// It's used to dispatch functions from webrender to the main thread's event loop. /// Required to allow WGL GLContext sharing in Windows. - Dispatch(Box<Fn() + Send>), + Dispatch(Box<dyn Fn() + Send>), /// Indicates to the compositor that it needs to record the time when the frame with /// the given ID (epoch) is painted and report it to the layout thread of the given /// pipeline ID. diff --git a/components/compositing/gl.rs b/components/compositing/gl.rs index 6637ef203ea..59c1225cd91 100644 --- a/components/compositing/gl.rs +++ b/components/compositing/gl.rs @@ -14,7 +14,7 @@ pub struct RenderTargetInfo { } pub fn initialize_png( - gl: &gl::Gl, + gl: &dyn gl::Gl, width: DeviceUintLength, height: DeviceUintLength, ) -> RenderTargetInfo { @@ -80,7 +80,7 @@ pub fn initialize_png( } pub fn draw_img( - gl: &gl::Gl, + gl: &dyn gl::Gl, render_target_info: RenderTargetInfo, width: DeviceUintLength, height: DeviceUintLength, diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index c631f39275e..d54feac56bb 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -4,30 +4,8 @@ #![deny(unsafe_code)] -extern crate embedder_traits; -extern crate euclid; -extern crate gfx_traits; -#[cfg(feature = "gleam")] -extern crate gleam; -#[cfg(feature = "gleam")] -extern crate image; -extern crate ipc_channel; -extern crate keyboard_types; -extern crate libc; #[macro_use] extern crate log; -extern crate msg; -extern crate net_traits; -extern crate profile_traits; -extern crate script_traits; -extern crate servo_channel; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_url; -extern crate style_traits; -extern crate time; -extern crate webrender; -extern crate webrender_api; pub use crate::compositor::IOCompositor; pub use crate::compositor::RenderNotifier; diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 9ff7e919746..087062c3fc2 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -132,9 +132,9 @@ pub trait WindowMethods { fn prepare_for_composite(&self) -> bool; /// Return the GL function pointer trait. #[cfg(feature = "gleam")] - fn gl(&self) -> Rc<gl::Gl>; + fn gl(&self) -> Rc<dyn gl::Gl>; /// Returns a thread-safe object to wake up the window's event loop. - fn create_event_loop_waker(&self) -> Box<EventLoopWaker>; + fn create_event_loop_waker(&self) -> Box<dyn EventLoopWaker>; /// Get the coordinates of the native window, the screen and the framebuffer. fn get_coordinates(&self) -> EmbedderCoordinates; /// Set whether the application is currently animating. diff --git a/components/config/lib.rs b/components/config/lib.rs index 7f24eeb7c5c..d7baff3a71d 100644 --- a/components/config/lib.rs +++ b/components/config/lib.rs @@ -4,22 +4,12 @@ #![deny(unsafe_code)] -#[cfg(not(target_os = "android"))] -extern crate dirs; -extern crate embedder_traits; -extern crate euclid; -extern crate getopts; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; -extern crate num_cpus; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_geometry; -extern crate servo_url; -extern crate url; pub mod basedir; #[allow(unsafe_code)] diff --git a/components/config/tests/opts.rs b/components/config/tests/opts.rs index 3e427074823..030f398a7cb 100644 --- a/components/config/tests/opts.rs +++ b/components/config/tests/opts.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 http://mozilla.org/MPL/2.0/. */ -extern crate servo_config; - use servo_config::opts::{parse_pref_from_command_line, parse_url_or_filename}; use servo_config::prefs::{PrefValue, PREFS}; use std::path::Path; diff --git a/components/config/tests/prefs.rs b/components/config/tests/prefs.rs index ee3916b7f5a..e4ff276ebb5 100644 --- a/components/config/tests/prefs.rs +++ b/components/config/tests/prefs.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 http://mozilla.org/MPL/2.0/. */ -extern crate servo_config; - use servo_config::basedir; use servo_config::prefs::{read_prefs, PrefValue, PREFS}; use std::fs::{self, File}; diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs index 54235a9b09c..1b4befa3af6 100644 --- a/components/constellation/lib.rs +++ b/components/constellation/lib.rs @@ -5,43 +5,10 @@ #![deny(unsafe_code)] #![cfg_attr(feature = "unstable", feature(conservative_impl_trait))] -extern crate backtrace; -extern crate bluetooth_traits; -extern crate canvas; -extern crate canvas_traits; -extern crate clipboard; -extern crate compositing; -extern crate debugger; -extern crate devtools_traits; -#[cfg(not(target_os = "ios"))] -extern crate embedder_traits; -extern crate euclid; -#[cfg(all(not(target_os = "windows"), not(target_os = "ios")))] -extern crate gaol; -extern crate gfx; -extern crate gfx_traits; -extern crate http; -extern crate ipc_channel; -extern crate keyboard_types; -extern crate layout_traits; #[macro_use] extern crate log; -extern crate metrics; -extern crate msg; -extern crate net; -extern crate net_traits; -extern crate profile_traits; -extern crate script_traits; -extern crate serde; #[macro_use] extern crate servo_channel; -extern crate servo_config; -extern crate servo_rand; -extern crate servo_remutex; -extern crate servo_url; -extern crate style_traits; -extern crate webrender_api; -extern crate webvr_traits; mod browsingcontext; mod constellation; diff --git a/components/debugger/lib.rs b/components/debugger/lib.rs index c6ba6147826..a609bd6129f 100644 --- a/components/debugger/lib.rs +++ b/components/debugger/lib.rs @@ -4,11 +4,10 @@ #[macro_use] extern crate log; -extern crate servo_channel; -extern crate ws; +use servo_channel; use std::thread; -use ws::{Builder, CloseCode, Handler, Handshake}; +use ws::{self, Builder, CloseCode, Handler, Handshake}; enum Message { ShutdownServer, diff --git a/components/deny_public_fields/lib.rs b/components/deny_public_fields/lib.rs index 28fbf85add0..e64ac990081 100644 --- a/components/deny_public_fields/lib.rs +++ b/components/deny_public_fields/lib.rs @@ -3,11 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate proc_macro; -extern crate syn; -#[macro_use] -extern crate synstructure; use std::str::FromStr; +use syn; +use synstructure::{self, decl_derive}; decl_derive!([DenyPublicFields] => deny_public_fields_derive); diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 634622a2068..73180a784ed 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -33,23 +33,23 @@ pub trait Actor: Any + ActorAsAny { } pub trait ActorAsAny { - fn actor_as_any(&self) -> &Any; - fn actor_as_any_mut(&mut self) -> &mut Any; + fn actor_as_any(&self) -> &dyn Any; + fn actor_as_any_mut(&mut self) -> &mut dyn Any; } impl<T: Actor> ActorAsAny for T { - fn actor_as_any(&self) -> &Any { + fn actor_as_any(&self) -> &dyn Any { self } - fn actor_as_any_mut(&mut self) -> &mut Any { + fn actor_as_any_mut(&mut self) -> &mut dyn Any { self } } /// A list of known, owned actors. pub struct ActorRegistry { - actors: HashMap<String, Box<Actor + Send>>, - new_actors: RefCell<Vec<Box<Actor + Send>>>, + actors: HashMap<String, Box<dyn Actor + Send>>, + new_actors: RefCell<Vec<Box<dyn Actor + Send>>>, old_actors: RefCell<Vec<String>>, script_actors: RefCell<HashMap<String, String>>, shareable: Option<Arc<Mutex<ActorRegistry>>>, @@ -131,11 +131,11 @@ impl ActorRegistry { } /// Add an actor to the registry of known actors that can receive messages. - pub fn register(&mut self, actor: Box<Actor + Send>) { + pub fn register(&mut self, actor: Box<dyn Actor + Send>) { self.actors.insert(actor.name(), actor); } - pub fn register_later(&self, actor: Box<Actor + Send>) { + pub fn register_later(&self, actor: Box<dyn Actor + Send>) { let mut actors = self.new_actors.borrow_mut(); actors.push(actor); } diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index be40e70eec6..0768a79ed09 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -12,20 +12,10 @@ #![allow(non_snake_case)] #![deny(unsafe_code)] -extern crate devtools_traits; -extern crate headers_core; -extern crate headers_ext; -extern crate http; -extern crate hyper; -extern crate ipc_channel; #[macro_use] extern crate log; -extern crate msg; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_channel; -extern crate time; use crate::actor::{Actor, ActorRegistry}; use crate::actors::browsing_context::BrowsingContextActor; diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index dc0979f580c..e0280345169 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -13,16 +13,10 @@ #[macro_use] extern crate bitflags; -extern crate http; -extern crate ipc_channel; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate msg; #[macro_use] extern crate serde; -extern crate servo_url; -extern crate time; use http::method::Method; use http::HeaderMap; @@ -30,8 +24,7 @@ use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use servo_url::ServoUrl; use std::net::TcpStream; -use time::Duration; -use time::Tm; +use time::{self, Duration, Tm}; // Information would be attached to NewGlobal to be received and show in devtools. // Extend these fields if we need more information. diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index bd3a9765e29..95d7b0446d5 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate proc_macro; - #[macro_use] extern crate quote; extern crate syn; diff --git a/components/embedder_traits/lib.rs b/components/embedder_traits/lib.rs index 48c231ca3cd..96364c5e639 100644 --- a/components/embedder_traits/lib.rs +++ b/components/embedder_traits/lib.rs @@ -2,19 +2,12 @@ * 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/. */ -extern crate ipc_channel; -extern crate keyboard_types; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; -extern crate msg; #[macro_use] extern crate serde; -extern crate servo_channel; -extern crate servo_url; -extern crate style_traits; -extern crate webrender_api; pub mod resources; diff --git a/components/geometry/lib.rs b/components/geometry/lib.rs index 2f421f6a277..654bf8b3c80 100644 --- a/components/geometry/lib.rs +++ b/components/geometry/lib.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 http://mozilla.org/MPL/2.0/. */ -extern crate app_units; -extern crate euclid; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate style_traits; -extern crate webrender_api; use app_units::{Au, MAX_AU, MIN_AU}; use euclid::{Length, Point2D, Rect, Size2D}; diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 442a9c8ae3a..24dbcde26cb 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -4,75 +4,16 @@ #![deny(unsafe_code)] -extern crate app_units; #[macro_use] extern crate bitflags; - -// Mac OS-specific library dependencies -#[cfg(target_os = "macos")] -extern crate byteorder; -#[cfg(target_os = "macos")] -extern crate core_foundation; -#[cfg(target_os = "macos")] -extern crate core_graphics; -#[cfg(target_os = "macos")] -extern crate core_text; - -// Windows-specific library dependencies -#[cfg(target_os = "windows")] -extern crate dwrote; - -extern crate euclid; -extern crate fnv; - -#[cfg(target_os = "linux")] -extern crate fontconfig; -extern crate fontsan; -#[cfg(any(target_os = "linux", target_os = "android"))] -extern crate freetype; -extern crate gfx_traits; - -// Eventually we would like the shaper to be pluggable, as many operating systems have their own -// shapers. For now, however, this is a hard dependency. -extern crate harfbuzz_sys as harfbuzz; - -extern crate ipc_channel; #[macro_use] extern crate lazy_static; -#[cfg(any(target_os = "linux", target_os = "android"))] -extern crate libc; #[macro_use] extern crate log; -#[cfg_attr(target_os = "windows", macro_use)] -extern crate malloc_size_of; -extern crate net_traits; -extern crate ordered_float; -#[cfg(all( - feature = "unstable", - any(target_feature = "sse2", target_feature = "neon") -))] -extern crate packed_simd; -extern crate range; #[macro_use] extern crate serde; -#[cfg(any(target_os = "linux", target_os = "android"))] -extern crate servo_allocator; -extern crate servo_arc; #[macro_use] extern crate servo_atoms; -extern crate servo_url; -extern crate smallvec; -extern crate style; -extern crate time; -#[cfg(target_os = "windows")] -extern crate truetype; -extern crate ucd; -extern crate unicode_bidi; -extern crate unicode_script; -extern crate webrender_api; -extern crate xi_unicode; -#[cfg(target_os = "android")] -extern crate xml5ever; // Fonts #[macro_use] diff --git a/components/gfx/platform/windows/font_context.rs b/components/gfx/platform/windows/font_context.rs index 7d304ed138d..400988d032f 100644 --- a/components/gfx/platform/windows/font_context.rs +++ b/components/gfx/platform/windows/font_context.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 http://mozilla.org/MPL/2.0/. */ +use malloc_size_of::malloc_size_of_is_0; + #[derive(Clone, Debug)] pub struct FontContextHandle; diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index d4dea69597d..6be4cbe263b 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.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 http://mozilla.org/MPL/2.0/. */ -extern crate app_units; -extern crate gfx; -extern crate servo_arc; -extern crate servo_atoms; -extern crate style; -extern crate webrender_api; - use app_units::Au; use gfx::font::{ fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope, @@ -31,6 +24,7 @@ use style::values::computed::font::{ }; use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily}; use style::values::generics::font::FontStyle; +use webrender_api; struct TestFontSource { handle: FontContextHandle, diff --git a/components/gfx/tests/font_template.rs b/components/gfx/tests/font_template.rs index 8d1935f738d..132e067cf1a 100644 --- a/components/gfx/tests/font_template.rs +++ b/components/gfx/tests/font_template.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 http://mozilla.org/MPL/2.0/. */ -#[cfg(not(target_os = "macos"))] -extern crate gfx; -#[cfg(not(target_os = "macos"))] -extern crate servo_atoms; -#[cfg(not(target_os = "macos"))] -extern crate style; - // Test doesn't yet run on Mac, see https://github.com/servo/servo/pull/19928 for explanation. #[cfg(not(target_os = "macos"))] #[test] diff --git a/components/gfx/tests/text_util.rs b/components/gfx/tests/text_util.rs index c35a06a2e2f..297823041d8 100644 --- a/components/gfx/tests/text_util.rs +++ b/components/gfx/tests/text_util.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 http://mozilla.org/MPL/2.0/. */ -extern crate gfx; - use gfx::text::util::{transform_text, CompressionMode}; #[test] diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 675c57b4615..ecd575d9b91 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -6,37 +6,39 @@ use app_units::Au; use crate::font::{Font, FontTableMethods, FontTableTag, ShapingFlags, ShapingOptions, KERN}; -use crate::harfbuzz::hb_blob_t; -use crate::harfbuzz::hb_bool_t; -use crate::harfbuzz::hb_buffer_add_utf8; -use crate::harfbuzz::hb_buffer_destroy; -use crate::harfbuzz::hb_buffer_get_glyph_positions; -use crate::harfbuzz::hb_buffer_get_length; -use crate::harfbuzz::hb_face_destroy; -use crate::harfbuzz::hb_feature_t; -use crate::harfbuzz::hb_font_create; -use crate::harfbuzz::hb_font_funcs_create; -use crate::harfbuzz::hb_font_funcs_set_glyph_h_advance_func; -use crate::harfbuzz::hb_font_funcs_set_glyph_h_kerning_func; -use crate::harfbuzz::hb_font_funcs_set_nominal_glyph_func; -use crate::harfbuzz::hb_font_set_funcs; -use crate::harfbuzz::hb_font_set_ppem; -use crate::harfbuzz::hb_font_set_scale; -use crate::harfbuzz::hb_glyph_info_t; -use crate::harfbuzz::hb_glyph_position_t; -use crate::harfbuzz::{hb_blob_create, hb_face_create_for_tables}; -use crate::harfbuzz::{hb_buffer_create, hb_font_destroy}; -use crate::harfbuzz::{hb_buffer_get_glyph_infos, hb_shape}; -use crate::harfbuzz::{hb_buffer_set_direction, hb_buffer_set_script}; -use crate::harfbuzz::{hb_buffer_t, hb_codepoint_t, hb_font_funcs_t}; -use crate::harfbuzz::{hb_face_t, hb_font_t}; -use crate::harfbuzz::{hb_position_t, hb_tag_t}; -use crate::harfbuzz::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY}; 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 euclid::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_glyph_h_kerning_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 std::os::raw::{c_char, c_int, c_uint, c_void}; use std::{char, cmp, ptr}; diff --git a/components/gfx/text/shaping/mod.rs b/components/gfx/text/shaping/mod.rs index 8c59c13427a..9f78c0d75ac 100644 --- a/components/gfx/text/shaping/mod.rs +++ b/components/gfx/text/shaping/mod.rs @@ -10,7 +10,7 @@ use crate::font::ShapingOptions; use crate::text::glyph::GlyphStore; -pub use crate::text::shaping::harfbuzz::Shaper; +pub use self::harfbuzz::Shaper; pub mod harfbuzz; diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 308c01cd279..f540ed61be6 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -6,7 +6,6 @@ #![crate_type = "rlib"] #![deny(unsafe_code)] -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; #[macro_use] diff --git a/components/jstraceable_derive/lib.rs b/components/jstraceable_derive/lib.rs index 571a50b7a1e..f00992b80dc 100644 --- a/components/jstraceable_derive/lib.rs +++ b/components/jstraceable_derive/lib.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 http://mozilla.org/MPL/2.0/. */ -extern crate quote; #[macro_use] extern crate syn; #[macro_use] extern crate synstructure; +use quote; + decl_derive!([JSTraceable] => js_traceable_derive); fn js_traceable_derive(s: synstructure::Structure) -> quote::Tokens { diff --git a/components/layout/animation.rs b/components/layout/animation.rs index 2a2b49d9715..0903c1b7fa5 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -163,7 +163,7 @@ pub fn update_animation_state<E>( /// lock held. pub fn recalc_style_for_animations<E>( context: &LayoutContext, - flow: &mut Flow, + flow: &mut dyn Flow, animations: &FxHashMap<OpaqueNode, Vec<Animation>>, ) where E: TElement, diff --git a/components/layout/block.rs b/components/layout/block.rs index 9fbd7434ea9..429662d29b5 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -546,7 +546,7 @@ pub struct AbsoluteAssignBSizesTraversal<'a>(pub &'a SharedStyleContext<'a>); impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> { #[inline] - fn process(&self, flow: &mut Flow) { + fn process(&self, flow: &mut dyn Flow) { if !flow.is_block_like() { return; } @@ -938,7 +938,7 @@ impl BlockFlow { layout_context: &LayoutContext, mut fragmentation_context: Option<FragmentationContext>, margins_may_collapse: MarginsMayCollapseFlag, - ) -> Option<Arc<Flow>> { + ) -> Option<Arc<dyn Flow>> { let _scope = layout_debug_scope!("assign_block_size_block_base {:x}", self.base.debug_id()); let mut break_at = None; @@ -1272,7 +1272,7 @@ impl BlockFlow { } } - if (&*self as &Flow).contains_roots_of_absolute_flow_tree() { + if (&*self as &dyn Flow).contains_roots_of_absolute_flow_tree() { // Assign block-sizes for all flows in this absolute flow tree. // This is preorder because the block-size of an absolute flow may depend on // the block-size of its containing block, which may also be an absolute flow. @@ -1307,7 +1307,7 @@ impl BlockFlow { if let Some(child) = child_remaining { children.push_front_arc(child); } - Some(Arc::new(self.clone_with_children(children)) as Arc<Flow>) + Some(Arc::new(self.clone_with_children(children)) as Arc<dyn Flow>) } }) } @@ -1592,7 +1592,7 @@ impl BlockFlow { content_inline_size: Au, mut callback: F, ) where - F: FnMut(&mut Flow, usize, Au, WritingMode, &mut Au, &mut Au), + F: FnMut(&mut dyn Flow, usize, Au, WritingMode, &mut Au, &mut Au), { let flags = self.base.flags.clone(); @@ -2246,7 +2246,7 @@ impl Flow for BlockFlow { self.assign_inline_position_for_formatting_context(layout_context, content_box); } - if (self as &Flow).floats_might_flow_through() { + if (self as &dyn Flow).floats_might_flow_through() { self.base.thread_id = parent_thread_id; if self .base @@ -2283,7 +2283,7 @@ impl Flow for BlockFlow { &mut self, layout_context: &LayoutContext, fragmentation_context: Option<FragmentationContext>, - ) -> Option<Arc<Flow>> { + ) -> Option<Arc<dyn Flow>> { if self.fragment.is_replaced() { let _scope = layout_debug_scope!( "assign_replaced_block_size_if_necessary {:x}", @@ -2613,7 +2613,7 @@ impl Flow for BlockFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -2641,7 +2641,7 @@ impl Flow for BlockFlow { ); } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { (*mutator)(&mut self.fragment) } diff --git a/components/layout/context.rs b/components/layout/context.rs index 1ab4637cd8a..08530e74a5c 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -64,7 +64,7 @@ pub struct LayoutContext<'a> { pub style_context: SharedStyleContext<'a>, /// Reference to the script thread image cache. - pub image_cache: Arc<ImageCache>, + pub image_cache: Arc<dyn ImageCache>, /// Interface to the font cache thread. pub font_cache_thread: Mutex<FontCacheThread>, @@ -77,7 +77,7 @@ pub struct LayoutContext<'a> { >, /// Paint worklets - pub registered_painters: &'a RegisteredPainters, + pub registered_painters: &'a dyn RegisteredPainters, /// A list of in-progress image loads to be shared with the script thread. /// A None value means that this layout was not initiated by the script thread. @@ -197,5 +197,5 @@ pub trait RegisteredPainter: RegisteredSpeculativePainter + Painter {} /// A set of registered painters pub trait RegisteredPainters: Sync { /// Look up a painter - fn get(&self, name: &Atom) -> Option<&RegisteredPainter>; + fn get(&self, name: &Atom) -> Option<&dyn RegisteredPainter>; } diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 42cf2c454fe..fe9d72fa55e 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -116,7 +116,7 @@ struct FlexItem { } impl FlexItem { - pub fn new(index: usize, flow: &Flow) -> FlexItem { + pub fn new(index: usize, flow: &dyn Flow) -> FlexItem { let style = &flow.as_block().fragment.style; let flex_grow = style.get_position().flex_grow; let flex_shrink = style.get_position().flex_shrink; @@ -140,7 +140,7 @@ impl FlexItem { /// Initialize the used flex base size, minimal main size and maximal main size. /// For block mode container this method should be called in assign_block_size() /// pass so that the item has already been layouted. - pub fn init_sizes(&mut self, flow: &mut Flow, containing_length: Au, direction: Direction) { + pub fn init_sizes(&mut self, flow: &mut dyn Flow, containing_length: Au, direction: Direction) { let block = flow.as_mut_block(); match direction { // TODO(stshine): the definition of min-{width, height} in style component @@ -207,7 +207,7 @@ impl FlexItem { /// Returns the outer main size of the item, including paddings and margins, /// clamped by max and min size. - pub fn outer_main_size(&self, flow: &Flow, direction: Direction) -> Au { + pub fn outer_main_size(&self, flow: &dyn Flow, direction: Direction) -> Au { let ref fragment = flow.as_block().fragment; let outer_width = match direction { Direction::Inline => { @@ -223,7 +223,7 @@ impl FlexItem { } /// Returns the number of auto margins in given direction. - pub fn auto_margin_count(&self, flow: &Flow, direction: Direction) -> i32 { + pub fn auto_margin_count(&self, flow: &dyn Flow, direction: Direction) -> i32 { let margin = flow.as_block().fragment.style.logical_margin(); let mut margin_count = 0; match direction { @@ -577,7 +577,7 @@ impl FlexFlow { debug!("content_inline_size = {:?}", content_inline_size); - let child_count = ImmutableFlowUtils::child_count(self as &Flow) as i32; + let child_count = ImmutableFlowUtils::child_count(self as &dyn Flow) as i32; debug!("child_count = {:?}", child_count); if child_count == 0 { return; @@ -1055,7 +1055,7 @@ impl Flow for FlexFlow { CollapsibleMargins::Collapse(block_start, block_end); // TODO(stshine): assign proper static position for absolute descendants. - if (&*self as &Flow).contains_roots_of_absolute_flow_tree() { + if (&*self as &dyn Flow).contains_roots_of_absolute_flow_tree() { // Assign block-sizes for all flows in this absolute flow tree. // This is preorder because the block-size of an absolute flow may depend on // the block-size of its containing block, which may also be an absolute flow. @@ -1124,7 +1124,7 @@ impl Flow for FlexFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -1135,7 +1135,7 @@ impl Flow for FlexFlow { ); } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator); } } diff --git a/components/layout/floats.rs b/components/layout/floats.rs index 88e5eb1d5ea..b054cccceaf 100644 --- a/components/layout/floats.rs +++ b/components/layout/floats.rs @@ -494,7 +494,7 @@ impl SpeculatedFloatPlacement { /// Given the speculated inline size of the floats out for the inorder predecessor of this /// flow, computes the speculated inline size of the floats flowing in. - pub fn compute_floats_in(&mut self, flow: &mut Flow) { + pub fn compute_floats_in(&mut self, flow: &mut dyn Flow) { let base_flow = flow.base(); if base_flow.flags.contains(FlowFlags::CLEARS_LEFT) { self.left = Au(0) @@ -506,7 +506,7 @@ impl SpeculatedFloatPlacement { /// Given the speculated inline size of the floats out for this flow's last child, computes the /// speculated inline size of the floats out for this flow. - pub fn compute_floats_out(&mut self, flow: &mut Flow) { + pub fn compute_floats_out(&mut self, flow: &mut dyn Flow) { if flow.is_block_like() { let block_flow = flow.as_block(); if block_flow.formatting_context_type() != FormattingContextType::None { @@ -564,7 +564,9 @@ impl SpeculatedFloatPlacement { } /// Given a flow, computes the speculated inline size of the floats in of its first child. - pub fn compute_floats_in_for_first_child(parent_flow: &mut Flow) -> SpeculatedFloatPlacement { + pub fn compute_floats_in_for_first_child( + parent_flow: &mut dyn Flow, + ) -> SpeculatedFloatPlacement { if !parent_flow.is_block_like() { return parent_flow.base().speculated_float_placement_in; } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index fea1c94f89d..4bf7622636c 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -255,7 +255,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static { &mut self, layout_context: &LayoutContext, _fragmentation_context: Option<FragmentationContext>, - ) -> Option<Arc<Flow>> { + ) -> Option<Arc<dyn Flow>> { fn recursive_assign_block_size<F: ?Sized + Flow + GetBaseFlow>( flow: &mut F, ctx: &LayoutContext, @@ -423,13 +423,13 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static { /// depth of the flow tree during fragment iteration. fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ); /// Mutably iterates through fragments in this flow. - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)); + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)); fn compute_collapsible_block_start_margin( &mut self, @@ -813,8 +813,8 @@ pub struct AbsoluteDescendantIter<'a> { } impl<'a> Iterator for AbsoluteDescendantIter<'a> { - type Item = &'a mut Flow; - fn next(&mut self) -> Option<&'a mut Flow> { + type Item = &'a mut dyn Flow; + fn next(&mut self) -> Option<&'a mut dyn Flow> { self.iter .next() .map(|info| FlowRef::deref_mut(&mut info.flow)) @@ -1245,7 +1245,7 @@ impl BaseFlow { } } -impl<'a> ImmutableFlowUtils for &'a Flow { +impl<'a> ImmutableFlowUtils for &'a dyn Flow { /// Returns true if this flow is a block flow or subclass thereof. fn is_block_like(self) -> bool { self.class().is_block_like() @@ -1419,7 +1419,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow { } } -impl<'a> MutableFlowUtils for &'a mut Flow { +impl<'a> MutableFlowUtils for &'a mut dyn Flow { /// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of /// calling them individually, since there is no reason not to perform both operations. fn repair_style_and_bubble_inline_sizes(self, style: &crate::ServoArc<ComputedValues>) { @@ -1550,8 +1550,8 @@ impl ContainingBlockLink { pub struct OpaqueFlow(pub usize); impl OpaqueFlow { - pub fn from_flow(flow: &Flow) -> OpaqueFlow { - let object_ptr: *const Flow = flow; + pub fn from_flow(flow: &dyn Flow) -> OpaqueFlow { + let object_ptr: *const dyn Flow = flow; let data_ptr = object_ptr as *const (); OpaqueFlow(data_ptr as usize) } diff --git a/components/layout/flow_list.rs b/components/layout/flow_list.rs index c24734a5a7d..07b42f19a9d 100644 --- a/components/layout/flow_list.rs +++ b/components/layout/flow_list.rs @@ -69,11 +69,11 @@ impl FlowList { self.flows.push_back(new_tail); } - pub fn push_back_arc(&mut self, new_head: Arc<Flow>) { + pub fn push_back_arc(&mut self, new_head: Arc<dyn Flow>) { self.flows.push_back(FlowRef::new(new_head)); } - pub fn back(&self) -> Option<&Flow> { + pub fn back(&self) -> Option<&dyn Flow> { self.flows.back().map(|x| &**x) } @@ -84,15 +84,15 @@ impl FlowList { self.flows.push_front(new_head); } - pub fn push_front_arc(&mut self, new_head: Arc<Flow>) { + pub fn push_front_arc(&mut self, new_head: Arc<dyn Flow>) { self.flows.push_front(FlowRef::new(new_head)); } - pub fn pop_front_arc(&mut self) -> Option<Arc<Flow>> { + pub fn pop_front_arc(&mut self) -> Option<Arc<dyn Flow>> { self.flows.pop_front().map(FlowRef::into_arc) } - pub fn front(&self) -> Option<&Flow> { + pub fn front(&self) -> Option<&dyn Flow> { self.flows.front().map(|x| &**x) } @@ -161,21 +161,21 @@ impl FlowList { } impl<'a> DoubleEndedIterator for FlowListIterator<'a> { - fn next_back(&mut self) -> Option<&'a Flow> { + fn next_back(&mut self) -> Option<&'a dyn Flow> { self.it.next_back().map(Deref::deref) } } impl<'a> DoubleEndedIterator for MutFlowListIterator<'a> { - fn next_back(&mut self) -> Option<&'a mut Flow> { + fn next_back(&mut self) -> Option<&'a mut dyn Flow> { self.it.next_back().map(FlowRef::deref_mut) } } impl<'a> Iterator for FlowListIterator<'a> { - type Item = &'a Flow; + type Item = &'a dyn Flow; #[inline] - fn next(&mut self) -> Option<&'a Flow> { + fn next(&mut self) -> Option<&'a dyn Flow> { self.it.next().map(Deref::deref) } @@ -186,9 +186,9 @@ impl<'a> Iterator for FlowListIterator<'a> { } impl<'a> Iterator for MutFlowListIterator<'a> { - type Item = &'a mut Flow; + type Item = &'a mut dyn Flow; #[inline] - fn next(&mut self) -> Option<&'a mut Flow> { + fn next(&mut self) -> Option<&'a mut dyn Flow> { self.it.next().map(FlowRef::deref_mut) } @@ -206,7 +206,7 @@ pub struct FlowListRandomAccessMut<'a> { } impl<'a> FlowListRandomAccessMut<'a> { - pub fn get<'b>(&'b mut self, index: usize) -> &'b mut Flow { + pub fn get<'b>(&'b mut self, index: usize) -> &'b mut dyn Flow { while index >= self.cache.len() { match self.iterator.next() { None => panic!("Flow index out of range!"), diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index 31748f7039d..6b9027459ee 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -13,11 +13,11 @@ use std::ops::Deref; use std::sync::{Arc, Weak}; #[derive(Clone, Debug)] -pub struct FlowRef(Arc<Flow>); +pub struct FlowRef(Arc<dyn Flow>); impl Deref for FlowRef { - type Target = Flow; - fn deref(&self) -> &Flow { + type Target = dyn Flow; + fn deref(&self) -> &dyn Flow { self.0.deref() } } @@ -25,19 +25,19 @@ impl Deref for FlowRef { impl FlowRef { /// `FlowRef`s can only be made available to the traversal code. /// See https://github.com/servo/servo/issues/14014 for more details. - pub fn new(mut r: Arc<Flow>) -> Self { + pub fn new(mut r: Arc<dyn Flow>) -> Self { // This assertion checks that this `FlowRef` does not alias normal `Arc`s. // If that happens, we're in trouble. assert!(Arc::get_mut(&mut r).is_some()); FlowRef(r) } - pub fn get_mut(this: &mut FlowRef) -> Option<&mut Flow> { + pub fn get_mut(this: &mut FlowRef) -> Option<&mut dyn Flow> { Arc::get_mut(&mut this.0) } pub fn downgrade(this: &FlowRef) -> WeakFlowRef { WeakFlowRef(Arc::downgrade(&this.0)) } - pub fn into_arc(mut this: FlowRef) -> Arc<Flow> { + pub fn into_arc(mut this: FlowRef) -> Arc<dyn Flow> { // This assertion checks that this `FlowRef` does not alias normal `Arc`s. // If that happens, we're in trouble. assert!(FlowRef::get_mut(&mut this).is_some()); @@ -48,14 +48,14 @@ impl FlowRef { /// See https://github.com/servo/servo/issues/6503 /// Use Arc::get_mut instead when possible (e.g. on an Arc that was just created). #[allow(unsafe_code)] - pub fn deref_mut(this: &mut FlowRef) -> &mut Flow { - let ptr: *const Flow = &*this.0; - unsafe { &mut *(ptr as *mut Flow) } + pub fn deref_mut(this: &mut FlowRef) -> &mut dyn Flow { + let ptr: *const dyn Flow = &*this.0; + unsafe { &mut *(ptr as *mut dyn Flow) } } } #[derive(Clone, Debug)] -pub struct WeakFlowRef(Weak<Flow>); +pub struct WeakFlowRef(Weak<dyn Flow>); impl WeakFlowRef { pub fn upgrade(&self) -> Option<FlowRef> { diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 024d51b22fb..af710142446 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -152,7 +152,7 @@ impl<'a> ResolveGeneratedContent<'a> { impl<'a> InorderFlowTraversal for ResolveGeneratedContent<'a> { #[inline] - fn process(&mut self, flow: &mut Flow, level: u32) { + fn process(&mut self, flow: &mut dyn Flow, level: u32) { let mut mutator = ResolveGeneratedContentFragmentMutator { traversal: self, level: level, @@ -163,7 +163,7 @@ impl<'a> InorderFlowTraversal for ResolveGeneratedContent<'a> { } #[inline] - fn should_process_subtree(&mut self, flow: &mut Flow) -> bool { + fn should_process_subtree(&mut self, flow: &mut dyn Flow) -> bool { flow.base() .restyle_damage .intersects(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT) || diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 6734620e5a0..7dde93384b7 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -27,7 +27,7 @@ pub trait LayoutDamageComputation { fn reflow_entire_document(self); } -impl<'a> LayoutDamageComputation for &'a mut Flow { +impl<'a> LayoutDamageComputation for &'a mut dyn Flow { fn compute_layout_damage(self) -> SpecialRestyleDamage { let mut special_damage = SpecialRestyleDamage::empty(); let is_absolutely_positioned = self @@ -53,7 +53,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow { .damage_for_child(is_absolutely_positioned, child_is_absolutely_positioned), ); { - let kid: &mut Flow = kid; + let kid: &mut dyn Flow = kid; special_damage.insert(kid.compute_layout_damage()); } self_base.restyle_damage.insert( diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 08a371bac08..080c68129a2 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1854,7 +1854,7 @@ impl Flow for InlineFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -1888,7 +1888,7 @@ impl Flow for InlineFlow { } } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { for fragment in &mut self.fragments.fragments { (*mutator)(fragment) } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index b91ee22eba8..2bf13e32173 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -4,49 +4,16 @@ #![deny(unsafe_code)] -extern crate app_units; -extern crate atomic_refcell; #[macro_use] extern crate bitflags; -extern crate canvas_traits; -extern crate euclid; -extern crate fnv; -extern crate fxhash; -extern crate gfx; -extern crate gfx_traits; #[macro_use] extern crate html5ever; -extern crate ipc_channel; -extern crate libc; #[macro_use] extern crate log; -extern crate malloc_size_of; -extern crate msg; -extern crate net_traits; -extern crate ordered_float; -extern crate parking_lot; -extern crate profile_traits; #[macro_use] extern crate range; -extern crate rayon; -extern crate script_layout_interface; -extern crate script_traits; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_arc; -extern crate servo_atoms; -extern crate servo_channel; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_url; -extern crate smallvec; -extern crate style; -extern crate style_traits; -extern crate unicode_bidi; -extern crate unicode_script; -extern crate webrender_api; -extern crate xi_unicode; #[macro_use] pub mod layout_debug; diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index cef1487f2f0..893b63fb66a 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -231,7 +231,7 @@ impl Flow for ListItemFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -266,7 +266,7 @@ impl Flow for ListItemFlow { } } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator); for marker in &mut self.marker_fragments { diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 71d9befac61..0d2a72a7b3b 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -241,7 +241,7 @@ impl Flow for MulticolFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -252,7 +252,7 @@ impl Flow for MulticolFlow { ); } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator); } @@ -295,7 +295,7 @@ impl Flow for MulticolColumnFlow { &mut self, layout_context: &LayoutContext, fragmentation_context: Option<FragmentationContext>, - ) -> Option<Arc<Flow>> { + ) -> Option<Arc<dyn Flow>> { Flow::fragment(&mut self.block_flow, layout_context, fragmentation_context) } @@ -345,7 +345,7 @@ impl Flow for MulticolColumnFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -356,7 +356,7 @@ impl Flow for MulticolColumnFlow { ); } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator); } diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index f510851ce92..3a5a956e28c 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -29,7 +29,7 @@ pub type FlowList = SmallVec<[UnsafeFlow; CHUNK_SIZE]>; /// Vtable + pointer representation of a Flow trait object. #[derive(Clone, Copy, Eq, PartialEq)] -pub struct UnsafeFlow(*const Flow); +pub struct UnsafeFlow(*const dyn Flow); unsafe impl Sync for UnsafeFlow {} unsafe impl Send for UnsafeFlow {} @@ -73,7 +73,7 @@ impl FlowParallelInfo { fn bottom_up_flow(mut unsafe_flow: UnsafeFlow, assign_bsize_traversal: &AssignBSizes) { loop { // Get a real flow. - let flow: &mut Flow = unsafe { mem::transmute(unsafe_flow) }; + let flow: &mut dyn Flow = unsafe { mem::transmute(unsafe_flow) }; // Perform the appropriate traversal. if assign_bsize_traversal.should_process(flow) { @@ -97,7 +97,7 @@ fn bottom_up_flow(mut unsafe_flow: UnsafeFlow, assign_bsize_traversal: &AssignBS // No, we're not at the root yet. Then are we the last child // of our parent to finish processing? If so, we can continue // on with our parent; otherwise, we've gotta wait. - let parent: &mut Flow = unsafe { &mut *(unsafe_parent.0 as *mut Flow) }; + let parent: &mut dyn Flow = unsafe { &mut *(unsafe_parent.0 as *mut dyn Flow) }; let parent_base = parent.mut_base(); if parent_base .parallel @@ -127,7 +127,7 @@ fn top_down_flow<'scope>( let mut had_children = false; unsafe { // Get a real flow. - let flow: &mut Flow = mem::transmute(*unsafe_flow); + let flow: &mut dyn Flow = mem::transmute(*unsafe_flow); flow.mut_base().thread_id = pool.current_thread_index().unwrap() as u8; if assign_isize_traversal.should_process(flow) { @@ -191,7 +191,7 @@ fn top_down_flow<'scope>( /// Run the main layout passes in parallel. pub fn reflow( - root: &mut Flow, + root: &mut dyn Flow, profiler_metadata: Option<TimerMetadata>, time_profiler_chan: time::ProfilerChan, context: &LayoutContext, diff --git a/components/layout/persistent_list.rs b/components/layout/persistent_list.rs index 0a8337bfaa7..735b2407ae5 100644 --- a/components/layout/persistent_list.rs +++ b/components/layout/persistent_list.rs @@ -77,7 +77,7 @@ where pub struct PersistentListIterator<'a, T> where - T: 'a + Send + Sync, + T: Send + Sync, { entry: Option<&'a PersistentListEntry<T>>, } diff --git a/components/layout/query.rs b/components/layout/query.rs index 7a6a85824ed..1255e65bcbd 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -366,7 +366,7 @@ impl FragmentBorderBoxIterator for MarginRetrievingFragmentBorderBoxIterator { pub fn process_content_box_request<N: LayoutNode>( requested_node: N, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> Option<Rect<Au>> { // FIXME(pcwalton): This has not been updated to handle the stacking context relative // stuff. So the position is wrong in most cases. @@ -377,7 +377,7 @@ pub fn process_content_box_request<N: LayoutNode>( pub fn process_content_boxes_request<N: LayoutNode>( requested_node: N, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> Vec<Rect<Au>> { // FIXME(pcwalton): This has not been updated to handle the stacking context relative // stuff. So the position is wrong in most cases. @@ -671,7 +671,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator { pub fn process_node_geometry_request<N: LayoutNode>( requested_node: N, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> Rect<i32> { let mut iterator = FragmentLocatingFragmentIterator::new(requested_node.opaque()); sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator); @@ -689,7 +689,7 @@ pub fn process_node_scroll_id_request<N: LayoutNode>( /// https://drafts.csswg.org/cssom-view/#scrolling-area pub fn process_node_scroll_area_request<N: LayoutNode>( requested_node: N, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> Rect<i32> { let mut iterator = UnioningFragmentScrollAreaIterator::new(requested_node.opaque()); sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator); @@ -742,7 +742,7 @@ pub fn process_resolved_style_request<'a, N>( node: N, pseudo: &Option<PseudoElement>, property: &PropertyId, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> String where N: LayoutNode, @@ -791,7 +791,7 @@ fn process_resolved_style_request_internal<'a, N>( requested_node: N, pseudo: &Option<PseudoElement>, property: &PropertyId, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> String where N: LayoutNode, @@ -843,7 +843,7 @@ where fn used_value_for_position_property<N: LayoutNode>( layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, requested_node: N, longhand_id: LonghandId, ) -> String { @@ -934,7 +934,7 @@ where pub fn process_offset_parent_query<N: LayoutNode>( requested_node: N, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, ) -> OffsetParentResponse { let mut iterator = ParentOffsetBorderBoxIterator::new(requested_node.opaque()); sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator); diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index 3203dee5e49..9ade33d97a7 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -19,14 +19,14 @@ use servo_config::opts; use style::servo::restyle_damage::ServoRestyleDamage; use webrender_api::LayoutPoint; -pub fn resolve_generated_content(root: &mut Flow, layout_context: &LayoutContext) { +pub fn resolve_generated_content(root: &mut dyn Flow, layout_context: &LayoutContext) { ResolveGeneratedContent::new(&layout_context).traverse(root, 0); } /// Run the main layout passes sequentially. -pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) { +pub fn reflow(root: &mut dyn Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) { fn doit( - flow: &mut Flow, + flow: &mut dyn Flow, assign_inline_sizes: AssignISizes, assign_block_sizes: AssignBSizes, relayout_mode: RelayoutMode, @@ -70,7 +70,7 @@ pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: Re } pub fn build_display_list_for_subtree<'a>( - flow_root: &mut Flow, + flow_root: &mut dyn Flow, layout_context: &'a LayoutContext, ) -> DisplayListBuildState<'a> { let mut state = StackingContextCollectionState::new(layout_context.id); @@ -83,13 +83,13 @@ pub fn build_display_list_for_subtree<'a>( } pub fn iterate_through_flow_tree_fragment_border_boxes( - root: &mut Flow, - iterator: &mut FragmentBorderBoxIterator, + root: &mut dyn Flow, + iterator: &mut dyn FragmentBorderBoxIterator, ) { fn doit( - flow: &mut Flow, + flow: &mut dyn Flow, level: i32, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, stacking_context_position: &Point2D<Au>, ) { flow.iterate_through_fragment_border_boxes(iterator, level, stacking_context_position); @@ -119,7 +119,7 @@ pub fn iterate_through_flow_tree_fragment_border_boxes( doit(root, 0, iterator, &Point2D::zero()); } -pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) { +pub fn store_overflow(layout_context: &LayoutContext, flow: &mut dyn Flow) { if !flow .base() .restyle_damage @@ -142,7 +142,7 @@ pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) { /// Guesses how much inline size will be taken up by floats on the left and right sides of the /// given flow. This is needed to speculatively calculate the inline sizes of block formatting /// contexts. The speculation typically succeeds, but if it doesn't we have to lay it out again. -pub fn guess_float_placement(flow: &mut Flow) { +pub fn guess_float_placement(flow: &mut dyn Flow) { if !flow .base() .restyle_damage diff --git a/components/layout/table.rs b/components/layout/table.rs index 4f28b22e6f6..10917628e75 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -611,7 +611,7 @@ impl Flow for TableFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -622,7 +622,7 @@ impl Flow for TableFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index a9d9660144f..910ad7f8c5b 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -115,7 +115,7 @@ impl Flow for TableCaptionFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -126,7 +126,7 @@ impl Flow for TableCaptionFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 51442f2f832..879ab9b82a1 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -334,7 +334,7 @@ impl Flow for TableCellFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -345,7 +345,7 @@ impl Flow for TableCellFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index d1347ef4cce..b2fd17d1978 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -112,13 +112,13 @@ impl Flow for TableColGroupFlow { fn iterate_through_fragment_border_boxes( &self, - _: &mut FragmentBorderBoxIterator, + _: &mut dyn FragmentBorderBoxIterator, _: i32, _: &Point2D<Au>, ) { } - fn mutate_fragments(&mut self, _: &mut FnMut(&mut Fragment)) {} + fn mutate_fragments(&mut self, _: &mut dyn FnMut(&mut Fragment)) {} } impl fmt::Debug for TableColGroupFlow { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 5b50b48448e..ba327bd266b 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -650,7 +650,7 @@ impl Flow for TableRowFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -661,7 +661,7 @@ impl Flow for TableRowFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } @@ -907,7 +907,7 @@ impl CollapsedBorder { /// Pushes column inline size, incoming rowspan, and border collapse info down to a child. pub fn propagate_column_inline_sizes_to_child( - child_flow: &mut Flow, + child_flow: &mut dyn Flow, table_writing_mode: WritingMode, column_computed_inline_sizes: &[ColumnComputedInlineSize], border_spacing: &BorderSpacing, @@ -975,7 +975,7 @@ pub fn propagate_column_inline_sizes_to_child( /// Lay out table cells inline according to the computer column sizes. fn set_inline_position_of_child_flow( - child_flow: &mut Flow, + child_flow: &mut dyn Flow, child_index: usize, column_index: &mut usize, incoming_rowspan: &[u32], diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 703bd9217a0..947bfde2d64 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -246,7 +246,7 @@ impl Flow for TableRowGroupFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -257,7 +257,7 @@ impl Flow for TableRowGroupFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index ad6bee3b4e3..12683ee8946 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -531,7 +531,7 @@ impl Flow for TableWrapperFlow { fn iterate_through_fragment_border_boxes( &self, - iterator: &mut FragmentBorderBoxIterator, + iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, ) { @@ -542,7 +542,7 @@ impl Flow for TableWrapperFlow { ) } - fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { + fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) { self.block_flow.mutate_fragments(mutator) } diff --git a/components/layout/tests/size_of.rs b/components/layout/tests/size_of.rs index 7d869271368..430053ca160 100644 --- a/components/layout/tests/size_of.rs +++ b/components/layout/tests/size_of.rs @@ -4,7 +4,6 @@ #![cfg(target_pointer_width = "64")] -extern crate layout; #[macro_use] extern crate size_of_test; diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 51888069cac..6e2e739d8db 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -90,23 +90,23 @@ where /// A top-down traversal. pub trait PreorderFlowTraversal { /// The operation to perform. Return true to continue or false to stop. - fn process(&self, flow: &mut Flow); + fn process(&self, flow: &mut dyn Flow); /// Returns true if this node should be processed and false if neither this node nor its /// descendants should be processed. - fn should_process_subtree(&self, _flow: &mut Flow) -> bool { + fn should_process_subtree(&self, _flow: &mut dyn Flow) -> bool { true } /// Returns true if this node must be processed in-order. If this returns false, /// we skip the operation for this node, but continue processing the descendants. /// This is called *after* parent nodes are visited. - fn should_process(&self, _flow: &mut Flow) -> bool { + fn should_process(&self, _flow: &mut dyn Flow) -> bool { true } /// Traverses the tree in preorder. - fn traverse(&self, flow: &mut Flow) { + fn traverse(&self, flow: &mut dyn Flow) { if !self.should_process_subtree(flow) { return; } @@ -124,7 +124,7 @@ pub trait PreorderFlowTraversal { /// their direct absolute descendants. /// /// Return true if the traversal is to continue or false to stop. - fn traverse_absolute_flows(&self, flow: &mut Flow) { + fn traverse_absolute_flows(&self, flow: &mut dyn Flow) { if self.should_process(flow) { self.process(flow); } @@ -137,17 +137,17 @@ pub trait PreorderFlowTraversal { /// A bottom-up traversal, with a optional in-order pass. pub trait PostorderFlowTraversal { /// The operation to perform. Return true to continue or false to stop. - fn process(&self, flow: &mut Flow); + fn process(&self, flow: &mut dyn Flow); /// Returns false if this node must be processed in-order. If this returns false, we skip the /// operation for this node, but continue processing the ancestors. This is called *after* /// child nodes are visited. - fn should_process(&self, _flow: &mut Flow) -> bool { + fn should_process(&self, _flow: &mut dyn Flow) -> bool { true } /// Traverses the tree in postorder. - fn traverse(&self, flow: &mut Flow) { + fn traverse(&self, flow: &mut dyn Flow) { for kid in flow.mut_base().child_iter_mut() { self.traverse(kid); } @@ -160,16 +160,16 @@ pub trait PostorderFlowTraversal { /// An in-order (sequential only) traversal. pub trait InorderFlowTraversal { /// The operation to perform. Returns the level of the tree we're at. - fn process(&mut self, flow: &mut Flow, level: u32); + fn process(&mut self, flow: &mut dyn Flow, level: u32); /// Returns true if this node should be processed and false if neither this node nor its /// descendants should be processed. - fn should_process_subtree(&mut self, _flow: &mut Flow) -> bool { + fn should_process_subtree(&mut self, _flow: &mut dyn Flow) -> bool { true } /// Traverses the tree in-order. - fn traverse(&mut self, flow: &mut Flow, level: u32) { + fn traverse(&mut self, flow: &mut dyn Flow, level: u32) { if !self.should_process_subtree(flow) { return; } @@ -238,7 +238,7 @@ pub struct BubbleISizes<'a> { impl<'a> PostorderFlowTraversal for BubbleISizes<'a> { #[inline] - fn process(&self, flow: &mut Flow) { + fn process(&self, flow: &mut dyn Flow) { flow.bubble_inline_sizes(); flow.mut_base() .restyle_damage @@ -246,7 +246,7 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> { } #[inline] - fn should_process(&self, flow: &mut Flow) -> bool { + fn should_process(&self, flow: &mut dyn Flow) -> bool { flow.base() .restyle_damage .contains(ServoRestyleDamage::BUBBLE_ISIZES) @@ -261,12 +261,12 @@ pub struct AssignISizes<'a> { impl<'a> PreorderFlowTraversal for AssignISizes<'a> { #[inline] - fn process(&self, flow: &mut Flow) { + fn process(&self, flow: &mut dyn Flow) { flow.assign_inline_sizes(self.layout_context); } #[inline] - fn should_process(&self, flow: &mut Flow) -> bool { + fn should_process(&self, flow: &mut dyn Flow) -> bool { flow.base() .restyle_damage .intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) @@ -283,7 +283,7 @@ pub struct AssignBSizes<'a> { impl<'a> PostorderFlowTraversal for AssignBSizes<'a> { #[inline] - fn process(&self, flow: &mut Flow) { + fn process(&self, flow: &mut dyn Flow) { // Can't do anything with anything that floats might flow through until we reach their // inorder parent. // @@ -297,7 +297,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizes<'a> { } #[inline] - fn should_process(&self, flow: &mut Flow) -> bool { + fn should_process(&self, flow: &mut dyn Flow) -> bool { let base = flow.base(); base.restyle_damage.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) && // The fragmentation countainer is responsible for calling @@ -312,14 +312,14 @@ pub struct ComputeStackingRelativePositions<'a> { impl<'a> PreorderFlowTraversal for ComputeStackingRelativePositions<'a> { #[inline] - fn should_process_subtree(&self, flow: &mut Flow) -> bool { + fn should_process_subtree(&self, flow: &mut dyn Flow) -> bool { flow.base() .restyle_damage .contains(ServoRestyleDamage::REPOSITION) } #[inline] - fn process(&self, flow: &mut Flow) { + fn process(&self, flow: &mut dyn Flow) { flow.compute_stacking_relative_position(self.layout_context); flow.mut_base() .restyle_damage @@ -333,7 +333,7 @@ pub struct BuildDisplayList<'a> { impl<'a> BuildDisplayList<'a> { #[inline] - pub fn traverse(&mut self, flow: &mut Flow) { + pub fn traverse(&mut self, flow: &mut dyn Flow) { let parent_stacking_context_id = self.state.current_stacking_context_id; self.state.current_stacking_context_id = flow.base().stacking_context_id; diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index bf10a795732..91b801464fe 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -5,52 +5,18 @@ //! The layout thread. Performs layout on the DOM, builds display lists and sends them to be //! painted. -extern crate app_units; -extern crate atomic_refcell; -extern crate embedder_traits; -extern crate euclid; -extern crate fnv; -extern crate fxhash; -extern crate gfx; -extern crate gfx_traits; -extern crate histogram; #[macro_use] extern crate html5ever; -extern crate ipc_channel; #[macro_use] extern crate layout; -extern crate layout_traits; #[macro_use] extern crate lazy_static; -extern crate libc; #[macro_use] extern crate log; -extern crate malloc_size_of; -extern crate metrics; -extern crate msg; -extern crate net_traits; -extern crate parking_lot; #[macro_use] extern crate profile_traits; -extern crate range; -extern crate rayon; -extern crate script; -extern crate script_layout_interface; -extern crate script_traits; -extern crate selectors; -extern crate serde_json; -extern crate servo_allocator; -extern crate servo_arc; -extern crate servo_atoms; #[macro_use] extern crate servo_channel; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_url; -extern crate style; -extern crate style_traits; -extern crate time as std_time; -extern crate webrender_api; mod dom_wrapper; @@ -101,8 +67,8 @@ use msg::constellation_msg::PipelineId; use msg::constellation_msg::TopLevelBrowsingContextId; use net_traits::image_cache::{ImageCache, UsePlaceholder}; use parking_lot::RwLock; -use profile_traits::mem::{self, Report, ReportKind, ReportsChan}; -use profile_traits::time::{self, profile, TimerMetadata}; +use profile_traits::mem::{self as profile_mem, Report, ReportKind, ReportsChan}; +use profile_traits::time::{self as profile_time, profile, TimerMetadata}; use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; use script_layout_interface::message::{Msg, NewLayoutThreadInfo, NodesFromPointQueryType, Reflow}; use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow}; @@ -124,7 +90,6 @@ use servo_url::ServoUrl; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; use std::collections::HashMap; -use std::mem as std_mem; use std::ops::{Deref, DerefMut}; use std::process; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -191,13 +156,13 @@ pub struct LayoutThread { script_chan: IpcSender<ConstellationControlMsg>, /// The channel on which messages can be sent to the time profiler. - time_profiler_chan: time::ProfilerChan, + time_profiler_chan: profile_time::ProfilerChan, /// The channel on which messages can be sent to the memory profiler. - mem_profiler_chan: mem::ProfilerChan, + mem_profiler_chan: profile_mem::ProfilerChan, /// Reference to the script thread image cache. - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, /// Public interface to the font cache thread. font_cache_thread: FontCacheThread, @@ -289,10 +254,10 @@ impl LayoutThreadFactory for LayoutThread { pipeline_port: IpcReceiver<LayoutControlMsg>, constellation_chan: IpcSender<ConstellationMsg>, script_chan: IpcSender<ConstellationControlMsg>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, font_cache_thread: FontCacheThread, - time_profiler_chan: time::ProfilerChan, - mem_profiler_chan: mem::ProfilerChan, + time_profiler_chan: profile_time::ProfilerChan, + mem_profiler_chan: profile_mem::ProfilerChan, content_process_shutdown_chan: Option<IpcSender<()>>, webrender_api_sender: webrender_api::RenderApiSender, webrender_document: webrender_api::DocumentId, @@ -480,10 +445,10 @@ impl LayoutThread { pipeline_port: IpcReceiver<LayoutControlMsg>, constellation_chan: IpcSender<ConstellationMsg>, script_chan: IpcSender<ConstellationControlMsg>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, font_cache_thread: FontCacheThread, - time_profiler_chan: time::ProfilerChan, - mem_profiler_chan: mem::ProfilerChan, + time_profiler_chan: profile_time::ProfilerChan, + mem_profiler_chan: profile_mem::ProfilerChan, webrender_api_sender: webrender_api::RenderApiSender, webrender_document: webrender_api::DocumentId, layout_threads: usize, @@ -716,13 +681,13 @@ impl LayoutThread { Msg::SetQuirksMode(mode) => self.handle_set_quirks_mode(mode), Msg::GetRPC(response_chan) => { response_chan - .send(Box::new(LayoutRPCImpl(self.rw_data.clone())) as Box<LayoutRPC + Send>) + .send(Box::new(LayoutRPCImpl(self.rw_data.clone())) as Box<dyn LayoutRPC + Send>) .unwrap(); }, Msg::Reflow(data) => { let mut data = ScriptReflowResult::new(data); profile( - time::ProfilerCategory::LayoutPerform, + profile_time::ProfilerCategory::LayoutPerform, self.profiler_metadata(), self.time_profiler_chan.clone(), || self.handle_reflow(&mut data, possibly_locked_rw_data), @@ -812,7 +777,7 @@ impl LayoutThread { let mut reports = vec![]; // Servo uses vanilla jemalloc, which doesn't have a // malloc_enclosing_size_of function. - let mut ops = MallocSizeOfOps::new(::servo_allocator::usable_size, None, None); + let mut ops = MallocSizeOfOps::new(servo_allocator::usable_size, None, None); // FIXME(njn): Just measuring the display tree for now. let rw_data = possibly_locked_rw_data.lock(); @@ -963,7 +928,7 @@ impl LayoutThread { /// This corresponds to `Reflow()` in Gecko and `layout()` in WebKit/Blink and should be /// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling. #[inline(never)] - fn solve_constraints(layout_root: &mut Flow, layout_context: &LayoutContext) { + fn solve_constraints(layout_root: &mut dyn Flow, layout_context: &LayoutContext) { let _scope = layout_debug_scope!("solve_constraints"); sequential::reflow(layout_root, layout_context, RelayoutMode::Incremental); } @@ -975,9 +940,9 @@ impl LayoutThread { #[inline(never)] fn solve_constraints_parallel( traversal: &rayon::ThreadPool, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, profiler_metadata: Option<TimerMetadata>, - time_profiler_chan: time::ProfilerChan, + time_profiler_chan: profile_time::ProfilerChan, layout_context: &LayoutContext, ) { let _scope = layout_debug_scope!("solve_constraints_parallel"); @@ -1000,14 +965,14 @@ impl LayoutThread { data: &Reflow, reflow_goal: &ReflowGoal, document: Option<&ServoLayoutDocument>, - layout_root: &mut Flow, + layout_root: &mut dyn Flow, layout_context: &mut LayoutContext, rw_data: &mut LayoutThreadData, ) { let writing_mode = layout_root.base().writing_mode; let (metadata, sender) = (self.profiler_metadata(), self.time_profiler_chan.clone()); profile( - time::ProfilerCategory::LayoutDispListBuild, + profile_time::ProfilerCategory::LayoutDispListBuild, metadata.clone(), sender.clone(), || { @@ -1149,7 +1114,7 @@ impl LayoutThread { let mut rw_data = possibly_locked_rw_data.lock(); // Record the time that layout query has been waited. - let now = std_time::precise_time_ns(); + let now = time::precise_time_ns(); if let ReflowGoal::LayoutQuery(_, timestamp) = data.reflow_goal { self.layout_query_waiting_time .increment(now - timestamp) @@ -1366,7 +1331,7 @@ impl LayoutThread { if token.should_traverse() { // Recalculate CSS styles and rebuild flows and fragments. profile( - time::ProfilerCategory::LayoutStyleRecalc, + profile_time::ProfilerCategory::LayoutStyleRecalc, self.profiler_metadata(), self.time_profiler_chan.clone(), || { @@ -1381,8 +1346,8 @@ impl LayoutThread { // TODO(pcwalton): Measure energy usage of text shaping, perhaps? let text_shaping_time = (font::get_and_reset_text_shaping_performance_counter() as u64) / (self.layout_threads as u64); - time::send_profile_data( - time::ProfilerCategory::LayoutTextShaping, + profile_time::send_profile_data( + profile_time::ProfilerCategory::LayoutTextShaping, self.profiler_metadata(), &self.time_profiler_chan, 0, @@ -1447,13 +1412,13 @@ impl LayoutThread { reflow_result: &mut ReflowComplete, ) { let pending_images = match context.pending_images { - Some(ref pending) => std_mem::replace(&mut *pending.lock().unwrap(), vec![]), + Some(ref pending) => std::mem::replace(&mut *pending.lock().unwrap(), vec![]), None => vec![], }; reflow_result.pending_images = pending_images; let newly_transitioning_nodes = match context.newly_transitioning_nodes { - Some(ref nodes) => std_mem::replace(&mut *nodes.lock().unwrap(), vec![]), + Some(ref nodes) => std::mem::replace(&mut *nodes.lock().unwrap(), vec![]), None => vec![], }; reflow_result.newly_transitioning_nodes = newly_transitioning_nodes; @@ -1608,7 +1573,7 @@ impl LayoutThread { // Perform an abbreviated style recalc that operates without access to the DOM. let animations = self.running_animations.read(); profile( - time::ProfilerCategory::LayoutStyleRecalc, + profile_time::ProfilerCategory::LayoutStyleRecalc, self.profiler_metadata(), self.time_profiler_chan.clone(), || { @@ -1663,7 +1628,7 @@ impl LayoutThread { } profile( - time::ProfilerCategory::LayoutRestyleDamagePropagation, + profile_time::ProfilerCategory::LayoutRestyleDamagePropagation, self.profiler_metadata(), self.time_profiler_chan.clone(), || { @@ -1685,7 +1650,7 @@ impl LayoutThread { // Resolve generated content. profile( - time::ProfilerCategory::LayoutGeneratedContent, + profile_time::ProfilerCategory::LayoutGeneratedContent, self.profiler_metadata(), self.time_profiler_chan.clone(), || sequential::resolve_generated_content(FlowRef::deref_mut(root_flow), &context), @@ -1693,7 +1658,7 @@ impl LayoutThread { // Guess float placement. profile( - time::ProfilerCategory::LayoutFloatPlacementSpeculation, + profile_time::ProfilerCategory::LayoutFloatPlacementSpeculation, self.profiler_metadata(), self.time_profiler_chan.clone(), || sequential::guess_float_placement(FlowRef::deref_mut(root_flow)), @@ -1707,7 +1672,7 @@ impl LayoutThread { .intersects(ServoRestyleDamage::REFLOW | ServoRestyleDamage::REFLOW_OUT_OF_FLOW) { profile( - time::ProfilerCategory::LayoutMain, + profile_time::ProfilerCategory::LayoutMain, self.profiler_metadata(), self.time_profiler_chan.clone(), || { @@ -1733,11 +1698,11 @@ impl LayoutThread { } profile( - time::ProfilerCategory::LayoutStoreOverflow, + profile_time::ProfilerCategory::LayoutStoreOverflow, self.profiler_metadata(), self.time_profiler_chan.clone(), || { - sequential::store_overflow(context, FlowRef::deref_mut(root_flow) as &mut Flow); + sequential::store_overflow(context, FlowRef::deref_mut(root_flow) as &mut dyn Flow); }, ); @@ -1781,7 +1746,7 @@ impl LayoutThread { self.generation.set(self.generation.get() + 1); } - fn reflow_all_nodes(flow: &mut Flow) { + fn reflow_all_nodes(flow: &mut dyn Flow) { debug!("reflowing all nodes!"); flow.mut_base().restyle_damage.insert( ServoRestyleDamage::REPAINT | @@ -1828,7 +1793,7 @@ impl ProfilerMetadataFactory for LayoutThread { // clearing the frame buffer to white. This ensures that setting a background // color on an iframe element, while the iframe content itself has a default // transparent background color is handled correctly. -fn get_root_flow_background_color(flow: &mut Flow) -> webrender_api::ColorF { +fn get_root_flow_background_color(flow: &mut dyn Flow) -> webrender_api::ColorF { let transparent = webrender_api::ColorF { r: 0.0, g: 0.0, @@ -1948,7 +1913,7 @@ lazy_static! { } struct RegisteredPainterImpl { - painter: Box<Painter>, + painter: Box<dyn Painter>, name: Atom, // FIXME: Should be a PrecomputedHashMap. properties: FxHashMap<Atom, PropertyId>, @@ -1992,17 +1957,17 @@ impl RegisteredPainter for RegisteredPainterImpl {} struct RegisteredPaintersImpl(FnvHashMap<Atom, RegisteredPainterImpl>); impl RegisteredSpeculativePainters for RegisteredPaintersImpl { - fn get(&self, name: &Atom) -> Option<&RegisteredSpeculativePainter> { + fn get(&self, name: &Atom) -> Option<&dyn RegisteredSpeculativePainter> { self.0 .get(&name) - .map(|painter| painter as &RegisteredSpeculativePainter) + .map(|painter| painter as &dyn RegisteredSpeculativePainter) } } impl RegisteredPainters for RegisteredPaintersImpl { - fn get(&self, name: &Atom) -> Option<&RegisteredPainter> { + fn get(&self, name: &Atom) -> Option<&dyn RegisteredPainter> { self.0 .get(&name) - .map(|painter| painter as &RegisteredPainter) + .map(|painter| painter as &dyn RegisteredPainter) } } diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index 9fb431c8e2e..0cea8397f7e 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -4,17 +4,6 @@ #![deny(unsafe_code)] -extern crate gfx; -extern crate ipc_channel; -extern crate metrics; -extern crate msg; -extern crate net_traits; -extern crate profile_traits; -extern crate script_traits; -extern crate servo_channel; -extern crate servo_url; -extern crate webrender_api; - // This module contains traits in layout used generically // in the rest of Servo. // The traits are here instead of in layout so @@ -32,6 +21,7 @@ use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use servo_channel::{Receiver, Sender}; use servo_url::ServoUrl; use std::sync::Arc; +use webrender_api; // A static method creating a layout thread // Here to remove the compositor -> layout dependency @@ -46,7 +36,7 @@ pub trait LayoutThreadFactory { pipeline_port: IpcReceiver<LayoutControlMsg>, constellation_chan: IpcSender<ConstellationMsg>, script_chan: IpcSender<ConstellationControlMsg>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs index f83a80b9302..e131822b69c 100644 --- a/components/metrics/lib.rs +++ b/components/metrics/lib.rs @@ -2,19 +2,10 @@ * 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/. */ -extern crate gfx_traits; -extern crate ipc_channel; #[macro_use] extern crate log; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate msg; -extern crate profile_traits; -extern crate script_traits; -extern crate servo_config; -extern crate servo_url; -extern crate time; use gfx_traits::{DisplayList, Epoch}; use ipc_channel::ipc::IpcSender; @@ -315,7 +306,7 @@ impl PaintTimeMetrics { &self, profiler_metadata_factory: &T, epoch: Epoch, - display_list: &DisplayList, + display_list: &dyn DisplayList, ) where T: ProfilerMetadataFactory, { diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 3e515e294f8..d2490c142eb 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -10,6 +10,5 @@ extern crate malloc_size_of; extern crate malloc_size_of_derive; #[macro_use] extern crate serde; -extern crate webrender_api; pub mod constellation_msg; diff --git a/components/msg/tests/size_of.rs b/components/msg/tests/size_of.rs index 62e2647ea61..54995bcb6f7 100644 --- a/components/msg/tests/size_of.rs +++ b/components/msg/tests/size_of.rs @@ -4,7 +4,6 @@ #![cfg(target_pointer_width = "64")] -extern crate msg; #[macro_use] extern crate size_of_test; diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 798c85da1bd..ce05657d371 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["rename-dependency"] + [package] name = "net" version = "0.0.1" @@ -17,7 +19,7 @@ doctest = false base64 = "0.9" brotli = "2.5" bytes = "0.4" -cookie = "0.11" +cookie_rs = {package = "cookie", version = "0.11"} devtools_traits = {path = "../devtools_traits"} embedder_traits = { path = "../embedder_traits" } flate2 = "1" diff --git a/components/net/connector.rs b/components/net/connector.rs index 38693e70e24..de9f9b2e087 100644 --- a/components/net/connector.rs +++ b/components/net/connector.rs @@ -161,7 +161,7 @@ pub fn create_http_client<E>( executor: E, ) -> Client<Connector, WrappedBody> where - E: Executor<Box<Future<Error = (), Item = ()> + Send + 'static>> + Sync + Send + 'static, + E: Executor<Box<dyn Future<Error = (), Item = ()> + Send + 'static>> + Sync + Send + 'static, { let connector = HttpsConnector::with_connector(HttpConnector::new(), ssl_connector_builder).unwrap(); diff --git a/components/net/cookie.rs b/components/net/cookie.rs index 5b9089cc1d3..113a49bd96e 100644 --- a/components/net/cookie.rs +++ b/components/net/cookie.rs @@ -5,7 +5,7 @@ //! Implementation of cookie creation and matching as specified by //! http://tools.ietf.org/html/rfc6265 -use crate::cookie_rs; +use cookie_rs; use hyper_serde::{self, Serde}; use net_traits::pub_domains::is_pub_domain; use net_traits::CookieSource; diff --git a/components/net/cookie_storage.rs b/components/net/cookie_storage.rs index 7eefb164439..2acde56866c 100644 --- a/components/net/cookie_storage.rs +++ b/components/net/cookie_storage.rs @@ -5,16 +5,14 @@ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 +use cookie_rs; use crate::cookie::Cookie; -use crate::cookie_rs; use net_traits::pub_domains::reg_suffix; use net_traits::CookieSource; use servo_url::ServoUrl; use std::cmp::Ordering; use std::collections::HashMap; -use time::Tm; - -extern crate time; +use time::{self, Tm}; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CookieStorage { diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 0ad92f527ef..499070c04d2 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -41,7 +41,7 @@ lazy_static! { const FILE_CHUNK_SIZE: usize = 32768; //32 KB -pub type Target<'a> = &'a mut (FetchTaskTarget + Send); +pub type Target<'a> = &'a mut (dyn FetchTaskTarget + Send); pub enum Data { Payload(Vec<u8>), diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 8898fdf1924..0bbb64a46cf 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -380,7 +380,7 @@ fn obtain_response( request_id: Option<&str>, is_xhr: bool, ) -> Box< - Future< + dyn Future< Item = ( HyperResponse<WrappedBody>, Option<ChromeToDevtoolsControlMsg>, diff --git a/components/net/lib.rs b/components/net/lib.rs index e4373edee33..7f36629d306 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -4,53 +4,18 @@ #![deny(unsafe_code)] -extern crate base64; -extern crate brotli; -extern crate bytes; -extern crate cookie as cookie_rs; -extern crate devtools_traits; -extern crate embedder_traits; -extern crate flate2; -extern crate headers_core; -extern crate headers_ext; -extern crate http; -extern crate hyper; -extern crate hyper_openssl; -extern crate hyper_serde; -extern crate immeta; -extern crate ipc_channel; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; #[macro_use] -#[no_link] extern crate matches; -extern crate mime; -extern crate mime_guess; -extern crate msg; -extern crate net_traits; -extern crate openssl; -extern crate pixels; #[macro_use] extern crate profile_traits; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_allocator; -extern crate servo_arc; -extern crate servo_channel; -extern crate servo_config; -extern crate servo_url; -extern crate time; -extern crate tokio; -extern crate url; -extern crate uuid; -extern crate webrender_api; -extern crate ws; mod blob_loader; pub mod connector; diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs index e6716789033..432cb36dee5 100644 --- a/components/net/mime_classifier.rs +++ b/components/net/mime_classifier.rs @@ -454,7 +454,7 @@ impl MIMEChecker for BinaryOrPlaintextClassifier { } } struct GroupedClassifier { - byte_matchers: Vec<Box<MIMEChecker + Send + Sync>>, + byte_matchers: Vec<Box<dyn MIMEChecker + Send + Sync>>, } impl GroupedClassifier { fn image_classifer() -> GroupedClassifier { diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index 9793fcb862d..55366efc628 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -3,9 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A thread that takes a URL and streams back the binary data. + +use cookie_rs; use crate::connector::{create_http_client, create_ssl_connector_builder}; use crate::cookie; -use crate::cookie_rs; use crate::cookie_storage::CookieStorage; use crate::fetch::cors_cache::CorsCache; use crate::fetch::methods::{fetch, CancellationListener, FetchContext}; diff --git a/components/net/tests/cookie.rs b/components/net/tests/cookie.rs index 9cf9aa3ac14..219b2979aa9 100644 --- a/components/net/tests/cookie.rs +++ b/components/net/tests/cookie.rs @@ -2,7 +2,7 @@ * 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 crate::cookie_rs; +use cookie_rs; use net::cookie::Cookie; use net::cookie_storage::CookieStorage; use net_traits::CookieSource; diff --git a/components/net/tests/http_loader.rs b/components/net/tests/http_loader.rs index bc5112f1f58..ba8f2e1a3fd 100644 --- a/components/net/tests/http_loader.rs +++ b/components/net/tests/http_loader.rs @@ -2,7 +2,7 @@ * 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 crate::cookie_rs::Cookie as CookiePair; +use cookie_rs::Cookie as CookiePair; use crate::fetch; use crate::fetch_with_context; use crate::make_server; diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index aa7a6aa9cf6..48063adad81 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -4,32 +4,8 @@ #![cfg(test)] -extern crate cookie as cookie_rs; -extern crate devtools_traits; -extern crate embedder_traits; -extern crate flate2; -extern crate futures; -extern crate headers_core; -extern crate headers_ext; -extern crate http; -extern crate hyper; -extern crate hyper_serde; -extern crate ipc_channel; #[macro_use] extern crate lazy_static; -extern crate mime; -extern crate msg; -extern crate net; -extern crate net_traits; -extern crate openssl; -extern crate profile_traits; -extern crate servo_channel; -extern crate servo_config; -extern crate servo_url; -extern crate time; -extern crate tokio; -extern crate tokio_openssl; -extern crate url; mod cookie; mod cookie_http_state; @@ -90,7 +66,7 @@ fn create_embedder_proxy() -> EmbedderProxy { } impl EventLoopWaker for DummyEventLoopWaker { fn wake(&self) {} - fn clone(&self) -> Box<EventLoopWaker + Send> { + fn clone(&self) -> Box<dyn EventLoopWaker + Send> { Box::new(DummyEventLoopWaker {}) } } diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml index e7534bf77ee..6fb2c926dd8 100644 --- a/components/net_traits/Cargo.toml +++ b/components/net_traits/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["rename-dependency"] + [package] name = "net_traits" version = "0.0.1" @@ -20,7 +22,7 @@ headers-ext = "0.0.3" http = "0.1" hyper = "0.12" hyper_serde = "0.9" -image = "0.19" +piston_image = {package = "image", version = "0.19"} ipc-channel = "0.11" lazy_static = "1" log = "0.4" diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs index e1ccf625789..3acd8903006 100644 --- a/components/net_traits/image/base.rs +++ b/components/net_traits/image/base.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::piston_image::{self, DynamicImage, ImageFormat}; use ipc_channel::ipc::IpcSharedMemory; +use piston_image::{DynamicImage, ImageFormat}; use pixels; use std::fmt; use webrender_api; diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 9acfe5dfcca..b7e11fc4af5 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -4,15 +4,6 @@ #![deny(unsafe_code)] -extern crate cookie as cookie_rs; -extern crate embedder_traits; -extern crate headers_core; -extern crate headers_ext; -extern crate http; -extern crate hyper; -extern crate hyper_serde; -extern crate image as piston_image; -extern crate ipc_channel; #[macro_use] extern crate lazy_static; #[macro_use] @@ -21,20 +12,12 @@ extern crate log; extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate mime; -extern crate msg; -extern crate num_traits; -extern crate pixels; #[macro_use] extern crate serde; -extern crate servo_arc; -extern crate servo_url; #[macro_use] extern crate url; -extern crate uuid; -extern crate webrender_api; -use crate::cookie_rs::Cookie; +use cookie::Cookie; use crate::filemanager_thread::FileManagerThreadMsg; use crate::request::{Request, RequestInit}; use crate::response::{HttpsState, Response, ResponseInit}; diff --git a/components/net_traits/tests/image.rs b/components/net_traits/tests/image.rs index 238fae97050..e7d2d460d7e 100644 --- a/components/net_traits/tests/image.rs +++ b/components/net_traits/tests/image.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 http://mozilla.org/MPL/2.0/. */ -extern crate net_traits; - use net_traits::image::base::detect_image_format; #[test] diff --git a/components/net_traits/tests/pub_domains.rs b/components/net_traits/tests/pub_domains.rs index 307dd2d81dc..c17f8ba8c07 100644 --- a/components/net_traits/tests/pub_domains.rs +++ b/components/net_traits/tests/pub_domains.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 http://mozilla.org/MPL/2.0/. */ -extern crate net_traits; - use net_traits::pub_domains::{is_pub_domain, is_reg_domain, pub_suffix, reg_suffix}; // These tests may need to be updated if the PSL changes. diff --git a/components/net_traits/tests/whitespace.rs b/components/net_traits/tests/whitespace.rs index 4954e0f67f4..407b060de1b 100644 --- a/components/net_traits/tests/whitespace.rs +++ b/components/net_traits/tests/whitespace.rs @@ -2,7 +2,7 @@ * 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/. */ -extern crate net_traits; +use net_traits; #[test] fn test_trim_http_whitespace() { diff --git a/components/pixels/lib.rs b/components/pixels/lib.rs index 806b854fda2..16c93b7b6af 100644 --- a/components/pixels/lib.rs +++ b/components/pixels/lib.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 http://mozilla.org/MPL/2.0/. */ -extern crate euclid; - use euclid::{Point2D, Rect, Size2D}; use std::borrow::Cow; diff --git a/components/profile/Cargo.toml b/components/profile/Cargo.toml index d9b3a14aecb..6008c31b10f 100644 --- a/components/profile/Cargo.toml +++ b/components/profile/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["rename-dependency"] + [package] name = "profile" version = "0.0.1" @@ -11,7 +13,7 @@ name = "profile" path = "lib.rs" [features] -unstable = ["jemalloc-sys"] +unstable = ["servo_allocator"] [dependencies] profile_traits = {path = "../profile_traits"} @@ -22,7 +24,7 @@ log = "0.4" serde = "1.0" serde_json = "1.0" servo_config = {path = "../config"} -time = "0.1.12" +time_crate = {package = "time", version = "0.1.12"} tokio = "0.1" [target.'cfg(target_os = "macos")'.dependencies] @@ -33,4 +35,4 @@ regex = "1.0" [target.'cfg(not(target_os = "windows"))'.dependencies] libc = "0.2" -jemalloc-sys = {version = "0.1.3", optional = true} +servo_allocator = {path = "../allocator", optional = true} diff --git a/components/profile/lib.rs b/components/profile/lib.rs index 248fd0ab19b..b9c6085be46 100644 --- a/components/profile/lib.rs +++ b/components/profile/lib.rs @@ -4,28 +4,12 @@ #![deny(unsafe_code)] -#[allow(unused_extern_crates)] -extern crate heartbeats_simple; -extern crate influent; -extern crate ipc_channel; -#[cfg(all(feature = "unstable", not(target_os = "windows")))] -extern crate jemalloc_sys; -#[cfg(not(target_os = "windows"))] -extern crate libc; #[macro_use] extern crate log; #[macro_use] extern crate profile_traits; -#[cfg(target_os = "linux")] -extern crate regex; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_config; -#[cfg(target_os = "macos")] -extern crate task_info; -extern crate time as std_time; -extern crate tokio; #[allow(unsafe_code)] mod heartbeats; diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 8e6a86c59cd..7c60ba07b67 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -496,7 +496,7 @@ mod system_reporter { } #[cfg(all(feature = "unstable", not(target_os = "windows")))] - use jemalloc_sys::mallctl; + use servo_allocator::jemalloc_sys::mallctl; #[cfg(all(feature = "unstable", not(target_os = "windows")))] fn jemalloc_stat(value_name: &str) -> Option<usize> { diff --git a/components/profile/time.rs b/components/profile/time.rs index 7cfdbcee14d..cd78fee4ed6 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -5,7 +5,6 @@ //! Timing functions. use crate::heartbeats; -use crate::std_time::precise_time_ns; use crate::trace_dump::TraceDump; use influent::client::{Client, Credentials}; use influent::create_client; @@ -26,6 +25,7 @@ use std::io::{self, Write}; use std::path::Path; use std::time::Duration; use std::{f64, thread, u32, u64}; +use time_crate::precise_time_ns; use tokio; use tokio::prelude::Future; diff --git a/components/profile_traits/lib.rs b/components/profile_traits/lib.rs index 017d35b24c1..cf7034d5962 100644 --- a/components/profile_traits/lib.rs +++ b/components/profile_traits/lib.rs @@ -8,15 +8,10 @@ #![deny(unsafe_code)] -extern crate bincode; -extern crate ipc_channel; #[macro_use] extern crate log; #[macro_use] extern crate serde; -extern crate servo_channel; -extern crate servo_config; -extern crate signpost; #[allow(unsafe_code)] pub mod energy; diff --git a/components/profile_traits/time.rs b/components/profile_traits/time.rs index 010bb009682..fe819a6cee8 100644 --- a/components/profile_traits/time.rs +++ b/components/profile_traits/time.rs @@ -2,13 +2,11 @@ * 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/. */ -extern crate time as std_time; - -use self::std_time::precise_time_ns; use crate::energy::read_energy_uj; use ipc_channel::ipc::IpcSender; use servo_config::opts; use signpost; +use time::precise_time_ns; #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] pub struct TimerMetadata { diff --git a/components/rand/lib.rs b/components/rand/lib.rs index 56c20522b76..54c0de6d501 100644 --- a/components/rand/lib.rs +++ b/components/rand/lib.rs @@ -16,8 +16,6 @@ extern crate lazy_static; #[macro_use] extern crate log; -extern crate rand; -extern crate uuid; #[cfg(target_pointer_width = "64")] use rand::isaac::Isaac64Rng as IsaacWordRng; diff --git a/components/range/lib.rs b/components/range/lib.rs index 9d65a229717..797ba4b9b83 100644 --- a/components/range/lib.rs +++ b/components/range/lib.rs @@ -4,10 +4,8 @@ #![deny(unsafe_code)] -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate num_traits; #[macro_use] extern crate serde; diff --git a/components/remutex/tests/smoke.rs b/components/remutex/tests/smoke.rs index 743bdfec167..5c095ea703f 100644 --- a/components/remutex/tests/smoke.rs +++ b/components/remutex/tests/smoke.rs @@ -10,8 +10,6 @@ // These tests came from https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs -extern crate servo_remutex; - use servo_remutex::{ReentrantMutex, ReentrantMutexGuard}; use std::cell::RefCell; use std::sync::Arc; diff --git a/components/script/build.rs b/components/script/build.rs index 0abb25ef24a..83b96495e16 100644 --- a/components/script/build.rs +++ b/components/script/build.rs @@ -2,12 +2,10 @@ * 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/. */ -extern crate cmake; -extern crate phf_codegen; -extern crate phf_shared; -extern crate serde_json; - -use serde_json::Value; +use cmake; +use phf_codegen; +use phf_shared; +use serde_json::{self, Value}; use std::env; use std::fmt; use std::fs::File; diff --git a/components/script/dom/abstractworkerglobalscope.rs b/components/script/dom/abstractworkerglobalscope.rs index ab919bd87c4..e01b98cf944 100644 --- a/components/script/dom/abstractworkerglobalscope.rs +++ b/components/script/dom/abstractworkerglobalscope.rs @@ -32,7 +32,7 @@ impl ScriptChan for SendableWorkerScriptChan { self.sender.send(msg).map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(SendableWorkerScriptChan { sender: self.sender.clone(), worker: self.worker.clone(), @@ -58,7 +58,7 @@ impl ScriptChan for WorkerThreadWorkerChan { self.sender.send(msg).map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(WorkerThreadWorkerChan { sender: self.sender.clone(), worker: self.worker.clone(), diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 25b77e052e6..5318eb11e4d 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -78,14 +78,14 @@ where pub unsafe trait StableTraceObject { /// Returns a stable trace object which address won't change for the whole /// lifetime of the value. - fn stable_trace_object(&self) -> *const JSTraceable; + fn stable_trace_object(&self) -> *const dyn JSTraceable; } unsafe impl<T> StableTraceObject for Dom<T> where T: DomObject, { - fn stable_trace_object<'a>(&'a self) -> *const JSTraceable { + fn stable_trace_object<'a>(&'a self) -> *const dyn JSTraceable { // The JSTraceable impl for Reflector doesn't actually do anything, // so we need this shenanigan to actually trace the reflector of the // T pointer in Dom<T>. @@ -198,7 +198,7 @@ where /// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*] /// (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting). pub struct RootCollection { - roots: UnsafeCell<Vec<*const JSTraceable>>, + roots: UnsafeCell<Vec<*const dyn JSTraceable>>, } thread_local!(static STACK_ROOTS: Cell<Option<*const RootCollection>> = Cell::new(None)); @@ -228,13 +228,13 @@ impl RootCollection { } /// Starts tracking a trace object. - unsafe fn root(&self, object: *const JSTraceable) { + unsafe fn root(&self, object: *const dyn JSTraceable) { debug_assert!(thread_state::get().is_script()); (*self.roots.get()).push(object); } /// Stops tracking a trace object, asserting if it isn't found. - unsafe fn unroot(&self, object: *const JSTraceable) { + unsafe fn unroot(&self, object: *const dyn JSTraceable) { debug_assert!(thread_state::get().is_script()); let roots = &mut *self.roots.get(); match roots.iter().rposition(|r| *r == object) { diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index d45bbdef121..d8d3000d037 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -375,7 +375,7 @@ unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64); unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64); unsafe_no_jsmanaged_fields!(Error); unsafe_no_jsmanaged_fields!(ServoUrl, ImmutableOrigin, MutableOrigin); -unsafe_no_jsmanaged_fields!(Image, ImageMetadata, ImageCache, PendingImageId); +unsafe_no_jsmanaged_fields!(Image, ImageMetadata, dyn ImageCache, PendingImageId); unsafe_no_jsmanaged_fields!(Metadata); unsafe_no_jsmanaged_fields!(NetworkError); unsafe_no_jsmanaged_fields!(Atom, Prefix, LocalName, Namespace, QualName); @@ -461,7 +461,7 @@ unsafe_no_jsmanaged_fields!(AudioBuffer); unsafe_no_jsmanaged_fields!(AudioContext<Backend>); unsafe_no_jsmanaged_fields!(NodeId); unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType); -unsafe_no_jsmanaged_fields!(Player<Error = ServoMediaError>); +unsafe_no_jsmanaged_fields!(dyn Player<Error = ServoMediaError>); unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>); unsafe_no_jsmanaged_fields!(RenderApiSender); @@ -497,7 +497,7 @@ where } // Safe thanks to the Send bound. -unsafe impl JSTraceable for Box<LayoutRPC + Send + 'static> { +unsafe impl JSTraceable for Box<dyn LayoutRPC + Send + 'static> { #[inline] unsafe fn trace(&self, _: *mut JSTracer) { // Do nothing @@ -733,7 +733,7 @@ where /// Holds a set of JSTraceables that need to be rooted struct RootedTraceableSet { - set: Vec<*const JSTraceable>, + set: Vec<*const dyn JSTraceable>, } thread_local!(/// TLV Holds a set of JSTraceables that need to be rooted @@ -744,7 +744,7 @@ impl RootedTraceableSet { RootedTraceableSet { set: vec![] } } - unsafe fn remove(traceable: *const JSTraceable) { + unsafe fn remove(traceable: *const dyn JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { let mut traceables = traceables.borrow_mut(); let idx = match traceables.set.iter().rposition(|x| *x == traceable) { @@ -755,7 +755,7 @@ impl RootedTraceableSet { }); } - unsafe fn add(traceable: *const JSTraceable) { + unsafe fn add(traceable: *const dyn JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { traceables.borrow_mut().set.push(traceable); }) diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs index 6e46d0268df..2a9e176af6e 100644 --- a/components/script/dom/bindings/weakref.rs +++ b/components/script/dom/bindings/weakref.rs @@ -269,7 +269,7 @@ impl<T: WeakReferenceable> DerefMut for WeakRefVec<T> { /// An entry of a vector of weak references. Passed to the closure /// given to `WeakRefVec::update`. #[allow_unrooted_interior] -pub struct WeakRefEntry<'a, T: WeakReferenceable + 'a> { +pub struct WeakRefEntry<'a, T: WeakReferenceable> { vec: &'a mut WeakRefVec<T>, index: &'a mut usize, } diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 1bf2a09b50f..6dbd1a860c5 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -126,7 +126,7 @@ impl CanvasRenderingContext2D { pub fn new_inherited( global: &GlobalScope, canvas: Option<&HTMLCanvasElement>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, base_url: ServoUrl, size: Size2D<u32>, ) -> CanvasRenderingContext2D { diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs index 51dc17d3343..65ff5393a89 100644 --- a/components/script/dom/cssrule.rs +++ b/components/script/dom/cssrule.rs @@ -44,25 +44,25 @@ impl CSSRule { } } - pub fn as_specific(&self) -> &SpecificCSSRule { + pub fn as_specific(&self) -> &dyn SpecificCSSRule { if let Some(rule) = self.downcast::<CSSStyleRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSFontFaceRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSKeyframesRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSMediaRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSNamespaceRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSViewportRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSKeyframeRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSImportRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSSupportsRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else { unreachable!() } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index afe0908c543..f9a3debe9b4 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -203,7 +203,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, timer_event_chan: IpcSender<TimerEvent>, @@ -233,7 +233,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, timer_event_chan: IpcSender<TimerEvent>, @@ -263,7 +263,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>, worker: TrustedWorkerAddress, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, worker_load_origin: WorkerScriptLoadOrigin, @@ -396,14 +396,14 @@ impl DedicatedWorkerGlobalScope { .expect("Thread spawning failed"); } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { Box::new(WorkerThreadWorkerChan { sender: self.own_sender.clone(), worker: self.worker.borrow().as_ref().unwrap().clone(), }) } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let (tx, rx) = channel(); let chan = Box::new(SendableWorkerScriptChan { sender: tx, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 330a1194d90..4807f892607 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2,7 +2,7 @@ * 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 crate::cookie_rs; +use cookie::Cookie; use crate::document_loader::{DocumentLoader, LoadType}; use crate::dom::activation::{synthetic_click_activation, ActivationSource}; use crate::dom::attr::Attr; @@ -3965,12 +3965,11 @@ impl DocumentMethods for Document { return Err(Error::Security); } - let cookies = - if let Some(cookie) = cookie_rs::Cookie::parse(cookie.to_string()).ok().map(Serde) { - vec![cookie] - } else { - vec![] - }; + let cookies = if let Some(cookie) = Cookie::parse(cookie.to_string()).ok().map(Serde) { + vec![cookie] + } else { + vec![] + }; let _ = self .window diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 8f65f49b7df..38e5b1ae3c0 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -2579,8 +2579,8 @@ impl ElementMethods for Element { } impl VirtualMethods for Element { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Node>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Node>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { @@ -2941,31 +2941,31 @@ impl<'a> SelectorsElement for DomRoot<Element> { } impl Element { - pub fn as_maybe_activatable(&self) -> Option<&Activatable> { + pub fn as_maybe_activatable(&self) -> Option<&dyn Activatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, )) => { let element = self.downcast::<HTMLInputElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, )) => { let element = self.downcast::<HTMLButtonElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLAnchorElement, )) => { let element = self.downcast::<HTMLAnchorElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLabelElement, )) => { let element = self.downcast::<HTMLLabelElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, _ => None, }; @@ -2978,50 +2978,50 @@ impl Element { }) } - pub fn as_stylesheet_owner(&self) -> Option<&StylesheetOwner> { + pub fn as_stylesheet_owner(&self) -> Option<&dyn StylesheetOwner> { if let Some(s) = self.downcast::<HTMLStyleElement>() { - return Some(s as &StylesheetOwner); + return Some(s as &dyn StylesheetOwner); } if let Some(l) = self.downcast::<HTMLLinkElement>() { - return Some(l as &StylesheetOwner); + return Some(l as &dyn StylesheetOwner); } None } // https://html.spec.whatwg.org/multipage/#category-submit - pub fn as_maybe_validatable(&self) -> Option<&Validatable> { + pub fn as_maybe_validatable(&self) -> Option<&dyn Validatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, )) => { let element = self.downcast::<HTMLInputElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, )) => { let element = self.downcast::<HTMLButtonElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLObjectElement, )) => { let element = self.downcast::<HTMLObjectElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLSelectElement, )) => { let element = self.downcast::<HTMLSelectElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTextAreaElement, )) => { let element = self.downcast::<HTMLTextAreaElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, _ => None, }; diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 3c1a1dd3381..a9cdbb07ea9 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -733,7 +733,7 @@ impl EventTargetMethods for EventTarget { } impl VirtualMethods for EventTarget { - fn super_type(&self) -> Option<&VirtualMethods> { + fn super_type(&self) -> Option<&dyn VirtualMethods> { None } } diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 96d4131f581..4b999d24ec0 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -463,7 +463,7 @@ impl GlobalScope { } /// `ScriptChan` to send messages to the event loop of this global scope. - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { if let Some(window) = self.downcast::<Window>() { return MainThreadScriptChan(window.main_thread_script_chan().clone()).clone(); } @@ -663,7 +663,7 @@ impl GlobalScope { /// Create a new sender/receiver pair that can be used to implement an on-demand /// event loop. Used for implementing web APIs that require blocking semantics /// without resorting to nested event loops. - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { if let Some(window) = self.downcast::<Window>() { return window.new_script_pair(); } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 73f16a8340a..efa96da7e0e 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -98,8 +98,8 @@ impl HTMLAnchorElement { } impl VirtualMethods for HTMLAnchorElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 1a167bd3b94..45532529808 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -285,8 +285,8 @@ impl HTMLAreaElement { } impl VirtualMethods for HTMLAreaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 33ba9886b48..1fe171d5182 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -108,8 +108,8 @@ impl HTMLBaseElementMethods for HTMLBaseElement { } impl VirtualMethods for HTMLBaseElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index b3bf5e6a76e..fa368f11c12 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -135,8 +135,8 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> { } impl VirtualMethods for HTMLBodyElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index b954c4a7d34..2b58aaea7a0 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -189,8 +189,8 @@ impl HTMLButtonElement { } impl VirtualMethods for HTMLButtonElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 0661f5717f0..2e86193c184 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -407,8 +407,8 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { } impl VirtualMethods for HTMLCanvasElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 99d3c4775b8..cc2256a6764 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -69,7 +69,10 @@ pub struct HTMLCollection { impl HTMLCollection { #[allow(unrooted_must_root)] - pub fn new_inherited(root: &Node, filter: Box<CollectionFilter + 'static>) -> HTMLCollection { + pub fn new_inherited( + root: &Node, + filter: Box<dyn CollectionFilter + 'static>, + ) -> HTMLCollection { HTMLCollection { reflector_: Reflector::new(), root: Dom::from_ref(root), @@ -99,7 +102,7 @@ impl HTMLCollection { pub fn new( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLCollection> { reflect_dom_object( Box::new(HTMLCollection::new_inherited(root, filter)), @@ -111,7 +114,7 @@ impl HTMLCollection { pub fn create( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLCollection> { HTMLCollection::new(window, root, filter) } diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 80d4c1caa98..3f7021dc786 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -62,8 +62,8 @@ impl HTMLDetailsElementMethods for HTMLDetailsElement { } impl VirtualMethods for HTMLDetailsElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index c3702a0357a..93b8e099510 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -718,8 +718,8 @@ impl HTMLElement { } impl VirtualMethods for HTMLElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Element>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Element>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 2026e7bd5e0..614bed522cd 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -95,8 +95,8 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement { } impl VirtualMethods for HTMLFieldSetElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 0794e4ca432..bf65d411be5 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -74,8 +74,8 @@ impl HTMLFontElementMethods for HTMLFontElement { } impl VirtualMethods for HTMLFontElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs index 57261fe26aa..b3a0ef2cede 100644 --- a/components/script/dom/htmlformcontrolscollection.rs +++ b/components/script/dom/htmlformcontrolscollection.rs @@ -25,7 +25,7 @@ pub struct HTMLFormControlsCollection { impl HTMLFormControlsCollection { fn new_inherited( root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> HTMLFormControlsCollection { HTMLFormControlsCollection { collection: HTMLCollection::new_inherited(root, filter), @@ -35,7 +35,7 @@ impl HTMLFormControlsCollection { pub fn new( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLFormControlsCollection> { reflect_dom_object( Box::new(HTMLFormControlsCollection::new_inherited(root, filter)), diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index ba322aa20e9..fc9e4832fe5 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1137,8 +1137,8 @@ pub trait FormControl: DomObject { } impl VirtualMethods for HTMLFormElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { @@ -1175,44 +1175,44 @@ impl VirtualMethods for HTMLFormElement { } pub trait FormControlElementHelpers { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a FormControl>; + fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl>; } impl FormControlElementHelpers for Element { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a FormControl> { + fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl> { let node = self.upcast::<Node>(); match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, - )) => Some(self.downcast::<HTMLButtonElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLButtonElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLFieldSetElement, - )) => Some(self.downcast::<HTMLFieldSetElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLFieldSetElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLImageElement, - )) => Some(self.downcast::<HTMLImageElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLImageElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, - )) => Some(self.downcast::<HTMLInputElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLInputElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLabelElement, - )) => Some(self.downcast::<HTMLLabelElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLLabelElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLegendElement, - )) => Some(self.downcast::<HTMLLegendElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLLegendElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLObjectElement, - )) => Some(self.downcast::<HTMLObjectElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLObjectElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLOutputElement, - )) => Some(self.downcast::<HTMLOutputElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLOutputElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLSelectElement, - )) => Some(self.downcast::<HTMLSelectElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLSelectElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTextAreaElement, - )) => Some(self.downcast::<HTMLTextAreaElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLTextAreaElement>().unwrap() as &dyn FormControl), _ => None, } } diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index c3aa6812062..89834cde5fc 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -78,8 +78,8 @@ impl HTMLHeadElement { } impl VirtualMethods for HTMLHeadElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { if let Some(ref s) = self.super_type() { diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 1abb3727a8b..01b4e4f526c 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -95,8 +95,8 @@ impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> { } impl VirtualMethods for HTMLHRElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 83499448cdc..9cae4e83e7a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -547,8 +547,8 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { } impl VirtualMethods for HTMLIFrameElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 05d1d2804e1..851f9971455 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -157,7 +157,7 @@ impl HTMLImageElement { /// The context required for asynchronously loading an external image. struct ImageContext { /// Reference to the script thread image cache. - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, /// Indicates whether the request failed, and why status: Result<(), NetworkError>, /// The cache ID for this request. @@ -229,7 +229,7 @@ impl HTMLImageElement { /// Update the current image with a valid URL. fn fetch_image(&self, img_url: &ServoUrl) { fn add_cache_listener_for_element( - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, id: PendingImageId, elem: &HTMLImageElement, ) { @@ -979,7 +979,7 @@ impl HTMLImageElement { fn react_to_environment_changes_sync_steps(&self, generation: u32) { // TODO reduce duplicacy of this code fn add_cache_listener_for_element( - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, id: PendingImageId, elem: &HTMLImageElement, selected_source: String, @@ -1576,8 +1576,8 @@ impl HTMLImageElementMethods for HTMLImageElement { } impl VirtualMethods for HTMLImageElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn adopting_steps(&self, old_doc: &Document) { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index e0f50575a44..051acf352a2 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -1206,8 +1206,8 @@ impl HTMLInputElement { } impl VirtualMethods for HTMLInputElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index badc60b5243..7b7129c00ae 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -134,8 +134,8 @@ impl HTMLLabelElementMethods for HTMLLabelElement { } impl VirtualMethods for HTMLLabelElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index 562c4675a58..345f1a62c55 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -52,8 +52,8 @@ impl HTMLLegendElement { } impl VirtualMethods for HTMLLegendElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index b1b913e86e9..cce6ae1f49e 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -54,8 +54,8 @@ impl HTMLLIElementMethods for HTMLLIElement { } impl VirtualMethods for HTMLLIElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 74d8e301cff..1efa6924fb8 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -177,8 +177,8 @@ fn is_favicon(value: &Option<String>) -> bool { } impl VirtualMethods for HTMLLinkElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 5182ac1f02d..b178b4b5801 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -1351,8 +1351,8 @@ impl HTMLMediaElementMethods for HTMLMediaElement { } impl VirtualMethods for HTMLMediaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 7e975c440c9..f6e14f032a3 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -171,8 +171,8 @@ impl HTMLMetaElementMethods for HTMLMetaElement { } impl VirtualMethods for HTMLMetaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 896c5eb90d1..66076cf5d04 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -114,8 +114,8 @@ impl Validatable for HTMLObjectElement { } impl VirtualMethods for HTMLObjectElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index 9c6b9e9695f..3a8c6b4fe48 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -63,8 +63,8 @@ impl HTMLOptGroupElementMethods for HTMLOptGroupElement { } impl VirtualMethods for HTMLOptGroupElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index a2d9e3609dd..7c17ffe7aa0 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -194,8 +194,8 @@ impl HTMLOptionElementMethods for HTMLOptionElement { } impl VirtualMethods for HTMLOptionElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 9ad4e7363d0..5c713fe3543 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -32,7 +32,7 @@ pub struct HTMLOptionsCollection { impl HTMLOptionsCollection { fn new_inherited( select: &HTMLSelectElement, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> HTMLOptionsCollection { HTMLOptionsCollection { collection: HTMLCollection::new_inherited(select.upcast(), filter), @@ -42,7 +42,7 @@ impl HTMLOptionsCollection { pub fn new( window: &Window, select: &HTMLSelectElement, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLOptionsCollection> { reflect_dom_object( Box::new(HTMLOptionsCollection::new_inherited(select, filter)), diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 1ca4cabba25..54ea702608c 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -71,8 +71,8 @@ impl HTMLOutputElementMethods for HTMLOutputElement { } impl VirtualMethods for HTMLOutputElement { - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type<'b>(&'b self) -> Option<&'b dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 1cc66221848..47a4950b3d6 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -708,8 +708,8 @@ impl HTMLScriptElement { } impl VirtualMethods for HTMLScriptElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index aa8abc4feb2..c91b483e2d8 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -354,8 +354,8 @@ impl HTMLSelectElementMethods for HTMLSelectElement { } impl VirtualMethods for HTMLSelectElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index 4cdbba9f620..3defc6b235f 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -63,8 +63,8 @@ impl HTMLSourceElement { } impl VirtualMethods for HTMLSourceElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index ede2cb743a8..364640fa169 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -169,8 +169,8 @@ impl HTMLStyleElement { } impl VirtualMethods for HTMLStyleElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index ddf668bb4d4..f9ef8724b71 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -145,8 +145,8 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> { } impl VirtualMethods for HTMLTableCellElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index d921855ae66..5283d6a9361 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -447,8 +447,8 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> { } impl VirtualMethods for HTMLTableElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 5255fdc0b0c..044e52f2389 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -165,8 +165,8 @@ impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> { } impl VirtualMethods for HTMLTableRowElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index f1422589c27..f12ed26ffc8 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -102,8 +102,8 @@ impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> } impl VirtualMethods for HTMLTableSectionElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index a080373af2c..7689e1efdc1 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -64,8 +64,8 @@ impl HTMLTemplateElementMethods for HTMLTemplateElement { } impl VirtualMethods for HTMLTemplateElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } /// <https://html.spec.whatwg.org/multipage/#template-adopting-steps> diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 05023ab683b..89ffff3e030 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -386,8 +386,8 @@ impl HTMLTextAreaElement { } impl VirtualMethods for HTMLTextAreaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index da4414d9a91..9fdd1663ed6 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -60,8 +60,8 @@ impl HTMLTitleElementMethods for HTMLTitleElement { } impl VirtualMethods for HTMLTitleElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 2c637f78a98..6854dd9d9cf 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -2616,8 +2616,8 @@ pub fn window_from_node<T: DerivedFrom<Node> + DomObject>(derived: &T) -> DomRoo } impl VirtualMethods for Node { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<EventTarget>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<EventTarget>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 91ceedaa576..6a9a517298f 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -131,7 +131,7 @@ impl PaintWorkletGlobalScope { unsafe { PaintWorkletGlobalScopeBinding::Wrap(runtime.cx(), global) } } - pub fn image_cache(&self) -> Arc<ImageCache> { + pub fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } @@ -396,7 +396,7 @@ impl PaintWorkletGlobalScope { } } - fn painter(&self, name: Atom) -> Box<Painter> { + fn painter(&self, name: Atom) -> Box<dyn Painter> { // Rather annoyingly we have to use a mutex here to make the painter Sync. struct WorkletPainter { name: Atom, diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 8358de2f49e..f9c2dba5f66 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -26,8 +26,8 @@ pub struct PromiseNativeHandler { impl PromiseNativeHandler { pub fn new( global: &GlobalScope, - resolve: Option<Box<Callback>>, - reject: Option<Box<Callback>>, + resolve: Option<Box<dyn Callback>>, + reject: Option<Box<dyn Callback>>, ) -> DomRoot<PromiseNativeHandler> { reflect_dom_object( Box::new(PromiseNativeHandler { @@ -40,7 +40,7 @@ impl PromiseNativeHandler { ) } - fn callback(callback: &Option<Box<Callback>>, cx: *mut JSContext, v: HandleValue) { + fn callback(callback: &Option<Box<dyn Callback>>, cx: *mut JSContext, v: HandleValue) { if let Some(ref callback) = *callback { callback.callback(cx, v) } diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index 06f11adaad8..c6f87f6e144 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -116,7 +116,7 @@ impl ScriptChan for ServiceWorkerChan { .map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(ServiceWorkerChan { sender: self.sender.clone(), }) @@ -412,7 +412,7 @@ impl ServiceWorkerGlobalScope { } } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { Box::new(ServiceWorkerChan { sender: self.own_sender.clone(), }) diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs index 39dbbf3b161..df138778166 100644 --- a/components/script/dom/svgelement.rs +++ b/components/script/dom/svgelement.rs @@ -29,7 +29,7 @@ impl SVGElement { } impl VirtualMethods for SVGElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Element>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Element>() as &dyn VirtualMethods) } } diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs index 713efced553..b0a6590027b 100644 --- a/components/script/dom/svggraphicselement.rs +++ b/components/script/dom/svggraphicselement.rs @@ -42,7 +42,7 @@ impl SVGGraphicsElement { } impl VirtualMethods for SVGGraphicsElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<SVGElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) } } diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 60c90544aca..6ea48c344e6 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -75,8 +75,8 @@ impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> { } impl VirtualMethods for SVGSVGElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<SVGGraphicsElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<SVGGraphicsElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index e0f9af46b3b..b8baddb46ae 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -1028,7 +1028,7 @@ impl TestBindingMethods for TestBinding { handler: Rc<SimpleCallback>, } impl SimpleHandler { - fn new(callback: Rc<SimpleCallback>) -> Box<Callback> { + fn new(callback: Rc<SimpleCallback>) -> Box<dyn Callback> { Box::new(SimpleHandler { handler: callback }) } } diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 3e28f02587d..7e0f5ce28c9 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -59,7 +59,7 @@ use style::attr::AttrValue; pub trait VirtualMethods { /// Returns self as the superclass of the implementation for this trait, /// if any. - fn super_type(&self) -> Option<&VirtualMethods>; + fn super_type(&self) -> Option<&dyn VirtualMethods>; /// Called when attributes of a node are mutated. /// <https://dom.spec.whatwg.org/#attribute-is-set> @@ -152,120 +152,120 @@ pub trait VirtualMethods { /// method call on the trait object will invoke the corresponding method on the /// concrete type, propagating up the parent hierarchy unless otherwise /// interrupted. -pub fn vtable_for(node: &Node) -> &VirtualMethods { +pub fn vtable_for(node: &Node) -> &dyn VirtualMethods { match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { - node.downcast::<HTMLAnchorElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLAnchorElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => { - node.downcast::<HTMLAreaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLAreaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBaseElement)) => { - node.downcast::<HTMLBaseElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLBaseElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => { - node.downcast::<HTMLBodyElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLBodyElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) => { - node.downcast::<HTMLButtonElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLButtonElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)) => { - node.downcast::<HTMLCanvasElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLCanvasElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDetailsElement)) => { - node.downcast::<HTMLDetailsElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLDetailsElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => { - node.downcast::<HTMLFieldSetElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFieldSetElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFontElement)) => { - node.downcast::<HTMLFontElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFontElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFormElement)) => { - node.downcast::<HTMLFormElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFormElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHeadElement)) => { - node.downcast::<HTMLHeadElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLHeadElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHRElement)) => { - node.downcast::<HTMLHRElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLHRElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLImageElement)) => { - node.downcast::<HTMLImageElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLImageElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) => { - node.downcast::<HTMLIFrameElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLIFrameElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => { - node.downcast::<HTMLInputElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLInputElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLabelElement)) => { - node.downcast::<HTMLLabelElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLabelElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLIElement)) => { - node.downcast::<HTMLLIElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLIElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { - node.downcast::<HTMLLinkElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLinkElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMediaElement(_))) => { - node.downcast::<HTMLMediaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLMediaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaElement)) => { - node.downcast::<HTMLMetaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLMetaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)) => { - node.downcast::<HTMLObjectElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLObjectElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptGroupElement)) => { - node.downcast::<HTMLOptGroupElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOptGroupElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => { - node.downcast::<HTMLOptionElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOptionElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOutputElement)) => { - node.downcast::<HTMLOutputElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOutputElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => { - node.downcast::<HTMLScriptElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLScriptElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => { - node.downcast::<HTMLSelectElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLSelectElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSourceElement)) => { - node.downcast::<HTMLSourceElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLSourceElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement)) => { - node.downcast::<HTMLStyleElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLStyleElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableElement)) => { - node.downcast::<HTMLTableElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTableElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTableCellElement, - )) => node.downcast::<HTMLTableCellElement>().unwrap() as &VirtualMethods, + )) => node.downcast::<HTMLTableCellElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => { - node.downcast::<HTMLTableRowElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTableRowElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTableSectionElement, - )) => node.downcast::<HTMLTableSectionElement>().unwrap() as &VirtualMethods, + )) => node.downcast::<HTMLTableSectionElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTemplateElement)) => { - node.downcast::<HTMLTemplateElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTemplateElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => { - node.downcast::<HTMLTextAreaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTextAreaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTitleElement)) => { - node.downcast::<HTMLTitleElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTitleElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement( SVGGraphicsElementTypeId::SVGSVGElement, - ))) => node.downcast::<SVGSVGElement>().unwrap() as &VirtualMethods, + ))) => node.downcast::<SVGSVGElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::Element) => { - node.downcast::<Element>().unwrap() as &VirtualMethods + node.downcast::<Element>().unwrap() as &dyn VirtualMethods }, - NodeTypeId::Element(_) => node.downcast::<HTMLElement>().unwrap() as &VirtualMethods, - _ => node as &VirtualMethods, + NodeTypeId::Element(_) => node.downcast::<HTMLElement>().unwrap() as &dyn VirtualMethods, + _ => node as &dyn VirtualMethods, } } diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index 76c995068dc..8b91e0cbd07 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -139,7 +139,7 @@ impl WebGLExtensionFeatures { #[must_root] #[derive(JSTraceable, MallocSizeOf)] pub struct WebGLExtensions { - extensions: DomRefCell<HashMap<String, Box<WebGLExtensionWrapper>>>, + extensions: DomRefCell<HashMap<String, Box<dyn WebGLExtensionWrapper>>>, features: DomRefCell<WebGLExtensionFeatures>, webgl_version: WebGLVersion, } diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index 9918952dc73..11c9bac3d7e 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -25,7 +25,7 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { fn is_enabled(&self) -> bool; fn enable(&self, ext: &WebGLExtensions); fn name(&self) -> &'static str; - fn as_any(&self) -> &Any; + fn as_any(&self) -> &dyn Any; } #[must_root] @@ -85,7 +85,7 @@ where T::name() } - fn as_any<'a>(&'a self) -> &'a Any { + fn as_any<'a>(&'a self) -> &'a dyn Any { self } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index c9ec7317a3c..9723395d0fa 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -384,7 +384,7 @@ impl Window { self.networking_task_source.clone() } - pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> { + pub fn history_traversal_task_source(&self) -> Box<dyn ScriptChan + Send> { self.history_traversal_task_source.clone() } @@ -412,12 +412,12 @@ impl Window { self.parent_info } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let (tx, rx) = channel(); (Box::new(SendableMainThreadScriptChan(tx)), Box::new(rx)) } - pub fn image_cache(&self) -> Arc<ImageCache> { + pub fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } @@ -446,7 +446,7 @@ impl Window { &self.bluetooth_extra_permission_data } - pub fn css_error_reporter(&self) -> Option<&ParseErrorReporter> { + pub fn css_error_reporter(&self) -> Option<&dyn ParseErrorReporter> { Some(&self.error_reporter) } @@ -1641,7 +1641,7 @@ impl Window { ) } - pub fn layout(&self) -> &LayoutRPC { + pub fn layout(&self) -> &dyn LayoutRPC { &*self.layout_rpc } @@ -2089,7 +2089,7 @@ impl Window { remote_event_task_source: RemoteEventTaskSource, websocket_task_source: WebsocketTaskSource, image_cache_chan: Sender<ImageCacheMsg>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, resource_threads: ResourceThreads, bluetooth_thread: IpcSender<BluetoothRequest>, mem_profiler_chan: MemProfilerChan, @@ -2112,7 +2112,7 @@ impl Window { webrender_document: DocumentId, webrender_api_sender: RenderApiSender, ) -> DomRoot<Self> { - let layout_rpc: Box<LayoutRPC + Send> = { + let layout_rpc: Box<dyn LayoutRPC + Send> = { let (rpc_send, rpc_recv) = channel(); layout_chan.send(Msg::GetRPC(rpc_send)).unwrap(); rpc_recv.recv().unwrap() diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index a9b1fc4aca4..015c18f2644 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -408,7 +408,7 @@ impl WorkerGlobalScope { } } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); let service_worker = self.downcast::<ServiceWorkerGlobalScope>(); if let Some(dedicated) = dedicated { @@ -444,7 +444,7 @@ impl WorkerGlobalScope { WebsocketTaskSource(self.script_chan(), self.pipeline_id()) } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); if let Some(dedicated) = dedicated { return dedicated.new_script_pair(); diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index 9e672723c54..3d971390614 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -93,7 +93,12 @@ impl WorkletGlobalScope { } /// Register a paint worklet to the script thread. - pub fn register_paint_worklet(&self, name: Atom, properties: Vec<Atom>, painter: Box<Painter>) { + pub fn register_paint_worklet( + &self, + name: Atom, + properties: Vec<Atom>, + painter: Box<dyn Painter>, + ) { self.to_script_thread_sender .send(MainThreadScriptMsg::RegisterPaintWorklet { pipeline_id: self.globalscope.pipeline_id(), @@ -147,7 +152,7 @@ pub struct WorkletGlobalScopeInit { /// Message to send to the scheduler pub scheduler_chan: IpcSender<TimerSchedulerMsg>, /// The image cache - pub image_cache: Arc<ImageCache>, + pub image_cache: Arc<dyn ImageCache>, } /// <https://drafts.css-houdini.org/worklets/#worklet-global-scope-type> diff --git a/components/script/layout_image.rs b/components/script/layout_image.rs index 99240074eaa..68a3e788cf4 100644 --- a/components/script/layout_image.rs +++ b/components/script/layout_image.rs @@ -21,7 +21,7 @@ use std::sync::{Arc, Mutex}; struct LayoutImageContext { id: PendingImageId, - cache: Arc<ImageCache>, + cache: Arc<dyn ImageCache>, } impl FetchResponseListener for LayoutImageContext { @@ -49,7 +49,7 @@ pub fn fetch_image_for_layout( url: ServoUrl, node: &Node, id: PendingImageId, - cache: Arc<ImageCache>, + cache: Arc<dyn ImageCache>, ) { let context = Arc::new(Mutex::new(LayoutImageContext { id: id, diff --git a/components/script/lib.rs b/components/script/lib.rs index 1eb70033d32..1e4579597a6 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -17,105 +17,38 @@ allow(unknown_lints) )] -extern crate app_units; -#[cfg(any(feature = "webgl_backtrace", feature = "js_backtrace"))] -extern crate backtrace; -extern crate base64; #[macro_use] extern crate bitflags; -extern crate bluetooth_traits; -extern crate byteorder; -extern crate canvas_traits; -extern crate caseless; -extern crate chrono; -extern crate cookie as cookie_rs; #[macro_use] extern crate cssparser; #[macro_use] extern crate deny_public_fields; -extern crate devtools_traits; -extern crate dom_struct; #[macro_use] extern crate domobject_derive; -extern crate embedder_traits; -extern crate encoding_rs; #[macro_use] extern crate enum_iterator; -extern crate euclid; -extern crate fnv; -extern crate gleam; -extern crate half; -extern crate headers_core; -extern crate headers_ext; #[macro_use] extern crate html5ever; -extern crate http; -extern crate hyper; -extern crate hyper_serde; -extern crate image; -extern crate ipc_channel; #[macro_use] extern crate js; #[macro_use] extern crate jstraceable_derive; -extern crate keyboard_types; #[macro_use] extern crate lazy_static; -extern crate libc; #[macro_use] extern crate log; #[macro_use] extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate metrics; -extern crate mime; -extern crate mime_guess; -extern crate mitochondria; -extern crate mozangle; -extern crate msg; -extern crate net_traits; -extern crate num_traits; -extern crate offscreen_gl_context; -extern crate parking_lot; -extern crate phf; -extern crate pixels; #[macro_use] extern crate profile_traits; -extern crate ref_filter_map; -extern crate ref_slice; -extern crate regex; -extern crate script_layout_interface; -extern crate script_traits; -extern crate selectors; -extern crate serde; -extern crate serde_bytes; -extern crate servo_allocator; -extern crate servo_arc; #[macro_use] extern crate servo_atoms; #[macro_use] extern crate servo_channel; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_media; -extern crate servo_rand; -extern crate servo_url; -extern crate smallvec; #[macro_use] extern crate style; -extern crate style_traits; -extern crate swapper; -extern crate time; -#[cfg(target_os = "linux")] -extern crate tinyfiledialogs; -extern crate unicode_segmentation; -extern crate url; -extern crate utf8; -extern crate uuid; -extern crate webrender_api; -extern crate webvr_traits; -extern crate xml5ever; #[macro_use] mod task; diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 8647c48d1ce..f0cdd8ccad0 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -66,7 +66,7 @@ pub enum CommonScriptMsg { /// Generic message that encapsulates event handling. Task( ScriptThreadEventCategory, - Box<TaskBox>, + Box<dyn TaskBox>, Option<PipelineId>, TaskSourceName, ), @@ -88,7 +88,7 @@ pub trait ScriptChan: JSTraceable { /// Send a message to the associated event loop. fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>; /// Clone this handle. - fn clone(&self) -> Box<ScriptChan + Send>; + fn clone(&self) -> Box<dyn ScriptChan + Send>; } #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] @@ -539,7 +539,7 @@ unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize { if dom_object.is_null() { return 0; } - let mut ops = MallocSizeOfOps::new(::servo_allocator::usable_size, None, None); + let mut ops = MallocSizeOfOps::new(servo_allocator::usable_size, None, None); (v.malloc_size_of)(&mut ops, dom_object) }, Err(_e) => { diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index abd7ec4fa1b..2835b37329e 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -17,8 +17,6 @@ //! a page runs its course and the script thread returns to processing events in the main event //! loop. -extern crate itertools; - use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; use crate::devtools; @@ -94,6 +92,7 @@ use headers_ext::LastModified; use headers_ext::ReferrerPolicy as ReferrerPolicyHeader; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; +use itertools; use js::glue::GetWindowProxyClass; use js::jsapi::{JSAutoCompartment, JSContext, JS_SetWrapObjectCallbacks}; use js::jsapi::{JSTracer, SetWindowProxyClass}; @@ -260,7 +259,7 @@ pub enum MainThreadScriptMsg { pipeline_id: PipelineId, name: Atom, properties: Vec<Atom>, - painter: Box<Painter>, + painter: Box<dyn Painter>, }, /// Dispatches a job queue. DispatchJobQueue { scope_url: ServoUrl }, @@ -314,7 +313,7 @@ impl QueuedTaskConversion for MainThreadScriptMsg { } } -impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> { +impl OpaqueSender<CommonScriptMsg> for Box<dyn ScriptChan + Send> { fn send(&self, msg: CommonScriptMsg) { ScriptChan::send(&**self, msg).unwrap(); } @@ -367,7 +366,7 @@ impl ScriptChan for SendableMainThreadScriptChan { self.0.send(msg).map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(SendableMainThreadScriptChan((&self.0).clone())) } } @@ -383,7 +382,7 @@ impl ScriptChan for MainThreadScriptChan { .map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(MainThreadScriptChan((&self.0).clone())) } } @@ -501,7 +500,7 @@ pub struct ScriptThread { /// A job queue for Service Workers keyed by their scope url job_queue_map: Rc<JobQueue>, /// Image cache for this script thread. - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, /// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if /// there are many iframes. resource_threads: ResourceThreads, @@ -515,21 +514,21 @@ pub struct ScriptThread { /// events in the event queue. chan: MainThreadScriptChan, - dom_manipulation_task_sender: Box<ScriptChan>, + dom_manipulation_task_sender: Box<dyn ScriptChan>, media_element_task_sender: Sender<MainThreadScriptMsg>, user_interaction_task_sender: Sender<MainThreadScriptMsg>, - networking_task_sender: Box<ScriptChan>, + networking_task_sender: Box<dyn ScriptChan>, history_traversal_task_source: HistoryTraversalTaskSource, - file_reading_task_sender: Box<ScriptChan>, + file_reading_task_sender: Box<dyn ScriptChan>, - performance_timeline_task_sender: Box<ScriptChan>, + performance_timeline_task_sender: Box<dyn ScriptChan>, - remote_event_task_sender: Box<ScriptChan>, + remote_event_task_sender: Box<dyn ScriptChan>, /// A channel to hand out to threads that need to respond to a message from the script thread. control_chan: IpcSender<ConstellationControlMsg>, @@ -913,7 +912,7 @@ impl ScriptThread { pipeline_id: PipelineId, name: Atom, properties: Vec<Atom>, - painter: Box<Painter>, + painter: Box<dyn Painter>, ) { let window = self.documents.borrow().find_window(pipeline_id); let window = match window { diff --git a/components/script/task.rs b/components/script/task.rs index 622da35567d..06137f90278 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -65,7 +65,7 @@ where } } -impl fmt::Debug for TaskBox { +impl fmt::Debug for dyn TaskBox { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_tuple(self.name()) .field(&format_args!("...")) diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index 1160da51c96..4d5d041f24c 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -18,7 +18,7 @@ use std::default::Default; pub type QueuedTask = ( Option<TrustedWorkerAddress>, ScriptThreadEventCategory, - Box<TaskBox>, + Box<dyn TaskBox>, Option<PipelineId>, TaskSourceName, ); diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index fa6da31e6eb..35f4ac6dad5 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -16,7 +16,7 @@ use std::fmt; use std::result::Result; #[derive(JSTraceable)] -pub struct DOMManipulationTaskSource(pub Box<ScriptChan + Send>, pub PipelineId); +pub struct DOMManipulationTaskSource(pub Box<dyn ScriptChan + Send>, pub PipelineId); impl Clone for DOMManipulationTaskSource { fn clone(&self) -> DOMManipulationTaskSource { diff --git a/components/script/task_source/file_reading.rs b/components/script/task_source/file_reading.rs index 3c5b0bbcb69..39a18c6e1ab 100644 --- a/components/script/task_source/file_reading.rs +++ b/components/script/task_source/file_reading.rs @@ -11,7 +11,7 @@ use msg::constellation_msg::PipelineId; use std::sync::Arc; #[derive(JSTraceable)] -pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); +pub struct FileReadingTaskSource(pub Box<dyn ScriptChan + Send + 'static>, pub PipelineId); impl Clone for FileReadingTaskSource { fn clone(&self) -> FileReadingTaskSource { diff --git a/components/script/task_source/history_traversal.rs b/components/script/task_source/history_traversal.rs index 0bc5841b73c..c1bc6d26d83 100644 --- a/components/script/task_source/history_traversal.rs +++ b/components/script/task_source/history_traversal.rs @@ -16,7 +16,7 @@ impl ScriptChan for HistoryTraversalTaskSource { .map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(HistoryTraversalTaskSource((&self.0).clone())) } } diff --git a/components/script/task_source/networking.rs b/components/script/task_source/networking.rs index a472a8f5691..fbf030c48b3 100644 --- a/components/script/task_source/networking.rs +++ b/components/script/task_source/networking.rs @@ -8,7 +8,7 @@ use crate::task_source::{TaskSource, TaskSourceName}; use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] -pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); +pub struct NetworkingTaskSource(pub Box<dyn ScriptChan + Send + 'static>, pub PipelineId); impl Clone for NetworkingTaskSource { fn clone(&self) -> NetworkingTaskSource { diff --git a/components/script/task_source/performance_timeline.rs b/components/script/task_source/performance_timeline.rs index f6c29880e98..8b2cef77e1c 100644 --- a/components/script/task_source/performance_timeline.rs +++ b/components/script/task_source/performance_timeline.rs @@ -16,7 +16,7 @@ use std::fmt; use std::result::Result; #[derive(JSTraceable)] -pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); +pub struct PerformanceTimelineTaskSource(pub Box<dyn ScriptChan + Send + 'static>, pub PipelineId); impl Clone for PerformanceTimelineTaskSource { fn clone(&self) -> PerformanceTimelineTaskSource { diff --git a/components/script/task_source/remote_event.rs b/components/script/task_source/remote_event.rs index e58f94d1645..89b9aef303e 100644 --- a/components/script/task_source/remote_event.rs +++ b/components/script/task_source/remote_event.rs @@ -8,7 +8,7 @@ use crate::task_source::{TaskSource, TaskSourceName}; use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] -pub struct RemoteEventTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); +pub struct RemoteEventTaskSource(pub Box<dyn ScriptChan + Send + 'static>, pub PipelineId); impl Clone for RemoteEventTaskSource { fn clone(&self) -> RemoteEventTaskSource { diff --git a/components/script/task_source/websocket.rs b/components/script/task_source/websocket.rs index 9cb116155d1..c54a107fd79 100644 --- a/components/script/task_source/websocket.rs +++ b/components/script/task_source/websocket.rs @@ -8,7 +8,7 @@ use crate::task_source::{TaskSource, TaskSourceName}; use msg::constellation_msg::PipelineId; #[derive(JSTraceable)] -pub struct WebsocketTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); +pub struct WebsocketTaskSource(pub Box<dyn ScriptChan + Send + 'static>, pub PipelineId); impl Clone for WebsocketTaskSource { fn clone(&self) -> WebsocketTaskSource { diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 30f1f12c6b5..f0ee142352b 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -2,7 +2,7 @@ * 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 crate::cookie_rs::Cookie; +use cookie::Cookie; use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 58695a27750..23de1c5b0f5 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -9,34 +9,12 @@ #![deny(unsafe_code)] #![feature(associated_type_defaults)] -extern crate app_units; -extern crate atomic_refcell; -extern crate canvas_traits; -extern crate cssparser; -extern crate euclid; -extern crate gfx_traits; #[macro_use] extern crate html5ever; -extern crate ipc_channel; -extern crate libc; #[macro_use] extern crate log; -extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate metrics; -extern crate msg; -extern crate net_traits; -extern crate profile_traits; -extern crate range; -extern crate script_traits; -extern crate selectors; -extern crate servo_arc; -extern crate servo_atoms; -extern crate servo_channel; -extern crate servo_url; -extern crate style; -extern crate webrender_api; pub mod message; pub mod reporter; @@ -53,6 +31,7 @@ use servo_url::ServoUrl; use std::ptr::NonNull; use std::sync::atomic::AtomicIsize; use style::data::ElementData; +use webrender_api; #[repr(C)] pub struct StyleData { diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 01edca28a77..5c504d06e84 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -42,7 +42,7 @@ pub enum Msg { Reflow(ScriptReflow), /// Get an RPC interface. - GetRPC(Sender<Box<LayoutRPC + Send>>), + GetRPC(Sender<Box<dyn LayoutRPC + Send>>), /// Requests that the layout thread render the next frame of all animations. TickAnimations, @@ -94,7 +94,7 @@ pub enum Msg { UpdateScrollStateFromScript(ScrollState), /// Tells layout that script has added some paint worklet modules. - RegisterPaint(Atom, Vec<Atom>, Box<Painter>), + RegisterPaint(Atom, Vec<Atom>, Box<dyn Painter>), /// Send to layout the precise time when the navigation started. SetNavigationStart(u64), @@ -214,7 +214,7 @@ pub struct NewLayoutThreadInfo { pub pipeline_port: IpcReceiver<LayoutControlMsg>, pub constellation_chan: IpcSender<ConstellationMsg>, pub script_chan: IpcSender<ConstellationControlMsg>, - pub image_cache: Arc<ImageCache>, + pub image_cache: Arc<dyn ImageCache>, pub content_process_shutdown_chan: Option<IpcSender<()>>, pub layout_threads: usize, pub paint_time_metrics: PaintTimeMetrics, diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index acc261033c9..00a60d1f3e8 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -9,35 +9,12 @@ #![deny(missing_docs)] #![deny(unsafe_code)] -extern crate bluetooth_traits; -extern crate canvas_traits; -extern crate cookie as cookie_rs; -extern crate devtools_traits; -extern crate embedder_traits; -extern crate euclid; -extern crate gfx_traits; -extern crate http; -extern crate hyper; -extern crate hyper_serde; -extern crate ipc_channel; -extern crate keyboard_types; -extern crate libc; #[macro_use] extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate msg; -extern crate net_traits; -extern crate profile_traits; #[macro_use] extern crate serde; -extern crate servo_atoms; -extern crate servo_channel; -extern crate servo_url; -extern crate style_traits; -extern crate time; -extern crate webrender_api; -extern crate webvr_traits; mod script_msg; pub mod webdriver_msg; @@ -575,7 +552,7 @@ pub struct InitialScriptState { /// A channel to the bluetooth thread. pub bluetooth_thread: IpcSender<BluetoothRequest>, /// The image cache for this script thread. - pub image_cache: Arc<ImageCache>, + pub image_cache: Arc<dyn ImageCache>, /// A channel to the time profiler thread. pub time_profiler_chan: profile_traits::time::ProfilerChan, /// A channel to the memory profiler thread. @@ -863,7 +840,7 @@ pub trait Painter: SpeculativePainter { ) -> Result<DrawAPaintImageResult, PaintWorkletError>; } -impl fmt::Debug for Painter { +impl fmt::Debug for dyn Painter { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_tuple("Painter") .field(&format_args!("..")) diff --git a/components/script_traits/webdriver_msg.rs b/components/script_traits/webdriver_msg.rs index 5e49864eb09..4a7647a9e24 100644 --- a/components/script_traits/webdriver_msg.rs +++ b/components/script_traits/webdriver_msg.rs @@ -4,7 +4,7 @@ #![allow(missing_docs)] -use crate::cookie_rs::Cookie; +use cookie::Cookie; use euclid::Rect; use hyper_serde::Serde; use ipc_channel::ipc::IpcSender; diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 94fd50508af..ce3ee0962b1 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -17,49 +17,40 @@ //! `Servo` is fed events from a generic type that implements the //! `WindowMethods` trait. -extern crate env_logger; -#[cfg(all(not(target_os = "windows"), not(target_os = "ios")))] -extern crate gaol; -extern crate gleam; #[macro_use] extern crate log; -pub extern crate bluetooth; -pub extern crate bluetooth_traits; -pub extern crate canvas; -pub extern crate canvas_traits; -pub extern crate compositing; -pub extern crate constellation; -pub extern crate debugger; -pub extern crate devtools; -pub extern crate devtools_traits; -pub extern crate embedder_traits; -pub extern crate euclid; -pub extern crate gfx; -pub extern crate ipc_channel; -pub extern crate layout_thread; -pub extern crate msg; -pub extern crate net; -pub extern crate net_traits; -pub extern crate profile; -pub extern crate profile_traits; -pub extern crate script; -pub extern crate script_layout_interface; -pub extern crate script_traits; -pub extern crate servo_channel; -pub extern crate servo_config; -pub extern crate servo_geometry; -pub extern crate servo_url; -pub extern crate style; -pub extern crate style_traits; -pub extern crate webrender_api; -pub extern crate webvr; -pub extern crate webvr_traits; - -#[cfg(feature = "webdriver")] -extern crate webdriver_server; - -extern crate webrender; +pub use bluetooth; +pub use bluetooth_traits; +pub use canvas; +pub use canvas_traits; +pub use compositing; +pub use constellation; +pub use debugger; +pub use devtools; +pub use devtools_traits; +pub use embedder_traits; +pub use euclid; +pub use gfx; +pub use ipc_channel; +pub use layout_thread; +pub use msg; +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_channel; +pub use servo_config; +pub use servo_geometry; +pub use servo_url; +pub use style; +pub use style_traits; +pub use webrender_api; +pub use webvr; +pub use webvr_traits; #[cfg(feature = "webdriver")] fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) { @@ -170,7 +161,7 @@ where let recorder = if opts.webrender_record { let record_path = PathBuf::from("wr-record.bin"); let recorder = Box::new(webrender::BinaryRecorder::new(&record_path)); - Some(recorder as Box<webrender::ApiRecordingReceiver>) + Some(recorder as Box<dyn webrender::ApiRecordingReceiver>) } else { None }; @@ -458,7 +449,7 @@ where } fn create_embedder_channel( - event_loop_waker: Box<EventLoopWaker>, + event_loop_waker: Box<dyn EventLoopWaker>, ) -> (EmbedderProxy, EmbedderReceiver) { let (sender, receiver) = channel(); ( @@ -471,7 +462,7 @@ fn create_embedder_channel( } fn create_compositor_channel( - event_loop_waker: Box<EventLoopWaker>, + event_loop_waker: Box<dyn EventLoopWaker>, ) -> (CompositorProxy, CompositorReceiver) { let (sender, receiver) = channel(); ( @@ -495,7 +486,7 @@ fn create_constellation( webrender: &mut webrender::Renderer, webrender_document: webrender_api::DocumentId, webrender_api_sender: webrender_api::RenderApiSender, - window_gl: Rc<gl::Gl>, + window_gl: Rc<dyn gl::Gl>, ) -> (Sender<ConstellationMsg>, SWManagerSenders) { let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new(embedder_proxy.clone()); diff --git a/components/url/lib.rs b/components/url/lib.rs index 069fc767691..7ec15b05d7b 100644 --- a/components/url/lib.rs +++ b/components/url/lib.rs @@ -12,10 +12,6 @@ extern crate malloc_size_of; extern crate malloc_size_of_derive; #[macro_use] extern crate serde; -extern crate servo_rand; -extern crate url; -extern crate url_serde; -extern crate uuid; pub mod origin; @@ -27,6 +23,7 @@ use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo}; use std::path::Path; use std::sync::Arc; use url::{Position, Url}; +use url_serde; pub use url::Host; diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index c199eddee28..40339bf14d9 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -6,30 +6,15 @@ #![crate_type = "rlib"] #![deny(unsafe_code)] -extern crate base64; -extern crate cookie as cookie_rs; -extern crate euclid; -extern crate hyper; -extern crate image; -extern crate ipc_channel; -extern crate keyboard_types; #[macro_use] extern crate log; -extern crate msg; -extern crate net_traits; -extern crate regex; -extern crate script_traits; #[macro_use] extern crate serde; -extern crate serde_json; -extern crate servo_channel; -extern crate servo_config; -extern crate servo_url; -extern crate uuid; -extern crate webdriver; mod keys; +use base64; +use cookie; use crate::keys::keycodes_to_keys; use euclid::TypedSize2D; use hyper::Method; @@ -45,7 +30,7 @@ use script_traits::webdriver_msg::{ use script_traits::{ConstellationMsg, LoadData, WebDriverCommandMsg}; use serde::de::{Deserialize, Deserializer, MapAccess, Visitor}; use serde::ser::{Serialize, Serializer}; -use serde_json::Value; +use serde_json::{self, Value}; use servo_channel::Sender; use servo_config::prefs::{PrefValue, PREFS}; use servo_url::ServoUrl; @@ -91,7 +76,7 @@ fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> { ]; } -fn cookie_msg_to_cookie(cookie: cookie_rs::Cookie) -> Cookie { +fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie { Cookie { name: cookie.name().to_owned(), value: cookie.value().to_owned(), @@ -920,7 +905,7 @@ impl Handler { ) -> WebDriverResult<WebDriverResponse> { let (sender, receiver) = ipc::channel().unwrap(); - let cookie = cookie_rs::Cookie::build(params.name.to_owned(), params.value.to_owned()) + let cookie = cookie::Cookie::build(params.name.to_owned(), params.value.to_owned()) .secure(params.secure) .http_only(params.httpOnly); let cookie = match params.domain { diff --git a/components/webvr/lib.rs b/components/webvr/lib.rs index 6b84eb6e1a9..fd2c70c81c2 100644 --- a/components/webvr/lib.rs +++ b/components/webvr/lib.rs @@ -4,17 +4,8 @@ #![deny(unsafe_code)] -extern crate canvas_traits; -extern crate euclid; -extern crate ipc_channel; #[macro_use] extern crate log; -extern crate msg; -extern crate rust_webvr; -extern crate script_traits; -extern crate servo_channel; -extern crate servo_config; -extern crate webvr_traits; mod webvr_thread; pub use crate::webvr_thread::{WebVRCompositorHandler, WebVRThread}; diff --git a/components/webvr/webvr_thread.rs b/components/webvr/webvr_thread.rs index 4a264e073c0..1a46a33c9cc 100644 --- a/components/webvr/webvr_thread.rs +++ b/components/webvr/webvr_thread.rs @@ -347,7 +347,7 @@ impl WebVRThread { /// * WebVRThread and its VRDisplays are destroyed after all tabs are dropped and the browser is about to exit. /// WebVRThread is closed using the Exit message. -pub struct WebVRCompositor(*mut VRDisplay); +pub struct WebVRCompositor(*mut dyn VRDisplay); pub struct WebVRCompositorHandler { compositors: HashMap<webgl::WebVRDeviceId, WebVRCompositor>, webvr_thread_receiver: Receiver<Option<WebVRCompositor>>, diff --git a/components/webvr_traits/lib.rs b/components/webvr_traits/lib.rs index d1d33111eb0..299e7090fc3 100644 --- a/components/webvr_traits/lib.rs +++ b/components/webvr_traits/lib.rs @@ -4,29 +4,27 @@ #![deny(unsafe_code)] -extern crate ipc_channel; -extern crate msg; #[macro_use] extern crate serde; -pub extern crate rust_webvr_api as webvr; mod webvr_traits; -pub use crate::webvr::VRDisplayCapabilities as WebVRDisplayCapabilities; -pub use crate::webvr::VRDisplayData as WebVRDisplayData; -pub use crate::webvr::VRDisplayEvent as WebVRDisplayEvent; -pub use crate::webvr::VRDisplayEventReason as WebVRDisplayEventReason; -pub use crate::webvr::VREvent as WebVREvent; -pub use crate::webvr::VREye as WebVREye; -pub use crate::webvr::VREyeParameters as WebVREyeParameters; -pub use crate::webvr::VRFieldOfView as WebVRFieldOfView; -pub use crate::webvr::VRFrameData as WebVRFrameData; -pub use crate::webvr::VRGamepadButton as WebVRGamepadButton; -pub use crate::webvr::VRGamepadData as WebVRGamepadData; -pub use crate::webvr::VRGamepadEvent as WebVRGamepadEvent; -pub use crate::webvr::VRGamepadHand as WebVRGamepadHand; -pub use crate::webvr::VRGamepadState as WebVRGamepadState; -pub use crate::webvr::VRLayer as WebVRLayer; -pub use crate::webvr::VRPose as WebVRPose; -pub use crate::webvr::VRStageParameters as WebVRStageParameters; pub use crate::webvr_traits::{WebVRMsg, WebVRResult}; +pub use rust_webvr_api as webvr; +pub use rust_webvr_api::VRDisplayCapabilities as WebVRDisplayCapabilities; +pub use rust_webvr_api::VRDisplayData as WebVRDisplayData; +pub use rust_webvr_api::VRDisplayEvent as WebVRDisplayEvent; +pub use rust_webvr_api::VRDisplayEventReason as WebVRDisplayEventReason; +pub use rust_webvr_api::VREvent as WebVREvent; +pub use rust_webvr_api::VREye as WebVREye; +pub use rust_webvr_api::VREyeParameters as WebVREyeParameters; +pub use rust_webvr_api::VRFieldOfView as WebVRFieldOfView; +pub use rust_webvr_api::VRFrameData as WebVRFrameData; +pub use rust_webvr_api::VRGamepadButton as WebVRGamepadButton; +pub use rust_webvr_api::VRGamepadData as WebVRGamepadData; +pub use rust_webvr_api::VRGamepadEvent as WebVRGamepadEvent; +pub use rust_webvr_api::VRGamepadHand as WebVRGamepadHand; +pub use rust_webvr_api::VRGamepadState as WebVRGamepadState; +pub use rust_webvr_api::VRLayer as WebVRLayer; +pub use rust_webvr_api::VRPose as WebVRPose; +pub use rust_webvr_api::VRStageParameters as WebVRStageParameters; diff --git a/components/webvr_traits/webvr_traits.rs b/components/webvr_traits/webvr_traits.rs index e8d6b7330a6..5a9f0a2e6ad 100644 --- a/components/webvr_traits/webvr_traits.rs +++ b/components/webvr_traits/webvr_traits.rs @@ -2,9 +2,9 @@ * 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 crate::webvr::*; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; +use rust_webvr_api::*; pub type WebVRResult<T> = Result<T, String>; diff --git a/ports/libsimpleservo/build.rs b/ports/libsimpleservo/build.rs index 0ba96d6b7a8..116a24b665a 100644 --- a/ports/libsimpleservo/build.rs +++ b/ports/libsimpleservo/build.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 http://mozilla.org/MPL/2.0/. */ -extern crate cc; -extern crate gl_generator; - use gl_generator::{Api, Fallbacks, Profile, Registry}; use std::env; use std::fs::File; diff --git a/ports/libsimpleservo/src/api.rs b/ports/libsimpleservo/src/api.rs index 1c374531612..4e6a168a97d 100644 --- a/ports/libsimpleservo/src/api.rs +++ b/ports/libsimpleservo/src/api.rs @@ -106,10 +106,10 @@ pub fn servo_version() -> String { /// In the future, this will be done in multiple steps. pub fn init( init_opts: InitOptions, - gl: Rc<gl::Gl>, - waker: Box<EventLoopWaker>, - readfile: Box<ReadFileTrait + Send + Sync>, - callbacks: Box<HostTrait>, + gl: Rc<dyn gl::Gl>, + waker: Box<dyn EventLoopWaker>, + readfile: Box<dyn ReadFileTrait + Send + Sync>, + callbacks: Box<dyn HostTrait>, ) -> Result<(), &'static str> { resources::set(Box::new(ResourceReader(readfile))); @@ -444,9 +444,9 @@ impl ServoGlue { } struct ServoCallbacks { - waker: Box<EventLoopWaker>, - gl: Rc<gl::Gl>, - host_callbacks: Box<HostTrait>, + waker: Box<dyn EventLoopWaker>, + gl: Rc<dyn gl::Gl>, + host_callbacks: Box<dyn HostTrait>, width: Cell<u32>, height: Cell<u32>, density: f32, @@ -464,12 +464,12 @@ impl WindowMethods for ServoCallbacks { self.host_callbacks.flush(); } - fn create_event_loop_waker(&self) -> Box<EventLoopWaker> { + fn create_event_loop_waker(&self) -> Box<dyn EventLoopWaker> { debug!("WindowMethods::create_event_loop_waker"); self.waker.clone() } - fn gl(&self) -> Rc<gl::Gl> { + fn gl(&self) -> Rc<dyn gl::Gl> { debug!("WindowMethods::gl"); self.gl.clone() } @@ -493,7 +493,7 @@ impl WindowMethods for ServoCallbacks { } } -struct ResourceReader(Box<ReadFileTrait + Send + Sync>); +struct ResourceReader(Box<dyn ReadFileTrait + Send + Sync>); impl resources::ResourceReaderMethods for ResourceReader { fn read(&self, file: Resource) -> Vec<u8> { diff --git a/ports/libsimpleservo/src/capi.rs b/ports/libsimpleservo/src/capi.rs index bcd1d247854..c71a45a08b2 100644 --- a/ports/libsimpleservo/src/capi.rs +++ b/ports/libsimpleservo/src/capi.rs @@ -64,7 +64,7 @@ pub extern "C" fn servo_version() -> *const c_char { fn init( opts: CInitOptions, - gl: Rc<gl::Gl>, + gl: Rc<dyn gl::Gl>, wakeup: extern "C" fn(), readfile: extern "C" fn(*const c_char) -> *const c_char, callbacks: CHostCallbacks, @@ -238,7 +238,7 @@ impl WakeupCallback { } impl EventLoopWaker for WakeupCallback { - fn clone(&self) -> Box<EventLoopWaker + Send> { + fn clone(&self) -> Box<dyn EventLoopWaker + Send> { Box::new(WakeupCallback(self.0)) } fn wake(&self) { diff --git a/ports/libsimpleservo/src/gl_glue.rs b/ports/libsimpleservo/src/gl_glue.rs index 3d8903a4e10..f819105ed4f 100644 --- a/ports/libsimpleservo/src/gl_glue.rs +++ b/ports/libsimpleservo/src/gl_glue.rs @@ -89,7 +89,7 @@ pub mod egl { pub mod gl { use servo::gl::Gl; use std::rc::Rc; - pub fn init() -> Result<Rc<Gl>, &'static str> { + pub fn init() -> Result<Rc<dyn Gl>, &'static str> { // FIXME: Add an OpenGL version unimplemented!() } diff --git a/ports/libsimpleservo/src/lib.rs b/ports/libsimpleservo/src/lib.rs index 6898f542a8c..cbe24f77c9f 100644 --- a/ports/libsimpleservo/src/lib.rs +++ b/ports/libsimpleservo/src/lib.rs @@ -2,20 +2,8 @@ * 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/. */ -#[cfg(target_os = "android")] -extern crate android_injected_glue; -#[cfg(target_os = "android")] -extern crate android_logger; -#[cfg(target_os = "android")] -extern crate jni; -#[cfg(any(target_os = "android", target_os = "windows"))] -extern crate libc; #[macro_use] extern crate log; -extern crate serde_json; -extern crate servo; -#[cfg(target_os = "windows")] -extern crate winapi; mod api; mod gl_glue; diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index 7f962ca9ce3..655063d37eb 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -153,7 +153,7 @@ pub struct Window { last_pressed: Cell<Option<KeyboardEvent>>, animation_state: Cell<AnimationState>, fullscreen: Cell<bool>, - gl: Rc<gl::Gl>, + gl: Rc<dyn gl::Gl>, suspended: Cell<bool>, } @@ -675,7 +675,7 @@ impl Window { } impl WindowMethods for Window { - fn gl(&self) -> Rc<gl::Gl> { + fn gl(&self) -> Rc<dyn gl::Gl> { self.gl.clone() } @@ -738,7 +738,7 @@ impl WindowMethods for Window { } } - fn create_event_loop_waker(&self) -> Box<EventLoopWaker> { + fn create_event_loop_waker(&self) -> Box<dyn EventLoopWaker> { struct GlutinEventLoopWaker { proxy: Option<Arc<winit::EventsLoopProxy>>, } @@ -762,7 +762,7 @@ impl WindowMethods for Window { } } } - fn clone(&self) -> Box<EventLoopWaker + Send> { + fn clone(&self) -> Box<dyn EventLoopWaker + Send> { Box::new(GlutinEventLoopWaker { proxy: self.proxy.clone(), }) diff --git a/ports/servo/non_android_main.rs b/ports/servo/non_android_main.rs index f246c8d3e4f..80e3f18a72a 100644 --- a/ports/servo/non_android_main.rs +++ b/ports/servo/non_android_main.rs @@ -2,32 +2,8 @@ * 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/. */ -extern crate backtrace; -extern crate euclid; -#[cfg(target_os = "windows")] -extern crate gdi32; -extern crate gleam; -extern crate glutin; -extern crate keyboard_types; -#[macro_use] -extern crate lazy_static; -#[cfg(any(target_os = "linux", target_os = "macos"))] -extern crate osmesa_sys; -extern crate servo; -#[cfg(feature = "unstable")] -#[macro_use] -extern crate sig; -#[cfg(any( - target_os = "macos", - target_os = "linux", - target_os = "windows" -))] -extern crate tinyfiledialogs; -#[cfg(target_os = "windows")] -extern crate user32; -#[cfg(target_os = "windows")] -extern crate winapi; -extern crate winit; +#[macro_use] extern crate lazy_static; +#[cfg(feature = "unstable")] #[macro_use] extern crate sig; // The window backed by glutin mod glutin_app; diff --git a/support/rust-task_info/build.rs b/support/rust-task_info/build.rs index e20f2723a80..94ef6005df5 100644 --- a/support/rust-task_info/build.rs +++ b/support/rust-task_info/build.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 http://mozilla.org/MPL/2.0/. */ -extern crate cc; - fn main() { cc::Build::new() .file("src/task_info.c") diff --git a/tests/unit/metrics/lib.rs b/tests/unit/metrics/lib.rs index e5f99bff746..bb1ee41a069 100644 --- a/tests/unit/metrics/lib.rs +++ b/tests/unit/metrics/lib.rs @@ -4,15 +4,5 @@ #![cfg(test)] -extern crate gfx_traits; -extern crate ipc_channel; -extern crate layout; -extern crate metrics; -extern crate msg; -extern crate profile_traits; -extern crate servo_url; -extern crate time; -extern crate webrender_api; - mod interactive_time; mod paint_time; diff --git a/tests/unit/profile/Cargo.toml b/tests/unit/profile/Cargo.toml index 9e608a7c3ce..fca955ca052 100644 --- a/tests/unit/profile/Cargo.toml +++ b/tests/unit/profile/Cargo.toml @@ -14,8 +14,5 @@ doctest = false ipc-channel = "0.11" profile = {path = "../../../components/profile"} profile_traits = {path = "../../../components/profile_traits"} - -# Work around https://github.com/alexcrichton/jemallocator/issues/19 -servo_allocator = {path = "../../../components/allocator"} servo_config = {path = "../../../components/config"} diff --git a/tests/unit/profile/lib.rs b/tests/unit/profile/lib.rs index a67e211ad7b..3d8c49b1754 100644 --- a/tests/unit/profile/lib.rs +++ b/tests/unit/profile/lib.rs @@ -4,10 +4,4 @@ #![cfg(test)] -extern crate ipc_channel; -extern crate profile; -extern crate profile_traits; -extern crate servo_allocator; -extern crate servo_config; - mod time; diff --git a/tests/unit/script/lib.rs b/tests/unit/script/lib.rs index 0251144dd30..0e68becec17 100644 --- a/tests/unit/script/lib.rs +++ b/tests/unit/script/lib.rs @@ -3,15 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #[cfg(test)] -extern crate euclid; -#[cfg(test)] -extern crate keyboard_types; -#[cfg(test)] -extern crate script; -#[cfg(test)] -extern crate servo_url; - -#[cfg(test)] mod headers; #[cfg(test)] mod htmlareaelement; |