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

[
    CustomToV8
] interface Element : Node {

    // DOM Level 1 Core

    [TreatReturnedNullStringAs=Null, PerWorldBindings] readonly attribute DOMString tagName;

    [TreatReturnedNullStringAs=Null] DOMString getAttribute([Default=Undefined] optional DOMString name);
    [RaisesException, CustomElementCallbacks=Enable] void setAttribute([Default=Undefined] optional DOMString name,
                                     [Default=Undefined] optional DOMString value);
    [CustomElementCallbacks=Enable] void removeAttribute([Default=Undefined] optional DOMString name);
    [MeasureAs=ElementGetAttributeNode] Attr getAttributeNode([Default=Undefined] optional DOMString name); // Removed from DOM4.
    [RaisesException, CustomElementCallbacks=Enable, MeasureAs=ElementSetAttributeNode] Attr setAttributeNode([Default=Undefined, StrictTypeChecking] optional Attr newAttr); // Removed from DOM4.
    [RaisesException, CustomElementCallbacks=Enable, MeasureAs=ElementRemoveAttributeNode] Attr removeAttributeNode([Default=Undefined, StrictTypeChecking] optional Attr oldAttr); // Removed from DOM4.
    [PerWorldBindings] NodeList getElementsByTagName([Default=Undefined] optional DOMString name);

    [PerWorldBindings] readonly attribute NamedNodeMap     attributes;
    [MeasureAs=HasAttributes] boolean hasAttributes();

    // DOM Level 2 Core

     DOMString getAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                            [Default=Undefined] optional DOMString localName);
     [RaisesException, CustomElementCallbacks=Enable] void setAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                       [Default=Undefined] optional DOMString qualifiedName,
                                       [Default=Undefined] optional DOMString value);
     [CustomElementCallbacks=Enable] void removeAttributeNS([TreatNullAs=NullString] DOMString namespaceURI,
                                          DOMString localName);
     NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                                   [Default=Undefined] optional DOMString localName);
     [MeasureAs=ElementGetAttributeNodeNS] Attr getAttributeNodeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                                                   [Default=Undefined] optional DOMString localName); // Removed from DOM4.
    [RaisesException, CustomElementCallbacks=Enable] Attr setAttributeNodeNS([Default=Undefined, StrictTypeChecking] optional Attr newAttr);
    boolean hasAttribute(DOMString name);
     boolean hasAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
                                          [Default=Undefined] optional DOMString localName);

    [PerWorldBindings] readonly attribute CSSStyleDeclaration style;

    // DOM4
    // iht.com relies on id returning the empty string when no id is present.
    // Other browsers do this as well. So we don't convert null to JS null.
    [Reflect] attribute DOMString id;
    [TreatReturnedNullStringAs=Null, PerWorldBindings] readonly attribute DOMString namespaceURI;
    [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, PerWorldBindings, SetterRaisesException] attribute DOMString prefix;
    [TreatReturnedNullStringAs=Null, PerWorldBindings] readonly attribute DOMString localName;

    // Common extensions

    [PerWorldBindings] readonly attribute long offsetLeft;
    [PerWorldBindings] readonly attribute long offsetTop;
    [PerWorldBindings] readonly attribute long offsetWidth;
    [PerWorldBindings] readonly attribute long offsetHeight;
    [ImplementedAs=bindingsOffsetParent, PerWorldBindings] readonly attribute Element offsetParent;
    [PerWorldBindings] readonly attribute long clientLeft;
    [PerWorldBindings] readonly attribute long clientTop;
    [PerWorldBindings] readonly attribute long clientWidth;
    [PerWorldBindings] readonly attribute long clientHeight;
             [PerWorldBindings] attribute long scrollLeft;
             [PerWorldBindings] attribute long scrollTop;
    [PerWorldBindings] readonly attribute long scrollWidth;
    [PerWorldBindings] 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, PerWorldBindings] attribute DOMString className;
    [PerWorldBindings] readonly attribute DOMTokenList classList;

    [PerWorldBindings] readonly attribute DOMStringMap dataset;

    // NodeSelector - Selector API
    [RaisesException] Element querySelector(DOMString selectors);
    [RaisesException] NodeList querySelectorAll(DOMString selectors);

    // WebKit extension, pending specification.
    [RaisesException] boolean webkitMatchesSelector([Default=Undefined] optional DOMString selectors);

    // Shadow DOM API
    [EnabledAtRuntime=ShadowDOM, Reflect, PerWorldBindings] attribute DOMString pseudo;
    [EnabledAtRuntime=ShadowDOM, RaisesException] ShadowRoot createShadowRoot();
    [EnabledAtRuntime=ShadowDOM, PerWorldBindings] readonly attribute ShadowRoot shadowRoot;
    [EnabledAtRuntime=ShadowDOM, PerWorldBindings] NodeList getDestinationInsertionPoints();

    // To-be-deprecated prefixed Shadow DOM API
    [Reflect=pseudo, ImplementedAs=pseudo, PerWorldBindings, MeasureAs=ShadowDOMPrefixedPseudo] attribute DOMString webkitPseudo;
    [ImplementedAs=createShadowRoot, RaisesException, MeasureAs=ShadowDOMPrefixedCreateShadowRoot] ShadowRoot webkitCreateShadowRoot();
    [ImplementedAs=shadowRoot, PerWorldBindings, MeasureAs=ShadowDOMPrefixedShadowRoot] readonly attribute ShadowRoot webkitShadowRoot;

    // CSSOM View Module API
    ClientRectList getClientRects();
    ClientRect getBoundingClientRect();

    // Mozilla version
    const unsigned short ALLOW_KEYBOARD_INPUT = 1;
    [EnabledAtRuntime=Fullscreen, PerWorldBindings, ActivityLog=Access] void webkitRequestFullScreen([Default=Undefined] optional unsigned short flags);

    // W3C version
    [EnabledAtRuntime=Fullscreen, PerWorldBindings, ActivityLog=Access] void webkitRequestFullscreen();

    void webkitRequestPointerLock();

    // CSS Regions API
    [EnabledAtRuntime=CSSRegions, PerWorldBindings] readonly attribute DOMString webkitRegionOverset;
    [EnabledAtRuntime=CSSRegions] sequence<Range> webkitGetRegionFlowRanges();

    // Event handler DOM attributes
    [NotEnumerable, PerWorldBindings] attribute EventHandler onabort;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onblur;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onchange;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onclick;
    [NotEnumerable, PerWorldBindings] attribute EventHandler oncontextmenu;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondblclick;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrag;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragend;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragenter;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragleave;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragover;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragstart;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrop;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onerror;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onfocus;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler oninput;
    [NotEnumerable, PerWorldBindings] attribute EventHandler oninvalid;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeydown;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeypress;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeyup;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onload;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousedown;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseenter;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseleave;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousemove;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseout;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseover;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseup;
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousewheel; // Deprecated in favor of onwheel.
    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onwheel;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onscroll;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onselect;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onsubmit;

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

    // WebKit extensions
    [NotEnumerable, PerWorldBindings] attribute EventHandler onbeforecut;
    [NotEnumerable, PerWorldBindings] attribute EventHandler oncut;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onbeforecopy;
    [NotEnumerable, PerWorldBindings] attribute EventHandler oncopy;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onbeforepaste;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onpaste;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onreset;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onsearch;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onselectstart;
    [NotEnumerable, EnabledAtRuntime=Touch, PerWorldBindings] attribute EventHandler ontouchstart;
    [NotEnumerable, EnabledAtRuntime=Touch, PerWorldBindings] attribute EventHandler ontouchmove;
    [NotEnumerable, EnabledAtRuntime=Touch, PerWorldBindings] attribute EventHandler ontouchend;
    [NotEnumerable, EnabledAtRuntime=Touch, PerWorldBindings] attribute EventHandler ontouchcancel;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onwebkitfullscreenchange;
    [NotEnumerable, PerWorldBindings] attribute EventHandler onwebkitfullscreenerror;
};

Element implements ParentNode;
Element implements ChildNode;
