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 {
62 pub block_size: SizeConstraint,
63 pub writing_mode: WritingMode,
64 pub preferred_aspect_ratio: Option<AspectRatio>,
65}
66
67impl ConstraintSpace {
68 fn new(
69 block_size: SizeConstraint,
70 writing_mode: WritingMode,
71 preferred_aspect_ratio: Option<AspectRatio>,
72 ) -> Self {
73 Self {
74 block_size,
75 writing_mode,
76 preferred_aspect_ratio,
77 }
78 }
79
80 fn new_for_style_and_ratio(
81 style: &ComputedValues,
82 preferred_aspect_ratio: Option<AspectRatio>,
83 ) -> Self {
84 Self::new(
85 SizeConstraint::default(),
86 style.writing_mode,
87 preferred_aspect_ratio,
88 )
89 }
90}
91
92pub(crate) struct IndefiniteContainingBlock {
96 pub size: LogicalVec2<Option<Au>>,
97 pub writing_mode: WritingMode,
98}
99
100impl From<&ConstraintSpace> for IndefiniteContainingBlock {
101 fn from(constraint_space: &ConstraintSpace) -> Self {
102 Self {
103 size: LogicalVec2 {
104 inline: None,
105 block: constraint_space.block_size.to_definite(),
106 },
107 writing_mode: constraint_space.writing_mode,
108 }
109 }
110}
111
112impl<'a> From<&'_ ContainingBlock<'a>> for IndefiniteContainingBlock {
113 fn from(containing_block: &ContainingBlock<'a>) -> Self {
114 Self {
115 size: LogicalVec2 {
116 inline: Some(containing_block.size.inline),
117 block: containing_block.size.block.to_definite(),
118 },
119 writing_mode: containing_block.style.writing_mode,
120 }
121 }
122}
123
124impl<'a> From<&'_ DefiniteContainingBlock<'a>> for IndefiniteContainingBlock {
125 fn from(containing_block: &DefiniteContainingBlock<'a>) -> Self {
126 Self {
127 size: containing_block.size.map(|v| Some(*v)),
128 writing_mode: containing_block.style.writing_mode,
129 }
130 }
131}
132
133#[derive(Clone, Debug, MallocSizeOf)]
134pub(crate) struct ContainingBlockSize {
135 inline: Au,
136 block: SizeConstraint,
137}
138
139pub(crate) struct ContainingBlock<'a> {
140 size: ContainingBlockSize,
141 style: &'a ComputedValues,
142}
143
144struct DefiniteContainingBlock<'a> {
145 size: LogicalVec2<Au>,
146 style: &'a ComputedValues,
147}
148
149impl<'a> From<&'_ DefiniteContainingBlock<'a>> for ContainingBlock<'a> {
150 fn from(definite: &DefiniteContainingBlock<'a>) -> Self {
151 ContainingBlock {
152 size: ContainingBlockSize {
153 inline: definite.size.inline,
154 block: SizeConstraint::Definite(definite.size.block),
155 },
156 style: definite.style,
157 }
158 }
159}
160
161#[derive(Clone, Copy, Debug)]
165struct PropagatedBoxTreeData {
166 allow_percentage_column_in_tables: bool,
167}
168
169impl Default for PropagatedBoxTreeData {
170 fn default() -> Self {
171 Self {
172 allow_percentage_column_in_tables: true,
173 }
174 }
175}
176
177impl PropagatedBoxTreeData {
178 fn disallowing_percentage_table_columns(&self) -> PropagatedBoxTreeData {
179 Self {
180 allow_percentage_column_in_tables: false,
181 }
182 }
183}