mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
clippy: Fix warnings in components/layout_2020
(#31611)
* clippy: fix warnings in components/layout_2020 * fix: review comments
This commit is contained in:
parent
1d1f239ecc
commit
b03411f567
17 changed files with 59 additions and 69 deletions
|
@ -54,7 +54,7 @@ impl BlockFormattingContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn construct_for_text_runs<'dom>(
|
||||
pub fn construct_for_text_runs(
|
||||
runs: impl Iterator<Item = TextRun>,
|
||||
layout_context: &LayoutContext,
|
||||
text_decoration_line: TextDecorationLine,
|
||||
|
@ -409,15 +409,11 @@ where
|
|||
// collecting all Cow strings into a vector and passing them along to text breaking
|
||||
// and shaping during final InlineFormattingContext construction.
|
||||
let inlines = self.current_inline_level_boxes();
|
||||
match inlines.last_mut().map(|last| last.borrow_mut()) {
|
||||
Some(mut last_box) => match *last_box {
|
||||
InlineLevelBox::TextRun(ref mut text_run) => {
|
||||
text_run.text.push_str(&input);
|
||||
return;
|
||||
},
|
||||
_ => {},
|
||||
},
|
||||
_ => {},
|
||||
if let Some(mut last_box) = inlines.last_mut().map(|last| last.borrow_mut()) {
|
||||
if let InlineLevelBox::TextRun(ref mut text_run) = *last_box {
|
||||
text_run.text.push_str(&input);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inlines.push(ArcRefCell::new(InlineLevelBox::TextRun(TextRun::new(
|
||||
|
|
|
@ -951,7 +951,7 @@ impl FloatBox {
|
|||
layout_context,
|
||||
positioning_context,
|
||||
&containing_block_for_children,
|
||||
&containing_block,
|
||||
containing_block,
|
||||
);
|
||||
content_size = LogicalVec2 {
|
||||
inline: inline_size,
|
||||
|
|
|
@ -1384,14 +1384,11 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
// Place all floats in this unbreakable segment.
|
||||
let mut segment_items = mem::take(&mut self.current_line_segment.line_items);
|
||||
for item in segment_items.iter_mut() {
|
||||
match item {
|
||||
LineItem::Float(float_item) => {
|
||||
self.place_float_line_item_for_commit_to_line(
|
||||
float_item,
|
||||
line_inline_size_without_trailing_whitespace,
|
||||
);
|
||||
},
|
||||
_ => {},
|
||||
if let LineItem::Float(float_item) = item {
|
||||
self.place_float_line_item_for_commit_to_line(
|
||||
float_item,
|
||||
line_inline_size_without_trailing_whitespace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1450,7 +1447,7 @@ impl InlineFormattingContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn foreach<'a>(&self, mut func: impl FnMut(InlineFormattingContextIterItem)) {
|
||||
fn foreach(&self, mut func: impl FnMut(InlineFormattingContextIterItem)) {
|
||||
// TODO(mrobinson): Using OwnedRef here we could maybe avoid the second borrow when
|
||||
// iterating through members of each inline box.
|
||||
struct InlineFormattingContextChildBoxIter {
|
||||
|
@ -2006,7 +2003,7 @@ impl IndependentFormattingContext {
|
|||
layout_context,
|
||||
child_positioning_context.as_mut().unwrap(),
|
||||
&containing_block_for_children,
|
||||
&ifc.containing_block,
|
||||
ifc.containing_block,
|
||||
);
|
||||
let (inline_size, block_size) =
|
||||
match independent_layout.content_inline_size_for_table {
|
||||
|
@ -2134,15 +2131,12 @@ impl FloatBox {
|
|||
}
|
||||
}
|
||||
|
||||
fn place_pending_floats(ifc: &mut InlineFormattingContextState, line_items: &mut Vec<LineItem>) {
|
||||
fn place_pending_floats(ifc: &mut InlineFormattingContextState, line_items: &mut [LineItem]) {
|
||||
for item in line_items.iter_mut() {
|
||||
match item {
|
||||
LineItem::Float(float_line_item) => {
|
||||
if float_line_item.needs_placement {
|
||||
ifc.place_float_fragment(&mut float_line_item.fragment);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
if let LineItem::Float(float_line_item) = item {
|
||||
if float_line_item.needs_placement {
|
||||
ifc.place_float_fragment(&mut float_line_item.fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2157,11 +2151,11 @@ fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Len
|
|||
}
|
||||
|
||||
fn is_baseline_relative(vertical_align: GenericVerticalAlign<LengthPercentage>) -> bool {
|
||||
match vertical_align {
|
||||
!matches!(
|
||||
vertical_align,
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Top) |
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => false,
|
||||
_ => true,
|
||||
}
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom)
|
||||
)
|
||||
}
|
||||
|
||||
/// Whether or not a strut should be created for an inline container. Normally
|
||||
|
|
|
@ -587,11 +587,11 @@ impl FloatLineItem {
|
|||
}
|
||||
|
||||
fn is_baseline_relative(vertical_align: GenericVerticalAlign<LengthPercentage>) -> bool {
|
||||
match vertical_align {
|
||||
!matches!(
|
||||
vertical_align,
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Top) |
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => false,
|
||||
_ => true,
|
||||
}
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom)
|
||||
)
|
||||
}
|
||||
|
||||
fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Length {
|
||||
|
|
|
@ -613,6 +613,7 @@ impl BlockLevelBox {
|
|||
///
|
||||
/// - <https://drafts.csswg.org/css2/visudet.html#blockwidth>
|
||||
/// - <https://drafts.csswg.org/css2/visudet.html#normal-block>
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||
layout_context: &LayoutContext,
|
||||
positioning_context: &mut PositioningContext,
|
||||
|
@ -856,7 +857,7 @@ impl NonReplacedFormattingContext {
|
|||
layout_context,
|
||||
positioning_context,
|
||||
&containing_block_for_children,
|
||||
&containing_block,
|
||||
containing_block,
|
||||
);
|
||||
|
||||
let (block_size, inline_size) = match layout.content_inline_size_for_table {
|
||||
|
@ -1162,7 +1163,7 @@ impl NonReplacedFormattingContext {
|
|||
/// <https://drafts.csswg.org/css2/visudet.html#block-replaced-width>
|
||||
/// <https://drafts.csswg.org/css2/visudet.html#inline-replaced-width>
|
||||
/// <https://drafts.csswg.org/css2/visudet.html#inline-replaced-height>
|
||||
fn layout_in_flow_replaced_block_level<'a>(
|
||||
fn layout_in_flow_replaced_block_level(
|
||||
containing_block: &ContainingBlock,
|
||||
base_fragment_info: BaseFragmentInfo,
|
||||
style: &Arc<ComputedValues>,
|
||||
|
@ -1348,8 +1349,8 @@ fn solve_margins(
|
|||
inline_size: Length,
|
||||
) -> ResolvedMargins {
|
||||
let (inline_margins, effective_margin_inline_start) =
|
||||
solve_inline_margins_for_in_flow_block_level(containing_block, &pbm, inline_size);
|
||||
let block_margins = solve_block_margins_for_in_flow_block_level(&pbm);
|
||||
solve_inline_margins_for_in_flow_block_level(containing_block, pbm, inline_size);
|
||||
let block_margins = solve_block_margins_for_in_flow_block_level(pbm);
|
||||
ResolvedMargins {
|
||||
margin: LogicalSides {
|
||||
inline_start: inline_margins.0,
|
||||
|
|
|
@ -83,6 +83,7 @@ impl BoxTree {
|
|||
where
|
||||
Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
|
||||
{
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum UpdatePoint {
|
||||
AbsolutelyPositionedBlockLevelBox(ArcRefCell<BlockLevelBox>),
|
||||
AbsolutelyPositionedInlineLevelBox(ArcRefCell<InlineLevelBox>),
|
||||
|
|
|
@ -709,7 +709,7 @@ pub struct TextTransformation<InputIterator> {
|
|||
pending_case_conversion_result: Option<PendingCaseConversionResult>,
|
||||
}
|
||||
|
||||
impl<'a, InputIterator> TextTransformation<InputIterator> {
|
||||
impl<InputIterator> TextTransformation<InputIterator> {
|
||||
pub fn new(char_iterator: InputIterator, text_transform: TextTransform) -> Self {
|
||||
Self {
|
||||
char_iterator,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue