aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/taffy
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/taffy')
-rw-r--r--components/layout/taffy/layout.rs15
-rw-r--r--components/layout/taffy/mod.rs24
2 files changed, 34 insertions, 5 deletions
diff --git a/components/layout/taffy/layout.rs b/components/layout/taffy/layout.rs
index a5838c1bd65..61c4a0508e9 100644
--- a/components/layout/taffy/layout.rs
+++ b/components/layout/taffy/layout.rs
@@ -23,8 +23,8 @@ use crate::fragment_tree::{
BoxFragment, CollapsedBlockMargins, Fragment, FragmentFlags, SpecificLayoutInfo,
};
use crate::geom::{
- LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size, SizeConstraint,
- Sizes,
+ LazySize, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size,
+ SizeConstraint, Sizes,
};
use crate::layout_box_base::CacheableLayoutResult;
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength};
@@ -251,6 +251,12 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
style,
};
+ let lazy_block_size = match content_box_known_dimensions.height {
+ // FIXME: use the correct min/max sizes.
+ None => LazySize::intrinsic(),
+ Some(height) => Au::from_f32_px(height).into(),
+ };
+
child.positioning_context = PositioningContext::default();
let layout = non_replaced.layout_without_caching(
self.layout_context,
@@ -258,13 +264,16 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
&content_box_size_override,
containing_block,
false, /* depends_on_block_constraints */
+ &lazy_block_size,
);
child.child_fragments = layout.fragments;
self.child_specific_layout_infos[usize::from(node_id)] =
layout.specific_layout_info;
- let block_size = layout.content_block_size.to_f32_px();
+ let block_size = lazy_block_size
+ .resolve(|| layout.content_block_size)
+ .to_f32_px();
let computed_size = taffy::Size {
width: inline_size + pb_sum.inline,
diff --git a/components/layout/taffy/mod.rs b/components/layout/taffy/mod.rs
index 50873fc3e66..ba80824fa99 100644
--- a/components/layout/taffy/mod.rs
+++ b/components/layout/taffy/mod.rs
@@ -8,6 +8,7 @@ use std::fmt;
use app_units::Au;
use malloc_size_of_derive::MallocSizeOf;
use servo_arc::Arc;
+use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use stylo_taffy::TaffyStyloStyle;
@@ -24,7 +25,6 @@ use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
#[derive(Debug, MallocSizeOf)]
pub(crate) struct TaffyContainer {
children: Vec<ArcRefCell<TaffyItemBox>>,
- #[conditional_malloc_size_of]
style: Arc<ComputedValues>,
}
@@ -69,6 +69,10 @@ impl TaffyContainer {
style: info.style.clone(),
}
}
+
+ pub(crate) fn repair_style(&mut self, new_style: &Arc<ComputedValues>) {
+ self.style = new_style.clone();
+ }
}
#[derive(MallocSizeOf)]
@@ -76,7 +80,6 @@ pub(crate) struct TaffyItemBox {
pub(crate) taffy_layout: taffy::Layout,
pub(crate) child_fragments: Vec<Fragment>,
pub(crate) positioning_context: PositioningContext,
- #[conditional_malloc_size_of]
pub(crate) style: Arc<ComputedValues>,
pub(crate) taffy_level_box: TaffyItemBoxInner,
}
@@ -145,6 +148,23 @@ impl TaffyItemBox {
},
}
}
+
+ pub(crate) fn repair_style(
+ &mut self,
+ context: &SharedStyleContext,
+ new_style: &Arc<ComputedValues>,
+ ) {
+ self.style = new_style.clone();
+ match &mut self.taffy_level_box {
+ TaffyItemBoxInner::InFlowBox(independent_formatting_context) => {
+ independent_formatting_context.repair_style(context, new_style)
+ },
+ TaffyItemBoxInner::OutOfFlowAbsolutelyPositionedBox(positioned_box) => positioned_box
+ .borrow_mut()
+ .context
+ .repair_style(context, new_style),
+ }
+ }
}
/// Details from Taffy grid layout that will be stored