mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
clippy: Fix warnings in components/shared
(#31627)
* clippy: fix warnings in `components/shared` * fix: formatting derive * fix: rename new to default
This commit is contained in:
parent
4efebf1e62
commit
21939c2ba8
11 changed files with 36 additions and 50 deletions
|
@ -3547,7 +3547,7 @@ impl Document {
|
||||||
RefMut::map(map, |m| {
|
RefMut::map(map, |m| {
|
||||||
&mut m
|
&mut m
|
||||||
.entry(Dom::from_ref(el))
|
.entry(Dom::from_ref(el))
|
||||||
.or_insert_with(|| NoTrace(PendingRestyle::new()))
|
.or_insert_with(|| NoTrace(PendingRestyle::default()))
|
||||||
.0
|
.0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> LayoutNode<'dom>
|
||||||
unsafe fn initialize_data(&self) {
|
unsafe fn initialize_data(&self) {
|
||||||
if self.get_style_and_opaque_layout_data().is_none() {
|
if self.get_style_and_opaque_layout_data().is_none() {
|
||||||
let opaque = StyleAndOpaqueLayoutData::new(
|
let opaque = StyleAndOpaqueLayoutData::new(
|
||||||
StyleData::new(),
|
StyleData::default(),
|
||||||
AtomicRefCell::new(LayoutDataType::default()),
|
AtomicRefCell::new(LayoutDataType::default()),
|
||||||
);
|
);
|
||||||
self.init_style_and_opaque_layout_data(opaque);
|
self.init_style_and_opaque_layout_data(opaque);
|
||||||
|
|
|
@ -207,6 +207,7 @@ impl RequestBody {
|
||||||
self.source == BodySource::Null
|
self.source == BodySource::Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> Option<usize> {
|
pub fn len(&self) -> Option<usize> {
|
||||||
self.total_bytes
|
self.total_bytes
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ impl ScrollTreeNode {
|
||||||
|
|
||||||
let scrollable_width = info.scrollable_size.width;
|
let scrollable_width = info.scrollable_size.width;
|
||||||
let scrollable_height = info.scrollable_size.height;
|
let scrollable_height = info.scrollable_size.height;
|
||||||
let original_layer_scroll_offset = info.offset.clone();
|
let original_layer_scroll_offset = info.offset;
|
||||||
|
|
||||||
if scrollable_width > 0. {
|
if scrollable_width > 0. {
|
||||||
info.offset.x = (info.offset.x + delta.x).min(0.0).max(-scrollable_width);
|
info.offset.x = (info.offset.x + delta.x).min(0.0).max(-scrollable_width);
|
||||||
|
@ -172,10 +172,10 @@ impl ScrollTree {
|
||||||
parent: parent.cloned(),
|
parent: parent.cloned(),
|
||||||
scroll_info,
|
scroll_info,
|
||||||
});
|
});
|
||||||
return ScrollTreeNodeId {
|
ScrollTreeNodeId {
|
||||||
index: self.nodes.len() - 1,
|
index: self.nodes.len() - 1,
|
||||||
spatial_id,
|
spatial_id,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a mutable reference to the node with the given index.
|
/// Get a mutable reference to the node with the given index.
|
||||||
|
@ -198,7 +198,7 @@ impl ScrollTree {
|
||||||
scroll_location: ScrollLocation,
|
scroll_location: ScrollLocation,
|
||||||
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
||||||
let parent = {
|
let parent = {
|
||||||
let ref mut node = self.get_node_mut(scroll_node_id);
|
let node = &mut self.get_node_mut(scroll_node_id);
|
||||||
let result = node.scroll(scroll_location);
|
let result = node.scroll(scroll_location);
|
||||||
if result.is_some() {
|
if result.is_some() {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -194,14 +194,14 @@ impl LoadData {
|
||||||
) -> LoadData {
|
) -> LoadData {
|
||||||
LoadData {
|
LoadData {
|
||||||
load_origin,
|
load_origin,
|
||||||
url: url,
|
url,
|
||||||
creator_pipeline_id: creator_pipeline_id,
|
creator_pipeline_id,
|
||||||
method: Method::GET,
|
method: Method::GET,
|
||||||
headers: HeaderMap::new(),
|
headers: HeaderMap::new(),
|
||||||
data: None,
|
data: None,
|
||||||
js_eval_result: None,
|
js_eval_result: None,
|
||||||
referrer: referrer,
|
referrer,
|
||||||
referrer_policy: referrer_policy,
|
referrer_policy,
|
||||||
srcdoc: "".to_string(),
|
srcdoc: "".to_string(),
|
||||||
inherited_secure_context,
|
inherited_secure_context,
|
||||||
crash: None,
|
crash: None,
|
||||||
|
@ -977,7 +977,7 @@ impl StructuredSerializedData {
|
||||||
// Note: we insert the blob at the original id,
|
// Note: we insert the blob at the original id,
|
||||||
// otherwise this will not match the storage key as serialized by SM in `serialized`.
|
// otherwise this will not match the storage key as serialized by SM in `serialized`.
|
||||||
// The clone has it's own new Id however.
|
// The clone has it's own new Id however.
|
||||||
blob_clones.insert(original_id.clone(), blob_clone);
|
blob_clones.insert(*original_id, blob_clone);
|
||||||
} else {
|
} else {
|
||||||
// Not panicking only because this is called from the constellation.
|
// Not panicking only because this is called from the constellation.
|
||||||
warn!("Serialized blob not in memory format(should never happen).");
|
warn!("Serialized blob not in memory format(should never happen).");
|
||||||
|
@ -1263,7 +1263,7 @@ impl WebrenderIpcSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
senders.into_iter().for_each(|(tx, data)| {
|
senders.into_iter().for_each(|(tx, data)| {
|
||||||
if let Err(e) = tx.send(&*data) {
|
if let Err(e) = tx.send(&data) {
|
||||||
warn!("error sending image data: {}", e);
|
warn!("error sending image data: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1308,8 +1308,8 @@ impl SerializedImageData {
|
||||||
/// Convert to ``ImageData`.
|
/// Convert to ``ImageData`.
|
||||||
pub fn to_image_data(&self) -> Result<ImageData, ipc::IpcError> {
|
pub fn to_image_data(&self) -> Result<ImageData, ipc::IpcError> {
|
||||||
match self {
|
match self {
|
||||||
SerializedImageData::Raw(rx) => rx.recv().map(|data| ImageData::new(data)),
|
SerializedImageData::Raw(rx) => rx.recv().map(ImageData::new),
|
||||||
SerializedImageData::External(image) => Ok(ImageData::External(image.clone())),
|
SerializedImageData::External(image) => Ok(ImageData::External(*image)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,6 +402,7 @@ pub enum JobError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
/// Messages sent from Job algorithms steps running in the SW manager,
|
/// Messages sent from Job algorithms steps running in the SW manager,
|
||||||
/// in order to resolve or reject the job promise.
|
/// in order to resolve or reject the job promise.
|
||||||
pub enum JobResult {
|
pub enum JobResult {
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl FileBlob {
|
||||||
|
|
||||||
/// Get the size of the file.
|
/// Get the size of the file.
|
||||||
pub fn get_size(&self) -> u64 {
|
pub fn get_size(&self) -> u64 {
|
||||||
self.size.clone()
|
self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the cached file data, if any.
|
/// Get the cached file data, if any.
|
||||||
|
@ -56,7 +56,7 @@ impl FileBlob {
|
||||||
|
|
||||||
/// Get the file id.
|
/// Get the file id.
|
||||||
pub fn get_id(&self) -> Uuid {
|
pub fn get_id(&self) -> Uuid {
|
||||||
self.id.clone()
|
self.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ impl BlobImpl {
|
||||||
id: file_id,
|
id: file_id,
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
cache: RefCell::new(None),
|
cache: RefCell::new(None),
|
||||||
size: size,
|
size,
|
||||||
});
|
});
|
||||||
BlobImpl {
|
BlobImpl {
|
||||||
blob_id,
|
blob_id,
|
||||||
|
@ -131,7 +131,7 @@ impl BlobImpl {
|
||||||
|
|
||||||
/// Get a clone of the blob-id
|
/// Get a clone of the blob-id
|
||||||
pub fn blob_id(&self) -> BlobId {
|
pub fn blob_id(&self) -> BlobId {
|
||||||
self.blob_id.clone()
|
self.blob_id
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a clone of the type-string
|
/// Get a clone of the type-string
|
||||||
|
|
|
@ -63,7 +63,7 @@ impl MessagePortImpl {
|
||||||
|
|
||||||
/// Maybe get the Id of the entangled port.
|
/// Maybe get the Id of the entangled port.
|
||||||
pub fn entangled_port_id(&self) -> Option<MessagePortId> {
|
pub fn entangled_port_id(&self) -> Option<MessagePortId> {
|
||||||
self.entangled_port.clone()
|
self.entangled_port
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Entanged this port with another.
|
/// Entanged this port with another.
|
||||||
|
@ -73,10 +73,7 @@ impl MessagePortImpl {
|
||||||
|
|
||||||
/// Is this port enabled?
|
/// Is this port enabled?
|
||||||
pub fn enabled(&self) -> bool {
|
pub fn enabled(&self) -> bool {
|
||||||
match self.state {
|
matches!(self.state, MessagePortState::Enabled(_))
|
||||||
MessagePortState::Enabled(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark this port as having been shipped.
|
/// Mark this port as having been shipped.
|
||||||
|
|
|
@ -49,11 +49,11 @@ pub struct StyleData {
|
||||||
pub parallel: DomParallelInfo,
|
pub parallel: DomParallelInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StyleData {
|
impl Default for StyleData {
|
||||||
pub fn new() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
element_data: AtomicRefCell::new(ElementData::default()),
|
element_data: AtomicRefCell::new(ElementData::default()),
|
||||||
parallel: DomParallelInfo::new(),
|
parallel: DomParallelInfo::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,20 +86,12 @@ impl StyleAndOpaqueLayoutData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information that we need stored in each DOM node.
|
/// Information that we need stored in each DOM node.
|
||||||
#[derive(MallocSizeOf)]
|
#[derive(Default, MallocSizeOf)]
|
||||||
pub struct DomParallelInfo {
|
pub struct DomParallelInfo {
|
||||||
/// The number of children remaining to process during bottom-up traversal.
|
/// The number of children remaining to process during bottom-up traversal.
|
||||||
pub children_to_process: AtomicIsize,
|
pub children_to_process: AtomicIsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DomParallelInfo {
|
|
||||||
pub fn new() -> DomParallelInfo {
|
|
||||||
DomParallelInfo {
|
|
||||||
children_to_process: AtomicIsize::new(0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
pub enum LayoutNodeType {
|
pub enum LayoutNodeType {
|
||||||
Element(LayoutElementType),
|
Element(LayoutElementType),
|
||||||
|
|
|
@ -199,11 +199,11 @@ pub struct PendingRestyle {
|
||||||
pub damage: RestyleDamage,
|
pub damage: RestyleDamage,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PendingRestyle {
|
impl Default for PendingRestyle {
|
||||||
/// Creates a new empty pending restyle.
|
/// Creates a new empty pending restyle.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> Self {
|
fn default() -> Self {
|
||||||
PendingRestyle {
|
Self {
|
||||||
snapshot: None,
|
snapshot: None,
|
||||||
hint: RestyleHint::empty(),
|
hint: RestyleHint::empty(),
|
||||||
damage: RestyleDamage::empty(),
|
damage: RestyleDamage::empty(),
|
||||||
|
|
|
@ -50,17 +50,11 @@ impl PseudoElementType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_before(&self) -> bool {
|
pub fn is_before(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, PseudoElementType::Before)
|
||||||
PseudoElementType::Before => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_replaced_content(&self) -> bool {
|
pub fn is_replaced_content(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, PseudoElementType::Before | PseudoElementType::After)
|
||||||
PseudoElementType::Before | PseudoElementType::After => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn style_pseudo_element(&self) -> PseudoElement {
|
pub fn style_pseudo_element(&self) -> PseudoElement {
|
||||||
|
@ -138,9 +132,8 @@ where
|
||||||
ConcreteNode: LayoutNode<'dom>,
|
ConcreteNode: LayoutNode<'dom>,
|
||||||
{
|
{
|
||||||
fn new(root: ConcreteNode) -> TreeIterator<ConcreteNode> {
|
fn new(root: ConcreteNode) -> TreeIterator<ConcreteNode> {
|
||||||
let mut stack = vec![];
|
let stack = vec![root];
|
||||||
stack.push(root);
|
TreeIterator { stack }
|
||||||
TreeIterator { stack: stack }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_skipping_children(&mut self) -> Option<ConcreteNode> {
|
pub fn next_skipping_children(&mut self) -> Option<ConcreteNode> {
|
||||||
|
@ -155,7 +148,9 @@ where
|
||||||
type Item = ConcreteNode;
|
type Item = ConcreteNode;
|
||||||
fn next(&mut self) -> Option<ConcreteNode> {
|
fn next(&mut self) -> Option<ConcreteNode> {
|
||||||
let ret = self.stack.pop();
|
let ret = self.stack.pop();
|
||||||
ret.map(|node| self.stack.extend(node.rev_children()));
|
if let Some(node) = ret {
|
||||||
|
self.stack.extend(node.rev_children())
|
||||||
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue