1#![deny(unsafe_code)]
6
7mod cell;
11mod context;
12mod display_list;
13mod dom;
14mod dom_traversal;
15mod flexbox;
16pub mod flow;
17mod formatting_contexts;
18mod fragment_tree;
19pub mod geom;
20mod layout_box_base;
21mod layout_impl;
22mod taffy;
23#[macro_use]
24mod construct_modern;
25mod lists;
26mod positioned;
27mod query;
28mod quotes;
29mod replaced;
30mod sizing;
31mod style_ext;
32pub mod table;
33mod traversal;
34
35use app_units::Au;
36pub use cell::ArcRefCell;
37pub(crate) use flow::BoxTree;
38pub(crate) use fragment_tree::FragmentTree;
39pub use layout_impl::LayoutFactoryImpl;
40use malloc_size_of_derive::MallocSizeOf;
41use servo_arc::Arc as ServoArc;
42use style::logical_geometry::WritingMode;
43use style::properties::ComputedValues;
44
45use crate::geom::LogicalVec2;
46use crate::sizing::SizeConstraint;
47use crate::style_ext::AspectRatio;
48
49pub(crate) type SharedStyle = ArcRefCell<ServoArc<ComputedValues>>;
58
59pub(crate) struct ConstraintSpace<'a> {
62 pub block_size: SizeConstraint,
63 pub style: &'a ComputedValues,
64 pub preferred_aspect_ratio: Option<AspectRatio>,
65}
66
67impl<'a> ConstraintSpace<'a> {
68 fn new(
69 block_size: SizeConstraint,
70 style: &'a ComputedValues,
71 preferred_aspect_ratio: Option<AspectRatio>,
72 ) -> Self {
73 Self {
74 block_size,
75 style,
76 preferred_aspect_ratio,
77 }
78 }
79}
80
81pub(crate) struct IndefiniteContainingBlock<'a> {
85 pub size: LogicalVec2<Option<Au>>,
86 pub style: &'a ComputedValues,
87}
88
89impl<'a> From<&ConstraintSpace<'a>> for IndefiniteContainingBlock<'a> {
90 fn from(constraint_space: &ConstraintSpace<'a>) -> Self {
91 Self {
92 size: LogicalVec2 {
93 inline: None,
94 block: constraint_space.block_size.to_definite(),
95 },
96 style: constraint_space.style,
97 }
98 }
99}
100
101impl<'a> From<&'_ ContainingBlock<'a>> for IndefiniteContainingBlock<'a> {
102 fn from(containing_block: &ContainingBlock<'a>) -> Self {
103 Self {
104 size: LogicalVec2 {
105 inline: Some(containing_block.size.inline),
106 block: containing_block.size.block.to_definite(),
107 },
108 style: containing_block.style,
109 }
110 }
111}
112
113impl<'a> From<&'_ DefiniteContainingBlock<'a>> for IndefiniteContainingBlock<'a> {
114 fn from(containing_block: &DefiniteContainingBlock<'a>) -> Self {
115 Self {
116 size: containing_block.size.map(|v| Some(*v)),
117 style: containing_block.style,
118 }
119 }
120}
121
122#[derive(Clone, Debug, MallocSizeOf)]
123pub(crate) struct ContainingBlockSize {
124 inline: Au,
125 block: SizeConstraint,
126}
127
128pub(crate) struct ContainingBlock<'a> {
129 size: ContainingBlockSize,
130 style: &'a ComputedValues,
131}
132
133struct DefiniteContainingBlock<'a> {
134 size: LogicalVec2<Au>,
135 style: &'a ComputedValues,
136}
137
138impl<'a> From<&'_ DefiniteContainingBlock<'a>> for ContainingBlock<'a> {
139 fn from(definite: &DefiniteContainingBlock<'a>) -> Self {
140 ContainingBlock {
141 size: ContainingBlockSize {
142 inline: definite.size.inline,
143 block: SizeConstraint::Definite(definite.size.block),
144 },
145 style: definite.style,
146 }
147 }
148}
149
150#[derive(Clone, Copy, Debug, MallocSizeOf)]
154struct PropagatedBoxTreeData {
155 allow_percentage_column_in_tables: bool,
156}
157
158impl Default for PropagatedBoxTreeData {
159 fn default() -> Self {
160 Self {
161 allow_percentage_column_in_tables: true,
162 }
163 }
164}
165
166impl PropagatedBoxTreeData {
167 fn disallowing_percentage_table_columns(&self) -> PropagatedBoxTreeData {
168 Self {
169 allow_percentage_column_in_tables: false,
170 }
171 }
172}