mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #29758 - michaelgrigoryan25:master, r=jdm
Patch: Applied code patches for clippy warnings <!-- Please describe your changes on the following line: --> This pull request fixes: - Some of the warnings generated by `./mach cargo-clippy` - A namespacing error in `headed_window.rs` --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because there are no functional changes. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
4e61168d68
8 changed files with 39 additions and 40 deletions
|
@ -19,7 +19,7 @@ use servo::Servo;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::mem;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use webxr::glwindow::GlWindowDiscovery;
|
use webxr::glwindow::GlWindowDiscovery;
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_events(&self) -> Vec<WindowEvent> {
|
fn get_events(&self) -> Vec<WindowEvent> {
|
||||||
mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new())
|
std::mem::take(&mut *self.event_queue.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function decides whether the event should be handled during `run_forever`.
|
// This function decides whether the event should be handled during `run_forever`.
|
||||||
|
|
|
@ -23,7 +23,7 @@ use servo::webrender_api::ScrollLocation;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::mem;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -59,7 +59,7 @@ where
|
||||||
current_url: None,
|
current_url: None,
|
||||||
browser_id: None,
|
browser_id: None,
|
||||||
browsers: Vec::new(),
|
browsers: Vec::new(),
|
||||||
window: window,
|
window,
|
||||||
clipboard_ctx: match ClipboardContext::new() {
|
clipboard_ctx: match ClipboardContext::new() {
|
||||||
Ok(c) => Some(c),
|
Ok(c) => Some(c),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -73,7 +73,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_events(&mut self) -> Vec<WindowEvent> {
|
pub fn get_events(&mut self) -> Vec<WindowEvent> {
|
||||||
mem::replace(&mut self.event_queue, Vec::new())
|
std::mem::take(&mut self.event_queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_window_events(&mut self, events: Vec<WindowEvent>) {
|
pub fn handle_window_events(&mut self, events: Vec<WindowEvent>) {
|
||||||
|
@ -279,7 +279,7 @@ where
|
||||||
String::from("Untitled")
|
String::from("Untitled")
|
||||||
};
|
};
|
||||||
let title = match self.title {
|
let title = match self.title {
|
||||||
Some(ref title) if title.len() > 0 => &**title,
|
Some(ref title) if !title.is_empty() => &**title,
|
||||||
_ => &fallback_title,
|
_ => &fallback_title,
|
||||||
};
|
};
|
||||||
let title = format!("{} - Servo", title);
|
let title = format!("{} - Servo", title);
|
||||||
|
@ -563,7 +563,7 @@ fn platform_get_selected_devices(devices: Vec<String>) -> Option<String> {
|
||||||
match tinyfiledialogs::list_dialog("Choose a device", &["Id", "Name"], dialog_rows) {
|
match tinyfiledialogs::list_dialog("Choose a device", &["Id", "Name"], dialog_rows) {
|
||||||
Some(device) => {
|
Some(device) => {
|
||||||
// The device string format will be "Address|Name". We need the first part of it.
|
// The device string format will be "Address|Name". We need the first part of it.
|
||||||
device.split("|").next().map(|s| s.to_string())
|
device.split('|').next().map(|s| s.to_string())
|
||||||
},
|
},
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ fn get_selected_files(patterns: Vec<FilterPattern>, multiple_files: bool) -> Opt
|
||||||
filters.push(tiny_dialog_escape(&s))
|
filters.push(tiny_dialog_escape(&s))
|
||||||
}
|
}
|
||||||
let filter_ref = &(filters.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]);
|
let filter_ref = &(filters.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]);
|
||||||
let filter_opt = if filters.len() > 0 {
|
let filter_opt = if !filters.is_empty() {
|
||||||
Some((filter_ref, ""))
|
Some((filter_ref, ""))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -618,7 +618,7 @@ fn get_selected_files(patterns: Vec<FilterPattern>, multiple_files: bool) -> Opt
|
||||||
|
|
||||||
fn sanitize_url(request: &str) -> Option<ServoUrl> {
|
fn sanitize_url(request: &str) -> Option<ServoUrl> {
|
||||||
let request = request.trim();
|
let request = request.trim();
|
||||||
ServoUrl::parse(&request)
|
ServoUrl::parse(request)
|
||||||
.ok()
|
.ok()
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
if request.contains('/') || is_reg_domain(request) {
|
if request.contains('/') || is_reg_domain(request) {
|
||||||
|
@ -650,7 +650,7 @@ fn tiny_dialog_escape(raw: &str) -> String {
|
||||||
_ => Some(c),
|
_ => Some(c),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
return shellwords::escape(&s);
|
shellwords::escape(&s)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub fn install() {
|
||||||
if let Some(name) = thread::current().name() {
|
if let Some(name) = thread::current().name() {
|
||||||
let _ = write!(&mut stderr, " in thread \"{}\"", name);
|
let _ = write!(&mut stderr, " in thread \"{}\"", name);
|
||||||
}
|
}
|
||||||
let _ = write!(&mut stderr, "\n");
|
let _ = writeln!(&mut stderr);
|
||||||
|
|
||||||
// This call always allocates, which in practice will segfault if
|
// This call always allocates, which in practice will segfault if
|
||||||
// we’re handling a non-main-thread (e.g. layout) segfault. Strictly
|
// we’re handling a non-main-thread (e.g. layout) segfault. Strictly
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
use servo::embedder_traits::EventLoopWaker;
|
use servo::embedder_traits::EventLoopWaker;
|
||||||
use std::sync::{Arc, Condvar, Mutex};
|
use std::sync::{Arc, Condvar, Mutex};
|
||||||
use std::time;
|
use std::time;
|
||||||
use winit;
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use winit::platform::macos::{ActivationPolicy, EventLoopBuilderExtMacOS};
|
use winit::platform::macos::{ActivationPolicy, EventLoopBuilderExtMacOS};
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ impl EventsLoop {
|
||||||
let events_loop = events_loop
|
let events_loop = events_loop
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Can't create waker for unavailable event loop.");
|
.expect("Can't create waker for unavailable event loop.");
|
||||||
Box::new(HeadedEventLoopWaker::new(&events_loop))
|
Box::new(HeadedEventLoopWaker::new(events_loop))
|
||||||
},
|
},
|
||||||
EventLoop::Headless(ref data) => Box::new(HeadlessEventLoopWaker(data.clone())),
|
EventLoop::Headless(ref data) => Box::new(HeadlessEventLoopWaker(data.clone())),
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ impl EventsLoop {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
EventLoop::Headless(ref data) => {
|
EventLoop::Headless(ref data) => {
|
||||||
let &(ref flag, ref condvar) = &**data;
|
let (flag, condvar) = &**data;
|
||||||
let mut event = winit::event::Event::NewEvents(winit::event::StartCause::Init);
|
let mut event = winit::event::Event::NewEvents(winit::event::StartCause::Init);
|
||||||
loop {
|
loop {
|
||||||
self.sleep(flag, condvar);
|
self.sleep(flag, condvar);
|
||||||
|
|
|
@ -14,9 +14,8 @@ use euclid::{
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||||
use winit::window::Icon;
|
use winit::window::Icon;
|
||||||
use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
|
use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
|
||||||
use image;
|
use servo::keyboard_types::{Key, KeyState, KeyboardEvent};
|
||||||
use keyboard_types::{Key, KeyState, KeyboardEvent};
|
|
||||||
use servo::compositing::windowing::{AnimationState, MouseWindowEvent, WindowEvent};
|
use servo::compositing::windowing::{AnimationState, MouseWindowEvent, WindowEvent};
|
||||||
use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods};
|
use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods};
|
||||||
use servo::embedder_traits::Cursor;
|
use servo::embedder_traits::Cursor;
|
||||||
|
@ -31,7 +30,7 @@ use servo::webrender_surfman::WebrenderSurfman;
|
||||||
use servo_media::player::context::{GlApi, GlContext as PlayerGLContext, NativeDisplay};
|
use servo_media::player::context::{GlApi, GlContext as PlayerGLContext, NativeDisplay};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::mem;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use surfman::platform::generic::multi::connection::NativeConnection;
|
use surfman::platform::generic::multi::connection::NativeConnection;
|
||||||
|
@ -120,10 +119,10 @@ impl Window {
|
||||||
let PhysicalSize {
|
let PhysicalSize {
|
||||||
width: screen_width,
|
width: screen_width,
|
||||||
height: screen_height,
|
height: screen_height,
|
||||||
} = primary_monitor.clone().size();
|
} = primary_monitor.size();
|
||||||
let screen_size = Size2D::new(screen_width as u32, screen_height as u32);
|
let screen_size = Size2D::new(screen_width, screen_height);
|
||||||
let PhysicalSize { width, height } = winit_window.inner_size();
|
let PhysicalSize { width, height } = winit_window.inner_size();
|
||||||
let inner_size = Size2D::new(width as u32, height as u32);
|
let inner_size = Size2D::new(width, height);
|
||||||
|
|
||||||
// Initialize surfman
|
// Initialize surfman
|
||||||
let connection =
|
let connection =
|
||||||
|
@ -298,7 +297,7 @@ impl Window {
|
||||||
|
|
||||||
impl WindowPortsMethods for Window {
|
impl WindowPortsMethods for Window {
|
||||||
fn get_events(&self) -> Vec<WindowEvent> {
|
fn get_events(&self) -> Vec<WindowEvent> {
|
||||||
mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new())
|
std::mem::take(&mut *self.event_queue.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_events(&self) -> bool {
|
fn has_events(&self) -> bool {
|
||||||
|
@ -319,12 +318,12 @@ impl WindowPortsMethods for Window {
|
||||||
|
|
||||||
fn set_inner_size(&self, size: DeviceIntSize) {
|
fn set_inner_size(&self, size: DeviceIntSize) {
|
||||||
self.winit_window
|
self.winit_window
|
||||||
.set_inner_size::<PhysicalSize<i32>>(PhysicalSize::new(size.width.into(), size.height.into()))
|
.set_inner_size::<PhysicalSize<i32>>(PhysicalSize::new(size.width, size.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_position(&self, point: DeviceIntPoint) {
|
fn set_position(&self, point: DeviceIntPoint) {
|
||||||
self.winit_window
|
self.winit_window
|
||||||
.set_outer_position::<PhysicalPosition<i32>>(PhysicalPosition::new(point.x.into(), point.y.into()))
|
.set_outer_position::<PhysicalPosition<i32>>(PhysicalPosition::new(point.x, point.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_fullscreen(&self, state: bool) {
|
fn set_fullscreen(&self, state: bool) {
|
||||||
|
@ -340,7 +339,7 @@ impl WindowPortsMethods for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_fullscreen(&self) -> bool {
|
fn get_fullscreen(&self) -> bool {
|
||||||
return self.fullscreen.get();
|
self.fullscreen.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_cursor(&self, cursor: Cursor) {
|
fn set_cursor(&self, cursor: Cursor) {
|
||||||
|
@ -532,7 +531,7 @@ impl WindowMethods for Window {
|
||||||
viewport,
|
viewport,
|
||||||
framebuffer,
|
framebuffer,
|
||||||
window: (win_size, win_origin),
|
window: (win_size, win_origin),
|
||||||
screen: screen,
|
screen,
|
||||||
// FIXME: Winit doesn't have API for available size. Fallback to screen size
|
// FIXME: Winit doesn't have API for available size. Fallback to screen size
|
||||||
screen_avail: screen,
|
screen_avail: screen,
|
||||||
hidpi_factor: self.servo_hidpi_factor(),
|
hidpi_factor: self.servo_hidpi_factor(),
|
||||||
|
@ -672,11 +671,11 @@ impl webxr::glwindow::GlWindow for XRWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_rotation(&self) -> Rotation3D<f32, UnknownUnit, UnknownUnit> {
|
fn get_rotation(&self) -> Rotation3D<f32, UnknownUnit, UnknownUnit> {
|
||||||
self.pose.xr_rotation.get().clone()
|
self.pose.xr_rotation.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_translation(&self) -> Vector3D<f32, UnknownUnit> {
|
fn get_translation(&self) -> Vector3D<f32, UnknownUnit> {
|
||||||
self.pose.xr_translation.get().clone()
|
self.pose.xr_translation.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mode(&self) -> webxr::glwindow::GlWindowMode {
|
fn get_mode(&self) -> webxr::glwindow::GlWindowMode {
|
||||||
|
@ -736,8 +735,8 @@ impl XRWindowPose {
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
if modifiers.shift() {
|
if modifiers.shift() {
|
||||||
x = 10.0 * x;
|
x *= 10.0;
|
||||||
y = 10.0 * y;
|
y *= 10.0;
|
||||||
}
|
}
|
||||||
let x: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_x(Angle::degrees(x));
|
let x: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_x(Angle::degrees(x));
|
||||||
let y: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_y(Angle::degrees(y));
|
let y: Rotation3D<_, UnknownUnit, UnknownUnit> = Rotation3D::around_y(Angle::degrees(y));
|
||||||
|
|
|
@ -20,7 +20,7 @@ use surfman::Connection;
|
||||||
use surfman::Context;
|
use surfman::Context;
|
||||||
use surfman::Device;
|
use surfman::Device;
|
||||||
use surfman::SurfaceType;
|
use surfman::SurfaceType;
|
||||||
use winit;
|
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
webrender_surfman: WebrenderSurfman,
|
webrender_surfman: WebrenderSurfman,
|
||||||
|
@ -91,7 +91,7 @@ impl WindowPortsMethods for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_fullscreen(&self) -> bool {
|
fn get_fullscreen(&self) -> bool {
|
||||||
return self.fullscreen.get();
|
self.fullscreen.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_animating(&self) -> bool {
|
fn is_animating(&self) -> bool {
|
||||||
|
|
|
@ -17,12 +17,12 @@ pub fn register_user_prefs(opts_matches: &Matches) {
|
||||||
let user_prefs_path = opts::get()
|
let user_prefs_path = opts::get()
|
||||||
.config_dir
|
.config_dir
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(|| basedir::default_config_dir())
|
.or_else(basedir::default_config_dir)
|
||||||
.map(|path| path.join("prefs.json"))
|
.map(|path| path.join("prefs.json"))
|
||||||
.filter(|path| path.exists());
|
.filter(|path| path.exists());
|
||||||
|
|
||||||
let mut userprefs = if let Some(path) = user_prefs_path {
|
let mut userprefs = if let Some(path) = user_prefs_path {
|
||||||
let mut file = File::open(&path).expect("Error opening user prefs");
|
let mut file = File::open(path).expect("Error opening user prefs");
|
||||||
let mut txt = String::new();
|
let mut txt = String::new();
|
||||||
file.read_to_string(&mut txt)
|
file.read_to_string(&mut txt)
|
||||||
.expect("Can't read user prefs file");
|
.expect("Can't read user prefs file");
|
||||||
|
@ -41,9 +41,9 @@ pub fn register_user_prefs(opts_matches: &Matches) {
|
||||||
Some("true") | None => PrefValue::Bool(true),
|
Some("true") | None => PrefValue::Bool(true),
|
||||||
Some("false") => PrefValue::Bool(false),
|
Some("false") => PrefValue::Bool(false),
|
||||||
Some(string) => {
|
Some(string) => {
|
||||||
if let Some(int) = string.parse::<i64>().ok() {
|
if let Ok(int) = string.parse::<i64>() {
|
||||||
PrefValue::Int(int)
|
PrefValue::Int(int)
|
||||||
} else if let Some(float) = string.parse::<f64>().ok() {
|
} else if let Ok(float) = string.parse::<f64>() {
|
||||||
PrefValue::Float(float)
|
PrefValue::Float(float)
|
||||||
} else {
|
} else {
|
||||||
PrefValue::from(string)
|
PrefValue::from(string)
|
||||||
|
@ -83,14 +83,14 @@ fn test_parse_pref_from_command_line() {
|
||||||
prefs::pref_map().get("dom.bluetooth.enabled"),
|
prefs::pref_map().get("dom.bluetooth.enabled"),
|
||||||
PrefValue::Bool(true)
|
PrefValue::Bool(true)
|
||||||
);
|
);
|
||||||
assert_eq!(pref!(dom.bluetooth.enabled), true);
|
assert!(pref!(dom.bluetooth.enabled));
|
||||||
|
|
||||||
test_parse_pref("dom.bluetooth.enabled=false");
|
test_parse_pref("dom.bluetooth.enabled=false");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
prefs::pref_map().get("dom.bluetooth.enabled"),
|
prefs::pref_map().get("dom.bluetooth.enabled"),
|
||||||
PrefValue::Bool(false)
|
PrefValue::Bool(false)
|
||||||
);
|
);
|
||||||
assert_eq!(pref!(dom.bluetooth.enabled), false);
|
assert!(pref!(dom.bluetooth.enabled));
|
||||||
|
|
||||||
// Test with numbers
|
// Test with numbers
|
||||||
test_parse_pref("layout.threads=42");
|
test_parse_pref("layout.threads=42");
|
||||||
|
@ -105,7 +105,7 @@ fn test_parse_pref_from_command_line() {
|
||||||
.set("dom.bluetooth.enabled", false)
|
.set("dom.bluetooth.enabled", false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
test_parse_pref("dom.bluetooth.enabled");
|
test_parse_pref("dom.bluetooth.enabled");
|
||||||
assert_eq!(pref!(dom.bluetooth.enabled), true);
|
assert!(pref!(dom.bluetooth.enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::events_loop::ServoEvent;
|
||||||
use servo::compositing::windowing::{WindowEvent, WindowMethods};
|
use servo::compositing::windowing::{WindowEvent, WindowMethods};
|
||||||
use servo::embedder_traits::Cursor;
|
use servo::embedder_traits::Cursor;
|
||||||
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
||||||
use winit;
|
|
||||||
|
|
||||||
// This should vary by zoom level and maybe actual text size (focused or under cursor)
|
// This should vary by zoom level and maybe actual text size (focused or under cursor)
|
||||||
pub const LINE_HEIGHT: f32 = 38.0;
|
pub const LINE_HEIGHT: f32 = 38.0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue