diff --git a/components/layout/block.rs b/components/layout/block.rs index e4463072b32..b0bd785ac3a 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1761,7 +1761,7 @@ impl BlockFlow { // If you remove the might_have_floats_in conditional, this will go off. // TODO(servo#30572) revert to debug_assert!() once underlying bug is fixed #[cfg(debug_assertions)] - if !(!self.is_inline_flex_item()) { + if self.is_inline_flex_item() { log::warn!("debug assertion failed! !self.is_inline_flex_item()"); } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index f2fa3cb9104..2a615c944b3 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -199,7 +199,7 @@ impl InlineBlockSplit { fragment_accumulator, InlineFragmentsAccumulator::from_inline_node(node, style_context), ) - .to_intermediate_inline_fragments::(style_context), + .get_intermediate_inline_fragments::(style_context), flow, }; @@ -305,7 +305,7 @@ impl InlineFragmentsAccumulator { .push_descendants(fragments.absolute_descendants); } - fn to_intermediate_inline_fragments<'dom, N>( + fn get_intermediate_inline_fragments<'dom, N>( self, context: &SharedStyleContext, ) -> IntermediateInlineFragments @@ -482,7 +482,9 @@ where node: &ConcreteThreadSafeLayoutNode, ) { let mut fragments = fragment_accumulator - .to_intermediate_inline_fragments::(self.style_context()); + .get_intermediate_inline_fragments::( + self.style_context(), + ); if fragments.is_empty() { return; }; @@ -1079,7 +1081,7 @@ where ConstructionItem::InlineFragments(InlineFragmentsConstructionResult { splits: opt_inline_block_splits, fragments: fragment_accumulator - .to_intermediate_inline_fragments::( + .get_intermediate_inline_fragments::( self.style_context(), ), }); @@ -1196,7 +1198,7 @@ where ConstructionItem::InlineFragments(InlineFragmentsConstructionResult { splits: LinkedList::new(), fragments: fragment_accumulator - .to_intermediate_inline_fragments::(context), + .get_intermediate_inline_fragments::(context), }); ConstructionResult::ConstructionItem(construction_item) } @@ -1246,7 +1248,7 @@ where ConstructionItem::InlineFragments(InlineFragmentsConstructionResult { splits: LinkedList::new(), fragments: fragment_accumulator - .to_intermediate_inline_fragments::( + .get_intermediate_inline_fragments::( style_context, ), }); diff --git a/components/layout/context.rs b/components/layout/context.rs index eb25b5bd51d..d43210c141b 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -55,6 +55,9 @@ pub fn malloc_size_of_persistent_local_context(ops: &mut MallocSizeOfOps) -> usi }) } +type WebrenderImageCache = + HashMap<(ServoUrl, UsePlaceholder), WebRenderImageInfo, BuildHasherDefault>; + /// Layout information shared among all workers. This must be thread-safe. pub struct LayoutContext<'a> { /// The pipeline id of this LayoutContext. @@ -73,11 +76,7 @@ pub struct LayoutContext<'a> { pub font_cache_thread: Mutex, /// A cache of WebRender image info. - pub webrender_image_cache: Arc< - RwLock< - HashMap<(ServoUrl, UsePlaceholder), WebRenderImageInfo, BuildHasherDefault>, - >, - >, + pub webrender_image_cache: Arc>, /// Paint worklets pub registered_painters: &'a dyn RegisteredPainters, diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 5e5738a0f4b..0f064c9c3aa 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +#![allow(clippy::too_many_arguments)] + use app_units::Au; use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use style::computed_values::background_attachment::single_value::T as BackgroundAttachment; diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index d453fdfe8e8..6d070f3d525 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -8,6 +8,8 @@ //! list building, as the actual painting does not happen here—only deciding *what* we're going to //! paint. +#![allow(clippy::too_many_arguments)] + use std::default::Default; use std::sync::Arc; use std::{f32, mem}; @@ -443,7 +445,7 @@ impl<'a> DisplayListBuildState<'a> { let mut list = Vec::new(); let root_context = mem::replace(&mut self.root_stacking_context, StackingContext::root()); - self.to_display_list_for_stacking_context(&mut list, root_context); + self.move_to_display_list_for_stacking_context(&mut list, root_context); DisplayList { list, @@ -451,7 +453,7 @@ impl<'a> DisplayListBuildState<'a> { } } - fn to_display_list_for_stacking_context( + fn move_to_display_list_for_stacking_context( &mut self, list: &mut Vec, stacking_context: StackingContext, @@ -473,7 +475,7 @@ impl<'a> DisplayListBuildState<'a> { .into_iter() .map(|index| index.to_define_item()), ); - self.to_display_list_for_items(list, child_items, info.children); + self.move_to_display_list_for_items(list, child_items, info.children); } else { let (push_item, pop_item) = stacking_context.to_display_list_items(); list.push(push_item); @@ -482,12 +484,12 @@ impl<'a> DisplayListBuildState<'a> { .into_iter() .map(|index| index.to_define_item()), ); - self.to_display_list_for_items(list, child_items, info.children); + self.move_to_display_list_for_items(list, child_items, info.children); list.push(pop_item); } } - fn to_display_list_for_items( + fn move_to_display_list_for_items( &mut self, list: &mut Vec, mut child_items: Vec, @@ -509,7 +511,7 @@ impl<'a> DisplayListBuildState<'a> { .map_or(false, |child| child.z_index < 0) { let context = child_stacking_contexts.next().unwrap(); - self.to_display_list_for_stacking_context(list, context); + self.move_to_display_list_for_stacking_context(list, context); } // Step 4: Block backgrounds and borders. @@ -524,7 +526,7 @@ impl<'a> DisplayListBuildState<'a> { child.context_type == StackingContextType::PseudoFloat }) { let context = child_stacking_contexts.next().unwrap(); - self.to_display_list_for_stacking_context(list, context); + self.move_to_display_list_for_stacking_context(list, context); } // Step 6 & 7: Content and inlines that generate stacking contexts. @@ -536,7 +538,7 @@ impl<'a> DisplayListBuildState<'a> { // Step 8 & 9: Positioned descendants with nonnegative, numeric z-indices. for child in child_stacking_contexts { - self.to_display_list_for_stacking_context(list, child); + self.move_to_display_list_for_stacking_context(list, child); } // Step 10: Outlines. @@ -2642,10 +2644,10 @@ impl BlockFlow { // The margins control which edges have sticky behavior. let sticky_frame_data = StickyFrameData { margins: SideOffsets2D::new( - sticky_position.top.to_option().map(|v| v.to_f32_px()), - sticky_position.right.to_option().map(|v| v.to_f32_px()), - sticky_position.bottom.to_option().map(|v| v.to_f32_px()), - sticky_position.left.to_option().map(|v| v.to_f32_px()), + sticky_position.top.as_option().map(|v| v.to_f32_px()), + sticky_position.right.as_option().map(|v| v.to_f32_px()), + sticky_position.bottom.as_option().map(|v| v.to_f32_px()), + sticky_position.left.as_option().map(|v| v.to_f32_px()), ), vertical_offset_bounds, horizontal_offset_bounds, diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 9f1d6d76df5..6343c341081 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -12,6 +12,8 @@ //! They are therefore not exactly analogous to constructs like Skia pictures, which consist of //! low-level drawing primitives. +#![allow(clippy::too_many_arguments)] + use std::cmp::Ordering; use std::collections::HashMap; use std::{f32, fmt}; diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 1f5b7104780..29152507c12 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -250,7 +250,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static { fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState); /// If this is a float, places it. The default implementation does nothing. - fn place_float_if_applicable<'a>(&mut self) {} + fn place_float_if_applicable(&mut self) {} /// Assigns block-sizes in-order; or, if this is a float, places the float. The default /// implementation simply assigns block-sizes if this flow might have floats in. Returns true @@ -505,6 +505,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static { } } +#[allow(clippy::wrong_self_convention)] pub trait ImmutableFlowUtils { // Convenience functions @@ -603,18 +604,18 @@ pub enum FlowClass { impl FlowClass { fn is_block_like(self) -> bool { - match self { + matches!( + self, FlowClass::Block | - FlowClass::ListItem | - FlowClass::Table | - FlowClass::TableRowGroup | - FlowClass::TableRow | - FlowClass::TableCaption | - FlowClass::TableCell | - FlowClass::TableWrapper | - FlowClass::Flex => true, - _ => false, - } + FlowClass::ListItem | + FlowClass::Table | + FlowClass::TableRowGroup | + FlowClass::TableRow | + FlowClass::TableCaption | + FlowClass::TableCell | + FlowClass::TableWrapper | + FlowClass::Flex + ) } } @@ -1232,50 +1233,32 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow { /// Returns true if this flow is a table row flow. fn is_table_row(self) -> bool { - match self.class() { - FlowClass::TableRow => true, - _ => false, - } + matches!(self.class(), FlowClass::TableRow) } /// Returns true if this flow is a table cell flow. fn is_table_cell(self) -> bool { - match self.class() { - FlowClass::TableCell => true, - _ => false, - } + matches!(self.class(), FlowClass::TableCell) } /// Returns true if this flow is a table colgroup flow. fn is_table_colgroup(self) -> bool { - match self.class() { - FlowClass::TableColGroup => true, - _ => false, - } + matches!(self.class(), FlowClass::TableColGroup) } /// Returns true if this flow is a table flow. fn is_table(self) -> bool { - match self.class() { - FlowClass::Table => true, - _ => false, - } + matches!(self.class(), FlowClass::Table) } /// Returns true if this flow is a table caption flow. fn is_table_caption(self) -> bool { - match self.class() { - FlowClass::TableCaption => true, - _ => false, - } + matches!(self.class(), FlowClass::TableCaption) } /// Returns true if this flow is a table rowgroup flow. fn is_table_rowgroup(self) -> bool { - match self.class() { - FlowClass::TableRowGroup => true, - _ => false, - } + matches!(self.class(), FlowClass::TableRowGroup) } /// Returns the number of children that this flow possesses. @@ -1285,18 +1268,12 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow { /// Returns true if this flow is a block flow. fn is_block_flow(self) -> bool { - match self.class() { - FlowClass::Block => true, - _ => false, - } + matches!(self.class(), FlowClass::Block) } /// Returns true if this flow is an inline flow. fn is_inline_flow(self) -> bool { - match self.class() { - FlowClass::Inline => true, - _ => false, - } + matches!(self.class(), FlowClass::Inline) } /// Dumps the flow tree for debugging. @@ -1392,7 +1369,7 @@ impl MutableOwnedFlowUtils for FlowRef { for descendant_link in abs_descendants.descendant_links.iter_mut() { // TODO(servo#30573) revert to debug_assert!() once underlying bug is fixed #[cfg(debug_assertions)] - if !(!descendant_link.has_reached_containing_block) { + if descendant_link.has_reached_containing_block { log::warn!("debug assertion failed! !descendant_link.has_reached_containing_block"); } let descendant_base = FlowRef::deref_mut(&mut descendant_link.flow).mut_base(); diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index b0955e66448..4657db77040 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -49,6 +49,7 @@ impl FlowRef { /// See . /// Use Arc::get_mut instead when possible (e.g. on an Arc that was just created). #[allow(unsafe_code)] + #[allow(clippy::should_implement_trait)] pub fn deref_mut(this: &mut FlowRef) -> &mut dyn Flow { let ptr: *const dyn Flow = &*this.0; unsafe { &mut *(ptr as *mut dyn Flow) } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 6884d4cbe6b..40233a2fc93 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1592,9 +1592,8 @@ impl Fragment { /// Returns true if and only if this fragment is a generated content fragment. pub fn is_unscanned_generated_content(&self) -> bool { match self.specific { - SpecificFragmentInfo::GeneratedContent(ref content) => match **content { - GeneratedContentInfo::Empty => false, - _ => true, + SpecificFragmentInfo::GeneratedContent(ref content) => { + !matches!(**content, GeneratedContentInfo::Empty) }, _ => false, } @@ -1602,10 +1601,7 @@ impl Fragment { /// Returns true if and only if this is a scanned text fragment. pub fn is_scanned_text_fragment(&self) -> bool { - match self.specific { - SpecificFragmentInfo::ScannedText(..) => true, - _ => false, - } + matches!(self.specific, SpecificFragmentInfo::ScannedText(..)) } pub fn suppress_line_break_before(&self) -> bool { @@ -1972,8 +1968,8 @@ impl Fragment { // see if we're going to overflow the line. If so, perform a best-effort split. let mut remaining_range = slice.text_run_range(); let split_is_empty = inline_start_range.is_empty() && - !(self.requires_line_break_afterward_if_wrapping_on_newlines() && - !self.white_space().allow_wrap()); + (self.white_space().allow_wrap() || + !self.requires_line_break_afterward_if_wrapping_on_newlines()); if split_is_empty { // We're going to overflow the line. overflowing = true; @@ -2259,14 +2255,14 @@ impl Fragment { /// Returns true if this fragment is replaced content. pub fn is_replaced(&self) -> bool { - match self.specific { + matches!( + self.specific, SpecificFragmentInfo::Iframe(_) | - SpecificFragmentInfo::Canvas(_) | - SpecificFragmentInfo::Image(_) | - SpecificFragmentInfo::Media(_) | - SpecificFragmentInfo::Svg(_) => true, - _ => false, - } + SpecificFragmentInfo::Canvas(_) | + SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | + SpecificFragmentInfo::Svg(_) + ) } /// Returns true if this fragment is replaced content or an inline-block or false otherwise. @@ -2507,10 +2503,10 @@ impl Fragment { /// Returns true if this fragment is a hypothetical box. See CSS 2.1 § 10.3.7. pub fn is_hypothetical(&self) -> bool { - match self.specific { - SpecificFragmentInfo::InlineAbsoluteHypothetical(_) => true, - _ => false, - } + matches!( + self.specific, + SpecificFragmentInfo::InlineAbsoluteHypothetical(_) + ) } /// Returns true if this fragment can merge with another immediately-following fragment or @@ -3069,10 +3065,7 @@ impl Fragment { } pub fn is_inline_absolute(&self) -> bool { - match self.specific { - SpecificFragmentInfo::InlineAbsolute(..) => true, - _ => false, - } + matches!(self.specific, SpecificFragmentInfo::InlineAbsolute(..)) } pub fn meld_with_next_inline_fragment(&mut self, next_fragment: &Fragment) { @@ -3141,11 +3134,11 @@ impl Fragment { /// `vertical-align` set to `top` or `bottom`. pub fn is_vertically_aligned_to_top_or_bottom(&self) -> bool { fn is_top_or_bottom(v: &VerticalAlign) -> bool { - match *v { + matches!( + *v, VerticalAlign::Keyword(VerticalAlignKeyword::Top) | - VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => true, - _ => false, - } + VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) + ) } if is_top_or_bottom(&self.style.get_box().vertical_align) { diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 20e1b1ead0e..862e8c88191 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -307,7 +307,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> { } // Truncate down counters. - for (_, counter) in &mut self.traversal.counters { + for counter in self.traversal.counters.values_mut() { counter.truncate_to_level(self.level); } self.traversal.list_item.truncate_to_level(self.level); diff --git a/components/layout/model.rs b/components/layout/model.rs index 557295de92a..c41666218ab 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -478,7 +478,7 @@ impl MaybeAuto { } #[inline] - pub fn to_option(&self) -> Option { + pub fn as_option(&self) -> Option { match *self { MaybeAuto::Specified(value) => Some(value), MaybeAuto::Auto => None, diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 22f542655cb..26d7d429a25 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -35,8 +35,9 @@ pub struct UnsafeFlow(*const dyn Flow); unsafe impl Sync for UnsafeFlow {} unsafe impl Send for UnsafeFlow {} impl PartialEq for UnsafeFlow { + #[allow(clippy::ptr_eq)] fn eq(&self, other: &Self) -> bool { - // Compare the pointers explicitly to avoid clippy lint + // Compare the pointers explicitly to avoid a clippy error self.0 as *const u8 == other.0 as *const u8 } } diff --git a/components/layout/query.rs b/components/layout/query.rs index 2bb03e2a5ca..4225c170b42 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -988,10 +988,10 @@ fn process_resolved_style_request_internal<'dom>( }, }; - let positioned = match style.get_box().position { - Position::Relative | Position::Sticky | Position::Fixed | Position::Absolute => true, - _ => false, - }; + let positioned = matches!( + style.get_box().position, + Position::Relative | Position::Sticky | Position::Fixed | Position::Absolute + ); //TODO: determine whether requested property applies to the element. // eg. width does not apply to non-replaced inline elements. diff --git a/components/layout/table.rs b/components/layout/table.rs index d6ce1c9a2b0..1821769bc79 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -37,7 +37,7 @@ use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto}; use crate::table_cell::TableCellFlow; use crate::table_row::{ - self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance, TableRowFlow, + self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderFrom, TableRowFlow, TableRowSizeData, }; use crate::table_wrapper::TableLayout; @@ -339,11 +339,11 @@ impl Flow for TableFlow { Some(TableInlineCollapsedBorders { start: CollapsedBorder::inline_start( &self.block_flow.fragment.style, - CollapsedBorderProvenance::FromTable, + CollapsedBorderFrom::Table, ), end: CollapsedBorder::inline_end( &self.block_flow.fragment.style, - CollapsedBorderProvenance::FromTable, + CollapsedBorderFrom::Table, ), }) } else { @@ -354,7 +354,7 @@ impl Flow for TableFlow { let mut previous_collapsed_block_end_borders = PreviousBlockCollapsedBorders::FromTable(CollapsedBorder::block_start( &self.block_flow.fragment.style, - CollapsedBorderProvenance::FromTable, + CollapsedBorderFrom::Table, )); let mut first_row = true; let (border_padding, _) = self.block_flow.fragment.surrounding_intrinsic_inline_size(); @@ -381,7 +381,7 @@ impl Flow for TableFlow { ), None => NextBlockCollapsedBorders::FromTable(CollapsedBorder::block_end( &self.block_flow.fragment.style, - CollapsedBorderProvenance::FromTable, + CollapsedBorderFrom::Table, )), }; perform_border_collapse_for_row( diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index cf8c7d3f5bb..013702e9401 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -27,7 +27,7 @@ use crate::display_list::{ use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::InternalTable; -use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance}; +use crate::table_row::{CollapsedBorder, CollapsedBorderFrom}; use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] @@ -406,19 +406,19 @@ impl CollapsedBordersForCell { } fn should_paint_inline_start_border(&self) -> bool { - self.inline_start_border.provenance != CollapsedBorderProvenance::FromPreviousTableCell + self.inline_start_border.provenance != CollapsedBorderFrom::PreviousTableCell } fn should_paint_inline_end_border(&self) -> bool { - self.inline_end_border.provenance != CollapsedBorderProvenance::FromNextTableCell + self.inline_end_border.provenance != CollapsedBorderFrom::NextTableCell } fn should_paint_block_start_border(&self) -> bool { - self.block_start_border.provenance != CollapsedBorderProvenance::FromPreviousTableCell + self.block_start_border.provenance != CollapsedBorderFrom::PreviousTableCell } fn should_paint_block_end_border(&self) -> bool { - self.block_end_border.provenance != CollapsedBorderProvenance::FromNextTableCell + self.block_end_border.provenance != CollapsedBorderFrom::NextTableCell } pub fn adjust_border_widths_for_painting(&self, border_widths: &mut LogicalMargin) { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index ad99dd4b15a..fbc441055da 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -4,6 +4,8 @@ //! CSS table formatting contexts. +#![allow(clippy::too_many_arguments)] + use std::cmp::max; use std::fmt; use std::iter::{Enumerate, Peekable}; @@ -123,7 +125,7 @@ impl TableRowFlow { fn include_sizes_from_previous_rows( col: &mut usize, incoming_rowspan: &[u32], - incoming_rowspan_data: &mut Vec, + incoming_rowspan_data: &mut [Au], max_block_size: &mut Au, ) { while let Some(span) = incoming_rowspan.get(*col) { @@ -390,7 +392,7 @@ impl Flow for TableRowFlow { self.preliminary_collapsed_borders .reset(CollapsedBorder::inline_start( row_style, - CollapsedBorderProvenance::FromTableRow, + CollapsedBorderFrom::TableRow, )); { @@ -736,7 +738,7 @@ pub struct CollapsedBorder { /// The color of the border. pub color: Color, /// The type of item that this border comes from. - pub provenance: CollapsedBorderProvenance, + pub provenance: CollapsedBorderFrom, } impl Serialize for CollapsedBorder { @@ -753,14 +755,14 @@ impl Serialize for CollapsedBorder { // FromTableColumnGroup are unused #[allow(dead_code)] #[derive(Clone, Copy, Debug, PartialEq, Serialize)] -pub enum CollapsedBorderProvenance { - FromPreviousTableCell = 6, - FromNextTableCell = 5, - FromTableRow = 4, - FromTableRowGroup = 3, - FromTableColumn = 2, - FromTableColumnGroup = 1, - FromTable = 0, +pub enum CollapsedBorderFrom { + PreviousTableCell = 6, + NextTableCell = 5, + TableRow = 4, + TableRowGroup = 3, + TableColumn = 2, + TableColumnGroup = 1, + Table = 0, } impl CollapsedBorder { @@ -770,13 +772,13 @@ impl CollapsedBorder { style: BorderStyle::None, width: Au(0), color: Color::transparent(), - provenance: CollapsedBorderProvenance::FromTable, + provenance: CollapsedBorderFrom::Table, } } /// Creates a collapsed border from the block-start border described in the given CSS style /// object. - fn top(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { + fn top(css_style: &ComputedValues, provenance: CollapsedBorderFrom) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_top_style, width: css_style.get_border().border_top_width, @@ -787,7 +789,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the right border described in the given CSS style /// object. - fn right(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { + fn right(css_style: &ComputedValues, provenance: CollapsedBorderFrom) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_right_style, width: css_style.get_border().border_right_width, @@ -798,10 +800,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the bottom border described in the given CSS style /// object. - fn bottom( - css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, - ) -> CollapsedBorder { + fn bottom(css_style: &ComputedValues, provenance: CollapsedBorderFrom) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_bottom_style, width: css_style.get_border().border_bottom_width, @@ -812,7 +811,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the left border described in the given CSS style /// object. - fn left(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { + fn left(css_style: &ComputedValues, provenance: CollapsedBorderFrom) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_left_style, width: css_style.get_border().border_left_width, @@ -825,7 +824,7 @@ impl CollapsedBorder { fn from_side( side: PhysicalSide, css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, + provenance: CollapsedBorderFrom, ) -> CollapsedBorder { match side { PhysicalSide::Top => CollapsedBorder::top(css_style, provenance), @@ -839,7 +838,7 @@ impl CollapsedBorder { /// style object. pub fn inline_start( css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, + provenance: CollapsedBorderFrom, ) -> CollapsedBorder { CollapsedBorder::from_side( css_style.writing_mode.inline_start_physical_side(), @@ -852,7 +851,7 @@ impl CollapsedBorder { /// style object. pub fn inline_end( css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, + provenance: CollapsedBorderFrom, ) -> CollapsedBorder { CollapsedBorder::from_side( css_style.writing_mode.inline_end_physical_side(), @@ -865,7 +864,7 @@ impl CollapsedBorder { /// style object. pub fn block_start( css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, + provenance: CollapsedBorderFrom, ) -> CollapsedBorder { CollapsedBorder::from_side( css_style.writing_mode.block_start_physical_side(), @@ -878,7 +877,7 @@ impl CollapsedBorder { /// object. pub fn block_end( css_style: &ComputedValues, - provenance: CollapsedBorderProvenance, + provenance: CollapsedBorderFrom, ) -> CollapsedBorder { CollapsedBorder::from_side( css_style.writing_mode.block_end_physical_side(), @@ -1120,7 +1119,7 @@ fn perform_inline_direction_border_collapse_for_row( let first_inline_border = &mut preliminary_collapsed_borders.inline[0]; first_inline_border.combine(&CollapsedBorder::inline_start( &child_table_cell.block_flow.fragment.style, - CollapsedBorderProvenance::FromNextTableCell, + CollapsedBorderFrom::NextTableCell, )); } @@ -1128,7 +1127,7 @@ fn perform_inline_direction_border_collapse_for_row( child_index + 1, CollapsedBorder::inline_end( &child_table_cell.block_flow.fragment.style, - CollapsedBorderProvenance::FromPreviousTableCell, + CollapsedBorderFrom::PreviousTableCell, ), ); @@ -1136,7 +1135,7 @@ fn perform_inline_direction_border_collapse_for_row( let next_child_flow = next_child_flow.as_block(); inline_collapsed_border.combine(&CollapsedBorder::inline_start( &next_child_flow.fragment.style, - CollapsedBorderProvenance::FromNextTableCell, + CollapsedBorderFrom::NextTableCell, )) }; @@ -1145,28 +1144,28 @@ fn perform_inline_direction_border_collapse_for_row( if child_index + 1 == children_count { inline_collapsed_border.combine(&CollapsedBorder::inline_end( row_style, - CollapsedBorderProvenance::FromTableRow, + CollapsedBorderFrom::TableRow, )); } let mut block_start_border = CollapsedBorder::block_start( &child_table_cell.block_flow.fragment.style, - CollapsedBorderProvenance::FromNextTableCell, + CollapsedBorderFrom::NextTableCell, ); block_start_border.combine(&CollapsedBorder::block_start( row_style, - CollapsedBorderProvenance::FromTableRow, + CollapsedBorderFrom::TableRow, )); preliminary_collapsed_borders .block_start .push_or_set(child_index, block_start_border); let mut block_end_border = CollapsedBorder::block_end( &child_table_cell.block_flow.fragment.style, - CollapsedBorderProvenance::FromPreviousTableCell, + CollapsedBorderFrom::PreviousTableCell, ); block_end_border.combine(&CollapsedBorder::block_end( row_style, - CollapsedBorderProvenance::FromTableRow, + CollapsedBorderFrom::TableRow, )); preliminary_collapsed_borders diff --git a/components/layout/text.rs b/components/layout/text.rs index 0c6e8ecc424..128bdfbe141 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Text layout. +#![allow(clippy::too_many_arguments)] use std::borrow::ToOwned; use std::collections::LinkedList; @@ -483,10 +484,10 @@ impl TextRunScanner { SpecificFragmentInfo::ScannedText(new_text_fragment_info), ); - let is_last_mapping_of_this_old_fragment = match mappings.peek() { - Some(mapping) if mapping.old_fragment_index == logical_offset => false, - _ => true, - }; + let is_last_mapping_of_this_old_fragment = !matches!( + mappings.peek(), + Some(mapping) if mapping.old_fragment_index == logical_offset + ); if let Some(ref mut context) = new_fragment.inline_context { for node in &mut context.nodes {