mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout: grid template getComputedStyle resolved value (#34885)
* Store taffy detailed info into fragment Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix info propagation and resolved grid track query Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix import Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix tracklist matching logic and type optimization Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Run fmt Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update wpt expectations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Optimizing info propagation and minor qol Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Run fmt Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
parent
040e29415b
commit
76fa456a9a
25 changed files with 297 additions and 778 deletions
|
@ -12,14 +12,16 @@ use style::Zero;
|
|||
use taffy::style_helpers::{TaffyMaxContent, TaffyMinContent};
|
||||
use taffy::{AvailableSpace, MaybeMath, RequestedAxis, RunMode};
|
||||
|
||||
use super::{TaffyContainer, TaffyItemBox, TaffyItemBoxInner, TaffyStyloStyle};
|
||||
use super::{
|
||||
DetailedTaffyGridInfo, TaffyContainer, TaffyItemBox, TaffyItemBoxInner, TaffyStyloStyle,
|
||||
};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::context::LayoutContext;
|
||||
use crate::formatting_contexts::{
|
||||
Baselines, IndependentFormattingContext, IndependentFormattingContextContents,
|
||||
IndependentLayout,
|
||||
};
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment};
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, DetailedLayoutInfo, Fragment};
|
||||
use crate::geom::{
|
||||
LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size,
|
||||
SizeConstraint, Sizes,
|
||||
|
@ -64,6 +66,10 @@ struct TaffyContainerContext<'a> {
|
|||
positioning_context: &'a mut PositioningContext,
|
||||
content_box_size_override: &'a ContainingBlock<'a>,
|
||||
style: &'a ComputedValues,
|
||||
detailed_layout_info: Option<DetailedLayoutInfo>,
|
||||
|
||||
/// Temporary location for children detailed info, which will be moved into child fragments
|
||||
child_detailed_layout_infos: Vec<Option<DetailedLayoutInfo>>,
|
||||
}
|
||||
|
||||
struct ChildIter(std::ops::Range<usize>);
|
||||
|
@ -264,6 +270,8 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
|
|||
};
|
||||
|
||||
child.child_fragments = layout.fragments;
|
||||
self.child_detailed_layout_infos[usize::from(node_id)] =
|
||||
layout.detailed_layout_info;
|
||||
|
||||
let block_size = layout.content_block_size.to_f32_px();
|
||||
|
||||
|
@ -314,6 +322,16 @@ impl taffy::LayoutGridContainer for TaffyContainerContext<'_> {
|
|||
let child = (*self.source_child_nodes[id]).borrow();
|
||||
TaffyStyloStyle(AtomicRef::map(child, |c| &*c.style))
|
||||
}
|
||||
|
||||
fn set_detailed_grid_info(
|
||||
&mut self,
|
||||
_node_id: taffy::NodeId,
|
||||
detailed_layout_info: taffy::DetailedGridInfo,
|
||||
) {
|
||||
self.detailed_layout_info = Some(DetailedLayoutInfo::Grid(Box::new(
|
||||
DetailedTaffyGridInfo::from_detailed_grid_layout(detailed_layout_info),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputeInlineContentSizes for TaffyContainer {
|
||||
|
@ -355,6 +373,8 @@ impl ComputeInlineContentSizes for TaffyContainer {
|
|||
content_box_size_override: containing_block,
|
||||
style,
|
||||
source_child_nodes: &self.children,
|
||||
detailed_layout_info: None,
|
||||
child_detailed_layout_infos: vec![None; self.children.len()],
|
||||
};
|
||||
|
||||
let (max_content_output, min_content_output) = match style.clone_display().inside() {
|
||||
|
@ -408,6 +428,8 @@ impl TaffyContainer {
|
|||
content_box_size_override,
|
||||
style: content_box_size_override.style,
|
||||
source_child_nodes: &self.children,
|
||||
detailed_layout_info: None,
|
||||
child_detailed_layout_infos: vec![None; self.children.len()],
|
||||
};
|
||||
|
||||
fn auto_or_to_option<T>(input: GenericLengthPercentageOrAuto<T>) -> Option<T> {
|
||||
|
@ -456,11 +478,13 @@ impl TaffyContainer {
|
|||
};
|
||||
|
||||
// Convert `taffy::Layout` into Servo `Fragment`s
|
||||
// with container_ctx.child_detailed_layout_infos will also moved to the corresponding `Fragment`s
|
||||
let fragments: Vec<Fragment> = self
|
||||
.children
|
||||
.iter()
|
||||
.map(|child| (**child).borrow_mut())
|
||||
.map(|mut child| {
|
||||
.enumerate()
|
||||
.map(|(child_id, mut child)| {
|
||||
fn rect_to_logical_sides<T>(rect: taffy::Rect<T>) -> LogicalSides<T> {
|
||||
LogicalSides {
|
||||
inline_start: rect.left,
|
||||
|
@ -522,6 +546,9 @@ impl TaffyContainer {
|
|||
.map(Au::from_f32_px),
|
||||
);
|
||||
|
||||
let child_detailed_layout_info: Option<DetailedLayoutInfo> =
|
||||
std::mem::take(&mut container_ctx.child_detailed_layout_infos[child_id]);
|
||||
|
||||
match &mut child.taffy_level_box {
|
||||
TaffyItemBoxInner::InFlowBox(independent_box) => {
|
||||
let fragment = Fragment::Box(
|
||||
|
@ -539,7 +566,8 @@ impl TaffyContainer {
|
|||
.with_baselines(Baselines {
|
||||
first: output.first_baselines.y.map(Au::from_f32_px),
|
||||
last: None,
|
||||
}),
|
||||
})
|
||||
.with_detailed_layout_info(child_detailed_layout_info),
|
||||
);
|
||||
|
||||
child
|
||||
|
@ -604,6 +632,8 @@ impl TaffyContainer {
|
|||
// "true" is a safe default as it will prevent Servo from performing optimizations based
|
||||
// on the assumption that the node's size does not depend on block constraints.
|
||||
depends_on_block_constraints: true,
|
||||
|
||||
detailed_layout_info: container_ctx.detailed_layout_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue