/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2000
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Vidur Apparao <vidur@netscape.com> (original author)
 *   Johnny Stenback <jst@netscape.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsIDOMWindow2.idl"

%{ C++
#include "jspubtd.h"
%}

interface nsIPrompt;
interface nsIControllers;
interface nsIDOMLocation;
interface nsIVariant;
interface nsIAnimationFrameListener;
interface nsIDOMMediaQueryList;

[scriptable, uuid(3a7b0839-b9d6-42ff-8ba6-910aba60a966)]
interface nsIDOMWindowInternal : nsIDOMWindow2
{
  readonly attribute nsIDOMWindowInternal        window;

  /* [replaceable] self */
  readonly attribute nsIDOMWindowInternal        self;

  readonly attribute nsIDOMNavigator             navigator;
  readonly attribute nsIDOMScreen                screen;
  readonly attribute nsIDOMHistory               history;

  /* [replaceable] content */
  readonly attribute nsIDOMWindow                content;

  /* [replaceable] prompter */
  [noscript] readonly attribute nsIPrompt        prompter;

  /* [replaceable] menubar */
  readonly attribute nsIDOMBarProp               menubar;

  /* [replaceable] toolbar */
  readonly attribute nsIDOMBarProp               toolbar;

  /* [replaceable] locationbar */
  readonly attribute nsIDOMBarProp               locationbar;

  /* [replaceable] personalbar */
  readonly attribute nsIDOMBarProp               personalbar;

  /* [replaceable] statusbar */
  readonly attribute nsIDOMBarProp               statusbar;

  readonly attribute boolean                     closed;
  readonly attribute nsIDOMCrypto                crypto;
  readonly attribute nsIDOMPkcs11                pkcs11;

  // XXX Shouldn't this be in nsIDOMChromeWindow?
  /* [replaceable] controllers */
  readonly attribute nsIControllers              controllers;

           attribute nsIDOMWindowInternal        opener;

  /* [replaceable] */
           attribute DOMString                   status;
           attribute DOMString                   defaultStatus;

  // XXX: The setter that takes a string argument needs to be special
  // cased!
  readonly attribute nsIDOMLocation              location;
  
  /* [replaceable] */
           attribute long                        innerWidth;
           attribute long                        innerHeight;
           attribute long                        outerWidth;
           attribute long                        outerHeight;
           attribute long                        screenX;
           attribute long                        screenY;
  readonly attribute float                       mozInnerScreenX;
  readonly attribute float                       mozInnerScreenY;

  /* The offset in pixels by which the window is scrolled */
  readonly attribute long                        pageXOffset;
  readonly attribute long                        pageYOffset;

  /* The maximum offset that the window can be scrolled to
     (i.e., the document width/height minus the scrollport width/height) */
  readonly attribute long                        scrollMaxX;
  readonly attribute long                        scrollMaxY;

  /* [replaceable] length */
  readonly attribute unsigned long               length;

           attribute boolean                     fullScreen;

  void                      alert(in DOMString text);
  boolean                   confirm(in DOMString text);

  // prompt() should return a null string if cancel is pressed
  DOMString                 prompt([optional] in DOMString aMessage,
                                   [optional] in DOMString aInitial);

  void                      focus();
  void                      blur();

  void                      back();
  void                      forward();
  void                      home();
  void                      stop();

  void                      print();

  void                      moveTo(in long xPos, in long yPos);
  void                      moveBy(in long xDif, in long yDif);
  void                      resizeTo(in long width, in long height);
  void                      resizeBy(in long widthDif, in long heightDif);
  void                      scroll(in long xScroll, in long yScroll);

  /**
   * Open a new window with this one as the parent.  This method will
   * NOT examine the JS stack for purposes of determining a caller.
   * This window will be used for security checks during the search by
   * name and the default character set on the newly opened window
   * will just be the default character set of this window.
   */
  [noscript] nsIDOMWindow   open(in DOMString url, in DOMString name,
                                 in DOMString options);

  /**
   * This method works like open except that aExtraArgument gets
   * converted into the array window.arguments in JS, if
   * aExtraArgument is a nsISupportsArray then the individual items in
   * the array are inserted into window.arguments, and primitive
   * nsISupports (nsISupportsPrimitives) types are converted to native
   * JS types when possible.
   */
  [noscript] nsIDOMWindow   openDialog(in DOMString url, in DOMString name,
                                       in DOMString options,
                                       in nsISupports aExtraArgument);
  void                      close();

  // XXX Should this be in nsIDOMChromeWindow?
  void                      updateCommands(in DOMString action);

  /* Find in page.
   * @param str: the search pattern
   * @param caseSensitive: is the search caseSensitive
   * @param backwards: should we search backwards
   * @param wrapAround: should we wrap the search
   * @param wholeWord: should we search only for whole words
   * @param searchInFrames: should we search through all frames
   * @param showDialog: should we show the Find dialog
   */
  boolean                   find([optional] in DOMString str,
                                 [optional] in boolean caseSensitive,
                                 [optional] in boolean backwards,
                                 [optional] in boolean wrapAround,
                                 [optional] in boolean wholeWord,
                                 [optional] in boolean searchInFrames,
                                 [optional] in boolean showDialog);

  // Ascii base64 data to binary data and vice versa...
  DOMString                 atob(in DOMString aAsciiString);
  DOMString                 btoa(in DOMString aBase64Data);

  readonly attribute nsIDOMElement               frameElement;

  nsIVariant                showModalDialog(in DOMString aURI,
                                            [optional] in nsIVariant aArgs,
                                            [optional] in DOMString aOptions);

  /**
   * Implements a safe message-passing system which can cross same-origin
   * boundaries.
   *
   * This method, when called, causes a MessageEvent to be asynchronously
   * dispatched at the primary document for the window upon which this method is
   * called.  (Note that the postMessage property on windows is allAccess and
   * thus is readable cross-origin.)  The dispatched event will have message as
   * its data, the calling context's window as its source, and an origin
   * determined by the calling context's main document URI.  The targetOrigin
   * argument specifies a URI and is used to restrict the message to be sent
   * only when the target window has the same origin as targetOrigin (since,
   * when the sender and the target have different origins, neither can read the
   * location of the other).
   * 
   * See the WHATWG HTML5 specification, section 6.4, for more details.
   */
  [implicit_jscontext, binaryname(PostMessageMoz)]
    void postMessage(in jsval message, in DOMString targetOrigin);

  /**
   * Returns the number of times this document for this window has
   * been painted to the screen.
   */
  readonly attribute unsigned long long mozPaintCount;

  /**
   * Request a refresh of this browser window.
   */
  void
    mozRequestAnimationFrame([optional] in nsIAnimationFrameListener aListener);

  /**
   * The current animation start time in milliseconds since the epoch.
   */
  readonly attribute long long mozAnimationStartTime;

  /**
   * http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface
   */
  nsIDOMMediaQueryList matchMedia(in DOMString media_query_list);
};

[scriptable, uuid(8fc58f56-f769-4368-a098-edd08550cf1a)]
interface nsIDOMMozURLProperty : nsISupports
{
  DOMString createObjectURL(in nsIDOMBlob blob);
  void revokeObjectURL(in DOMString URL);
};

[scriptable, uuid(05563c0c-b74c-41ad-91d1-bc22d580a581)]
interface nsIDOMWindow_2_0_BRANCH : nsISupports
{
  readonly attribute nsIDOMMozURLProperty URL;
};
