/* -*- 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 Communicator client code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Johnny Stenback <jst@netscape.com> (original author)
 *   Brian Ryner <bryner@brianryner.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 "nsISupports.idl"

interface nsIDocShell;
interface nsIURI;
interface nsIFrame;
interface nsIChromeFrameMessageManager;
interface nsIVariant;

[scriptable, uuid(50a67436-bb44-11df-8d9a-001e37d2764a)]
interface nsIFrameLoader : nsISupports
{
  /**
   * Get the docshell from the frame loader.
   */
  readonly attribute nsIDocShell docShell;

  /**
   * Start loading the frame. This method figures out what to load
   * from the owner content in the frame loader.
   */
  void loadFrame();

  /**
   * Loads the specified URI in this frame. Behaves identically to loadFrame,
   * except that this method allows specifying the URI to load.
   */
  void loadURI(in nsIURI aURI);

  /**
   * Destroy the frame loader and everything inside it. This will
   * clear the weak owner content reference.
   */
  void destroy();

  /**
   * Find out whether the loader's frame is at too great a depth in
   * the frame tree.  This can be used to decide what operations may
   * or may not be allowed on the loader's docshell.
   */
  readonly attribute boolean depthTooGreat;

  /**
   * Updates the position and size of the subdocument loaded by this frameloader.
   *
   *  @param aIFrame The nsIFrame for the content node that owns this frameloader
   */
  [noscript] void updatePositionAndSize(in nsIFrame aIFrame);

  /**
   * Activate remote frame.
   * Throws an exception with non-remote frames.
   */
  void activateRemoteFrame();

  /**
   * @see nsIDOMWindowUtils sendMouseEvent.
   */
  void sendCrossProcessMouseEvent(in AString aType,
                                  in float aX,
                                  in float aY,
                                  in long aButton,
                                  in long aClickCount,
                                  in long aModifiers,
                                  [optional] in boolean aIgnoreRootScrollFrame);

  /**
   * Activate event forwarding from client (remote frame) to parent.
   */
  void activateFrameEvent(in AString aType, in boolean capture);

  // Note, when frameloaders are swapped, also messageManagers are swapped.
  readonly attribute nsIChromeFrameMessageManager messageManager;

  /**
   * @see nsIDOMWindowUtils sendKeyEvent.
   */
  void sendCrossProcessKeyEvent(in AString aType,
                                in long aKeyCode,
                                in long aCharCode,
                                in long aModifiers,
                                [optional] in boolean aPreventDefault);

  attribute boolean delayRemoteDialogs;

  /**
   * Implement viewport scrolling/scaling, used to support
   * asynchronous re-paints of content pixels.  These interfaces are
   * only meaningful for <browser>.
   *
   * These interfaces do *not* scroll or scale the content document;
   * instead they set a "goal" scroll/scale wrt the current content
   * viewport.  When the content document is painted, the viewport*
   * attributes are used to set a compensating transform.  If the
   * metrics of the content document's current pixels don't match the
   * viewport* config, the transform matrix may need to translate
   * content pixels and/or perform a "fuzzy-scale" that doesn't
   * re-rasterize fonts or intelligently resample images.
   *
   * The viewport* attrs are allowed to transform content pixels in
   * such a way that the <browser>'s visible rect encloses pixels that
   * the content document does not (yet) define.
   *
   * The viewport scroll values are in units of chrome-document CSS
   * pixels.
   *
   * These APIs are designed to be used with nsIDOMWindowUtils
   * setDisplayPort() and setResolution().
   */
  void scrollViewportTo(in float xPx, in float yPx);
  void scrollViewportBy(in float dxPx, in float dyPx);
  void setViewportScale(in float xScale, in float yScale);

  readonly attribute float viewportScrollX;
  readonly attribute float viewportScrollY;
};

native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);

[scriptable, uuid(5879040e-83e9-40e3-b2bb-5ddf43b76e47)]
interface nsIFrameLoaderOwner : nsISupports
{
  /**
   * The frame loader owned by this nsIFrameLoaderOwner
   */
  readonly attribute nsIFrameLoader frameLoader;
  [noscript, notxpcom] alreadyAddRefed_nsFrameLoader GetFrameLoader();

  /**
   * Swap frame loaders with the given nsIFrameLoaderOwner.  This may
   * only be posible in a very limited range of circumstances, or
   * never, depending on the object implementing this interface.
   *
   * @throws NS_ERROR_NOT_IMPLEMENTED if the swapping logic is not
   *   implemented for the two given frame loader owners.
   * @throws NS_ERROR_DOM_SECURITY_ERR if the swap is not allowed on
   *   security grounds.
   */
  void swapFrameLoaders(in nsIFrameLoaderOwner aOtherOwner);
};
