Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/blitz-dom/src/layout/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 23 additions & 1 deletion packages/stylo_taffy/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -712,6 +733,7 @@ pub fn to_taffy_style(style: &stylo::ComputedValues) -> taffy::Style<Atom> {
},
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()),
Expand Down
6 changes: 6 additions & 0 deletions packages/stylo_taffy/src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl<T: Deref<Target = ComputedValues>> taffy::CoreStyle for TaffyStyloStyle<T>
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)
Expand Down
Loading