/*
 * 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.
 */

[
        JSGenerateToNativeObject,
    JSInlineGetOwnPropertySlot,
] interface Element : Node {

        // DOM Level 1 Core

    [TreatReturnedNullStringAs=Null] readonly attribute DOMString tagName;

    [TreatReturnedNullStringAs=Null] DOMString getAttribute([Default=Undefined] optional DOMString name);
    [ObjCLegacyUnnamedParameters] void setAttribute([Default=Undefined] optional DOMString name,
                                     [Default=Undefined] optional DOMString value)
            raises(DOMException);
    void removeAttribute([Default=Undefined] optional DOMString name);
    Attr getAttributeNode([Default=Undefined] optional DOMString name);
    Attr setAttributeNode([Default=Undefined] optional Attr newAttr)
            raises(DOMException);
    Attr removeAttributeNode([Default=Undefined] optional Attr oldAttr)
            raises(DOMException);
    NodeList getElementsByTagName([Default=Undefined] optional DOMString name);

#if !defined(LANGUAGE_OBJECTIVE_C)
    // For ObjC this is defined on Node for legacy support.
    readonly attribute NamedNodeMap     attributes;
    boolean            hasAttributes();
#endif

        // DOM Level 2 Core

    [ObjCLegacyUnnamedParameters] DOMString getAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                            [Default=Undefined] optional DOMString localName);
    [ObjCLegacyUnnamedParameters] void setAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                       [Default=Undefined] optional DOMString qualifiedName, 
                                       [Default=Undefined] optional DOMString value)
            raises(DOMException);
    [ObjCLegacyUnnamedParameters] void removeAttributeNS([TreatNullAs=NullString] DOMString namespaceURI,
                                          DOMString localName);
    [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                                   [Default=Undefined] optional DOMString localName);
    [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                           [Default=Undefined] optional DOMString localName);
    Attr setAttributeNodeNS([Default=Undefined] optional Attr newAttr)
            raises(DOMException);
    boolean hasAttribute(DOMString name);
    [ObjCLegacyUnnamedParameters] boolean hasAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                          [Default=Undefined] optional DOMString localName);

        readonly attribute CSSStyleDeclaration style;

        // Common extensions

        readonly attribute long offsetLeft;
        readonly attribute long offsetTop;
        readonly attribute long offsetWidth;
        readonly attribute long offsetHeight;
    [ImplementedAs=bindingsOffsetParent] 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(optional boolean alignWithTop);

        // WebKit extensions

    void scrollIntoViewIfNeeded(optional boolean centerIfNeeded);
    void scrollByLines([Default=Undefined] optional long lines);
    void scrollByPages([Default=Undefined] optional long pages);

        // HTML 5
    NodeList getElementsByClassName([Default=Undefined] optional DOMString name);

    [Reflect=class] attribute DOMString className;
    readonly attribute DOMTokenList classList;

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

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

        // WebKit extension, pending specification.
    boolean webkitMatchesSelector([Default=Undefined] optional 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;

    // ShadowAware API
#if defined(ENABLE_SHADOW_DOM) && ENABLE_SHADOW_DOM && defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    [Reflect=pseudo, ImplementedAs=pseudo] attribute DOMString webkitPseudo;
    [ImplementedAs=createShadowRoot] ShadowRoot webkitCreateShadowRoot() raises(DOMException);
    [ImplementedAs=authorShadowRoot] readonly attribute ShadowRoot webkitShadowRoot;
    [ImplementedAs=insertionParentForBinding] readonly attribute Node webkitInsertionParent;
#endif

    // DOM 4
    void remove()
        raises(DOMException);

#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
        // Mozilla version
        const unsigned short ALLOW_KEYBOARD_INPUT = 1;
    void webkitRequestFullScreen([Default=Undefined] optional unsigned short flags);

        // W3C version
    void webkitRequestFullscreen();
#endif

    [Conditional=POINTER_LOCK] void webkitRequestPointerLock();

        // CSS Regions API
    [Conditional=CSS_REGIONS] readonly attribute DOMString webkitRegionOverset;
    [Conditional=CSS_REGIONS] sequence<Range> webkitGetRegionFlowRanges();

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

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

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

