import { HTMLElement } from './dom.js';
import { Style, WritingMode } from './cascade.js';
import { Run, Paragraph, Linebox, InlineMetrics } from './text.js';
import { Box } from './box.js';
export type LayoutContext = {
lastBlockContainerArea: BlockContainerArea;
lastPositionedArea: BlockContainerArea;
mode: 'min-content' | 'max-content' | 'normal';
bfc: BlockFormattingContext;
};
export declare class BlockFormattingContext {
inlineSize: number;
fctx: FloatContext;
stack: (BlockContainer | {
post: BlockContainer;
})[];
cbBlockStart: number;
cbLineLeft: number;
cbLineRight: number;
private sizeStack;
private offsetStack;
private last;
private level;
private hypotheticals;
private margin;
constructor(inlineSize: number);
boxStart(box: BlockContainer, ctx: LayoutContext): void;
boxEnd(box: BlockContainer): void;
finalize(box: BlockContainer): void;
positionBlockContainers(): void;
}
declare class FloatSide {
items: BlockContainer[];
shelfBlockOffset: number;
shelfTrackIndex: number;
blockOffsets: number[];
inlineSizes: number[];
inlineOffsets: number[];
floatCounts: number[];
constructor();
initialize(blockOffset: number): void;
repr(): string;
getSizeOfTracks(start: number, end: number, inlineOffset: number): number;
getOverflow(): number;
getFloatCountOfTracks(start: number, end: number): number;
getEndTrack(start: number, blockOffset: number, blockSize: number): number;
getTrackRange(blockOffset: number, blockSize?: number): [number, number];
getOccupiedSpace(blockOffset: number, blockSize: number, inlineOffset: number): number;
boxStart(blockOffset: number): void;
dropShelf(blockOffset: number): void;
getNextTrackOffset(): number;
getBottom(): number;
splitTrack(trackIndex: number, blockOffset: number): void;
splitIfShelfDropped(): void;
placeFloat(box: BlockContainer, vacancy: IfcVacancy, cbLineLeft: number, cbLineRight: number): void;
}
export declare class IfcVacancy {
leftOffset: number;
rightOffset: number;
inlineSize: number;
blockOffset: number;
leftFloatCount: number;
rightFloatCount: number;
constructor(leftOffset: number, rightOffset: number, blockOffset: number, inlineSize: number, leftFloatCount: number, rightFloatCount: number);
}
export declare class FloatContext {
bfc: BlockFormattingContext;
leftFloats: FloatSide;
rightFloats: FloatSide;
gotFirstBox: boolean;
misfits: BlockContainer[];
constructor(bfc: BlockFormattingContext);
boxStart(): void;
getVacancyForLine(blockOffset: number, blockSize: number): IfcVacancy;
getLocalVacancyForLine(bfc: BlockFormattingContext, blockOffset: number, blockSize: number, vacancy: IfcVacancy): void;
getVacancyForBox(box: BlockContainer): IfcVacancy;
getLeftBottom(): number;
getRightBottom(): number;
getBothBottom(): number;
findLinePosition(blockOffset: number, blockSize: number, inlineSize: number): IfcVacancy;
placeFloat(lineWidth: number, lineIsEmpty: boolean, box: BlockContainer): void;
consumeMisfits(): void;
dropShelf(blockOffset: number): void;
postLine(line: Linebox, didBreak: boolean): void;
preTextContent(): void;
}
export declare class BlockContainerArea {
parent: BlockContainerArea | null;
blockContainer: BlockContainer;
blockStart: number;
blockSize: number;
lineLeft: number;
inlineSize: number;
constructor(blockContainer: BlockContainer, x?: number, y?: number, w?: number, h?: number);
clone(): BlockContainerArea;
get writingMode(): WritingMode;
get direction(): import("./cascade.js").Direction;
get x(): number;
get y(): number;
get width(): number;
get height(): number;
setParent(p: BlockContainerArea): void;
blockSizeForWritingMode(writingMode: WritingMode): number;
inlineSizeForWritingMode(writingMode: WritingMode): number;
absolutify(): void;
repr(indent?: number): string;
}
type BlockContainerOfInlines = BlockContainer & {
children: IfcInline[];
};
type BlockContainerOfBlockContainers = BlockContainer & {
children: BlockContainer[];
};
export declare class BlockContainer extends Box {
children: IfcInline[] | BlockContainer[];
borderArea: BlockContainerArea;
paddingArea: BlockContainerArea;
contentArea: BlockContainerArea;
containingBlock: BlockContainerArea | null;
constructor(style: Style, children: IfcInline[] | BlockContainer[], attrs: number);
fillAreas(): void;
get sym(): "◼︎" | "𝗈";
get desc(): string;
get writingMode(): WritingMode;
get direction(): import("./cascade.js").Direction;
setBlockPosition(position: number): void;
setBlockSize(size: number): void;
setInlinePosition(lineLeft: number): void;
setInlineOuterSize(size: number): void;
getContainingBlockToContent(): {
blockStart: number;
lineLeft: number;
lineRight: number;
};
getDefiniteInlineSize(): number | undefined;
getMarginsAutoIsZero(): {
blockStart: number;
lineRight: number;
blockEnd: number;
lineLeft: number;
};
assignContainingBlocks(ctx: LayoutContext): void;
isBlockContainer(): this is BlockContainer;
isInlineLevel(): boolean;
isBlockLevel(): boolean;
isBfcRoot(): boolean;
isFloat(): boolean;
loggingEnabled(): boolean;
isBlockContainerOfInlines(): this is BlockContainerOfInlines;
canCollapseThrough(): boolean;
isBlockContainerOfBlockContainers(): this is BlockContainerOfBlockContainers;
preprocess(): void;
postprocess(): void;
doTextLayout(ctx: LayoutContext): void;
}
export declare function layoutBlockBox(box: BlockContainer, ctx: LayoutContext): void;
export declare function layoutFloatBox(box: BlockContainer, ctx: LayoutContext): void;
export declare class Break extends Box {
className: string;
isBreak(): this is Break;
get sym(): string;
get desc(): string;
}
export declare class Inline extends Box {
children: InlineLevel[];
nshaped: number;
metrics: InlineMetrics;
start: number;
end: number;
constructor(style: Style, children: InlineLevel[], attrs: number);
preprocess(): void;
postprocess(): void;
hasLineLeftGap(ifc: IfcInline): boolean | undefined;
hasLineRightGap(ifc: IfcInline): boolean | undefined;
getLineLeftMarginBorderPadding(ifc: IfcInline): number;
getLineRightMarginBorderPadding(ifc: IfcInline): number;
isInline(): this is Inline;
get sym(): string;
get desc(): string;
absolutify(): void;
}
export declare class IfcInline extends Inline {
children: InlineLevel[];
text: string;
paragraph: Paragraph;
containingBlock: BlockContainerArea | null;
private analysis;
static ANALYSIS_HAS_TEXT: number;
static ANALYSIS_WRAPS: number;
static ANALYSIS_WS_COLLAPSES: number;
static ANALYSIS_HAS_INLINES: number;
static ANALYSIS_HAS_BREAKS: number;
static ANALYSIS_IS_COMPLEX_TEXT: number;
static ANALYSIS_HAS_SOFT_HYPHEN: number;
static ANALYSIS_HAS_FLOATS: number;
constructor(style: Style, children: InlineLevel[], attrs: number);
isIfcInline(): this is IfcInline;
get writingMode(): WritingMode;
loggingEnabled(): boolean;
postprepare(): void;
private prepare;
itemizeInlines(): Generator<{
i: number;
style: Style;
}, void, unknown>;
preprocess(): void;
postprocess(): void;
doTextLayout(ctx: LayoutContext): void;
hasText(): number;
wraps(): number;
collapses(): number;
hasFloats(): number;
hasInlines(): number;
hasBreaks(): number;
isComplexText(): number;
hasSoftHyphen(): number;
assignContainingBlocks(ctx: LayoutContext): void;
}
export type InlineLevel = Inline | BlockContainer | Run | Break;
type InlineIteratorBuffered = {
state: 'pre' | 'post';
item: Inline;
} | {
state: 'text';
item: Run;
} | {
state: 'float';
item: BlockContainer;
} | {
state: 'break';
};
type InlineIteratorValue = InlineIteratorBuffered | {
state: 'breakop';
};
export declare function createInlineIterator(inline: IfcInline): {
next: () => {
done: true;
} | {
done: false;
value: InlineIteratorValue;
};
};
export declare function createPreorderInlineIterator(inline: IfcInline): {
next: () => {
done: true;
} | {
done: false;
value: Inline | Run;
};
};
export declare function generateBlockContainer(el: HTMLElement, parentEl?: HTMLElement): BlockContainer;
export {};