class Range

# class Range |
Full name | `DOM::Range`
Definition | `#include <dom2_range.h>`
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum CompareHow { START_TO_START = 0, START_TO_END = 1, END_TO_END = 2, END_TO_START = 3 }

#### Public Methods

- Range ()
- Range (const Document rootContainer)
- Range (const Range &other)
- Range (const Node startContainer, const long startOffset, const Node endContainer, const long endOffset)
- Range & operator = (const Range &other)
- ~Range ()
- Node startContainer () const
- long startOffset () const
- Node endContainer () const
- long endOffset () const
- bool collapsed () const
- Node commonAncestorContainer ()
- void setStart ( const Node &refNode, long offset )
- void setEnd ( const Node &refNode, long offset )
- void setStartBefore ( const Node &refNode )
- void setStartAfter ( const Node &refNode )
- void setEndBefore ( const Node &refNode )
- void setEndAfter ( const Node &refNode )
- void collapse ( bool toStart )
- void selectNode ( const Node &refNode )
- void selectNodeContents ( const Node &refNode )
- short compareBoundaryPoints ( CompareHow how, const Range &sourceRange )
- bool boundaryPointsValid ( )
- void deleteContents ( )
- DocumentFragment extractContents ( )
- DocumentFragment cloneContents ( )
- void insertNode ( const Node &newNode )
- void surroundContents ( const Node &newParent )
- Range cloneRange ( )
- DOMString toString ( )
- DOMString toHTML ( )
- void detach ( )
- bool isDetached () const
- RangeImpl * handle () const
- bool isNull () const

#### Protected Methods

- Range (RangeImpl *i)

#### Protected Members

- RangeImpl *impl

## Detailed Description

Range () | ### Range

Range (const Document rootContainer) | ### Range

Range (const Range &other) | ### Range

Range (const Node startContainer, const long startOffset, const Node endContainer, const long endOffset) | ### Range

Range & operator = (const Range &other) | ### operator =

~Range () | ### ~Range

Node startContainer () | ### startContainer

[const]

Node within which the range begins

long startOffset () | ### startOffset

[const]

Offset within the starting node of the range.

Node endContainer () | ### endContainer

[const]

Node within which the range ends

long endOffset () | ### endOffset

[const]

Offset within the ending node of the range.

bool collapsed () | ### collapsed

[const]

TRUE if the range is collapsed

Node commonAncestorContainer () | ### commonAncestorContainer

Gets the common ancestor container of the range's two end-points. Also sets it.

void setStart ( const Node &refNode, long offset ) | ### setStart

Sets the attributes describing the start of the range.

INVALID_NODE_TYPE_ERR: Raised if `refNode` or an ancestor of `refNode` is an Attr, Entity, Notation, or DocumentType node.

If an offset is out-of-bounds, should it just be fixed up or should an exception be raised.

Parameters:

refNode | The `refNode` value. This parameter must be different from `null` .
offset | The `startOffset` value.

Throws: RangeException, NULL_NODE_ERR:, Raised, if, `, refNode,` , is, `, null,` , .

void setEnd ( const Node &refNode, long offset ) | ### setEnd

Sets the attributes describing the end of a range.

INVALID_NODE_TYPE_ERR: Raised if `refNode` or an ancestor of `refNode` is an Attr, Entity, Notation, or DocumentType node.

Parameters:

refNode | The `refNode` value. This parameter must be different from `null` .
offset | The `endOffset` value.

Throws: RangeException, NULL_NODE_ERR:, Raised, if, `, refNode,` , is, `, null,` , .

void setStartBefore ( const Node &refNode ) | ### setStartBefore

Sets the start position to be before a node

Parameters:

refNode | Range starts before `refNode`

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node, or, if, `, refNode,` , is, a, Document, DocumentFragment, Attr, Entity, or, Notation, node.

void setStartAfter ( const Node &refNode ) | ### setStartAfter

Sets the start position to be after a node

Parameters:

refNode | Range starts after `refNode`

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node, or, if, `, refNode,` , is, a, Document, DocumentFragment, Attr, Entity, or, Notation, node.

void setEndBefore ( const Node &refNode ) | ### setEndBefore

Sets the end position to be before a node.

Parameters:

refNode | Range ends before `refNode`

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node, or, if, `, refNode,` , is, a, Document, DocumentFragment, Attr, Entity, or, Notation, node.

void setEndAfter ( const Node &refNode ) | ### setEndAfter

Sets the end of a range to be after a node

Parameters:

refNode | Range ends after `refNode` .

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node, or, if, `, refNode,` , is, a, Document, DocumentFragment, Attr, Entity, or, Notation, node.

void collapse ( bool toStart ) | ### collapse

Collapse a range onto one of its end-points

Parameters:

toStart | If TRUE, collapses the Range onto its start; if FALSE, collapses it onto its end.

void selectNode ( const Node &refNode ) | ### selectNode

Select a node and its contents

