diff --git a/Cargo.toml b/Cargo.toml index e4360010..83a38620 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,4 +113,8 @@ harness = false [profile.release-lto] inherits = "release" -lto = true \ No newline at end of file +lto = true + +# Tell clippy to allow e.g. #[cfg(macos)] +[lints.clippy] +mismatched_target_os = "allow" \ No newline at end of file diff --git a/src/compositor.rs b/src/compositor.rs index 08ea9a6c..22b2ee7d 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -1746,9 +1746,9 @@ impl IOCompositor { if previous_pipeline_id.replace(pipeline_id) != Some(pipeline_id) { let scroll_result = self .pipeline_details - .get_mut(&pipeline_id)? + .get_mut(pipeline_id)? .scroll_tree - .scroll_node_or_ancestor(&scroll_tree_node, scroll_location); + .scroll_node_or_ancestor(scroll_tree_node, scroll_location); if let Some((external_id, offset)) = scroll_result { return Some((*pipeline_id, external_id, offset)); } @@ -1778,11 +1778,7 @@ impl IOCompositor { pipeline_ids.push(*pipeline_id); } } - if pipeline_ids.is_empty() && !self.webxr_main_thread.running() { - self.is_animating = false; - } else { - self.is_animating = true; - }; + self.is_animating = !pipeline_ids.is_empty() || self.webxr_main_thread.running(); for pipeline_id in &pipeline_ids { self.tick_animations_for_pipeline(*pipeline_id) } diff --git a/src/keyboard.rs b/src/keyboard.rs index 0c0adf0a..96f7b259 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -21,7 +21,7 @@ fn get_servo_key_from_winit_key(key: &LogicalKey) -> Key { // TODO: figure out how to map NavigateForward, NavigateBackward // TODO: map the remaining keys if possible match key { - LogicalKey::Character(c) => return Key::Character(c.to_string()), + LogicalKey::Character(c) => Key::Character(c.to_string()), // printable: Key1 to Key0 // printable: A to Z LogicalKey::Named(NamedKey::Escape) => Key::Escape, diff --git a/src/main.rs b/src/main.rs index 6d4a9e13..0b4cc0c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,16 +24,16 @@ impl ApplicationHandler for App { window_id: winit::window::WindowId, event: winit::event::WindowEvent, ) { - self.verso.as_mut().map(|v| { + if let Some(v) = self.verso.as_mut() { v.handle_winit_window_event(window_id, event); v.handle_servo_messages(event_loop); - }); + } } fn user_event(&mut self, event_loop: &event_loop::ActiveEventLoop, _: ()) { - self.verso.as_mut().map(|v| { + if let Some(v) = self.verso.as_mut() { v.handle_servo_messages(event_loop); - }); + } } } diff --git a/src/touch.rs b/src/touch.rs index 43b1bb26..b87f17b1 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -70,14 +70,20 @@ pub enum TouchAction { NoAction, } -impl TouchHandler { - /// Create a touch handler. - pub fn new() -> Self { - TouchHandler { +impl Default for TouchHandler { + fn default() -> Self { + Self { state: Nothing, active_touch_points: Vec::new(), } } +} + +impl TouchHandler { + /// Create a touch handler. + pub fn new() -> Self { + Self::default() + } /// Handle touch down input. pub fn on_touch_down(&mut self, id: TouchId, point: Point2D) { diff --git a/src/verso.rs b/src/verso.rs index 51e13374..42620975 100644 --- a/src/verso.rs +++ b/src/verso.rs @@ -504,7 +504,9 @@ impl Verso { // Check compositor status and set control flow. if shutdown { // If Compositor has shut down, deinit and remove it. - self.compositor.take().map(IOCompositor::deinit); + if let Some(compositor) = self.compositor.take() { + IOCompositor::deinit(compositor) + } evl.exit(); } else if self.is_animating() { evl.set_control_flow(ControlFlow::Poll); diff --git a/src/webview.rs b/src/webview.rs index e50e8f7f..98fce311 100644 --- a/src/webview.rs +++ b/src/webview.rs @@ -101,14 +101,14 @@ impl Window { } } EmbedderMsg::SetClipboardContents(text) => { - clipboard.map(|c| { + if let Some(c) = clipboard { if let Err(e) = c.set_text(text) { log::warn!( "Verso WebView {webview_id:?} failed to set clipboard contents: {}", e ); } - }); + } } EmbedderMsg::EventDelivered(event) => { if let CompositorEventVariant::MouseButtonEvent = event { @@ -178,16 +178,19 @@ impl Window { let url = match Url::parse(unparsed_url) { Ok(url_parsed) => url_parsed, Err(e) => { - if e == url::ParseError::RelativeUrlWithoutBase - { - Url::parse(&format!("https://{}", unparsed_url)).unwrap() + if e == url::ParseError::RelativeUrlWithoutBase { + Url::parse(&format!("https://{}", unparsed_url)) + .unwrap() } else { panic!("Verso Panel failed to parse URL: {}", e); } } }; - send_to_constellation(sender, ConstellationMsg::LoadUrl(id, ServoUrl::from_url(url))); + send_to_constellation( + sender, + ConstellationMsg::LoadUrl(id, ServoUrl::from_url(url)), + ); } else { match msg.as_str() { "PREV" => { @@ -245,11 +248,11 @@ impl Window { } } EmbedderMsg::SetClipboardContents(text) => { - clipboard.map(|c| { + if let Some(c) = clipboard { if let Err(e) = c.set_text(text) { log::warn!("Verso Panel failed to set clipboard contents: {}", e); } - }); + } } e => { log::trace!("Verso Panel isn't supporting this message yet: {e:?}") diff --git a/src/window.rs b/src/window.rs index 9810883c..a3b95f25 100644 --- a/src/window.rs +++ b/src/window.rs @@ -245,7 +245,7 @@ impl Window { } WindowEvent::ModifiersChanged(modifier) => self.modifiers_state.set(modifier.state()), WindowEvent::KeyboardInput { event, .. } => { - let event = keyboard_event_from_winit(&event, self.modifiers_state.get()); + let event = keyboard_event_from_winit(event, self.modifiers_state.get()); log::trace!("Verso is handling {:?}", event); let msg = ConstellationMsg::Keyboard(event); send_to_constellation(sender, msg); @@ -312,12 +312,12 @@ impl Window { compositor: &mut IOCompositor, ) -> (Option, bool) { if self.panel.as_ref().filter(|w| w.webview_id == id).is_some() { - self.webview.as_ref().map(|w| { + if let Some(w) = self.webview.as_ref() { send_to_constellation( &compositor.constellation_chan, ConstellationMsg::CloseWebView(w.webview_id), ) - }); + } (self.panel.take(), false) } else if self .webview