Fix some new warnings

This commit is contained in:
Simon Sapin 2019-06-19 16:07:13 +02:00
parent 112f1ddeba
commit 1d38bc0419
65 changed files with 179 additions and 175 deletions

View file

@ -26,7 +26,7 @@ impl HangMonitorRegister {
pub fn init(
constellation_chan: IpcSender<HangMonitorAlert>,
control_port: IpcReceiver<SamplerControlMsg>,
) -> Box<BackgroundHangMonitorRegister> {
) -> Box<dyn BackgroundHangMonitorRegister> {
let (sender, port) = unbounded();
let _ = thread::Builder::new().spawn(move || {
let mut monitor =
@ -48,7 +48,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
component_id: MonitoredComponentId,
transient_hang_timeout: Duration,
permanent_hang_timeout: Duration,
) -> Box<BackgroundHangMonitor> {
) -> Box<dyn BackgroundHangMonitor> {
let bhm_chan = BackgroundHangMonitorChan::new(self.sender.clone(), component_id);
#[cfg(all(
@ -77,7 +77,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
}
impl BackgroundHangMonitorClone for HangMonitorRegister {
fn clone_box(&self) -> Box<BackgroundHangMonitorRegister> {
fn clone_box(&self) -> Box<dyn BackgroundHangMonitorRegister> {
Box::new(self.clone())
}
}
@ -85,7 +85,7 @@ impl BackgroundHangMonitorClone for HangMonitorRegister {
/// Messages sent from monitored components to the monitor.
pub enum MonitoredComponentMsg {
/// Register component for monitoring,
Register(Box<Sampler>, Option<String>, Duration, Duration),
Register(Box<dyn Sampler>, Option<String>, Duration, Duration),
/// Unregister component for monitoring.
Unregister,
/// Notify start of new activity for a given component,
@ -142,7 +142,7 @@ impl BackgroundHangMonitor for BackgroundHangMonitorChan {
}
struct MonitoredComponent {
sampler: Box<Sampler>,
sampler: Box<dyn Sampler>,
last_activity: Instant,
last_annotation: Option<HangAnnotation>,
transient_hang_timeout: Duration,

View file

@ -17,7 +17,7 @@ pub struct DummySampler;
impl DummySampler {
#[allow(dead_code)]
pub fn new() -> Box<Sampler> {
pub fn new() -> Box<dyn Sampler> {
Box::new(DummySampler)
}
}

View file

@ -128,7 +128,7 @@ pub struct LinuxSampler {
impl LinuxSampler {
#[allow(unsafe_code, dead_code)]
pub fn new() -> Box<Sampler> {
pub fn new() -> Box<dyn Sampler> {
let thread_id = unsafe { libc::syscall(libc::SYS_gettid) as libc::pid_t };
let handler = SigHandler::SigAction(sigprof_handler);
let action = SigAction::new(

View file

@ -16,7 +16,7 @@ pub struct MacOsSampler {
impl MacOsSampler {
#[allow(unsafe_code)]
pub fn new() -> Box<Sampler> {
pub fn new() -> Box<dyn Sampler> {
let thread_id = unsafe { mach::mach_init::mach_thread_self() };
Box::new(MacOsSampler { thread_id })
}

View file

@ -13,7 +13,7 @@ pub struct WindowsSampler {
impl WindowsSampler {
#[allow(unsafe_code, dead_code)]
pub fn new() -> Box<Sampler> {
pub fn new() -> Box<dyn Sampler> {
let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId
Box::new(WindowsSampler { thread_id })
}

View file

@ -55,7 +55,7 @@ impl Backend for AzureBackend {
&mut self,
style: FillOrStrokeStyle,
state: &mut CanvasPaintState<'a>,
drawtarget: &GenericDrawTarget,
drawtarget: &dyn GenericDrawTarget,
) {
if let Some(pattern) = style.to_azure_pattern(drawtarget) {
state.fill_style = Pattern::Azure(pattern)
@ -66,7 +66,7 @@ impl Backend for AzureBackend {
&mut self,
style: FillOrStrokeStyle,
state: &mut CanvasPaintState<'a>,
drawtarget: &GenericDrawTarget,
drawtarget: &dyn GenericDrawTarget,
) {
if let Some(pattern) = style.to_azure_pattern(drawtarget) {
state.stroke_style = Pattern::Azure(pattern)
@ -84,7 +84,7 @@ impl Backend for AzureBackend {
.set_composition_op(op.to_azure_style());
}
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<GenericDrawTarget> {
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<dyn GenericDrawTarget> {
// FIXME(nox): Why is the size made of i32 values?
Box::new(DrawTarget::new(
BackendType::Skia,
@ -222,7 +222,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget {
GradientStops::Azure(self.create_gradient_stops(&gradient_stops, extend_mode.into_azure()))
}
fn create_path_builder(&self) -> Box<GenericPathBuilder> {
fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> {
Box::new(self.create_path_builder())
}
@ -230,7 +230,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget {
&self,
size: &Size2D<i32>,
format: SurfaceFormat,
) -> Box<GenericDrawTarget> {
) -> Box<dyn GenericDrawTarget> {
Box::new(self.create_similar_draw_target(size, format.into_azure()))
}
fn create_source_surface_from_data(
@ -378,7 +378,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget {
}
#[allow(unsafe_code)]
fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
unsafe { f(self.snapshot().get_data_surface().data()) }
}
@ -619,11 +619,11 @@ impl ToAzureStyle for CompositionOrBlending {
}
pub trait ToAzurePattern {
fn to_azure_pattern(&self, drawtarget: &GenericDrawTarget) -> Option<azure_hl::Pattern>;
fn to_azure_pattern(&self, drawtarget: &dyn GenericDrawTarget) -> Option<azure_hl::Pattern>;
}
impl ToAzurePattern for FillOrStrokeStyle {
fn to_azure_pattern(&self, drawtarget: &GenericDrawTarget) -> Option<azure_hl::Pattern> {
fn to_azure_pattern(&self, drawtarget: &dyn GenericDrawTarget) -> Option<azure_hl::Pattern> {
Some(match *self {
FillOrStrokeStyle::Color(ref color) => {
azure_hl::Pattern::Color(ColorPattern::new(color.to_azure_style()))
@ -747,7 +747,7 @@ impl Path {
pub fn transformed_copy_to_builder(
&self,
transform: &Transform2D<f32>,
) -> Box<GenericPathBuilder> {
) -> Box<dyn GenericPathBuilder> {
Box::new(self.as_azure().transformed_copy_to_builder(transform))
}
@ -755,7 +755,7 @@ impl Path {
self.as_azure().contains_point(x, y, path_transform)
}
pub fn copy_to_builder(&self) -> Box<GenericPathBuilder> {
pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
Box::new(self.as_azure().copy_to_builder())
}
}

View file

@ -26,9 +26,9 @@ enum PathState {
/// Path builder in user-space. If a transform has been applied
/// but no further path operations have occurred, it is stored
/// in the optional field.
UserSpacePathBuilder(Box<GenericPathBuilder>, Option<Transform2D<f32>>),
UserSpacePathBuilder(Box<dyn GenericPathBuilder>, Option<Transform2D<f32>>),
/// Path builder in device-space.
DeviceSpacePathBuilder(Box<GenericPathBuilder>),
DeviceSpacePathBuilder(Box<dyn GenericPathBuilder>),
/// Path in user-space. If a transform has been applied but
/// but no further path operations have occurred, it is stored
/// in the optional field.
@ -61,20 +61,20 @@ pub trait Backend {
&mut self,
style: FillOrStrokeStyle,
state: &mut CanvasPaintState<'a>,
drawtarget: &GenericDrawTarget,
drawtarget: &dyn GenericDrawTarget,
);
fn set_stroke_style<'a>(
&mut self,
style: FillOrStrokeStyle,
state: &mut CanvasPaintState<'a>,
drawtarget: &GenericDrawTarget,
drawtarget: &dyn GenericDrawTarget,
);
fn set_global_composition<'a>(
&mut self,
op: CompositionOrBlending,
state: &mut CanvasPaintState<'a>,
);
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<GenericDrawTarget>;
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<dyn GenericDrawTarget>;
fn recreate_paint_state<'a>(&self, state: &CanvasPaintState<'a>) -> CanvasPaintState<'a>;
fn size_from_pattern(&self, rect: &Rect<f32>, pattern: &Pattern) -> Option<Size2D<f32>>;
}
@ -117,7 +117,7 @@ pub trait GenericPathBuilder {
/// A wrapper around a stored PathBuilder and an optional transformation that should be
/// applied to any points to ensure they are in the matching device space.
struct PathBuilderRef<'a> {
builder: &'a Box<GenericPathBuilder>,
builder: &'a Box<dyn GenericPathBuilder>,
transform: Transform2D<f32>,
}
@ -215,12 +215,12 @@ pub trait GenericDrawTarget {
gradient_stops: Vec<GradientStop>,
extend_mode: ExtendMode,
) -> GradientStops;
fn create_path_builder(&self) -> Box<GenericPathBuilder>;
fn create_path_builder(&self) -> Box<dyn GenericPathBuilder>;
fn create_similar_draw_target(
&self,
size: &Size2D<i32>,
format: SurfaceFormat,
) -> Box<GenericDrawTarget>;
) -> Box<dyn GenericDrawTarget>;
fn create_source_surface_from_data(
&self,
data: &[u8],
@ -275,7 +275,7 @@ pub trait GenericDrawTarget {
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
);
fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec<u8>) -> Vec<u8>;
fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8>;
fn snapshot_data_owned(&self) -> Vec<u8>;
}
@ -377,8 +377,8 @@ pub enum Filter {
}
pub struct CanvasData<'a> {
backend: Box<Backend>,
drawtarget: Box<GenericDrawTarget>,
backend: Box<dyn Backend>,
drawtarget: Box<dyn GenericDrawTarget>,
path_state: Option<PathState>,
state: CanvasPaintState<'a>,
saved_states: Vec<CanvasPaintState<'a>>,
@ -392,12 +392,12 @@ pub struct CanvasData<'a> {
}
#[cfg(feature = "azure_backend")]
fn create_backend() -> Box<Backend> {
fn create_backend() -> Box<dyn Backend> {
Box::new(crate::azure_backend::AzureBackend)
}
#[cfg(feature = "raqote_backend")]
fn create_backend() -> Box<Backend> {
fn create_backend() -> Box<dyn Backend> {
Box::new(crate::raqote_backend::RaqoteBackend)
}
@ -442,7 +442,7 @@ impl<'a> CanvasData<'a> {
image_data.into()
};
let writer = |draw_target: &GenericDrawTarget| {
let writer = |draw_target: &dyn GenericDrawTarget| {
write_image(
draw_target,
image_data,
@ -498,7 +498,7 @@ impl<'a> CanvasData<'a> {
);
if self.need_to_draw_shadow() {
self.draw_with_shadow(&draw_rect, |new_draw_target: &GenericDrawTarget| {
self.draw_with_shadow(&draw_rect, |new_draw_target: &dyn GenericDrawTarget| {
new_draw_target.fill_rect(
&draw_rect,
self.state.fill_style.clone(),
@ -524,7 +524,7 @@ impl<'a> CanvasData<'a> {
}
if self.need_to_draw_shadow() {
self.draw_with_shadow(&rect, |new_draw_target: &GenericDrawTarget| {
self.draw_with_shadow(&rect, |new_draw_target: &dyn GenericDrawTarget| {
new_draw_target.stroke_rect(
rect,
self.state.stroke_style.clone(),
@ -1023,7 +1023,7 @@ impl<'a> CanvasData<'a> {
self.state.shadow_blur != 0.0f64)
}
fn create_draw_target_for_shadow(&self, source_rect: &Rect<f32>) -> Box<GenericDrawTarget> {
fn create_draw_target_for_shadow(&self, source_rect: &Rect<f32>) -> Box<dyn GenericDrawTarget> {
let draw_target = self.drawtarget.create_similar_draw_target(
&Size2D::new(
source_rect.size.width as i32,
@ -1040,7 +1040,7 @@ impl<'a> CanvasData<'a> {
fn draw_with_shadow<F>(&self, rect: &Rect<f32>, draw_shadow_source: F)
where
F: FnOnce(&GenericDrawTarget),
F: FnOnce(&dyn GenericDrawTarget),
{
let shadow_src_rect = self.state.transform.transform_rect(rect);
let new_draw_target = self.create_draw_target_for_shadow(&shadow_src_rect);
@ -1116,7 +1116,7 @@ pub struct CanvasPaintState<'a> {
/// dest_rect: Area of the destination target where the pixels will be copied
/// smoothing_enabled: It determines if smoothing is applied to the image result
fn write_image(
draw_target: &GenericDrawTarget,
draw_target: &dyn GenericDrawTarget,
image_data: Vec<u8>,
image_size: Size2D<f64>,
dest_rect: Rect<f64>,

View file

@ -36,7 +36,7 @@ impl Backend for RaqoteBackend {
&mut self,
_style: FillOrStrokeStyle,
_state: &mut CanvasPaintState<'a>,
_drawtarget: &GenericDrawTarget,
_drawtarget: &dyn GenericDrawTarget,
) {
unimplemented!()
}
@ -45,7 +45,7 @@ impl Backend for RaqoteBackend {
&mut self,
_style: FillOrStrokeStyle,
_state: &mut CanvasPaintState<'a>,
_drawtarget: &GenericDrawTarget,
_drawtarget: &dyn GenericDrawTarget,
) {
unimplemented!()
}
@ -58,7 +58,7 @@ impl Backend for RaqoteBackend {
unimplemented!()
}
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<GenericDrawTarget> {
fn create_drawtarget(&self, size: Size2D<u64>) -> Box<dyn GenericDrawTarget> {
Box::new(raqote::DrawTarget::new(
size.width as i32,
size.height as i32,
@ -121,7 +121,7 @@ impl Path {
pub fn transformed_copy_to_builder(
&self,
_transform: &Transform2D<f32>,
) -> Box<GenericPathBuilder> {
) -> Box<dyn GenericPathBuilder> {
unimplemented!()
}
@ -129,7 +129,7 @@ impl Path {
unimplemented!()
}
pub fn copy_to_builder(&self) -> Box<GenericPathBuilder> {
pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
unimplemented!()
}
}
@ -156,7 +156,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
unimplemented!()
}
fn create_path_builder(&self) -> Box<GenericPathBuilder> {
fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> {
unimplemented!()
}
@ -164,7 +164,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
&self,
_size: &Size2D<i32>,
_format: SurfaceFormat,
) -> Box<GenericDrawTarget> {
) -> Box<dyn GenericDrawTarget> {
unimplemented!()
}
fn create_source_surface_from_data(
@ -246,13 +246,13 @@ impl GenericDrawTarget for raqote::DrawTarget {
&self,
_rect: &Rect<f32>,
_pattern: Pattern,
_stroke_options: &StrokeOptions,
_stroke_options: &StrokeOptions<'_>,
_draw_options: &DrawOptions,
) {
unimplemented!()
}
fn snapshot_data(&self, _f: &Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
fn snapshot_data(&self, _f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
unimplemented!()
}

View file

@ -154,5 +154,5 @@ pub struct InitialCompositorState {
pub webrender: webrender::Renderer,
pub webrender_document: webrender_api::DocumentId,
pub webrender_api: webrender_api::RenderApi,
pub webvr_heartbeats: Vec<Box<WebVRMainThreadHeartbeat>>,
pub webvr_heartbeats: Vec<Box<dyn WebVRMainThreadHeartbeat>>,
}

View file

@ -166,7 +166,7 @@ pub trait EmbedderMethods {
fn register_vr_services(
&mut self,
_: &mut VRServiceManager,
_: &mut Vec<Box<WebVRMainThreadHeartbeat>>,
_: &mut Vec<Box<dyn WebVRMainThreadHeartbeat>>,
) {
}
}

View file

@ -171,8 +171,8 @@ impl fmt::Display for PrefError {
impl std::error::Error for PrefError {}
pub struct Accessor<P, V> {
pub getter: Box<Fn(&P) -> V + Sync>,
pub setter: Box<Fn(&mut P, V) + Sync>,
pub getter: Box<dyn Fn(&P) -> V + Sync>,
pub setter: Box<dyn Fn(&mut P, V) + Sync>,
}
impl<P, V> Accessor<P, V> {

View file

@ -227,7 +227,7 @@ pub struct Constellation<Message, LTF, STF> {
/// A handle to register components for hang monitoring.
/// None when in multiprocess mode.
background_monitor_register: Option<Box<BackgroundHangMonitorRegister>>,
background_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
/// Channels to control all sampling profilers.
sampling_profiler_control: Vec<IpcSender<SamplerControlMsg>>,

View file

@ -121,7 +121,7 @@ pub struct InitialPipelineState {
/// A handle to register components for hang monitoring.
/// None when in multiprocess mode.
pub background_monitor_register: Option<Box<BackgroundHangMonitorRegister>>,
pub background_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
/// A channel for the background hang monitor to send messages to the constellation.
pub background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
@ -516,7 +516,7 @@ impl UnprivilegedPipelineContent {
pub fn start_all<Message, LTF, STF>(
self,
wait_for_completion: bool,
background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
) where
LTF: LayoutThreadFactory<Message = Message>,
STF: ScriptThreadFactory<Message = Message>,
@ -704,7 +704,9 @@ impl UnprivilegedPipelineContent {
}
}
pub fn register_with_background_hang_monitor(&mut self) -> Box<BackgroundHangMonitorRegister> {
pub fn register_with_background_hang_monitor(
&mut self,
) -> Box<dyn BackgroundHangMonitorRegister> {
HangMonitorRegister::init(
self.background_hang_monitor_to_constellation_chan.clone(),
self.sampling_profiler_port

View file

@ -65,14 +65,14 @@ pub enum Cursor {
/// Used to wake up the event loop, provided by the servo port/embedder.
pub trait EventLoopWaker: 'static + Send {
fn clone(&self) -> Box<EventLoopWaker + Send>;
fn clone(&self) -> Box<dyn EventLoopWaker + Send>;
fn wake(&self);
}
/// Sends messages to the embedder.
pub struct EmbedderProxy {
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
pub event_loop_waker: Box<EventLoopWaker>,
pub event_loop_waker: Box<dyn EventLoopWaker>,
}
impl EmbedderProxy {

View file

@ -6,10 +6,11 @@ use std::path::PathBuf;
use std::sync::{Once, RwLock};
lazy_static! {
static ref RES: RwLock<Option<Box<ResourceReaderMethods + Sync + Send>>> = RwLock::new(None);
static ref RES: RwLock<Option<Box<dyn ResourceReaderMethods + Sync + Send>>> =
RwLock::new(None);
}
pub fn set(reader: Box<ResourceReaderMethods + Sync + Send>) {
pub fn set(reader: Box<dyn ResourceReaderMethods + Sync + Send>) {
*RES.write().unwrap() = Some(reader);
}
@ -67,7 +68,7 @@ pub trait ResourceReaderMethods {
fn sandbox_access_files_dirs(&self) -> Vec<PathBuf>;
}
fn resources_for_tests() -> Box<ResourceReaderMethods + Sync + Send> {
fn resources_for_tests() -> Box<dyn ResourceReaderMethods + Sync + Send> {
use std::env;
use std::fs::File;
use std::io::Read;

View file

@ -114,8 +114,8 @@ pub fn fixed_to_float(before: usize, f: i32) -> f64 {
pub fn is_bidi_control(c: char) -> bool {
match c {
'\u{202A}'...'\u{202E}' => true,
'\u{2066}'...'\u{2069}' => true,
'\u{202A}'..='\u{202E}' => true,
'\u{2066}'..='\u{2069}' => true,
'\u{200E}' | '\u{200F}' | '\u{061C}' => true,
_ => false,
}

View file

@ -156,7 +156,7 @@ pub struct LayoutThread {
font_cache_sender: IpcSender<()>,
/// A means of communication with the background hang monitor.
background_hang_monitor: Box<BackgroundHangMonitor>,
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
/// The channel on which messages can be sent to the constellation.
constellation_chan: IpcSender<ConstellationMsg>,
@ -296,7 +296,7 @@ impl LayoutThreadFactory for LayoutThread {
is_iframe: bool,
chan: (Sender<Msg>, Receiver<Msg>),
pipeline_port: IpcReceiver<LayoutControlMsg>,
background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
image_cache: Arc<dyn ImageCache>,
@ -520,7 +520,7 @@ impl LayoutThread {
is_iframe: bool,
port: Receiver<Msg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
background_hang_monitor: Box<BackgroundHangMonitor>,
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
image_cache: Arc<dyn ImageCache>,

View file

@ -36,7 +36,7 @@ pub trait LayoutThreadFactory {
is_iframe: bool,
chan: (Sender<Self::Message>, Receiver<Self::Message>),
pipeline_port: IpcReceiver<LayoutControlMsg>,
background_hang_monitor: Box<BackgroundHangMonitorRegister>,
background_hang_monitor: Box<dyn BackgroundHangMonitorRegister>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
image_cache: Arc<dyn ImageCache>,

View file

@ -92,7 +92,7 @@ use void::Void;
type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
/// A closure implementing a stateful predicate on pointers.
type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool;
type VoidPtrToBoolFnMut = dyn FnMut(*const c_void) -> bool;
/// Operations used when measuring heap usage of data structures.
pub struct MallocSizeOfOps {

View file

@ -463,17 +463,17 @@ pub trait BackgroundHangMonitorRegister: BackgroundHangMonitorClone + Send {
component: MonitoredComponentId,
transient_hang_timeout: Duration,
permanent_hang_timeout: Duration,
) -> Box<BackgroundHangMonitor>;
) -> Box<dyn BackgroundHangMonitor>;
}
impl Clone for Box<BackgroundHangMonitorRegister> {
fn clone(&self) -> Box<BackgroundHangMonitorRegister> {
impl Clone for Box<dyn BackgroundHangMonitorRegister> {
fn clone(&self) -> Box<dyn BackgroundHangMonitorRegister> {
self.clone_box()
}
}
pub trait BackgroundHangMonitorClone {
fn clone_box(&self) -> Box<BackgroundHangMonitorRegister>;
fn clone_box(&self) -> Box<dyn BackgroundHangMonitorRegister>;
}
/// Proxy methods to communicate with the background hang monitor

View file

@ -220,7 +220,7 @@ impl Gzip {
}
#[allow(unsafe_code)]
fn poll_with_read(reader: &mut Read, buf: &mut BytesMut) -> Poll<Option<Chunk>, Error> {
fn poll_with_read(reader: &mut dyn Read, buf: &mut BytesMut) -> Poll<Option<Chunk>, Error> {
if buf.remaining_mut() == 0 {
buf.reserve(INIT_BUFFER_SIZE);
}

View file

@ -1054,7 +1054,7 @@ fn http_network_or_cache_fetch(
let forward_response =
http_network_fetch(http_request, credentials_flag, done_chan, context);
// Substep 3
if let Some((200...399, _)) = forward_response.raw_status {
if let Some((200..=399, _)) = forward_response.raw_status {
if !http_request.method.is_safe() {
if let Ok(mut http_cache) = context.state.http_cache.write() {
http_cache.invalidate(&http_request, &forward_response);

View file

@ -140,7 +140,7 @@ pub fn is_token(s: &[u8]) -> bool {
s.iter().all(|&x| {
// http://tools.ietf.org/html/rfc2616#section-2.2
match x {
0...31 | 127 => false, // CTLs
0..=31 | 127 => false, // CTLs
40 | 41 | 60 | 62 | 64 | 44 | 59 | 58 | 92 | 34 | 47 | 91 | 93 | 63 | 61 | 123 |
125 | 32 => false, // separators
x if x > 127 => false, // non-CHARs

View file

@ -96,21 +96,21 @@ pub fn xml_name_type(name: &str) -> XMLName {
fn is_valid_start(c: char) -> bool {
match c {
':' |
'A'...'Z' |
'A'..='Z' |
'_' |
'a'...'z' |
'\u{C0}'...'\u{D6}' |
'\u{D8}'...'\u{F6}' |
'\u{F8}'...'\u{2FF}' |
'\u{370}'...'\u{37D}' |
'\u{37F}'...'\u{1FFF}' |
'\u{200C}'...'\u{200D}' |
'\u{2070}'...'\u{218F}' |
'\u{2C00}'...'\u{2FEF}' |
'\u{3001}'...'\u{D7FF}' |
'\u{F900}'...'\u{FDCF}' |
'\u{FDF0}'...'\u{FFFD}' |
'\u{10000}'...'\u{EFFFF}' => true,
'a'..='z' |
'\u{C0}'..='\u{D6}' |
'\u{D8}'..='\u{F6}' |
'\u{F8}'..='\u{2FF}' |
'\u{370}'..='\u{37D}' |
'\u{37F}'..='\u{1FFF}' |
'\u{200C}'..='\u{200D}' |
'\u{2070}'..='\u{218F}' |
'\u{2C00}'..='\u{2FEF}' |
'\u{3001}'..='\u{D7FF}' |
'\u{F900}'..='\u{FDCF}' |
'\u{FDF0}'..='\u{FFFD}' |
'\u{10000}'..='\u{EFFFF}' => true,
_ => false,
}
}
@ -120,10 +120,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
match c {
'-' |
'.' |
'0'...'9' |
'0'..='9' |
'\u{B7}' |
'\u{300}'...'\u{36F}' |
'\u{203F}'...'\u{2040}' => true,
'\u{300}'..='\u{36F}' |
'\u{203F}'..='\u{2040}' => true,
_ => false,
}
}

View file

@ -174,9 +174,9 @@ pub struct DedicatedWorkerGlobalScope {
worker: DomRefCell<Option<TrustedWorkerAddress>>,
#[ignore_malloc_size_of = "Can't measure trait objects"]
/// Sender to the parent thread.
parent_sender: Box<ScriptChan + Send>,
parent_sender: Box<dyn ScriptChan + Send>,
#[ignore_malloc_size_of = "Arc"]
image_cache: Arc<ImageCache>,
image_cache: Arc<dyn ImageCache>,
}
impl WorkerEventLoopMethods for DedicatedWorkerGlobalScope {

View file

@ -499,7 +499,7 @@ fn is_field_vchar(x: u8) -> bool {
// https://tools.ietf.org/html/rfc5234#appendix-B.1
pub fn is_vchar(x: u8) -> bool {
match x {
0x21...0x7E => true,
0x21..=0x7E => true,
_ => false,
}
}
@ -507,7 +507,7 @@ pub fn is_vchar(x: u8) -> bool {
// http://tools.ietf.org/html/rfc7230#section-3.2.6
pub fn is_obs_text(x: u8) -> bool {
match x {
0x80...0xFF => true,
0x80..=0xFF => true,
_ => false,
}
}

View file

@ -82,7 +82,7 @@ impl Area {
while index < size {
let val = num[index];
match val {
b'0'...b'9' | b'.' | b'-' | b'E' | b'e' => break,
b'0'..=b'9' | b'.' | b'-' | b'E' | b'e' => break,
_ => {},
}

View file

@ -57,7 +57,7 @@ pub struct HTMLCollection {
reflector_: Reflector,
root: Dom<Node>,
#[ignore_malloc_size_of = "Contains a trait object; can't measure due to #6870"]
filter: Box<CollectionFilter + 'static>,
filter: Box<dyn CollectionFilter + 'static>,
// We cache the version of the root node and all its decendents,
// the length of the collection, and a cursor into the collection.
// FIXME: make the cached cursor element a weak pointer

View file

@ -210,7 +210,7 @@ impl FetchResponseListener for ImageContext {
0 => Err(NetworkError::Internal(
"No http status code received".to_owned(),
)),
200...299 => Ok(()), // HTTP ok status codes
200..=299 => Ok(()), // HTTP ok status codes
_ => Err(NetworkError::Internal(format!(
"HTTP error code {}",
status_code

View file

@ -227,7 +227,7 @@ pub struct HTMLMediaElement {
#[ignore_malloc_size_of = "promises are hard"]
in_flight_play_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, ErrorResult)>>,
#[ignore_malloc_size_of = "servo_media"]
player: DomRefCell<Option<Box<Player>>>,
player: DomRefCell<Option<Box<dyn Player>>>,
#[ignore_malloc_size_of = "Arc"]
frame_renderer: Arc<Mutex<MediaFrameRenderer>>,
/// https://html.spec.whatwg.org/multipage/#show-poster-flag
@ -1223,7 +1223,7 @@ impl HTMLMediaElement {
};
let (action_sender, action_receiver) = ipc::channel().unwrap();
let renderer: Option<Arc<Mutex<FrameRenderer>>> = match self.media_type_id() {
let renderer: Option<Arc<Mutex<dyn FrameRenderer>>> = match self.media_type_id() {
HTMLMediaElementTypeId::HTMLAudioElement => None,
HTMLMediaElementTypeId::HTMLVideoElement => Some(self.frame_renderer.clone()),
};

View file

@ -198,7 +198,7 @@ impl FetchResponseListener for ScriptContext {
0 => Err(NetworkError::Internal(
"No http status code received".to_owned(),
)),
200...299 => Ok(()), // HTTP ok status codes
200..=299 => Ok(()), // HTTP ok status codes
_ => Err(NetworkError::Internal(format!(
"HTTP error code {}",
status_code

View file

@ -72,7 +72,7 @@ pub struct PaintWorkletGlobalScope {
worklet_global: WorkletGlobalScope,
/// The image cache
#[ignore_malloc_size_of = "Arc"]
image_cache: Arc<ImageCache>,
image_cache: Arc<dyn ImageCache>,
/// <https://drafts.css-houdini.org/css-paint-api/#paint-definitions>
paint_definitions: DomRefCell<HashMap<Atom, Box<PaintDefinition>>>,
/// <https://drafts.css-houdini.org/css-paint-api/#paint-class-instances>

View file

@ -19,8 +19,8 @@ pub trait Callback: JSTraceable + MallocSizeOf {
#[dom_struct]
pub struct PromiseNativeHandler {
reflector: Reflector,
resolve: Option<Box<Callback>>,
reject: Option<Box<Callback>>,
resolve: Option<Box<dyn Callback>>,
reject: Option<Box<dyn Callback>>,
}
impl PromiseNativeHandler {

View file

@ -203,7 +203,7 @@ impl RTCPeerConnection {
Ok(RTCPeerConnection::new(&window.global(), config))
}
fn make_signaller(&self) -> Box<WebRtcSignaller> {
fn make_signaller(&self) -> Box<dyn WebRtcSignaller> {
let trusted = Trusted::new(self);
let (task_source, canceller) = self
.global()

View file

@ -174,7 +174,7 @@ pub struct Window {
task_manager: TaskManager,
navigator: MutNullableDom<Navigator>,
#[ignore_malloc_size_of = "Arc"]
image_cache: Arc<ImageCache>,
image_cache: Arc<dyn ImageCache>,
#[ignore_malloc_size_of = "channels are hard"]
image_cache_chan: Sender<ImageCacheMsg>,
window_proxy: MutNullableDom<WindowProxy>,
@ -215,7 +215,7 @@ pub struct Window {
/// A handle to perform RPC calls into the layout, quickly.
#[ignore_malloc_size_of = "trait objects are hard"]
layout_rpc: Box<LayoutRPC + Send + 'static>,
layout_rpc: Box<dyn LayoutRPC + Send + 'static>,
/// The current size of the window, in pixels.
window_size: Cell<WindowSizeData>,

View file

@ -1668,7 +1668,7 @@ pub fn is_field_value(slice: &[u8]) -> bool {
false
}
},
0...31 | 127 => false, // CTLs
0..=31 | 127 => false, // CTLs
x if x > 127 => false, // non ASCII
_ if prev == PreviousCharacter::Other || prev == PreviousCharacter::SPHT => {
prev = PreviousCharacter::Other;

View file

@ -4,7 +4,6 @@
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
#![cfg_attr(feature = "unstable", feature(on_unimplemented))]
#![feature(borrow_state)]
#![feature(const_fn)]
#![feature(drain_filter)]
#![feature(inner_deref)]

View file

@ -508,8 +508,8 @@ unsafe_no_jsmanaged_fields!(RefCell<IncompleteParserContexts>);
unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>);
unsafe_no_jsmanaged_fields!(BackgroundHangMonitorRegister);
unsafe_no_jsmanaged_fields!(BackgroundHangMonitor);
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitorRegister);
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitor);
#[derive(JSTraceable)]
// ScriptThread instances are rooted on creation, so this is okay
@ -540,9 +540,9 @@ pub struct ScriptThread {
task_queue: TaskQueue<MainThreadScriptMsg>,
/// A handle to register associated layout threads for hang-monitoring.
background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
/// The dedicated means of communication with the background-hang-monitor for this script-thread.
background_hang_monitor: Box<BackgroundHangMonitor>,
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
/// A channel to hand out to script thread-based entities that need to be able to enqueue
/// events in the event queue.
@ -2337,7 +2337,7 @@ impl ScriptThread {
// 2. If response's status is 204 or 205, then abort these steps.
match metadata {
Some(Metadata {
status: Some((204...205, _)),
status: Some((204..=205, _)),
..
}) => {
// If we have an existing window that is being navigated:

View file

@ -221,7 +221,7 @@ pub struct LayoutThreadInit {
pub is_parent: bool,
pub layout_pair: (Sender<Msg>, Receiver<Msg>),
pub pipeline_port: IpcReceiver<LayoutControlMsg>,
pub background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
pub constellation_chan: IpcSender<ConstellationMsg>,
pub script_chan: IpcSender<ConstellationControlMsg>,
pub image_cache: Arc<dyn ImageCache>,

View file

@ -47,7 +47,7 @@ impl Error for ParentMismatchError {
"ParentMismatchError"
}
fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
None
}
}
@ -111,7 +111,7 @@ fn is_webidl_ty(symbols: &crate::Symbols, cx: &LateContext, ty: &ty::TyS) -> boo
ret
}
fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box<Error>> {
fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box<dyn Error>> {
let idl = weedle::parse(code).expect("Invalid webidl provided");
let mut inherits = "";
@ -156,7 +156,7 @@ fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box<E
}))
}
fn check_webidl(name: &str, parent_name: &Option<String>) -> Result<(), Box<Error>> {
fn check_webidl(name: &str, parent_name: &Option<String>) -> Result<(), Box<dyn Error>> {
let path = get_webidl_path(&name)?;
if let Some(parent) = parent_name {
let code = fs::read_to_string(path)?;

View file

@ -600,7 +600,7 @@ pub struct InitialScriptState {
/// A channel on which messages can be sent to the constellation from script.
pub script_to_constellation_chan: ScriptToConstellationChan,
/// A handle to register script-(and associated layout-)threads for hang monitoring.
pub background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
/// A sender for the layout thread to communicate to the constellation.
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
/// A channel to schedule timer events.

View file

@ -134,7 +134,7 @@ where
/// An optional hook function for checking whether a pseudo-element
/// should match when matching_mode is ForStatelessPseudoElement.
pub pseudo_element_matching_fn: Option<&'a Fn(&Impl::PseudoElement) -> bool>,
pub pseudo_element_matching_fn: Option<&'a dyn Fn(&Impl::PseudoElement) -> bool>,
/// Extra implementation-dependent matching data.
pub extra_data: Impl::ExtraMatchingData,

View file

@ -199,7 +199,7 @@ impl<Window> Servo<Window>
where
Window: WindowMethods + 'static + ?Sized,
{
pub fn new(mut embedder: Box<EmbedderMethods>, window: Rc<Window>) -> Servo<Window> {
pub fn new(mut embedder: Box<dyn EmbedderMethods>, window: Rc<Window>) -> Servo<Window> {
// Global configuration options, parsed from the command line.
let opts = opts::get();

View file

@ -471,7 +471,7 @@ fn compute_style_for_animation_step<E>(
step: &KeyframesStep,
previous_style: &ComputedValues,
style_from_cascade: &Arc<ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
@ -656,7 +656,7 @@ pub fn update_style_for_animation<E>(
context: &SharedStyleContext,
animation: &Animation,
style: &mut Arc<ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
) -> AnimationUpdate
where
E: TElement,

View file

@ -508,9 +508,9 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
fn hex(ch: char) -> Result<u8, ()> {
match ch {
'0'...'9' => Ok((ch as u8) - b'0'),
'a'...'f' => Ok((ch as u8) - b'a' + 10),
'A'...'F' => Ok((ch as u8) - b'A' + 10),
'0'..='9' => Ok((ch as u8) - b'0'),
'a'..='f' => Ok((ch as u8) - b'a' + 10),
'A'..='F' => Ok((ch as u8) - b'A' + 10),
_ => Err(()),
}
}
@ -550,7 +550,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
// Steps 6 & 7
match value.chars().nth(0) {
Some('0'...'9') => {},
Some('0'..='9') => {},
_ => return LengthOrPercentageOrAuto::Auto,
}
@ -565,7 +565,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
let (mut found_full_stop, mut found_percent) = (false, false);
for (i, ch) in value.chars().enumerate() {
match ch {
'0'...'9' => continue,
'0'..='9' => continue,
'%' => {
found_percent = true;
end_index = i;

View file

@ -181,7 +181,7 @@ pub struct SharedStyleContext<'a> {
/// Paint worklets
#[cfg(feature = "servo")]
pub registered_speculative_painters: &'a RegisteredSpeculativePainters,
pub registered_speculative_painters: &'a dyn RegisteredSpeculativePainters,
/// Data needed to create the thread-local style context from the shared one.
#[cfg(feature = "servo")]
@ -826,5 +826,5 @@ pub trait RegisteredSpeculativePainter: SpeculativePainter {
#[cfg(feature = "servo")]
pub trait RegisteredSpeculativePainters: Sync {
/// Look up a speculative painter
fn get(&self, name: &Atom) -> Option<&RegisteredSpeculativePainter>;
fn get(&self, name: &Atom) -> Option<&dyn RegisteredSpeculativePainter>;
}

View file

@ -63,8 +63,8 @@ impl Stylesheet {
origin: Origin,
media: MediaList,
shared_lock: SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
) -> Stylesheet {
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
@ -89,8 +89,8 @@ impl Stylesheet {
protocol_encoding_label: Option<&str>,
environment_encoding: Option<&'static encoding_rs::Encoding>,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
) {
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
Self::update_from_str(

View file

@ -582,7 +582,7 @@ trait PrivateMatchMethods: TElement {
context: &SharedStyleContext,
style: &mut Arc<ComputedValues>,
possibly_expired_animations: &mut Vec<crate::animation::PropertyAnimation>,
font_metrics: &crate::font_metrics::FontMetricsProvider,
font_metrics: &dyn crate::font_metrics::FontMetricsProvider,
) {
use crate::animation::{self, Animation, AnimationUpdate};
use crate::dom::TNode;

View file

@ -51,7 +51,7 @@ pub struct ParserContext<'a> {
/// The quirks mode of this stylesheet.
pub quirks_mode: QuirksMode,
/// The active error reporter, or none if error reporting is disabled.
error_reporter: Option<&'a ParseErrorReporter>,
error_reporter: Option<&'a dyn ParseErrorReporter>,
/// The currently active namespaces.
pub namespaces: Option<&'a Namespaces>,
/// The use counters we want to record while parsing style rules, if any.
@ -67,7 +67,7 @@ impl<'a> ParserContext<'a> {
rule_type: Option<CssRuleType>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode,
error_reporter: Option<&'a ParseErrorReporter>,
error_reporter: Option<&'a dyn ParseErrorReporter>,
use_counters: Option<&'a UseCounters>,
) -> Self {
Self {
@ -89,7 +89,7 @@ impl<'a> ParserContext<'a> {
rule_type: Option<CssRuleType>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode,
error_reporter: Option<&'a ParseErrorReporter>,
error_reporter: Option<&'a dyn ParseErrorReporter>,
use_counters: Option<&'a UseCounters>,
) -> Self {
Self::new(

View file

@ -82,7 +82,7 @@ pub fn cascade<E>(
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
visited_rules: Option<&StrongRuleNode>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
quirks_mode: QuirksMode,
rule_cache: Option<&RuleCache>,
rule_cache_conditions: &mut RuleCacheConditions,
@ -116,7 +116,7 @@ fn cascade_rules<E>(
parent_style: Option<&ComputedValues>,
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
cascade_mode: CascadeMode,
quirks_mode: QuirksMode,
rule_cache: Option<&RuleCache>,
@ -213,7 +213,7 @@ pub fn apply_declarations<'a, E, F, I>(
parent_style: Option<&ComputedValues>,
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
cascade_mode: CascadeMode,
quirks_mode: QuirksMode,
rule_cache: Option<&RuleCache>,

View file

@ -1199,7 +1199,7 @@ where
pub fn parse_style_attribute(
input: &str,
url_data: &UrlExtraData,
error_reporter: Option<&ParseErrorReporter>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
) -> PropertyDeclarationBlock {
let context = ParserContext::new(
@ -1226,7 +1226,7 @@ pub fn parse_one_declaration_into(
id: PropertyId,
input: &str,
url_data: &UrlExtraData,
error_reporter: Option<&ParseErrorReporter>,
error_reporter: Option<&dyn ParseErrorReporter>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode
) -> Result<(), ()> {

View file

@ -60,7 +60,7 @@ pub fn split_commas<'a>(s: &'a str) -> Filter<Split<'a, char>, fn(&&str) -> bool
/// Character is ascii digit
pub fn is_ascii_digit(c: &char) -> bool {
match *c {
'0'...'9' => true,
'0'..='9' => true,
_ => false,
}
}
@ -161,7 +161,7 @@ pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
/// Returns an ascii lowercase version of a string, only allocating if needed.
pub fn string_as_ascii_lowercase<'a>(input: &'a str) -> Cow<'a, str> {
if input.bytes().any(|c| matches!(c, b'A'...b'Z')) {
if input.bytes().any(|c| matches!(c, b'A'..=b'Z')) {
input.to_ascii_lowercase().into()
} else {
// Already ascii lowercase.

View file

@ -352,7 +352,7 @@ impl CssRule {
parent_stylesheet_contents: &StylesheetContents,
shared_lock: &SharedRwLock,
state: State,
loader: Option<&StylesheetLoader>,
loader: Option<&dyn StylesheetLoader>,
) -> Result<Self, RulesMutateError> {
let url_data = parent_stylesheet_contents.url_data.read();
let context = ParserContext::new(

View file

@ -127,7 +127,7 @@ pub trait CssRulesHelpers {
parent_stylesheet_contents: &StylesheetContents,
index: usize,
nested: bool,
loader: Option<&StylesheetLoader>,
loader: Option<&dyn StylesheetLoader>,
) -> Result<CssRule, RulesMutateError>;
}
@ -139,7 +139,7 @@ impl CssRulesHelpers for RawOffsetArc<Locked<CssRules>> {
parent_stylesheet_contents: &StylesheetContents,
index: usize,
nested: bool,
loader: Option<&StylesheetLoader>,
loader: Option<&dyn StylesheetLoader>,
) -> Result<CssRule, RulesMutateError> {
let new_rule = {
let read_guard = lock.read();

View file

@ -44,7 +44,7 @@ pub struct TopLevelRuleParser<'a> {
/// A reference to the lock we need to use to create rules.
pub shared_lock: &'a SharedRwLock,
/// A reference to a stylesheet loader if applicable, for `@import` rules.
pub loader: Option<&'a StylesheetLoader>,
pub loader: Option<&'a dyn StylesheetLoader>,
/// The top-level parser context.
///
/// This won't contain any namespaces, and only nested parsers created with

View file

@ -76,8 +76,8 @@ impl StylesheetContents {
url_data: UrlExtraData,
origin: Origin,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
use_counters: Option<&UseCounters>,
@ -343,8 +343,8 @@ impl Stylesheet {
existing: &Stylesheet,
css: &str,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
line_number_offset: u32,
) {
let namespaces = RwLock::new(Namespaces::default());
@ -382,8 +382,8 @@ impl Stylesheet {
origin: Origin,
namespaces: &mut Namespaces,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
use_counters: Option<&UseCounters>,
@ -450,8 +450,8 @@ impl Stylesheet {
origin: Origin,
media: Arc<Locked<MediaList>>,
shared_lock: SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
) -> Self {

View file

@ -650,7 +650,7 @@ impl Stylist {
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
@ -678,7 +678,7 @@ impl Stylist {
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
rules: StrongRuleNode,
) -> Arc<ComputedValues>
where
@ -773,8 +773,8 @@ impl Stylist {
rule_inclusion: RuleInclusion,
parent_style: &ComputedValues,
is_probe: bool,
font_metrics: &FontMetricsProvider,
matching_fn: Option<&Fn(&PseudoElement) -> bool>,
font_metrics: &dyn FontMetricsProvider,
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<Arc<ComputedValues>>
where
E: TElement,
@ -809,7 +809,7 @@ impl Stylist {
pseudo: &PseudoElement,
guards: &StylesheetGuards,
parent_style: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
element: Option<E>,
) -> Arc<ComputedValues>
where
@ -862,7 +862,7 @@ impl Stylist {
parent_style: Option<&ComputedValues>,
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
rule_cache: Option<&RuleCache>,
rule_cache_conditions: &mut RuleCacheConditions,
) -> Arc<ComputedValues>
@ -919,7 +919,7 @@ impl Stylist {
pseudo: &PseudoElement,
is_probe: bool,
rule_inclusion: RuleInclusion,
matching_fn: Option<&Fn(&PseudoElement) -> bool>,
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<CascadeInputs>
where
E: TElement,

View file

@ -147,7 +147,7 @@ pub struct Context<'a> {
/// A font metrics provider, used to access font metrics to implement
/// font-relative units.
pub font_metrics_provider: &'a FontMetricsProvider,
pub font_metrics_provider: &'a dyn FontMetricsProvider,
/// Whether or not we are computing the media list in a media query
pub in_media_query: bool,

View file

@ -27,7 +27,7 @@ pub mod CssType {
}
/// See SpecifiedValueInfo::collect_completion_keywords.
pub type KeywordsCollectFn<'a> = &'a mut FnMut(&[&'static str]);
pub type KeywordsCollectFn<'a> = &'a mut dyn FnMut(&[&'static str]);
/// Information of values of a given specified value type.
///

View file

@ -21,9 +21,9 @@ use std::rc::Rc;
pub struct App {
events_loop: Rc<RefCell<EventsLoop>>,
window: Rc<WindowPortsMethods>,
servo: RefCell<Servo<WindowPortsMethods>>,
browser: RefCell<Browser<WindowPortsMethods>>,
window: Rc<dyn WindowPortsMethods>,
servo: RefCell<Servo<dyn WindowPortsMethods>>,
browser: RefCell<Browser<dyn WindowPortsMethods>>,
event_queue: RefCell<Vec<WindowEvent>>,
suspended: Cell<bool>,
}

View file

@ -24,7 +24,7 @@ pub struct EmbedderCallbacks {
}
impl EmbedderCallbacks {
pub fn new(events_loop: Rc<RefCell<EventsLoop>>, gl: Rc<gl::Gl>) -> EmbedderCallbacks {
pub fn new(events_loop: Rc<RefCell<EventsLoop>>, gl: Rc<dyn gl::Gl>) -> EmbedderCallbacks {
EmbedderCallbacks { events_loop, gl }
}
}
@ -37,7 +37,7 @@ impl EmbedderMethods for EmbedderCallbacks {
fn register_vr_services(
&mut self,
services: &mut VRServiceManager,
heartbeats: &mut Vec<Box<WebVRMainThreadHeartbeat>>,
heartbeats: &mut Vec<Box<dyn WebVRMainThreadHeartbeat>>,
) {
if !opts::get().headless {
if pref!(dom.webvr.test) {

View file

@ -393,7 +393,7 @@ enum ScrollState {
struct EventLoopWakerInstance;
impl EventLoopWaker for EventLoopWakerInstance {
fn clone(&self) -> Box<EventLoopWaker + Send> {
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
Box::new(EventLoopWakerInstance)
}

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 https://mozilla.org/MPL/2.0/. */
#![allow(bare_trait_objects)] // Until https://github.com/brendanzab/gl-rs/pull/493
pub type ServoGl = std::rc::Rc<dyn servo::gl::Gl>;
#[cfg(any(target_os = "android", target_os = "windows"))]

View file

@ -52,7 +52,7 @@ pub struct InitOptions {
pub enum VRInitOptions {
None,
VRExternal(*mut c_void),
VRService(Box<VRService>, Box<VRMainThreadHeartbeat>),
VRService(Box<dyn VRService>, Box<dyn VRMainThreadHeartbeat>),
}
#[derive(Clone, Debug)]
@ -571,7 +571,7 @@ impl EmbedderMethods for ServoEmbedderCallbacks {
fn register_vr_services(
&mut self,
services: &mut VRServiceManager,
heartbeats: &mut Vec<Box<VRMainThreadHeartbeat>>,
heartbeats: &mut Vec<Box<dyn VRMainThreadHeartbeat>>,
) {
debug!("EmbedderMethods::register_vrexternal");
match mem::replace(&mut self.vr_init, VRInitOptions::None) {

View file

@ -337,7 +337,7 @@ impl WakeupCallback {
}
impl EventLoopWaker for WakeupCallback {
fn clone(&self) -> Box<EventLoopWaker + Send> {
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
Box::new(WakeupCallback {
callback: self.callback.clone(),
jvm: self.jvm.clone(),