/*
 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
 * 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., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

module core {

    interface [
        GenerateNativeConverter,
        InlineGetOwnPropertySlot
    ] Element : Node {

        // DOM Level 1 Core

        readonly attribute [ConvertNullStringTo=Null] DOMString tagName;

        [ConvertNullStringTo=Null] DOMString getAttribute(in [Optional=CallWithDefaultValue] DOMString name);
        [OldStyleObjC] void setAttribute(in [Optional=CallWithDefaultValue] DOMString name,
                                         in [Optional=CallWithDefaultValue] DOMString value)
            raises(DOMException);
        void removeAttribute(in [Optional=CallWithDefaultValue] DOMString name)
            raises(DOMException);
        Attr getAttributeNode(in [Optional=CallWithDefaultValue] DOMString name);
        Attr setAttributeNode(in [Optional=CallWithDefaultValue] Attr newAttr)
            raises(DOMException);
        Attr removeAttributeNode(in [Optional=CallWithDefaultValue] Attr oldAttr)
            raises(DOMException);
        NodeList getElementsByTagName(in [Optional=CallWithDefaultValue] DOMString name);

        // DOM Level 2 Core

        [OldStyleObjC] DOMString getAttributeNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
                                                in [Optional=CallWithDefaultValue] DOMString localName);
        [OldStyleObjC] void setAttributeNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
                                           in [Optional=CallWithDefaultValue] DOMString qualifiedName, 
                                           in [Optional=CallWithDefaultValue] DOMString value)
            raises(DOMException);
        [OldStyleObjC] void removeAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
                                              in DOMString localName)
            raises(DOMException);
        [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
                                                       in [Optional=CallWithDefaultValue] DOMString localName);
        [OldStyleObjC] Attr getAttributeNodeNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
                                               in [Optional=CallWithDefaultValue] DOMString localName);
        Attr setAttributeNodeNS(in [Optional=CallWithDefaultValue] Attr newAttr)
            raises(DOMException);
        boolean hasAttribute(in DOMString name);
        [OldStyleObjC] boolean hasAttributeNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
                                              in [Optional=CallWithDefaultValue] DOMString localName);

        readonly attribute CSSStyleDeclaration style;

        // Common extensions

        readonly attribute long offsetLeft;
        readonly attribute long offsetTop;
        readonly attribute long offsetWidth;
        readonly attribute long offsetHeight;
        readonly attribute Element offsetParent;
        readonly attribute long clientLeft;
        readonly attribute long clientTop;
        readonly attribute long clientWidth;
        readonly attribute long clientHeight;
                 attribute long scrollLeft;
                 attribute long scrollTop;
        readonly attribute long scrollWidth;
        readonly attribute long scrollHeight;

        void focus();
        void blur();
        void scrollIntoView(in [Optional] boolean alignWithTop);

        // IE extensions

        boolean contains(in [Optional=CallWithDefaultValue] Element element);

        // WebKit extensions

        void scrollIntoViewIfNeeded(in [Optional] boolean centerIfNeeded);
        void scrollByLines(in [Optional=CallWithDefaultValue] long lines);
        void scrollByPages(in [Optional=CallWithDefaultValue] long pages);

#if defined(ENABLE_ANIMATION_API) && ENABLE_ANIMATION_API
        WebKitAnimationList webkitGetAnimations();
#endif

        // HTML 5
        NodeList getElementsByClassName(in [Optional=CallWithDefaultValue] DOMString name);

#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
        readonly attribute DOMStringMap dataset;
#endif

        // NodeSelector - Selector API
        Element querySelector(in DOMString selectors)
            raises(DOMException);
        NodeList querySelectorAll(in DOMString selectors)
            raises(DOMException);

        // WebKit extension, pending specification.
        boolean webkitMatchesSelector(in [Optional=CallWithDefaultValue] DOMString selectors)
            raises(DOMException);

        // ElementTraversal API
        readonly attribute Element firstElementChild;
        readonly attribute Element lastElementChild;
        readonly attribute Element previousElementSibling;
        readonly attribute Element nextElementSibling;
        readonly attribute unsigned long childElementCount;

#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
        // CSSOM View Module API
        ClientRectList getClientRects();
        ClientRect getBoundingClientRect();
#endif

#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
        // Objective-C extensions
        readonly attribute DOMString innerText;
#endif

#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
        const unsigned short ALLOW_KEYBOARD_INPUT = 1;
        [EnabledAtRuntime] void webkitRequestFullScreen(in [Optional=CallWithDefaultValue] unsigned short flags);
#endif

#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
        // Event handler DOM attributes
        attribute [DontEnum] EventListener onabort;
        attribute [DontEnum] EventListener onblur;
        attribute [DontEnum] EventListener onchange;
        attribute [DontEnum] EventListener onclick;
        attribute [DontEnum] EventListener oncontextmenu;
        attribute [DontEnum] EventListener ondblclick;
        attribute [DontEnum] EventListener ondrag;
        attribute [DontEnum] EventListener ondragend;
        attribute [DontEnum] EventListener ondragenter;
        attribute [DontEnum] EventListener ondragleave;
        attribute [DontEnum] EventListener ondragover;
        attribute [DontEnum] EventListener ondragstart;
        attribute [DontEnum] EventListener ondrop;
        attribute [DontEnum] EventListener onerror;
        attribute [DontEnum] EventListener onfocus;
        attribute [DontEnum] EventListener oninput;
        attribute [DontEnum] EventListener oninvalid;
        attribute [DontEnum] EventListener onkeydown;
        attribute [DontEnum] EventListener onkeypress;
        attribute [DontEnum] EventListener onkeyup;
        attribute [DontEnum] EventListener onload;
        attribute [DontEnum] EventListener onmousedown;
        attribute [DontEnum] EventListener onmousemove;
        attribute [DontEnum] EventListener onmouseout;
        attribute [DontEnum] EventListener onmouseover;
        attribute [DontEnum] EventListener onmouseup;
        attribute [DontEnum] EventListener onmousewheel;
        attribute [DontEnum] EventListener onscroll;
        attribute [DontEnum] EventListener onselect;
        attribute [DontEnum] EventListener onsubmit;

        // attribute [DontEnum] EventListener oncanplay;
        // attribute [DontEnum] EventListener oncanplaythrough;
        // attribute [DontEnum] EventListener ondurationchange;
        // attribute [DontEnum] EventListener onemptied;
        // attribute [DontEnum] EventListener onended;
        // attribute [DontEnum] EventListener onloadeddata;
        // attribute [DontEnum] EventListener onloadedmetadata;
        // attribute [DontEnum] EventListener onloadstart;
        // attribute [DontEnum] EventListener onpause;
        // attribute [DontEnum] EventListener onplay;
        // attribute [DontEnum] EventListener onplaying;
        // attribute [DontEnum] EventListener onprogress;
        // attribute [DontEnum] EventListener onratechange;
        // attribute [DontEnum] EventListener onreadystatechange;
        // attribute [DontEnum] EventListener onseeked;
        // attribute [DontEnum] EventListener onseeking;
        // attribute [DontEnum] EventListener onshow;
        // attribute [DontEnum] EventListener onstalled;
        // attribute [DontEnum] EventListener onsuspend;
        // attribute [DontEnum] EventListener ontimeupdate;
        // attribute [DontEnum] EventListener onvolumechange;
        // attribute [DontEnum] EventListener onwaiting;

        // WebKit extensions
        attribute [DontEnum] EventListener onbeforecut;
        attribute [DontEnum] EventListener oncut;
        attribute [DontEnum] EventListener onbeforecopy;
        attribute [DontEnum] EventListener oncopy;
        attribute [DontEnum] EventListener onbeforepaste;
        attribute [DontEnum] EventListener onpaste;
        attribute [DontEnum] EventListener onreset;
        attribute [DontEnum] EventListener onsearch;
        attribute [DontEnum] EventListener onselectstart;
        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchstart;
        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchmove;
        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
        attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
#endif
    };

}
