
// This file introduces / supplements and forces Dart declarations.

module default {
  NamedNodeMap implements sequence<Node>;
  NodeList implements sequence<Node>;
  HTMLCollection implements sequence<Node>;
  MediaList implements sequence<DOMString>;
  StyleSheetList implements sequence<StyleSheet>;
  TouchList implements sequence<Touch>;
  CanvasPixelArray implements sequence<int>;
}

module dom {
  // Force NodeSelector. WebKit defines these operations directly.
  interface NodeSelector {
    Element   querySelector(in DOMString selectors);
    NodeList  querySelectorAll(in DOMString selectors);
  };
  Document implements NodeSelector;
  DocumentFragment implements NodeSelector;
  Element implements NodeSelector;

  // Force ElementTraversal. WebKit defines these directly.
  interface ElementTraversal {
    getter attribute unsigned long childElementCount;
    getter attribute Element firstElementChild;
    getter attribute Element lastElementChild;
    getter attribute Element nextElementSibling;
    getter attribute Element previousElementSibling;
  };
  Element implements ElementTraversal;
};

module window {
  [Supplemental]
  interface Window {
    // Provide a different signature for postMessage.  Because one of the
    // desired signatures conflicts with an existing option, it is simpler to
    // completely suppress postMessage and introduce a new
    // postMessage_replacement that is renamed as postMessage.
    [Suppressed] void postMessage(in SerializedScriptValue message, [Optional] in MessagePort messagePort, in DOMString targetOrigin)
        raises(DOMException);

    [DartName=postMessage, ImplementationFunction=postMessage]
    void postMessage_replacement(in SerializedScriptValue message, in DOMString targetOrigin)
      raises(DOMException);
    [DartName=postMessage, ImplementationFunction=postMessage]
    void postMessage_replacement(in SerializedScriptValue message, in MessagePort messagePort, in DOMString targetOrigin)
      raises(DOMException);

  };
};

module html {
  // Define factory for XMLHttpRequest.
  [Supplemental]
  interface Window {
    XMLHttpRequest createXMLHttpRequest();
  };

  [Supplemental]
  interface Console {
    [Suppressed] void debug();
    void debug(DOMObject arg);
    [Suppressed] void error();
    void error(DOMObject arg);
    [Suppressed] void info();
    void info(DOMObject arg);
    [Suppressed] void log();
    void log(DOMObject arg);
    [Suppressed] void warn();
    void warn(DOMObject arg);
    [Suppressed] void trace();
    void trace(DOMObject arg);
  };

  [Supplemental]
  interface HTMLOptionsCollection {
    [Suppressed] void add(in optional HTMLOptionElement element, in optional long before);
  };

  [Supplemental]
  interface WebGLContextEvent {
    [Suppressed] void initEvent(in optional DOMString eventTypeArg,
                                in optional boolean canBubbleArg,
                                in optional boolean cancelableArg,
                                in optional DOMString statusMessageArg);
  };
};

module canvas {
  interface CanvasPixelArray {
    int item(in int index);
  };

  // TODO(dstockwell): Define these manually.
  [Supplemental]
  interface Float32Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Float64Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Int16Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Int32Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Int8Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Uint16Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Uint32Array {
    [Suppressed] void set();
  };
  [Supplemental]
  interface Uint8Array {
    [Suppressed] void set();
  };
};

module storage {
  // TODO(vsm): Define new names for these (see b/4436830).
  [Supplemental]
  interface IDBCursor {
    [DartName=continueFunction] void continue(in optional IDBKey key);
  };
  [Supplemental]
  interface IDBIndex {
    [DartName=getObject] IDBRequest get(in IDBKey key);
  };
  [Supplemental]
  interface IDBObjectStore {
    [DartName=getObject] IDBRequest get(in IDBKey key);
  };
};
