/*
 * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#ifndef DO_NO_IMPORTS
import "oaidl.idl";
import "ocidl.idl";
import "DOMCore.idl";
#endif

interface IDOMNode;
interface IDOMDocumentFragment;

typedef enum _WebSelectionAffinity {
   WebSelectionAffinityUpstream = 0,
   WebSelectionAffinityDownstream = 1
} WebSelectionAffinity;

enum {
    //
    // DOM range exception codes
    //
    DOM_BAD_BOUNDARYPOINTS_ERR        = 1,
    DOM_INVALID_NODE_TYPE_ERR         = 2,
};

enum {
    //
    // DOM Range comparison codes
    //
    DOM_START_TO_START                = 0,
    DOM_START_TO_END                  = 1,
    DOM_END_TO_END                    = 2,
    DOM_END_TO_START                  = 3,
};

/*
    @interface DOMRange : DOMObject
*/
[
    object,
    oleautomation,
    uuid(2F33E42C-0B39-48b3-B7B6-E910CDB325AD),
    pointer_default(unique)
]
interface IDOMRange : IDOMObject
{
    /*
        - (DOMNode *)startContainer;
    */
    HRESULT startContainer([out, retval] IDOMNode** node);

    /*
        - (int)startOffset;
    */
    HRESULT startOffset([out, retval] int* offset);

    /*
        - (DOMNode *)endContainer;
    */
    HRESULT endContainer([out, retval] IDOMNode** node);

    /*
        - (int)endOffset;
    */
    HRESULT endOffset([out, retval] int* offset);

    /*
        - (BOOL)collapsed;
    */
    HRESULT collapsed([out, retval] BOOL* result);

    /*
        - (DOMNode *)commonAncestorContainer;
    */
    HRESULT commonAncestorContainer([out, retval] IDOMNode** container);

    /*
        - (void)setStart:(DOMNode *)refNode :(int)offset;
    */
    HRESULT setStart([in] IDOMNode* refNode, [in] int offset);

    /*
        - (void)setEnd:(DOMNode *)refNode :(int)offset;
    */
    HRESULT setEnd([in] IDOMNode* refNode, [in] int offset);

    /*
        - (void)setStartBefore:(DOMNode *)refNode;
    */
    HRESULT setStartBefore([in] IDOMNode* refNode);

    /*
        - (void)setStartAfter:(DOMNode *)refNode;
    */
    HRESULT setStartAfter([in] IDOMNode* refNode);

    /*
        - (void)setEndBefore:(DOMNode *)refNode;
    */
    HRESULT setEndBefore([in] IDOMNode* refNode);

    /*
        - (void)setEndAfter:(DOMNode *)refNode;
    */
    HRESULT setEndAfter([in] IDOMNode* refNode);

    /*
        - (void)collapse:(BOOL)toStart;
    */
    HRESULT collapse([in] BOOL toStart);

    /*
        - (void)selectNode:(DOMNode *)refNode;
    */
    HRESULT selectNode([in] IDOMNode* refNode);

    /*
        - (void)selectNodeContents:(DOMNode *)refNode;
    */
    HRESULT selectNodeContents([in] IDOMNode* refNode);

    /*
        - (short)compareBoundaryPoints:(unsigned short)how :(DOMRange *)sourceRange;
    */
    HRESULT compareBoundaryPoints([in] unsigned short how, [in] IDOMRange* sourceRange);

    /*
        - (void)deleteContents;
    */
    HRESULT deleteContents();

    /*
        - (DOMDocumentFragment *)extractContents;
    */
    HRESULT extractContents([out, retval] IDOMDocumentFragment** fragment);

    /*
        - (DOMDocumentFragment *)cloneContents;
    */
    HRESULT cloneContents([out, retval] IDOMDocumentFragment** fragment);

    /*
        - (void)insertNode:(DOMNode *)newNode;
    */
    HRESULT insertNode([in] IDOMNode* newNode);

    /*
        - (void)surroundContents:(DOMNode *)newParent;
    */
    HRESULT surroundContents([in] IDOMNode* newParent);

    /*
        - (DOMRange *)cloneRange;
    */
    HRESULT cloneRange([out, retval] IDOMRange** range);

    /*
        - (NSString *)toString;
    */
    HRESULT toString([out, retval] BSTR* str);

    /*
        - (void)detach;
    */
    HRESULT detach();
}
