mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix last few warnings (#32270)
* Fix clippy in components/script warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do (components/script/dom/htmlformelement.rs:896:20) warning: `Box::new(_)` of default value (components/script/dom/paintworkletglobalscope.rs:291:29) warning: this creates an owned instance just for comparison (components/script/dom/radionodelist.rs:105:50) * Fix clippy in layout_thread (2013 and 2020) warning: this `if` statement can be collapsed (components/layout_thread/lib.rs:876:17) warning: the following explicit lifetimes could be elided: 'a (components/layout_thread/lib.rs:239 and 2020 same line) warning: deref which would be done by auto-deref (components/layout_thread/lib.rs:500 and 1289) warning: dereferencing a tuple pattern where every element takes a reference (components/layout_thread/lib.rs:503,1562 and 2020 line 1153) warning: useless conversion to the same type: `style::invalidation::element::restyle_hints::RestyleHint` (components/layout_thread_2020/lib.rs:742:36) * Fix clippy in components/servo warning: constants have by default a `'static` lifetime (components/servo/lib.rs:1238:31) warning: creating a `let` binding to a value of unit type, which usually can't be used afterwards (5 occurances in components/servo/lib.rs) * FIx clippy in ports/servoshell warning: this expression creates a reference which is immediately dereferenced by the compiler (ports/servoshell/app.rs:251:89) warning: using `clone` on type `Option<TopLevelBrowsingContextId>` which implements the `Copy` trait (ports/servoshell/webview.rs:122:9)
This commit is contained in:
parent
1f6d358cf9
commit
3d4fd0e550
8 changed files with 49 additions and 55 deletions
|
@ -260,7 +260,7 @@ impl Layout for LayoutThread {
|
|||
self.handle_request(Request::FromFontCache);
|
||||
}
|
||||
|
||||
fn device<'a>(&'a self) -> &'a Device {
|
||||
fn device(&self) -> &Device {
|
||||
self.stylist.device()
|
||||
}
|
||||
|
||||
|
@ -497,10 +497,10 @@ impl Layout for LayoutThread {
|
|||
let properties = properties
|
||||
.drain(..)
|
||||
.filter_map(|name| {
|
||||
let id = PropertyId::parse_enabled_for_all_content(&*name).ok()?;
|
||||
let id = PropertyId::parse_enabled_for_all_content(&name).ok()?;
|
||||
Some((name.clone(), id))
|
||||
})
|
||||
.filter(|&(_, ref id)| !id.is_shorthand())
|
||||
.filter(|(_, id)| !id.is_shorthand())
|
||||
.collect();
|
||||
let registered_painter = RegisteredPainterImpl {
|
||||
name: name.clone(),
|
||||
|
@ -873,40 +873,39 @@ impl LayoutThread {
|
|||
let traversal = ComputeStackingRelativePositions { layout_context };
|
||||
traversal.traverse(layout_root);
|
||||
|
||||
if layout_root
|
||||
if (layout_root
|
||||
.base()
|
||||
.restyle_damage
|
||||
.contains(ServoRestyleDamage::REPAINT) ||
|
||||
self.display_list.borrow().is_none()
|
||||
self.display_list.borrow().is_none()) &&
|
||||
reflow_goal.needs_display_list()
|
||||
{
|
||||
if reflow_goal.needs_display_list() {
|
||||
let background_color = get_root_flow_background_color(layout_root);
|
||||
let mut build_state = sequential::build_display_list_for_subtree(
|
||||
layout_root,
|
||||
layout_context,
|
||||
background_color,
|
||||
data.page_clip_rect.size,
|
||||
);
|
||||
let background_color = get_root_flow_background_color(layout_root);
|
||||
let mut build_state = sequential::build_display_list_for_subtree(
|
||||
layout_root,
|
||||
layout_context,
|
||||
background_color,
|
||||
data.page_clip_rect.size,
|
||||
);
|
||||
|
||||
debug!("Done building display list.");
|
||||
debug!("Done building display list.");
|
||||
|
||||
let root_size = {
|
||||
let root_flow = layout_root.base();
|
||||
root_flow.overflow.scroll.size
|
||||
};
|
||||
let root_size = {
|
||||
let root_flow = layout_root.base();
|
||||
root_flow.overflow.scroll.size
|
||||
};
|
||||
|
||||
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
|
||||
build_state.root_stacking_context.bounds = origin;
|
||||
build_state.root_stacking_context.overflow = origin;
|
||||
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
|
||||
build_state.root_stacking_context.bounds = origin;
|
||||
build_state.root_stacking_context.overflow = origin;
|
||||
|
||||
// We will not use build_state.iframe_sizes again, so it's safe to move it.
|
||||
let iframe_sizes = std::mem::take(&mut build_state.iframe_sizes);
|
||||
self.update_iframe_sizes(iframe_sizes);
|
||||
// We will not use build_state.iframe_sizes again, so it's safe to move it.
|
||||
let iframe_sizes = std::mem::take(&mut build_state.iframe_sizes);
|
||||
self.update_iframe_sizes(iframe_sizes);
|
||||
|
||||
*self.indexable_text.borrow_mut() =
|
||||
std::mem::take(&mut build_state.indexable_text);
|
||||
*self.display_list.borrow_mut() = Some(build_state.to_display_list());
|
||||
}
|
||||
*self.indexable_text.borrow_mut() =
|
||||
std::mem::take(&mut build_state.indexable_text);
|
||||
*self.display_list.borrow_mut() = Some(build_state.to_display_list());
|
||||
}
|
||||
|
||||
if !reflow_goal.needs_display() {
|
||||
|
@ -1286,7 +1285,7 @@ impl LayoutThread {
|
|||
thread_pool: Option<&rayon::ThreadPool>,
|
||||
) {
|
||||
Self::cancel_animations_for_nodes_not_in_flow_tree(
|
||||
&mut *(context.style_context.animations.sets.write()),
|
||||
&mut (context.style_context.animations.sets.write()),
|
||||
FlowRef::deref_mut(root_flow),
|
||||
);
|
||||
|
||||
|
@ -1559,7 +1558,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
|||
)?,
|
||||
];
|
||||
|
||||
for &(ref contents, ref url) in &opts::get().user_stylesheets {
|
||||
for (contents, url) in &opts::get().user_stylesheets {
|
||||
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
||||
Stylesheet::from_bytes(
|
||||
contents,
|
||||
|
|
|
@ -236,7 +236,7 @@ impl Layout for LayoutThread {
|
|||
self.handle_request(Request::FromFontCache);
|
||||
}
|
||||
|
||||
fn device<'a>(&'a self) -> &'a Device {
|
||||
fn device(&self) -> &Device {
|
||||
self.stylist.device()
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ impl LayoutThread {
|
|||
}
|
||||
|
||||
// Stash the data on the element for processing by the style system.
|
||||
style_data.hint.insert(restyle.hint.into());
|
||||
style_data.hint.insert(restyle.hint);
|
||||
style_data.damage = restyle.damage;
|
||||
debug!("Noting restyle for {:?}: {:?}", el, style_data);
|
||||
}
|
||||
|
@ -1150,7 +1150,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
|||
)?,
|
||||
];
|
||||
|
||||
for &(ref contents, ref url) in &opts::get().user_stylesheets {
|
||||
for (contents, url) in &opts::get().user_stylesheets {
|
||||
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
||||
Stylesheet::from_bytes(
|
||||
contents,
|
||||
|
|
|
@ -893,7 +893,7 @@ impl HTMLFormElement {
|
|||
// https://html.spec.whatwg.org/multipage/#submit-body
|
||||
fn submit_entity_body(
|
||||
&self,
|
||||
form_data: &mut Vec<FormDatum>,
|
||||
form_data: &mut [FormDatum],
|
||||
mut load_data: LoadData,
|
||||
enctype: FormEncType,
|
||||
encoding: &'static Encoding,
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom_struct::dom_struct;
|
|||
use euclid::{Scale, Size2D};
|
||||
use js::jsapi::{
|
||||
HandleValueArray, Heap, IsCallable, IsConstructor, JSAutoRealm, JSObject,
|
||||
JS_ClearPendingException, JS_IsExceptionPending, NewArrayObject,
|
||||
JS_ClearPendingException, JS_IsExceptionPending, NewArrayObject, Value,
|
||||
};
|
||||
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
|
||||
use js::rust::wrappers::{Call, Construct1};
|
||||
|
@ -288,7 +288,7 @@ impl PaintWorkletGlobalScope {
|
|||
}
|
||||
// Step 5.4
|
||||
entry
|
||||
.insert(Box::new(Heap::default()))
|
||||
.insert(Box::<Heap<Value>>::default())
|
||||
.set(paint_instance.get());
|
||||
},
|
||||
};
|
||||
|
|
|
@ -102,7 +102,7 @@ impl RadioNodeListMethods for RadioNodeList {
|
|||
// Step 1
|
||||
if let Some(input) = node.downcast::<HTMLInputElement>() {
|
||||
match input.input_type() {
|
||||
InputType::Radio if value == DOMString::from("on") => {
|
||||
InputType::Radio if value == *"on" => {
|
||||
// Step 2
|
||||
let val = input.Value();
|
||||
if val.is_empty() || val == value {
|
||||
|
|
|
@ -1059,8 +1059,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
|
|||
flags: FontInstanceFlags,
|
||||
) -> FontInstanceKey {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self
|
||||
.0
|
||||
self.0
|
||||
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
|
||||
FontToCompositorMsg::AddFontInstance(font_key, size, flags, sender),
|
||||
)));
|
||||
|
@ -1070,8 +1069,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
|
|||
let (sender, receiver) = unbounded();
|
||||
let (bytes_sender, bytes_receiver) =
|
||||
ipc::bytes_channel().expect("failed to create IPC channel");
|
||||
let _ = self
|
||||
.0
|
||||
self.0
|
||||
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
|
||||
FontToCompositorMsg::AddFont(sender, index, bytes_receiver),
|
||||
)));
|
||||
|
@ -1081,8 +1079,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
|
|||
|
||||
fn add_system_font(&self, handle: NativeFontHandle) -> FontKey {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self
|
||||
.0
|
||||
self.0
|
||||
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
|
||||
FontToCompositorMsg::AddSystemFont(sender, handle),
|
||||
)));
|
||||
|
@ -1096,16 +1093,14 @@ struct CanvasWebrenderApi(CompositorProxy);
|
|||
impl canvas_paint_thread::WebrenderApi for CanvasWebrenderApi {
|
||||
fn generate_key(&self) -> Option<ImageKey> {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self
|
||||
.0
|
||||
self.0
|
||||
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Canvas(
|
||||
CanvasToCompositorMsg::GenerateKey(sender),
|
||||
)));
|
||||
receiver.recv().ok()
|
||||
}
|
||||
fn update_images(&self, updates: Vec<canvas_paint_thread::ImageUpdate>) {
|
||||
let _ = self
|
||||
.0
|
||||
self.0
|
||||
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Canvas(
|
||||
CanvasToCompositorMsg::UpdateImages(updates),
|
||||
)));
|
||||
|
@ -1235,29 +1230,29 @@ enum UserAgent {
|
|||
|
||||
fn default_user_agent_string_for(agent: UserAgent) -> &'static str {
|
||||
#[cfg(all(target_os = "linux", target_arch = "x86_64", not(target_env = "ohos")))]
|
||||
const DESKTOP_UA_STRING: &'static str =
|
||||
const DESKTOP_UA_STRING: &str =
|
||||
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Servo/1.0 Firefox/111.0";
|
||||
#[cfg(all(
|
||||
target_os = "linux",
|
||||
not(target_arch = "x86_64"),
|
||||
not(target_env = "ohos")
|
||||
))]
|
||||
const DESKTOP_UA_STRING: &'static str =
|
||||
const DESKTOP_UA_STRING: &str =
|
||||
"Mozilla/5.0 (X11; Linux i686; rv:109.0) Servo/1.0 Firefox/111.0";
|
||||
|
||||
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
|
||||
const DESKTOP_UA_STRING: &'static str =
|
||||
const DESKTOP_UA_STRING: &str =
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Servo/1.0 Firefox/111.0";
|
||||
#[cfg(all(target_os = "windows", not(target_arch = "x86_64")))]
|
||||
const DESKTOP_UA_STRING: &'static str =
|
||||
const DESKTOP_UA_STRING: &str =
|
||||
"Mozilla/5.0 (Windows NT 10.0; rv:109.0) Servo/1.0 Firefox/111.0";
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
const DESKTOP_UA_STRING: &'static str =
|
||||
const DESKTOP_UA_STRING: &str =
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Servo/1.0 Firefox/111.0";
|
||||
|
||||
#[cfg(any(target_os = "android", target_env = "ohos"))]
|
||||
const DESKTOP_UA_STRING: &'static str = "";
|
||||
const DESKTOP_UA_STRING: &str = "";
|
||||
|
||||
match agent {
|
||||
UserAgent::Desktop => DESKTOP_UA_STRING,
|
||||
|
|
|
@ -248,7 +248,7 @@ impl App {
|
|||
window_id: _,
|
||||
} => {
|
||||
let response =
|
||||
minibrowser.on_window_event(window.winit_window().unwrap(), &event);
|
||||
minibrowser.on_window_event(window.winit_window().unwrap(), event);
|
||||
// Update minibrowser if there's resize event to sync up with window.
|
||||
if let WindowEvent::Resized(_) = event {
|
||||
minibrowser.update(
|
||||
|
|
|
@ -119,7 +119,7 @@ where
|
|||
}
|
||||
|
||||
pub fn focused_webview_id(&self) -> Option<WebViewId> {
|
||||
self.focused_webview_id.clone()
|
||||
self.focused_webview_id
|
||||
}
|
||||
|
||||
pub fn current_url_string(&self) -> Option<&str> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue