|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "domstubs.idl" |
|
7 |
|
8 /** |
|
9 * The nsIDOMRange interface is an interface to a DOM range object. |
|
10 * |
|
11 * For more information on this interface please see |
|
12 * http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ |
|
13 */ |
|
14 |
|
15 [scriptable, builtinclass, uuid(1f94055c-42e7-4a30-96a1-6a804f1c2d1e)] |
|
16 interface nsIDOMRange : nsISupports |
|
17 { |
|
18 readonly attribute nsIDOMNode startContainer; |
|
19 readonly attribute long startOffset; |
|
20 readonly attribute nsIDOMNode endContainer; |
|
21 readonly attribute long endOffset; |
|
22 readonly attribute boolean collapsed; |
|
23 readonly attribute nsIDOMNode commonAncestorContainer; |
|
24 |
|
25 void setStart(in nsIDOMNode refNode, in long offset); |
|
26 void setEnd(in nsIDOMNode refNode, in long offset); |
|
27 void setStartBefore(in nsIDOMNode refNode); |
|
28 void setStartAfter(in nsIDOMNode refNode); |
|
29 void setEndBefore(in nsIDOMNode refNode); |
|
30 void setEndAfter(in nsIDOMNode refNode); |
|
31 void collapse(in boolean toStart); |
|
32 void selectNode(in nsIDOMNode refNode); |
|
33 void selectNodeContents(in nsIDOMNode refNode); |
|
34 |
|
35 // CompareHow |
|
36 const unsigned short START_TO_START = 0; |
|
37 const unsigned short START_TO_END = 1; |
|
38 const unsigned short END_TO_END = 2; |
|
39 const unsigned short END_TO_START = 3; |
|
40 |
|
41 short compareBoundaryPoints(in unsigned short how, |
|
42 in nsIDOMRange sourceRange); |
|
43 void deleteContents(); |
|
44 nsIDOMDocumentFragment extractContents(); |
|
45 nsIDOMDocumentFragment cloneContents(); |
|
46 void insertNode(in nsIDOMNode newNode); |
|
47 void surroundContents(in nsIDOMNode newParent); |
|
48 nsIDOMRange cloneRange(); |
|
49 DOMString toString(); |
|
50 void detach(); |
|
51 |
|
52 // This method comes from |
|
53 // http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface |
|
54 nsIDOMDocumentFragment createContextualFragment(in DOMString fragment); |
|
55 |
|
56 // This returns true if parent+offset equals either |
|
57 // of the boundary points or is between them. |
|
58 boolean isPointInRange(in nsIDOMNode parent, |
|
59 in long offset); |
|
60 |
|
61 // comparePoint returns |
|
62 // -1 if point is before the start boundary point, |
|
63 // 0 if point is either of the boundary points or between them, |
|
64 // 1 if point is after the end boundary point. |
|
65 // Sort of a strcmp for ranges. |
|
66 short comparePoint(in nsIDOMNode parent, in long offset); |
|
67 |
|
68 /** |
|
69 * Returns whether the range intersects node. |
|
70 */ |
|
71 boolean intersectsNode(in nsIDOMNode node); |
|
72 |
|
73 // These methods come from |
|
74 // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface |
|
75 nsIDOMClientRectList getClientRects(); |
|
76 nsIDOMClientRect getBoundingClientRect(); |
|
77 }; |