Skip to main content

PureHorzBox

Enum PureHorzBox 

Source
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.

Fields

§text: String
§width: Length
§height: Length
§depth: Length
§

OuterEmpty

Interword glue.

Fields

§natural: Length
§shrinkable: Length
§stretchable: Length
§

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).

Fields

§width: Length
§

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).

Fields

§width: Length
§height: Length
§image: ImageId
§

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.

Fields

§penalty: i32
§pre_break: Vec<PureHorzBox>
§post_break: Vec<PureHorzBox>
§no_break: Vec<PureHorzBox>
§

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

§width: Length
§height: Length
§depth: Length
§origin_independent: bool

True 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.

Fields

§height: Length
§depth: Length
§width: Length
§

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.

Fields

§width: Length
§height: Length
§depth: Length
§glyphs: Vec<MathGlyph>
§

HookPageBreak

A deferred page-break hook (hook-page-break; v0.0.6’s PHGHookPageBreak). Zero-width, renders nothing.

Fields

§

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

§width: Length
§height: Length
§depth: Length
§block: Vec<VertBox>
§anchor_last: bool

Which 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: bool

Built 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.

Fields

§width: Length
§height: Length
§depth: Length
§deco: DecoId
§contents: Vec<(Length, PureHorzBox)>
§

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.

Fields

§end: bool
§

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.

Fields

§end: bool
§height: Length
§depth: Length
§

Footnote

add-footnote’s marker (v0.0.6 PHGFootnote(imvblst), horzBox.ml:283ImHorzFootnote, :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.

Fields

§block: Vec<VertBox>
§

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

Source

pub fn natural_width(&self) -> Length

Source

pub fn is_glue(&self) -> bool

false for every variant except the two glue kinds.

Source

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

Source

pub fn visit<__T>(&self, visitor: impl IntoVisitor<__T>) -> &Self

Visit self with any Visit, returning self to chain.

Source§

impl PureHorzBox

Source

pub fn visit_mut<__T>(&mut self, visitor: impl IntoVisitorMut<__T>) -> &mut Self

Visit self with any VisitMut, returning self to chain.

Trait Implementations§

Source§

impl Ast for PureHorzBox

Source§

impl Clone for PureHorzBox

Source§

fn clone(&self) -> PureHorzBox

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PureHorzBox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<__F: FnMut(&PureHorzBox)> IntoHook<PureHorzBox> for __F

Source§

fn into_hook(self) -> impl Hook

Source§

impl<__F: FnMut(&mut PureHorzBox)> IntoHookMut<PureHorzBox> for __F

Source§

impl<__F: FnMut(&PureHorzBox)> IntoVisitor<PureHorzBox> for __F

Source§

fn into_visitor(self) -> impl Visit

Source§

impl<__F: FnMut(&mut PureHorzBox)> IntoVisitorMut<PureHorzBox> for __F

Source§

impl PartialEq for PureHorzBox

Source§

fn eq(&self, other: &PureHorzBox) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Repeater<0> for PureHorzBox

Source§

type Type = Vec<MathGlyph>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<1> for PureHorzBox

Source§

type Type = ImageId

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<2> for PureHorzBox

Source§

type Type = Vec<GraphicsElem>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<3> for PureHorzBox

Source§

type Type = String

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<4> for PureHorzBox

Source§

type Type = TabularBox

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<5> for PureHorzBox

Source§

type Type = GraphicsFnId

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<6> for PureHorzBox

Source§

type Type = Length

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<7> for PureHorzBox

Source§

type Type = HookId

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<8> for PureHorzBox

Source§

type Type = Vec<PureHorzBox>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<9> for PureHorzBox

Source§

type Type = Vec<(Length, PureHorzBox)>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<10> for PureHorzBox

Source§

type Type = DecoId

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<11> for PureHorzBox

Source§

type Type = HorzStringInfo

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<12> for PureHorzBox

Source§

type Type = i32

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<13> for PureHorzBox

Source§

type Type = bool

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<14> for PureHorzBox

Source§

type Type = InlineMarkKind

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<15> for PureHorzBox

Source§

type Type = Vec<VertBox>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl StructuralPartialEq for PureHorzBox

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Clone for T
where T: Clone,

Source§

fn clone(&self) -> T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Debug for T
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.