Module length_percentage

Source
Expand description

<length-percentage> computed values, and related ones.

The over-all design is a tagged pointer, with the lower bits of the pointer being non-zero if it is a non-calc value.

It is expected to take 64 bits both in x86 and x86-64. This is implemented as a union, with 4 different variants:

  • The length and percentage variants have a { tag, f32 } (effectively) layout. The tag has to overlap with the lower 2 bits of the calc variant.

  • The calc() variant is a { tag, pointer } in x86 (so same as the others), or just a { pointer } in x86-64 (so that the two bits of the tag can be obtained from the lower bits of the pointer).

  • There’s a tag variant just to make clear when only the tag is intended to be read. Note that the tag needs to be masked always by TAG_MASK, to deal with the pointer variant in x86-64.

The assertions in the constructor methods ensure that the tag getter matches our expectations.

Structs§

CalcLengthPercentage
The representation of a calc() function with mixed lengths and percentages.
CalcLengthPercentageResolution
Result of resolving CalcLengthPercentage
LengthPercentage
A <length-percentage> value. This can be either a <length>, a <percentage>, or a combination of both via calc().

Enums§

AllowAnchorPosResolutionInCalcPercentage
What anchor positioning functions are allowed to resolve in calc percentage values.
CalcLengthPercentageLeaf
The leaves of a <length-percentage> calc expression.
Serializable 🔒
An unpacked <length-percentage> that owns the calc() variant, for serialization purposes.
Tag 🔒
Unpacked
An unpacked <length-percentage> that borrows the calc() variant.
UnpackedMut 🔒
An unpacked <length-percentage> that mutably borrows the calc() variant.

Functions§

static_assert 🔒

Type Aliases§

CalcAnchorSide
Type for anchor side in calc() and other math fucntions.
CalcNode
The computed version of a calc() node for <length-percentage> values.
NonNegativeLengthPercentage
A wrapper of LengthPercentage, whose value must be >= 0.