org.xwiki.gwt.dom.client
Interface Range


public interface Range

A contiguous fragment of a Document or DocumentFragment that can contain nodes and parts of text nodes.

Version:
$Id: c8702f65f0614a67794ae878b4b24110604fd8de $
See Also:
"http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html"

Method Summary
 DocumentFragment cloneContents()
          Duplicates the contents of this range.
 Range cloneRange()
          Produces a new Range whose boundary-points are equal to the boundary-points of this range.
 void collapse(boolean toStart)
          Collapse this range onto one of its boundary-points.
 short compareBoundaryPoints(RangeCompare how, Range sourceRange)
          Compare the boundary-points of two Ranges in a document.
 void deleteContents()
          Removes the contents of this range from the containing document or document fragment without returning a reference to the removed content.
 void detach()
          Called to indicate that this range is no longer in use and that the implementation may relinquish any resources associated with this range.
 DocumentFragment extractContents()
          Moves the contents of this range from the containing document or document fragment to a new DocumentFragment.
 com.google.gwt.dom.client.Node getCommonAncestorContainer()
           
 com.google.gwt.dom.client.Node getEndContainer()
           
 int getEndOffset()
           
 com.google.gwt.dom.client.Node getStartContainer()
           
 int getStartOffset()
           
 void insertNode(com.google.gwt.dom.client.Node newNode)
          Inserts a node into the Document or DocumentFragment at the start of the Range.
 boolean isCollapsed()
           
 void selectNode(com.google.gwt.dom.client.Node refNode)
          Select a node and its contents.
 void selectNodeContents(com.google.gwt.dom.client.Node refNode)
          Select the contents within a node.
 void setEnd(com.google.gwt.dom.client.Node refNode, int offset)
          Sets the attributes describing the end of this range.
 void setEndAfter(com.google.gwt.dom.client.Node refNode)
          Sets the end of this Range to be after the given node.
 void setEndBefore(com.google.gwt.dom.client.Node refNode)
          Sets the end position to be before the given node.
 void setStart(com.google.gwt.dom.client.Node refNode, int offset)
          Sets the attributes describing the start of this range.
 void setStartAfter(com.google.gwt.dom.client.Node refNode)
          Sets the start position to be after the given node.
 void setStartBefore(com.google.gwt.dom.client.Node refNode)
          Sets the start position to be before the given node.
 void surroundContents(com.google.gwt.dom.client.Node newParent)
          Re-parents the contents of this range to the given node and inserts the node at the position of the start of this range.
 String toHTML()
           
 String toString()
          Returns the contents of this range as a string.
 

Method Detail

cloneContents

DocumentFragment cloneContents()
Duplicates the contents of this range.

Returns:
a DocumentFragment that contains content equivalent to this range

cloneRange

Range cloneRange()
Produces a new Range whose boundary-points are equal to the boundary-points of this range.

Returns:
the duplicated range

collapse

void collapse(boolean toStart)
Collapse this range onto one of its boundary-points.

Parameters:
toStart - if true, collapses this range onto its start; if false, collapses it onto its end.

compareBoundaryPoints

short compareBoundaryPoints(RangeCompare how,
                            Range sourceRange)
Compare the boundary-points of two Ranges in a document.

Parameters:
how - the type of comparison
sourceRange - the range to compared to
Returns:
-1, 0 or 1 depending on whether the corresponding boundary-point of this range is respectively before, equal to, or after the corresponding boundary-point of sourceRange

deleteContents

void deleteContents()
Removes the contents of this range from the containing document or document fragment without returning a reference to the removed content.


detach

void detach()
Called to indicate that this range is no longer in use and that the implementation may relinquish any resources associated with this range.


extractContents

DocumentFragment extractContents()
Moves the contents of this range from the containing document or document fragment to a new DocumentFragment.

Returns:
a DocumentFragment containing the extracted contents

getCommonAncestorContainer

com.google.gwt.dom.client.Node getCommonAncestorContainer()
Returns:
the deepest common ancestor container of this range's two boundary-points

getEndContainer

com.google.gwt.dom.client.Node getEndContainer()
Returns:
the node within which this range ends

getEndOffset

int getEndOffset()
Returns:
the offset within the ending node of this range

getStartContainer

com.google.gwt.dom.client.Node getStartContainer()
Returns:
the node within which this range begins

getStartOffset

int getStartOffset()
Returns:
the offset within the starting node of this range

insertNode

void insertNode(com.google.gwt.dom.client.Node newNode)
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.

Parameters:
newNode - the node to insert at the start of this range.

isCollapsed

boolean isCollapsed()
Returns:
true if this range is collapsed

selectNode

void selectNode(com.google.gwt.dom.client.Node refNode)
Select a node and its contents.

Parameters:
refNode - the node to select

selectNodeContents

void selectNodeContents(com.google.gwt.dom.client.Node refNode)
Select the contents within a node.

Parameters:
refNode - the node to select from

setEnd

void setEnd(com.google.gwt.dom.client.Node refNode,
            int offset)
Sets the attributes describing the end of this range.

Parameters:
refNode - the #endContainer value. This parameter must be different from null.
offset - the #endOffset value

setEndAfter

void setEndAfter(com.google.gwt.dom.client.Node refNode)
Sets the end of this Range to be after the given node.

Parameters:
refNode - the reference node, after which this range will end

setEndBefore

void setEndBefore(com.google.gwt.dom.client.Node refNode)
Sets the end position to be before the given node.

Parameters:
refNode - the reference node, before which this range will end

setStart

void setStart(com.google.gwt.dom.client.Node refNode,
              int offset)
Sets the attributes describing the start of this range.

Parameters:
refNode - the #startContainer value. This parameter must be different from null.
offset - the #startOffset value

setStartAfter

void setStartAfter(com.google.gwt.dom.client.Node refNode)
Sets the start position to be after the given node.

Parameters:
refNode - the reference node, after which this range will start

setStartBefore

void setStartBefore(com.google.gwt.dom.client.Node refNode)
Sets the start position to be before the given node.

Parameters:
refNode - the reference node, before which this range will start

surroundContents

void surroundContents(com.google.gwt.dom.client.Node newParent)
Re-parents the contents of this range to the given node and inserts the node at the position of the start of this range.

Parameters:
newParent - the node to surround the contents with

toHTML

String toHTML()
Returns:
the HTML contents of this range

toString

String toString()
Returns the contents of this range as a string. This string contains only the data characters, not any mark-up.

Overrides:
toString in class Object
Returns:
the contents of this range


Copyright © 2004–2014 XWiki. All rights reserved.