Skip to content

//shared/org.readium.r2.shared.publication.html/DomRange

DomRange

[androidJvm]\ data class DomRange(start: DomRange.Point, end: DomRange.Point?) : JSONable, Parcelable

This construct enables a serializable representation of a DOM Range.

In a DOM Range object, the startContainer + startOffset tuple represents the start boundary point. Similarly, the the endContainer + endOffset tuple represents the end boundary point. In both cases, the start/endContainer property is a pointer to either a DOM text node, or a DOM element (this typically depends on the mechanism from which the DOM Range instance originates, for example when obtaining the currently-selected document fragment using the window.selection API). In the case of a DOM text node, the start/endOffset corresponds to a position within the character data. In the case of a DOM element node, the start/endOffset corresponds to a position that designates a child text node.

Note that end field is optional. When only the start field is specified, the domRange object represents a "collapsed" range that has identical start and end boundary points.

https://github.com/readium/architecture/blob/master/models/locators/extensions/html.md#the-domrange-object

Parameters

androidJvm

start A serializable representation of the "start" boundary point of the DOM Range.
end A serializable representation of the "end" boundary point of the DOM Range.

Constructors

DomRange [androidJvm]
fun DomRange(start: DomRange.Point, end: DomRange.Point? = null)

Types

Name Summary
Companion [androidJvm]
object Companion
Point [androidJvm]
data class Point(cssSelector: String, textNodeIndex: Int, charOffset: Int?) : JSONable, Parcelable
A serializable representation of a boundary point in a DOM Range.

Functions

Name Summary
describeContents [androidJvm]
abstract fun describeContents(): Int
toJSON [androidJvm]
open override fun toJSON(): JSONObject
Serializes the object to its JSON representation.
writeToParcel [androidJvm]
abstract fun writeToParcel(p0: Parcel, p1: Int)

Properties

Name Summary
end [androidJvm]
val end: DomRange.Point? = null
start [androidJvm]
val start: DomRange.Point