NAME

Mozilla::DOM::Range

Mozilla::DOM::Range is a wrapper around an instance of Mozilla's nsIDOMRange interface. This class inherits from Supports.

* The nsIDOMRange interface is an interface to a DOM range object.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Traversal-Range/

The constants START_TO_START, START_TO_END, END_TO_END, and END_TO_START are available for the "how" argument to "CompareBoundaryPoints". You can export them all with use Mozilla::DOM::Range qw(:how) or export them individually.

CLASS METHODS

$iid = Mozilla::DOM::Range->GetIID()

Pass this to QueryInterface.

METHODS

$node = $range->GetStartContainer()

* Node within which the Range begins

$offset = $range->GetStartOffset()

* Offset within the starting node of the Range.

$node = $range->GetEndContainer()

Node within which the Range ends

$offset = $range->GetEndOffset()

Offset within the ending node of the Range.

$range->SetStart($node, $offset)

Sets the attributes describing the start of the Range.

    • $refNode (Mozilla::DOM::Node)

      The refNode value. This parameter must be different from null.

    • $offset (integer (long))

      The startOffset value.

$range->SetStartBefore($node)

Sets the start position to be before a node

    • $refNode (Mozilla::DOM::Node)

$range->SetStartAfter($node)

Sets the start position to be after a node

    • $refNode (Mozilla::DOM::Node)

$range->SetEnd($node, $offset)

Sets the attributes describing the end of a Range.

    • $refNode (Mozilla::DOM::Node)

      The refNode value. This parameter must be different from null.

    • $offset (integer (long))

      The endOffset value.

$range->SetEndBefore($node)

Sets the end position to be before a node.

    • $refNode (Mozilla::DOM::Node)

$range->SetEndAfter($node)

Sets the end of a Range to be after a node

    • $refNode (Mozilla::DOM::Node)

$range->Collapse($toStart)

Collapse a Range onto one of its boundary-points

    • $toStart (boolean)

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

$bool = $range->GetCollapsed()

$range->SelectNode($refNode)

Select a node and its contents

    • $refNode (Mozilla::DOM::Node)

$range->SelectNodeContents($node)

Select the contents within a node (i.e. don't include the tags)

    • $refNode (Mozilla::DOM::Node)

$num = $range->CompareBoundaryPoints($how, $sourceRange)

Compare the boundary-points of two Ranges in a document.

    • $how (integer (short))

      A code representing the type of comparison (which boundary point of the source range to which boundary point of the range): START_TO_START, START_TO_END, END_TO_END, END_TO_START.

    • $sourceRange (Mozilla::DOM::Range)

      The Range on which this current Range is compared to.

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

$range->DeleteContents()

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

$documentfragment = $range->ExtractContents()

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

$documentfragment = $range->CloneContents()

Duplicates the contents of a Range

$range->InsertNode($node)

Inserts a node into the Document or DocumentFragment at the start of the Range. If the container is a Text node, this will be split at the start of the Range (as if the Text node's splitText method was performed at the insertion point) and the insertion will occur between the two resulting Text nodes. Adjacent Text nodes will not be automatically merged. If the node to be inserted is a DocumentFragment node, the children will be inserted rather than the DocumentFragment node itself.

    • $newNode (Mozilla::DOM::Node)

      The node to insert at the start of the Range

$range->SurroundContents($newParentNode)

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

    • $newParent (Mozilla::DOM::Node)

$range->CloneRange($range)

Produces a new Range whose boundary-points are equal to the boundary-points of the Range.

$node = $range->GetCommonAncestorContainer()

The deepest common ancestor container of the Range's two boundary-points.

$str = $range->ToString()

Returns the contents of a Range as a string. This string contains only the data characters, not any markup.

$range->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.

SEE ALSO

Mozilla::DOM

COPYRIGHT

Copyright (C) 2005, Scott Lanning

This software is licensed under the LGPL. See Mozilla::DOM for a full notice.