Range.webidl (3634B)
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 file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * http://dom.spec.whatwg.org/#range 8 * http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment 9 * http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface 10 * 11 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 12 * liability, trademark and document use rules apply. 13 */ 14 15 // Use ProbablyShortLivingWrapper so that the Range object could be deleted 16 // as soon as possible, and thus slow down DOM operations less. 17 [Exposed=Window, ProbablyShortLivingWrapper] 18 interface Range : AbstractRange { 19 [Throws] 20 constructor(); 21 22 [Throws] 23 readonly attribute Node commonAncestorContainer; 24 25 [Throws, BinaryName="setStartJS"] 26 undefined setStart(Node refNode, unsigned long offset); 27 [Throws, BinaryName="setEndJS"] 28 undefined setEnd(Node refNode, unsigned long offset); 29 [Throws, BinaryName="setStartBeforeJS"] 30 undefined setStartBefore(Node refNode); 31 [Throws, BinaryName="setStartAfterJS"] 32 undefined setStartAfter(Node refNode); 33 [Throws, BinaryName="setEndBeforeJS"] 34 undefined setEndBefore(Node refNode); 35 [Throws, BinaryName="setEndAfterJS"] 36 undefined setEndAfter(Node refNode); 37 [BinaryName="collapseJS"] 38 undefined collapse(optional boolean toStart = false); 39 [Throws, BinaryName="selectNodeJS"] 40 undefined selectNode(Node refNode); 41 [Throws, BinaryName="selectNodeContentsJS"] 42 undefined selectNodeContents(Node refNode); 43 44 const unsigned short START_TO_START = 0; 45 const unsigned short START_TO_END = 1; 46 const unsigned short END_TO_END = 2; 47 const unsigned short END_TO_START = 3; 48 [Throws] 49 short compareBoundaryPoints(unsigned short how, Range sourceRange); 50 [CEReactions, Throws] 51 undefined deleteContents(); 52 [CEReactions, Throws] 53 DocumentFragment extractContents(); 54 [CEReactions, Throws] 55 DocumentFragment cloneContents(); 56 [CEReactions, Throws] 57 undefined insertNode(Node node); 58 [CEReactions, Throws] 59 undefined surroundContents(Node newParent); 60 61 Range cloneRange(); 62 undefined detach(); 63 64 [Throws] 65 boolean isPointInRange(Node node, unsigned long offset); 66 [Throws] 67 short comparePoint(Node node, unsigned long offset); 68 69 [Throws] 70 boolean intersectsNode(Node node); 71 72 [Throws, BinaryName="ToString"] 73 stringifier; 74 }; 75 76 // http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment 77 partial interface Range { 78 [CEReactions, NeedsSubjectPrincipal=NonSystem, Throws, UseCounter] 79 DocumentFragment createContextualFragment((TrustedHTML or DOMString) fragment); 80 }; 81 82 // http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface 83 partial interface Range { 84 DOMRectList? getClientRects(); 85 [ChromeOnly] DOMRectList? getAllowCrossShadowBoundaryClientRects(); 86 DOMRect getBoundingClientRect(); 87 }; 88 89 dictionary ClientRectsAndTexts { 90 required DOMRectList rectList; 91 required sequence<DOMString> textList; 92 }; 93 94 partial interface Range { 95 [ChromeOnly, Throws] 96 ClientRectsAndTexts getClientRectsAndTexts(); 97 }; 98 99 // ChromeOnly methods that allow setting Range boundaries to cross 100 // shadow boundary. 101 partial interface Range { 102 [ChromeOnly, Throws] 103 undefined setStartAllowCrossShadowBoundary(Node refNode, unsigned long offset); 104 [ChromeOnly, Throws] 105 undefined setEndAllowCrossShadowBoundary(Node refNode, unsigned long offset); 106 };