153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)/*
253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * Copyright (C) 2006 Apple Computer, Inc.
353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) *
553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * This library is free software; you can redistribute it and/or
653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * modify it under the terms of the GNU Library General Public
753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * License as published by the Free Software Foundation; either
853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * version 2 of the License, or (at your option) any later version.
953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) *
1053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * This library is distributed in the hope that it will be useful,
1153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of
1253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * Library General Public License for more details.
1453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) *
1553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * You should have received a copy of the GNU Library General Public License
1653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * along with this library; see the file COPYING.LIB.  If not, write to
1753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * Boston, MA 02110-1301, USA.
1953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) */
2053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
2153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// Introduced in DOM Level 2:
2253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)[
2381a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    Constructor,
24a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    ConstructorCallWith=Document,
25a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch    WillBeGarbageCollected,
2653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)] interface Range {
2753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
28f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute Node startContainer;
29f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute long startOffset;
30f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute Node endContainer;
31f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute long endOffset;
32f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute boolean collapsed;
33f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    readonly attribute Node commonAncestorContainer;
3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
35a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setStart(Node refNode, long offset);
36a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setEnd(Node refNode, long offset);
37a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setStartBefore(Node refNode);
38a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setStartAfter(Node refNode);
39a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setEndBefore(Node refNode);
40a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void setEndAfter(Node refNode);
41197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    void collapse(optional boolean toStart = false);
42a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void selectNode(Node refNode);
43a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] void selectNodeContents(Node refNode);
4453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
4553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // CompareHow
4653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short START_TO_START = 0;
4753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short START_TO_END   = 1;
4853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short END_TO_END     = 2;
4953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short END_TO_START   = 3;
5053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    [RaisesException, TypeChecking=Interface] short compareBoundaryPoints(unsigned short how, Range sourceRange);
5253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
531e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    [RaisesException, CustomElementCallbacks] void deleteContents();
541e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    [RaisesException, CustomElementCallbacks] DocumentFragment extractContents();
551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    [RaisesException, CustomElementCallbacks] DocumentFragment cloneContents();
56a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException, CustomElementCallbacks] void insertNode(Node newNode);
57a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException, CustomElementCallbacks] void surroundContents(Node newParent);
58f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    Range cloneRange();
59197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
60197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    stringifier;
6153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
62f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    [DeprecateAs=RangeDetach] void detach();
6353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
64a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] boolean isPointInRange(Node refNode, long offset);
65c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    [RaisesException, TypeChecking=Interface] short comparePoint(Node refNode, long offset);
66a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
67a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException] boolean intersectsNode(Node refNode);
68a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
6953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // CSSOM View Module API extensions
7053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
7153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    ClientRectList getClientRects();
7253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    ClientRect getBoundingClientRect();
7353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
74a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    // DOM Parsing and Serialization
7553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
76a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    [RaisesException, CustomElementCallbacks] DocumentFragment createContextualFragment(DOMString html);
7753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
7853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // WebKit extensions
7953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
8053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    // CompareResults
8153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short NODE_BEFORE           = 0;
8253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short NODE_AFTER            = 1;
8353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short NODE_BEFORE_AND_AFTER = 2;
8453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const unsigned short NODE_INSIDE           = 3;
8553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
86323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    [RaisesException, MeasureAs=RangeCompareNode] short compareNode([Default=Undefined] optional Node refNode);
8753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
88323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    [RaisesException, MeasureAs=RangeExpand] void expand([Default=Undefined] optional DOMString unit);
8953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)};
90