Package org.htmlunit.javascript.host.dom
Class Range
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.dom.AbstractRange
org.htmlunit.javascript.host.dom.Range
- All Implemented Interfaces:
Serializable
,Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
The JavaScript object that represents a Range.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Comparison mode for compareBoundaryPoints.static final int
Comparison mode for compareBoundaryPoints.static final int
Comparison mode for compareBoundaryPoints.static final int
Comparison mode for compareBoundaryPoints.Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
ConstructorsConstructorDescriptionRange()
Creates an instance.Range
(SimpleRange simpleRange) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns a clone of the range in a document fragment.Returns a clone of the range.void
collapse
(boolean toStart) Collapse a Range onto one of its boundaries.compareBoundaryPoints
(int how, Range sourceRange) Compares the boundary points of two Ranges.createContextualFragment
(String valueAsString) Parses an HTML snippet.void
Deletes the contents of the range.void
detach()
Releases Range from use to improve performance.Moves this range's contents from the document tree into a document fragment.Returns an object that bounds the contents of the range.Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client.Returns the deepest common ancestor container of the Range's two boundary points.private static int
getPositionInContainer
(Node refNode) void
insertNode
(Node newNode) Inserts a new node at the beginning of the range.void
JavaScript constructor.Returns the text of the Range.void
selectNode
(Node refNode) Selects a node and its contents.void
selectNodeContents
(Node refNode) Select the contents within a node.void
Sets the attributes describing the end of a Range.void
setEndAfter
(Node refNode) Sets the end of the range to be after the node.void
setEndBefore
(Node refNode) Sets the end of the range to be before the node.void
Sets the attributes describing the start of a Range.void
setStartAfter
(Node refNode) Sets the start of the range to be after the node.void
setStartBefore
(Node refNode) Sets the start of the range to be before the node.void
surroundContents
(Node newNode) Surrounds the contents of the range in a new node.Methods inherited from class org.htmlunit.javascript.host.dom.AbstractRange
equivalentValues, getDefaultValue, getEndContainer, getEndOffset, getSimpleRange, getStartContainer, getStartOffset, internGetEndContainer, internGetEndOffset, internGetStartContainer, internGetStartOffset, internSetEndContainer, internSetEndOffset, internSetStartContainer, internSetStartOffset, isCollapsed
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Field Details
-
START_TO_START
public static final int START_TO_STARTComparison mode for compareBoundaryPoints.- See Also:
-
START_TO_END
public static final int START_TO_ENDComparison mode for compareBoundaryPoints.- See Also:
-
END_TO_END
public static final int END_TO_ENDComparison mode for compareBoundaryPoints.- See Also:
-
END_TO_START
public static final int END_TO_STARTComparison mode for compareBoundaryPoints.- See Also:
-
-
Constructor Details
-
Range
public Range()Creates an instance. -
Range
Creates a new instance.- Parameters:
document
- the HTML document creating the range
-
Range
Range(SimpleRange simpleRange)
-
-
Method Details
-
jsConstructor
public void jsConstructor()JavaScript constructor.- Overrides:
jsConstructor
in classAbstractRange
-
setStart
Sets the attributes describing the start of a Range.- Parameters:
refNode
- the reference nodeoffset
- the offset value within the node
-
setStartAfter
Sets the start of the range to be after the node.- Parameters:
refNode
- the reference node
-
setStartBefore
Sets the start of the range to be before the node.- Parameters:
refNode
- the reference node
-
getPositionInContainer
-
setEnd
Sets the attributes describing the end of a Range.- Parameters:
refNode
- the reference nodeoffset
- the offset value within the node
-
setEndAfter
Sets the end of the range to be after the node.- Parameters:
refNode
- the reference node
-
setEndBefore
Sets the end of the range to be before the node.- Parameters:
refNode
- the reference node
-
selectNodeContents
Select the contents within a node.- Parameters:
refNode
- Node to select from
-
selectNode
Selects a node and its contents.- Parameters:
refNode
- the node to select
-
collapse
public void collapse(boolean toStart) Collapse a Range onto one of its boundaries.- Parameters:
toStart
- iftrue
, collapses the Range onto its start; else collapses it onto its end
-
getCommonAncestorContainer
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
-
createContextualFragment
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:
-
extractContents
Moves this range's contents from the document tree into a document fragment.- Returns:
- the new document fragment containing the range contents
-
compareBoundaryPoints
Compares the boundary points of two Ranges.- Parameters:
how
- a constant describing the comparison methodsourceRange
- the Range to compare boundary points with this range- Returns:
- -1, 0, or 1, indicating whether the corresponding boundary-point of range is respectively before, equal to, or after the corresponding boundary-point of sourceRange.
-
cloneContents
Returns a clone of the range in a document fragment.- Returns:
- a clone
-
deleteContents
public void deleteContents()Deletes the contents of the range. -
insertNode
Inserts a new node at the beginning of the range. If the range begins at an offset, the node is split.- Parameters:
newNode
- The node to insert- See Also:
-
surroundContents
Surrounds the contents of the range in a new node.- Parameters:
newNode
- The node to surround the range in
-
cloneRange
Returns a clone of the range.- Returns:
- a clone of the range
-
detach
public void detach()Releases Range from use to improve performance. -
jsToString
Returns the text of the Range.- Returns:
- the text
-
getClientRects
Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line.- Returns:
- a collection of rectangles that describes the layout of the contents
-
getBoundingClientRect
Returns an object that bounds the contents of the range. this a rectangle enclosing the union of the bounding rectangles for all the elements in the range.- Returns:
- an object the bounds the contents of the range
-