dom/browser-element/BrowserElementParent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/browser-element/BrowserElementParent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_BrowserElementHelpers_h
     1.9 +#define mozilla_BrowserElementHelpers_h
    1.10 +
    1.11 +#include "nsAString.h"
    1.12 +#include "mozilla/gfx/Point.h"
    1.13 +#include "mozilla/gfx/Rect.h"
    1.14 +#include "Units.h"
    1.15 +#include "mozilla/dom/Element.h"
    1.16 +
    1.17 +class nsIDOMWindow;
    1.18 +class nsIURI;
    1.19 +
    1.20 +namespace mozilla {
    1.21 +
    1.22 +namespace dom {
    1.23 +class TabParent;
    1.24 +}
    1.25 +
    1.26 +/**
    1.27 + * BrowserElementParent implements a portion of the parent-process side of
    1.28 + * <iframe mozbrowser>.
    1.29 + *
    1.30 + * Most of the parent-process side of <iframe mozbrowser> is implemented in
    1.31 + * BrowserElementParent.js.  This file implements the few parts of this
    1.32 + * functionality which must be written in C++.
    1.33 + *
    1.34 + * We don't communicate with the JS code that lives in BrowserElementParent.js;
    1.35 + * the JS and C++ parts are completely separate.
    1.36 + */
    1.37 +class BrowserElementParent
    1.38 +{
    1.39 +public:
    1.40 +
    1.41 +  /**
    1.42 +   * Possible results from a window.open call.
    1.43 +   * ADDED     - The frame was added to a document (i.e. handled by the embedder).
    1.44 +   * IGNORED   - The frame was not added to a document and the embedder didn't
    1.45 +   *             call preventDefault() to prevent the platform from handling the call.
    1.46 +   * CANCELLED - The frame was not added to a document, but the embedder still
    1.47 +   *             called preventDefault() to prevent the platform from handling the call.
    1.48 +   */
    1.49 +
    1.50 +  enum OpenWindowResult {
    1.51 +    OPEN_WINDOW_ADDED,
    1.52 +    OPEN_WINDOW_IGNORED,
    1.53 +    OPEN_WINDOW_CANCELLED
    1.54 +  };
    1.55 +
    1.56 +  /**
    1.57 +   * Handle a window.open call from an out-of-process <iframe mozbrowser>.
    1.58 +   *
    1.59 +   * window.open inside <iframe mozbrowser> doesn't actually open a new
    1.60 +   * top-level window.  Instead, the "embedder" (the document which contains
    1.61 +   * the <iframe mozbrowser> whose content called window.open) gets the
    1.62 +   * opportunity to place a new <iframe mozbrowser> in the DOM somewhere.  This
    1.63 +   * new "popup" iframe acts as the opened window.
    1.64 +   *
    1.65 +   * This method proceeds in three steps.
    1.66 +   *
    1.67 +   * 1) We fire a mozbrowseropenwindow CustomEvent on the opener
    1.68 +   *    iframe element.  This event's detail is an instance of
    1.69 +   *    OpenWindowEventDetail.
    1.70 +   *
    1.71 +   * 2) The embedder (the document which contains the opener iframe) can accept
    1.72 +   *    the window.open request by inserting event.detail.frameElement (an iframe
    1.73 +   *    element) into the DOM somewhere.
    1.74 +   *
    1.75 +   * 3) If the embedder accepted the window.open request, we return true and
    1.76 +   *    set aPopupTabParent's frame element to event.detail.frameElement.
    1.77 +   *    Otherwise, we return false.
    1.78 +   *
    1.79 +   * @param aURL the URL the new window should load.  The empty string is
    1.80 +   *             allowed.
    1.81 +   * @param aOpenerTabParent the TabParent whose TabChild called window.open.
    1.82 +   * @param aPopupTabParent the TabParent inside which the opened window will
    1.83 +   *                        live.
    1.84 +   * @return an OpenWindowresult that describes whether the embedder added the
    1.85 +   *         frame to a document and whether it called preventDefault to prevent
    1.86 +   *         the platform from handling the open request.
    1.87 +   */
    1.88 +  static OpenWindowResult
    1.89 +  OpenWindowOOP(dom::TabParent* aOpenerTabParent,
    1.90 +                dom::TabParent* aPopupTabParent,
    1.91 +                const nsAString& aURL,
    1.92 +                const nsAString& aName,
    1.93 +                const nsAString& aFeatures);
    1.94 +
    1.95 +  /**
    1.96 +   * Handle a window.open call from an in-process <iframe mozbrowser>.
    1.97 +   *
    1.98 +   * (These parameter types are silly, but they match what our caller has in
    1.99 +   * hand.  Feel free to add an override, if they are inconvenient to you.)
   1.100 +   *
   1.101 +   * @param aURI the URI the new window should load.  May be null.
   1.102 +   * @return an OpenWindowResult that describes whether the browser added the
   1.103 +   *         frame to a document or whether they called preventDefault to prevent
   1.104 +   *         the platform from handling the open request
   1.105 +   */
   1.106 +  static OpenWindowResult
   1.107 +  OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
   1.108 +                      nsIURI* aURI,
   1.109 +                      const nsAString& aName,
   1.110 +                      const nsACString& aFeatures,
   1.111 +                      nsIDOMWindow** aReturnWindow);
   1.112 +
   1.113 +  /**
   1.114 +   * Fire a mozbrowserasyncscroll CustomEvent on the given TabParent's frame element.
   1.115 +   * This event's detail is an AsyncScrollEventDetail dictionary.
   1.116 +   *
   1.117 +   * @param aContentRect: The portion of the page which is currently visible
   1.118 +   *                      onscreen in CSS pixels.
   1.119 +   *
   1.120 +   * @param aContentSize: The content width/height in CSS pixels.
   1.121 +   *
   1.122 +   * aContentRect.top + aContentRect.height may be larger than aContentSize.height.
   1.123 +   * This indicates that the content is over-scrolled, which occurs when the
   1.124 +   * page "rubber-bands" after being scrolled all the way to the bottom.
   1.125 +   * Similarly, aContentRect.left + aContentRect.width may be greater than
   1.126 +   * contentSize.width, and both left and top may be negative.
   1.127 +   */
   1.128 +  static bool
   1.129 +  DispatchAsyncScrollEvent(dom::TabParent* aTabParent,
   1.130 +                           const CSSRect& aContentRect,
   1.131 +                           const CSSSize& aContentSize);
   1.132 +
   1.133 +private:
   1.134 +  static OpenWindowResult
   1.135 +  DispatchOpenWindowEvent(dom::Element* aOpenerFrameElement,
   1.136 +                          dom::Element* aPopupFrameElement,
   1.137 +                          const nsAString& aURL,
   1.138 +                          const nsAString& aName,
   1.139 +                          const nsAString& aFeatures);
   1.140 +};
   1.141 +
   1.142 +} // namespace mozilla
   1.143 +
   1.144 +#endif

mercurial