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 byTAG_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§
- Calc
Length Percentage - The representation of a calc() function with mixed lengths and percentages.
- Calc
Length Percentage Resolution - Result of resolving
CalcLengthPercentage
- Length
Percentage - A
<length-percentage>
value. This can be either a<length>
, a<percentage>
, or a combination of both viacalc()
.
Enums§
- Allow
Anchor PosResolution InCalc Percentage - What anchor positioning functions are allowed to resolve in calc percentage values.
- Calc
Length Percentage Leaf - The leaves of a
<length-percentage>
calc expression. - Serializable 🔒
- An unpacked
<length-percentage>
that owns thecalc()
variant, for serialization purposes. - Tag 🔒
- Unpacked
- An unpacked
<length-percentage>
that borrows thecalc()
variant. - Unpacked
Mut 🔒 - An unpacked
<length-percentage>
that mutably borrows thecalc()
variant.
Functions§
- static_
assert 🔒 ⚠
Type Aliases§
- Calc
Anchor Side - Type for anchor side in
calc()
and other math fucntions. - Calc
Node - The computed version of a calc() node for
<length-percentage>
values. - NonNegative
Length Percentage - A wrapper of LengthPercentage, whose value must be >= 0.