diff options
-rw-r--r-- | components/canvas/canvas_data.rs | 3 | ||||
-rw-r--r-- | components/canvas/raqote_backend.rs | 8 | ||||
-rw-r--r-- | components/canvas/webgl_thread.rs | 8 | ||||
-rw-r--r-- | components/compositing/compositor.rs | 55 | ||||
-rw-r--r-- | components/compositing/gl.rs | 2 | ||||
-rw-r--r-- | components/compositing/touch.rs | 5 | ||||
-rw-r--r-- | components/compositing/windowing.rs | 2 | ||||
-rw-r--r-- | components/constellation/sandboxing.rs | 1 | ||||
-rw-r--r-- | components/gfx/font_cache_thread.rs | 2 | ||||
-rw-r--r-- | components/metrics/lib.rs | 18 | ||||
-rw-r--r-- | components/script/dom/document.rs | 2 | ||||
-rw-r--r-- | components/webdriver_server/actions.rs | 23 | ||||
-rw-r--r-- | components/webdriver_server/lib.rs | 44 | ||||
-rw-r--r-- | components/webgpu/lib.rs | 12 |
14 files changed, 87 insertions, 98 deletions
diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 59a0fed8345..7525574a927 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -114,6 +114,7 @@ pub trait GenericPathBuilder { control_point3: &Point2D<f32>, ); fn close(&mut self); + #[allow(clippy::too_many_arguments)] fn ellipse( &mut self, origin: Point2D<f32>, @@ -195,6 +196,7 @@ impl<'a> PathBuilderRef<'a> { .arc(center, radius, start_angle, end_angle, ccw); } + #[allow(clippy::too_many_arguments)] pub fn ellipse( &mut self, center: &Point2D<f32>, @@ -978,6 +980,7 @@ impl<'a> CanvasData<'a> { } } + #[allow(clippy::too_many_arguments)] pub fn ellipse( &mut self, center: &Point2D<f32>, diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 902f535e42f..aa3737897eb 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -670,7 +670,7 @@ impl GenericDrawTarget for raqote::DrawTarget { } impl Filter { - fn to_raqote(&self) -> raqote::FilterMode { + fn to_raqote(self) -> raqote::FilterMode { match self { Filter::Bilinear => raqote::FilterMode::Bilinear, Filter::Nearest => raqote::FilterMode::Nearest, @@ -847,7 +847,7 @@ pub trait ToRaqotePattern<'a> { } pub trait ToRaqoteGradientStop { - fn to_raqote(&self) -> raqote::GradientStop; + fn to_raqote(self) -> raqote::GradientStop; } /// Clamp a 0..1 number to a 0..255 range to u8. @@ -878,7 +878,7 @@ pub fn clamp_floor_256_f32(val: f32) -> u8 { } impl ToRaqoteGradientStop for CanvasGradientStop { - fn to_raqote(&self) -> raqote::GradientStop { + fn to_raqote(self) -> raqote::GradientStop { let color = raqote::Color::new( self.color.alpha.map(clamp_unit_f32).unwrap_or(0), self.color.red.unwrap_or(0), @@ -890,7 +890,7 @@ impl ToRaqoteGradientStop for CanvasGradientStop { } } -impl<'a> ToRaqotePattern<'_> for FillOrStrokeStyle { +impl ToRaqotePattern<'_> for FillOrStrokeStyle { #[allow(unsafe_code)] fn to_raqote_pattern(self) -> Option<Pattern<'static>> { use canvas_traits::canvas::FillOrStrokeStyle::*; diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 7362b61e9f4..835056591d3 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -2514,8 +2514,8 @@ fn to_name_in_compiled_shader(s: &str) -> String { fn from_name_in_compiled_shader(s: &str) -> String { map_dot_separated(s, |s, mapped| { - mapped.push_str(if s.starts_with(ANGLE_NAME_PREFIX) { - &s[ANGLE_NAME_PREFIX.len()..] + mapped.push_str(if let Some(stripped) = s.strip_prefix(ANGLE_NAME_PREFIX) { + stripped } else { s }) @@ -2533,6 +2533,7 @@ fn map_dot_separated<F: Fn(&str, &mut String)>(s: &str, f: F) -> String { mapped } +#[allow(clippy::too_many_arguments)] fn prepare_pixels( internal_format: TexFormat, data_type: TexDataType, @@ -3100,7 +3101,8 @@ impl WebXRBridge { contexts: &mut dyn WebXRContexts<WebXRSurfman>, context_id: WebXRContextId, ) { - for (_, manager) in &mut self.managers { + for manager in self.managers.values_mut() { + #[allow(clippy::unnecessary_to_owned)] // Needs mutable borrow later in destroy for (other_id, layer_id) in manager.layers().to_vec() { if other_id == context_id { manager.destroy_layer(device, contexts, context_id, layer_id); diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index fbee79dc232..93822053d69 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -42,7 +42,6 @@ use script_traits::{ }; use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength}; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; -use webrender; use webrender::{CaptureBits, RenderApi, Transaction}; use webrender_api::units::{ DeviceIntPoint, DeviceIntSize, DevicePoint, LayoutPoint, LayoutRect, LayoutSize, @@ -79,6 +78,7 @@ const MAX_ZOOM: f32 = 8.0; const MIN_ZOOM: f32 = 0.1; trait ConvertPipelineIdFromWebRender { + #[allow(clippy::wrong_self_convention)] fn from_webrender(&self) -> PipelineId; } @@ -919,10 +919,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { } fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails { - if !self.pipeline_details.contains_key(&pipeline_id) { - self.pipeline_details - .insert(pipeline_id, PipelineDetails::new()); - } + self.pipeline_details + .entry(pipeline_id) + .or_insert_with(PipelineDetails::new); self.pipeline_details .get_mut(&pipeline_id) .expect("Insert then get failed!") @@ -930,7 +929,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> { match self.pipeline_details.get(&pipeline_id) { - Some(ref details) => details.pipeline.as_ref(), + Some(details) => details.pipeline.as_ref(), None => { warn!( "Compositor layer has an unknown pipeline ({:?}).", @@ -1021,8 +1020,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { self.webrender_api .send_transaction(self.webrender_document, txn); - self.create_pipeline_details_for_frame_tree(&frame_tree); - self.reset_scroll_tree_for_unattached_pipelines(&frame_tree); + self.create_pipeline_details_for_frame_tree(frame_tree); + self.reset_scroll_tree_for_unattached_pipelines(frame_tree); self.frame_tree_id.next(); } @@ -1081,7 +1080,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { let data = WindowSizeData { device_pixel_ratio: dppx, - initial_viewport: initial_viewport, + initial_viewport, }; let top_level_browsing_context_id = @@ -1118,7 +1117,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { self.send_window_size(WindowSizeType::Resize); self.composite_if_necessary(CompositingReason::Resize); - return true; + true } pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) { @@ -1171,7 +1170,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { let dppx = self.page_zoom * self.hidpi_factor(); let scaled_point = (point / dppx).to_untyped(); let world_point = WorldPoint::from_untyped(scaled_point); - return self.hit_test_at_point(world_point); + self.hit_test_at_point(world_point) } fn hit_test_at_point(&self, point: WorldPoint) -> Option<CompositorHitTestResult> { @@ -1320,7 +1319,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { scroll_location: ScrollLocation::Delta(LayoutVector2D::from_untyped( scroll_delta.to_untyped(), )), - cursor: cursor, + cursor, event_count: 1, })); }, @@ -1378,7 +1377,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { fn on_scroll_window_event(&mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint) { self.pending_scroll_zoom_events .push(ScrollZoomEvent::Scroll(ScrollEvent { - scroll_location: scroll_location, + scroll_location, cursor, event_count: 1, })); @@ -1603,21 +1602,18 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { } fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId) { - let details = match self.pipeline_details.get(&pipeline_id) { + let details = match self.pipeline_details.get(pipeline_id) { Some(details) => details, None => return, }; let mut scroll_states = Vec::new(); details.scroll_tree.nodes.iter().for_each(|node| { - match (node.external_id(), node.offset()) { - (Some(scroll_id), Some(scroll_offset)) => { - scroll_states.push(ScrollState { - scroll_id, - scroll_offset, - }); - }, - _ => {}, + if let (Some(scroll_id), Some(scroll_offset)) = (node.external_id(), node.offset()) { + scroll_states.push(ScrollState { + scroll_id, + scroll_offset, + }); } }); @@ -1632,7 +1628,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { // Check if any pipelines currently have active animations or animation callbacks. fn animations_active(&self) -> bool { - for (_, details) in &self.pipeline_details { + for details in self.pipeline_details.values() { // If animations are currently running, then don't bother checking // with the constellation if the output image is stable. if details.animations_running { @@ -1666,7 +1662,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { // This gets sent to the constellation for comparison with the current // frame tree. let mut pipeline_epochs = HashMap::new(); - for (id, _) in &self.pipeline_details { + for id in self.pipeline_details.keys() { let webrender_pipeline_id = id.to_webrender(); if let Some(WebRenderEpoch(epoch)) = self .webrender @@ -1830,7 +1826,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { continue; } // in which case, we remove it from the list of pending metrics, - to_remove.push(id.clone()); + to_remove.push(*id); if let Some(pipeline) = self.pipeline(*id) { // and inform layout with the measured paint time. let message = LayoutControlMsg::PaintMetric(epoch, paint_time); @@ -1897,7 +1893,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { width: img.width(), height: img.height(), format: PixelFormat::RGB8, - bytes: ipc::IpcSharedMemory::from_bytes(&*img), + bytes: ipc::IpcSharedMemory::from_bytes(&img), id: None, cors_status: CorsStatus::Safe, }) @@ -2078,10 +2074,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { pub fn repaint_synchronously(&mut self) { while self.shutdown_state != ShutdownState::ShuttingDown { let msg = self.port.recv_compositor_msg(); - let need_recomposite = match msg { - CompositorMsg::NewWebRenderFrameReady(_) => true, - _ => false, - }; + let need_recomposite = matches!(msg, CompositorMsg::NewWebRenderFrameReady(_)); let keep_going = self.handle_browser_message(msg); if need_recomposite { self.composite(); @@ -2142,7 +2135,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { .map(|dir| dir.join("capture_webrender").join(&capture_id)) .ok() }) - .find(|val| match create_dir_all(&val) { + .find(|val| match create_dir_all(val) { Ok(_) => true, Err(err) => { eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err); diff --git a/components/compositing/gl.rs b/components/compositing/gl.rs index 407fb34546b..18761c5829e 100644 --- a/components/compositing/gl.rs +++ b/components/compositing/gl.rs @@ -132,7 +132,7 @@ impl RenderTargetInfo { let dst_start = y * stride; let src_start = (height - y - 1) * stride; let src_slice = &orig_pixels[src_start..src_start + stride]; - (&mut pixels[dst_start..dst_start + stride]).clone_from_slice(&src_slice[..stride]); + pixels[dst_start..dst_start + stride].clone_from_slice(&src_slice[..stride]); } RgbImage::from_raw(width as u32, height as u32, pixels).expect("Flipping image failed!") diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index 34bb90099e4..0acd0690b43 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -25,10 +25,7 @@ pub struct TouchPoint { impl TouchPoint { pub fn new(id: TouchId, point: Point2D<f32, DevicePixel>) -> Self { - TouchPoint { - id: id, - point: point, - } + TouchPoint { id, point } } } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index a1a36ee688d..987ffd675ea 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -218,7 +218,7 @@ impl EmbedderCoordinates { /// to the framebuffer with OpenGL commands. pub fn get_flipped_viewport(&self) -> DeviceIntRect { let fb_height = self.framebuffer.height; - let mut view = self.viewport.clone(); + let mut view = self.viewport; view.origin.y = fb_height - view.origin.y - view.size.height; DeviceIntRect::from_untyped(&view.to_untyped()) } diff --git a/components/constellation/sandboxing.rs b/components/constellation/sandboxing.rs index 5354d8c8a5d..c8cbb651ee8 100644 --- a/components/constellation/sandboxing.rs +++ b/components/constellation/sandboxing.rs @@ -28,6 +28,7 @@ use crate::pipeline::UnprivilegedPipelineContent; use crate::serviceworker::ServiceWorkerUnprivilegedContent; #[derive(Deserialize, Serialize)] +#[allow(clippy::large_enum_variant)] pub enum UnprivilegedContent { Pipeline(UnprivilegedPipelineContent), ServiceWorker(ServiceWorkerUnprivilegedContent), diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index 1ea34f523a7..773fe64fe46 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -521,7 +521,7 @@ impl FontCacheThread { }; let mut number_loading = 0; - stylesheet.effective_font_face_rules(&device, guard, |rule| { + stylesheet.effective_font_face_rules(device, guard, |rule| { let font_face = match rule.font_face() { Some(font_face) => font_face, None => return, diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs index 971ad729441..7aa42f365ae 100644 --- a/components/metrics/lib.rs +++ b/components/metrics/lib.rs @@ -75,13 +75,7 @@ fn set_metric<U: ProgressiveWebMetric>( pwm.send_queued_constellation_msg(metric_type, time); // Send the metric to the time profiler. - send_profile_data( - category, - metadata, - &pwm.get_time_profiler_chan(), - time, - time, - ); + send_profile_data(category, metadata, pwm.get_time_profiler_chan(), time, time); // Print the metric to console if the print-pwm option was given. if opts::get().print_pwm { @@ -119,13 +113,15 @@ pub struct InteractiveWindow { start: SystemTime, } -impl InteractiveWindow { - pub fn new() -> InteractiveWindow { - InteractiveWindow { +impl Default for InteractiveWindow { + fn default() -> Self { + Self { start: SystemTime::now(), } } +} +impl InteractiveWindow { // We need to either start or restart the 10s window // start: we've added a new document // restart: there was a task > 50ms @@ -163,7 +159,7 @@ impl InteractiveMetrics { dom_content_loaded: Cell::new(None), main_thread_available: Cell::new(None), time_to_interactive: Cell::new(None), - time_profiler_chan: time_profiler_chan, + time_profiler_chan, url, } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f2e30a0fe27..43059b0f5bb 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3200,7 +3200,7 @@ impl Document { fullscreen_element: MutNullableDom::new(None), form_id_listener_map: Default::default(), interactive_time: DomRefCell::new(interactive_time), - tti_window: DomRefCell::new(InteractiveWindow::new()), + tti_window: DomRefCell::new(InteractiveWindow::default()), canceller: canceller, throw_on_dynamic_markup_insertion_counter: Cell::new(0), page_showing: Cell::new(false), diff --git a/components/webdriver_server/actions.rs b/components/webdriver_server/actions.rs index 435d9a13dba..6eb883374e8 100644 --- a/components/webdriver_server/actions.rs +++ b/components/webdriver_server/actions.rs @@ -101,8 +101,8 @@ impl Handler { actions_by_tick: &[ActionSequence], ) -> Result<(), ErrorStatus> { for tick_actions in actions_by_tick.iter() { - let tick_duration = compute_tick_duration(&tick_actions); - self.dispatch_tick_actions(&tick_actions, tick_duration)?; + let tick_duration = compute_tick_duration(tick_actions); + self.dispatch_tick_actions(tick_actions, tick_duration)?; } Ok(()) } @@ -144,10 +144,10 @@ impl Handler { .or_insert(InputSourceState::Key(KeyInputState::new())); match action { KeyAction::Down(action) => { - self.dispatch_keydown_action(&source_id, &action) + self.dispatch_keydown_action(source_id, action) }, KeyAction::Up(action) => { - self.dispatch_keyup_action(&source_id, &action) + self.dispatch_keyup_action(source_id, action) }, }; }, @@ -174,15 +174,15 @@ impl Handler { match action { PointerAction::Cancel => (), PointerAction::Down(action) => { - self.dispatch_pointerdown_action(&source_id, &action) + self.dispatch_pointerdown_action(source_id, action) }, PointerAction::Move(action) => self.dispatch_pointermove_action( - &source_id, - &action, + source_id, + action, tick_duration, )?, PointerAction::Up(action) => { - self.dispatch_pointerup_action(&source_id, &action) + self.dispatch_pointerup_action(source_id, action) }, } }, @@ -435,6 +435,7 @@ impl Handler { } // https://w3c.github.io/webdriver/#dfn-perform-a-pointer-move + #[allow(clippy::too_many_arguments)] fn perform_pointer_move( &mut self, source_id: &str, @@ -470,11 +471,7 @@ impl Handler { }; // Step 3 - let last = if 1.0 - duration_ratio < 0.001 { - true - } else { - false - }; + let last = 1.0 - duration_ratio < 0.001; // Step 4 let (x, y) = if last { diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 50337ecaa0a..2793be805b1 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -67,7 +67,7 @@ use webdriver::server::{self, Session, SessionTeardownKind, WebDriverHandler}; use crate::actions::{InputSourceState, PointerInputState}; fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> { - return vec![ + vec![ ( Method::POST, "/session/{sessionId}/servo/prefs/get", @@ -83,7 +83,7 @@ fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> { "/session/{sessionId}/servo/prefs/reset", ServoExtensionRoute::ResetPrefs, ), - ]; + ] } fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie { @@ -157,8 +157,8 @@ impl WebDriverSession { ) -> WebDriverSession { WebDriverSession { id: Uuid::new_v4(), - browsing_context_id: browsing_context_id, - top_level_browsing_context_id: top_level_browsing_context_id, + browsing_context_id, + top_level_browsing_context_id, script_timeout: Some(30_000), load_timeout: 300_000, @@ -189,6 +189,7 @@ struct Handler { } #[derive(Clone, Copy, Debug, PartialEq)] +#[allow(clippy::enum_variant_names)] enum ServoExtensionRoute { GetPrefs, SetPrefs, @@ -222,6 +223,7 @@ impl WebDriverExtensionRoute for ServoExtensionRoute { } #[derive(Clone, Debug, PartialEq)] +#[allow(clippy::enum_variant_names)] enum ServoExtensionCommand { GetPrefs(GetPrefsParameters), SetPrefs(SetPrefsParameters), @@ -251,7 +253,7 @@ impl Serialize for SendableWebDriverJSValue { WebDriverJSValue::Null => serializer.serialize_unit(), WebDriverJSValue::Boolean(x) => serializer.serialize_bool(x), WebDriverJSValue::Number(x) => serializer.serialize_f64(x), - WebDriverJSValue::String(ref x) => serializer.serialize_str(&x), + WebDriverJSValue::String(ref x) => serializer.serialize_str(x), WebDriverJSValue::Element(ref x) => x.serialize(serializer), WebDriverJSValue::Frame(ref x) => x.serialize(serializer), WebDriverJSValue::Window(ref x) => x.serialize(serializer), @@ -279,7 +281,7 @@ impl Serialize for WebDriverPrefValue { { match self.0 { PrefValue::Bool(b) => serializer.serialize_bool(b), - PrefValue::Str(ref s) => serializer.serialize_str(&s), + PrefValue::Str(ref s) => serializer.serialize_str(s), PrefValue::Float(f) => serializer.serialize_f64(f), PrefValue::Int(i) => serializer.serialize_i64(i), PrefValue::Missing => serializer.serialize_unit(), @@ -407,7 +409,7 @@ impl Handler { load_status_sender, load_status_receiver, session: None, - constellation_chan: constellation_chan, + constellation_chan, resize_timeout: 500, } } @@ -713,14 +715,8 @@ impl Handler { params: &WindowRectParameters, ) -> WebDriverResult<WebDriverResponse> { let (sender, receiver) = ipc::channel().unwrap(); - let width = match params.width { - Some(v) => v, - None => 0, - }; - let height = match params.height { - Some(v) => v, - None => 0, - }; + let width = params.width.unwrap_or(0); + let height = params.height.unwrap_or(0); let size = Size2D::new(width as u32, height as u32); let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id; let cmd_msg = WebDriverCommandMsg::SetWindowSize( @@ -1368,7 +1364,7 @@ impl Handler { let input_cancel_list = { let session = self.session_mut()?; session.input_cancel_list.reverse(); - mem::replace(&mut session.input_cancel_list, Vec::new()) + mem::take(&mut session.input_cancel_list) }; if let Err(error) = self.dispatch_actions(&input_cancel_list) { @@ -1471,7 +1467,7 @@ impl Handler { receiver .recv() .unwrap() - .or_else(|error| Err(WebDriverError::new(error, "")))?; + .map_err(|error| WebDriverError::new(error, ""))?; let input_events = send_keys(&keys.text); @@ -1629,12 +1625,10 @@ impl Handler { serde_json::to_value(encoded)?, ))) }, - Err(_) => { - return Err(WebDriverError::new( - ErrorStatus::StaleElementReference, - "Element not found", - )); - }, + Err(_) => Err(WebDriverError::new( + ErrorStatus::StaleElementReference, + "Element not found", + )), } } @@ -1662,7 +1656,7 @@ impl Handler { &self, parameters: &SetPrefsParameters, ) -> WebDriverResult<WebDriverResponse> { - for &(ref key, ref value) in parameters.prefs.iter() { + for (key, value) in parameters.prefs.iter() { prefs::pref_map() .set(key, value.0.clone()) .expect("Failed to set preference"); @@ -1674,7 +1668,7 @@ impl Handler { &self, parameters: &GetPrefsParameters, ) -> WebDriverResult<WebDriverResponse> { - let prefs = if parameters.prefs.len() == 0 { + let prefs = if parameters.prefs.is_empty() { prefs::pref_map().reset_all(); BTreeMap::new() } else { diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs index 20a1b0cdaa8..14210d1e683 100644 --- a/components/webgpu/lib.rs +++ b/components/webgpu/lib.rs @@ -54,6 +54,7 @@ const DEVICE_POLL_INTERVAL: u64 = 100; pub const PRESENTATION_BUFFER_COUNT: usize = 10; #[derive(Debug, Deserialize, Serialize)] +#[allow(clippy::large_enum_variant)] pub enum WebGPUResponse { RequestAdapter { adapter_info: wgt::AdapterInfo, @@ -330,6 +331,12 @@ impl WebGPU { } } +type WebGPUBufferMaps<'a> = + HashMap<id::BufferId, Rc<BufferMapInfo<'a, Option<WebGPUResponseResult>>>>; +type WebGPUPresentBufferMaps<'a> = + HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>; + +#[allow(clippy::upper_case_acronyms)] // Name of the library struct WGPU<'a> { receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>, sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>, @@ -340,10 +347,9 @@ struct WGPU<'a> { // Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid _invalid_adapters: Vec<WebGPUAdapter>, // Buffers with pending mapping - buffer_maps: HashMap<id::BufferId, Rc<BufferMapInfo<'a, Option<WebGPUResponseResult>>>>, + buffer_maps: WebGPUBufferMaps<'a>, // Presentation Buffers with pending mapping - present_buffer_maps: - HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>, + present_buffer_maps: WebGPUPresentBufferMaps<'a>, //TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867) error_command_encoders: RefCell<HashMap<id::CommandEncoderId, String>>, webrender_api: RenderApi, |