mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Fix a bunch of clippy lints
This commit is contained in:
parent
b1ca3d1cdf
commit
6b215f38ee
58 changed files with 281 additions and 356 deletions
|
@ -1520,12 +1520,10 @@ impl BlockFlow {
|
|||
}
|
||||
|
||||
fn determine_if_layer_needed(&mut self) {
|
||||
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||
// Fixed position layers get layers.
|
||||
if self.is_fixed() {
|
||||
self.base.flags.insert(NEEDS_LAYER);
|
||||
return
|
||||
}
|
||||
// Fixed position layers get layers.
|
||||
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.is_fixed() {
|
||||
self.base.flags.insert(NEEDS_LAYER);
|
||||
return
|
||||
}
|
||||
|
||||
// This flow needs a layer if it has a 3d transform, or provides perspective
|
||||
|
|
|
@ -1102,12 +1102,9 @@ impl<'a, 'ln, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'ln>>
|
|||
node,
|
||||
caption_side::T::top);
|
||||
|
||||
match construction_result {
|
||||
ConstructionResult::Flow(table_flow, table_abs_descendants) => {
|
||||
wrapper_flow.add_new_child(table_flow);
|
||||
abs_descendants.push_descendants(table_abs_descendants);
|
||||
}
|
||||
_ => {}
|
||||
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
|
||||
wrapper_flow.add_new_child(table_flow);
|
||||
abs_descendants.push_descendants(table_abs_descendants);
|
||||
}
|
||||
|
||||
// If the value of `caption-side` is `bottom`, place it now.
|
||||
|
@ -1271,12 +1268,9 @@ impl<'a, 'ln, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'ln>>
|
|||
for kid in node.children() {
|
||||
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
|
||||
// as `display: none`.
|
||||
match kid.swap_out_construction_result() {
|
||||
ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(
|
||||
fragment)) => {
|
||||
col_fragments.push(fragment);
|
||||
}
|
||||
_ => {}
|
||||
if let ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(fragment))
|
||||
= kid.swap_out_construction_result() {
|
||||
col_fragments.push(fragment)
|
||||
}
|
||||
}
|
||||
if col_fragments.is_empty() {
|
||||
|
|
|
@ -236,24 +236,20 @@ impl<'le, ConcreteElement> PrivateElementMatchMethods<'le, ConcreteElement>
|
|||
let parent_data: Option<&PrivateStyleData> = unsafe {
|
||||
parent_node.borrow_data_unchecked().map(|d| &*d)
|
||||
};
|
||||
match parent_data {
|
||||
Some(parent_data_ref) => {
|
||||
// Check parent style.
|
||||
let parent_style = (*parent_data_ref).style.as_ref().unwrap();
|
||||
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
|
||||
return None
|
||||
}
|
||||
|
||||
// Check tag names, classes, etc.
|
||||
if !candidate.can_share_style_with(self) {
|
||||
return None
|
||||
}
|
||||
|
||||
return Some(candidate.style.clone())
|
||||
if let Some(parent_data_ref) = parent_data {
|
||||
// Check parent style.
|
||||
let parent_style = (*parent_data_ref).style.as_ref().unwrap();
|
||||
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
|
||||
return None
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Check tag names, classes, etc.
|
||||
if !candidate.can_share_style_with(self) {
|
||||
return None
|
||||
}
|
||||
|
||||
return Some(candidate.style.clone())
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2006,24 +2006,18 @@ impl Fragment {
|
|||
}
|
||||
|
||||
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
|
||||
match self.specific {
|
||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||
let position = self.border_box.start.i;
|
||||
flow_ref::deref_mut(&mut info.flow_ref)
|
||||
.update_late_computed_inline_position_if_necessary(position)
|
||||
}
|
||||
_ => {}
|
||||
if let SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) = self.specific {
|
||||
let position = self.border_box.start.i;
|
||||
flow_ref::deref_mut(&mut info.flow_ref)
|
||||
.update_late_computed_inline_position_if_necessary(position)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_late_computed_block_position_if_necessary(&mut self) {
|
||||
match self.specific {
|
||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||
let position = self.border_box.start.b;
|
||||
flow_ref::deref_mut(&mut info.flow_ref)
|
||||
.update_late_computed_block_position_if_necessary(position)
|
||||
}
|
||||
_ => {}
|
||||
if let SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) = self.specific {
|
||||
let position = self.border_box.start.b;
|
||||
flow_ref::deref_mut(&mut info.flow_ref)
|
||||
.update_late_computed_block_position_if_necessary(position)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,9 +302,9 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
|||
"es.0[self.traversal.quote as usize]
|
||||
};
|
||||
if close {
|
||||
close_quote.to_string()
|
||||
close_quote.clone()
|
||||
} else {
|
||||
open_quote.to_string()
|
||||
open_quote.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -654,7 +654,7 @@ impl LayoutTask {
|
|||
// FIXME(njn): Just measuring the display tree for now.
|
||||
let rw_data = possibly_locked_rw_data.lock();
|
||||
let stacking_context = rw_data.stacking_context.as_ref();
|
||||
let ref formatted_url = format!("url({})", *self.url.borrow());
|
||||
let formatted_url = &format!("url({})", *self.url.borrow());
|
||||
reports.push(Report {
|
||||
path: path![formatted_url, "layout-task", "display-list"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
|
@ -731,7 +731,7 @@ impl LayoutTask {
|
|||
|
||||
/// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely)
|
||||
/// crash.
|
||||
fn exit_now<'a, 'b>(&mut self) {
|
||||
fn exit_now(&mut self) {
|
||||
if let Some(ref mut traversal) = self.parallel_traversal {
|
||||
traversal.shutdown()
|
||||
}
|
||||
|
|
|
@ -480,7 +480,7 @@ pub fn process_resolved_style_request<'ln, N: LayoutNode<'ln>>(
|
|||
requested_node: N,
|
||||
property: &Atom) -> Option<String> {
|
||||
let maybe_data = layout_node.borrow_layout_data();
|
||||
let position = maybe_data.map(|data| {
|
||||
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
||||
match (*data).flow_construction_result {
|
||||
ConstructionResult::Flow(ref flow_ref, _) =>
|
||||
flow::base(flow_ref.deref()).stacking_relative_position,
|
||||
|
@ -488,7 +488,7 @@ pub fn process_resolved_style_request<'ln, N: LayoutNode<'ln>>(
|
|||
// https://github.com/servo/servo/issues/8307
|
||||
_ => Point2D::zero()
|
||||
}
|
||||
}).unwrap_or(Point2D::zero());
|
||||
});
|
||||
let property = match *property {
|
||||
atom!("bottom") => PositionProperty::Bottom,
|
||||
atom!("top") => PositionProperty::Top,
|
||||
|
|
|
@ -747,33 +747,27 @@ fn set_inline_position_of_child_flow(
|
|||
inline_start_border: border_collapse_info.collapsed_borders_for_row
|
||||
.inline
|
||||
.get(child_index)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(CollapsedBorder::new()),
|
||||
.map_or(CollapsedBorder::new(), |x| *x),
|
||||
inline_end_border: border_collapse_info.collapsed_borders_for_row
|
||||
.inline
|
||||
.get(child_index + 1)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(CollapsedBorder::new()),
|
||||
.map_or(CollapsedBorder::new(), |x| *x),
|
||||
block_start_border: border_collapse_info.collapsed_borders_for_row
|
||||
.block_start
|
||||
.get(child_index)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(CollapsedBorder::new()),
|
||||
.map_or(CollapsedBorder::new(), |x| *x),
|
||||
block_end_border: border_collapse_info.collapsed_borders_for_row
|
||||
.block_end
|
||||
.get(child_index)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(CollapsedBorder::new()),
|
||||
.map_or(CollapsedBorder::new(), |x| *x),
|
||||
inline_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||
.inline
|
||||
.get(child_index)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(Au(0)),
|
||||
.map_or(Au(0), |x| *x),
|
||||
inline_end_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||
.inline
|
||||
.get(child_index + 1)
|
||||
.map(|x| *x)
|
||||
.unwrap_or(Au(0)),
|
||||
.map_or(Au(0), |x| *x),
|
||||
block_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||
.block_start,
|
||||
block_end_width: border_collapse_info.collapsed_border_spacing_for_row.block_end,
|
||||
|
|
|
@ -38,15 +38,12 @@ fn text(fragments: &LinkedList<Fragment>) -> String {
|
|||
let mut text = String::new();
|
||||
|
||||
for fragment in fragments {
|
||||
match fragment.specific {
|
||||
SpecificFragmentInfo::UnscannedText(ref info) => {
|
||||
if fragment.white_space().preserve_newlines() {
|
||||
text.push_str(&info.text);
|
||||
} else {
|
||||
text.push_str(&info.text.replace("\n", " "));
|
||||
}
|
||||
if let SpecificFragmentInfo::UnscannedText(ref info) = fragment.specific {
|
||||
if fragment.white_space().preserve_newlines() {
|
||||
text.push_str(&info.text);
|
||||
} else {
|
||||
text.push_str(&info.text.replace("\n", " "));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
text
|
||||
|
|
|
@ -198,7 +198,7 @@ impl<'ln> TNode<'ln> for ServoLayoutNode<'ln> {
|
|||
}
|
||||
|
||||
fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
|
||||
self.node.downcast().map(|document| ServoLayoutDocument::from_layout_js(document))
|
||||
self.node.downcast().map(ServoLayoutDocument::from_layout_js)
|
||||
}
|
||||
|
||||
fn has_changed(&self) -> bool {
|
||||
|
@ -432,7 +432,7 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
|
||||
node.downcast().map(|element| ServoLayoutElement::from_layout_js(element))
|
||||
node.downcast().map(ServoLayoutElement::from_layout_js)
|
||||
}
|
||||
|
||||
macro_rules! state_getter {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue