diff --git a/Cargo.lock b/Cargo.lock index ff0a6c2ad..a8e8af74a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7397,7 +7397,7 @@ dependencies = [ [[package]] name = "taffy" version = "0.13.0" -source = "git+https://github.com/DioxusLabs/taffy?rev=02820e54b7a0a38cc2443eb9d2d24a44db36f235#02820e54b7a0a38cc2443eb9d2d24a44db36f235" +source = "git+https://github.com/DioxusLabs/taffy?rev=4ae4219b34e0ad22fd907cb1a7fa9a68c1ea1621#4ae4219b34e0ad22fd907cb1a7fa9a68c1ea1621" dependencies = [ "arrayvec", "serde", diff --git a/Cargo.toml b/Cargo.toml index 8c2dee9a7..be4987b6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ dioxus-cli-config = { version = "0.7.3" } dioxus-core-macro = { version = "0.7.3" } # Taffy + Parley + Fontations -taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "02820e54b7a0a38cc2443eb9d2d24a44db36f235", default-features = false, features = [ +taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "4ae4219b34e0ad22fd907cb1a7fa9a68c1ea1621", default-features = false, features = [ "std", "flexbox", "grid", diff --git a/packages/blitz-dom/src/layout/damage.rs b/packages/blitz-dom/src/layout/damage.rs index 27b72643a..0651b9a26 100644 --- a/packages/blitz-dom/src/layout/damage.rs +++ b/packages/blitz-dom/src/layout/damage.rs @@ -219,6 +219,7 @@ pub(crate) fn compute_layout_damage(old: &ComputedValues, new: &ComputedValues) if old_box.display != new_box.display || old_box.float != new_box.float || old_box.position != new_box.position + || old_box.contain != new_box.contain || old.clone_visibility() != new.clone_visibility() { return true; diff --git a/packages/stylo_taffy/src/convert.rs b/packages/stylo_taffy/src/convert.rs index 2819c4761..048b1fd48 100644 --- a/packages/stylo_taffy/src/convert.rs +++ b/packages/stylo_taffy/src/convert.rs @@ -10,7 +10,9 @@ pub(crate) mod stylo { pub(crate) use style::properties::longhands::position::computed_value::T as Position; pub(crate) use style::values::computed::length_percentage::CalcLengthPercentage; pub(crate) use style::values::computed::length_percentage::Unpacked as UnpackedLengthPercentage; - pub(crate) use style::values::computed::{BorderSideWidth, LengthPercentage, Percentage}; + pub(crate) use style::values::computed::{ + BorderSideWidth, Contain, LengthPercentage, Percentage, + }; pub(crate) use style::values::generics::NonNegative; pub(crate) use style::values::generics::length::{ GenericLengthPercentageOrNormal, GenericMargin, GenericMaxSize, GenericSize, @@ -274,6 +276,25 @@ pub fn overflow(input: stylo::Overflow) -> taffy::Overflow { } } +#[inline] +pub fn contain(input: stylo::Contain, display: stylo::Display) -> taffy::Contain { + // Layout and paint containment do not apply to non-atomic inline-level boxes + // (https://drafts.csswg.org/css-contain-1/#containment-layout) + if display.outside() == stylo::DisplayOutside::Inline + && display.inside() == stylo::DisplayInside::Flow + { + return taffy::Contain::NONE; + } + let mut result = taffy::Contain::NONE; + if input.contains(stylo::Contain::LAYOUT) { + result |= taffy::Contain::LAYOUT; + } + if input.contains(stylo::Contain::PAINT) { + result |= taffy::Contain::PAINT; + } + result +} + #[inline] pub fn direction(input: stylo::Direction) -> taffy::Direction { match input { @@ -712,6 +733,7 @@ pub fn to_taffy_style(style: &stylo::ComputedValues) -> taffy::Style { }, direction: self::direction(style.clone_direction()), scrollbar_width: 0.0, + contain: self::contain(style.clone_contain(), style.clone_display()), #[cfg(feature = "floats")] float: self::float(style.clone_float()), diff --git a/packages/stylo_taffy/src/wrapper.rs b/packages/stylo_taffy/src/wrapper.rs index 9461169ae..5f7c85482 100644 --- a/packages/stylo_taffy/src/wrapper.rs +++ b/packages/stylo_taffy/src/wrapper.rs @@ -68,6 +68,12 @@ impl> taffy::CoreStyle for TaffyStyloStyle 0.0 } + #[inline] + fn contain(&self) -> taffy::Contain { + let box_styles = self.0.get_box(); + convert::contain(box_styles.contain, box_styles.display) + } + #[inline] fn position(&self) -> taffy::Position { convert::position(self.0.get_box().position)