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::{
api::units::*, api::*, create_webrender_instance, render_api::*, set_profiler_hooks, AsyncPropertySampler,
AsyncScreenshotHandle, Compositor, LayerCompositor, CompositorCapabilities, CompositorConfig, CompositorSurfaceTransform, Device,
MappableCompositor, MappedTileInfo, NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PartialPresentCompositor,
PendingShadersToPrecache, PipelineInfo, ProfilerHooks, RecordedFrameHandle, RenderBackendHooks, Renderer, RendererStats,
ClipRadius, SWGLCompositeSurfaceInfo, SceneBuilderHooks, ShaderPrecacheFlags, Shaders, SharedShaders, TextureCacheConfig,
UploadMethod, WebRenderOptions, WindowVisibility, WindowProperties, ONE_TIME_USAGE_HINT, CompositorInputConfig, CompositorSurfaceUsage,
AsyncScreenshotHandle, ClipRadius, Compositor, CompositorCapabilities, CompositorConfig, CompositorInputConfig,
CompositorSurfaceTransform, CompositorSurfaceUsage, Device, LayerCompositor, MappableCompositor, MappedTileInfo,
NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PartialPresentCompositor, PendingShadersToPrecache, PipelineInfo,
ProfilerHooks, RecordedFrameHandle, RenderBackendHooks, Renderer, RendererStats, SWGLCompositeSurfaceInfo,
SceneBuilderHooks, ShaderPrecacheFlags, Shaders, SharedShaders, TextureCacheConfig, UploadMethod, WebRenderOptions,
WindowProperties, WindowVisibility, ONE_TIME_USAGE_HINT,
};
use wr_malloc_size_of::MallocSizeOfOps;
@@ -1543,11 +1544,7 @@ impl WrLayerCompositor {
impl LayerCompositor for WrLayerCompositor {
// Begin compositing a frame with the supplied input config
fn begin_frame(
&mut self,
input: &CompositorInputConfig,
) {
fn begin_frame(&mut self, input: &CompositorInputConfig) {
if self.enable_screenshot != input.enable_screenshot {
let mut layers_to_destroy = Vec::new();
mem::swap(&mut self.surface_pool, &mut layers_to_destroy);
@@ -1568,10 +1565,10 @@ impl LayerCompositor for WrLayerCompositor {
for request in input.layers {
let size = request.clip_rect.size();
let existing_index = self.surface_pool.iter().position(|layer| {
layer.is_opaque == request.is_opaque &&
layer.usage.matches(&request.usage)
});
let existing_index = self
.surface_pool
.iter()
.position(|layer| layer.is_opaque == request.is_opaque && layer.usage.matches(&request.usage));
let mut layer = match existing_index {
Some(existing_index) => {
@@ -1583,7 +1580,7 @@ impl LayerCompositor for WrLayerCompositor {
layer.usage = request.usage;
layer
}
},
None => {
let id = NativeSurfaceId(self.next_layer_id);
self.next_layer_id += 1;
@@ -1591,20 +1588,11 @@ impl LayerCompositor for WrLayerCompositor {
unsafe {
match request.usage {
CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {
wr_compositor_create_swapchain_surface(
self.compositor,
id,
size,
request.is_opaque,
);
}
wr_compositor_create_swapchain_surface(self.compositor, id, size, request.is_opaque);
},
CompositorSurfaceUsage::External { .. } => {
wr_compositor_create_external_surface(
self.compositor,
id,
request.is_opaque,
);
}
wr_compositor_create_external_surface(self.compositor, id, request.is_opaque);
},
}
}
@@ -1615,31 +1603,21 @@ impl LayerCompositor for WrLayerCompositor {
frames_since_used: 0,
usage: request.usage,
}
}
},
};
match layer.usage {
CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {
if layer.size.width != size.width || layer.size.height != size.height {
unsafe {
wr_compositor_resize_swapchain(
self.compositor,
layer.id,
size
);
wr_compositor_resize_swapchain(self.compositor, layer.id, size);
}
layer.size = size;
}
}
CompositorSurfaceUsage::External { external_image_id, .. } => {
unsafe {
wr_compositor_attach_external_image(
self.compositor,
layer.id,
external_image_id,
);
}
}
},
CompositorSurfaceUsage::External { external_image_id, .. } => unsafe {
wr_compositor_attach_external_image(self.compositor, layer.id, external_image_id);
},
}
self.visual_tree.push(layer);
@@ -1655,10 +1633,7 @@ impl LayerCompositor for WrLayerCompositor {
let layer = &self.visual_tree[index];
unsafe {
wr_compositor_bind_swapchain(
self.compositor,
layer.id,
);
wr_compositor_bind_swapchain(self.compositor, layer.id);
}
}
@@ -1667,10 +1642,7 @@ impl LayerCompositor for WrLayerCompositor {
let layer = &self.visual_tree[index];
unsafe {
wr_compositor_present_swapchain(
self.compositor,
layer.id,
);
wr_compositor_present_swapchain(self.compositor, layer.id);
}
}
@@ -1961,10 +1933,10 @@ pub extern "C" fn wr_window_new(
CompositorConfig::Native {
compositor: Box::new(SwCompositor::new(
sw_gl.unwrap(),
Box::new(WrCompositor(compositor)),
use_native_compositor,
)),
}
Box::new(WrCompositor(compositor)),
use_native_compositor,
)),
}
} else if use_native_compositor {
if use_layer_compositor {
CompositorConfig::Layer {
@@ -4498,7 +4470,9 @@ pub extern "C" fn wr_shaders_new(
#[no_mangle]
pub unsafe extern "C" fn wr_shaders_delete(shaders: *mut WrShaders) {
// 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) {
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 {
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,
Err(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
// the rest of the shaders.
false
}
},
};
shaders.device.end_frame();

View File

@@ -131,9 +131,9 @@ fn convert_directive(
ModuleDefinition(wast::QuoteWat::Wat(wast::Wat::Module(module))) => {
let module_text = module_definition_to_js_string(&module, wast)?;
if let Some(id) = module.id {
writeln!(out, "let ${} = module(`{}`);", id.name(), module_text)?;
writeln!(out, "let ${} = module(`{}`);", id.name(), module_text)?;
} else {
writeln!(out, "let _ = module(`{}`);", module_text)?;
writeln!(out, "let _ = module(`{}`);", module_text)?;
}
}
ModuleDefinition(..) => bail!("unsupported module definition...definition"),

View File

@@ -674,7 +674,11 @@ impl DataStorageInner {
for entry in self.private_slots.iter().filter(|entry| !entry.is_empty()) {
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);
}
}

View File

@@ -501,7 +501,8 @@ mod test {
fn run_handler_storage_test(package: &str, storage: AndroidStorageInput) {
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.marionette_host_port, 4242);

View File

@@ -283,7 +283,12 @@ impl RemoteBrowser {
) -> WebDriverResult<RemoteBrowser> {
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.
let (mut profile, is_custom_profile) = match options.profile {

View File

@@ -306,7 +306,9 @@ pub mod platform {
/// Searches the system path for `firefox`.
pub fn firefox_default_path() -> Option<PathBuf> {
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")
}
@@ -359,7 +361,9 @@ pub mod platform {
#[test]
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();

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 std::collections::HashMap;
use std::collections::HashMap;
use url::Url;
// Custom Handle type which trivially wraps an i64.

View File

@@ -3,8 +3,8 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use nix::{
errno::Errno,
poll::{poll, PollFd, PollFlags, PollTimeout},
errno::Errno,
poll::{poll, PollFd, PollFlags, PollTimeout},
};
use crate::{errors::IPCError, ignore_eintr, IPCConnector, IPCEvent, IPCListener};