aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/sequential.rs
diff options
context:
space:
mode:
authorPyfisch <pyfisch@gmail.com>2018-08-24 15:44:25 +0200
committerPyfisch <pyfisch@gmail.com>2018-09-01 13:24:57 +0200
commit349047b096fc8d121bc1a5be1ab74eabe648285b (patch)
treea18c07097a9935a54c8c2f5c5a317a8479bc1dcf /components/layout/sequential.rs
parent577830de909dd692f2d178d139984f45bbf929c3 (diff)
downloadservo-349047b096fc8d121bc1a5be1ab74eabe648285b.tar.gz
servo-349047b096fc8d121bc1a5be1ab74eabe648285b.zip
Rustfmt layout crate
Diffstat (limited to 'components/layout/sequential.rs')
-rw-r--r--components/layout/sequential.rs75
1 files changed, 47 insertions, 28 deletions
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index e3984867a11..5da3f842656 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -25,10 +25,12 @@ pub fn resolve_generated_content(root: &mut Flow, layout_context: &LayoutContext
/// Run the main layout passes sequentially.
pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) {
- fn doit(flow: &mut Flow,
- assign_inline_sizes: AssignISizes,
- assign_block_sizes: AssignBSizes,
- relayout_mode: RelayoutMode) {
+ fn doit(
+ flow: &mut Flow,
+ assign_inline_sizes: AssignISizes,
+ assign_block_sizes: AssignBSizes,
+ relayout_mode: RelayoutMode,
+ ) {
// Force reflow children during this traversal. This is needed when we failed
// the float speculation of a block formatting context and need to fix it.
if relayout_mode == RelayoutMode::Force {
@@ -67,42 +69,47 @@ pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: Re
doit(root, assign_inline_sizes, assign_block_sizes, relayout_mode);
}
-pub fn build_display_list_for_subtree<'a>(flow_root: &mut Flow,
- layout_context: &'a LayoutContext)
- -> DisplayListBuildState<'a> {
+pub fn build_display_list_for_subtree<'a>(
+ flow_root: &mut Flow,
+ layout_context: &'a LayoutContext,
+) -> DisplayListBuildState<'a> {
let mut state = StackingContextCollectionState::new(layout_context.id);
flow_root.collect_stacking_contexts(&mut state);
let state = DisplayListBuildState::new(layout_context, state);
- let mut build_display_list = BuildDisplayList {
- state: state,
- };
+ let mut build_display_list = BuildDisplayList { state: state };
build_display_list.traverse(flow_root);
build_display_list.state
}
-pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut Flow, iterator: &mut FragmentBorderBoxIterator) {
- fn doit(flow: &mut Flow,
- level: i32,
- iterator: &mut FragmentBorderBoxIterator,
- stacking_context_position: &Point2D<Au>) {
+pub fn iterate_through_flow_tree_fragment_border_boxes(
+ root: &mut Flow,
+ iterator: &mut FragmentBorderBoxIterator,
+) {
+ fn doit(
+ flow: &mut Flow,
+ level: i32,
+ iterator: &mut FragmentBorderBoxIterator,
+ stacking_context_position: &Point2D<Au>,
+ ) {
flow.iterate_through_fragment_border_boxes(iterator, level, stacking_context_position);
for kid in flow.mut_base().child_iter_mut() {
let mut stacking_context_position = *stacking_context_position;
if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() {
- stacking_context_position = Point2D::new(kid.as_block().fragment.margin.inline_start, Au(0)) +
- kid.base().stacking_relative_position +
- stacking_context_position.to_vector();
- let relative_position = kid.as_block()
+ stacking_context_position =
+ Point2D::new(kid.as_block().fragment.margin.inline_start, Au(0)) +
+ kid.base().stacking_relative_position +
+ stacking_context_position.to_vector();
+ let relative_position = kid
+ .as_block()
.stacking_relative_border_box(CoordinateSystem::Own);
- if let Some(matrix) = kid.as_block()
- .fragment
- .transform_matrix(&relative_position) {
+ 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);
@@ -113,7 +120,11 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut Flow, iterator
}
pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) {
- if !flow.base().restyle_damage.contains(ServoRestyleDamage::STORE_OVERFLOW) {
+ if !flow
+ .base()
+ .restyle_damage
+ .contains(ServoRestyleDamage::STORE_OVERFLOW)
+ {
return;
}
@@ -132,13 +143,21 @@ pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) {
/// given flow. This is needed to speculatively calculate the inline sizes of block formatting
/// contexts. The speculation typically succeeds, but if it doesn't we have to lay it out again.
pub fn guess_float_placement(flow: &mut Flow) {
- if !flow.base().restyle_damage.intersects(ServoRestyleDamage::REFLOW) {
+ if !flow
+ .base()
+ .restyle_damage
+ .intersects(ServoRestyleDamage::REFLOW)
+ {
return;
}
let mut floats_in = SpeculatedFloatPlacement::compute_floats_in_for_first_child(flow);
for kid in flow.mut_base().child_iter_mut() {
- if kid.base().flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {
+ if kid
+ .base()
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
+ {
// Do not propagate floats in or out, but do propogate between kids.
guess_float_placement(kid);
} else {