/*
 * Copyright © 2009 W3C® (MIT, ERCIM, Keio), All Rights Reserved.
 * W3C liability, trademark and document use rules apply.
 *
 * See CSSOM View Module Editor's Draft 23 January 2009
 * http://dev.w3.org/csswg/cssom-view/
 */

#ifndef _CSSOM_IDL_
#define _CSSOM_IDL_

#include "dom.idl"
#include "ranges.idl"

module html5
{
  interface HTMLElement;
};

module events
{
  interface MouseEvent;
};

module views
{
  typedef dom::Document Document;
  typedef dom::Element Element;
  typedef ranges::Range Range;
  typedef events::MouseEvent MouseEvent;
  typedef html5::HTMLElement HTMLElement;

  interface ClientRect;
  interface ClientRectList;
  interface DocumentView;
  interface Media;
  interface Screen;

  interface AbstractView {
    readonly attribute DocumentView document;
    readonly attribute Media media;
  };

  interface Media {
    readonly attribute DOMString type;
    boolean matchMedium(in DOMString mediaquery);
  };

  interface ScreenView : AbstractView {
    // viewport
    readonly attribute long innerWidth;
    readonly attribute long innerHeight;
    readonly attribute long pageXOffset;
    readonly attribute long pageYOffset;
    void scroll(in long x, in long y);
    void scrollTo(in long x, in long y);
    void scrollBy(in long x, in long y);

    // client
    readonly attribute long screenX;
    readonly attribute long screenY;
    readonly attribute long outerWidth;
    readonly attribute long outerHeight;

    // output device
    readonly attribute Screen screen;
  };

  interface Screen {
    readonly attribute unsigned long availWidth;
    readonly attribute unsigned long availHeight;
    readonly attribute unsigned long width;
    readonly attribute unsigned long height;
    readonly attribute unsigned long colorDepth;
    readonly attribute unsigned long pixelDepth;
  };

  [ImplementedOn=Document]
  interface DocumentView {
    readonly attribute AbstractView defaultView;
    Element elementFromPoint(in float x, in float y);
    Range caretRangeFromPoint(in float x, in float y);
  };

  [ImplementedOn=Element]
  interface ElementView {
    ClientRectList getClientRects();
    ClientRect getBoundingClientRect();

             attribute long scrollTop;   // scroll on setting
             attribute long scrollLeft;  // scroll on setting
    readonly attribute long scrollWidth;
    readonly attribute long scrollHeight;

    readonly attribute long clientTop;
    readonly attribute long clientLeft;
    readonly attribute long clientWidth;
    readonly attribute long clientHeight;

  };

  [ImplementedOn=HTMLElement]
  interface HTMLElementView {
    readonly attribute Element offsetParent;
    readonly attribute long offsetTop;
    readonly attribute long offsetLeft;
    readonly attribute long offsetWidth;
    readonly attribute long offsetHeight;
  };

  [ImplementedOn=Range]
  interface RangeView {
    ClientRectList getClientRects();
    ClientRect getBoundingClientRect();
  };

  [ImplementedOn=MouseEvent]
  interface MouseEventView {
    // readonly attribute long screenX;  // XXX defined in MouseEvent
    // readonly attribute long screenY;  // XXX defined in MouseEvent

    readonly attribute long pageX;
    readonly attribute long pageY;

    // readonly attribute long clientX;  // XXX defined in MouseEvent
    // readonly attribute long clientY;  // XXX defined in MouseEvent

    readonly attribute long offsetX;
    readonly attribute long offsetY;

    // historical; equivalent to clientX, clientY
    readonly attribute long x;
    readonly attribute long y;
  };

  interface ClientRectList {
    readonly attribute unsigned long length;
    ClientRect item(in unsigned long index);
  };

  interface ClientRect {
    readonly attribute float top;
    readonly attribute float right;
    readonly attribute float bottom;
    readonly attribute float left;
    readonly attribute float width;
    readonly attribute float height;
  };

};

#endif // _CSSOM_IDL_
