JavaScript is disabled on your browser.
Skip navigation links
org.htmlunit.javascript.host.dom

Class Range

    • Field Detail

      • START_TO_START

        public static final int START_TO_START
        Comparison mode for compareBoundaryPoints.
        See Also:
        Constant Field Values
      • START_TO_END

        public static final int START_TO_END
        Comparison mode for compareBoundaryPoints.
        See Also:
        Constant Field Values
      • END_TO_END

        public static final int END_TO_END
        Comparison mode for compareBoundaryPoints.
        See Also:
        Constant Field Values
      • END_TO_START

        public static final int END_TO_START
        Comparison mode for compareBoundaryPoints.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Range

        public Range()
        Creates an instance.
      • Range

        public Range(Document document)
        Creates a new instance.
        Parameters:
        document - the HTML document creating the range
    • Method Detail

      • setStart

        public void 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
      • setStartAfter

        public void setStartAfter(Node refNode)
        Sets the start of the range to be after the node.
        Parameters:
        refNode - the reference node
      • setStartBefore

        public void setStartBefore(Node refNode)
        Sets the start of the range to be before the node.
        Parameters:
        refNode - the reference node
      • setEnd

        public void 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
      • setEndAfter

        public void setEndAfter(Node refNode)
        Sets the end of the range to be after the node.
        Parameters:
        refNode - the reference node
      • setEndBefore

        public void setEndBefore(Node refNode)
        Sets the end of the range to be before the node.
        Parameters:
        refNode - the reference node
      • selectNodeContents

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

        public void selectNode(Node refNode)
        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 - if true, collapses the Range onto its start; else collapses it onto its end
      • getCommonAncestorContainer

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

        public HtmlUnitScriptable 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
      • extractContents

        public HtmlUnitScriptable extractContents()
        Moves this range's contents from the document tree into a document fragment.
        Returns:
        the new document fragment containing the range contents
      • compareBoundaryPoints

        public int compareBoundaryPoints(int how,
         Range sourceRange)
        Compares the boundary points of two Ranges.
        Parameters:
        how - a constant describing the comparison method
        sourceRange - 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

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

        public void insertNode(Node newNode)
        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:
        https://developer.mozilla.org/en/DOM/range
      • surroundContents

        public void surroundContents(Node newNode)
        Surrounds the contents of the range in a new node.
        Parameters:
        newNode - The node to surround the range in
      • cloneRange

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

        public String jsToString()
        Returns the text of the Range.
        Returns:
        the text
      • getClientRects

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

        public DOMRect 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
Skip navigation links

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

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