com.gargoylesoftware.htmlunit.javascript.host
Class Selection

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.Selection
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 Selection
extends SimpleScriptable

A JavaScript object for a Selection.

Version:
$Revision: 5864 $
Author:
Ahmed Ashour, Daniel Gredler
See Also:
MSDN Documentation, Gecko DOM Reference, 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
Selection()
           
 
Method Summary
 Object getDefaultValue(Class<?> hint)
          Returns the JavaScript default value of this object.
 void jsxFunction_addRange(Range range)
          Adds a range to the selection.
 void jsxFunction_collapse(Node parentNode, int offset)
          Collapses the current selection to a single point.
 void jsxFunction_collapseToEnd()
          Moves the anchor of the selection to the same point as the focus.
 void jsxFunction_collapseToStart()
          Moves the focus of the selection to the same point at the anchor.
 TextRange jsxFunction_createRange()
          Creates a TextRange object from the current text selection (IE only).
 void jsxFunction_empty()
          Cancels the current selection, sets the selection type to none, and sets the item property to null (IE only).
 void jsxFunction_extend(Node parentNode, int offset)
          Moves the focus of the selection to a specified point.
 Range jsxFunction_getRangeAt(int index)
          Returns the range at the specified index.
 void jsxFunction_removeAllRanges()
          Removes all ranges from the selection.
 void jsxFunction_removeRange(Range range)
          Removes a range from the selection.
 void jsxFunction_selectAllChildren(Node parentNode)
          Adds all the children of the specified node to the selection.
 Node jsxGet_anchorNode()
          Returns the node in which the selection begins.
 int jsxGet_anchorOffset()
          Returns the number of characters that the selection's anchor is offset within the anchor node.
 Node jsxGet_focusNode()
          Returns the node in which the selection ends.
 int jsxGet_focusOffset()
          Returns the number of characters that the selection's focus is offset within the focus node.
 boolean jsxGet_isCollapsed()
          Returns a boolean indicating whether the selection's start and end points are at the same position.
 int jsxGet_rangeCount()
          Returns the number of ranges in the selection.
 String jsxGet_type()
          Returns the type of selection (IE only).
 
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

Selection

public Selection()
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_anchorNode

public Node jsxGet_anchorNode()
Returns the node in which the selection begins.

Returns:
the node in which the selection begins

jsxGet_anchorOffset

public int jsxGet_anchorOffset()
Returns the number of characters that the selection's anchor is offset within the anchor node.

Returns:
the number of characters that the selection's anchor is offset within the anchor node

jsxGet_focusNode

public Node jsxGet_focusNode()
Returns the node in which the selection ends.

Returns:
the node in which the selection ends

jsxGet_focusOffset

public int jsxGet_focusOffset()
Returns the number of characters that the selection's focus is offset within the focus node.

Returns:
the number of characters that the selection's focus is offset within the focus node

jsxGet_isCollapsed

public boolean jsxGet_isCollapsed()
Returns a boolean indicating whether the selection's start and end points are at the same position.

Returns:
a boolean indicating whether the selection's start and end points are at the same position

jsxGet_rangeCount

public int jsxGet_rangeCount()
Returns the number of ranges in the selection.

Returns:
the number of ranges in the selection

jsxGet_type

public String jsxGet_type()
Returns the type of selection (IE only).

Returns:
the type of selection

jsxFunction_createRange

public TextRange jsxFunction_createRange()
Creates a TextRange object from the current text selection (IE only).

Returns:
the created TextRange object

jsxFunction_addRange

public void jsxFunction_addRange(Range range)
Adds a range to the selection.

Parameters:
range - the range to add

jsxFunction_removeRange

public void jsxFunction_removeRange(Range range)
Removes a range from the selection.

Parameters:
range - the range to remove

jsxFunction_removeAllRanges

public void jsxFunction_removeAllRanges()
Removes all ranges from the selection.


jsxFunction_getRangeAt

public Range jsxFunction_getRangeAt(int index)
Returns the range at the specified index.

Parameters:
index - the index of the range to return
Returns:
the range at the specified index

jsxFunction_collapse

public void jsxFunction_collapse(Node parentNode,
                                 int offset)
Collapses the current selection to a single point. The document is not modified.

Parameters:
parentNode - the caret location will be within this node
offset - the caret will be placed this number of characters from the beginning of the parentNode's text

jsxFunction_collapseToEnd

public void jsxFunction_collapseToEnd()
Moves the anchor of the selection to the same point as the focus. The focus does not move.


jsxFunction_collapseToStart

public void jsxFunction_collapseToStart()
Moves the focus of the selection to the same point at the anchor. The anchor does not move.


jsxFunction_empty

public void jsxFunction_empty()
Cancels the current selection, sets the selection type to none, and sets the item property to null (IE only).


jsxFunction_extend

public void jsxFunction_extend(Node parentNode,
                               int offset)
Moves the focus of the selection to a specified point. The anchor of the selection does not move.

Parameters:
parentNode - the node within which the focus will be moved
offset - the number of characters from the beginning of parentNode's text the focus will be placed

jsxFunction_selectAllChildren

public void jsxFunction_selectAllChildren(Node parentNode)
Adds all the children of the specified node to the selection. The previous selection is lost.

Parameters:
parentNode - all children of parentNode will be selected; parentNode itself is not part of the selection


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