pub enum PureHorzBox {
Show 17 variants
InnerString {
info: HorzStringInfo,
text: String,
width: Length,
height: Length,
depth: Length,
},
OuterEmpty {
natural: Length,
shrinkable: Length,
stretchable: Length,
},
OuterFil,
FixedEmpty {
width: Length,
},
Image {
width: Length,
height: Length,
image: ImageId,
},
Discretionary {
penalty: i32,
pre_break: Vec<PureHorzBox>,
post_break: Vec<PureHorzBox>,
no_break: Vec<PureHorzBox>,
},
Graphics {
width: Length,
height: Length,
depth: Length,
elems: Vec<GraphicsElem>,
origin_independent: bool,
},
GraphicsOuter {
height: Length,
depth: Length,
width: Length,
fn_id: GraphicsFnId,
},
Math {
width: Length,
height: Length,
depth: Length,
glyphs: Vec<MathGlyph>,
rules: Vec<GraphicsElem>,
},
HookPageBreak {
id: HookId,
},
Tabular(TabularBox),
EmbeddedBlock {
width: Length,
height: Length,
depth: Length,
block: Vec<VertBox>,
anchor_last: bool,
breakable: bool,
},
Frame {
width: Length,
height: Length,
depth: Length,
deco: DecoId,
contents: Vec<(Length, PureHorzBox)>,
},
FrameMarker {
id: DecoId,
end: bool,
},
InlineFrameMarker {
id: DecoId,
end: bool,
height: Length,
depth: Length,
},
Footnote {
block: Vec<VertBox>,
},
InlineMark(InlineMarkKind),
}Expand description
A milestone-1 subset of pure_horz_box from horzBox.ml, keeping its
vocabulary so the full port extends rather than replaces it.
The #[subast] list names every other box type reachable from a field
of this enum; self-recursion (Discretionary, Frame) is implicit. It is
what crate::visit’s generated traversal descends through, and it is
unchecked on stable Rust — see that module’s “The one trap” note and
the tests/visit_reachability.rs test standing in for the missing check.
Variants§
InnerString
Fixed text with pre-measured dimensions.
OuterEmpty
Interword glue.
OuterFil
Infinitely stretchable glue (inline-fil).
FixedEmpty
A fixed-width empty box with no stretch/shrink (inline-skip;
v0.0.6: PHSFixedEmpty). Unlike OuterEmpty this is never a legal
line-break point (see is_glue).
Image
A raster image placed at a fixed on-page size (use-image-by-width).
width/height are already-computed on-page dimensions (v0.0.6
ImageInfo.get_height_from_width). Like FixedEmpty, never a legal
line-break point (is_glue).
Discretionary
A break point that may or may not be taken (v0.0.6’s
LBDiscretionary(penalty, id, pre, post_nobreak, post_break),
ref:src/backend/lineBreakBox.ml:22-27). If the paragraph breaker
chooses to break here, pre_break renders at the end of the closed
line and post_break at the start of the next; otherwise no_break
renders in its place. UAX#14 only needs zero-width inter-chunk
break points with all three slots empty. Unlike OuterEmpty/OuterFil
this is not “glue” (see is_glue) — it is scored separately via
is_break_point/break_penalty.
Graphics
A box carrying resolved graphics elements (inline-graphics;
v0.0.6: PHGFixedGraphics), coordinates already relative to the
box’s baseline-left origin. Carries a real depth (graphics can extend
below the baseline), so both height and depth feed line metrics.
Never a legal line-break point (see is_glue).
Fields
elems: Vec<GraphicsElem>origin_independent: boolTrue when the callback ignored its placed-point argument, so its
elems are PAGE-ABSOLUTE (e.g. a slydifi frame background /
full-page decoration built with fun _ -> …). Such graphics must
be emitted with an IDENTITY cm — NOT translated by the box’s
placed position — otherwise the whole decoration shifts off the
page (the box is often placed at a negative text-origin). For an
ordinary position-relative callback this is false and the writer’s
per-box cm translate applies as usual.
GraphicsOuter
inline-graphics-outer (v0.0.6 PHGOuterFilGraphics,
vminst.ml:1891): a graphics box whose WIDTH stretches like
inline-fil (upstream widinfo {natural = 0; stretchable = Fils(1)},
lineBreak.ml:40-48). width starts at ZERO and is written by
justify_line with the box’s per-fil slack share; the box is then
replaced by a resolved Graphics in a lang-side post-pass that fires
fn_id’s callback with that width. NOT glue (upstream’s box is pure
content, never a break point), but counted as a fil by
measure/justify_line.
Math
A laid-out inline math run (${…}): one box carrying its own
pre-shifted sub-glyphs, each with a vertical offset relative to this
box’s baseline (MathGlyph::dy) — the line model has only a
horizontal dx per box and a single baseline_y per line, so a
superscript can’t be a separate box. width/height/depth are the
run’s outer metrics (computed by read_math), so the line breaker
never re-enters the math engine. Never a legal line-break point (see
is_glue) — a math run is laid out and flowed atomically.
rules: filled paths the run needs alongside its glyphs — the
fraction bar and radical sign/overbar are Fills, not glyphs, since
neither is drawable through a font’s Tj. Box-local, y-up
coordinates relative to this box’s own baseline-left origin, exactly
PureHorzBox::Graphics::elems’ convention. natural_width is
unaffected — a bar/radical-sign always sits within glyphs’
already-measured span. Empty for the read_math path and for every
atom layout_math_atom doesn’t specially handle.
HookPageBreak
A deferred page-break hook (hook-page-break; v0.0.6’s
PHGHookPageBreak). Zero-width, renders nothing.
Tabular(TabularBox)
A ruled grid box (tabular; v0.0.6’s PHGFixedTabular), carrying
each cell’s already-laid-out inline run (tabular::TabularCellBox)
plus the resolved rule graphics from the user’s callback. The PDF
writers recurse into it in emit_box, which is also where its three
coordinate frames are reconciled.
EmbeddedBlock
An inline box carrying a whole block (embed-block-top; upstream’s
PHGEmbeddedVert/HorzEmbeddedVertBreakable). block is already
broken into VertBox lines, which the writer stacks from the box’s
placed origin. ATOMIC — it does not split across a page boundary.
Fields
anchor_last: boolWhich of the block’s lines sits on the surrounding text baseline:
false = the FIRST line (embed-block-top, adjust_to_first_line),
true = the LAST line (embed-block-bottom, adjust_to_last_line).
Governs both this box’s height/depth split and where the writers
anchor the block’s inner lines (place_embedded_block).
breakable: boolBuilt by embed-block-BREAKABLE (upstream
HorzEmbeddedVertBreakable) rather than embed-block-top/-bottom
(HorzEmbeddedVert). The breakable one is not laid out as inline
content at all: the line breaker flushes the current line, splices
the block’s own vertical boxes straight into the vertical list
(AlreadyVert, lineBreak.ml:809-818), and starts a fresh line.
See break_into_lines.
Frame
An UNBREAKABLE inline frame (inline-frame-outer/-inner; upstream
PHGOuterFrame/PHGInnerFrame) — ATOMIC: contents are pre-fit at
their natural width (fit_cell) and the frame never splits across a
line break, matching upstream’s model. inline-frame-breakable is NOT
this variant — see PureHorzBox::InlineFrameMarker.
width/height/depth are the OUTER dims (padding included, baseline
unshifted — padding grows the box, upstream lineBreak.ml’s frame
metrics). contents carry x-offsets from the frame’s left edge (pad-L
already applied), all on the frame’s own baseline. deco is fired
lang-side after placement; the writers draw nothing for it here.
FrameMarker
A placed block-frame marker (VertBox::FrameStart/FrameEnd after
page breaking) — zero-width, renders nothing (writers’ wildcard arm),
read back by fire_hooks only.
InlineFrameMarker
One boundary of an inline BREAKABLE frame (inline-frame-breakable;
upstream HorzFrameBreakable) — the horizontal twin of
PureHorzBox::FrameMarker, and for the same reason.
Upstream keeps a breakable frame TRANSPARENT to the paragraph breaker:
LBFrameBreakable threads the enclosing width map straight through its
contents (lineBreak.ml:1094), so glue and discretionaries inside the
frame are ordinary DP nodes of the enclosing paragraph, and cut
(:824) re-frames the resulting fragments one line at a time
(append_framed_lines), firing decoS for an unbroken frame and
decoH/decoM/decoT per fragment for a broken one.
This port’s breaker is a flat index DP over one Vec<PureHorzBox>, so
the same transparency is spelled the other way round: the primitive
SPLICES the frame’s contents into the paragraph stream (padding-L and
-R as FixedEmpty, upstream’s append_horz_padding) and brackets them
with this zero-width marker pair, so the inner boxes simply are the
paragraph’s boxes. fire_hooks reassembles the fragments by walking
the markers.
height/depth are the WHOLE frame’s padded content extent
(content ± pad), carried on BOTH markers so that any line holding
either one reserves the frame’s full vertical extent. Upstream instead
sizes each fragment from its own contents; for an unbroken frame (every
bundled caller: \ref, \href, TOC entries — all zero-padding) the two
agree exactly, and for a broken one this over-reserves a fragment by the
difference between the frame’s tallest content and that fragment’s,
which is zero for uniform text.
Footnote
add-footnote’s marker (v0.0.6 PHGFootnote(imvblst),
horzBox.ml:283 → ImHorzFootnote, :306): a zero-width/height/
depth inline box carrying the footnote’s already-assembled block.
Rides the paragraph like HookPageBreak (writers skip it via their
wildcard arm); chop_page (pagebreak.rs) extracts it when the line
carrying it is COMMITTED to a page, reserves the block’s stacked
height at the page bottom, and bottom-places the block in the same
column (upstream pageBreak.ml:131-142 + handlePdf.ml:400-403).
The marker itself stays in the placed line’s contents (render-inert)
— extraction is a read-only scan, unlike upstream’s removing
embed_page_info (pageInfo.ml:47). Consequence: the block payload
appears both (inert) inside its referencing line and (rendered) as
bottom-placed lines — any future exhaustive consumer of a placed
line’s contents must treat this variant as inert or it will
double-count the body.
InlineMark(InlineMarkKind)
An INERT reflow marker for emphasis runs (\emph/\bold in the
repo-controlled stdlibs that opt in) and list-bullet fencing,
emitted by the inline-mark primitive. Zero width/height/depth and
renders nothing, so it contributes zero advance wherever it rides in a
placed line’s contents. Read only by the reflow HTML walker (the
html-support branch’s reflow/inline.rs), which uses
EmphStart/EmphEnd to wrap <em>/<strong> and
BulletStart/BulletEnd to suppress the drawn bullet/number glyph run
(the real marker comes from the <ul>/<ol> itself).
Implementations§
Source§impl PureHorzBox
impl PureHorzBox
pub fn natural_width(&self) -> Length
Sourcepub fn is_break_point(&self) -> bool
pub fn is_break_point(&self) -> bool
A legal paragraph-break candidate: glue (today’s only breakpoints) or a discretionary (UAX#14/hyphenation break points). CJK text has no glue at all, so discretionaries are its only break candidates.
EXCEPT a NO_BREAK_PENALTY discretionary, which is upstream’s
LBPure(glue) in disguise (see that constant): it renders its
no_break slot and offers no edge.
Source§impl PureHorzBox
impl PureHorzBox
Sourcepub fn visit<__T>(&self, visitor: impl IntoVisitor<__T>) -> &Self
pub fn visit<__T>(&self, visitor: impl IntoVisitor<__T>) -> &Self
Visit self with any Visit, returning self to chain.
Source§impl PureHorzBox
impl PureHorzBox
Sourcepub fn visit_mut<__T>(&mut self, visitor: impl IntoVisitorMut<__T>) -> &mut Self
pub fn visit_mut<__T>(&mut self, visitor: impl IntoVisitorMut<__T>) -> &mut Self
Visit self with any VisitMut, returning self to chain.
Trait Implementations§
impl Ast for PureHorzBox
Source§impl Clone for PureHorzBox
impl Clone for PureHorzBox
Source§fn clone(&self) -> PureHorzBox
fn clone(&self) -> PureHorzBox
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PureHorzBox
impl Debug for PureHorzBox
Source§impl<__F: FnMut(&PureHorzBox)> IntoHook<PureHorzBox> for __F
impl<__F: FnMut(&PureHorzBox)> IntoHook<PureHorzBox> for __F
Source§impl<__F: FnMut(&mut PureHorzBox)> IntoHookMut<PureHorzBox> for __F
impl<__F: FnMut(&mut PureHorzBox)> IntoHookMut<PureHorzBox> for __F
fn into_hook_mut(self) -> impl HookMut
Source§impl<__F: FnMut(&PureHorzBox)> IntoVisitor<PureHorzBox> for __F
impl<__F: FnMut(&PureHorzBox)> IntoVisitor<PureHorzBox> for __F
fn into_visitor(self) -> impl Visit
Source§impl<__F: FnMut(&mut PureHorzBox)> IntoVisitorMut<PureHorzBox> for __F
impl<__F: FnMut(&mut PureHorzBox)> IntoVisitorMut<PureHorzBox> for __F
fn into_visitor_mut(self) -> impl VisitMut
Source§impl PartialEq for PureHorzBox
impl PartialEq for PureHorzBox
Source§impl Repeater<0> for PureHorzBox
impl Repeater<0> for PureHorzBox
Source§impl Repeater<1> for PureHorzBox
impl Repeater<1> for PureHorzBox
Source§impl Repeater<2> for PureHorzBox
impl Repeater<2> for PureHorzBox
Source§type Type = Vec<GraphicsElem>
type Type = Vec<GraphicsElem>
<T as Repeater<INDEX>>::Type.Source§impl Repeater<3> for PureHorzBox
impl Repeater<3> for PureHorzBox
Source§impl Repeater<4> for PureHorzBox
impl Repeater<4> for PureHorzBox
Source§impl Repeater<5> for PureHorzBox
impl Repeater<5> for PureHorzBox
Source§type Type = InlineMarkKind
type Type = InlineMarkKind
<T as Repeater<INDEX>>::Type.Source§impl Repeater<6> for PureHorzBox
impl Repeater<6> for PureHorzBox
Source§impl Repeater<7> for PureHorzBox
impl Repeater<7> for PureHorzBox
Source§impl Repeater<8> for PureHorzBox
impl Repeater<8> for PureHorzBox
Source§type Type = HorzStringInfo
type Type = HorzStringInfo
<T as Repeater<INDEX>>::Type.Source§impl Repeater<9> for PureHorzBox
impl Repeater<9> for PureHorzBox
Source§impl Repeater<10> for PureHorzBox
impl Repeater<10> for PureHorzBox
Source§impl Repeater<11> for PureHorzBox
impl Repeater<11> for PureHorzBox
Source§impl Repeater<12> for PureHorzBox
impl Repeater<12> for PureHorzBox
Source§impl Repeater<13> for PureHorzBox
impl Repeater<13> for PureHorzBox
Source§type Type = TabularBox
type Type = TabularBox
<T as Repeater<INDEX>>::Type.Source§impl Repeater<14> for PureHorzBox
impl Repeater<14> for PureHorzBox
Source§type Type = GraphicsFnId
type Type = GraphicsFnId
<T as Repeater<INDEX>>::Type.Source§impl Repeater<15> for PureHorzBox
impl Repeater<15> for PureHorzBox
Source§type Type = Vec<PureHorzBox>
type Type = Vec<PureHorzBox>
<T as Repeater<INDEX>>::Type.