Parameters:

refNode | The node to select.

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node, or, if, `, refNode,` , is, a, Document, DocumentFragment, Attr, Entity, or, Notation, node.

void selectNodeContents ( const Node &refNode ) | ### selectNodeContents

Select the contents within a node

Parameters:

refNode | Node to select from

Throws: RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, `, refNode,` , or, an, ancestor, of, `, refNode,` , is, an, Attr, Entity, Notation, or, DocumentType, node.

enum CompareHow { START_TO_START = 0, START_TO_END = 1, END_TO_END = 2, END_TO_START = 3 } | ### CompareHow

short compareBoundaryPoints ( CompareHow how, const Range &sourceRange ) | ### compareBoundaryPoints

Compare the end-points of two ranges in a document.

Returns: -1, 0 or 1 depending on whether the corresponding end-point of the Range is before, equal to, or after the corresponding end-point of `sourceRange` .

Throws: DOMException, WRONG_DOCUMENT_ERR:, Raised, if, the, two, Ranges, are, not, in, the, same, document, or, document, fragment.

bool boundaryPointsValid ( ) | ### boundaryPointsValid

not part of the DOM

Compare the boundary-points of a range.

Return true if the startContainer is before the endContainer, or if they are equal. Return false if the startContainer is after the endContainer.

void deleteContents ( ) | ### deleteContents

Removes the contents of a range from the containing document or document fragment without returning a reference to the removed content.

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, if, any, portion, of, the, content, of, the, range, is, read-only, or, any, of, the, nodes, that, contain, any, of, the, content, of, the, range, are, read-only.

DocumentFragment extractContents ( ) | ### extractContents

Moves the contents of a range from the containing document or document fragment to a new DocumentFragment.

HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be extracted into the new DocumentFragment.

Returns: A DocumentFragment containing the extracted contents.

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, if, any, portion, of, the, content, of, the, range, is, read-only, or, any, of, the, nodes, which, contain, any, of, the, content, of, the, range, are, read-only.

DocumentFragment cloneContents ( ) | ### cloneContents

Duplicates the contents of a range

Returns: A DocumentFragment containing contents equivalent to those of this range.

Throws: DOMException, HIERARCHY_REQUEST_ERR:, Raised, if, a, DocumentType, node, would, be, extracted, into, the, new, DocumentFragment.

void insertNode ( const Node &newNode ) | ### insertNode

Inserts a node into the document or document fragment at the start of the range.

WRONG_DOCUMENT_ERR: Raised if `newNode` and the container of the start of the Range were not created from the same document.

HIERARCHY_REQUEST_ERR: Raised if the container of the start of the Range is of a type that does not allow children of the type of `newNode` or if `newNode` is an ancestor of the container .

Parameters:

newNode | The node to insert at the start of the range

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, if, an, ancestor, container, of, the, start, of, the, range, is, read-only., RangeException, INVALID_NODE_TYPE_ERR:, Raised, if, `, node,` , is, an, Attr, Entity, Notation, DocumentFragment, or, Document, node.

void surroundContents ( const Node &newParent ) | ### surroundContents

Reparents the contents of the range to the given node and inserts the node at the position of the start of the range.

WRONG_DOCUMENT_ERR: Raised if `newParent` and the container of the start of the Range were not created from the same document.

HIERARCHY_REQUEST_ERR: Raised if the container of the start of the Range is of a type that does not allow children of the type of `newParent` or if `newParent` is an ancestor of the container or if `node` would end up with a child node of a type not allowed by the type of `node` .

INVALID_NODE_TYPE_ERR: Raised if `node` is an Attr, Entity, DocumentType, Notation, Document, or DocumentFragment node.

Parameters:

newParent | The node to surround the contents with.

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, if, an, ancestor, container, of, either, end-point, of, the, range, is, read-only., RangeException, BAD_ENDPOINTS_ERR:, Raised, if, the, range, partially, selects, a, non-text, node.

Range cloneRange ( ) | ### cloneRange

Produces a new range whose end-points are equal to the end-points of the range.

Returns: The duplicated range.

DOMString toString ( ) | ### toString

Returns the contents of a range as a string.

Returns: The contents of the range.

DOMString toHTML ( ) | ### toHTML

void detach ( ) | ### detach

Called to indicate that the range is no longer in use and that the implementation may relinquish any resources associated with this range. Subsequent calls to any methods or attribute getters on this range will result in a DOMException being thrown with an error code of INVALID_STATE_ERR.

bool isDetached () | ### isDetached

[const]

not part of the DOM TRUE if the range is detached

RangeImpl * handle () | ### handle

[const]

not part of the DOM

bool isNull () | ### isNull

[const]

RangeImpl * impl | ### impl

[protected]

Range (RangeImpl *i) | ### Range

[protected]

Generated by: root on macppc.ports.openbsd.org on Sat Sep 6 10:37:43 2003, using kdoc 2.0a54.