Colibrio Reader Framework API - Cloud license
    Preparing search index...

    Interface IVisibleContentAreaRectsResultExperimental

    The visible content rects of a named area in the ReaderView: one entry per line box or element, each paired with the content location it was generated from.

    In EPUB content, the rects cover lines of text and img, video and picture elements. They can also cover other elements, such as svg, math and hr elements. An svg or math element has one rect for all of its content. Content with display: none or visibility: hidden, and content without a size, has no rect. In PDF content, only selectable text has rects. A page without selectable text, such as a scanned page, has none.

    rects holds every rect of the result in document order. ranges divides rects into continuous runs of content. Content that is close together on screen can be far apart in the document, or belong to different ReaderDocuments, so one result can hold several runs.

    Content that a publication element clips is still listed at its full layout geometry in clientRect. Each rect's clippedClientRect holds the geometry left after clipping, and clippingRects lists the clipping elements.

    All coordinates are in application viewport coordinate space and describe the moment the IReaderViewVisibleContent snapshot was taken: a later navigation, scroll or ReaderView transform makes them out of date.

    This API is experimental and might be subject to changes in future releases.

    interface IVisibleContentAreaRectsResult {
        areaRect: DOMRect;
        areaType: VisibleContentAreaType;
        clippingRects: IVisibleContentClippingRect[];
        ranges: IVisibleContentRectsRange[];
        rects: IVisibleContentRect[];
        getContentLocationPaintState(
            contentLocation: IContentLocation,
        ): ContentLocationPaintState;
        getVisibleContentRectsIntersectingContentLocation(
            contentLocation: IContentLocation,
        ): IVisibleContentRect[];
        getVisibleContentRectsIntersectingRect(
            clientRect: DOMRect,
        ): IVisibleContentRect[];
        toJSON(): IVisibleContentAreaRectsResultData;
    }

    Properties

    areaRect: DOMRect

    The resolved rectangle of areaType that the rects were tested against. It is the rectangle IReaderViewVisibleContent.getResolvedAreaRect returns for areaType. Coordinates are in application viewport coordinate space.

    The named area the rects were tested against.

    The elements that can clip the content in rects, whether or not they clip any of it. An element is listed once for each visible page it appears on. Its entries share the same contentLocation, and each entry holds the geometry on its own page. The list may include elements that no rect in rects refers to.

    IVisibleContentRect.clippingRectIndex is an index into this list, naming the nearest ancestor element that can clip that rect. Each clipping rect's own clippingRectIndex names the nearest ancestor that can clip it. The indices are valid for every rect in rects, whichever run it belongs to, but only against the list of the result they came from.

    Only EPUB content produces clipping rects. Rects from other publication formats have null clippingRectIndex values, even when the content is clipped.

    The continuous runs of content in rects, in document order. Together the runs cover every rect in rects exactly once.

    Every rect in this result, in document order.

    Methods

    • Experimental

      Get whether the content at contentLocation is painted in this result's area.

      In EPUB content, a location points into the document structure, so content without a rect is judged by document order. The location is:

      • PAINTED when it covers content that one of the rects in rects paints.
      • NOT_PAINTED when it covers only unpainted content, such as a display: none element, inside one of the runs in ranges.
      • OUTSIDE_VISIBLE_CONTENT otherwise.

      In PDF content, a location is a point or region on a PDF page, so paint state is judged by geometry alone. The location is PAINTED when it intersects the area, and OUTSIDE_VISIBLE_CONTENT otherwise. Content without a rect, such as an image or a blank margin, follows the same rule. PDF content is never NOT_PAINTED.

      A location that covers both painted and unpainted content is PAINTED. In EPUB content, paint state is decided per rect, so unpainted inline content inside a painted line, such as a visibility: hidden span, can be PAINTED. Clipping and opacity do not count: content that is fully clipped or has opacity: 0 is PAINTED.

      Coverage follows IContentLocation.intersects. A location that ends exactly where painted content starts does not cover it, and a collapsed location at the start of painted content does.

      For an #id href, IEpubReaderPublication.fetchContentLocationFromHref returns a collapsed location before the element, so its paint state depends on the content around it, not on the element. To check whether an element is painted, pass a range that covers it, such as from the location before the element to the location before its next sibling element.

      In EPUB content, IReaderViewVisibleContent.getContentRectsContainedInArea leaves out lines that are only partly inside the area, so a location in such a line is OUTSIDE_VISIBLE_CONTENT in its result.

      The answer reflects the snapshot this result was taken from. Later changes to the publication content do not affect it.

      Parameters

      Returns ContentLocationPaintState

      The paint state of the content at contentLocation.

    • Experimental

      Get the rects in this result whose contentLocation intersects the passed contentLocation.

      Each rect covers a whole line box or element, so the returned rects can cover more content than contentLocation, and content outside this result's area is never returned. For the exact geometry of a content location, use IVisiblePage.fetchContentRects or IVisiblePage.fetchBoundingClientRectForContentLocation.

      The returned rects are the same objects as in rects. Their clippingRectIndex values index this result's clippingRects.

      Parameters

      • contentLocation: IContentLocation

        The content location to test the rects against.

      Returns IVisibleContentRect[]

      The matching rects, in document order. Empty when no rect matches.

    • Experimental

      Get the rects in this result whose clientRect intersects the passed clientRect.

      A rect that only touches the passed clientRect at an edge does not intersect it.

      The test uses each rect's unclipped clientRect, as the area methods on IReaderViewVisibleContent do, so the returned rects include content that a publication element clips away. To drop the rects that clipping hides entirely, skip the rects whose IVisibleContentRect.clippedState is FULLY_CLIPPED.

      The returned rects are the same objects as in rects. Their clippingRectIndex values index this result's clippingRects.

      Parameters

      • clientRect: DOMRect

        The rectangle to test the rects against, in application viewport coordinate space.

      Returns IVisibleContentRect[]

      The matching rects, in document order. Empty when no rect matches.