UNPKG

@vivliostyle/core

Version:

Vivliostyle Core library for HTML+CSS typesetting with EPUB/Web publications support

93 lines (92 loc) 4.67 kB
import { Layout, Vtree } from "./types"; /** * Enable page/column breaking using the browser's multi-column feature. * This function sets CSS properties on the column element to create a * single-column (column-count: 1) that splits into multiple columns * when content overflows the column's size. The large column gap * (column-gap) ensures that the browser creates new columns * apart from the original column position, and it helps determine * page/column breaking positions in our layout processing. */ export declare function setBrowserColumnBreaking(column: Vtree.Container): void; /** * Disable the browser's multi-column feature for page/column breaking. * This function resets the CSS properties set by `setBrowserColumnBreaking`. */ export declare function unsetBrowserColumnBreaking(column: Vtree.Container): void; /** * Check if the browser's multi-column feature is being used for page/column breaking. */ export declare function isUsingBrowserColumnBreaking(column: Vtree.Container): boolean; /** * Mark the column as a root column for Vivliostyle layout processing. */ export declare function setAsRootColumn(column: Vtree.Container): void; /** * Check if the column is marked as a root column for Vivliostyle layout processing. */ export declare function isRootColumn(column: Vtree.Container): boolean; /** * Check if the client rectangle of an element or range is located * in a column beyond the current one due to the browser's column breaking. * * @param rect - The client rectangle to check. * @param vertical - Whether the layout is vertical. * @return the number of columns the end edge of the rectangle is after the current column. */ export declare function checkIfBeyondColumnBreaks(rect: Vtree.ClientRect, vertical: boolean): number; /** * Adjust the client rectangle of an element or range to account for * the browser's column breaking. * This function modifies the rectangle's coordinates to ensure that * if the rectangle is located in a column beyond the current one, * its position in the block-progression direction is moved accordingly * so that overflow checks can be performed based solely on the * block-progression position. * * @param rect - The client rectangle to check. * @param vertical - Whether the layout is vertical. * @return the number of columns the start edge of the rectangle is after the current column. */ export declare function adjustRectForColumnBreaking(rect: Vtree.ClientRect, vertical: boolean): number; /** * Adjust multiple client rectangles for column breaking. */ export declare function adjustRectsForColumnBreaking(rects: Vtree.ClientRect[], vertical: boolean): void; /** * Get the client rectangle of an element, adjusted for column breaking. */ export declare function getElementClientRectAdjusted(clientLayout: Vtree.ClientLayout, element: Element, vertical: boolean): Vtree.ClientRect; /** * Clear forced column breaks between two nodes. * This is used to prevent unnecessary blank pages. */ export declare function clearForcedColumnBreaks(prevNode: Node, currNode: Node): void; /** * Find the nearest ancestor element that establishes a multi-column * layout but is not the root column element. */ export declare function findAncestorNonRootMultiColumn(node: Node): Element | null; /** * Fix overflow caused by forced column breaks in non-root multi-column elements. */ export declare function fixOverflowAtForcedColumnBreak(node: Node): void; /** * Calculate the position of the "after" edge in the block-progression. * Returns the edge position in pixels if it was determined successfully, * and returns NaN if the position could not be determined and the node * should be considered zero-height. */ export declare function calculateEdge(nodeContext: Vtree.NodeContext, clientLayout: Vtree.ClientLayout, extraOffset: number, vertical: boolean): number; export declare function getElementHeight(element: Element, column: Layout.Column, vertical: boolean): number; export declare function isOrphan(node: Node): boolean; export declare function removeFollowingSiblings(parentNode: Node, viewNode: Node): void; /** * Marks an element as "special". It should not be used in bbox calculations. */ export declare const SPECIAL_ATTR = "data-adapt-spec"; export declare function isSpecial(e: Element): boolean; export declare function isOutOfFlow(node: Node): boolean; export declare function isSpecialNodeContext(nodeContext: Vtree.NodeContext): boolean; export declare function isSpecialInlineDisplay(display: string): boolean; export declare function findAncestorSpecialInlineNodeContext(nodeContext: Vtree.NodeContext): Vtree.NodeContext | null;