michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "domstubs.idl" michael@0: michael@0: /** michael@0: * The nsIDOMRange interface is an interface to a DOM range object. michael@0: * michael@0: * For more information on this interface please see michael@0: * http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ michael@0: */ michael@0: michael@0: [scriptable, builtinclass, uuid(1f94055c-42e7-4a30-96a1-6a804f1c2d1e)] michael@0: interface nsIDOMRange : nsISupports michael@0: { michael@0: readonly attribute nsIDOMNode startContainer; michael@0: readonly attribute long startOffset; michael@0: readonly attribute nsIDOMNode endContainer; michael@0: readonly attribute long endOffset; michael@0: readonly attribute boolean collapsed; michael@0: readonly attribute nsIDOMNode commonAncestorContainer; michael@0: michael@0: void setStart(in nsIDOMNode refNode, in long offset); michael@0: void setEnd(in nsIDOMNode refNode, in long offset); michael@0: void setStartBefore(in nsIDOMNode refNode); michael@0: void setStartAfter(in nsIDOMNode refNode); michael@0: void setEndBefore(in nsIDOMNode refNode); michael@0: void setEndAfter(in nsIDOMNode refNode); michael@0: void collapse(in boolean toStart); michael@0: void selectNode(in nsIDOMNode refNode); michael@0: void selectNodeContents(in nsIDOMNode refNode); michael@0: michael@0: // CompareHow michael@0: const unsigned short START_TO_START = 0; michael@0: const unsigned short START_TO_END = 1; michael@0: const unsigned short END_TO_END = 2; michael@0: const unsigned short END_TO_START = 3; michael@0: michael@0: short compareBoundaryPoints(in unsigned short how, michael@0: in nsIDOMRange sourceRange); michael@0: void deleteContents(); michael@0: nsIDOMDocumentFragment extractContents(); michael@0: nsIDOMDocumentFragment cloneContents(); michael@0: void insertNode(in nsIDOMNode newNode); michael@0: void surroundContents(in nsIDOMNode newParent); michael@0: nsIDOMRange cloneRange(); michael@0: DOMString toString(); michael@0: void detach(); michael@0: michael@0: // This method comes from michael@0: // http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface michael@0: nsIDOMDocumentFragment createContextualFragment(in DOMString fragment); michael@0: michael@0: // This returns true if parent+offset equals either michael@0: // of the boundary points or is between them. michael@0: boolean isPointInRange(in nsIDOMNode parent, michael@0: in long offset); michael@0: michael@0: // comparePoint returns michael@0: // -1 if point is before the start boundary point, michael@0: // 0 if point is either of the boundary points or between them, michael@0: // 1 if point is after the end boundary point. michael@0: // Sort of a strcmp for ranges. michael@0: short comparePoint(in nsIDOMNode parent, in long offset); michael@0: michael@0: /** michael@0: * Returns whether the range intersects node. michael@0: */ michael@0: boolean intersectsNode(in nsIDOMNode node); michael@0: michael@0: // These methods come from michael@0: // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface michael@0: nsIDOMClientRectList getClientRects(); michael@0: nsIDOMClientRect getBoundingClientRect(); michael@0: };