Handling footnote-display requires the footnote area children to be recreated
each time one footnote is added: as footnotes can be blocks or inlines, we have
to create anonymous boxes each time, and thus to do the whole footnote area
layout.
There’s nothing in the specification about that, but here’s what we do now:
- The style of a footnote inherits from its parent’s style, it doesn’t inherit
from the footnote area’s style. That’s how cascade works for real elements, and
there’s no real reason or way to avoid this.
- The style of a footnote marker inherits from the footnote style. The marker
is just like a ::before block regarding to its style, even if it is actually
put before the footnote element in the footnote body.
- The style of a footnote call inherits from the footnote parent’s style. It
doesn’t inherit from the footnote’s style, that’s actually applied to the
footnote and inherited by its marker.
This way, we keep the "normal" cascade for "normal" elements, and have
everything else being quite obvious.
The 1st point is annoying in real-life use cases, because we’d really like to
see the footnote’s style inherit from the footnote area’s style. But we really
don’t want to break the cascade. Do we? No, we don’t.
The 3rd point is probably the most disturbing one, mainly because
.footnote::footnote-call doesn’t match the call: to match a footnote call in a
paragraph, for example, we have to use p::footnote-call instead.
As the bottom of the page is now dynamic (because it changes with footnotes),
passing the max_position_y is difficult: it would require the value to be
passed to layout functions, and returned (possibly updated) by these functions.
The new solution is to store the page bottom in the context, and to update it
when a footnote is included. The new max position y is calculated when needed,
using the updated position of the page bottom.
To handle extra bottom spaces (bottom padding/border/margin of a parent box for
example), a bottom_space parameter is given when needed. This value can be set
to -inf when we don’t want to take care of the page bottom (that’s equivalent
to max_position_y=inf).