mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Lint layout_2020 with clippy (#31169)
cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
This commit is contained in:
parent
886f6c58d4
commit
50f56affe3
30 changed files with 224 additions and 244 deletions
|
@ -133,20 +133,16 @@ impl Table {
|
|||
/// the target and returns a [`ResolvedSlotAndLocation`] for each of them. If there is
|
||||
/// no slot at the given coordinates or that slot is an empty space, an empty vector
|
||||
/// is returned.
|
||||
pub(super) fn resolve_slot_at<'a>(
|
||||
&'a self,
|
||||
pub(super) fn resolve_slot_at(
|
||||
&self,
|
||||
coords: TableSlotCoordinates,
|
||||
) -> Vec<ResolvedSlotAndLocation<'a>> {
|
||||
) -> Vec<ResolvedSlotAndLocation<'_>> {
|
||||
let slot = self.get_slot(coords);
|
||||
match slot {
|
||||
Some(TableSlot::Cell(cell)) => vec![ResolvedSlotAndLocation {
|
||||
cell: &cell,
|
||||
coords,
|
||||
}],
|
||||
Some(TableSlot::Cell(cell)) => vec![ResolvedSlotAndLocation { cell, coords }],
|
||||
Some(TableSlot::Spanned(ref offsets)) => offsets
|
||||
.iter()
|
||||
.map(|offset| self.resolve_slot_at(coords - *offset))
|
||||
.flatten()
|
||||
.flat_map(|offset| self.resolve_slot_at(coords - *offset))
|
||||
.collect(),
|
||||
Some(TableSlot::Empty) | None => {
|
||||
warn!("Tried to resolve an empty or nonexistant slot!");
|
||||
|
@ -170,12 +166,12 @@ impl Table {
|
|||
|
||||
let coords_of_slots_that_cover_target: Vec<_> = slots_covering_slot_above
|
||||
.into_iter()
|
||||
.filter(|ref slot| slot.covers_cell_at(target_coords))
|
||||
.filter(|slot| slot.covers_cell_at(target_coords))
|
||||
.map(|slot| target_coords - slot.coords)
|
||||
.collect();
|
||||
|
||||
if coords_of_slots_that_cover_target.is_empty() {
|
||||
return None;
|
||||
None
|
||||
} else {
|
||||
Some(TableSlot::Spanned(coords_of_slots_that_cover_target))
|
||||
}
|
||||
|
@ -245,7 +241,7 @@ impl TableBuilder {
|
|||
TableSlotCoordinates::new(self.current_x(), self.current_y())
|
||||
}
|
||||
|
||||
pub fn start_row<'builder>(&'builder mut self) {
|
||||
pub fn start_row(&mut self) {
|
||||
self.table.slots.push(Vec::new());
|
||||
self.table.size.height += 1;
|
||||
self.create_slots_for_cells_above_with_rowspan(true);
|
||||
|
@ -421,7 +417,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
let row_content = std::mem::replace(&mut self.current_anonymous_row_content, Vec::new());
|
||||
let row_content = std::mem::take(&mut self.current_anonymous_row_content);
|
||||
let context = self.context;
|
||||
let anonymous_style = self
|
||||
.context
|
||||
|
|
|
@ -199,10 +199,10 @@ impl<'a> TableLayout<'a> {
|
|||
Auto => (min_content_width, min_content_width, max_content_width),
|
||||
};
|
||||
|
||||
min_content_sizing_guesses.push(min_content_width.into());
|
||||
min_content_percentage_sizing_guesses.push(min_content_percentage_sizing_guess.into());
|
||||
min_content_specified_sizing_guesses.push(min_content_specified_sizing_guess.into());
|
||||
max_content_sizing_guesses.push(max_content_sizing_guess.into());
|
||||
min_content_sizing_guesses.push(min_content_width);
|
||||
min_content_percentage_sizing_guesses.push(min_content_percentage_sizing_guess);
|
||||
min_content_specified_sizing_guesses.push(min_content_specified_sizing_guess);
|
||||
max_content_sizing_guesses.push(max_content_sizing_guess);
|
||||
}
|
||||
|
||||
// > If the assignable table width is less than or equal to the max-content sizing-guess, the
|
||||
|
@ -493,7 +493,7 @@ impl Table {
|
|||
positioning_context: &mut PositioningContext,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> IndependentLayout {
|
||||
let mut table_layout = TableLayout::new(&self);
|
||||
let mut table_layout = TableLayout::new(self);
|
||||
table_layout.compute_measures(layout_context, positioning_context, containing_block);
|
||||
let (fragments, content_block_size) =
|
||||
table_layout.layout_into_box_fragments(positioning_context);
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Table {
|
|||
|
||||
/// Return the slot at the given coordinates, if it exists in the table, otherwise
|
||||
/// return None.
|
||||
fn get_slot<'a>(&'a self, coords: TableSlotCoordinates) -> Option<&'a TableSlot> {
|
||||
fn get_slot(&self, coords: TableSlotCoordinates) -> Option<&TableSlot> {
|
||||
self.slots.get(coords.y)?.get(coords.x)
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ impl Table {
|
|||
) -> Option<TableSlotCoordinates> {
|
||||
match self.get_slot(coords) {
|
||||
Some(&TableSlot::Cell(_)) => Some(coords),
|
||||
Some(&TableSlot::Spanned(ref offsets)) => Some(coords - offsets[0]),
|
||||
_ => return None,
|
||||
Some(TableSlot::Spanned(offsets)) => Some(coords - offsets[0]),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ impl Table {
|
|||
|
||||
let slot = self.get_slot(resolved_coords);
|
||||
match slot {
|
||||
Some(&TableSlot::Cell(ref cell)) => Some(cell),
|
||||
Some(TableSlot::Cell(cell)) => Some(cell),
|
||||
_ => unreachable!(
|
||||
"Spanned slot should not point to an empty cell or another spanned slot."
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue