/*
 * Copyright (C) 2006 Apple Computer, Inc.
 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

module core {

    interface [GenerateConstructor] DOMImplementation {

        // DOM Level 1

        [OldStyleObjC] boolean hasFeature(in DOMString feature, 
                                          in [ConvertNullToNullString] DOMString version);

        // DOM Level 2

        [OldStyleObjC] DocumentType createDocumentType(in DOMString qualifiedName,
                                                       in DOMString publicId,
                                                       in DOMString systemId)
            raises(DOMException);
        [OldStyleObjC] Document createDocument(in [ConvertNullToNullString] DOMString namespaceURI, 
                                               in [ConvertNullToNullString] DOMString qualifiedName, 
                                               in [ConvertNullToNullString] DocumentType doctype)
            raises(DOMException);

        // DOMImplementationCSS interface from DOM Level 2 CSS

        [OldStyleObjC] CSSStyleSheet createCSSStyleSheet(in DOMString title,
                                                         in DOMString media)
            raises(DOMException);

        // HTMLDOMImplementation interface from DOM Level 2 HTML

        HTMLDocument createHTMLDocument(in DOMString title);
    };

}
