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/. */
7 #ifndef mozilla_dom_BrowserBridgeChild_h
8 #define mozilla_dom_BrowserBridgeChild_h
10 #include "mozilla/dom/PBrowserBridgeChild.h"
11 #include "mozilla/dom/BrowserChild.h"
12 #include "mozilla/dom/ipc/IdType.h"
14 namespace mozilla::dom
{
15 class BrowsingContext
;
17 class BrowserBridgeHost
;
20 * BrowserBridgeChild implements the child actor part of the PBrowserBridge
21 * protocol. See PBrowserBridge for more information.
23 class BrowserBridgeChild
: public PBrowserBridgeChild
{
25 typedef mozilla::layers::LayersId LayersId
;
27 NS_INLINE_DECL_REFCOUNTING(BrowserBridgeChild
, final
);
29 BrowserChild
* Manager() {
30 MOZ_ASSERT(CanSend());
31 return static_cast<BrowserChild
*>(PBrowserBridgeChild::Manager());
34 TabId
GetTabId() { return mId
; }
36 LayersId
GetLayersId() { return mLayersId
; }
38 nsFrameLoader
* GetFrameLoader() const { return mFrameLoader
; }
40 BrowsingContext
* GetBrowsingContext() { return mBrowsingContext
; }
42 nsILoadContext
* GetLoadContext();
44 void NavigateByKey(bool aForward
, bool aForDocumentNavigation
);
46 void Activate(uint64_t aActionId
);
48 void Deactivate(bool aWindowLowering
, uint64_t aActionId
);
50 already_AddRefed
<BrowserBridgeHost
> FinishInit(nsFrameLoader
* aFrameLoader
);
52 #if defined(ACCESSIBILITY)
53 void SetEmbedderAccessible(PDocAccessibleChild
* aDoc
, uint64_t aID
) {
54 MOZ_ASSERT((aDoc
&& aID
) || (!aDoc
&& !aID
));
55 mEmbedderAccessibleID
= aID
;
56 Unused
<< SendSetEmbedderAccessible(aDoc
, aID
);
59 uint64_t GetEmbedderAccessibleID() { return mEmbedderAccessibleID
; }
60 #endif // defined(ACCESSIBILITY)
62 static BrowserBridgeChild
* GetFrom(nsFrameLoader
* aFrameLoader
);
64 static BrowserBridgeChild
* GetFrom(nsIContent
* aContent
);
66 BrowserBridgeChild(BrowsingContext
* aBrowsingContext
, TabId aId
,
67 const LayersId
& aLayersId
);
70 friend class ContentChild
;
71 friend class PBrowserBridgeChild
;
73 mozilla::ipc::IPCResult
RecvRequestFocus(const bool& aCanRaise
,
74 const CallerType aCallerType
);
76 mozilla::ipc::IPCResult
RecvMoveFocus(const bool& aForward
,
77 const bool& aForDocumentNavigation
);
79 // TODO: Use MOZ_CAN_RUN_SCRIPT when it gains IPDL support (bug 1539864)
80 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
81 RecvMaybeFireEmbedderLoadEvents(
82 EmbedderElementEventType aFireEventAtEmbeddingElement
);
84 mozilla::ipc::IPCResult
RecvIntrinsicSizeOrRatioChanged(
85 const Maybe
<IntrinsicSize
>& aIntrinsicSize
,
86 const Maybe
<AspectRatio
>& aIntrinsicRatio
);
88 mozilla::ipc::IPCResult
RecvImageLoadComplete(const nsresult
& aResult
);
90 MOZ_CAN_RUN_SCRIPT_BOUNDARY
91 mozilla::ipc::IPCResult
RecvScrollRectIntoView(
92 const nsRect
& aRect
, const ScrollAxis
& aVertical
,
93 const ScrollAxis
& aHorizontal
, const ScrollFlags
& aScrollFlags
,
94 const int32_t& aAppUnitsPerDevPixel
);
96 mozilla::ipc::IPCResult
RecvSubFrameCrashed();
98 void ActorDestroy(ActorDestroyReason aWhy
) override
;
101 ~BrowserBridgeChild();
103 void UnblockOwnerDocsLoadEvent();
107 bool mHadInitialLoad
= false;
108 RefPtr
<nsFrameLoader
> mFrameLoader
;
109 RefPtr
<BrowsingContext
> mBrowsingContext
;
110 #if defined(ACCESSIBILITY)
111 // We need to keep track of the embedder accessible id we last sent to the
113 uint64_t mEmbedderAccessibleID
= 0;
114 #endif // defined(ACCESSIBILITY)
117 } // namespace mozilla::dom
119 #endif // !defined(mozilla_dom_BrowserBridgeParent_h)