Layout function should return an indication that it was unable to layout an element
We can use the layout
function to know if the content has sufficient break points to prevent content from overflowing the fragmentainer.
In other words, if the layout
returns an "error" because content is overflowing then we can use this information to drop rules (for instance, break-after: avoid
, break-before: avoid
or break-inside:avoid
) in order to find additional breakpoints.
Currently, the function returns undefined
or a BreakToken
. The chunker is also using a breakToken
mutable variable that can equal to any one of these values:
false
BreakToken(undefined, undefined)
BreakToken(node, undefined)
BreakToken(node, offset)
undefined
When layout
returns undefined
it's unclear if was because the function couldn't layout an element.
We could probably return a LayoutResult
object that might contain a BreakToken
and/or an error (or a list of elements overflowing from the fragmentainer).
We could also throw an exception, catch it and decide if we want to proceed or if we want to abort.
@fchasen Thoughts?