//! Every value the engine has for an element when it calls the box-generation generated //! function, under the one name and type each value has, and the fixed fields of the //! function's answer. //! //! The function's types file (`box_generation_types.rs`) is written by a model, and the //! engine fills its inputs struct without knowing in advance which values it holds: box //! tree construction (`boxtree.rs` `build_box`) builds a [`BoxGenerationEngineValues`] for //! the element, and `box_generation::inputs_from`, which `build.rs` writes from the types //! file in place, copies each field the inputs struct declares from the field of the same //! name here. So a types file's inputs struct may only take fields of //! [`BoxGenerationEngineValues`], under the same names and types, and its outputs struct //! has exactly the fields of [`BoxGenerationEngineAnswer`]. `job-check types --engine` //! checks both on the file alone (`jobs/src/types_file.rs` `check_names`). //! //! The list holds more than the function needs on purpose: choosing which values the //! specification's rules read is the types file's work. A value not listed here is not //! available at the call, because the engine does not compute it at that point. //! //! A value whose doc has a paragraph opening `Needed:` is one the specification's rules //! read whenever the specification text says one of the quoted phrases in it: a types //! file written from that text takes the value. `job-check types --engine //! --specification ` refuses a types file that does not while the text says the //! phrase (`jobs/src/types_file.rs` `check_needs`). use dom::computed::{Display, Float, Position}; /// Every value the engine has worked out for the element at the call, and nothing else. #[derive(Debug, Clone, Copy, PartialEq)] pub struct BoxGenerationEngineValues { /// The element's `display` as the stylesheets give it, before CSS 2.1 section 9.7 /// turns an `inline-block` that floats or is absolutely positioned into `block` /// (`dom::computed::display_before_blockification`). Keywords the engine has no /// variant for arrive as `Display::Other`. The root element's arrives already /// blockified by the style system: a root `inline-block` arrives as `Display::Block`. pub display: Display, /// The element's computed `position`. `sticky` arrives as `Position::Static`. pub position: Position, /// The element's computed `float`. The style system has already made it /// `Float::None` when `position` is `absolute` or `fixed`, as a browser's computed /// value is. pub float: Float, /// Whether the element is the document's root element (``). /// /// Needed: the specification text says "the root element" (CSS 2.1 9.7 has a rule /// of its own for the root). pub is_root: bool, /// The computed `display` of the element's parent element; `None` for the root /// element, which has none. pub parent_display: Option, } /// The fields of the function's answer, which the engine reads by these names: a types /// file's outputs struct declares exactly these. #[derive(Debug, Clone, Copy, PartialEq)] pub struct BoxGenerationEngineAnswer { /// The element's used `display`. `Display::None`: the element generates no box and /// nothing in its subtree does. `Display::Contents`: the element generates no box, /// and its children's boxes take its place among its parent's children. Anything /// else: the element generates one box, inline-level when the value is /// `Display::InlineBlock` and block-level otherwise. pub display: Display, /// The element's used `float`: `Float::Left` or `Float::Right` takes the box out of /// normal flow as a float on that side; `Float::None` leaves it where it is. pub float: Float, }