cargo fix --edition-idioms

This commit is contained in:
Simon Sapin 2018-11-01 21:43:04 +01:00
parent b1fd6237d1
commit 2012be4a8b
203 changed files with 665 additions and 1281 deletions

3
Cargo.lock generated
View file

@ -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",
]

View file

@ -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;

View file

@ -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 =

View file

@ -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"));

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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()

View file

@ -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;

View file

@ -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,

View file

@ -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());
}

View file

@ -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;

View file

@ -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};

View file

@ -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())

View file

@ -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()))
}

View file

@ -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.

View file

@ -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,

View file

@ -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;

View file

@ -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.

View file

@ -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)]

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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,

View file

@ -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);

View file

@ -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);
}

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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]

View file

@ -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;

View file

@ -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,

View file

@ -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]

View file

@ -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]

View file

@ -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};

View file

@ -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;

View file

@ -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]

View file

@ -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 {

View file

@ -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,

View file

@ -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)
}

View file

@ -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>;
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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)
}

View file

@ -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!"),

View file

@ -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> {

View file

@ -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) ||

View file

@ -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(

View file

@ -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)
}

View file

@ -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;

View file

@ -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 {

View file

@ -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);
}

View file

@ -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,

View file

@ -77,7 +77,7 @@ where
pub struct PersistentListIterator<'a, T>
where
T: 'a + Send + Sync,
T: Send + Sync,
{
entry: Option<&'a PersistentListEntry<T>>,
}

View file

@ -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);

View file

@ -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

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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 {

View file

@ -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],

View file

@ -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)
}

View file

@ -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)
}

View file

@ -4,7 +4,6 @@
#![cfg(target_pointer_width = "64")]
extern crate layout;
#[macro_use]
extern crate size_of_test;

View file

@ -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;

View file

@ -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)
}
}

View file

@ -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,

View file

@ -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,
{

View file

@ -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;

View file

@ -4,7 +4,6 @@
#![cfg(target_pointer_width = "64")]
extern crate msg;
#[macro_use]
extern crate size_of_test;

View file

@ -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"

View file

@ -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();

View file

@ -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;

View file

@ -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 {

View file

@ -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>),

View file

@ -380,7 +380,7 @@ fn obtain_response(
request_id: Option<&str>,
is_xhr: bool,
) -> Box<
Future<
dyn Future<
Item = (
HyperResponse<WrappedBody>,
Option<ChromeToDevtoolsControlMsg>,

View file

@ -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;

View file

@ -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 {

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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 {})
}
}

View file

@ -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"

View file

@ -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;

View file

@ -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};

View file

@ -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]

View file

@ -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.

View file

@ -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() {

View file

@ -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;

View file

@ -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}

View file

@ -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;

View file

@ -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> {

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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;

View file

@ -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;

Some files were not shown because too many files have changed in this diff Show more