mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
layout: grid-template getComputedStyle cleanup (#34926)
* Update Taffy and WPT expectations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Rename DetailedInfo to SpecificInfo 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
c94d909a86
commit
bbb255d81c
12 changed files with 41 additions and 167 deletions
|
@ -15,7 +15,7 @@ use crate::dom_traversal::{Contents, NodeAndStyleInfo};
|
|||
use crate::flexbox::FlexContainer;
|
||||
use crate::flow::BlockFormattingContext;
|
||||
use crate::fragment_tree::{
|
||||
BaseFragmentInfo, BoxFragment, DetailedLayoutInfo, Fragment, FragmentFlags,
|
||||
BaseFragmentInfo, BoxFragment, Fragment, FragmentFlags, SpecificLayoutInfo,
|
||||
};
|
||||
use crate::geom::LogicalSides;
|
||||
use crate::layout_box_base::LayoutBoxBase;
|
||||
|
@ -88,7 +88,7 @@ pub(crate) struct IndependentLayout {
|
|||
pub depends_on_block_constraints: bool,
|
||||
|
||||
/// Additional information of this layout that could be used by Javascripts and devtools.
|
||||
pub detailed_layout_info: Option<DetailedLayoutInfo>,
|
||||
pub detailed_layout_info: Option<SpecificLayoutInfo>,
|
||||
}
|
||||
|
||||
pub(crate) struct IndependentLayoutResult {
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::geom::{
|
|||
AuOrAuto, LengthPercentageOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, ToLogical,
|
||||
};
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
use crate::taffy::DetailedTaffyGridInfo;
|
||||
use crate::taffy::SpecificTaffyGridInfo;
|
||||
|
||||
/// Describes how a [`BoxFragment`] paints its background.
|
||||
pub(crate) enum BackgroundMode {
|
||||
|
@ -41,8 +41,8 @@ pub(crate) struct ExtraBackground {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) enum DetailedLayoutInfo {
|
||||
Grid(Box<DetailedTaffyGridInfo>),
|
||||
pub(crate) enum SpecificLayoutInfo {
|
||||
Grid(Box<SpecificTaffyGridInfo>),
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -89,7 +89,7 @@ pub(crate) struct BoxFragment {
|
|||
|
||||
/// Additional information of from layout that could be used by Javascripts and devtools.
|
||||
#[serde(skip_serializing)]
|
||||
pub detailed_layout_info: Option<DetailedLayoutInfo>,
|
||||
pub detailed_layout_info: Option<SpecificLayoutInfo>,
|
||||
}
|
||||
|
||||
impl BoxFragment {
|
||||
|
@ -177,7 +177,7 @@ impl BoxFragment {
|
|||
self.background_mode = BackgroundMode::None;
|
||||
}
|
||||
|
||||
pub fn with_detailed_layout_info(mut self, info: Option<DetailedLayoutInfo>) -> Self {
|
||||
pub fn with_detailed_layout_info(mut self, info: Option<SpecificLayoutInfo>) -> Self {
|
||||
self.detailed_layout_info = info;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ use crate::formatting_contexts::{
|
|||
IndependentFormattingContext, IndependentFormattingContextContents,
|
||||
};
|
||||
use crate::fragment_tree::{
|
||||
BoxFragment, CollapsedBlockMargins, DetailedLayoutInfo, Fragment, FragmentFlags,
|
||||
HoistedSharedFragment,
|
||||
BoxFragment, CollapsedBlockMargins, Fragment, FragmentFlags, HoistedSharedFragment,
|
||||
SpecificLayoutInfo,
|
||||
};
|
||||
use crate::geom::{
|
||||
AuOrAuto, LengthPercentageOrAuto, LogicalRect, LogicalSides, LogicalVec2, PhysicalPoint,
|
||||
|
@ -562,7 +562,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
let mut new_fragment = {
|
||||
let content_size: LogicalVec2<Au>;
|
||||
let fragments;
|
||||
let mut detailed_layout_info: Option<DetailedLayoutInfo> = None;
|
||||
let mut detailed_layout_info: Option<SpecificLayoutInfo> = None;
|
||||
match &context.contents {
|
||||
IndependentFormattingContextContents::Replaced(replaced) => {
|
||||
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-width
|
||||
|
|
|
@ -40,10 +40,10 @@ use style_traits::{ParsingMode, ToCss};
|
|||
|
||||
use crate::flow::inline::construct::{TextTransformation, WhitespaceCollapse};
|
||||
use crate::fragment_tree::{
|
||||
BoxFragment, DetailedLayoutInfo, Fragment, FragmentFlags, FragmentTree, Tag,
|
||||
BoxFragment, Fragment, FragmentFlags, FragmentTree, SpecificLayoutInfo, Tag,
|
||||
};
|
||||
use crate::geom::{PhysicalRect, PhysicalVec};
|
||||
use crate::taffy::DetailedTaffyGridInfo;
|
||||
use crate::taffy::SpecificTaffyGridInfo;
|
||||
|
||||
pub fn process_content_box_request(
|
||||
requested_node: OpaqueNode,
|
||||
|
@ -234,7 +234,7 @@ pub fn process_resolved_style_request<'dom>(
|
|||
//
|
||||
// > When an element generates a grid container box...
|
||||
if display.inside() == DisplayInside::Grid {
|
||||
if let Some(DetailedLayoutInfo::Grid(info)) = detailed_layout_info {
|
||||
if let Some(SpecificLayoutInfo::Grid(info)) = detailed_layout_info {
|
||||
if let Some(value) = resolve_grid_template(info, style, longhand_id) {
|
||||
return Some(value);
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ fn resolved_size_should_be_used_value(fragment: &Fragment) -> bool {
|
|||
}
|
||||
|
||||
fn resolve_grid_template(
|
||||
grid_info: &DetailedTaffyGridInfo,
|
||||
grid_info: &SpecificTaffyGridInfo,
|
||||
style: &ComputedValues,
|
||||
longhand_id: LonghandId,
|
||||
) -> Option<String> {
|
||||
|
|
|
@ -13,7 +13,7 @@ use taffy::style_helpers::{TaffyMaxContent, TaffyMinContent};
|
|||
use taffy::{AvailableSpace, MaybeMath, RequestedAxis, RunMode};
|
||||
|
||||
use super::{
|
||||
DetailedTaffyGridInfo, TaffyContainer, TaffyItemBox, TaffyItemBoxInner, TaffyStyloStyle,
|
||||
SpecificTaffyGridInfo, TaffyContainer, TaffyItemBox, TaffyItemBoxInner, TaffyStyloStyle,
|
||||
};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::context::LayoutContext;
|
||||
|
@ -21,7 +21,7 @@ use crate::formatting_contexts::{
|
|||
Baselines, IndependentFormattingContext, IndependentFormattingContextContents,
|
||||
IndependentLayout,
|
||||
};
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, DetailedLayoutInfo, Fragment};
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment, SpecificLayoutInfo};
|
||||
use crate::geom::{
|
||||
LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size,
|
||||
SizeConstraint, Sizes,
|
||||
|
@ -66,10 +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>,
|
||||
detailed_layout_info: Option<SpecificLayoutInfo>,
|
||||
|
||||
/// Temporary location for children detailed info, which will be moved into child fragments
|
||||
child_detailed_layout_infos: Vec<Option<DetailedLayoutInfo>>,
|
||||
child_detailed_layout_infos: Vec<Option<SpecificLayoutInfo>>,
|
||||
}
|
||||
|
||||
struct ChildIter(std::ops::Range<usize>);
|
||||
|
@ -328,8 +328,8 @@ impl taffy::LayoutGridContainer for TaffyContainerContext<'_> {
|
|||
_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),
|
||||
self.detailed_layout_info = Some(SpecificLayoutInfo::Grid(Box::new(
|
||||
SpecificTaffyGridInfo::from_detailed_grid_layout(detailed_layout_info),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ impl TaffyContainer {
|
|||
.map(Au::from_f32_px),
|
||||
);
|
||||
|
||||
let child_detailed_layout_info: Option<DetailedLayoutInfo> =
|
||||
let child_detailed_layout_info: Option<SpecificLayoutInfo> =
|
||||
std::mem::take(&mut container_ctx.child_detailed_layout_infos[child_id]);
|
||||
|
||||
match &mut child.taffy_level_box {
|
||||
|
|
|
@ -121,15 +121,15 @@ impl TaffyItemBox {
|
|||
|
||||
/// Details from Taffy grid layout that will be stored
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct DetailedTaffyGridInfo {
|
||||
pub rows: DetailedTaffyGridTrackInfo,
|
||||
pub columns: DetailedTaffyGridTrackInfo,
|
||||
pub(crate) struct SpecificTaffyGridInfo {
|
||||
pub rows: SpecificTaffyGridTrackInfo,
|
||||
pub columns: SpecificTaffyGridTrackInfo,
|
||||
}
|
||||
|
||||
impl DetailedTaffyGridInfo {
|
||||
impl SpecificTaffyGridInfo {
|
||||
fn from_detailed_grid_layout(grid_info: taffy::DetailedGridInfo) -> Self {
|
||||
Self {
|
||||
rows: DetailedTaffyGridTrackInfo {
|
||||
rows: SpecificTaffyGridTrackInfo {
|
||||
sizes: grid_info
|
||||
.rows
|
||||
.sizes
|
||||
|
@ -137,7 +137,7 @@ impl DetailedTaffyGridInfo {
|
|||
.map(|size| Au::from_f32_px(*size))
|
||||
.collect(),
|
||||
},
|
||||
columns: DetailedTaffyGridTrackInfo {
|
||||
columns: SpecificTaffyGridTrackInfo {
|
||||
sizes: grid_info
|
||||
.columns
|
||||
.sizes
|
||||
|
@ -150,6 +150,6 @@ impl DetailedTaffyGridInfo {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct DetailedTaffyGridTrackInfo {
|
||||
pub(crate) struct SpecificTaffyGridTrackInfo {
|
||||
pub sizes: Box<[Au]>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue