tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1311HTML 640Markdown 11TOML 63653 Definiciones

Floor outer flex-basis by padding_border sum (floors inner flex-basis at 0)

d1b0451f76b04e50972b1c78ff5b1a91d4c948b8 · por Nico Burns · (hace 3 años) · padre 39bf6ce4b · ver el árbol en este commit

Delta semántico · 1

src/compute/flexbox.rs

1 archivos · +9 −0

diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 700477410..976848d98 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -680,6 +680,15 @@ fn determine_flex_base_size(
             .main(constants.dir);
         };
 
+        // Floor flex-basis by the padding_border_sum (floors inner_flex_basis at 0)
+        // This seems to be in violation of the spec which explicitly states that the content box should not be floored at
+        // (like it usually is) when calculating the flex-basis. But including this matches both Chrome and Firefox's behaviour.
+        //
+        // TODO: resolve spec violation
+        // Spec: https://www.w3.org/TR/css-flexbox-1/#intrinsic-item-contributions
+        // Spec: https://www.w3.org/TR/css-flexbox-1/#change-2016-max-contribution
+        let padding_border_sum = child.padding.main_axis_sum(constants.dir) + child.border.main_axis_sum(constants.dir);
+        child.flex_basis = child.flex_basis.max(padding_border_sum);
 
         // The hypothetical main size is the item’s flex base size clamped according to its
         // used min and max main sizes (and flooring the content box size at zero).