JavaScript is disabled on your browser.
Skip navigation links
org.htmlunit.html.impl

Class SimpleRange

  • All Implemented Interfaces:
    Serializable


    public class SimpleRange
    extends Object
    implements Serializable 
    Simple implementation of an Range.
    Author:
    Marc Guillemot, Daniel Gredler, James Phillpotts, Ahmed Ashour, Ronald Brill
    See Also:
    Serialized Form
    • Constructor Detail

      • SimpleRange

        public SimpleRange()
        Constructs a range without any content.
      • SimpleRange

        public SimpleRange(DomNode node)
        Constructs a range for the specified element.
        Parameters:
        node - the node for the range
      • SimpleRange

        public SimpleRange(DomNode node,
         int offset)
        Constructs a range for the provided element and start and end offset.
        Parameters:
        node - the node for the range
        offset - the start and end offset
      • SimpleRange

        public SimpleRange(DomNode startNode,
         int startOffset,
         DomNode endNode,
         int endOffset)
        Constructs a range for the provided elements and offsets.
        Parameters:
        startNode - the start node
        startOffset - the start offset
        endNode - the end node
        endOffset - the end offset
    • Method Detail

      • cloneContents

        public DomDocumentFragment cloneContents()
        Duplicates the contents of this.
        Returns:
        DocumentFragment that contains content equivalent to this
      • cloneRange

        public SimpleRange cloneRange()
        Produces a new SimpleRange whose boundary-points are equal to the boundary-points of this.
        Returns:
        duplicated simple
      • collapse

        public void collapse(boolean toStart)
        Collapse this range onto one of its boundary-points.
        Parameters:
        toStart - if true, collapses the Range onto its start; else collapses it onto its end.
      • 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 DomDocumentFragment extractContents()
         throws DOMException 
        Moves the contents of a Range from the containing document or document fragment to a new DocumentFragment.
        Returns:
        DocumentFragment containing the extracted contents
        Throws:
        DOMException - in case of error
      • isCollapsed

        public boolean isCollapsed()
         throws DOMException 
        Returns:
        true if startContainer equals endContainer and startOffset equals endOffset
        Throws:
        DOMException - in case of error
      • getCommonAncestorContainer

        public DomNode getCommonAncestorContainer()
         throws DOMException 
        Returns:
        the deepest common ancestor container of this range's two boundary-points.
        Throws:
        DOMException - in case of error
      • getEndContainer

        public DomNode getEndContainer()
        Returns:
        the Node within which this range ends
      • getEndOffset

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

        public DomNode getStartContainer()
        Returns:
        the Node within which this range begins
      • getStartOffset

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

        public void insertNode(DomNode 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 the Range
      • selectNode

        public void selectNode(DomNode node)
        Select a node and its contents.
        Parameters:
        node - The node to select.
      • selectNodeContents

        public void selectNodeContents(DomNode node)
        Select the contents within a node.
        Parameters:
        node - Node to select from
      • setEnd

        public void setEnd(DomNode refNode,
         int offset)
        Sets the attributes describing the end.
        Parameters:
        refNode - the refNode
        offset - offset
      • setStart

        public void setStart(DomNode refNode,
         int offset)
        Sets the attributes describing the start.
        Parameters:
        refNode - the refNode
        offset - offset
      • surroundContents

        public void surroundContents(DomNode newParent)
        Reparents the contents of the Range to the given node and inserts the node at the position of the start of the Range.
        Parameters:
        newParent - The node to surround the contents with.
      • containedNodes

        public List<DomNode> containedNodes()
        Returns:
        a list with all nodes contained in this range
Skip navigation links

Copyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /