Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / ipc / BrowserChild.h
blob27767514c1d8ed9893e89d4023510540f4f18dbc
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"
13 #include "nsCOMPtr.h"
14 #include "nsIWebBrowserChrome.h"
15 #include "nsIInterfaceRequestor.h"
16 #include "nsIWindowProvider.h"
17 #include "nsIDocShell.h"
18 #include "nsIInterfaceRequestorUtils.h"
19 #include "nsWeakReference.h"
20 #include "nsIBrowserChild.h"
21 #include "nsITooltipListener.h"
22 #include "nsIWebProgressListener.h"
23 #include "nsIWebProgressListener2.h"
24 #include "mozilla/Attributes.h"
25 #include "mozilla/dom/TabContext.h"
26 #include "mozilla/dom/CoalescedMouseData.h"
27 #include "mozilla/dom/CoalescedTouchData.h"
28 #include "mozilla/dom/CoalescedWheelData.h"
29 #include "mozilla/dom/MessageManagerCallback.h"
30 #include "mozilla/dom/VsyncMainChild.h"
31 #include "mozilla/DOMEventTargetHelper.h"
32 #include "mozilla/EventDispatcher.h"
33 #include "mozilla/EventForwards.h"
34 #include "mozilla/layers/APZCCallbackHelper.h"
35 #include "mozilla/layers/CompositorOptions.h"
36 #include "mozilla/layers/CompositorTypes.h"
37 #include "mozilla/layers/GeckoContentControllerTypes.h"
38 #include "mozilla/dom/ipc/IdType.h"
39 #include "PuppetWidget.h"
40 #include "nsDeque.h"
41 #include "nsIRemoteTab.h"
43 class nsBrowserStatusFilter;
44 class nsIDOMWindow;
45 class nsIHttpChannel;
46 class nsIRequest;
47 class nsISerialEventTarget;
48 class nsIWebProgress;
49 class nsWebBrowser;
50 class nsDocShellLoadState;
52 template <typename T>
53 class nsTHashtable;
54 template <typename T>
55 class nsPtrHashKey;
57 namespace mozilla {
58 enum class NativeKeyBindingsType : uint8_t;
60 class AbstractThread;
61 class PresShell;
63 namespace layers {
64 class APZChild;
65 class APZEventState;
66 class AsyncDragMetrics;
67 class IAPZCTreeManager;
68 class ImageCompositeNotification;
69 class PCompositorBridgeChild;
70 } // namespace layers
72 namespace widget {
73 struct AutoCacheNativeKeyCommands;
74 } // namespace widget
76 namespace dom {
78 class BrowserChild;
79 class BrowsingContext;
80 class TabGroup;
81 class ClonedMessageData;
82 class CoalescedMouseData;
83 class CoalescedWheelData;
84 class SessionStoreChild;
85 class RequestData;
86 class WebProgressData;
88 #define DOM_BROWSERCHILD_IID \
89 { \
90 0x58a5775d, 0xba05, 0x45bf, { \
91 0xbd, 0xb8, 0xd7, 0x61, 0xf9, 0x01, 0x01, 0x31 \
92 } \
95 class BrowserChildMessageManager : public ContentFrameMessageManager,
96 public nsIMessageSender,
97 public nsSupportsWeakReference {
98 public:
99 explicit BrowserChildMessageManager(BrowserChild* aBrowserChild);
101 NS_DECL_ISUPPORTS_INHERITED
102 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BrowserChildMessageManager,
103 DOMEventTargetHelper)
105 void MarkForCC();
107 JSObject* WrapObject(JSContext* aCx,
108 JS::Handle<JSObject*> aGivenProto) override;
110 Nullable<WindowProxyHolder> GetContent(ErrorResult& aError) override;
111 already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) override;
112 already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
114 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
116 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override {
117 aVisitor.mForceContentDispatch = true;
120 // Dispatch a runnable related to the global.
121 nsresult Dispatch(already_AddRefed<nsIRunnable>&& aRunnable) const;
123 RefPtr<BrowserChild> mBrowserChild;
125 protected:
126 ~BrowserChildMessageManager();
130 * BrowserChild implements the child actor part of the PBrowser protocol. See
131 * PBrowser for more information.
133 class BrowserChild final : public nsMessageManagerScriptExecutor,
134 public ipc::MessageManagerCallback,
135 public PBrowserChild,
136 public nsIWebBrowserChrome,
137 public nsIInterfaceRequestor,
138 public nsIWindowProvider,
139 public nsSupportsWeakReference,
140 public nsIBrowserChild,
141 public nsIObserver,
142 public nsIWebProgressListener2,
143 public TabContext,
144 public nsITooltipListener,
145 public mozilla::ipc::IShmemAllocator {
146 using PuppetWidget = mozilla::widget::PuppetWidget;
147 using ClonedMessageData = mozilla::dom::ClonedMessageData;
148 using CoalescedMouseData = mozilla::dom::CoalescedMouseData;
149 using CoalescedWheelData = mozilla::dom::CoalescedWheelData;
150 using APZEventState = mozilla::layers::APZEventState;
151 using TouchBehaviorFlags = mozilla::layers::TouchBehaviorFlags;
153 friend class PBrowserChild;
155 public:
157 * Find BrowserChild of aTabId in the same content process of the
158 * caller.
160 static already_AddRefed<BrowserChild> FindBrowserChild(const TabId& aTabId);
162 // Return a list of all active BrowserChildren.
163 static nsTArray<RefPtr<BrowserChild>> GetAll();
165 public:
167 * Create a new BrowserChild object.
169 BrowserChild(ContentChild* aManager, const TabId& aTabId,
170 const TabContext& aContext,
171 dom::BrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
172 bool aIsTopLevel);
174 MOZ_CAN_RUN_SCRIPT nsresult Init(mozIDOMWindowProxy* aParent,
175 WindowGlobalChild* aInitialWindowChild);
177 /** Return a BrowserChild with the given attributes. */
178 static already_AddRefed<BrowserChild> Create(
179 ContentChild* aManager, const TabId& aTabId, const TabContext& aContext,
180 BrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
181 bool aIsTopLevel);
183 // Let managees query if it is safe to send messages.
184 bool IsDestroyed() const { return mDestroyed; }
186 TabId GetTabId() const {
187 MOZ_ASSERT(mUniqueId != 0);
188 return mUniqueId;
191 NS_DECLARE_STATIC_IID_ACCESSOR(DOM_BROWSERCHILD_IID)
192 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
193 NS_DECL_NSIWEBBROWSERCHROME
194 NS_DECL_NSIINTERFACEREQUESTOR
195 NS_DECL_NSIWINDOWPROVIDER
196 NS_DECL_NSIBROWSERCHILD
197 NS_DECL_NSIOBSERVER
198 NS_DECL_NSIWEBPROGRESSLISTENER
199 NS_DECL_NSIWEBPROGRESSLISTENER2
200 NS_DECL_NSITOOLTIPLISTENER
202 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(BrowserChild,
203 nsIBrowserChild)
205 FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild)
207 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
208 return mBrowserChildMessageManager->WrapObject(aCx, aGivenProto);
211 // Get the Document for the top-level window in this tab.
212 already_AddRefed<Document> GetTopLevelDocument() const;
214 // Get the pres-shell of the document for the top-level window in this tab.
215 PresShell* GetTopLevelPresShell() const;
217 BrowserChildMessageManager* GetMessageManager() {
218 return mBrowserChildMessageManager;
221 bool IsTopLevel() const { return mIsTopLevel; }
223 bool ShouldSendWebProgressEventsToParent() const {
224 return mShouldSendWebProgressEventsToParent;
228 * MessageManagerCallback methods that we override.
230 virtual bool DoSendBlockingMessage(
231 const nsAString& aMessage, StructuredCloneData& aData,
232 nsTArray<StructuredCloneData>* aRetVal) override;
234 virtual nsresult DoSendAsyncMessage(const nsAString& aMessage,
235 StructuredCloneData& aData) override;
237 bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
238 const ViewID& aViewId,
239 const Maybe<ZoomConstraints>& aConstraints);
241 mozilla::ipc::IPCResult RecvLoadURL(nsDocShellLoadState* aLoadState,
242 const ParentShowInfo& aInfo);
244 mozilla::ipc::IPCResult RecvCreateAboutBlankDocumentViewer(
245 nsIPrincipal* aPrincipal, nsIPrincipal* aPartitionedPrincipal);
247 mozilla::ipc::IPCResult RecvResumeLoad(const uint64_t& aPendingSwitchID,
248 const ParentShowInfo&);
250 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult
251 RecvCloneDocumentTreeIntoSelf(
252 const MaybeDiscarded<BrowsingContext>& aSourceBC,
253 const embedding::PrintData& aPrintData,
254 CloneDocumentTreeIntoSelfResolver&& aResolve);
256 MOZ_CAN_RUN_SCRIPT_BOUNDARY
257 mozilla::ipc::IPCResult RecvUpdateRemotePrintSettings(
258 const embedding::PrintData& aPrintData);
260 MOZ_CAN_RUN_SCRIPT_BOUNDARY
261 mozilla::ipc::IPCResult RecvShow(const ParentShowInfo&, const OwnerShowInfo&);
263 mozilla::ipc::IPCResult RecvInitRendering(
264 const TextureFactoryIdentifier& aTextureFactoryIdentifier,
265 const layers::LayersId& aLayersId,
266 const mozilla::layers::CompositorOptions& aCompositorOptions,
267 const bool& aLayersConnected);
269 mozilla::ipc::IPCResult RecvCompositorOptionsChanged(
270 const mozilla::layers::CompositorOptions& aNewOptions);
272 mozilla::ipc::IPCResult RecvUpdateDimensions(
273 const mozilla::dom::DimensionInfo& aDimensionInfo);
274 mozilla::ipc::IPCResult RecvSizeModeChanged(const nsSizeMode& aSizeMode);
276 mozilla::ipc::IPCResult RecvChildToParentMatrix(
277 const mozilla::Maybe<mozilla::gfx::Matrix4x4>& aMatrix,
278 const mozilla::ScreenRect& aTopLevelViewportVisibleRectInBrowserCoords);
280 MOZ_CAN_RUN_SCRIPT_BOUNDARY
281 mozilla::ipc::IPCResult RecvDynamicToolbarMaxHeightChanged(
282 const mozilla::ScreenIntCoord& aHeight);
284 mozilla::ipc::IPCResult RecvDynamicToolbarOffsetChanged(
285 const mozilla::ScreenIntCoord& aOffset);
287 mozilla::ipc::IPCResult RecvKeyboardHeightChanged(
288 const mozilla::ScreenIntCoord& aHeight);
290 mozilla::ipc::IPCResult RecvActivate(uint64_t aActionId);
292 mozilla::ipc::IPCResult RecvDeactivate(uint64_t aActionId);
294 mozilla::ipc::IPCResult RecvRealMouseMoveEvent(
295 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
296 const uint64_t& aInputBlockId);
297 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEvent(
298 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
299 const uint64_t& aInputBlockId);
300 mozilla::ipc::IPCResult RecvRealMouseMoveEventForTests(
301 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
302 const uint64_t& aInputBlockId);
303 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEventForTests(
304 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
305 const uint64_t& aInputBlockId);
307 mozilla::ipc::IPCResult RecvSynthMouseMoveEvent(
308 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
309 const uint64_t& aInputBlockId);
310 mozilla::ipc::IPCResult RecvNormalPrioritySynthMouseMoveEvent(
311 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
312 const uint64_t& aInputBlockId);
314 mozilla::ipc::IPCResult RecvRealMouseButtonEvent(
315 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
316 const uint64_t& aInputBlockId);
317 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseButtonEvent(
318 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
319 const uint64_t& aInputBlockId);
321 mozilla::ipc::IPCResult RecvRealPointerButtonEvent(
322 const mozilla::WidgetPointerEvent& aEvent,
323 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId);
324 mozilla::ipc::IPCResult RecvNormalPriorityRealPointerButtonEvent(
325 const mozilla::WidgetPointerEvent& aEvent,
326 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId);
328 mozilla::ipc::IPCResult RecvRealMouseEnterExitWidgetEvent(
329 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
330 const uint64_t& aInputBlockId);
331 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseEnterExitWidgetEvent(
332 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
333 const uint64_t& aInputBlockId);
335 MOZ_CAN_RUN_SCRIPT_BOUNDARY
336 mozilla::ipc::IPCResult RecvRealDragEvent(const WidgetDragEvent& aEvent,
337 const uint32_t& aDragAction,
338 const uint32_t& aDropEffect,
339 nsIPrincipal* aPrincipal,
340 nsIContentSecurityPolicy* aCsp);
342 mozilla::ipc::IPCResult RecvRealKeyEvent(
343 const mozilla::WidgetKeyboardEvent& aEvent, const nsID& aUUID);
345 mozilla::ipc::IPCResult RecvNormalPriorityRealKeyEvent(
346 const mozilla::WidgetKeyboardEvent& aEvent, const nsID& aUUID);
348 mozilla::ipc::IPCResult RecvMouseWheelEvent(
349 const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
350 const uint64_t& aInputBlockId);
352 mozilla::ipc::IPCResult RecvNormalPriorityMouseWheelEvent(
353 const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
354 const uint64_t& aInputBlockId);
356 mozilla::ipc::IPCResult RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
357 const ScrollableLayerGuid& aGuid,
358 const uint64_t& aInputBlockId,
359 const nsEventStatus& aApzResponse);
361 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchEvent(
362 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
363 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
365 mozilla::ipc::IPCResult RecvRealTouchMoveEvent(
366 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
367 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
369 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent(
370 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
371 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
373 mozilla::ipc::IPCResult RecvRealTouchMoveEvent2(
374 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
375 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
376 return RecvRealTouchMoveEvent(aEvent, aGuid, aInputBlockId, aApzResponse);
379 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent2(
380 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
381 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
382 return RecvNormalPriorityRealTouchMoveEvent(aEvent, aGuid, aInputBlockId,
383 aApzResponse);
386 mozilla::ipc::IPCResult RecvUpdateSHistory();
388 mozilla::ipc::IPCResult RecvNativeSynthesisResponse(
389 const uint64_t& aObserverId, const nsCString& aResponse);
391 mozilla::ipc::IPCResult RecvCompositionEvent(
392 const mozilla::WidgetCompositionEvent& aEvent);
394 mozilla::ipc::IPCResult RecvNormalPriorityCompositionEvent(
395 const mozilla::WidgetCompositionEvent& aEvent);
397 mozilla::ipc::IPCResult RecvSelectionEvent(
398 const mozilla::WidgetSelectionEvent& aEvent);
400 mozilla::ipc::IPCResult RecvNormalPrioritySelectionEvent(
401 const mozilla::WidgetSelectionEvent& aEvent);
403 mozilla::ipc::IPCResult RecvSimpleContentCommandEvent(
404 const mozilla::EventMessage& aMessage);
406 mozilla::ipc::IPCResult RecvNormalPrioritySimpleContentCommandEvent(
407 const mozilla::EventMessage& aMessage);
409 mozilla::ipc::IPCResult RecvInsertText(const nsAString& aStringToInsert);
411 mozilla::ipc::IPCResult RecvUpdateRemoteStyle(
412 const StyleImageRendering& aImageRendering);
414 mozilla::ipc::IPCResult RecvNormalPriorityInsertText(
415 const nsAString& aStringToInsert);
417 mozilla::ipc::IPCResult RecvReplaceText(const nsString& aReplaceSrcString,
418 const nsString& aStringToInsert,
419 uint32_t aOffset,
420 bool aPreventSetSelection);
422 mozilla::ipc::IPCResult RecvNormalPriorityReplaceText(
423 const nsString& aReplaceSrcString, const nsString& aStringToInsert,
424 uint32_t aOffset, bool aPreventSetSelection);
426 MOZ_CAN_RUN_SCRIPT_BOUNDARY
427 mozilla::ipc::IPCResult RecvPasteTransferable(
428 const IPCTransferable& aTransferable);
430 mozilla::ipc::IPCResult RecvLoadRemoteScript(const nsAString& aURL,
431 const bool& aRunInGlobalScope);
433 mozilla::ipc::IPCResult RecvAsyncMessage(const nsAString& aMessage,
434 const ClonedMessageData& aData);
435 mozilla::ipc::IPCResult RecvSwappedWithOtherRemoteLoader(
436 const IPCTabContext& aContext);
438 mozilla::ipc::IPCResult RecvSafeAreaInsetsChanged(
439 const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets);
441 #ifdef ACCESSIBILITY
442 PDocAccessibleChild* AllocPDocAccessibleChild(
443 PDocAccessibleChild*, const uint64_t&,
444 const MaybeDiscardedBrowsingContext&);
445 bool DeallocPDocAccessibleChild(PDocAccessibleChild*);
446 #endif
448 RefPtr<VsyncMainChild> GetVsyncChild();
450 nsIWebNavigation* WebNavigation() const { return mWebNav; }
452 PuppetWidget* WebWidget() { return mPuppetWidget; }
454 bool IsTransparent() const { return mIsTransparent; }
456 const EffectsInfo& GetEffectsInfo() const { return mEffectsInfo; }
458 void SetBackgroundColor(const nscolor& aColor);
460 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual mozilla::ipc::IPCResult RecvUpdateEffects(
461 const EffectsInfo& aEffects);
463 void RequestEditCommands(NativeKeyBindingsType aType,
464 const WidgetKeyboardEvent& aEvent,
465 nsTArray<CommandInt>& aCommands);
467 bool IsVisible();
468 bool IsPreservingLayers() const { return mIsPreservingLayers; }
471 * Signal to this BrowserChild that it should be made visible:
472 * activated widget, retained layer tree, etc. (Respectively,
473 * made not visible.)
475 void UpdateVisibility();
476 void MakeVisible();
477 void MakeHidden();
478 void PresShellActivenessMaybeChanged();
480 ContentChild* Manager() const { return mManager; }
482 static inline BrowserChild* GetFrom(nsIDocShell* aDocShell) {
483 if (!aDocShell) {
484 return nullptr;
487 nsCOMPtr<nsIBrowserChild> tc = aDocShell->GetBrowserChild();
488 return static_cast<BrowserChild*>(tc.get());
491 static inline BrowserChild* GetFrom(mozIDOMWindow* aWindow) {
492 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
493 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
494 return GetFrom(docShell);
497 static inline BrowserChild* GetFrom(mozIDOMWindowProxy* aWindow) {
498 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
499 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
500 return GetFrom(docShell);
503 static BrowserChild* GetFrom(PresShell* aPresShell);
504 static BrowserChild* GetFrom(layers::LayersId aLayersId);
506 layers::LayersId GetLayersId() { return mLayersId; }
507 Maybe<bool> IsLayersConnected() { return mLayersConnected; }
509 void DidComposite(mozilla::layers::TransactionId aTransactionId,
510 const TimeStamp& aCompositeStart,
511 const TimeStamp& aCompositeEnd);
513 void ClearCachedResources();
514 void SchedulePaint();
515 void ReinitRendering();
516 void ReinitRenderingForDeviceReset();
518 void NotifyJankedAnimations(const nsTArray<uint64_t>& aJankedAnimations);
520 static inline BrowserChild* GetFrom(nsIDOMWindow* aWindow) {
521 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
522 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
523 return GetFrom(docShell);
526 mozilla::ipc::IPCResult RecvUIResolutionChanged(const float& aDpi,
527 const int32_t& aRounding,
528 const double& aScale);
530 mozilla::ipc::IPCResult RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
531 nsTArray<uint32_t>&& aCharCodes);
532 MOZ_CAN_RUN_SCRIPT_BOUNDARY
533 mozilla::ipc::IPCResult RecvPrintPreview(const PrintData& aPrintData,
534 const MaybeDiscardedBrowsingContext&,
535 PrintPreviewResolver&& aCallback);
537 mozilla::ipc::IPCResult RecvExitPrintPreview();
539 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvPrint(
540 const MaybeDiscardedBrowsingContext&, const PrintData&, bool,
541 PrintResolver&&);
543 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvPrintClonedPage(
544 const MaybeDiscardedBrowsingContext&, const PrintData&,
545 const MaybeDiscardedBrowsingContext&);
547 mozilla::ipc::IPCResult RecvDestroyPrintClone(
548 const MaybeDiscardedBrowsingContext&);
550 mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(
551 const uintptr_t& aNewHandle);
553 mozilla::ipc::IPCResult RecvWillChangeProcess();
555 PPaymentRequestChild* AllocPPaymentRequestChild();
557 bool DeallocPPaymentRequestChild(PPaymentRequestChild* aActor);
559 LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
560 LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
561 ScreenIntCoord GetDynamicToolbarMaxHeight() const {
562 return mDynamicToolbarMaxHeight;
564 mozilla::ScreenIntCoord GetKeyboardHeight() const { return mKeyboardHeight; }
566 bool IPCOpen() const { return mIPCOpen; }
568 const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
569 bool AsyncPanZoomEnabled() const;
571 LayoutDeviceIntSize GetInnerSize();
572 CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; }
574 Maybe<nsRect> GetVisibleRect() const;
576 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
577 void DoFakeShow(const ParentShowInfo&);
579 void ContentReceivedInputBlock(uint64_t aInputBlockId,
580 bool aPreventDefault) const;
581 void SetTargetAPZC(
582 uint64_t aInputBlockId,
583 const nsTArray<layers::ScrollableLayerGuid>& aTargets) const;
584 MOZ_CAN_RUN_SCRIPT_BOUNDARY
585 mozilla::ipc::IPCResult RecvHandleTap(
586 const layers::GeckoContentController_TapType& aType,
587 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
588 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
589 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
591 MOZ_CAN_RUN_SCRIPT_BOUNDARY
592 mozilla::ipc::IPCResult RecvNormalPriorityHandleTap(
593 const layers::GeckoContentController_TapType& aType,
594 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
595 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
596 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
598 bool UpdateFrame(const layers::RepaintRequest& aRequest);
599 void NotifyAPZStateChange(
600 const ViewID& aViewId,
601 const layers::GeckoContentController_APZStateChange& aChange,
602 const int& aArg, Maybe<uint64_t> aInputBlockId);
603 void StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics);
604 void ZoomToRect(const uint32_t& aPresShellId,
605 const ScrollableLayerGuid::ViewID& aViewId,
606 const CSSRect& aRect, const uint32_t& aFlags);
608 // Request that the docshell be marked as active.
609 void PaintWhileInterruptingJS();
611 void UnloadLayersWhileInterruptingJS();
613 nsresult CanCancelContentJS(nsIRemoteTab::NavigationType aNavigationType,
614 int32_t aNavigationIndex, nsIURI* aNavigationURI,
615 int32_t aEpoch, bool* aCanCancel);
617 #if defined(XP_WIN) && defined(ACCESSIBILITY)
618 uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
619 #endif
621 BrowsingContext* GetBrowsingContext() const { return mBrowsingContext; }
623 // The transform from the coordinate space of this BrowserChild to the
624 // coordinate space of the native window its BrowserParent is in.
625 mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
626 GetChildToParentConversionMatrix() const;
628 // Returns the portion of the visible rect of this remote document in the
629 // top browser window coordinate system. This is the result of being
630 // clipped by all ancestor viewports.
631 Maybe<ScreenRect> GetTopLevelViewportVisibleRectInBrowserCoords() const;
633 // Similar to above GetTopLevelViewportVisibleRectInBrowserCoords(), but
634 // in this out-of-process document's coordinate system.
635 Maybe<LayoutDeviceRect> GetTopLevelViewportVisibleRectInSelfCoords() const;
637 // Prepare to dispatch all coalesced mousemove events. We'll move all data
638 // in mCoalescedMouseData to a nsDeque; then we start processing them. We
639 // can't fetch the coalesced event one by one and dispatch it because we
640 // may reentry the event loop and access to the same hashtable. It's
641 // called when dispatching some mouse events other than mousemove.
642 void FlushAllCoalescedMouseData();
643 void ProcessPendingCoalescedMouseDataAndDispatchEvents();
645 void ProcessPendingCoalescedTouchData();
647 void HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
648 const ScrollableLayerGuid& aGuid,
649 const uint64_t& aInputBlockId);
651 void SetCancelContentJSEpoch(int32_t aEpoch) {
652 mCancelContentJSEpoch = aEpoch;
655 void UpdateSessionStore();
657 mozilla::dom::SessionStoreChild* GetSessionStoreChild() {
658 return mSessionStoreChild;
661 #ifdef XP_WIN
662 // Check if the window this BrowserChild is associated with supports
663 // protected media (EME) or not.
664 // Returns a promise the will resolve true if the window supports
665 // protected media or false if it does not. The promise will be rejected
666 // with an ResponseRejectReason if the IPC needed to do the check fails.
667 // Callers should treat the reject case as if the window does not support
668 // protected media to ensure robust handling.
669 RefPtr<IsWindowSupportingProtectedMediaPromise>
670 DoesWindowSupportProtectedMedia();
671 #endif
673 // Notify the content blocking event in the parent process. This sends an
674 // IPC message to the BrowserParent in the parent. The BrowserParent will
675 // find the top-level WindowGlobalParent and notify the event from it.
676 void NotifyContentBlockingEvent(
677 uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
678 const nsACString& aTrackingOrigin,
679 const nsTArray<nsCString>& aTrackingFullHashes,
680 const Maybe<
681 ContentBlockingNotifier::StorageAccessPermissionGrantedReason>&
682 aReason,
683 const Maybe<ContentBlockingNotifier::CanvasFingerprinter>&
684 aCanvasFingerprinter,
685 const Maybe<bool> aCanvasFingerprinterKnownText);
687 already_AddRefed<nsIDragSession> GetDragSession();
688 void SetDragSession(nsIDragSession* aSession);
690 mozilla::ipc::IPCResult RecvInvokeChildDragSession(
691 const MaybeDiscarded<WindowContext>& aSourceWindowContext,
692 const MaybeDiscarded<WindowContext>& aSourceTopWindowContext,
693 nsIPrincipal* aPrincipal, nsTArray<IPCTransferableData>&& aTransferables,
694 const uint32_t& aAction);
696 mozilla::ipc::IPCResult RecvUpdateDragSession(
697 nsIPrincipal* aPrincipal, nsTArray<IPCTransferableData>&& aTransferables,
698 EventMessage aEventMessage);
700 MOZ_CAN_RUN_SCRIPT_BOUNDARY
701 mozilla::ipc::IPCResult RecvEndDragSession(
702 const bool& aDoneDrag, const bool& aUserCancelled,
703 const mozilla::LayoutDeviceIntPoint& aEndDragPoint,
704 const uint32_t& aKeyModifiers, const uint32_t& aDropEffect);
706 mozilla::ipc::IPCResult RecvStoreDropTargetAndDelayEndDragSession(
707 const LayoutDeviceIntPoint& aPt, uint32_t aDropEffect,
708 uint32_t aDragAction, nsIPrincipal* aPrincipal,
709 nsIContentSecurityPolicy* aCsp);
711 MOZ_CAN_RUN_SCRIPT_BOUNDARY
712 mozilla::ipc::IPCResult RecvDispatchToDropTargetAndResumeEndDragSession(
713 bool aShouldDrop);
715 protected:
716 virtual ~BrowserChild();
718 mozilla::ipc::IPCResult RecvDestroy();
720 MOZ_CAN_RUN_SCRIPT_BOUNDARY
721 mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled);
723 mozilla::ipc::IPCResult RecvPreserveLayers(bool);
725 mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
726 const bool& aForDocumentNavigation);
728 mozilla::ipc::IPCResult RecvSuppressDisplayport(const bool& aEnabled);
730 mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference);
732 mozilla::ipc::IPCResult RecvStopIMEStateManagement();
734 mozilla::ipc::IPCResult RecvAllowScriptsToClose();
736 mozilla::ipc::IPCResult RecvReleaseAllPointerCapture();
738 mozilla::ipc::IPCResult RecvReleasePointerLock();
740 private:
741 void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
742 const ScrollableLayerGuid& aGuid,
743 const DoubleTapToZoomMetrics& aMetrics);
745 void ActorDestroy(ActorDestroyReason why) override;
747 bool InitBrowserChildMessageManager();
749 void InitRenderingState(
750 const TextureFactoryIdentifier& aTextureFactoryIdentifier,
751 const layers::LayersId& aLayersId,
752 const mozilla::layers::CompositorOptions& aCompositorOptions);
753 void InitAPZState();
755 void DestroyWindow();
757 void ApplyParentShowInfo(const ParentShowInfo&);
759 bool HasValidInnerSize();
761 LayoutDeviceIntRect GetOuterRect();
763 void SetUnscaledInnerSize(const CSSSize& aSize) {
764 mUnscaledInnerSize = aSize;
767 bool SkipRepeatedKeyEvent(const WidgetKeyboardEvent& aEvent);
769 void UpdateRepeatedKeyEventEndTime(const WidgetKeyboardEvent& aEvent);
771 void DispatchCoalescedWheelEvent();
774 * Dispatch aEvent on aEvent.mWidget.
776 nsEventStatus DispatchWidgetEventViaAPZ(WidgetGUIEvent& aEvent);
778 void DispatchWheelEvent(const WidgetWheelEvent& aEvent,
779 const ScrollableLayerGuid& aGuid,
780 const uint64_t& aInputBlockId);
782 void InternalSetDocShellIsActive(bool aIsActive);
784 MOZ_CAN_RUN_SCRIPT
785 mozilla::ipc::IPCResult CommonPrint(
786 const MaybeDiscardedBrowsingContext& aBc, const PrintData& aPrintData,
787 RefPtr<BrowsingContext>* aCachedBrowsingContext);
789 bool CreateRemoteLayerManager(
790 mozilla::layers::PCompositorBridgeChild* aCompositorChild);
792 nsresult PrepareRequestData(nsIRequest* aRequest, RequestData& aRequestData);
793 nsresult PrepareProgressListenerData(nsIWebProgress* aWebProgress,
794 nsIRequest* aRequest,
795 WebProgressData& aWebProgressData,
796 RequestData& aRequestData);
798 MOZ_CAN_RUN_SCRIPT_BOUNDARY
799 nsresult UpdateRemotePrintSettings(const embedding::PrintData& aPrintData);
801 MOZ_CAN_RUN_SCRIPT_BOUNDARY
802 nsresult CloneDocumentTreeIntoSelf(
803 const MaybeDiscarded<BrowsingContext>& aSourceBC,
804 const embedding::PrintData& aPrintData);
806 already_AddRefed<DataTransfer> ConvertToDataTransfer(
807 nsIPrincipal* aPrincipal, nsTArray<IPCTransferableData>&& aTransferables,
808 EventMessage aMessage);
810 class DelayedDeleteRunnable;
812 RefPtr<BrowserChildMessageManager> mBrowserChildMessageManager;
813 TextureFactoryIdentifier mTextureFactoryIdentifier;
814 RefPtr<nsWebBrowser> mWebBrowser;
815 nsCOMPtr<nsIWebNavigation> mWebNav;
816 RefPtr<PuppetWidget> mPuppetWidget;
817 nsCOMPtr<nsIURI> mLastURI;
818 RefPtr<ContentChild> mManager;
819 RefPtr<BrowsingContext> mBrowsingContext;
820 RefPtr<nsBrowserStatusFilter> mStatusFilter;
821 RefPtr<nsIDragSession> mDragSession;
823 Maybe<CodeNameIndex> mPreviousConsumedKeyDownCode;
824 uint32_t mChromeFlags;
825 uint32_t mMaxTouchPoints;
826 layers::LayersId mLayersId;
827 CSSRect mUnscaledOuterRect;
828 Maybe<bool> mLayersConnected;
829 Maybe<bool> mLayersConnectRequested;
830 EffectsInfo mEffectsInfo;
832 RefPtr<APZEventState> mAPZEventState;
834 // Position of client area relative to the outer window
835 LayoutDeviceIntPoint mClientOffset;
836 // Position of tab, relative to parent widget (typically the window)
837 // NOTE: This value is valuable only for the top level browser.
838 LayoutDeviceIntPoint mChromeOffset;
839 ScreenIntCoord mDynamicToolbarMaxHeight;
840 // The software keyboard height.
841 ScreenIntCoord mKeyboardHeight;
842 TabId mUniqueId;
844 // Position of a delayed drop event.
845 LayoutDeviceIntPoint mDelayedDropPoint;
847 bool mDidFakeShow : 1;
848 bool mTriedBrowserInit : 1;
849 bool mHasValidInnerSize : 1;
850 bool mDestroyed : 1;
852 // Whether or not this browser is the child part of the top level PBrowser
853 // actor in a remote browser.
854 bool mIsTopLevel : 1;
856 bool mIsTransparent : 1;
857 bool mIPCOpen : 1;
859 bool mDidSetRealShowInfo : 1;
860 bool mDidLoadURLInit : 1;
862 bool mSkipKeyPress : 1;
864 bool mCoalesceMouseMoveEvents : 1;
866 bool mShouldSendWebProgressEventsToParent : 1;
868 // Whether we are rendering to the compositor or not.
869 bool mRenderLayers : 1;
871 // Whether we're artificially preserving layers.
872 bool mIsPreservingLayers : 1;
874 // Holds the compositor options for the compositor rendering this tab,
875 // once we find out which compositor that is.
876 Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
878 friend class ContentChild;
880 CSSSize mUnscaledInnerSize;
882 // Store the end time of the handling of the last repeated
883 // keydown/keypress event so that in case event handling takes time, some
884 // repeated events can be skipped to not flood child process.
885 mozilla::TimeStamp mRepeatedKeyEventTime;
887 // Similar to mRepeatedKeyEventTime, store the end time (from parent
888 // process) of handling the last repeated wheel event so that in case
889 // event handling takes time, some repeated events can be skipped to not
890 // flood child process.
891 mozilla::TimeStamp mLastWheelProcessedTimeFromParent;
892 mozilla::TimeDuration mLastWheelProcessingDuration;
894 // Hash table to track coalesced mousemove events for different pointers.
895 nsClassHashtable<nsUint32HashKey, CoalescedMouseData> mCoalescedMouseData;
897 nsDeque<CoalescedMouseData> mToBeDispatchedMouseData;
899 CoalescedWheelData mCoalescedWheelData;
900 CoalescedTouchData mCoalescedTouchData;
902 RefPtr<CoalescedMouseMoveFlusher> mCoalescedMouseEventFlusher;
903 RefPtr<CoalescedTouchMoveFlusher> mCoalescedTouchMoveEventFlusher;
905 RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
906 RefPtr<SessionStoreChild> mSessionStoreChild;
908 #if defined(XP_WIN) && defined(ACCESSIBILITY)
909 // The handle associated with the native window that contains this tab
910 uintptr_t mNativeWindowHandle;
911 #endif // defined(XP_WIN)
913 int32_t mCancelContentJSEpoch;
915 Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
916 // When mChildToParentConversionMatrix is Nothing() this value is invalid.
917 ScreenRect mTopLevelViewportVisibleRectInBrowserCoords;
919 #ifdef XP_WIN
920 // Should only be accessed on main thread.
921 Maybe<bool> mWindowSupportsProtectedMedia;
922 #endif
924 // If set, resolve when we receive ChildToParentMatrix.
925 RefPtr<dom::Promise> mContentTransformPromise;
927 DISALLOW_EVIL_CONSTRUCTORS(BrowserChild);
930 NS_DEFINE_STATIC_IID_ACCESSOR(BrowserChild, DOM_BROWSERCHILD_IID)
932 } // namespace dom
933 } // namespace mozilla
935 #endif // mozilla_dom_BrowserChild_h