Bug 1617369 - Reformat recent rust changes with rustfmt r=emilio,webdriver-reviewers,whimboo

Updated with rustfmt 1.8.0-stable (17067e9ac6 2025-05-09)

Differential Revision: https://phabricator.services.mozilla.com/D249881
This commit is contained in:
Sylvestre Ledru
2025-05-21 16:44:09 +00:00
committed by sledru@mozilla.com
parent c678da6424
commit 01c27257dc
8 changed files with 61 additions and 69 deletions

View File

@@ -38,11 +38,12 @@ use tracy_rs::register_thread_with_profiler;
use webrender::sw_compositor::SwCompositor; use webrender::sw_compositor::SwCompositor;
use webrender::{ use webrender::{
api::units::*, api::*, create_webrender_instance, render_api::*, set_profiler_hooks, AsyncPropertySampler, api::units::*, api::*, create_webrender_instance, render_api::*, set_profiler_hooks, AsyncPropertySampler,
AsyncScreenshotHandle, Compositor, LayerCompositor, CompositorCapabilities, CompositorConfig, CompositorSurfaceTransform, Device, AsyncScreenshotHandle, ClipRadius, Compositor, CompositorCapabilities, CompositorConfig, CompositorInputConfig,
MappableCompositor, MappedTileInfo, NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PartialPresentCompositor, CompositorSurfaceTransform, CompositorSurfaceUsage, Device, LayerCompositor, MappableCompositor, MappedTileInfo,
PendingShadersToPrecache, PipelineInfo, ProfilerHooks, RecordedFrameHandle, RenderBackendHooks, Renderer, RendererStats, NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PartialPresentCompositor, PendingShadersToPrecache, PipelineInfo,
ClipRadius, SWGLCompositeSurfaceInfo, SceneBuilderHooks, ShaderPrecacheFlags, Shaders, SharedShaders, TextureCacheConfig, ProfilerHooks, RecordedFrameHandle, RenderBackendHooks, Renderer, RendererStats, SWGLCompositeSurfaceInfo,
UploadMethod, WebRenderOptions, WindowVisibility, WindowProperties, ONE_TIME_USAGE_HINT, CompositorInputConfig, CompositorSurfaceUsage, SceneBuilderHooks, ShaderPrecacheFlags, Shaders, SharedShaders, TextureCacheConfig, UploadMethod, WebRenderOptions,
WindowProperties, WindowVisibility, ONE_TIME_USAGE_HINT,
}; };
use wr_malloc_size_of::MallocSizeOfOps; use wr_malloc_size_of::MallocSizeOfOps;
@@ -1543,11 +1544,7 @@ impl WrLayerCompositor {
impl LayerCompositor for WrLayerCompositor { impl LayerCompositor for WrLayerCompositor {
// Begin compositing a frame with the supplied input config // Begin compositing a frame with the supplied input config
fn begin_frame( fn begin_frame(&mut self, input: &CompositorInputConfig) {
&mut self,
input: &CompositorInputConfig,
) {
if self.enable_screenshot != input.enable_screenshot { if self.enable_screenshot != input.enable_screenshot {
let mut layers_to_destroy = Vec::new(); let mut layers_to_destroy = Vec::new();
mem::swap(&mut self.surface_pool, &mut layers_to_destroy); mem::swap(&mut self.surface_pool, &mut layers_to_destroy);
@@ -1568,10 +1565,10 @@ impl LayerCompositor for WrLayerCompositor {
for request in input.layers { for request in input.layers {
let size = request.clip_rect.size(); let size = request.clip_rect.size();
let existing_index = self.surface_pool.iter().position(|layer| { let existing_index = self
layer.is_opaque == request.is_opaque && .surface_pool
layer.usage.matches(&request.usage) .iter()
}); .position(|layer| layer.is_opaque == request.is_opaque && layer.usage.matches(&request.usage));
let mut layer = match existing_index { let mut layer = match existing_index {
Some(existing_index) => { Some(existing_index) => {
@@ -1583,7 +1580,7 @@ impl LayerCompositor for WrLayerCompositor {
layer.usage = request.usage; layer.usage = request.usage;
layer layer
} },
None => { None => {
let id = NativeSurfaceId(self.next_layer_id); let id = NativeSurfaceId(self.next_layer_id);
self.next_layer_id += 1; self.next_layer_id += 1;
@@ -1591,20 +1588,11 @@ impl LayerCompositor for WrLayerCompositor {
unsafe { unsafe {
match request.usage { match request.usage {
CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => { CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {
wr_compositor_create_swapchain_surface( wr_compositor_create_swapchain_surface(self.compositor, id, size, request.is_opaque);
self.compositor, },
id,
size,
request.is_opaque,
);
}
CompositorSurfaceUsage::External { .. } => { CompositorSurfaceUsage::External { .. } => {
wr_compositor_create_external_surface( wr_compositor_create_external_surface(self.compositor, id, request.is_opaque);
self.compositor, },
id,
request.is_opaque,
);
}
} }
} }
@@ -1615,31 +1603,21 @@ impl LayerCompositor for WrLayerCompositor {
frames_since_used: 0, frames_since_used: 0,
usage: request.usage, usage: request.usage,
} }
} },
}; };
match layer.usage { match layer.usage {
CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => { CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {
if layer.size.width != size.width || layer.size.height != size.height { if layer.size.width != size.width || layer.size.height != size.height {
unsafe { unsafe {
wr_compositor_resize_swapchain( wr_compositor_resize_swapchain(self.compositor, layer.id, size);
self.compositor,
layer.id,
size
);
} }
layer.size = size; layer.size = size;
} }
} },
CompositorSurfaceUsage::External { external_image_id, .. } => { CompositorSurfaceUsage::External { external_image_id, .. } => unsafe {
unsafe { wr_compositor_attach_external_image(self.compositor, layer.id, external_image_id);
wr_compositor_attach_external_image( },
self.compositor,
layer.id,
external_image_id,
);
}
}
} }
self.visual_tree.push(layer); self.visual_tree.push(layer);
@@ -1655,10 +1633,7 @@ impl LayerCompositor for WrLayerCompositor {
let layer = &self.visual_tree[index]; let layer = &self.visual_tree[index];
unsafe { unsafe {
wr_compositor_bind_swapchain( wr_compositor_bind_swapchain(self.compositor, layer.id);
self.compositor,
layer.id,
);
} }
} }
@@ -1667,10 +1642,7 @@ impl LayerCompositor for WrLayerCompositor {
let layer = &self.visual_tree[index]; let layer = &self.visual_tree[index];
unsafe { unsafe {
wr_compositor_present_swapchain( wr_compositor_present_swapchain(self.compositor, layer.id);
self.compositor,
layer.id,
);
} }
} }
@@ -4498,7 +4470,9 @@ pub extern "C" fn wr_shaders_new(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn wr_shaders_delete(shaders: *mut WrShaders) { pub unsafe extern "C" fn wr_shaders_delete(shaders: *mut WrShaders) {
// Deallocate the box by moving the values out of it. // Deallocate the box by moving the values out of it.
let WrShaders { shaders, mut device, .. } = *Box::from_raw(shaders); let WrShaders {
shaders, mut device, ..
} = *Box::from_raw(shaders);
if let Ok(shaders) = Rc::try_unwrap(shaders) { if let Ok(shaders) = Rc::try_unwrap(shaders) {
shaders.into_inner().deinit(&mut device); shaders.into_inner().deinit(&mut device);
} }
@@ -4511,7 +4485,11 @@ pub unsafe extern "C" fn wr_shaders_delete(shaders: *mut WrShaders) {
pub extern "C" fn wr_shaders_resume_warmup(shaders: &mut WrShaders) -> bool { pub extern "C" fn wr_shaders_resume_warmup(shaders: &mut WrShaders) -> bool {
shaders.device.begin_frame(); shaders.device.begin_frame();
let need_another_call = match shaders.shaders.borrow_mut().resume_precache(&mut shaders.device, &mut shaders.shaders_to_precache) { let need_another_call = match shaders
.shaders
.borrow_mut()
.resume_precache(&mut shaders.device, &mut shaders.shaders_to_precache)
{
Ok(need_another_call) => need_another_call, Ok(need_another_call) => need_another_call,
Err(e) => { Err(e) => {
warn!(" Failed to create a shader during warmup: {:?}", e); warn!(" Failed to create a shader during warmup: {:?}", e);
@@ -4524,7 +4502,7 @@ pub extern "C" fn wr_shaders_resume_warmup(shaders: &mut WrShaders) -> bool {
// to compile it's likely that we will run into similar errors with // to compile it's likely that we will run into similar errors with
// the rest of the shaders. // the rest of the shaders.
false false
} },
}; };
shaders.device.end_frame(); shaders.device.end_frame();

View File

@@ -674,7 +674,11 @@ impl DataStorageInner {
for entry in self.private_slots.iter().filter(|entry| !entry.is_empty()) { for entry in self.private_slots.iter().filter(|entry| !entry.is_empty()) {
f(entry, DataType::Private); f(entry, DataType::Private);
} }
for entry in self.temporary_slots.iter().filter(|entry| !entry.is_empty()) { for entry in self
.temporary_slots
.iter()
.filter(|entry| !entry.is_empty())
{
f(entry, DataType::Temporary); f(entry, DataType::Temporary);
} }
} }

View File

@@ -501,7 +501,8 @@ mod test {
fn run_handler_storage_test(package: &str, storage: AndroidStorageInput) { fn run_handler_storage_test(package: &str, storage: AndroidStorageInput) {
let options = AndroidOptions::new(package.to_owned(), storage); let options = AndroidOptions::new(package.to_owned(), storage);
let handler = AndroidHandler::new(&options, 4242, true, None).expect("has valid Android handler"); let handler =
AndroidHandler::new(&options, 4242, true, None).expect("has valid Android handler");
assert_eq!(handler.options, options); assert_eq!(handler.options, options);
assert_eq!(handler.marionette_host_port, 4242); assert_eq!(handler.marionette_host_port, 4242);

View File

@@ -283,7 +283,12 @@ impl RemoteBrowser {
) -> WebDriverResult<RemoteBrowser> { ) -> WebDriverResult<RemoteBrowser> {
let android_options = options.android.unwrap(); let android_options = options.android.unwrap();
let handler = AndroidHandler::new(&android_options, marionette_port, system_access, websocket_port)?; let handler = AndroidHandler::new(
&android_options,
marionette_port,
system_access,
websocket_port,
)?;
// Profile management. // Profile management.
let (mut profile, is_custom_profile) = match options.profile { let (mut profile, is_custom_profile) = match options.profile {

View File

@@ -306,7 +306,9 @@ pub mod platform {
/// Searches the system path for `firefox`. /// Searches the system path for `firefox`.
pub fn firefox_default_path() -> Option<PathBuf> { pub fn firefox_default_path() -> Option<PathBuf> {
if running_as_snap() { if running_as_snap() {
return Some(PathBuf::from("/snap/firefox/current/usr/lib/firefox/firefox")); return Some(PathBuf::from(
"/snap/firefox/current/usr/lib/firefox/firefox",
));
} }
find_binary("firefox") find_binary("firefox")
} }
@@ -359,7 +361,9 @@ pub mod platform {
#[test] #[test]
fn test_default_path() { fn test_default_path() {
let snap_path = Some(PathBuf::from("/snap/firefox/current/usr/lib/firefox/firefox")); let snap_path = Some(PathBuf::from(
"/snap/firefox/current/usr/lib/firefox/firefox",
));
let snap_env = SnapEnvironment::new(); let snap_env = SnapEnvironment::new();