Function layout_2020::flow::inline::inline_container_needs_strut

source ·
fn inline_container_needs_strut(
    style: &ComputedValues,
    layout_context: &LayoutContext<'_>,
    pbm: Option<&PaddingBorderMargin>,
) -> bool
Expand description

Whether or not a strut should be created for an inline container. Normally all inline containers get struts. In quirks mode this isn’t always the case though.

From https://quirks.spec.whatwg.org/#the-line-height-calculation-quirk

§§ 3.3. The line height calculation quirk

In quirks mode and limited-quirks mode, an inline box that matches the following conditions, must, for the purpose of line height calculation, act as if the box had a line-height of zero.

  • The border-top-width, border-bottom-width, padding-top and padding-bottom properties have a used value of zero and the box has a vertical writing mode, or the border-right-width, border-left-width, padding-right and padding-left properties have a used value of zero and the box has a horizontal writing mode.
  • It either contains no text or it contains only collapsed whitespace.

§§ 3.4. The blocks ignore line-height quirk

In quirks mode and limited-quirks mode, for a block container element whose content is composed of inline-level elements, the element’s line-height must be ignored for the purpose of calculating the minimal height of line boxes within the element.

Since we incorporate the size of the strut into the line-height calculation when adding text, we can simply not incorporate the strut at the start of inline box processing. This also works the same for the root of the IFC.