servo: Merge #10490 - Add tests and clean up `FlexFlow::(block|inline)_mode_assign_inline_sizes` (from danlrobertson:correct-size); r=SimonSapin
authorDaniel Robertson <dan.robertson@anidata.org>
Mon, 11 Apr 2016 21:41:37 +0500
changeset 476644 39a8bea6d01b9debe27900245827cbf1dba6ff8b
parent 476643 0bdab191226e3c458469636d459e70b84b3e3798
child 476645 dbebb6aa5a0eb85475574dd211d3002de1ecc48d
push id44079
push userbmo:gps@mozilla.com
push dateSat, 04 Feb 2017 00:14:49 +0000
reviewersSimonSapin
servo: Merge #10490 - Add tests and clean up `FlexFlow::(block|inline)_mode_assign_inline_sizes` (from danlrobertson:correct-size); r=SimonSapin Clean up `block_mode_assign_inline_sizes` and `inline_mode_assign_inline_sizes` and add extra css tests. r? @SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: 608533cb4ad31358269cfa8039077767f325f3be
servo/components/layout/flex.rs
--- a/servo/components/layout/flex.rs
+++ b/servo/components/layout/flex.rs
@@ -181,45 +181,47 @@ impl FlexFlow {
                                       inline_end_content_edge: Au,
                                       content_inline_size: Au) {
         let _scope = layout_debug_scope!("flex::block_mode_assign_inline_sizes");
         debug!("block_mode_assign_inline_sizes");
 
         // FIXME (mbrubeck): Get correct mode for absolute containing block
         let containing_block_mode = self.block_flow.base.writing_mode;
 
+        let container_block_size = match self.available_main_size {
+            AxisSize::Definite(length) => Some(length),
+            _ => None
+        };
+        let container_inline_size = match self.available_cross_size {
+            AxisSize::Definite(length) => length,
+            AxisSize::MinMax(ref constraint) => constraint.clamp(content_inline_size),
+            AxisSize::Infinite => content_inline_size
+        };
         let mut iterator = self.block_flow.base.child_iter_mut().enumerate().peekable();
         while let Some((_, kid)) = iterator.next() {
             {
                 let kid_base = flow::mut_base(kid);
-                kid_base.block_container_explicit_block_size = match self.available_main_size {
-                    AxisSize::Definite(length) => Some(length),
-                    _ => None
-                }
+                kid_base.block_container_explicit_block_size = container_block_size;
             }
 
             // The inline-start margin edge of the child flow is at our inline-start content edge,
             // and its inline-size is our content inline-size.
             let kid_mode = flow::base(kid).writing_mode;
             {
                 let kid_base = flow::mut_base(kid);
                 if kid_base.flags.contains(INLINE_POSITION_IS_STATIC) {
                     kid_base.position.start.i =
                         if kid_mode.is_bidi_ltr() == containing_block_mode.is_bidi_ltr() {
                             inline_start_content_edge
                         } else {
                             // The kid's inline 'start' is at the parent's 'end'
                             inline_end_content_edge
                         };
                 }
-                kid_base.block_container_inline_size = match self.available_main_size {
-                    AxisSize::Definite(length) => length,
-                    AxisSize::MinMax(ref constraint) => constraint.clamp(content_inline_size),
-                    AxisSize::Infinite => content_inline_size,
-                };
+                kid_base.block_container_inline_size = container_inline_size;
                 kid_base.block_container_writing_mode = containing_block_mode;
             }
         }
     }
 
     // TODO(zentner): This function should actually flex elements!
     // Currently, this is the core of InlineFlow::propagate_assigned_inline_size_to_children() with
     // fragment logic stripped out.
@@ -242,17 +244,16 @@ impl FlexFlow {
         let inline_size = match self.available_main_size {
             AxisSize::Definite(length) => length,
             AxisSize::MinMax(ref constraint) => constraint.clamp(content_inline_size),
             AxisSize::Infinite => content_inline_size,
         };
 
         let even_content_inline_size = inline_size / child_count;
 
-        let inline_size = self.block_flow.base.block_container_inline_size;
         let container_mode = self.block_flow.base.block_container_writing_mode;
         self.block_flow.base.position.size.inline = inline_size;
 
         let block_container_explicit_block_size = self.block_flow.base.block_container_explicit_block_size;
         let mut inline_child_start = inline_start_content_edge;
         for kid in self.block_flow.base.child_iter_mut() {
             let kid_base = flow::mut_base(kid);