com.gargoylesoftware.htmlunit.javascript.host
Class Range

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Range
All Implemented Interfaces:
Serializable, Cloneable, Map, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class Range
extends SimpleScriptable

The JavaScript object that represents a Range.

Version:
$Revision: 5564 $
Author:
Marc Guillemot, Ahmed Ashour, Daniel Gredler
See Also:
XULPlanet, DOM-Level-2-Traversal-Range, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Range()
          Creates a new instance.
Range(HTMLDocument document)
          Creates a new instance.
 
Method Summary
 Object getDefaultValue(Class<?> hint)
          Returns the JavaScript default value of this object.
 void jsxFunction_collapse(boolean toStart)
          Collapse a Range onto one of its boundaries.
 Object jsxFunction_createContextualFragment(String valueAsString)
          Parses an HTML snippet.
 Object jsxFunction_extractContents()
          Moves this range's contents from the document tree into a document fragment.
 void jsxFunction_selectNode(Node refNode)
          Selects a node and its contents.
 void jsxFunction_selectNodeContents(Node refNode)
          Select the contents within a node.
 void jsxFunction_setEnd(Node refNode, int offset)
          Sets the attributes describing the end of a Range.
 void jsxFunction_setEndAfter(Node refNode)
          Sets the end of the range to be after the node.
 void jsxFunction_setEndBefore(Node refNode)
          Sets the end of the range to be before the node.
 void jsxFunction_setStart(Node refNode, int offset)
          Sets the attributes describing the start of a Range.
 void jsxFunction_setStartAfter(Node refNode)
          Sets the start of the range to be after the node.
 void jsxFunction_setStartBefore(Node refNode)
          Sets the start of the range to be before the node.
 boolean jsxGet_collapsed()
          Indicates if the range is collapsed.
 Object jsxGet_commonAncestorContainer()
          Returns the deepest common ancestor container of the Range's two boundary points.
 Object jsxGet_endContainer()
          Gets the node within which the Range ends.
 int jsxGet_endOffset()
          Gets the offset within the end node of the Range.
 Object jsxGet_startContainer()
          Gets the node within which the Range begins.
 int jsxGet_startOffset()
          Gets the offset within the starting node of the Range.
 SimpleRange toW3C()
          Returns a W3C Range version of this object.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, keySet, preventExtensions, put, put, put, putAll, putConst, putConstProperty, putProperty, putProperty, redefineProperty, remove, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size, values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Range

public Range()
Creates a new instance.


Range

public Range(HTMLDocument document)
Creates a new instance.

Parameters:
document - the HTML document creating the range
Method Detail

getDefaultValue

public Object getDefaultValue(Class<?> hint)
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.

Specified by:
getDefaultValue in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
getDefaultValue in class SimpleScriptable
Parameters:
hint - a hint as to the format of the default value (ignored in this case)
Returns:
the default value

jsxGet_startContainer

public Object jsxGet_startContainer()
Gets the node within which the Range begins.

Returns:
undefined if not initialized

jsxGet_endContainer

public Object jsxGet_endContainer()
Gets the node within which the Range ends.

Returns:
undefined if not initialized

jsxGet_startOffset

public int jsxGet_startOffset()
Gets the offset within the starting node of the Range.

Returns:
0 if not initialized

jsxGet_endOffset

public int jsxGet_endOffset()
Gets the offset within the end node of the Range.

Returns:
0 if not initialized

jsxFunction_setStart

public void jsxFunction_setStart(Node refNode,
                                 int offset)
Sets the attributes describing the start of a Range.

Parameters:
refNode - the reference node
offset - the offset value within the node

jsxFunction_setStartAfter

public void jsxFunction_setStartAfter(Node refNode)
Sets the start of the range to be after the node.

Parameters:
refNode - the reference node

jsxFunction_setStartBefore

public void jsxFunction_setStartBefore(Node refNode)
Sets the start of the range to be before the node.

Parameters:
refNode - the reference node

jsxGet_collapsed

public boolean jsxGet_collapsed()
Indicates if the range is collapsed.

Returns:
true if the range is collapsed

jsxFunction_setEnd

public void jsxFunction_setEnd(Node refNode,
                               int offset)
Sets the attributes describing the end of a Range.

Parameters:
refNode - the reference node
offset - the offset value within the node

jsxFunction_setEndAfter

public void jsxFunction_setEndAfter(Node refNode)
Sets the end of the range to be after the node.

Parameters:
refNode - the reference node

jsxFunction_setEndBefore

public void jsxFunction_setEndBefore(Node refNode)
Sets the end of the range to be before the node.

Parameters:
refNode - the reference node

jsxFunction_selectNodeContents

public void jsxFunction_selectNodeContents(Node refNode)
Select the contents within a node.

Parameters:
refNode - Node to select from

jsxFunction_selectNode

public void jsxFunction_selectNode(Node refNode)
Selects a node and its contents.

Parameters:
refNode - the node to select

jsxFunction_collapse

public void jsxFunction_collapse(boolean toStart)
Collapse a Range onto one of its boundaries.

Parameters:
toStart - if true, collapses the Range onto its start; else collapses it onto its end

jsxGet_commonAncestorContainer

public Object jsxGet_commonAncestorContainer()
Returns the deepest common ancestor container of the Range's two boundary points.

Returns:
the deepest common ancestor container of the Range's two boundary points

jsxFunction_createContextualFragment

public Object jsxFunction_createContextualFragment(String valueAsString)
Parses an HTML snippet.

Parameters:
valueAsString - text that contains text and tags to be converted to a document fragment
Returns:
a document fragment
See Also:
Mozilla documentation

jsxFunction_extractContents

public Object jsxFunction_extractContents()
Moves this range's contents from the document tree into a document fragment.

Returns:
the new document fragment containing the range contents

toW3C

public SimpleRange toW3C()
Returns a W3C Range version of this object.

Returns:
a W3C Range version of this object


Copyright © 2002-2011 Gargoyle Software Inc.. All Rights Reserved.