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_BrowserChild_h
8 #define mozilla_dom_BrowserChild_h
10 #include "mozilla/dom/ContentFrameMessageManager.h"
11 #include "mozilla/dom/PBrowserChild.h"
12 #include "nsIWebNavigation.h"
14 #include "nsIWebBrowserChrome.h"
15 #include "nsIWebBrowserChromeFocus.h"
16 #include "nsIDOMEventListener.h"
17 #include "nsIInterfaceRequestor.h"
18 #include "nsIWindowProvider.h"
19 #include "nsIDocShell.h"
20 #include "nsIInterfaceRequestorUtils.h"
21 #include "nsWeakReference.h"
22 #include "nsIBrowserChild.h"
23 #include "nsITooltipListener.h"
24 #include "nsIWebProgressListener.h"
25 #include "nsIWebProgressListener2.h"
26 #include "mozilla/Attributes.h"
27 #include "mozilla/dom/TabContext.h"
28 #include "mozilla/dom/CoalescedMouseData.h"
29 #include "mozilla/dom/CoalescedTouchData.h"
30 #include "mozilla/dom/CoalescedWheelData.h"
31 #include "mozilla/dom/MessageManagerCallback.h"
32 #include "mozilla/dom/VsyncMainChild.h"
33 #include "mozilla/DOMEventTargetHelper.h"
34 #include "mozilla/EventDispatcher.h"
35 #include "mozilla/EventForwards.h"
36 #include "mozilla/layers/CompositorTypes.h"
37 #include "mozilla/layers/APZCCallbackHelper.h"
38 #include "mozilla/layers/CompositorOptions.h"
39 #include "mozilla/layers/GeckoContentControllerTypes.h"
40 #include "mozilla/dom/ipc/IdType.h"
41 #include "AudioChannelService.h"
42 #include "PuppetWidget.h"
44 #include "nsIRemoteTab.h"
45 #include "nsTHashSet.h"
47 class nsBrowserStatusFilter
;
51 class nsISerialEventTarget
;
54 class nsDocShellLoadState
;
62 enum class NativeKeyBindingsType
: uint8_t;
70 class AsyncDragMetrics
;
71 class IAPZCTreeManager
;
72 class ImageCompositeNotification
;
73 class PCompositorBridgeChild
;
77 struct AutoCacheNativeKeyCommands
;
83 class BrowsingContext
;
85 class ClonedMessageData
;
86 class CoalescedMouseData
;
87 class CoalescedWheelData
;
88 class SessionStoreChild
;
90 class WebProgressData
;
92 class BrowserChildMessageManager
: public ContentFrameMessageManager
,
93 public nsIMessageSender
,
94 public DispatcherTrait
,
95 public nsSupportsWeakReference
{
97 explicit BrowserChildMessageManager(BrowserChild
* aBrowserChild
);
99 NS_DECL_ISUPPORTS_INHERITED
100 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BrowserChildMessageManager
,
101 DOMEventTargetHelper
)
105 JSObject
* WrapObject(JSContext
* aCx
,
106 JS::Handle
<JSObject
*> aGivenProto
) override
;
108 virtual Nullable
<WindowProxyHolder
> GetContent(ErrorResult
& aError
) override
;
109 virtual already_AddRefed
<nsIDocShell
> GetDocShell(
110 ErrorResult
& aError
) override
;
111 virtual already_AddRefed
<nsIEventTarget
> GetTabEventTarget() override
;
113 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager
)
115 void GetEventTargetParent(EventChainPreVisitor
& aVisitor
) override
{
116 aVisitor
.mForceContentDispatch
= true;
119 // Dispatch a runnable related to the global.
120 virtual nsresult
Dispatch(mozilla::TaskCategory aCategory
,
121 already_AddRefed
<nsIRunnable
>&& aRunnable
) override
;
123 virtual nsISerialEventTarget
* EventTargetFor(
124 mozilla::TaskCategory aCategory
) const override
;
126 virtual AbstractThread
* AbstractMainThreadFor(
127 mozilla::TaskCategory aCategory
) override
;
129 RefPtr
<BrowserChild
> mBrowserChild
;
132 ~BrowserChildMessageManager();
136 * BrowserChild implements the child actor part of the PBrowser protocol. See
137 * PBrowser for more information.
139 class BrowserChild final
: public nsMessageManagerScriptExecutor
,
140 public ipc::MessageManagerCallback
,
141 public PBrowserChild
,
142 public nsIWebBrowserChrome
,
143 public nsIWebBrowserChromeFocus
,
144 public nsIInterfaceRequestor
,
145 public nsIWindowProvider
,
146 public nsSupportsWeakReference
,
147 public nsIBrowserChild
,
149 public nsIWebProgressListener2
,
151 public nsITooltipListener
,
152 public mozilla::ipc::IShmemAllocator
{
153 using PuppetWidget
= mozilla::widget::PuppetWidget
;
154 using ClonedMessageData
= mozilla::dom::ClonedMessageData
;
155 using CoalescedMouseData
= mozilla::dom::CoalescedMouseData
;
156 using CoalescedWheelData
= mozilla::dom::CoalescedWheelData
;
157 using APZEventState
= mozilla::layers::APZEventState
;
158 using TouchBehaviorFlags
= mozilla::layers::TouchBehaviorFlags
;
160 friend class PBrowserChild
;
164 * Find BrowserChild of aTabId in the same content process of the
167 static already_AddRefed
<BrowserChild
> FindBrowserChild(const TabId
& aTabId
);
169 // Return a list of all active BrowserChildren.
170 static nsTArray
<RefPtr
<BrowserChild
>> GetAll();
174 * Create a new BrowserChild object.
176 BrowserChild(ContentChild
* aManager
, const TabId
& aTabId
,
177 const TabContext
& aContext
,
178 dom::BrowsingContext
* aBrowsingContext
, uint32_t aChromeFlags
,
181 MOZ_CAN_RUN_SCRIPT nsresult
Init(mozIDOMWindowProxy
* aParent
,
182 WindowGlobalChild
* aInitialWindowChild
);
184 /** Return a BrowserChild with the given attributes. */
185 static already_AddRefed
<BrowserChild
> Create(
186 ContentChild
* aManager
, const TabId
& aTabId
, const TabContext
& aContext
,
187 BrowsingContext
* aBrowsingContext
, uint32_t aChromeFlags
,
190 // Let managees query if it is safe to send messages.
191 bool IsDestroyed() const { return mDestroyed
; }
193 const TabId
GetTabId() const {
194 MOZ_ASSERT(mUniqueId
!= 0);
198 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
199 NS_DECL_NSIWEBBROWSERCHROME
200 NS_DECL_NSIWEBBROWSERCHROMEFOCUS
201 NS_DECL_NSIINTERFACEREQUESTOR
202 NS_DECL_NSIWINDOWPROVIDER
203 NS_DECL_NSIBROWSERCHILD
205 NS_DECL_NSIWEBPROGRESSLISTENER
206 NS_DECL_NSIWEBPROGRESSLISTENER2
207 NS_DECL_NSITOOLTIPLISTENER
209 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(BrowserChild
,
212 FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild
)
214 JSObject
* WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
215 return mBrowserChildMessageManager
->WrapObject(aCx
, aGivenProto
);
218 // Get the Document for the top-level window in this tab.
219 already_AddRefed
<Document
> GetTopLevelDocument() const;
221 // Get the pres-shell of the document for the top-level window in this tab.
222 PresShell
* GetTopLevelPresShell() const;
224 BrowserChildMessageManager
* GetMessageManager() {
225 return mBrowserChildMessageManager
;
228 bool IsTopLevel() const { return mIsTopLevel
; }
230 bool ShouldSendWebProgressEventsToParent() const {
231 return mShouldSendWebProgressEventsToParent
;
235 * MessageManagerCallback methods that we override.
237 virtual bool DoSendBlockingMessage(
238 const nsAString
& aMessage
, StructuredCloneData
& aData
,
239 nsTArray
<StructuredCloneData
>* aRetVal
) override
;
241 virtual nsresult
DoSendAsyncMessage(const nsAString
& aMessage
,
242 StructuredCloneData
& aData
) override
;
244 bool DoUpdateZoomConstraints(const uint32_t& aPresShellId
,
245 const ViewID
& aViewId
,
246 const Maybe
<ZoomConstraints
>& aConstraints
);
248 mozilla::ipc::IPCResult
RecvLoadURL(nsDocShellLoadState
* aLoadState
,
249 const ParentShowInfo
& aInfo
);
251 mozilla::ipc::IPCResult
RecvCreateAboutBlankContentViewer(
252 nsIPrincipal
* aPrincipal
, nsIPrincipal
* aPartitionedPrincipal
);
254 mozilla::ipc::IPCResult
RecvResumeLoad(const uint64_t& aPendingSwitchID
,
255 const ParentShowInfo
&);
257 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
258 RecvCloneDocumentTreeIntoSelf(
259 const MaybeDiscarded
<BrowsingContext
>& aSourceBC
,
260 const embedding::PrintData
& aPrintData
,
261 CloneDocumentTreeIntoSelfResolver
&& aResolve
);
263 MOZ_CAN_RUN_SCRIPT_BOUNDARY
264 mozilla::ipc::IPCResult
RecvUpdateRemotePrintSettings(
265 const embedding::PrintData
& aPrintData
);
267 MOZ_CAN_RUN_SCRIPT_BOUNDARY
268 mozilla::ipc::IPCResult
RecvShow(const ParentShowInfo
&, const OwnerShowInfo
&);
270 mozilla::ipc::IPCResult
RecvInitRendering(
271 const TextureFactoryIdentifier
& aTextureFactoryIdentifier
,
272 const layers::LayersId
& aLayersId
,
273 const mozilla::layers::CompositorOptions
& aCompositorOptions
,
274 const bool& aLayersConnected
);
276 mozilla::ipc::IPCResult
RecvCompositorOptionsChanged(
277 const mozilla::layers::CompositorOptions
& aNewOptions
);
279 mozilla::ipc::IPCResult
RecvUpdateDimensions(
280 const mozilla::dom::DimensionInfo
& aDimensionInfo
);
281 mozilla::ipc::IPCResult
RecvSizeModeChanged(const nsSizeMode
& aSizeMode
);
283 mozilla::ipc::IPCResult
RecvChildToParentMatrix(
284 const mozilla::Maybe
<mozilla::gfx::Matrix4x4
>& aMatrix
,
285 const mozilla::ScreenRect
& aTopLevelViewportVisibleRectInBrowserCoords
);
287 MOZ_CAN_RUN_SCRIPT_BOUNDARY
288 mozilla::ipc::IPCResult
RecvDynamicToolbarMaxHeightChanged(
289 const mozilla::ScreenIntCoord
& aHeight
);
291 mozilla::ipc::IPCResult
RecvDynamicToolbarOffsetChanged(
292 const mozilla::ScreenIntCoord
& aOffset
);
294 mozilla::ipc::IPCResult
RecvActivate(uint64_t aActionId
);
296 mozilla::ipc::IPCResult
RecvDeactivate(uint64_t aActionId
);
298 mozilla::ipc::IPCResult
RecvRealMouseMoveEvent(
299 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
300 const uint64_t& aInputBlockId
);
301 mozilla::ipc::IPCResult
RecvNormalPriorityRealMouseMoveEvent(
302 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
303 const uint64_t& aInputBlockId
);
304 mozilla::ipc::IPCResult
RecvRealMouseMoveEventForTests(
305 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
306 const uint64_t& aInputBlockId
);
307 mozilla::ipc::IPCResult
RecvNormalPriorityRealMouseMoveEventForTests(
308 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
309 const uint64_t& aInputBlockId
);
311 mozilla::ipc::IPCResult
RecvSynthMouseMoveEvent(
312 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
313 const uint64_t& aInputBlockId
);
314 mozilla::ipc::IPCResult
RecvNormalPrioritySynthMouseMoveEvent(
315 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
316 const uint64_t& aInputBlockId
);
318 mozilla::ipc::IPCResult
RecvRealMouseButtonEvent(
319 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
320 const uint64_t& aInputBlockId
);
321 mozilla::ipc::IPCResult
RecvNormalPriorityRealMouseButtonEvent(
322 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
323 const uint64_t& aInputBlockId
);
325 mozilla::ipc::IPCResult
RecvRealMouseEnterExitWidgetEvent(
326 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
327 const uint64_t& aInputBlockId
);
328 mozilla::ipc::IPCResult
RecvNormalPriorityRealMouseEnterExitWidgetEvent(
329 const mozilla::WidgetMouseEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
330 const uint64_t& aInputBlockId
);
332 MOZ_CAN_RUN_SCRIPT_BOUNDARY
333 mozilla::ipc::IPCResult
RecvRealDragEvent(const WidgetDragEvent
& aEvent
,
334 const uint32_t& aDragAction
,
335 const uint32_t& aDropEffect
,
336 nsIPrincipal
* aPrincipal
,
337 nsIContentSecurityPolicy
* aCsp
);
339 mozilla::ipc::IPCResult
RecvRealKeyEvent(
340 const mozilla::WidgetKeyboardEvent
& aEvent
, const nsID
& aUUID
);
342 mozilla::ipc::IPCResult
RecvNormalPriorityRealKeyEvent(
343 const mozilla::WidgetKeyboardEvent
& aEvent
, const nsID
& aUUID
);
345 mozilla::ipc::IPCResult
RecvMouseWheelEvent(
346 const mozilla::WidgetWheelEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
347 const uint64_t& aInputBlockId
);
349 mozilla::ipc::IPCResult
RecvNormalPriorityMouseWheelEvent(
350 const mozilla::WidgetWheelEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
351 const uint64_t& aInputBlockId
);
353 mozilla::ipc::IPCResult
RecvRealTouchEvent(const WidgetTouchEvent
& aEvent
,
354 const ScrollableLayerGuid
& aGuid
,
355 const uint64_t& aInputBlockId
,
356 const nsEventStatus
& aApzResponse
);
358 mozilla::ipc::IPCResult
RecvNormalPriorityRealTouchEvent(
359 const WidgetTouchEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
360 const uint64_t& aInputBlockId
, const nsEventStatus
& aApzResponse
);
362 mozilla::ipc::IPCResult
RecvRealTouchMoveEvent(
363 const WidgetTouchEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
364 const uint64_t& aInputBlockId
, const nsEventStatus
& aApzResponse
);
366 mozilla::ipc::IPCResult
RecvNormalPriorityRealTouchMoveEvent(
367 const WidgetTouchEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
368 const uint64_t& aInputBlockId
, const nsEventStatus
& aApzResponse
);
370 mozilla::ipc::IPCResult
RecvRealTouchMoveEvent2(
371 const WidgetTouchEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
372 const uint64_t& aInputBlockId
, const nsEventStatus
& aApzResponse
) {
373 return RecvRealTouchMoveEvent(aEvent
, aGuid
, aInputBlockId
, aApzResponse
);
376 mozilla::ipc::IPCResult
RecvNormalPriorityRealTouchMoveEvent2(
377 const WidgetTouchEvent
& aEvent
, const ScrollableLayerGuid
& aGuid
,
378 const uint64_t& aInputBlockId
, const nsEventStatus
& aApzResponse
) {
379 return RecvNormalPriorityRealTouchMoveEvent(aEvent
, aGuid
, aInputBlockId
,
383 mozilla::ipc::IPCResult
RecvUpdateSHistory();
385 mozilla::ipc::IPCResult
RecvNativeSynthesisResponse(
386 const uint64_t& aObserverId
, const nsCString
& aResponse
);
388 mozilla::ipc::IPCResult
RecvCompositionEvent(
389 const mozilla::WidgetCompositionEvent
& aEvent
);
391 mozilla::ipc::IPCResult
RecvNormalPriorityCompositionEvent(
392 const mozilla::WidgetCompositionEvent
& aEvent
);
394 mozilla::ipc::IPCResult
RecvSelectionEvent(
395 const mozilla::WidgetSelectionEvent
& aEvent
);
397 mozilla::ipc::IPCResult
RecvNormalPrioritySelectionEvent(
398 const mozilla::WidgetSelectionEvent
& aEvent
);
400 mozilla::ipc::IPCResult
RecvSetIsUnderHiddenEmbedderElement(
401 const bool& aIsUnderHiddenEmbedderElement
);
403 mozilla::ipc::IPCResult
RecvInsertText(const nsAString
& aStringToInsert
);
405 mozilla::ipc::IPCResult
RecvUpdateRemoteStyle(
406 const StyleImageRendering
& aImageRendering
);
408 mozilla::ipc::IPCResult
RecvNormalPriorityInsertText(
409 const nsAString
& aStringToInsert
);
411 MOZ_CAN_RUN_SCRIPT_BOUNDARY
412 mozilla::ipc::IPCResult
RecvPasteTransferable(
413 const IPCTransferableData
& aTransferableData
, const bool& aIsPrivateData
,
414 nsIPrincipal
* aRequestingPrincipal
,
415 const nsContentPolicyType
& aContentPolicyType
);
417 mozilla::ipc::IPCResult
RecvLoadRemoteScript(const nsAString
& aURL
,
418 const bool& aRunInGlobalScope
);
420 mozilla::ipc::IPCResult
RecvAsyncMessage(const nsAString
& aMessage
,
421 const ClonedMessageData
& aData
);
422 mozilla::ipc::IPCResult
RecvSwappedWithOtherRemoteLoader(
423 const IPCTabContext
& aContext
);
425 mozilla::ipc::IPCResult
RecvSafeAreaInsetsChanged(
426 const mozilla::ScreenIntMargin
& aSafeAreaInsets
);
429 PDocAccessibleChild
* AllocPDocAccessibleChild(
430 PDocAccessibleChild
*, const uint64_t&,
431 const MaybeDiscardedBrowsingContext
&, const uint32_t&,
432 const IAccessibleHolder
&);
433 bool DeallocPDocAccessibleChild(PDocAccessibleChild
*);
436 RefPtr
<VsyncMainChild
> GetVsyncChild();
438 nsIWebNavigation
* WebNavigation() const { return mWebNav
; }
440 PuppetWidget
* WebWidget() { return mPuppetWidget
; }
442 bool IsTransparent() const { return mIsTransparent
; }
444 const EffectsInfo
& GetEffectsInfo() const { return mEffectsInfo
; }
446 void SetBackgroundColor(const nscolor
& aColor
);
448 MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual mozilla::ipc::IPCResult
RecvUpdateEffects(
449 const EffectsInfo
& aEffects
);
451 void RequestEditCommands(NativeKeyBindingsType aType
,
452 const WidgetKeyboardEvent
& aEvent
,
453 nsTArray
<CommandInt
>& aCommands
);
456 bool IsPreservingLayers() const { return mIsPreservingLayers
; }
459 * Signal to this BrowserChild that it should be made visible:
460 * activated widget, retained layer tree, etc. (Respectively,
463 MOZ_CAN_RUN_SCRIPT
void UpdateVisibility();
464 MOZ_CAN_RUN_SCRIPT
void MakeVisible();
466 void PresShellActivenessMaybeChanged();
468 ContentChild
* Manager() const { return mManager
; }
470 static inline BrowserChild
* GetFrom(nsIDocShell
* aDocShell
) {
475 nsCOMPtr
<nsIBrowserChild
> tc
= aDocShell
->GetBrowserChild();
476 return static_cast<BrowserChild
*>(tc
.get());
479 static inline BrowserChild
* GetFrom(mozIDOMWindow
* aWindow
) {
480 nsCOMPtr
<nsIWebNavigation
> webNav
= do_GetInterface(aWindow
);
481 nsCOMPtr
<nsIDocShell
> docShell
= do_QueryInterface(webNav
);
482 return GetFrom(docShell
);
485 static inline BrowserChild
* GetFrom(mozIDOMWindowProxy
* aWindow
) {
486 nsCOMPtr
<nsIWebNavigation
> webNav
= do_GetInterface(aWindow
);
487 nsCOMPtr
<nsIDocShell
> docShell
= do_QueryInterface(webNav
);
488 return GetFrom(docShell
);
491 static BrowserChild
* GetFrom(PresShell
* aPresShell
);
492 static BrowserChild
* GetFrom(layers::LayersId aLayersId
);
494 layers::LayersId
GetLayersId() { return mLayersId
; }
495 Maybe
<bool> IsLayersConnected() { return mLayersConnected
; }
497 void DidComposite(mozilla::layers::TransactionId aTransactionId
,
498 const TimeStamp
& aCompositeStart
,
499 const TimeStamp
& aCompositeEnd
);
501 void DidRequestComposite(const TimeStamp
& aCompositeReqStart
,
502 const TimeStamp
& aCompositeReqEnd
);
504 void ClearCachedResources();
505 void SchedulePaint();
506 void ReinitRendering();
507 void ReinitRenderingForDeviceReset();
509 void NotifyJankedAnimations(const nsTArray
<uint64_t>& aJankedAnimations
);
511 static inline BrowserChild
* GetFrom(nsIDOMWindow
* aWindow
) {
512 nsCOMPtr
<nsIWebNavigation
> webNav
= do_GetInterface(aWindow
);
513 nsCOMPtr
<nsIDocShell
> docShell
= do_QueryInterface(webNav
);
514 return GetFrom(docShell
);
517 mozilla::ipc::IPCResult
RecvUIResolutionChanged(const float& aDpi
,
518 const int32_t& aRounding
,
519 const double& aScale
);
521 mozilla::ipc::IPCResult
RecvHandleAccessKey(const WidgetKeyboardEvent
& aEvent
,
522 nsTArray
<uint32_t>&& aCharCodes
);
523 MOZ_CAN_RUN_SCRIPT_BOUNDARY
524 mozilla::ipc::IPCResult
RecvPrintPreview(const PrintData
& aPrintData
,
525 const MaybeDiscardedBrowsingContext
&,
526 PrintPreviewResolver
&& aCallback
);
528 mozilla::ipc::IPCResult
RecvExitPrintPreview();
530 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvPrint(
531 const MaybeDiscardedBrowsingContext
&, const PrintData
&);
533 mozilla::ipc::IPCResult
RecvUpdateNativeWindowHandle(
534 const uintptr_t& aNewHandle
);
536 mozilla::ipc::IPCResult
RecvWillChangeProcess();
538 PPaymentRequestChild
* AllocPPaymentRequestChild();
540 bool DeallocPPaymentRequestChild(PPaymentRequestChild
* aActor
);
542 LayoutDeviceIntPoint
GetClientOffset() const { return mClientOffset
; }
543 LayoutDeviceIntPoint
GetChromeOffset() const { return mChromeOffset
; };
544 ScreenIntCoord
GetDynamicToolbarMaxHeight() const {
545 return mDynamicToolbarMaxHeight
;
548 bool IPCOpen() const { return mIPCOpen
; }
550 const mozilla::layers::CompositorOptions
& GetCompositorOptions() const;
551 bool AsyncPanZoomEnabled() const;
553 ScreenIntSize
GetInnerSize();
554 CSSSize
GetUnscaledInnerSize() { return mUnscaledInnerSize
; }
556 Maybe
<nsRect
> GetVisibleRect() const;
558 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
559 void DoFakeShow(const ParentShowInfo
&);
561 void ContentReceivedInputBlock(uint64_t aInputBlockId
,
562 bool aPreventDefault
) const;
564 uint64_t aInputBlockId
,
565 const nsTArray
<layers::ScrollableLayerGuid
>& aTargets
) const;
566 MOZ_CAN_RUN_SCRIPT_BOUNDARY
567 mozilla::ipc::IPCResult
RecvHandleTap(
568 const layers::GeckoContentController_TapType
& aType
,
569 const LayoutDevicePoint
& aPoint
, const Modifiers
& aModifiers
,
570 const ScrollableLayerGuid
& aGuid
, const uint64_t& aInputBlockId
);
572 MOZ_CAN_RUN_SCRIPT_BOUNDARY
573 mozilla::ipc::IPCResult
RecvNormalPriorityHandleTap(
574 const layers::GeckoContentController_TapType
& aType
,
575 const LayoutDevicePoint
& aPoint
, const Modifiers
& aModifiers
,
576 const ScrollableLayerGuid
& aGuid
, const uint64_t& aInputBlockId
);
578 bool UpdateFrame(const layers::RepaintRequest
& aRequest
);
579 bool NotifyAPZStateChange(
580 const ViewID
& aViewId
,
581 const layers::GeckoContentController_APZStateChange
& aChange
,
582 const int& aArg
, Maybe
<uint64_t> aInputBlockId
);
583 void StartScrollbarDrag(const layers::AsyncDragMetrics
& aDragMetrics
);
584 void ZoomToRect(const uint32_t& aPresShellId
,
585 const ScrollableLayerGuid::ViewID
& aViewId
,
586 const CSSRect
& aRect
, const uint32_t& aFlags
);
588 // Request that the docshell be marked as active.
589 void PaintWhileInterruptingJS(const layers::LayersObserverEpoch
& aEpoch
);
591 void UnloadLayersWhileInterruptingJS(
592 const layers::LayersObserverEpoch
& aEpoch
);
594 nsresult
CanCancelContentJS(nsIRemoteTab::NavigationType aNavigationType
,
595 int32_t aNavigationIndex
, nsIURI
* aNavigationURI
,
596 int32_t aEpoch
, bool* aCanCancel
);
598 layers::LayersObserverEpoch
LayersObserverEpoch() const {
599 return mLayersObserverEpoch
;
602 #if defined(XP_WIN) && defined(ACCESSIBILITY)
603 uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle
; }
606 BrowsingContext
* GetBrowsingContext() const { return mBrowsingContext
; }
608 #if defined(ACCESSIBILITY)
609 void SetTopLevelDocAccessibleChild(PDocAccessibleChild
* aTopLevelChild
) {
610 mTopLevelDocAccessibleChild
= aTopLevelChild
;
613 PDocAccessibleChild
* GetTopLevelDocAccessibleChild() {
614 return mTopLevelDocAccessibleChild
;
618 // The transform from the coordinate space of this BrowserChild to the
619 // coordinate space of the native window its BrowserParent is in.
620 mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
621 GetChildToParentConversionMatrix() const;
623 // Returns the portion of the visible rect of this remote document in the
624 // top browser window coordinate system. This is the result of being clipped
625 // by all ancestor viewports.
626 Maybe
<ScreenRect
> GetTopLevelViewportVisibleRectInBrowserCoords() const;
628 // Similar to above GetTopLevelViewportVisibleRectInBrowserCoords(), but in
629 // this out-of-process document's coordinate system.
630 Maybe
<LayoutDeviceRect
> GetTopLevelViewportVisibleRectInSelfCoords() const;
632 // Prepare to dispatch all coalesced mousemove events. We'll move all data
633 // in mCoalescedMouseData to a nsDeque; then we start processing them. We
634 // can't fetch the coalesced event one by one and dispatch it because we may
635 // reentry the event loop and access to the same hashtable. It's called when
636 // dispatching some mouse events other than mousemove.
637 void FlushAllCoalescedMouseData();
638 void ProcessPendingCoalescedMouseDataAndDispatchEvents();
640 void ProcessPendingCoalescedTouchData();
642 void HandleRealMouseButtonEvent(const WidgetMouseEvent
& aEvent
,
643 const ScrollableLayerGuid
& aGuid
,
644 const uint64_t& aInputBlockId
);
646 void SetCancelContentJSEpoch(int32_t aEpoch
) {
647 mCancelContentJSEpoch
= aEpoch
;
650 void UpdateSessionStore();
652 mozilla::dom::SessionStoreChild
* GetSessionStoreChild() {
653 return mSessionStoreChild
;
657 // Check if the window this BrowserChild is associated with supports
658 // protected media (EME) or not.
659 // Returns a promise the will resolve true if the window supports protected
660 // media or false if it does not. The promise will be rejected with an
661 // ResponseRejectReason if the IPC needed to do the check fails. Callers
662 // should treat the reject case as if the window does not support protected
663 // media to ensure robust handling.
664 RefPtr
<IsWindowSupportingProtectedMediaPromise
>
665 DoesWindowSupportProtectedMedia();
668 // Notify the content blocking event in the parent process. This sends an IPC
669 // message to the BrowserParent in the parent. The BrowserParent will find the
670 // top-level WindowGlobalParent and notify the event from it.
671 void NotifyContentBlockingEvent(
672 uint32_t aEvent
, nsIChannel
* aChannel
, bool aBlocked
,
673 const nsACString
& aTrackingOrigin
,
674 const nsTArray
<nsCString
>& aTrackingFullHashes
,
676 ContentBlockingNotifier::StorageAccessPermissionGrantedReason
>&
680 virtual ~BrowserChild();
682 mozilla::ipc::IPCResult
RecvDestroy();
684 MOZ_CAN_RUN_SCRIPT_BOUNDARY
685 mozilla::ipc::IPCResult
RecvRenderLayers(
686 const bool& aEnabled
, const layers::LayersObserverEpoch
& aEpoch
);
688 mozilla::ipc::IPCResult
RecvPreserveLayers(bool);
690 mozilla::ipc::IPCResult
RecvNavigateByKey(const bool& aForward
,
691 const bool& aForDocumentNavigation
);
693 mozilla::ipc::IPCResult
RecvSuppressDisplayport(const bool& aEnabled
);
695 mozilla::ipc::IPCResult
RecvScrollbarPreferenceChanged(ScrollbarPreference
);
697 mozilla::ipc::IPCResult
RecvStopIMEStateManagement();
699 mozilla::ipc::IPCResult
RecvAllowScriptsToClose();
701 mozilla::ipc::IPCResult
RecvReleaseAllPointerCapture();
704 void HandleDoubleTap(const CSSPoint
& aPoint
, const Modifiers
& aModifiers
,
705 const ScrollableLayerGuid
& aGuid
);
707 void ActorDestroy(ActorDestroyReason why
) override
;
709 bool InitBrowserChildMessageManager();
711 void InitRenderingState(
712 const TextureFactoryIdentifier
& aTextureFactoryIdentifier
,
713 const layers::LayersId
& aLayersId
,
714 const mozilla::layers::CompositorOptions
& aCompositorOptions
);
717 void DestroyWindow();
719 void ApplyParentShowInfo(const ParentShowInfo
&);
721 bool HasValidInnerSize();
723 ScreenIntRect
GetOuterRect();
725 void SetUnscaledInnerSize(const CSSSize
& aSize
) {
726 mUnscaledInnerSize
= aSize
;
729 bool SkipRepeatedKeyEvent(const WidgetKeyboardEvent
& aEvent
);
731 void UpdateRepeatedKeyEventEndTime(const WidgetKeyboardEvent
& aEvent
);
733 void DispatchCoalescedWheelEvent();
736 * Dispatch aEvent on aEvent.mWidget.
738 nsEventStatus
DispatchWidgetEventViaAPZ(WidgetGUIEvent
& aEvent
);
740 void DispatchWheelEvent(const WidgetWheelEvent
& aEvent
,
741 const ScrollableLayerGuid
& aGuid
,
742 const uint64_t& aInputBlockId
);
744 void InternalSetDocShellIsActive(bool aIsActive
);
746 bool CreateRemoteLayerManager(
747 mozilla::layers::PCompositorBridgeChild
* aCompositorChild
);
749 nsresult
PrepareRequestData(nsIRequest
* aRequest
, RequestData
& aRequestData
);
750 nsresult
PrepareProgressListenerData(nsIWebProgress
* aWebProgress
,
751 nsIRequest
* aRequest
,
752 WebProgressData
& aWebProgressData
,
753 RequestData
& aRequestData
);
755 MOZ_CAN_RUN_SCRIPT_BOUNDARY
756 nsresult
UpdateRemotePrintSettings(const embedding::PrintData
& aPrintData
);
758 MOZ_CAN_RUN_SCRIPT_BOUNDARY
759 nsresult
CloneDocumentTreeIntoSelf(
760 const MaybeDiscarded
<BrowsingContext
>& aSourceBC
,
761 const embedding::PrintData
& aPrintData
);
763 class DelayedDeleteRunnable
;
765 RefPtr
<BrowserChildMessageManager
> mBrowserChildMessageManager
;
766 TextureFactoryIdentifier mTextureFactoryIdentifier
;
767 RefPtr
<nsWebBrowser
> mWebBrowser
;
768 nsCOMPtr
<nsIWebNavigation
> mWebNav
;
769 RefPtr
<PuppetWidget
> mPuppetWidget
;
770 nsCOMPtr
<nsIURI
> mLastURI
;
771 RefPtr
<ContentChild
> mManager
;
772 RefPtr
<BrowsingContext
> mBrowsingContext
;
773 RefPtr
<nsBrowserStatusFilter
> mStatusFilter
;
774 uint32_t mChromeFlags
;
775 uint32_t mMaxTouchPoints
;
776 layers::LayersId mLayersId
;
777 CSSRect mUnscaledOuterRect
;
778 Maybe
<bool> mLayersConnected
;
779 Maybe
<bool> mLayersConnectRequested
;
780 EffectsInfo mEffectsInfo
;
782 RefPtr
<VsyncMainChild
> mVsyncChild
;
784 RefPtr
<APZEventState
> mAPZEventState
;
786 // Position of client area relative to the outer window
787 LayoutDeviceIntPoint mClientOffset
;
788 // Position of tab, relative to parent widget (typically the window)
789 // NOTE: This value is valuable only for the top level browser.
790 LayoutDeviceIntPoint mChromeOffset
;
791 ScreenIntCoord mDynamicToolbarMaxHeight
;
794 bool mDidFakeShow
: 1;
795 bool mTriedBrowserInit
: 1;
796 bool mIgnoreKeyPressEvent
: 1;
797 bool mHasValidInnerSize
: 1;
800 // Whether or not this browser is the child part of the top level PBrowser
801 // actor in a remote browser.
802 bool mIsTopLevel
: 1;
804 bool mIsTransparent
: 1;
807 bool mDidSetRealShowInfo
: 1;
808 bool mDidLoadURLInit
: 1;
810 bool mSkipKeyPress
: 1;
811 bool mDidSetEffectsInfo
: 1;
813 bool mCoalesceMouseMoveEvents
: 1;
815 bool mShouldSendWebProgressEventsToParent
: 1;
817 // Whether we are rendering to the compositor or not.
818 bool mRenderLayers
: 1;
820 // Whether we're artificially preserving layers.
821 bool mIsPreservingLayers
: 1;
823 // Holds the compositor options for the compositor rendering this tab,
824 // once we find out which compositor that is.
825 Maybe
<mozilla::layers::CompositorOptions
> mCompositorOptions
;
827 friend class ContentChild
;
829 CSSSize mUnscaledInnerSize
;
831 // Store the end time of the handling of the last repeated keydown/keypress
832 // event so that in case event handling takes time, some repeated events can
833 // be skipped to not flood child process.
834 mozilla::TimeStamp mRepeatedKeyEventTime
;
836 // Similar to mRepeatedKeyEventTime, store the end time (from parent process)
837 // of handling the last repeated wheel event so that in case event handling
838 // takes time, some repeated events can be skipped to not flood child process.
839 mozilla::TimeStamp mLastWheelProcessedTimeFromParent
;
840 mozilla::TimeDuration mLastWheelProcessingDuration
;
842 // Hash table to track coalesced mousemove events for different pointers.
843 nsClassHashtable
<nsUint32HashKey
, CoalescedMouseData
> mCoalescedMouseData
;
845 nsDeque
<CoalescedMouseData
> mToBeDispatchedMouseData
;
847 CoalescedWheelData mCoalescedWheelData
;
848 CoalescedTouchData mCoalescedTouchData
;
850 RefPtr
<CoalescedMouseMoveFlusher
> mCoalescedMouseEventFlusher
;
851 RefPtr
<CoalescedTouchMoveFlusher
> mCoalescedTouchMoveEventFlusher
;
853 RefPtr
<layers::IAPZCTreeManager
> mApzcTreeManager
;
854 RefPtr
<SessionStoreChild
> mSessionStoreChild
;
856 // The most recently seen layer observer epoch in RecvSetDocShellIsActive.
857 layers::LayersObserverEpoch mLayersObserverEpoch
;
859 #if defined(XP_WIN) && defined(ACCESSIBILITY)
860 // The handle associated with the native window that contains this tab
861 uintptr_t mNativeWindowHandle
;
862 #endif // defined(XP_WIN)
864 #if defined(ACCESSIBILITY)
865 PDocAccessibleChild
* mTopLevelDocAccessibleChild
;
867 int32_t mCancelContentJSEpoch
;
869 Maybe
<LayoutDeviceToLayoutDeviceMatrix4x4
> mChildToParentConversionMatrix
;
870 // When mChildToParentConversionMatrix is Nothing() this value is invalid.
871 ScreenRect mTopLevelViewportVisibleRectInBrowserCoords
;
874 // Should only be accessed on main thread.
875 Maybe
<bool> mWindowSupportsProtectedMedia
;
878 // If set, resolve when we receive ChildToParentMatrix.
879 RefPtr
<dom::Promise
> mContentTransformPromise
;
881 DISALLOW_EVIL_CONSTRUCTORS(BrowserChild
);
885 } // namespace mozilla
887 #endif // mozilla_dom_BrowserChild_h