org.xwiki.gwt.dom.client.internal.mozilla
Class NativeRange

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by org.xwiki.gwt.dom.client.JavaScriptObject
          extended by org.xwiki.gwt.dom.client.internal.mozilla.NativeRange

public final class NativeRange
extends JavaScriptObject

The native range implementation for browsers that follow the W3C Range specification.

Version:
$Id: NativeRange.java 20039 2009-05-16 12:04:30Z sdumitriu $

Constructor Summary
protected NativeRange()
          Default constructor.
 
Method Summary
 DocumentFragment cloneContents()
          Duplicates the contents of this range.
 NativeRange 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(int how, NativeRange 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()
           
static NativeRange newInstance(Document document)
          Creates a new native range using the given document.
 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.
 
Methods inherited from class org.xwiki.gwt.dom.client.JavaScriptObject
fromJson, get, getKeys, remove, set
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NativeRange

protected NativeRange()
Default constructor. Needs to be protected because all instances are created from JavaScript.

Method Detail

newInstance

public static NativeRange newInstance(Document document)
Creates a new native range using the given document.

Parameters:
document - the document to use for creating the new native range
Returns:
the newly created native range

isCollapsed

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

getCommonAncestorContainer

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

getEndContainer

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

getEndOffset

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

getStartContainer

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

getStartOffset

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

setStart

public 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

setEnd

public 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

setStartBefore

public 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

setStartAfter

public 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

setEndBefore

public 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

setEndAfter

public 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

selectNode

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

Parameters:
refNode - the node to select

selectNodeContents

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

Parameters:
refNode - the node to select from

collapse

public 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.

cloneContents

public DocumentFragment cloneContents()
Duplicates the contents of this range.

Returns:
a DocumentFragment that contains content equivalent to this range

deleteContents

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


extractContents

public 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

insertNode

public 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.

surroundContents

public 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

compareBoundaryPoints

public short compareBoundaryPoints(int how,
                                   NativeRange 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

cloneRange

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

Returns:
the duplicated range

detach

public 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.



Copyright © 2004-2009 XWiki. All Rights Reserved.