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

[
	JSCustomHeader,
    JSGenerateToNativeObject
] interface Element : Node {

    // DOM Level 1 Core

    readonly attribute DOMString? tagName;
	// FIXME: Using "undefined" as default parameter value is wrong.
	DOMString? getAttribute(optional DOMString name = "undefined");
	
    // FIXME: Using "undefined" as default parameter value is wrong.
	void setAttribute(optional DOMString name = "undefined", optional DOMString value = "undefined")
        raises(DOMException);
        
    // FIXME: Using "undefined" as default parameter value is wrong.
    void removeAttribute(in optional DOMString name = "undefined");
    Attr getAttributeNode(in optional DOMString name = "undefined");
    
    Attr setAttributeNode(in Attr newAttr)
        raises(DOMException);
    Attr removeAttributeNode(in Attr oldAttr)
        raises(DOMException);
        
    // FIXME: Using "undefined" as default parameter value is wrong.
    NodeList getElementsByTagName(in optional DOMString name = "undefined");

    // DOM Level 2 Core

	// FIXME: Using "undefined" as default parameter value is wrong.
    [ObjCLegacyUnnamedParameters] DOMString getAttributeNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
    
    // FIXME: Using "undefined" as default parameter value is wrong.
	void setAttributeNS(optional DOMString? namespaceURI = null, optional DOMString qualifiedName = "undefined", optional DOMString value = "undefined")
        raises(DOMException);
   
    [ObjCLegacyUnnamedParameters] void removeAttributeNS(DOMString? namespaceURI, DOMString localName);
    
    // FIXME: Using "undefined" as default parameter value is wrong.
    [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
    
    // FIXME: Using "undefined" as default parameter value is wrong.
    [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
    Attr setAttributeNodeNS(in Attr newAttr)
        raises(DOMException);
    boolean hasAttribute(in DOMString name);        
    // FIXME: Using "undefined" as default parameter value is wrong.
    [ObjCLegacyUnnamedParameters] boolean hasAttributeNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");

    readonly attribute CSSStyleDeclaration style;

#if defined(ENABLE_BML) && ENABLE_BML
    readonly attribute CSSStyleDeclaration normalStyle;
    readonly attribute CSSStyleDeclaration focusStyle;
    readonly attribute CSSStyleDeclaration activeStyle;
#endif

    // 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(in optional boolean alignWithTop);

    // WebKit extensions

    void scrollIntoViewIfNeeded(in optional boolean centerIfNeeded);
    void scrollByLines(in optional long lines = 0);
    void scrollByPages(in optional long pages = 0);

    // HTML 5
    
    // FIXME: Using "undefined" as default parameter value is wrong.
    NodeList getElementsByClassName(in optional DOMString name = "undefined");
	[TreatNullAs=EmptyString] attribute DOMString innerHTML setter raises(DOMException);
	[TreatNullAs=EmptyString] attribute DOMString outerHTML setter raises(DOMException);
	     
    [Reflect=class] attribute DOMString className;
        
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    readonly attribute DOMStringMap dataset;
#endif

    // WebKit extension, pending specification.
    // FIXME: Using "undefined" as default parameter value is wrong.
    boolean matches(DOMString selectors)
        raises(DOMException);
    boolean webkitMatchesSelector(DOMString selectors)
        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(in optional unsigned short flags = 0);

    // W3C version
    void webkitRequestFullscreen();
#endif

    [Conditional=POINTER_LOCK] void webkitRequestPointerLock();

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

    // Shadow DOM API
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    [Conditional=SHADOW_DOM, RaisesException] ShadowRoot attachShadow(Dictionary options);
    [Conditional=SHADOW_DOM, ImplementedAs=bindingShadowRoot] readonly attribute ShadowRoot shadowRoot;
    [Conditional=SHADOW_DOM, Reflect] attribute DOMString slot;
#endif

#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, LenientThis] attribute EventListener onmouseenter;
	[NotEnumerable, LenientThis] 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;

    [NotEnumerable] attribute EventListener oncanplay;
    [NotEnumerable] attribute EventListener oncanplaythrough;
    [NotEnumerable] attribute EventListener ondurationchange;
    [NotEnumerable] attribute EventListener onemptied;
    [NotEnumerable] attribute EventListener onended;
    [NotEnumerable] attribute EventListener onloadeddata;
    [NotEnumerable] attribute EventListener onloadedmetadata;
    [NotEnumerable] attribute EventListener onloadstart;
    [NotEnumerable] attribute EventListener onpause;
    [NotEnumerable] attribute EventListener onplay;
    [NotEnumerable] attribute EventListener onplaying;
    [NotEnumerable] attribute EventListener onprogress;
    [NotEnumerable] attribute EventListener onratechange;
    [NotEnumerable] attribute EventListener onreadystatechange;
    [NotEnumerable] attribute EventListener onseeked;
    [NotEnumerable] attribute EventListener onseeking;
    [NotEnumerable] attribute EventListener onshow;
    [NotEnumerable] attribute EventListener onstalled;
    [NotEnumerable] attribute EventListener onsuspend;
    [NotEnumerable] attribute EventListener ontimeupdate;
    [NotEnumerable] attribute EventListener onvolumechange;
    [NotEnumerable] attribute 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
};

Element implements ChildNode;
Element implements ParentNode;
Element implements NonDocumentTypeChildNode;
