mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Replace .map_or(false with Option::is_some_and (#33468)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
236cae9ce5
commit
7df30f3788
51 changed files with 165 additions and 171 deletions
|
@ -505,9 +505,10 @@ impl<'a> DisplayListBuildState<'a> {
|
|||
// Properly order display items that make up a stacking context. "Steps" here
|
||||
// refer to the steps in CSS 2.1 Appendix E.
|
||||
// Steps 1 and 2: Borders and background for the root.
|
||||
while child_items.last().map_or(false, |child| {
|
||||
child.section() == DisplayListSection::BackgroundAndBorders
|
||||
}) {
|
||||
while child_items
|
||||
.last()
|
||||
.is_some_and(|child| child.section() == DisplayListSection::BackgroundAndBorders)
|
||||
{
|
||||
list.push(child_items.pop().unwrap());
|
||||
}
|
||||
|
||||
|
@ -515,31 +516,34 @@ impl<'a> DisplayListBuildState<'a> {
|
|||
let mut child_stacking_contexts = child_stacking_contexts.into_iter().peekable();
|
||||
while child_stacking_contexts
|
||||
.peek()
|
||||
.map_or(false, |child| child.z_index < 0)
|
||||
.is_some_and(|child| child.z_index < 0)
|
||||
{
|
||||
let context = child_stacking_contexts.next().unwrap();
|
||||
self.move_to_display_list_for_stacking_context(list, context);
|
||||
}
|
||||
|
||||
// Step 4: Block backgrounds and borders.
|
||||
while child_items.last().map_or(false, |child| {
|
||||
child.section() == DisplayListSection::BlockBackgroundsAndBorders
|
||||
}) {
|
||||
while child_items
|
||||
.last()
|
||||
.is_some_and(|child| child.section() == DisplayListSection::BlockBackgroundsAndBorders)
|
||||
{
|
||||
list.push(child_items.pop().unwrap());
|
||||
}
|
||||
|
||||
// Step 5: Floats.
|
||||
while child_stacking_contexts.peek().map_or(false, |child| {
|
||||
child.context_type == StackingContextType::PseudoFloat
|
||||
}) {
|
||||
while child_stacking_contexts
|
||||
.peek()
|
||||
.is_some_and(|child| child.context_type == StackingContextType::PseudoFloat)
|
||||
{
|
||||
let context = child_stacking_contexts.next().unwrap();
|
||||
self.move_to_display_list_for_stacking_context(list, context);
|
||||
}
|
||||
|
||||
// Step 6 & 7: Content and inlines that generate stacking contexts.
|
||||
while child_items.last().map_or(false, |child| {
|
||||
child.section() == DisplayListSection::Content
|
||||
}) {
|
||||
while child_items
|
||||
.last()
|
||||
.is_some_and(|child| child.section() == DisplayListSection::Content)
|
||||
{
|
||||
list.push(child_items.pop().unwrap());
|
||||
}
|
||||
|
||||
|
|
|
@ -868,7 +868,7 @@ impl Fragment {
|
|||
node_address == self.node ||
|
||||
self.inline_context
|
||||
.as_ref()
|
||||
.map_or(false, |ctx| ctx.contains_node(node_address))
|
||||
.is_some_and(|ctx| ctx.contains_node(node_address))
|
||||
}
|
||||
|
||||
/// Adds a style to the inline context for this fragment. If the inline context doesn't exist
|
||||
|
@ -2750,9 +2750,7 @@ impl Fragment {
|
|||
/// Returns true if this fragment has a transform applied that causes it to take up no space.
|
||||
pub fn has_non_invertible_transform_or_zero_scale(&self) -> bool {
|
||||
self.transform_matrix(&Rect::default())
|
||||
.map_or(false, |matrix| {
|
||||
!matrix.is_invertible() || matrix.m11 == 0. || matrix.m22 == 0.
|
||||
})
|
||||
.is_some_and(|matrix| !matrix.is_invertible() || matrix.m11 == 0. || matrix.m22 == 0.)
|
||||
}
|
||||
|
||||
/// Returns true if this fragment establishes a new stacking context and false otherwise.
|
||||
|
|
|
@ -228,7 +228,7 @@ impl<'a> TextRun {
|
|||
// Split off any trailing whitespace into a separate glyph run.
|
||||
let mut whitespace = slice.end..slice.end;
|
||||
let mut rev_char_indices = word.char_indices().rev().peekable();
|
||||
let ends_with_newline = rev_char_indices.peek().map_or(false, |&(_, c)| c == '\n');
|
||||
let ends_with_newline = rev_char_indices.peek().is_some_and(|&(_, c)| c == '\n');
|
||||
if let Some((i, _)) = rev_char_indices
|
||||
.take_while(|&(_, c)| char_is_whitespace(c))
|
||||
.last()
|
||||
|
|
|
@ -219,7 +219,7 @@ fn construct_flows_at<'dom>(context: &LayoutContext, node: impl LayoutNode<'dom>
|
|||
if nonincremental_layout ||
|
||||
tnode.restyle_damage() != RestyleDamage::empty() ||
|
||||
node.as_element()
|
||||
.map_or(false, |el| el.has_dirty_descendants())
|
||||
.is_some_and(|el| el.has_dirty_descendants())
|
||||
{
|
||||
let mut flow_constructor = FlowConstructor::new(context);
|
||||
if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue