diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 10 | ||||
-rw-r--r-- | components/layout/construct.rs | 18 | ||||
-rw-r--r-- | components/layout/css/matching.rs | 26 | ||||
-rw-r--r-- | components/layout/fragment.rs | 22 | ||||
-rw-r--r-- | components/layout/generated_content.rs | 4 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 4 | ||||
-rw-r--r-- | components/layout/query.rs | 4 | ||||
-rw-r--r-- | components/layout/table_row.rs | 18 | ||||
-rw-r--r-- | components/layout/text.rs | 13 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 4 |
10 files changed, 48 insertions, 75 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 5b34977b484..7de0d52ef42 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -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 diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 6e6ea30332c..89c895ca4f2 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -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() { diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index e83899e2893..bffd6188344 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -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 - } + 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 + } - return Some(candidate.style.clone()) + // Check tag names, classes, etc. + if !candidate.can_share_style_with(self) { + return None } - _ => {} - } + return Some(candidate.style.clone()) + } None } } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index cf88e24aba3..828cdeabf8d 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -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) } } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 686d9ec3920..fd1f1d2f219 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -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() } } } diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index da3b7518f3f..88425fde26b 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -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() } diff --git a/components/layout/query.rs b/components/layout/query.rs index ff084a1adf8..1b1f0907a4b 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -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, diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 731285221f7..c3b318acd61 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -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, diff --git a/components/layout/text.rs b/components/layout/text.rs index b561b8d5da1..d28cea4c0e2 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -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 diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index c2092a81e21..147fda916e3 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -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 { |