clippy: Fix warnings in components/layout (#31612)

* clippy: fix warnings in components/layout

* fix: formatting
This commit is contained in:
eri 2024-03-11 11:24:36 +01:00 committed by GitHub
parent 7f1ef4c7fe
commit a6e25d555b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 129 additions and 150 deletions

View file

@ -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()");
}

View file

@ -199,7 +199,7 @@ impl InlineBlockSplit {
fragment_accumulator,
InlineFragmentsAccumulator::from_inline_node(node, style_context),
)
.to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(style_context),
.get_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(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::<ConcreteThreadSafeLayoutNode>(self.style_context());
.get_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(
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::<ConcreteThreadSafeLayoutNode>(
.get_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(
self.style_context(),
),
});
@ -1196,7 +1198,7 @@ where
ConstructionItem::InlineFragments(InlineFragmentsConstructionResult {
splits: LinkedList::new(),
fragments: fragment_accumulator
.to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(context),
.get_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(context),
});
ConstructionResult::ConstructionItem(construction_item)
}
@ -1246,7 +1248,7 @@ where
ConstructionItem::InlineFragments(InlineFragmentsConstructionResult {
splits: LinkedList::new(),
fragments: fragment_accumulator
.to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(
.get_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(
style_context,
),
});

View file

@ -55,6 +55,9 @@ pub fn malloc_size_of_persistent_local_context(ops: &mut MallocSizeOfOps) -> usi
})
}
type WebrenderImageCache =
HashMap<(ServoUrl, UsePlaceholder), WebRenderImageInfo, BuildHasherDefault<FnvHasher>>;
/// 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<FontCacheThread>,
/// A cache of WebRender image info.
pub webrender_image_cache: Arc<
RwLock<
HashMap<(ServoUrl, UsePlaceholder), WebRenderImageInfo, BuildHasherDefault<FnvHasher>>,
>,
>,
pub webrender_image_cache: Arc<RwLock<WebrenderImageCache>>,
/// Paint worklets
pub registered_painters: &'a dyn RegisteredPainters,

View file

@ -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;

View file

@ -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<DisplayItem>,
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<DisplayItem>,
mut child_items: Vec<DisplayItem>,
@ -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,

View file

@ -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};

View file

@ -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();

View file

@ -49,6 +49,7 @@ impl FlowRef {
/// See <https://github.com/servo/servo/issues/6503>.
/// 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) }

View file

@ -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) {

View file

@ -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);

View file

@ -478,7 +478,7 @@ impl MaybeAuto {
}
#[inline]
pub fn to_option(&self) -> Option<Au> {
pub fn as_option(&self) -> Option<Au> {
match *self {
MaybeAuto::Specified(value) => Some(value),
MaybeAuto::Auto => None,

View file

@ -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
}
}

View file

@ -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.

View file

@ -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(

View file

@ -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<Au>) {

View file

@ -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<Au>,
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

View file

@ -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 {