tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BrowserParent.h (39467B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_BrowserParent_h
      8 #define mozilla_dom_BrowserParent_h
      9 
     10 #include "LiveResizeListener.h"
     11 #include "Units.h"
     12 #include "js/TypeDecls.h"
     13 #include "mozilla/AlreadyAddRefed.h"
     14 #include "mozilla/ContentCache.h"
     15 #include "mozilla/EventForwards.h"
     16 #include "mozilla/RefPtr.h"
     17 #include "mozilla/dom/BrowserBridgeParent.h"
     18 #include "mozilla/dom/PBrowserParent.h"
     19 #include "mozilla/dom/TabContext.h"
     20 #include "mozilla/dom/UniqueContentParentKeepAlive.h"
     21 #include "mozilla/dom/VsyncParent.h"
     22 #include "mozilla/dom/ipc/IdType.h"
     23 #include "mozilla/layout/RemoteLayerTreeOwner.h"
     24 #include "nsCOMPtr.h"
     25 #include "nsIAuthPromptProvider.h"
     26 #include "nsIBrowserDOMWindow.h"
     27 #include "nsIDOMEventListener.h"
     28 #include "nsIFilePicker.h"
     29 #include "nsIRemoteTab.h"
     30 #include "nsIWidget.h"
     31 #include "nsTArray.h"
     32 #include "nsWeakReference.h"
     33 
     34 class imgIContainer;
     35 class nsCycleCollectionTraversalCallback;
     36 class nsDocShellLoadState;
     37 class nsFrameLoader;
     38 class nsIBrowser;
     39 class nsIContent;
     40 class nsIDocShell;
     41 class nsILoadContext;
     42 class nsIPrincipal;
     43 class nsIRequest;
     44 class nsIURI;
     45 class nsIWebBrowserPersistDocumentReceiver;
     46 class nsIWebProgress;
     47 class nsIXULBrowserWindow;
     48 class nsPIDOMWindowOuter;
     49 
     50 namespace mozilla {
     51 
     52 namespace a11y {
     53 class DocAccessibleParent;
     54 }
     55 
     56 namespace widget {
     57 struct IMENotification;
     58 }  // namespace widget
     59 
     60 namespace gfx {
     61 class SourceSurface;
     62 }  // namespace gfx
     63 
     64 namespace dom {
     65 
     66 class CanonicalBrowsingContext;
     67 class ClonedMessageData;
     68 class ContentParent;
     69 class Element;
     70 class DataTransfer;
     71 class BrowserHost;
     72 class BrowserBridgeParent;
     73 
     74 namespace ipc {
     75 class StructuredCloneData;
     76 }  // namespace ipc
     77 
     78 #define DOM_BROWSERPARENT_IID \
     79  {0x58b47b52, 0x77dc, 0x44cf, {0x8b, 0xe5, 0x8e, 0x78, 0x24, 0xd9, 0xae, 0xc5}}
     80 
     81 /**
     82 * BrowserParent implements the parent actor part of the PBrowser protocol. See
     83 * PBrowser for more information.
     84 */
     85 class BrowserParent final : public PBrowserParent,
     86                            public nsIDOMEventListener,
     87                            public nsIAuthPromptProvider,
     88                            public nsSupportsWeakReference,
     89                            public TabContext,
     90                            public LiveResizeListener {
     91  typedef mozilla::dom::ClonedMessageData ClonedMessageData;
     92  using TapType = GeckoContentController_TapType;
     93 
     94  friend class PBrowserParent;
     95 
     96  virtual ~BrowserParent();
     97 
     98 public:
     99  // Helper class for ContentParent::RecvCreateWindow.
    100  struct AutoUseNewTab;
    101 
    102  NS_INLINE_DECL_STATIC_IID(DOM_BROWSERPARENT_IID)
    103  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    104  NS_DECL_NSIAUTHPROMPTPROVIDER
    105  // nsIDOMEventListener interfaces
    106  NS_DECL_NSIDOMEVENTLISTENER
    107 
    108  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(BrowserParent, nsIDOMEventListener)
    109 
    110  BrowserParent(ContentParent* aManager, const TabId& aTabId,
    111                const TabContext& aContext,
    112                CanonicalBrowsingContext* aBrowsingContext,
    113                uint32_t aChromeFlags);
    114 
    115  /**
    116   * Returns the focused BrowserParent or nullptr if chrome or another app
    117   * is focused.
    118   */
    119  static BrowserParent* GetFocused();
    120 
    121  static BrowserParent* GetLastMouseRemoteTarget();
    122 
    123  static BrowserParent* GetFrom(nsFrameLoader* aFrameLoader);
    124 
    125  static BrowserParent* GetFrom(PBrowserParent* aBrowserParent);
    126 
    127  static BrowserParent* GetFrom(nsIContent* aContent);
    128 
    129  static BrowserParent* GetBrowserParentFromLayersId(
    130      layers::LayersId aLayersId);
    131 
    132  static TabId GetTabIdFrom(nsIDocShell* docshell);
    133 
    134  const TabId GetTabId() const { return mTabId; }
    135 
    136  ContentParent* Manager() const;
    137 
    138  CanonicalBrowsingContext* GetBrowsingContext() { return mBrowsingContext; }
    139 
    140  void RecomputeProcessPriority();
    141 
    142  already_AddRefed<nsILoadContext> GetLoadContext();
    143 
    144  Element* GetOwnerElement() const { return mFrameElement; }
    145 
    146  nsIBrowserDOMWindow* GetBrowserDOMWindow() const { return mBrowserDOMWindow; }
    147 
    148  already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter();
    149 
    150  already_AddRefed<nsIWidget> GetTopLevelWidget();
    151 
    152  // Returns the closest widget for our frameloader's content.
    153  already_AddRefed<nsIWidget> GetWidget() const;
    154 
    155  // Returns the top-level widget for our frameloader's document.
    156  already_AddRefed<nsIWidget> GetDocWidget() const;
    157 
    158  /**
    159   * Returns the widget which may have native focus and handles text input
    160   * like keyboard input, IME, etc.
    161   */
    162  already_AddRefed<nsIWidget> GetTextInputHandlingWidget() const;
    163 
    164  nsIXULBrowserWindow* GetXULBrowserWindow();
    165 
    166  static uint32_t GetMaxTouchPoints(Element* aElement);
    167  uint32_t GetMaxTouchPoints() { return GetMaxTouchPoints(mFrameElement); }
    168 
    169  /**
    170   * Return the top level DocAccessibleParent for this BrowserParent.
    171   * Note that in the case of an out-of-process iframe, the returned actor
    172   * might not be at the top level of the DocAccessibleParent tree; i.e. it
    173   * might have a parent. However, it will be at the top level in its content
    174   * process. That is, doc->IsTopLevelInContentProcess() will always be true,
    175   * but doc->IsTopLevel() might not.
    176   */
    177  a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
    178 
    179  LayersId GetLayersId() const;
    180 
    181  // Returns the BrowserBridgeParent if this BrowserParent is for an
    182  // out-of-process iframe and nullptr otherwise.
    183  BrowserBridgeParent* GetBrowserBridgeParent() const;
    184 
    185  // Returns the BrowserHost if this BrowserParent is for a top-level browser
    186  // and nullptr otherwise.
    187  BrowserHost* GetBrowserHost() const;
    188 
    189  ParentShowInfo GetShowInfo();
    190 
    191  // Get the content principal from the owner element.
    192  already_AddRefed<nsIPrincipal> GetContentPrincipal() const;
    193 
    194  /**
    195   * Let managees query if Destroy() is already called so they don't send out
    196   * messages when the PBrowser actor is being destroyed.
    197   */
    198  bool IsDestroyed() const { return mIsDestroyed; }
    199 
    200  /**
    201   * Returns whether we're in the process of creating a new window (from
    202   * window.open). If so, LoadURL calls are being skipped until everything is
    203   * set up. For further details, see `mCreatingWindow` below.
    204   */
    205  bool CreatingWindow() const { return mCreatingWindow; }
    206 
    207  // Whether our embedder can render transparent.
    208  bool IsTransparent() const;
    209 
    210  /*
    211   * Visit each BrowserParent in the tree formed by PBrowser and
    212   * PBrowserBridge, including `this`.
    213   */
    214  template <typename Callback>
    215  void VisitAll(Callback aCallback) {
    216    aCallback(this);
    217    VisitAllDescendants(aCallback);
    218  }
    219 
    220  /*
    221   * Visit each BrowserParent in the tree formed by PBrowser and
    222   * PBrowserBridge, excluding `this`.
    223   */
    224  template <typename Callback>
    225  void VisitAllDescendants(Callback aCallback) {
    226    const auto& browserBridges = ManagedPBrowserBridgeParent();
    227    for (const auto& key : browserBridges) {
    228      BrowserBridgeParent* browserBridge =
    229          static_cast<BrowserBridgeParent*>(key);
    230      BrowserParent* browserParent = browserBridge->GetBrowserParent();
    231 
    232      aCallback(browserParent);
    233      browserParent->VisitAllDescendants(aCallback);
    234    }
    235  }
    236 
    237  /*
    238   * Visit each BrowserBridgeParent that is a child of this BrowserParent.
    239   */
    240  template <typename Callback>
    241  void VisitChildren(Callback aCallback) {
    242    const auto& browserBridges = ManagedPBrowserBridgeParent();
    243    for (const auto& key : browserBridges) {
    244      BrowserBridgeParent* browserBridge =
    245          static_cast<BrowserBridgeParent*>(key);
    246      aCallback(browserBridge);
    247    }
    248  }
    249 
    250  void SetOwnerElement(Element* aElement);
    251 
    252  void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) {
    253    mBrowserDOMWindow = aBrowserDOMWindow;
    254  }
    255 
    256  void SwapFrameScriptsFrom(nsTArray<FrameScriptInfo>& aFrameScripts) {
    257    aFrameScripts.SwapElements(mDelayedFrameScripts);
    258  }
    259 
    260  void CacheFrameLoader(nsFrameLoader* aFrameLoader);
    261 
    262  void Destroy();
    263 
    264  void RemoveWindowListeners();
    265 
    266  void AddWindowListeners();
    267 
    268  mozilla::ipc::IPCResult RecvDidUnsuppressPainting();
    269  mozilla::ipc::IPCResult RecvDidUnsuppressPaintingNormalPriority() {
    270    return RecvDidUnsuppressPainting();
    271  }
    272  mozilla::ipc::IPCResult RecvMoveFocus(const bool& aForward,
    273                                        const bool& aForDocumentNavigation);
    274 
    275  mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks);
    276 
    277  // TODO: Use MOZ_CAN_RUN_SCRIPT when it gains IPDL support (bug 1539864)
    278  MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvReplyKeyEvent(
    279      const WidgetKeyboardEvent& aEvent, const nsID& aUUID);
    280 
    281  // TODO: Use MOZ_CAN_RUN_SCRIPT when it gains IPDL support (bug 1539864)
    282  MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvAccessKeyNotHandled(
    283      const WidgetKeyboardEvent& aEvent);
    284 
    285  mozilla::ipc::IPCResult RecvRegisterProtocolHandler(const nsString& aScheme,
    286                                                      nsIURI* aHandlerURI,
    287                                                      const nsString& aTitle,
    288                                                      nsIURI* aDocURI);
    289 
    290  mozilla::ipc::IPCResult RecvOnStateChange(
    291      const WebProgressData& aWebProgressData, const RequestData& aRequestData,
    292      const uint32_t aStateFlags, const nsresult aStatus,
    293      const Maybe<WebProgressStateChangeData>& aStateChangeData);
    294 
    295  mozilla::ipc::IPCResult RecvOnProgressChange(const int32_t aCurTotalProgres,
    296                                               const int32_t aMaxTotalProgress);
    297 
    298  mozilla::ipc::IPCResult RecvOnLocationChange(
    299      const WebProgressData& aWebProgressData, const RequestData& aRequestData,
    300      nsIURI* aLocation, const uint32_t aFlags, const bool aCanGoBack,
    301      const bool aCanGoBackIgnoringUserInteraction, const bool aCanGoForward,
    302      const Maybe<WebProgressLocationChangeData>& aLocationChangeData);
    303 
    304  mozilla::ipc::IPCResult RecvOnStatusChange(const nsString& aMessage);
    305 
    306  mozilla::ipc::IPCResult RecvNotifyContentBlockingEvent(
    307      const uint32_t& aEvent, const RequestData& aRequestData,
    308      const bool aBlocked, const nsACString& aTrackingOrigin,
    309      nsTArray<nsCString>&& aTrackingFullHashes,
    310      const Maybe<mozilla::ContentBlockingNotifier::
    311                      StorageAccessPermissionGrantedReason>& aReason,
    312      const Maybe<CanvasFingerprintingEvent>& aCanvasFingerprintingEvent);
    313 
    314  mozilla::ipc::IPCResult RecvNavigationFinished();
    315 
    316  already_AddRefed<nsIBrowser> GetBrowser();
    317 
    318  bool ReceiveProgressListenerData(const WebProgressData& aWebProgressData,
    319                                   const RequestData& aRequestData,
    320                                   CanonicalBrowsingContext** aBrowsingContext,
    321                                   nsIRequest** aRequest);
    322 
    323  mozilla::ipc::IPCResult RecvIntrinsicSizeOrRatioChanged(
    324      const Maybe<IntrinsicSize>& aIntrinsicSize,
    325      const Maybe<AspectRatio>& aIntrinsicRatio);
    326 
    327  mozilla::ipc::IPCResult RecvImageLoadComplete(const nsresult& aResult);
    328 
    329  mozilla::ipc::IPCResult RecvSyncMessage(
    330      const nsString& aMessage, const ClonedMessageData& aData,
    331      nsTArray<UniquePtr<ipc::StructuredCloneData>>* aRetVal);
    332 
    333  mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMessage,
    334                                           const ClonedMessageData& aData);
    335 
    336  mozilla::ipc::IPCResult RecvNotifyIMEFocus(
    337      const ContentCache& aContentCache,
    338      const widget::IMENotification& aEventMessage,
    339      NotifyIMEFocusResolver&& aResolve);
    340 
    341  mozilla::ipc::IPCResult RecvNotifyIMETextChange(
    342      const ContentCache& aContentCache,
    343      const widget::IMENotification& aEventMessage);
    344 
    345  mozilla::ipc::IPCResult RecvNotifyIMECompositionUpdate(
    346      const ContentCache& aContentCache,
    347      const widget::IMENotification& aEventMessage);
    348 
    349  mozilla::ipc::IPCResult RecvNotifyIMESelection(
    350      const ContentCache& aContentCache,
    351      const widget::IMENotification& aEventMessage);
    352 
    353  mozilla::ipc::IPCResult RecvUpdateContentCache(
    354      const ContentCache& aContentCache);
    355 
    356  mozilla::ipc::IPCResult RecvNotifyIMEMouseButtonEvent(
    357      const widget::IMENotification& aEventMessage, bool* aConsumedByIME);
    358 
    359  mozilla::ipc::IPCResult RecvNotifyIMEPositionChange(
    360      const ContentCache& aContentCache,
    361      const widget::IMENotification& aEventMessage);
    362 
    363  mozilla::ipc::IPCResult RecvOnEventNeedingAckHandled(
    364      const EventMessage& aMessage, const uint32_t& aCompositionId);
    365 
    366  mozilla::ipc::IPCResult RecvRequestIMEToCommitComposition(
    367      const bool& aCancel, const uint32_t& aCompositionId, bool* aIsCommitted,
    368      nsString* aCommittedString);
    369 
    370  mozilla::ipc::IPCResult RecvGetInputContext(widget::IMEState* aIMEState);
    371 
    372  mozilla::ipc::IPCResult RecvSetInputContext(
    373      const widget::InputContext& aContext,
    374      const widget::InputContextAction& aAction);
    375 
    376  mozilla::ipc::IPCResult RecvRequestFocus(const bool& aCanRaise,
    377                                           const CallerType aCallerType);
    378 
    379  mozilla::ipc::IPCResult RecvWheelZoomChange(bool aIncrease);
    380 
    381  mozilla::ipc::IPCResult RecvLookUpDictionary(
    382      const nsString& aText, nsTArray<mozilla::FontRange>&& aFontRangeArray,
    383      const bool& aIsVertical, const LayoutDeviceIntPoint& aPoint);
    384 
    385  mozilla::ipc::IPCResult RecvEnableDisableCommands(
    386      const MaybeDiscarded<BrowsingContext>& aContext, const nsString& aAction,
    387      nsTArray<nsCString>&& aEnabledCommands,
    388      nsTArray<nsCString>&& aDisabledCommands);
    389 
    390  mozilla::ipc::IPCResult RecvSetCursor(
    391      const nsCursor& aValue, Maybe<IPCImage>&& aCustomCursor,
    392      const float& aResolutionX, const float& aResolutionY,
    393      const uint32_t& aHotspotX, const uint32_t& aHotspotY, const bool& aForce);
    394 
    395  mozilla::ipc::IPCResult RecvSetLinkStatus(const nsString& aStatus);
    396 
    397  mozilla::ipc::IPCResult RecvShowTooltip(const uint32_t& aX,
    398                                          const uint32_t& aY,
    399                                          const nsString& aTooltip,
    400                                          const nsString& aDirection);
    401 
    402  mozilla::ipc::IPCResult RecvHideTooltip();
    403 
    404  mozilla::ipc::IPCResult RecvRespondStartSwipeEvent(
    405      const uint64_t& aInputBlockId, const bool& aStartSwipe);
    406 
    407  mozilla::ipc::IPCResult RecvDispatchWheelEvent(
    408      const mozilla::WidgetWheelEvent& aEvent);
    409 
    410  mozilla::ipc::IPCResult RecvDispatchMouseEvent(
    411      const mozilla::WidgetMouseEvent& aEvent);
    412 
    413  mozilla::ipc::IPCResult RecvDispatchKeyboardEvent(
    414      const mozilla::WidgetKeyboardEvent& aEvent);
    415 
    416  mozilla::ipc::IPCResult RecvDispatchTouchEvent(
    417      const mozilla::WidgetTouchEvent& aEvent);
    418 
    419  mozilla::ipc::IPCResult RecvScrollRectIntoView(
    420      const nsRect& aRect, const ScrollAxis& aVertical,
    421      const ScrollAxis& aHorizontal, const ScrollFlags& aScrollFlags,
    422      const int32_t& aAppUnitsPerDevPixel);
    423 
    424  already_AddRefed<PColorPickerParent> AllocPColorPickerParent(
    425      const MaybeDiscarded<BrowsingContext>& aBrowsingContext,
    426      const nsString& aTitle, const nsString& aInitialColor,
    427      const nsTArray<nsString>& aDefaultColors);
    428 
    429  already_AddRefed<PVsyncParent> AllocPVsyncParent();
    430 
    431  mozilla::ipc::IPCResult RecvPVsyncConstructor(PVsyncParent* aActor) override;
    432 
    433 #ifdef ACCESSIBILITY
    434  PDocAccessibleParent* AllocPDocAccessibleParent(
    435      PDocAccessibleParent*, const uint64_t&,
    436      const MaybeDiscardedBrowsingContext&);
    437  bool DeallocPDocAccessibleParent(PDocAccessibleParent*);
    438  virtual mozilla::ipc::IPCResult RecvPDocAccessibleConstructor(
    439      PDocAccessibleParent* aDoc, PDocAccessibleParent* aParentDoc,
    440      const uint64_t& aParentID,
    441      const MaybeDiscardedBrowsingContext& aBrowsingContext) override;
    442 #endif
    443 
    444  already_AddRefed<PSessionStoreParent> AllocPSessionStoreParent();
    445 
    446  mozilla::ipc::IPCResult RecvNewWindowGlobal(
    447      ManagedEndpoint<PWindowGlobalParent>&& aEndpoint,
    448      const WindowGlobalInit& aInit);
    449 
    450  mozilla::ipc::IPCResult RecvIsWindowSupportingProtectedMedia(
    451      const uint64_t& aOuterWindowID,
    452      IsWindowSupportingProtectedMediaResolver&& aResolve);
    453 
    454  mozilla::ipc::IPCResult RecvIsWindowSupportingWebVR(
    455      const uint64_t& aOuterWindowID,
    456      IsWindowSupportingWebVRResolver&& aResolve);
    457 
    458  void LoadURL(nsDocShellLoadState* aLoadState);
    459 
    460  void ResumeLoad(uint64_t aPendingSwitchID);
    461 
    462  void InitRendering();
    463  bool AttachWindowRenderer();
    464  void MaybeShowFrame();
    465 
    466  bool Show(const OwnerShowInfo&);
    467 
    468  void UpdateDimensions(const LayoutDeviceIntRect& aRect,
    469                        const LayoutDeviceIntSize& aSize);
    470 
    471  DimensionInfo GetDimensionInfo();
    472 
    473  nsresult UpdatePosition();
    474 
    475  void SizeModeChanged(const nsSizeMode& aSizeMode);
    476 
    477  void HandleAccessKey(const WidgetKeyboardEvent& aEvent,
    478                       nsTArray<uint32_t>& aCharCodes);
    479 
    480  void DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight);
    481  void DynamicToolbarOffsetChanged(ScreenIntCoord aOffset);
    482 #ifdef MOZ_WIDGET_ANDROID
    483  void KeyboardHeightChanged(ScreenIntCoord aHeight);
    484  void AndroidPipModeChanged(bool);
    485 #endif
    486 
    487  void Activate(uint64_t aActionId);
    488 
    489  void Deactivate(bool aWindowLowering, uint64_t aActionId);
    490 
    491  void MouseEnterIntoWidget();
    492 
    493  bool MapEventCoordinatesForChildProcess(mozilla::WidgetEvent* aEvent);
    494 
    495  void MapEventCoordinatesForChildProcess(const LayoutDeviceIntPoint& aOffset,
    496                                          mozilla::WidgetEvent* aEvent);
    497 
    498  LayoutDeviceToCSSScale GetLayoutDeviceToCSSScale();
    499 
    500  MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult
    501  RecvRequestNativeKeyBindings(const uint32_t& aType,
    502                               const mozilla::WidgetKeyboardEvent& aEvent,
    503                               nsTArray<mozilla::CommandInt>* aCommands);
    504 
    505  mozilla::ipc::IPCResult RecvSynthesizeNativeKeyEvent(
    506      const int32_t& aNativeKeyboardLayout, const int32_t& aNativeKeyCode,
    507      const uint32_t& aModifierFlags, const nsString& aCharacters,
    508      const nsString& aUnmodifiedCharacters,
    509      const Maybe<uint64_t>& aCallbackId);
    510 
    511  mozilla::ipc::IPCResult RecvSynthesizeNativeMouseEvent(
    512      const LayoutDeviceIntPoint& aPoint, const uint32_t& aNativeMessage,
    513      const int16_t& aButton, const uint32_t& aModifierFlags,
    514      const Maybe<uint64_t>& aCallbackId);
    515 
    516  mozilla::ipc::IPCResult RecvSynthesizeNativeMouseMove(
    517      const LayoutDeviceIntPoint& aPoint, const Maybe<uint64_t>& aCallbackId);
    518 
    519  mozilla::ipc::IPCResult RecvSynthesizeNativeMouseScrollEvent(
    520      const LayoutDeviceIntPoint& aPoint, const uint32_t& aNativeMessage,
    521      const double& aDeltaX, const double& aDeltaY, const double& aDeltaZ,
    522      const uint32_t& aModifierFlags, const uint32_t& aAdditionalFlags,
    523      const Maybe<uint64_t>& aCallbackId);
    524 
    525  mozilla::ipc::IPCResult RecvSynthesizeNativeTouchPoint(
    526      const uint32_t& aPointerId, const TouchPointerState& aPointerState,
    527      const LayoutDeviceIntPoint& aPoint, const double& aPointerPressure,
    528      const uint32_t& aPointerOrientation, const Maybe<uint64_t>& aCallbackId);
    529 
    530  mozilla::ipc::IPCResult RecvSynthesizeNativeTouchPadPinch(
    531      const TouchpadGesturePhase& aEventPhase, const float& aScale,
    532      const LayoutDeviceIntPoint& aPoint, const int32_t& aModifierFlags);
    533 
    534  mozilla::ipc::IPCResult RecvSynthesizeNativeTouchTap(
    535      const LayoutDeviceIntPoint& aPoint, const bool& aLongTap,
    536      const Maybe<uint64_t>& aCallbackId);
    537 
    538  mozilla::ipc::IPCResult RecvSynthesizeNativePenInput(
    539      const uint32_t& aPointerId, const TouchPointerState& aPointerState,
    540      const LayoutDeviceIntPoint& aPoint, const double& aPressure,
    541      const uint32_t& aRotation, const int32_t& aTiltX, const int32_t& aTiltY,
    542      const int32_t& aButton, const Maybe<uint64_t>& aCallbackId);
    543 
    544  mozilla::ipc::IPCResult RecvSynthesizeNativeTouchpadDoubleTap(
    545      const LayoutDeviceIntPoint& aPoint, const uint32_t& aModifierFlags);
    546 
    547  mozilla::ipc::IPCResult RecvSynthesizeNativeTouchpadPan(
    548      const TouchpadGesturePhase& aEventPhase,
    549      const LayoutDeviceIntPoint& aPoint, const double& aDeltaX,
    550      const double& aDeltaY, const int32_t& aModifierFlags,
    551      const Maybe<uint64_t>& aCallbackId);
    552 
    553  mozilla::ipc::IPCResult RecvLockNativePointer();
    554 
    555  mozilla::ipc::IPCResult RecvUnlockNativePointer();
    556 
    557  /**
    558   * The following Send*Event() marks aEvent as posted to remote process if
    559   * it succeeded.  So, you can check the result with
    560   * aEvent.HasBeenPostedToRemoteProcess().
    561   */
    562  void SendRealMouseEvent(WidgetMouseEvent& aEvent);
    563 
    564  void SendRealDragEvent(WidgetDragEvent& aEvent, uint32_t aDragAction,
    565                         uint32_t aDropEffect, nsIPrincipal* aPrincipal,
    566                         nsIPolicyContainer* aPolicyContainer);
    567 
    568  void SendMouseWheelEvent(WidgetWheelEvent& aEvent);
    569 
    570  mozilla::ipc::IPCResult RecvSynthesizedEventResponse(
    571      const uint64_t& aCallbackId);
    572 
    573  /**
    574   * Only when the event is synthesized, retrieving writing mode may flush
    575   * the layout.
    576   */
    577  MOZ_CAN_RUN_SCRIPT_BOUNDARY void SendRealKeyEvent(
    578      WidgetKeyboardEvent& aEvent);
    579 
    580  void SendRealTouchEvent(WidgetTouchEvent& aEvent);
    581 
    582  /**
    583   * Different from above Send*Event(), these methods return true if the
    584   * event has been posted to the remote process or failed to do that but
    585   * shouldn't be handled by following event listeners.
    586   * If you need to check if it's actually posted to the remote process,
    587   * you can refer aEvent.HasBeenPostedToRemoteProcess().
    588   */
    589  bool SendCompositionEvent(mozilla::WidgetCompositionEvent& aEvent,
    590                            uint32_t aCompositionId);
    591 
    592  bool SendSelectionEvent(mozilla::WidgetSelectionEvent& aEvent);
    593 
    594  MOZ_CAN_RUN_SCRIPT_BOUNDARY bool SendHandleTap(
    595      TapType aType, const LayoutDevicePoint& aPoint, Modifiers aModifiers,
    596      const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId,
    597      const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
    598 
    599  already_AddRefed<PFilePickerParent> AllocPFilePickerParent(
    600      const nsString& aTitle, const nsIFilePicker::Mode& aMode,
    601      const MaybeDiscarded<BrowsingContext>& aBrowsingContext);
    602 
    603  bool GetGlobalJSObject(JSContext* cx, JSObject** globalp);
    604 
    605  void StartPersistence(CanonicalBrowsingContext* aContext,
    606                        nsIWebBrowserPersistDocumentReceiver* aRecv,
    607                        ErrorResult& aRv);
    608 
    609  bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent);
    610 
    611  bool SendSimpleContentCommandEvent(
    612      const mozilla::WidgetContentCommandEvent& aEvent);
    613  bool SendInsertText(const mozilla::WidgetContentCommandEvent& aEvent);
    614  bool SendReplaceText(const mozilla::WidgetContentCommandEvent& aEvent);
    615 
    616  bool SendPasteTransferable(IPCTransferable&& aTransferable);
    617 
    618  // Helper for transforming a point
    619  LayoutDeviceIntPoint TransformPoint(
    620      const LayoutDeviceIntPoint& aPoint,
    621      const LayoutDeviceToLayoutDeviceMatrix4x4& aMatrix);
    622  LayoutDevicePoint TransformPoint(
    623      const LayoutDevicePoint& aPoint,
    624      const LayoutDeviceToLayoutDeviceMatrix4x4& aMatrix);
    625 
    626  // Transform a coordinate from the parent process coordinate space to the
    627  // child process coordinate space.
    628  LayoutDeviceIntPoint TransformParentToChild(const WidgetMouseEvent& aEvent);
    629  LayoutDeviceIntPoint TransformParentToChild(
    630      const LayoutDeviceIntPoint& aPoint);
    631  LayoutDevicePoint TransformParentToChild(const LayoutDevicePoint& aPoint);
    632 
    633  // Transform a coordinate from the child process coordinate space to the
    634  // parent process coordinate space.
    635  LayoutDeviceIntPoint TransformChildToParent(
    636      const LayoutDeviceIntPoint& aPoint);
    637  LayoutDevicePoint TransformChildToParent(const LayoutDevicePoint& aPoint);
    638  LayoutDeviceIntRect TransformChildToParent(const LayoutDeviceIntRect& aRect);
    639 
    640  // Returns the matrix that transforms event coordinates from the coordinate
    641  // space of the child process to the coordinate space of the parent process.
    642  LayoutDeviceToLayoutDeviceMatrix4x4 GetChildToParentConversionMatrix();
    643 
    644  void SetChildToParentConversionMatrix(
    645      const Maybe<LayoutDeviceToLayoutDeviceMatrix4x4>& aMatrix,
    646      const ScreenRect& aRemoteDocumentRect);
    647 
    648  // Returns the offset from the origin of our frameloader's nearest widget to
    649  // the origin of its layout frame. This offset is used to translate event
    650  // coordinates relative to the PuppetWidget origin in the child process.
    651  //
    652  // GOING AWAY. PLEASE AVOID ADDING CALLERS. Use the above tranformation
    653  // methods instead.
    654  LayoutDeviceIntPoint GetChildProcessOffset();
    655 
    656  // Returns the offset from the on-screen origin of our top-level window's
    657  // widget (including window decorations) to the origin of our frameloader's
    658  // nearest widget. This offset is used to translate coordinates from the
    659  // PuppetWidget's origin to absolute screen coordinates in the child.
    660  LayoutDeviceIntPoint GetClientOffset();
    661 
    662  void StopIMEStateManagement();
    663 
    664  PPaymentRequestParent* AllocPPaymentRequestParent();
    665 
    666  bool DeallocPPaymentRequestParent(PPaymentRequestParent* aActor);
    667 
    668  bool SendLoadRemoteScript(const nsAString& aURL,
    669                            const bool& aRunInGlobalScope);
    670 
    671  void LayerTreeUpdate(bool aActive);
    672 
    673  mozilla::ipc::IPCResult RecvInvokeDragSession(
    674      nsTArray<IPCTransferableData>&& aTransferables, const uint32_t& aAction,
    675      Maybe<BigBuffer>&& aVisualDnDData, const uint32_t& aStride,
    676      const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect,
    677      nsIPrincipal* aPrincipal, nsIPolicyContainer* aPolicyContainer,
    678      const CookieJarSettingsArgs& aCookieJarSettingsArgs,
    679      const MaybeDiscarded<WindowContext>& aSourceWindowContext,
    680      const MaybeDiscarded<WindowContext>& aSourceTopWindowContext);
    681 
    682  mozilla::ipc::IPCResult RecvUpdateDropEffect(const uint32_t& aDragAction,
    683                                               const uint32_t& aDropEffect);
    684 
    685  void AddInitialDnDDataTo(IPCTransferableData* aTransferableData,
    686                           nsIPrincipal** aPrincipal);
    687 
    688  bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
    689                             LayoutDeviceIntRect* aDragRect);
    690 
    691  mozilla::ipc::IPCResult RecvEnsureLayersConnected(
    692      CompositorOptions* aCompositorOptions);
    693 
    694  // LiveResizeListener implementation
    695  void LiveResizeStarted() override;
    696  void LiveResizeStopped() override;
    697 
    698  void SetReadyToHandleInputEvents() { mIsReadyToHandleInputEvents = true; }
    699  bool IsReadyToHandleInputEvents() { return mIsReadyToHandleInputEvents; }
    700 
    701  void NavigateByKey(bool aForward, bool aForDocumentNavigation);
    702 
    703  bool GetDocShellIsActive() const;
    704 
    705  bool GetHasPresented();
    706  bool GetHasLayers();
    707  bool GetRenderLayers();
    708  void SetRenderLayers(bool aRenderLayers);
    709  bool GetPriorityHint();
    710  void SetPriorityHint(bool aPriorityHint);
    711  void PreserveLayers(bool aPreserveLayers);
    712  void NotifyResolutionChanged();
    713  void NotifyTransparencyChanged();
    714 
    715  bool CanCancelContentJS(nsIRemoteTab::NavigationType aNavigationType,
    716                          int32_t aNavigationIndex,
    717                          nsIURI* aNavigationURI) const;
    718 
    719  // Called when the BrowserParent is being destroyed or entering bfcache.
    720  void Deactivated();
    721 
    722  void MaybeInvokeDragSession(EventMessage aMessage);
    723 
    724 protected:
    725  friend BrowserBridgeParent;
    726  friend BrowserHost;
    727 
    728  void SetBrowserBridgeParent(BrowserBridgeParent* aBrowser);
    729  void SetBrowserHost(BrowserHost* aBrowser);
    730 
    731  bool ReceiveMessage(
    732      const nsString& aMessage, bool aSync, ipc::StructuredCloneData* aData,
    733      nsTArray<UniquePtr<ipc::StructuredCloneData>>* aJSONRetVal = nullptr);
    734 
    735  virtual void ActorDestroy(ActorDestroyReason why) override;
    736 
    737  mozilla::ipc::IPCResult RecvRemoteIsReadyToHandleInputEvents();
    738 
    739  mozilla::ipc::IPCResult RecvSetDimensions(mozilla::DimensionRequest aRequest,
    740                                            const double& aScale);
    741 
    742  mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(
    743      const nsCString& aOrigin, const bool& aHideDoorHanger);
    744 
    745  mozilla::ipc::IPCResult RecvShowOnionServicesAuthPrompt(
    746      const nsCString& aOnionName, const nsCString& aTopic);
    747 
    748  mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName);
    749  mozilla::ipc::IPCResult RecvGetSystemFont(nsCString* aFontName);
    750 
    751  mozilla::ipc::IPCResult RecvVisitURI(nsIURI* aURI, nsIURI* aLastVisitedURI,
    752                                       const uint32_t& aFlags,
    753                                       const uint64_t& aBrowserId);
    754 
    755  mozilla::ipc::IPCResult RecvQueryVisitedState(
    756      nsTArray<RefPtr<nsIURI>>&& aURIs);
    757 
    758  mozilla::ipc::IPCResult RecvMaybeFireEmbedderLoadEvents(
    759      EmbedderElementEventType aFireEventAtEmbeddingElement);
    760 
    761  mozilla::ipc::IPCResult RecvRequestPointerLock(
    762      RequestPointerLockResolver&& aResolve);
    763  mozilla::ipc::IPCResult RecvReleasePointerLock();
    764 
    765  mozilla::ipc::IPCResult RecvRequestPointerCapture(
    766      const uint32_t& aPointerId, RequestPointerCaptureResolver&& aResolve);
    767  mozilla::ipc::IPCResult RecvReleasePointerCapture(const uint32_t& aPointerId);
    768 
    769  mozilla::ipc::IPCResult RecvShowDynamicToolbar();
    770 
    771  void GetIPCTransferableData(nsIDragSession* aSession,
    772                              nsTArray<IPCTransferableData>& aIPCTransferables);
    773 
    774 private:
    775  void SuppressDisplayport(bool aEnabled);
    776 
    777  void SetRenderLayersInternal(bool aEnabled);
    778 
    779  already_AddRefed<nsFrameLoader> GetFrameLoader(
    780      bool aUseCachedFrameLoaderAfterDestroy = false) const;
    781 
    782  void TryCacheDPIAndScale();
    783 
    784  bool AsyncPanZoomEnabled() const;
    785 
    786  // Update state prior to routing an APZ-aware event to the child process.
    787  // |aOutTargetGuid| will contain the identifier
    788  // of the APZC instance that handled the event. aOutTargetGuid may be null.
    789  // |aOutInputBlockId| will contain the identifier of the input block
    790  // that this event was added to, if there was one. aOutInputBlockId may be
    791  // null. |aOutApzResponse| will contain the response that the APZ gave when
    792  // processing the input block; this is used for generating appropriate
    793  // pointercancel events.
    794  void ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
    795                                   uint64_t* aOutInputBlockId,
    796                                   nsEventStatus* aOutApzResponse);
    797 
    798  // When dropping links we perform a roundtrip from
    799  // Parent (SendRealDragEvent) -> Child -> Parent (RecvDropLinks)
    800  // and have to ensure that the child did not modify links to be loaded.
    801  bool QueryDropLinksForVerification();
    802 
    803  void UnlockNativePointer();
    804 
    805  void UpdateNativePointerLockCenter(nsIWidget* aWidget);
    806 
    807 private:
    808  // This is used when APZ needs to find the BrowserParent associated with a
    809  // layer to dispatch events.
    810  typedef nsTHashMap<nsUint64HashKey, BrowserParent*> LayerToBrowserParentTable;
    811  static LayerToBrowserParentTable* sLayerToBrowserParentTable;
    812 
    813  static void AddBrowserParentToTable(layers::LayersId aLayersId,
    814                                      BrowserParent* aBrowserParent);
    815 
    816  static void RemoveBrowserParentFromTable(layers::LayersId aLayersId);
    817 
    818  // Keeps track of which BrowserParent has keyboard focus.
    819  // If nullptr, the parent process has focus.
    820  // Use UpdateFocus() to manage.
    821  static BrowserParent* sFocus;
    822 
    823  // Keeps track of which top-level BrowserParent the keyboard focus is under.
    824  // If nullptr, the parent process has focus.
    825  // Use SetTopLevelWebFocus and UnsetTopLevelWebFocus to manage.
    826  static BrowserParent* sTopLevelWebFocus;
    827 
    828  // Setter for sTopLevelWebFocus
    829  static void SetTopLevelWebFocus(BrowserParent* aBrowserParent);
    830 
    831  // Unsetter for sTopLevelWebFocus; only unsets if argument matches
    832  // current sTopLevelWebFocus. Use UnsetTopLevelWebFocusAll() to
    833  // unset regardless of current value.
    834  static void UnsetTopLevelWebFocus(BrowserParent* aBrowserParent);
    835 
    836  // Recomputes sFocus and returns it.
    837  static BrowserParent* UpdateFocus();
    838 
    839  // Keeps track of which BrowserParent the real mouse event is sent to.
    840  static BrowserParent* sLastMouseRemoteTarget;
    841 
    842  // Unsetter for LastMouseRemoteTarget; only unsets if argument matches
    843  // current sLastMouseRemoteTarget.
    844  static void UnsetLastMouseRemoteTarget(BrowserParent* aBrowserParent);
    845 
    846  struct APZData {
    847    bool operator==(const APZData& aOther) const {
    848      return aOther.guid == guid && aOther.blockId == blockId &&
    849             aOther.apzResponse == apzResponse;
    850    }
    851 
    852    bool operator!=(const APZData& aOther) const { return !(*this == aOther); }
    853 
    854    ScrollableLayerGuid guid;
    855    uint64_t blockId;
    856    nsEventStatus apzResponse;
    857  };
    858  void SendRealTouchMoveEvent(WidgetTouchEvent& aEvent, APZData& aAPZData,
    859                              uint32_t aConsecutiveTouchMoveCount);
    860 
    861  void UpdateVsyncParentVsyncDispatcher();
    862 
    863 public:
    864  // Unsets sTopLevelWebFocus regardless of its current value.
    865  static void UnsetTopLevelWebFocusAll();
    866 
    867  // Recomputes focus when the BrowsingContext tree changes in a
    868  // way that potentially invalidates the sFocus.
    869  static void UpdateFocusFromBrowsingContext();
    870 
    871 private:
    872  TabId mTabId;
    873 
    874  // The root browsing context loaded in this BrowserParent.
    875  RefPtr<CanonicalBrowsingContext> mBrowsingContext;
    876  RefPtr<Element> mFrameElement;
    877  nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
    878  // We keep a strong reference to the frameloader after we've sent the
    879  // Destroy message and before we've received __delete__. This allows us to
    880  // dispatch message manager messages during this time.
    881  RefPtr<nsFrameLoader> mFrameLoader;
    882  uint32_t mChromeFlags;
    883 
    884  // Pointer back to BrowserBridgeParent if there is one associated with
    885  // this BrowserParent. This is non-owning to avoid cycles and is managed
    886  // by the BrowserBridgeParent instance, which has the strong reference
    887  // to this BrowserParent.
    888  BrowserBridgeParent* mBrowserBridgeParent;
    889  // Pointer to the BrowserHost that owns us, if any. This is mutually
    890  // exclusive with mBrowserBridgeParent, and one is guaranteed to be
    891  // non-null.
    892  BrowserHost* mBrowserHost;
    893 
    894  // KeepAlive for the containing process.
    895  // NOTE: While this is a strong reference to ContentParent, which is
    896  // cycle-collected, it is cleared as the BrowserParent's IPC connection is
    897  // destroyed, so does not need to be cycle-collected.
    898  UniqueContentParentKeepAlive mContentParentKeepAlive;
    899 
    900  ContentCacheInParent mContentCache;
    901 
    902  layout::RemoteLayerTreeOwner mRemoteLayerTreeOwner;
    903 
    904  Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
    905  Maybe<ScreenRect> mRemoteDocumentRect;
    906 
    907  // mWaitingReplyKeyboardEvents stores keyboard events which are sent from
    908  // SendRealKeyEvent and the event will be back as a reply event.  They are
    909  // removed when RecvReplyKeyEvent receives corresponding event or newer event.
    910  // Note that reply event will be used for handling non-reserved shortcut keys.
    911  // Therefore, we need to store only important data for GlobalKeyHandler.
    912  struct SentKeyEventData {
    913    uint32_t mKeyCode;
    914    uint32_t mCharCode;
    915    uint32_t mPseudoCharCode;
    916    KeyNameIndex mKeyNameIndex;
    917    CodeNameIndex mCodeNameIndex;
    918    Modifiers mModifiers;
    919    nsID mUUID;
    920  };
    921  nsTArray<SentKeyEventData> mWaitingReplyKeyboardEvents;
    922 
    923  LayoutDeviceIntRect mRect;
    924  LayoutDeviceIntSize mDimensions;
    925  float mDPI;
    926  int32_t mRounding;
    927  CSSToLayoutDeviceScale mDefaultScale;
    928  bool mUpdatedDimensions;
    929  nsSizeMode mSizeMode;
    930  LayoutDeviceIntPoint mClientOffset;
    931  LayoutDeviceIntPoint mChromeOffset;
    932 
    933  // When loading a new tab or window via window.open, the child is
    934  // responsible for loading the URL it wants into the new BrowserChild. When
    935  // the parent receives the CreateWindow message, though, it sends a LoadURL
    936  // message, usually for about:blank. It's important for the about:blank load
    937  // to get processed because the Firefox frontend expects every new window to
    938  // immediately start loading something (see bug 1123090). However, we want
    939  // the child to process the LoadURL message before it returns from
    940  // ProvideWindow so that the URL sent from the parent doesn't override the
    941  // child's URL. This is not possible using our IPC mechanisms. To solve the
    942  // problem, we skip sending the LoadURL message in the parent and instead
    943  // return the URL as a result from CreateWindow. The child simulates
    944  // receiving a LoadURL message before returning from ProvideWindow.
    945  //
    946  // The mCreatingWindow flag is set while dispatching CreateWindow. During
    947  // that time, any LoadURL calls are skipped.
    948  bool mCreatingWindow;
    949 
    950  // When loading a new tab or window via window.open, we want to ensure that
    951  // frame scripts for that tab are loaded before any scripts start to run in
    952  // the window. We can't load the frame scripts the normal way, using
    953  // separate IPC messages, since they won't be processed by the child until
    954  // returning to the event loop, which is too late. Instead, we queue up
    955  // frame scripts that we intend to load and send them as part of the
    956  // CreateWindow response. Then BrowserChild loads them immediately.
    957  nsTArray<FrameScriptInfo> mDelayedFrameScripts;
    958 
    959  // Cached cursor setting from BrowserChild.  When the cursor is over the
    960  // tab, it should take this appearance.
    961  nsIWidget::Cursor mCursor;
    962 
    963  nsTArray<nsString> mVerifyDropLinks;
    964 
    965 #ifdef DEBUG
    966  int32_t mActiveSupressDisplayportCount = 0;
    967 #endif
    968 
    969  // When true, we've initiated normal shutdown and notified our managing
    970  // PContent.
    971  bool mMarkedDestroying : 1;
    972  // When true, the BrowserParent is invalid and we should not send IPC
    973  // messages anymore.
    974  bool mIsDestroyed : 1;
    975  // True if the cursor changes from the BrowserChild should change the widget
    976  // cursor.  This happens whenever the cursor is in the remote target's
    977  // region.
    978  bool mRemoteTargetSetsCursor : 1;
    979 
    980  // If this flag is set, then the tab's layers will be preserved even when
    981  // the tab's docshell is inactive.
    982  bool mIsPreservingLayers : 1;
    983 
    984  // Holds the most recent value passed to the RenderLayers function. This
    985  // does not necessarily mean that the layers have finished rendering
    986  // and have uploaded - for that, use mHasLayers.
    987  bool mRenderLayers : 1;
    988 
    989  // True if process should be set to a higher priority.
    990  bool mPriorityHint : 1;
    991 
    992  // True if the compositor has reported that the BrowserChild has uploaded
    993  // layers.
    994  bool mHasLayers : 1;
    995 
    996  // True if this BrowserParent has had its layer tree sent to the compositor
    997  // at least once.
    998  bool mHasPresented : 1;
    999 
   1000  // True when the remote browser is created and ready to handle input events.
   1001  bool mIsReadyToHandleInputEvents : 1;
   1002 
   1003  // True if we suppress the eMouseEnterIntoWidget event due to the
   1004  // BrowserChild was not ready to handle it. We will resend it when the next
   1005  // time we fire a mouse event and the BrowserChild is ready.
   1006  bool mIsMouseEnterIntoWidgetEventSuppressed : 1;
   1007 
   1008  // True after RecvLockNativePointer has been called and until
   1009  // UnlockNativePointer has been called.
   1010  bool mLockedNativePointer : 1;
   1011 
   1012  // True between ShowTooltip and HideTooltip messages.
   1013  bool mShowingTooltip : 1;
   1014 };
   1015 
   1016 struct MOZ_STACK_CLASS BrowserParent::AutoUseNewTab final {
   1017 public:
   1018  explicit AutoUseNewTab(BrowserParent* aNewTab) : mNewTab(aNewTab) {
   1019    MOZ_ASSERT(!aNewTab->mCreatingWindow);
   1020    aNewTab->mCreatingWindow = true;
   1021  }
   1022 
   1023  ~AutoUseNewTab() { mNewTab->mCreatingWindow = false; }
   1024 
   1025 private:
   1026  RefPtr<BrowserParent> mNewTab;
   1027 };
   1028 
   1029 }  // namespace dom
   1030 }  // namespace mozilla
   1031 
   1032 #endif  // mozilla_dom_BrowserParent_h