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

interface nsIPrompt;
interface nsIControllers;
interface nsIDOMLocation;
interface nsIVariant;

[scriptable, uuid(89b9ff5a-78db-430b-b3b4-66469457435a)]
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;

  /* [replaceable] directories */
  readonly attribute nsIDOMBarProp               directories;
  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;

  /* 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(in DOMString aMessage,
                                   in DOMString aInitial,
                                   in DOMString aTitle,
                                   in unsigned long aSavePassword);

  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);

  //void                      clearTimeout(in long timerID);
  //void                      clearInterval(in long timerID);
  //[noscript] long           setTimeout(/* in function,
  //                                        in unsigned long timeout */);
  //[noscript] long           setInterval(/* in function,
  //                                        in unsigned long timeout */);

  /**
   * 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);

  /* See nsIDOMJSWindow for the scriptable version of find()
   * @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
   */
  [noscript] boolean        find(in DOMString str, 
                                 in boolean caseSensitive,
                                 in boolean backwards, 
                                 in boolean wrapAround,
                                 in boolean wholeWord, 
                                 in boolean searchInFrames, 
                                 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 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 a domain and URI determined by
   * the calling context's main document URI.
   * 
   * See the WHATWG HTML5 specification, section 6.4, for more details.
   */
  [binaryname(PostMessageMoz)] void postMessage(in DOMString message,
                                                [optional] in DOMString origin);
};
