author Randell Jesup <>
Fri, 30 Aug 2013 02:08:04 -0400
changeset 157990 c118114b08f1fc72e2e359402ba4bd212886e8f2
parent 157145 bedb4f9707ce21836ffb5a3c887e29ac913990a5
child 159303 bd53e981282f9ed59ca35ce59776c2f94e9f6e7d
permissions -rw-r--r--
Bug 901583: Webrtc updated to 4563; pull made Sat Aug 17 11:00:00 EDT 2013 rs=jesup

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_BrowserElementHelpers_h
#define mozilla_BrowserElementHelpers_h

#include "nsAString.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Rect.h"
#include "Units.h"

class nsIDOMWindow;
class nsIURI;

namespace mozilla {

namespace dom {
class TabParent;

 * BrowserElementParent implements a portion of the parent-process side of
 * <iframe mozbrowser>.
 * Most of the parent-process side of <iframe mozbrowser> is implemented in
 * BrowserElementParent.js.  This file implements the few parts of this
 * functionality which must be written in C++.
 * We don't communicate with the JS code that lives in BrowserElementParent.js;
 * the JS and C++ parts are completely separate.
class BrowserElementParent
   * Handle a call from an out-of-process <iframe mozbrowser>.
   * inside <iframe mozbrowser> doesn't actually open a new
   * top-level window.  Instead, the "embedder" (the document which contains
   * the <iframe mozbrowser> whose content called gets the
   * opportunity to place a new <iframe mozbrowser> in the DOM somewhere.  This
   * new "popup" iframe acts as the opened window.
   * This method proceeds in three steps.
   * 1) We fire a mozbrowseropenwindow CustomEvent on the opener
   *    iframe element.  This event's detail is an instance of
   *    OpenWindowEventDetail.
   * 2) The embedder (the document which contains the opener iframe) can accept
   *    the request by inserting event.detail.frameElement (an iframe
   *    element) into the DOM somewhere.
   * 3) If the embedder accepted the request, we return true and
   *    set aPopupTabParent's frame element to event.detail.frameElement.
   *    Otherwise, we return false.
   * @param aURL the URL the new window should load.  The empty string is
   *             allowed.
   * @param aOpenerTabParent the TabParent whose TabChild called
   * @param aPopupTabParent the TabParent inside which the opened window will
   *                        live.
   * @return true on success, false otherwise.  Failure is not (necessarily)
   *         an error; it may indicate that the embedder simply rejected the
   * request.
  static bool
  OpenWindowOOP(dom::TabParent* aOpenerTabParent,
                dom::TabParent* aPopupTabParent,
                const nsAString& aURL,
                const nsAString& aName,
                const nsAString& aFeatures);

   * Handle a call from an in-process <iframe mozbrowser>.
   * As with OpenWindowOOP, we return true if the request
   * succeeded, and return false if the embedder denied the request.
   * (These parameter types are silly, but they match what our caller has in
   * hand.  Feel free to add an override, if they are inconvenient to you.)
   * @param aURI the URI the new window should load.  May be null.
  static bool
  OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
                      nsIURI* aURI,
                      const nsAString& aName,
                      const nsACString& aFeatures,
                      nsIDOMWindow** aReturnWindow);

   * Fire a mozbrowserasyncscroll CustomEvent on the given TabParent's frame element.
   * This event's detail is an instance of nsIAsyncScrollEventDetail.
   * @param aContentRect: The portion of the page which is currently visible
   *                      onscreen in CSS pixels.
   * @param aContentSize: The content width/height in CSS pixels.
   * + aContentRect.height may be larger than aContentSize.height.
   * This indicates that the content is over-scrolled, which occurs when the
   * page "rubber-bands" after being scrolled all the way to the bottom.
   * Similarly, aContentRect.left + aContentRect.width may be greater than
   * contentSize.width, and both left and top may be negative.
  static bool
  DispatchAsyncScrollEvent(dom::TabParent* aTabParent,
                           const CSSRect& aContentRect,
                           const CSSSize& aContentSize);

} // namespace mozilla