UNPKG

@vivliostyle/core

Version:

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

216 lines (215 loc) 11 kB
import * as Css from "./css"; import * as Constants from "./constants"; import * as GeometryUtil from "./geometry-util"; import * as Task from "./task"; import { Layout as LayoutType, PageFloats, Vtree } from "./types"; export declare const FloatReference: typeof PageFloats.FloatReference; export type FloatReference = PageFloats.FloatReference; type PageFloatID = PageFloats.PageFloatID; export declare function floatReferenceOf(str: string): FloatReference; export declare function isPageFloat(floatReference: FloatReference): boolean; /** * Interpret a float value with the writing-mode and direction assuming the * float-reference is inline and returns "left" or "right". */ export declare function resolveInlineFloatDirection(floatSide: string, vertical: boolean, direction: string, pageSide: Constants.PageSide): string; export declare class PageFloat implements PageFloats.PageFloat { readonly nodePosition: Vtree.NodePosition; readonly floatReference: FloatReference; readonly floatSide: string; readonly clearSide: string | null; readonly flowName: string; readonly floatMinWrapBlock: Css.Numeric | null; order: number | null; id: PageFloatID | null; /** * Set to true when this float is created inside a page float area. * Used to bypass the normal anchor check in isAllowedOnContext because * the anchor node is lost after page-level invalidation. (Issue #1675) */ insidePageFloatArea: boolean; /** * Reference to the parent page float that contains this float. * Set when this float is created inside a page float area, allowing * isAllowedOnContext to check whether the parent is still present. * (Issue #1675) */ parentPageFloat: PageFloat | null; constructor(nodePosition: Vtree.NodePosition, floatReference: FloatReference, floatSide: string, clearSide: string | null, flowName: string, floatMinWrapBlock: Css.Numeric | null); getOrder(): number; getId(): PageFloatID; isAllowedOnContext(pageFloatLayoutContext: PageFloatLayoutContext): boolean; isAllowedToPrecede(other: PageFloat): boolean; } export declare class PageFloatStore { private floats; private nextPageFloatIndex; private nextOrder; private createPageFloatId; addPageFloat(float: PageFloat): void; findPageFloatByNodePosition(nodePosition: Vtree.NodePosition): PageFloat | null; findPageFloatById(id: PageFloatID): PageFloat; } /** * @param continues Represents whether the float is fragmented and continues * after this fragment */ export declare class PageFloatFragment implements PageFloats.PageFloatFragment { readonly floatReference: FloatReference; readonly floatSide: string; readonly clearSide: string | null; readonly continuations: PageFloatContinuation[]; readonly area: Vtree.Container; readonly continues: boolean; constructor(floatReference: FloatReference, floatSide: string, clearSide: string | null, continuations: PageFloatContinuation[], area: Vtree.Container, continues: boolean); hasFloat(float: PageFloat): boolean; findNotAllowedFloat(context: PageFloatLayoutContext): PageFloat | null; getOuterShape(): GeometryUtil.Shape; getOuterRect(): GeometryUtil.Rect; getOrder(): number; shouldBeStashedBefore(float: PageFloat): boolean; addContinuations(continuations: PageFloatContinuation[]): void; getFlowName(): string; } export declare class PageFloatContinuation implements PageFloats.PageFloatContinuation { readonly float: PageFloat; readonly nodePosition: Vtree.NodePosition; constructor(float: PageFloat, nodePosition: Vtree.NodePosition); equals(other: PageFloatContinuation | null): boolean; } export type PageFloatPlacementCondition = PageFloats.PageFloatPlacementCondition; /** * @param generatingNodePosition Source NodePosition generating the context. * Specify when a column context is generated by a non-root element (for * example page floats) */ export declare class PageFloatLayoutContext implements PageFloats.PageFloatLayoutContext { readonly parent: PageFloatLayoutContext; private readonly floatReference; private container; readonly flowName: string | null; readonly generatingNodePosition: Vtree.NodePosition | null; private children; writingMode: Css.Val; direction: Css.Val; private invalidated; private floatStore; private forbiddenFloats; floatFragments: PageFloatFragment[]; private stashedFloatFragments; private floatAnchors; private floatsDeferredToNext; private floatsDeferredFromPrevious; private layoutConstraints; private locked; /** * Reference to the outer column's context for page float area contexts. * Used only for getParent() navigation to propagate nested page floats * and footnotes to region/page level. Unlike `parent`, this does NOT * affect children registration, isInvalidated() propagation, or * getFloatFragmentExclusions(). (Issue #1675) */ private outerContext; constructor(parent: PageFloatLayoutContext, floatReference: FloatReference | null, container: Vtree.Container, flowName: string | null, generatingNodePosition: Vtree.NodePosition | null, writingMode: Css.Val | null, direction: Css.Val | null); /** * Returns the effective parent context for hierarchy traversal. * For normal contexts, returns `parent`. For page float area contexts * (where `parent` is null), falls back to `outerContext`. (Issue #1675) */ get effectiveParent(): PageFloatLayoutContext | null; private getParent; /** * Set the outer context for a page float area context. * This shares the float store so that page floats/footnotes created inside * a page float area are visible at all levels. (Issue #1675) */ setOuterContext(outerContext: PageFloatLayoutContext): void; private getPreviousSiblingOf; private getPreviousSibling; getContainer(floatReference?: FloatReference): Vtree.Container; setContainer(container: Vtree.Container): void; addPageFloat(float: PageFloat): void; getPageFloatLayoutContext(floatReference: FloatReference): PageFloatLayoutContext; findPageFloatByNodePosition(nodePosition: Vtree.NodePosition): PageFloat | null; private forbid; isForbidden(float: PageFloat): boolean; addPageFloatFragment(floatFragment: PageFloatFragment, dontInvalidate?: boolean): void; removePageFloatFragment(floatFragment: PageFloatFragment, dontInvalidate?: boolean): void; findPageFloatFragment(float: PageFloat): PageFloatFragment | null; hasFloatFragments(condition?: (p1: PageFloatFragment) => boolean): boolean; hasContinuingFloatFragmentsInFlow(flowName: string): boolean; registerPageFloatAnchor(float: PageFloat, anchorViewNode: Node): void; collectPageFloatAnchors(): any; isAnchorAlreadyAppeared(floatId: PageFloatID): boolean; deferPageFloat(continuation: PageFloatContinuation): void; hasPrecedingFloatsDeferredToNext(float: PageFloat, ignoreReference?: boolean): boolean; getLastFollowingFloatInFragments(float: PageFloat): PageFloat | null; getDeferredPageFloatContinuations(flowName?: string | null): PageFloatContinuation[]; getPageFloatContinuationsDeferredToNext(flowName?: string | null): PageFloatContinuation[]; getFloatsDeferredToNextInChildContexts(): PageFloat[]; checkAndForbidNotAllowedFloat(): boolean; checkAndForbidFloatFollowingDeferredFloat(): boolean; finish(): void; hasSameContainerAs(other: PageFloatLayoutContext): boolean; invalidate(): void; detachChildren(): PageFloatLayoutContext[]; attachChildren(children: PageFloatLayoutContext[]): void; isInvalidated(): any; validate(): void; private toLogical; private toPhysical; private toLogicalFloatSides; removeEndFloatFragments(floatSide: string): void; stashEndFloatFragments(float: PageFloat): void; restoreStashedFragments(floatReference: FloatReference): void; discardStashedFragments(floatReference: FloatReference): void; getStashedFloatFragments(floatReference: FloatReference): PageFloatFragment[]; private getLimitValue; private getLimitValueInner; private getLimitValuesInner; /** * @param anchorEdge Null indicates that the anchor is not in the current * container. * @return Logical float side (snap-block is resolved when init=false). Null * indicates that the float area does not fit inside the container */ setFloatAreaDimensions(area: LayoutType.PageFloatArea, floatReference: FloatReference, floatSide: string, anchorEdge: number | null, init: boolean, force: boolean, condition: PageFloatPlacementCondition): string | null; getFloatFragmentExclusions(): GeometryUtil.Shape[]; private reattachFloatFragments; getMaxReachedAfterEdge(): number; getBlockEndEdgeOfBlockStartFloats(inlinePos?: number): number; getBlockStartEdgeOfBlockEndFloats(inlinePos?: number): number; getPageFloatClearEdge(clear: string, column: LayoutType.Column): number; getPageFloatPlacementCondition(float: PageFloat, floatSide: string, clearSide: string | null): PageFloatPlacementCondition; getLayoutConstraints(): LayoutType.LayoutConstraint[]; addLayoutConstraint(layoutConstraint: LayoutType.LayoutConstraint, floatReference: FloatReference): void; isColumnFullWithPageFloats(column: LayoutType.Column): boolean; getMaxBlockSizeOfPageFloats(): number; lock(): void; unlock(): void; isLocked(): boolean; } export interface PageFloatLayoutStrategy extends PageFloats.PageFloatLayoutStrategy { } export declare class PageFloatLayoutStrategyResolver { static register(strategy: PageFloatLayoutStrategy): void; findByNodeContext(nodeContext: Vtree.NodeContext): PageFloatLayoutStrategy; findByFloat(float: PageFloat): PageFloatLayoutStrategy; } export declare class NormalPageFloatLayoutStrategy implements PageFloatLayoutStrategy { /** @override */ appliesToNodeContext(nodeContext: Vtree.NodeContext): boolean; /** @override */ appliesToFloat(float: PageFloat): boolean; /** @override */ createPageFloat(nodeContext: Vtree.NodeContext, pageFloatLayoutContext: PageFloatLayoutContext, column: LayoutType.Column): Task.Result<PageFloat>; /** @override */ createPageFloatFragment(continuations: PageFloatContinuation[], floatSide: string, clearSide: string | null, floatArea: LayoutType.PageFloatArea, continues: boolean): PageFloatFragment; /** @override */ findPageFloatFragment(float: PageFloat, pageFloatLayoutContext: PageFloatLayoutContext): PageFloatFragment | null; /** @override */ adjustPageFloatArea(floatArea: LayoutType.PageFloatArea, floatContainer: Vtree.Container, column: LayoutType.Column): Task.Result<void>; /** @override */ forbid(float: PageFloat, pageFloatLayoutContext: PageFloatLayoutContext): void; } export {};