aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/animation.rs21
-rw-r--r--components/layout/block.rs30
-rw-r--r--components/layout/construct.rs15
-rw-r--r--components/layout/data.rs2
-rw-r--r--components/layout/display_list/background.rs2
-rw-r--r--components/layout/display_list/border.rs2
-rw-r--r--components/layout/display_list/builder.rs15
-rw-r--r--components/layout/display_list/gradient.rs2
-rw-r--r--components/layout/display_list/items.rs23
-rw-r--r--components/layout/flex.rs17
-rw-r--r--components/layout/floats.rs8
-rw-r--r--components/layout/flow.rs34
-rw-r--r--components/layout/fragment.rs24
-rw-r--r--components/layout/incremental.rs11
-rw-r--r--components/layout/inline.rs8
-rw-r--r--components/layout/list_item.rs2
-rw-r--r--components/layout/model.rs6
-rw-r--r--components/layout/multicol.rs2
-rw-r--r--components/layout/query.rs6
-rw-r--r--components/layout/sequential.rs11
-rw-r--r--components/layout/table.rs18
-rw-r--r--components/layout/table_caption.rs2
-rw-r--r--components/layout/table_cell.rs17
-rw-r--r--components/layout/table_colgroup.rs2
-rw-r--r--components/layout/table_row.rs2
-rw-r--r--components/layout/table_rowgroup.rs2
-rw-r--r--components/layout/table_wrapper.rs14
-rw-r--r--components/layout/text.rs12
-rw-r--r--components/layout/traversal.rs7
-rw-r--r--components/layout/wrapper.rs2
30 files changed, 162 insertions, 157 deletions
diff --git a/components/layout/animation.rs b/components/layout/animation.rs
index 026a267f449..96e4801fa4e 100644
--- a/components/layout/animation.rs
+++ b/components/layout/animation.rs
@@ -78,16 +78,17 @@ pub fn update_animation_state<E>(
for (key, running_animations) in running_animations.iter_mut() {
let mut animations_still_running = vec![];
for mut running_animation in running_animations.drain(..) {
- let still_running = !running_animation.is_expired() && match running_animation {
- Animation::Transition(_, started_at, ref frame) => {
- now < started_at + frame.duration
- },
- Animation::Keyframes(_, _, _, ref mut state) => {
- // This animation is still running, or we need to keep
- // iterating.
- now < state.started_at + state.duration || state.tick()
- },
- };
+ let still_running = !running_animation.is_expired() &&
+ match running_animation {
+ Animation::Transition(_, started_at, ref frame) => {
+ now < started_at + frame.duration
+ },
+ Animation::Keyframes(_, _, _, ref mut state) => {
+ // This animation is still running, or we need to keep
+ // iterating.
+ now < state.started_at + state.duration || state.tick()
+ },
+ };
debug!(
"update_animation_state({:?}): {:?}",
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 8077b66f821..823d5226ea1 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -25,7 +25,6 @@
//!
//! http://dev.w3.org/csswg/css-sizing/
-use app_units::{Au, MAX_AU};
use crate::context::LayoutContext;
use crate::display_list::items::DisplayListSection;
use crate::display_list::StackingContextCollectionState;
@@ -49,6 +48,7 @@ use crate::model::{
};
use crate::sequential;
use crate::traversal::PreorderFlowTraversal;
+use app_units::{Au, MAX_AU};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use gfx_traits::print_tree::PrintTree;
use serde::{Serialize, Serializer};
@@ -809,11 +809,10 @@ impl BlockFlow {
viewport_size: &Size2D<Au>,
descendant: OpaqueFlow,
) -> LogicalSize<Au> {
- debug_assert!(
- self.base
- .flags
- .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
- );
+ debug_assert!(self
+ .base
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED));
if self.is_fixed() || self.is_root() {
// Initial containing block is the CB for the root
LogicalSize::from_physical(self.base.writing_mode, *viewport_size)
@@ -1176,10 +1175,11 @@ impl BlockFlow {
let mut block_size = cur_b - block_start_offset;
let is_root = self.is_root();
- if is_root || self.formatting_context_type() != FormattingContextType::None || self
- .base
- .flags
- .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
+ if is_root ||
+ self.formatting_context_type() != FormattingContextType::None ||
+ self.base
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
{
// The content block-size includes all the floats per CSS 2.1 § 10.6.7. The easiest
// way to handle this is to just treat it as clearance.
@@ -1953,14 +1953,12 @@ impl BlockFlow {
)
},
(Float::Left, _) => {
- left_float_width_accumulator = left_float_width_accumulator + child_base
- .intrinsic_inline_sizes
- .preferred_inline_size;
+ left_float_width_accumulator = left_float_width_accumulator +
+ child_base.intrinsic_inline_sizes.preferred_inline_size;
},
(Float::Right, _) => {
- right_float_width_accumulator = right_float_width_accumulator + child_base
- .intrinsic_inline_sizes
- .preferred_inline_size;
+ right_float_width_accumulator = right_float_width_accumulator +
+ child_base.intrinsic_inline_sizes.preferred_inline_size;
},
}
}
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 76b15b3b1c7..efa31184dac 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -763,17 +763,20 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult {
let mut fragments = IntermediateInlineFragments::new();
- let node_is_input_or_text_area =
- node.type_id() == Some(LayoutNodeType::Element(LayoutElementType::HTMLInputElement)) ||
- node.type_id() == Some(LayoutNodeType::Element(
+ let node_is_input_or_text_area = node.type_id() ==
+ Some(LayoutNodeType::Element(LayoutElementType::HTMLInputElement)) ||
+ node.type_id() ==
+ Some(LayoutNodeType::Element(
LayoutElementType::HTMLTextAreaElement,
));
if node.get_pseudo_element_type().is_replaced_content() || node_is_input_or_text_area {
// A TextArea's text contents are displayed through the input text
// box, so don't construct them.
- if node.type_id() == Some(LayoutNodeType::Element(
- LayoutElementType::HTMLTextAreaElement,
- )) {
+ if node.type_id() ==
+ Some(LayoutNodeType::Element(
+ LayoutElementType::HTMLTextAreaElement,
+ ))
+ {
for kid in node.children() {
self.set_flow_construction_result(&kid, ConstructionResult::None)
}
diff --git a/components/layout/data.rs b/components/layout/data.rs
index 697aa58c65a..5f6672d1488 100644
--- a/components/layout/data.rs
+++ b/components/layout/data.rs
@@ -2,8 +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/. */
-use atomic_refcell::AtomicRefCell;
use crate::construct::ConstructionResult;
+use atomic_refcell::AtomicRefCell;
use script_layout_interface::StyleData;
#[repr(C)]
diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs
index 85bb7960a8e..89d6aebb0db 100644
--- a/components/layout/display_list/background.rs
+++ b/components/layout/display_list/background.rs
@@ -4,9 +4,9 @@
// FIXME(rust-lang/rust#26264): Remove GenericBackgroundSize.
-use app_units::Au;
use crate::display_list::border;
use crate::model::MaybeAuto;
+use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
use style::computed_values::background_clip::single_value::T as BackgroundClip;
diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs
index bf1df990096..265b25a2805 100644
--- a/components/layout/display_list/border.rs
+++ b/components/layout/display_list/border.rs
@@ -4,8 +4,8 @@
// FIXME(rust-lang/rust#26264): Remove GenericBorderImageSideWidth.
-use app_units::Au;
use crate::display_list::ToLayout;
+use app_units::Au;
use euclid::{Rect, SideOffsets2D, Size2D};
use style::computed_values::border_image_outset::T as BorderImageOutset;
use style::properties::style_structs::Border;
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 835c39865ff..e3dd66b8a2b 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -8,8 +8,6 @@
//! list building, as the actual painting does not happen here—only deciding *what* we're going to
//! paint.
-use app_units::{Au, AU_PER_PX};
-use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
use crate::block::BlockFlow;
use crate::context::LayoutContext;
use crate::display_list::background::{self, get_cyclic};
@@ -33,6 +31,8 @@ use crate::inline::{InlineFlow, InlineFragmentNodeFlags};
use crate::list_item::ListItemFlow;
use crate::model::MaybeAuto;
use crate::table_cell::CollapsedBordersForCell;
+use app_units::{Au, AU_PER_PX};
+use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedRect, TypedSize2D, Vector2D};
use fnv::FnvHashMap;
use gfx::text::glyph::ByteIndex;
@@ -2172,13 +2172,10 @@ impl FragmentDisplayListBuilding for Fragment {
// FIXME(pcwalton): Get the real container size.
let container_size = Size2D::zero();
let metrics = &text_fragment.run.font_metrics;
- let baseline_origin = stacking_relative_content_box.origin + LogicalPoint::new(
- self.style.writing_mode,
- Au(0),
- metrics.ascent,
- )
- .to_physical(self.style.writing_mode, container_size)
- .to_vector();
+ let baseline_origin = stacking_relative_content_box.origin +
+ LogicalPoint::new(self.style.writing_mode, Au(0), metrics.ascent)
+ .to_physical(self.style.writing_mode, container_size)
+ .to_vector();
// Base item for all text/shadows
let base = state.create_base_display_item(
diff --git a/components/layout/display_list/gradient.rs b/components/layout/display_list/gradient.rs
index 6ed057f9c24..6cdee3d6df8 100644
--- a/components/layout/display_list/gradient.rs
+++ b/components/layout/display_list/gradient.rs
@@ -4,8 +4,8 @@
// FIXME(rust-lang/rust#26264): Remove GenericEndingShape and GenericGradientItem.
-use app_units::Au;
use crate::display_list::ToLayout;
+use app_units::Au;
use euclid::{Point2D, Size2D, Vector2D};
use style::properties::ComputedValues;
use style::values::computed::image::{EndingShape, LineDirection};
diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs
index 6525087f8c9..030464fd881 100644
--- a/components/layout/display_list/items.rs
+++ b/components/layout/display_list/items.rs
@@ -513,29 +513,28 @@ impl ClippingRegion {
/// This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_point(&self, point: &LayoutPoint) -> bool {
- self.main.contains(point) && self
- .complex
- .iter()
- .all(|complex| complex.rect.contains(point))
+ self.main.contains(point) &&
+ self.complex
+ .iter()
+ .all(|complex| complex.rect.contains(point))
}
/// Returns true if this clipping region might intersect the given rectangle and false
/// otherwise. This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_rect(&self, rect: &LayoutRect) -> bool {
- self.main.intersects(rect) && self
- .complex
- .iter()
- .all(|complex| complex.rect.intersects(rect))
+ self.main.intersects(rect) &&
+ self.complex
+ .iter()
+ .all(|complex| complex.rect.intersects(rect))
}
/// Returns true if this clipping region completely surrounds the given rect.
#[inline]
pub fn does_not_clip_rect(&self, rect: &LayoutRect) -> bool {
- self.main.contains(&rect.origin) && self.main.contains(&rect.bottom_right()) && self
- .complex
- .iter()
- .all(|complex| {
+ self.main.contains(&rect.origin) &&
+ self.main.contains(&rect.bottom_right()) &&
+ self.complex.iter().all(|complex| {
complex.rect.contains(&rect.origin) && complex.rect.contains(&rect.bottom_right())
})
}
diff --git a/components/layout/flex.rs b/components/layout/flex.rs
index 6eb99d88262..1848cdf2e81 100644
--- a/components/layout/flex.rs
+++ b/components/layout/flex.rs
@@ -4,7 +4,6 @@
//! Layout for elements with a CSS `display` property of `flex`.
-use app_units::{Au, MAX_AU};
use crate::block::{AbsoluteAssignBSizesTraversal, BlockFlow, MarginsMayCollapseFlag};
use crate::context::LayoutContext;
use crate::display_list::StackingContextCollectionState;
@@ -16,6 +15,7 @@ use crate::layout_debug;
use crate::model::{AdjoiningMargins, CollapsibleMargins};
use crate::model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use crate::traversal::PreorderFlowTraversal;
+use app_units::{Au, MAX_AU};
use euclid::Point2D;
use std::cmp::{max, min};
use std::ops::Range;
@@ -846,13 +846,14 @@ impl FlexFlow {
// as if it has a fixed cross size, all child blocks should resolve against it.
// block.assign_block_size(layout_context);
}
- block.base.position.start.b = margin_block_start + if !self.cross_reverse {
- cur_b
- } else {
- self.block_flow.fragment.border_padding.block_start * 2 + total_cross_size -
- cur_b -
- line.cross_size
- };
+ block.base.position.start.b = margin_block_start +
+ if !self.cross_reverse {
+ cur_b
+ } else {
+ self.block_flow.fragment.border_padding.block_start * 2 + total_cross_size -
+ cur_b -
+ line.cross_size
+ };
// TODO(stshine): support baseline alignment.
if free_space != Au(0) {
let flex_cross = match self_align {
diff --git a/components/layout/floats.rs b/components/layout/floats.rs
index a423ead9f6d..5e9ee3ae886 100644
--- a/components/layout/floats.rs
+++ b/components/layout/floats.rs
@@ -2,10 +2,10 @@
* 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/. */
-use app_units::{Au, MAX_AU};
use crate::block::FormattingContextType;
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
use crate::persistent_list::PersistentList;
+use app_units::{Au, MAX_AU};
use std::cmp::{max, min};
use std::fmt;
use style::computed_values::float::T as StyleFloat;
@@ -353,7 +353,7 @@ impl Floats {
info.ceiling,
info.max_inline_size,
MAX_AU,
- )
+ );
},
FloatKind::Right => {
return LogicalRect::new(
@@ -362,7 +362,7 @@ impl Floats {
info.ceiling,
info.max_inline_size,
MAX_AU,
- )
+ );
},
}
}
@@ -395,7 +395,7 @@ impl Floats {
info.max_inline_size,
MAX_AU,
),
- }
+ };
},
Some(rect) => {
assert_ne!(
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index c649cc32eeb..2059fe35525 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -25,7 +25,6 @@
//! line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and
//! similar methods.
-use app_units::Au;
use crate::block::{BlockFlow, FormattingContextType};
use crate::context::LayoutContext;
use crate::display_list::items::ClippingAndScrolling;
@@ -46,6 +45,7 @@ use crate::table_colgroup::TableColGroupFlow;
use crate::table_row::TableRowFlow;
use crate::table_rowgroup::TableRowGroupFlow;
use crate::table_wrapper::TableWrapperFlow;
+use app_units::Au;
use euclid::{Point2D, Rect, Size2D, Vector2D};
use gfx_traits::print_tree::PrintTree;
use gfx_traits::StackingContextId;
@@ -342,14 +342,14 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
overflow.scroll.size.height = border_box.size.height;
}
- if !self.as_block().fragment.establishes_stacking_context() || self
- .as_block()
- .fragment
- .style
- .get_box()
- .transform
- .0
- .is_empty()
+ if !self.as_block().fragment.establishes_stacking_context() ||
+ self.as_block()
+ .fragment
+ .style
+ .get_box()
+ .transform
+ .0
+ .is_empty()
{
overflow.translate(&position.origin.to_vector());
return overflow;
@@ -466,10 +466,10 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
}
fn contains_positioned_fragments(&self) -> bool {
- self.contains_relatively_positioned_fragments() || self
- .base()
- .flags
- .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
+ self.contains_relatively_positioned_fragments() ||
+ self.base()
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
}
fn contains_relatively_positioned_fragments(&self) -> bool {
@@ -1406,10 +1406,10 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow {
return Some(kid.base().position.start.b + baseline_offset);
}
}
- if kid.is_block_like() && !kid
- .base()
- .flags
- .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
+ if kid.is_block_like() &&
+ !kid.base()
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
{
if let Some(baseline_offset) = kid.baseline_offset_of_last_line_box_in_flow() {
return Some(kid.base().position.start.b + baseline_offset);
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index e95d0293894..3e84a36c595 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -4,8 +4,6 @@
//! The `Fragment` type, which represents the leaves of the layout tree.
-use app_units::Au;
-use canvas_traits::canvas::{CanvasId, CanvasMsg};
use crate::context::{with_thread_local_font_context, LayoutContext};
use crate::display_list::items::{ClipScrollNodeIndex, OpaqueNode, BLUR_INFLATION_FACTOR};
use crate::display_list::ToLayout;
@@ -22,6 +20,8 @@ use crate::text;
use crate::text::TextRunScanner;
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
use crate::ServoArc;
+use app_units::Au;
+use canvas_traits::canvas::{CanvasId, CanvasMsg};
use euclid::{Point2D, Rect, Size2D, Vector2D};
use gfx::text::glyph::ByteIndex;
use gfx::text::text_run::{TextRun, TextRunSlice};
@@ -849,10 +849,10 @@ impl Fragment {
}
pub fn contains_node(&self, node_address: OpaqueNode) -> bool {
- node_address == self.node || self
- .inline_context
- .as_ref()
- .map_or(false, |ctx| ctx.contains_node(node_address))
+ node_address == self.node ||
+ self.inline_context
+ .as_ref()
+ .map_or(false, |ctx| ctx.contains_node(node_address))
}
/// Adds a style to the inline context for this fragment. If the inline context doesn't exist
@@ -1939,9 +1939,9 @@ impl Fragment {
// The advance is more than the remaining inline-size, so split here. First, check to
// 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());
+ let split_is_empty = inline_start_range.is_empty() &&
+ !(self.requires_line_break_afterward_if_wrapping_on_newlines() &&
+ !self.white_space().allow_wrap());
if split_is_empty {
// We're going to overflow the line.
overflowing = true;
@@ -2416,9 +2416,9 @@ impl Fragment {
minimum_line_metrics.space_above_baseline
},
VerticalAlign::TextBottom => {
- offset = minimum_line_metrics.space_below_baseline - self
- .content_inline_metrics(layout_context)
- .space_below_baseline
+ offset = minimum_line_metrics.space_below_baseline -
+ self.content_inline_metrics(layout_context)
+ .space_below_baseline
},
VerticalAlign::Top => {
if let Some(actual_line_metrics) = actual_line_metrics {
diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs
index 0df2540489f..e3007511f8e 100644
--- a/components/layout/incremental.rs
+++ b/components/layout/incremental.rs
@@ -62,17 +62,18 @@ impl<'a> LayoutDamageComputation for &'a mut dyn Flow {
.damage_for_parent(child_is_absolutely_positioned),
);
- has_counter_affecting_children =
- has_counter_affecting_children || kid.base().flags.intersects(
+ has_counter_affecting_children = has_counter_affecting_children ||
+ kid.base().flags.intersects(
FlowFlags::AFFECTS_COUNTERS | FlowFlags::HAS_COUNTER_AFFECTING_CHILDREN,
);
}
}
let self_base = self.mut_base();
- if self_base.flags.float_kind() != Float::None && self_base
- .restyle_damage
- .intersects(ServoRestyleDamage::REFLOW)
+ if self_base.flags.float_kind() != Float::None &&
+ self_base
+ .restyle_damage
+ .intersects(ServoRestyleDamage::REFLOW)
{
special_damage.insert(SpecialRestyleDamage::REFLOW_ENTIRE_DOCUMENT);
}
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index eceb2c7594e..34161a16702 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -2,7 +2,6 @@
* 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/. */
-use app_units::{Au, MIN_AU};
use crate::block::AbsoluteAssignBSizesTraversal;
use crate::context::{LayoutContext, LayoutFontContext};
use crate::display_list::items::OpaqueNode;
@@ -20,6 +19,7 @@ use crate::model::IntrinsicISizesContribution;
use crate::text;
use crate::traversal::PreorderFlowTraversal;
use crate::ServoArc;
+use app_units::{Au, MIN_AU};
use euclid::{Point2D, Size2D};
use gfx::font::FontMetrics;
use gfx_traits::print_tree::PrintTree;
@@ -1363,9 +1363,9 @@ impl InlineFlow {
fragment_index: FragmentIndex,
) -> Range<FragmentIndex> {
let mut start_index = fragment_index;
- while start_index > FragmentIndex(0) && self.fragments.fragments
- [(start_index - FragmentIndex(1)).get() as usize]
- .is_positioned()
+ while start_index > FragmentIndex(0) &&
+ self.fragments.fragments[(start_index - FragmentIndex(1)).get() as usize]
+ .is_positioned()
{
start_index = start_index - FragmentIndex(1)
}
diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs
index c0082a8d635..08ae74f4cbe 100644
--- a/components/layout/list_item.rs
+++ b/components/layout/list_item.rs
@@ -5,7 +5,6 @@
//! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a
//! block and an extra inline fragment for the marker.
-use app_units::Au;
use crate::block::BlockFlow;
use crate::context::{with_thread_local_font_context, LayoutContext};
use crate::display_list::StackingContextCollectionState;
@@ -18,6 +17,7 @@ use crate::fragment::{
};
use crate::generated_content;
use crate::inline::InlineFlow;
+use app_units::Au;
use euclid::Point2D;
use style::computed_values::list_style_type::T as ListStyleType;
use style::computed_values::position::T as Position;
diff --git a/components/layout/model.rs b/components/layout/model.rs
index 9daeb770f9d..4db60d05a4b 100644
--- a/components/layout/model.rs
+++ b/components/layout/model.rs
@@ -4,8 +4,8 @@
//! Borders, padding, and margins.
-use app_units::Au;
use crate::fragment::Fragment;
+use app_units::Au;
use euclid::SideOffsets2D;
use std::cmp::{max, min};
use std::fmt;
@@ -133,8 +133,8 @@ impl MarginCollapseInfo {
) -> (CollapsibleMargins, Au) {
let state = match self.state {
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
- may_collapse_through =
- may_collapse_through && match fragment.style().content_block_size() {
+ may_collapse_through = may_collapse_through &&
+ match fragment.style().content_block_size() {
LengthOrPercentageOrAuto::Auto => true,
LengthOrPercentageOrAuto::Length(l) => l.px() == 0.,
LengthOrPercentageOrAuto::Percentage(v) => {
diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs
index 986d0d3a7b1..294670f0a1e 100644
--- a/components/layout/multicol.rs
+++ b/components/layout/multicol.rs
@@ -4,7 +4,6 @@
//! CSS Multi-column layout http://dev.w3.org/csswg/css-multicol/
-use app_units::Au;
use crate::block::BlockFlow;
use crate::context::LayoutContext;
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
@@ -12,6 +11,7 @@ use crate::floats::FloatKind;
use crate::flow::{Flow, FlowClass, FragmentationContext, GetBaseFlow, OpaqueFlow};
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use crate::ServoArc;
+use app_units::Au;
use euclid::{Point2D, Vector2D};
use gfx_traits::print_tree::PrintTree;
use std::cmp::{max, min};
diff --git a/components/layout/query.rs b/components/layout/query.rs
index d7801c389da..60d1719e13a 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -4,7 +4,6 @@
//! Utilities for querying the layout, as needed by the layout thread.
-use app_units::Au;
use crate::construct::ConstructionResult;
use crate::context::LayoutContext;
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
@@ -15,6 +14,7 @@ use crate::inline::InlineFragmentNodeFlags;
use crate::opaque_node::OpaqueNodeMethods;
use crate::sequential;
use crate::wrapper::LayoutNodeLayoutData;
+use app_units::Au;
use euclid::{Point2D, Rect, Size2D, Vector2D};
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
@@ -777,7 +777,7 @@ where
// so this should be web-compatible.
PropertyId::ShorthandAlias(..) | PropertyId::Shorthand(_) => return String::new(),
PropertyId::Custom(ref name) => {
- return style.computed_value_to_string(PropertyDeclarationId::Custom(name))
+ return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
},
};
@@ -825,7 +825,7 @@ where
// so this should be web-compatible.
PropertyId::ShorthandAlias(..) | PropertyId::Shorthand(_) => return String::new(),
PropertyId::Custom(ref name) => {
- return style.computed_value_to_string(PropertyDeclarationId::Custom(name))
+ return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
},
};
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index 2e10187dbd9..a1fe086d79f 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -4,7 +4,6 @@
//! Implements sequential traversals over the DOM and flow trees.
-use app_units::Au;
use crate::context::LayoutContext;
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
use crate::floats::SpeculatedFloatPlacement;
@@ -14,6 +13,7 @@ use crate::generated_content::ResolveGeneratedContent;
use crate::incremental::RelayoutMode;
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
use crate::traversal::{InorderFlowTraversal, PostorderFlowTraversal, PreorderFlowTraversal};
+use app_units::Au;
use euclid::{Point2D, Vector2D};
use servo_config::opts;
use style::servo::restyle_damage::ServoRestyleDamage;
@@ -106,10 +106,11 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(
.stacking_relative_border_box(CoordinateSystem::Own);
if let Some(matrix) = kid.as_block().fragment.transform_matrix(&relative_position) {
let transform_matrix = matrix.transform_point2d(&LayoutPoint::zero()).unwrap();
- stacking_context_position = stacking_context_position + Vector2D::new(
- Au::from_f32_px(transform_matrix.x),
- Au::from_f32_px(transform_matrix.y),
- )
+ stacking_context_position = stacking_context_position +
+ Vector2D::new(
+ Au::from_f32_px(transform_matrix.x),
+ Au::from_f32_px(transform_matrix.y),
+ )
}
}
doit(kid, level + 1, iterator, &stacking_context_position);
diff --git a/components/layout/table.rs b/components/layout/table.rs
index 965d1cb7880..5f08b107b31 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -4,7 +4,6 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::block::{BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer};
use crate::block::{ISizeConstraintInput, ISizeConstraintSolution};
use crate::context::LayoutContext;
@@ -24,6 +23,7 @@ use crate::table_cell::TableCellFlow;
use crate::table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};
use crate::table_row::{TableRowFlow, TableRowSizeData};
use crate::table_wrapper::TableLayout;
+use app_units::Au;
use euclid::Point2D;
use gfx_traits::print_tree::PrintTree;
use std::{cmp, fmt};
@@ -952,9 +952,8 @@ impl TableLikeFlow for BlockFlow {
row.mut_base().restyle_damage.remove(
ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW,
);
- current_block_offset =
- current_block_offset +
- border_spacing_for_row(&self.fragment, row, block_direction_spacing);
+ current_block_offset = current_block_offset +
+ border_spacing_for_row(&self.fragment, row, block_direction_spacing);
i += 1;
}
@@ -990,11 +989,12 @@ impl TableLikeFlow for BlockFlow {
current_block_offset = current_block_offset + delta;
// Take border, padding, and spacing into account.
- let block_end_offset = self.fragment.border_padding.block_end + if has_rows {
- block_direction_spacing
- } else {
- Au(0)
- };
+ let block_end_offset = self.fragment.border_padding.block_end +
+ if has_rows {
+ block_direction_spacing
+ } else {
+ Au(0)
+ };
current_block_offset = current_block_offset + block_end_offset;
// Now that `current_block_offset` is at the block-end of the border box, compute the
diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs
index 8bd4fcccaaa..b217aa65f8b 100644
--- a/components/layout/table_caption.rs
+++ b/components/layout/table_caption.rs
@@ -4,13 +4,13 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::block::BlockFlow;
use crate::context::LayoutContext;
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
use crate::display_list::{StackingContextCollectionFlags, StackingContextCollectionState};
use crate::flow::{Flow, FlowClass, OpaqueFlow};
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
+use app_units::Au;
use euclid::Point2D;
use gfx_traits::print_tree::PrintTree;
use std::fmt;
diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs
index 55510de3a2a..b5d95b1e4dd 100644
--- a/components/layout/table_cell.rs
+++ b/components/layout/table_cell.rs
@@ -4,7 +4,6 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag};
use crate::context::LayoutContext;
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
@@ -15,6 +14,7 @@ use crate::layout_debug;
use crate::model::MaybeAuto;
use crate::table::InternalTable;
use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance};
+use app_units::Au;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use gfx_traits::print_tree::PrintTree;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
@@ -106,12 +106,15 @@ impl TableCellFlow {
if kid_base.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {
continue;
}
- let start = kid_base.position.start.b - kid_base
- .collapsible_margins
- .block_start_margin_for_noncollapsible_context();
- let end = kid_base.position.start.b + kid_base.position.size.block + kid_base
- .collapsible_margins
- .block_end_margin_for_noncollapsible_context();
+ let start = kid_base.position.start.b -
+ kid_base
+ .collapsible_margins
+ .block_start_margin_for_noncollapsible_context();
+ let end = kid_base.position.start.b +
+ kid_base.position.size.block +
+ kid_base
+ .collapsible_margins
+ .block_end_margin_for_noncollapsible_context();
match extents {
Some((ref mut first_start, ref mut last_end)) => {
if start < *first_start {
diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs
index 3b83744f979..28cdafea7ec 100644
--- a/components/layout/table_colgroup.rs
+++ b/components/layout/table_colgroup.rs
@@ -4,12 +4,12 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::context::LayoutContext;
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow};
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use crate::layout_debug;
+use app_units::Au;
use euclid::Point2D;
use std::fmt;
use style::logical_geometry::LogicalSize;
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index e193f68a30c..90c3c812f1c 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -4,7 +4,6 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::block::{BlockFlow, ISizeAndMarginsComputer};
use crate::context::LayoutContext;
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
@@ -18,6 +17,7 @@ use crate::layout_debug;
use crate::model::MaybeAuto;
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use crate::table_cell::{CollapsedBordersForCell, TableCellFlow};
+use app_units::Au;
use euclid::Point2D;
use gfx_traits::print_tree::PrintTree;
use serde::{Serialize, Serializer};
diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs
index 1ce2a0477ee..b2afd3c2aba 100644
--- a/components/layout/table_rowgroup.rs
+++ b/components/layout/table_rowgroup.rs
@@ -4,7 +4,6 @@
//! CSS table formatting contexts.
-use app_units::Au;
use crate::block::{BlockFlow, ISizeAndMarginsComputer};
use crate::context::LayoutContext;
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
@@ -13,6 +12,7 @@ use crate::flow::{Flow, FlowClass, OpaqueFlow};
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use crate::layout_debug;
use crate::table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow};
+use app_units::Au;
use euclid::Point2D;
use gfx_traits::print_tree::PrintTree;
use serde::{Serialize, Serializer};
diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs
index f5f57eee16a..94d7d2d32a0 100644
--- a/components/layout/table_wrapper.rs
+++ b/components/layout/table_wrapper.rs
@@ -11,7 +11,6 @@
//!
//! Hereafter this document is referred to as INTRINSIC.
-use app_units::Au;
use crate::block::{
AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput,
};
@@ -26,6 +25,7 @@ use crate::flow::{Flow, FlowClass, FlowFlags, ImmutableFlowUtils, OpaqueFlow};
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use crate::model::MaybeAuto;
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
+use app_units::Au;
use euclid::Point2D;
use gfx_traits::print_tree::PrintTree;
use std::cmp::{max, min};
@@ -795,18 +795,18 @@ impl ExcessInlineSizeDistributionInfo {
if !column_intrinsic_inline_size.constrained &&
column_intrinsic_inline_size.percentage == 0.0
{
- column_intrinsic_inline_size.preferred.to_f32_px() / self
- .preferred_inline_size_of_nonconstrained_columns_with_no_percentage
- .to_f32_px()
+ column_intrinsic_inline_size.preferred.to_f32_px() /
+ self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage
+ .to_f32_px()
} else {
0.0
}
} else if self.count_of_nonconstrained_columns_with_no_percentage > 0 {
1.0 / (self.count_of_nonconstrained_columns_with_no_percentage as CSSFloat)
} else if self.preferred_inline_size_of_constrained_columns_with_no_percentage > Au(0) {
- column_intrinsic_inline_size.preferred.to_f32_px() / self
- .preferred_inline_size_of_constrained_columns_with_no_percentage
- .to_f32_px()
+ column_intrinsic_inline_size.preferred.to_f32_px() /
+ self.preferred_inline_size_of_constrained_columns_with_no_percentage
+ .to_f32_px()
} else if self.total_percentage > 0.0 {
column_intrinsic_inline_size.percentage / self.total_percentage
} else {
diff --git a/components/layout/text.rs b/components/layout/text.rs
index 703f3d5954d..aba5703a1c6 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -4,12 +4,12 @@
//! Text layout.
-use app_units::Au;
use crate::context::LayoutFontContext;
use crate::fragment::{Fragment, ScannedTextFlags};
use crate::fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use crate::inline::{InlineFragmentNodeFlags, InlineFragments};
use crate::linked_list::split_off_head;
+use app_units::Au;
use gfx::font::{FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions};
use gfx::text::glyph::ByteIndex;
use gfx::text::text_run::TextRun;
@@ -112,11 +112,11 @@ impl TextRunScanner {
// Create a clump.
split_first_fragment_at_newline_if_necessary(&mut fragments);
self.clump.append(&mut split_off_head(&mut fragments));
- while !fragments.is_empty() && self
- .clump
- .back()
- .unwrap()
- .can_merge_with_fragment(fragments.front().unwrap())
+ while !fragments.is_empty() &&
+ self.clump
+ .back()
+ .unwrap()
+ .can_merge_with_fragment(fragments.front().unwrap())
{
split_first_fragment_at_newline_if_necessary(&mut fragments);
self.clump.append(&mut split_off_head(&mut fragments));
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index 9ffd4e87c29..6d44fcfc5e4 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -201,9 +201,10 @@ where
// Always reconstruct if incremental layout is turned off.
let nonincremental_layout = opts::get().nonincremental_layout;
- if nonincremental_layout || tnode.restyle_damage() != RestyleDamage::empty() || node
- .as_element()
- .map_or(false, |el| el.has_dirty_descendants())
+ if nonincremental_layout ||
+ tnode.restyle_damage() != RestyleDamage::empty() ||
+ node.as_element()
+ .map_or(false, |el| el.has_dirty_descendants())
{
let mut flow_constructor = FlowConstructor::new(context);
if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) {
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index 3602acf7f7b..063d7f3d25d 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -30,8 +30,8 @@
#![allow(unsafe_code)]
-use atomic_refcell::{AtomicRef, AtomicRefMut};
use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
+use atomic_refcell::{AtomicRef, AtomicRefMut};
use script_layout_interface::wrapper_traits::GetLayoutData;
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use style::dom::{NodeInfo, TNode};