diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/animation.rs | 20 | ||||
-rw-r--r-- | components/layout/block.rs | 9 | ||||
-rw-r--r-- | components/layout/construct.rs | 5 | ||||
-rw-r--r-- | components/layout/display_list/items.rs | 3 | ||||
-rw-r--r-- | components/layout/flex.rs | 3 | ||||
-rw-r--r-- | components/layout/fragment.rs | 74 | ||||
-rw-r--r-- | components/layout/inline.rs | 15 | ||||
-rw-r--r-- | components/layout/list_item.rs | 3 | ||||
-rw-r--r-- | components/layout/model.rs | 30 | ||||
-rw-r--r-- | components/layout/multicol.rs | 3 | ||||
-rw-r--r-- | components/layout/query.rs | 13 | ||||
-rw-r--r-- | components/layout/table_cell.rs | 3 | ||||
-rw-r--r-- | components/layout/table_wrapper.rs | 18 |
13 files changed, 117 insertions, 82 deletions
diff --git a/components/layout/animation.rs b/components/layout/animation.rs index c9c83744361..9ce47e16d5a 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -89,7 +89,10 @@ pub fn update_animation_state<E>( }, }; - debug!("update_animation_state({:?}): {:?}", still_running, running_animation); + debug!( + "update_animation_state({:?}): {:?}", + still_running, running_animation + ); if still_running { animations_still_running.push(running_animation); @@ -97,11 +100,13 @@ pub fn update_animation_state<E>( } if let Animation::Transition(node, _, ref frame) = running_animation { - script_chan.send(ConstellationControlMsg::TransitionEnd( - node.to_untrusted_node_address(), - frame.property_animation.property_name().into(), - frame.duration, - )).unwrap(); + script_chan + .send(ConstellationControlMsg::TransitionEnd( + node.to_untrusted_node_address(), + frame.property_animation.property_name().into(), + frame.duration, + )) + .unwrap(); } expired_animations @@ -150,7 +155,8 @@ pub fn update_animation_state<E>( .send(ConstellationMsg::ChangeRunningAnimationsState( pipeline_id, animation_state, - )).unwrap(); + )) + .unwrap(); } /// Recalculates style for a set of animations. This does *not* run with the DOM diff --git a/components/layout/block.rs b/components/layout/block.rs index 76fb026ae0b..99ca7ada523 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1334,7 +1334,8 @@ impl BlockFlow { self.fragment.style.writing_mode, inline_size_for_float_placement, block_size + self.fragment.margin.block_start_end(), - ).convert( + ) + .convert( self.fragment.style.writing_mode, self.base.floats.writing_mode, ), @@ -1361,7 +1362,8 @@ impl BlockFlow { self.base.floats.writing_mode, self.base.writing_mode, container_size, - ).start; + ) + .start; let margin_offset = LogicalPoint::new( self.base.writing_mode, Au(0), @@ -2626,7 +2628,8 @@ impl Flow for BlockFlow { .early_absolute_position_info .relative_containing_block_mode, CoordinateSystem::Own, - ).translate(&stacking_context_position.to_vector()), + ) + .translate(&stacking_context_position.to_vector()), ); } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index b06e80bdd61..bfa6e878943 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -185,7 +185,8 @@ impl InlineBlockSplit { predecessors: mem::replace( fragment_accumulator, InlineFragmentsAccumulator::from_inline_node(node, style_context), - ).to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(style_context), + ) + .to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(style_context), flow: flow, }; @@ -402,7 +403,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> &self.layout_context, )); SpecificFragmentInfo::Image(image_info) - } + }, Some(LayoutNodeType::Element(LayoutElementType::HTMLMediaElement)) => { let data = node.media_data().unwrap(); SpecificFragmentInfo::Media(Box::new(MediaFragmentInfo::new(data))) diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 13de1360737..0a85e0a290a 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -590,7 +590,8 @@ impl ClippingRegion { rect: complex.rect.translate(delta), radii: complex.radii, mode: complex.mode, - }).collect(), + }) + .collect(), } } diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 3ccbb59a4b4..d8f0f167198 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -922,7 +922,8 @@ impl Flow for FlexFlow { .base .flags .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) - }).map(|(index, flow)| FlexItem::new(index, flow)) + }) + .map(|(index, flow)| FlexItem::new(index, flow)) .collect(); items.sort_by_key(|item| item.order); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 7774a4a9014..cb781484e63 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -416,23 +416,28 @@ impl ImageFragmentInfo { layout_context: &LayoutContext, ) -> ImageFragmentInfo { // First use any image data present in the element... - let image_or_metadata = node.image_data().and_then(|(image, metadata)| { - match (image, metadata) { + let image_or_metadata = node + .image_data() + .and_then(|(image, metadata)| match (image, metadata) { (Some(image), _) => Some(ImageOrMetadata::Image(image)), (None, Some(metadata)) => Some(ImageOrMetadata::Metadata(metadata)), _ => None, - } - }).or_else(|| url.and_then(|url| { - // Otherwise query the image cache for anything known about the associated source URL. - layout_context.get_or_request_image_or_meta( - node.opaque(), - url, - UsePlaceholder::Yes - ).map(|result| match result { - ImageOrMetadataAvailable::ImageAvailable(i, _) => ImageOrMetadata::Image(i), - ImageOrMetadataAvailable::MetadataAvailable(m) => ImageOrMetadata::Metadata(m), }) - })); + .or_else(|| { + url.and_then(|url| { + // Otherwise query the image cache for anything known about the associated source URL. + layout_context + .get_or_request_image_or_meta(node.opaque(), url, UsePlaceholder::Yes) + .map(|result| match result { + ImageOrMetadataAvailable::ImageAvailable(i, _) => { + ImageOrMetadata::Image(i) + }, + ImageOrMetadataAvailable::MetadataAvailable(m) => { + ImageOrMetadata::Metadata(m) + }, + }) + }) + }); let current_pixel_density = density.unwrap_or(1f64); @@ -452,15 +457,13 @@ impl ImageFragmentInfo { }), ) }, - Some(ImageOrMetadata::Metadata(m)) => { - ( - None, - Some(ImageMetadata { - height: (m.height as f64 / current_pixel_density) as u32, - width: (m.width as f64 / current_pixel_density) as u32, - }), - ) - }, + Some(ImageOrMetadata::Metadata(m)) => ( + None, + Some(ImageMetadata { + height: (m.height as f64 / current_pixel_density) as u32, + width: (m.width as f64 / current_pixel_density) as u32, + }), + ), None => (None, None), }; @@ -1012,7 +1015,7 @@ impl Fragment { } else { Au(0) } - } + }, SpecificFragmentInfo::Media(ref info) => { if let Some((_, width, _)) = info.current_frame { Au::from_px(width as i32) @@ -1042,7 +1045,7 @@ impl Fragment { } else { Au(0) } - } + }, SpecificFragmentInfo::Media(ref info) => { if let Some((_, _, height)) = info.current_frame { Au::from_px(height as i32) @@ -1174,17 +1177,21 @@ impl Fragment { (_, Ordering::Equal) => (first_isize, first_bsize), // When both rectangles grow (smaller than min sizes), // Choose the larger one; - (Ordering::Greater, Ordering::Greater) => if first_isize > second_isize { - (first_isize, first_bsize) - } else { - (second_isize, second_bsize) + (Ordering::Greater, Ordering::Greater) => { + if first_isize > second_isize { + (first_isize, first_bsize) + } else { + (second_isize, second_bsize) + } }, // When both rectangles shrink (larger than max sizes), // Choose the smaller one; - (Ordering::Less, Ordering::Less) => if first_isize > second_isize { - (second_isize, second_bsize) - } else { - (first_isize, first_bsize) + (Ordering::Less, Ordering::Less) => { + if first_isize > second_isize { + (second_isize, second_bsize) + } else { + (first_isize, first_bsize) + } }, // It does not matter which we choose here, because both sizes // will be clamped to constraint; @@ -3173,7 +3180,8 @@ impl Fragment { perspective_origin .vertical .to_used_value(stacking_relative_border_box.size.height), - ).to_layout(); + ) + .to_layout(); let pre_transform = LayoutTransform::create_translation( perspective_origin.x, diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 8093f3c9eeb..7f52c817dd1 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -316,7 +316,8 @@ impl LineBreaker { .map(|fragment| match fragment.specific { SpecificFragmentInfo::ScannedText(ref info) => info.run.bidi_level, _ => para_level, - }).collect(); + }) + .collect(); let mut lines = mem::replace(&mut self.lines, Vec::new()); @@ -336,7 +337,8 @@ impl LineBreaker { let start = FragmentIndex(run.start as isize); let len = FragmentIndex(run.len() as isize); (Range::new(start, len), levels[run.start]) - }).collect(), + }) + .collect(), ); } } @@ -1719,7 +1721,8 @@ impl Flow for InlineFlow { debug_assert!(first_fragment_index < self.fragments.fragments.len()); let first_fragment = &self.fragments.fragments[first_fragment_index]; let padding_box_origin = (first_fragment.border_box - - first_fragment.style.logical_border_width()).start; + first_fragment.style.logical_border_width()) + .start; containing_block_positions.push( padding_box_origin.to_physical(self.base.writing_mode, container_size), ); @@ -1733,7 +1736,8 @@ impl Flow for InlineFlow { debug_assert!(first_fragment_index < self.fragments.fragments.len()); let first_fragment = &self.fragments.fragments[first_fragment_index]; let padding_box_origin = (first_fragment.border_box - - first_fragment.style.logical_border_width()).start; + first_fragment.style.logical_border_width()) + .start; containing_block_positions.push( padding_box_origin.to_physical(self.base.writing_mode, container_size), ); @@ -1878,7 +1882,8 @@ impl Flow for InlineFlow { relative_containing_block_size, relative_containing_block_mode, CoordinateSystem::Own, - ).translate(&stacking_context_position.to_vector()), + ) + .translate(&stacking_context_position.to_vector()), ) } } diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 002651918f3..08473cb89ef 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -257,7 +257,8 @@ impl Flow for ListItemFlow { .early_absolute_position_info .relative_containing_block_mode, CoordinateSystem::Own, - ).translate(&stacking_context_position.to_vector()), + ) + .translate(&stacking_context_position.to_vector()), ); } } diff --git a/components/layout/model.rs b/components/layout/model.rs index c33c21a49b9..0c10159f480 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -505,10 +505,12 @@ pub fn style_length( ) -> MaybeAuto { match container_size { Some(length) => MaybeAuto::from_style(style_length, length), - None => if let LengthOrPercentageOrAuto::Length(length) = style_length { - MaybeAuto::Specified(Au::from(length)) - } else { - MaybeAuto::Auto + None => { + if let LengthOrPercentageOrAuto::Length(length) = style_length { + MaybeAuto::Specified(Au::from(length)) + } else { + MaybeAuto::Auto + } }, } } @@ -580,19 +582,23 @@ impl SizeConstraint { ) -> SizeConstraint { let mut min_size = match container_size { Some(container_size) => min_size.to_used_value(container_size), - None => if let LengthOrPercentage::Length(length) = min_size { - Au::from(length) - } else { - Au(0) + None => { + if let LengthOrPercentage::Length(length) = min_size { + Au::from(length) + } else { + Au(0) + } }, }; let mut max_size = match container_size { Some(container_size) => max_size.to_used_value(container_size), - None => if let LengthOrPercentageOrNone::Length(length) = max_size { - Some(Au::from(length)) - } else { - None + None => { + if let LengthOrPercentageOrNone::Length(length) = max_size { + Some(Au::from(length)) + } else { + None + } }, }; // Make sure max size is not smaller than min size. diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 4344ffa531b..79f25482d9e 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -164,7 +164,8 @@ impl Flow for MulticolFlow { LogicalSize::from_physical( self.block_flow.base.writing_mode, ctx.shared_context().viewport_size(), - ).block + ) + .block } }, }); diff --git a/components/layout/query.rs b/components/layout/query.rs index eb94e9c0449..95623c7a98b 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -603,7 +603,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator { // cause this assertion to fail sometimes, so it's // commented out for now. /*assert!(node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT), - "First fragment of inline node found wasn't its first fragment!");*/ + "First fragment of inline node found wasn't its first fragment!");*/ self.node_offset_box = Some(NodeOffsetBoxInfo { offset: border_box.origin, @@ -840,12 +840,11 @@ where let applies = true; fn used_value_for_position_property<N: LayoutNode>( - layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement, - layout_root: &mut Flow, - requested_node: N, - longhand_id: LonghandId, - ) -> String - { + layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement, + layout_root: &mut Flow, + requested_node: N, + longhand_id: LonghandId, + ) -> String { let maybe_data = layout_el.borrow_layout_data(); let position = maybe_data.map_or(Point2D::zero(), |data| { match (*data).flow_construction_result { diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index e94ecba71dd..51442f2f832 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -197,7 +197,8 @@ impl Flow for TableCellFlow { let specified_inline_size = MaybeAuto::from_style( self.block_flow.fragment.style().content_inline_size(), Au(0), - ).specified_or_zero(); + ) + .specified_or_zero(); if self .block_flow .base diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 0d1596d9c85..cb4a033298c 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -143,7 +143,8 @@ impl TableWrapperFlow { ); total_guess = &total_guess + &guess; guess - }).collect(); + }) + .collect(); // Assign inline sizes. let selection = @@ -385,7 +386,8 @@ impl Flow for TableWrapperFlow { size: column_intrinsic_inline_size.minimum_length, percentage: column_intrinsic_inline_size.percentage, }, - ).collect::<Vec<_>>(); + ) + .collect::<Vec<_>>(); // Our inline-size was set to the inline-size of the containing block by the flow's parent. // Now compute the real value. @@ -753,17 +755,17 @@ impl ExcessInlineSizeDistributionInfo { if !column_intrinsic_inline_size.constrained && column_intrinsic_inline_size.percentage == 0.0 { - self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage = - self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage + - column_intrinsic_inline_size.preferred; + self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage = self + .preferred_inline_size_of_nonconstrained_columns_with_no_percentage + + column_intrinsic_inline_size.preferred; self.count_of_nonconstrained_columns_with_no_percentage += 1 } if column_intrinsic_inline_size.constrained && column_intrinsic_inline_size.percentage == 0.0 { - self.preferred_inline_size_of_constrained_columns_with_no_percentage = - self.preferred_inline_size_of_constrained_columns_with_no_percentage + - column_intrinsic_inline_size.preferred + self.preferred_inline_size_of_constrained_columns_with_no_percentage = self + .preferred_inline_size_of_constrained_columns_with_no_percentage + + column_intrinsic_inline_size.preferred } self.total_percentage += column_intrinsic_inline_size.percentage; self.column_count += 1 |