//! Every value the engine has for a box when it calls the `width` 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 (`width_types.rs`) is written by a model, and the engine fills //! its inputs struct without knowing in advance which values it holds: the call sites //! (`fragment.rs` `layout_box_styled`, which calls once for the width and again for a box //! whose `aspect-ratio` gave it another width) build a [`WidthEngineValues`], and //! `width::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 [`WidthEngineValues`], under the same names and //! types, and its outputs struct has exactly the fields of [`WidthEngineAnswer`]. `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::LengthPercentageOrAuto; use crate::width::Direction; /// Every value the engine has worked out for the box at the call, and nothing else. #[derive(Debug, Clone, Copy, PartialEq)] pub struct WidthEngineValues { /// The width, in px, of the containing block's content box: the space the box's margins, /// borders, padding and content share. /// /// Needed: the specification text says "containing block". pub containing_block_width: f64, /// The computed `width`, in px when a `Length`. A percentage `width` has already been /// resolved against the containing block's width; an intrinsic-sizing keyword /// (`min-content`, `max-content`, `fit-content`) has been resolved to a `Length` from /// the box's own content. `Length` measures the box `box-sizing` names (the border box /// when `border_box_sizing` holds, the content box otherwise); `Auto` is the keyword; /// `Percentage` is a percentage the engine could not resolve; `Unresolved` is a `calc()` /// mixing a length and a percentage. /// /// Needed: the specification text says "'width'". pub width: LengthPercentageOrAuto, /// The computed `margin-left`: a `Length` in px, a `Percentage` of the containing block's /// width as a fraction, `Auto`, or `Unresolved` for a `calc()` mixing a length and a /// percentage. /// /// Needed: the specification text says "'margin-left'". pub margin_left: LengthPercentageOrAuto, /// The computed `margin-right`, in px when a `Length` and otherwise in the forms /// `margin_left` has. /// /// Needed: the specification text says "'margin-right'". pub margin_right: LengthPercentageOrAuto, /// The used `padding-left`, in px. /// /// Needed: the specification text says "'padding-left'". pub padding_left: f64, /// The used `padding-right`, in px. /// /// Needed: the specification text says "'padding-right'". pub padding_right: f64, /// The used `border-left-width`, in px. /// /// Needed: the specification text says "'border-left-width'". pub border_left: f64, /// The used `border-right-width`, in px. /// /// Needed: the specification text says "'border-right-width'". pub border_right: f64, /// Whether the computed `box-sizing` is `border-box` rather than `content-box`. pub border_box_sizing: bool, /// The containing block's `direction`, which decides which margin an over-constrained /// box gives up. /// /// Needed: the specification text says "'direction'". pub direction: Direction, /// The computed `min-width` in px, as the style gives it (the engine does not convert it /// for `box-sizing`); an intrinsic-sizing keyword has been resolved to a length the way /// `width`'s is. `None` when it is not a definite length (`auto`, or a percentage). pub min_width: Option, /// The computed `max-width` in px, in the form `min_width` has; `None` for `none` or for a /// percentage. pub max_width: Option, /// Whether the computed `width` is the keyword `stretch` (or its `-webkit-fill-available` /// alias). The engine reports `width` as `Auto` for it, so this tells the two apart. /// /// Needed: the specification text says "stretch". pub width_is_stretch: bool, /// Whether the computed `min-width` is the keyword `stretch`; `min_width` is `None` then. /// /// Needed: the specification text says "stretch". pub min_width_is_stretch: bool, /// Whether the computed `max-width` is the keyword `stretch`; `max_width` is `None` then. /// /// Needed: the specification text says "stretch". pub max_width_is_stretch: bool, } /// 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 WidthEngineAnswer { /// The box's used content-box width, in px, whatever its `box-sizing`. The engine puts /// it on the 1/64 px grid itself. pub used_width: f64, /// The used `margin-left`, in px. The engine places the box's border box this far from /// the containing block's left content edge. pub used_margin_left: f64, /// The used `margin-right`, in px. The engine does not read it. pub used_margin_right: f64, }