Skip to main content

layout/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5#![deny(unsafe_code)]
6
7//! Layout. Performs layout on the DOM, builds display lists and sends them to be
8//! painted.
9
10mod accessibility;
11mod cell;
12mod containing_block;
13mod context;
14mod display_list;
15mod dom;
16mod dom_traversal;
17mod flexbox;
18pub mod flow;
19mod formatting_contexts;
20mod fragment_tree;
21pub mod geom;
22mod layout_box_base;
23mod layout_impl;
24mod taffy;
25#[macro_use]
26mod construct_modern;
27mod layout_root;
28mod lists;
29mod positioned;
30mod query;
31mod quotes;
32mod replaced;
33mod selection;
34mod sizing;
35mod style_ext;
36pub mod table;
37mod traversal;
38
39pub use cell::ArcRefCell;
40pub(crate) use flow::BoxTree;
41pub(crate) use fragment_tree::FragmentTree;
42pub use layout_impl::LayoutFactoryImpl;
43use malloc_size_of_derive::MallocSizeOf;
44use servo_arc::Arc as ServoArc;
45use style::properties::ComputedValues;
46
47/// At times, a style is "owned" by more than one layout object. For example, text
48/// fragments need a handle on their parent inline box's style. In order to make
49/// incremental layout easier to implement, another layer of shared ownership is added via
50/// [`SharedStyle`]. This allows updating the style in originating layout object and
51/// having all "depdendent" objects update automatically.
52///
53///  Note that this is not a cost-free data structure, so should only be
54/// used when necessary.
55pub(crate) type SharedStyle = ArcRefCell<ServoArc<ComputedValues>>;
56
57/// Data that is propagated from ancestors to descendants during [`crate::flow::BoxTree`]
58/// construction.  This allows data to flow in the reverse direction of the typical layout
59/// propoagation, but only during `BoxTree` construction.
60#[derive(Clone, Copy, Debug, MallocSizeOf)]
61struct PropagatedBoxTreeData {
62    allow_percentage_column_in_tables: bool,
63}
64
65impl Default for PropagatedBoxTreeData {
66    fn default() -> Self {
67        Self {
68            allow_percentage_column_in_tables: true,
69        }
70    }
71}
72
73impl PropagatedBoxTreeData {
74    fn disallowing_percentage_table_columns(&self) -> PropagatedBoxTreeData {
75        Self {
76            allow_percentage_column_in_tables: false,
77        }
78    }
79}