Backed out changeset 1d9301697aa0 (bug 1887752) for causing failures on browser_all_f...
[gecko.git] / dom / ipc / BrowserChild.h
blob90cb7124763bc2c5514baf0aad4ce17da8c1a740
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 "nsIWebBrowserChromeFocus.h"
16 #include "nsIInterfaceRequestor.h"
17 #include "nsIWindowProvider.h"
18 #include "nsIDocShell.h"
19 #include "nsIInterfaceRequestorUtils.h"
20 #include "nsWeakReference.h"
21 #include "nsIBrowserChild.h"
22 #include "nsITooltipListener.h"
23 #include "nsIWebProgressListener.h"
24 #include "nsIWebProgressListener2.h"
25 #include "mozilla/Attributes.h"
26 #include "mozilla/dom/TabContext.h"
27 #include "mozilla/dom/CoalescedMouseData.h"
28 #include "mozilla/dom/CoalescedTouchData.h"
29 #include "mozilla/dom/CoalescedWheelData.h"
30 #include "mozilla/dom/MessageManagerCallback.h"
31 #include "mozilla/dom/VsyncMainChild.h"
32 #include "mozilla/DOMEventTargetHelper.h"
33 #include "mozilla/EventDispatcher.h"
34 #include "mozilla/EventForwards.h"
35 #include "mozilla/layers/APZCCallbackHelper.h"
36 #include "mozilla/layers/CompositorOptions.h"
37 #include "mozilla/layers/CompositorTypes.h"
38 #include "mozilla/layers/GeckoContentControllerTypes.h"
39 #include "mozilla/dom/ipc/IdType.h"
40 #include "PuppetWidget.h"
41 #include "nsDeque.h"
42 #include "nsIRemoteTab.h"
44 class nsBrowserStatusFilter;
45 class nsIDOMWindow;
46 class nsIHttpChannel;
47 class nsIRequest;
48 class nsISerialEventTarget;
49 class nsIWebProgress;
50 class nsWebBrowser;
51 class nsDocShellLoadState;
53 template <typename T>
54 class nsTHashtable;
55 template <typename T>
56 class nsPtrHashKey;
58 namespace mozilla {
59 enum class NativeKeyBindingsType : uint8_t;
61 class AbstractThread;
62 class PresShell;
64 namespace layers {
65 class APZChild;
66 class APZEventState;
67 class AsyncDragMetrics;
68 class IAPZCTreeManager;
69 class ImageCompositeNotification;
70 class PCompositorBridgeChild;
71 } // namespace layers
73 namespace widget {
74 struct AutoCacheNativeKeyCommands;
75 } // namespace widget
77 namespace dom {
79 class BrowserChild;
80 class BrowsingContext;
81 class TabGroup;
82 class ClonedMessageData;
83 class CoalescedMouseData;
84 class CoalescedWheelData;
85 class SessionStoreChild;
86 class RequestData;
87 class WebProgressData;
89 class BrowserChildMessageManager : public ContentFrameMessageManager,
90 public nsIMessageSender,
91 public nsSupportsWeakReference {
92 public:
93 explicit BrowserChildMessageManager(BrowserChild* aBrowserChild);
95 NS_DECL_ISUPPORTS_INHERITED
96 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BrowserChildMessageManager,
97 DOMEventTargetHelper)
99 void MarkForCC();
101 JSObject* WrapObject(JSContext* aCx,
102 JS::Handle<JSObject*> aGivenProto) override;
104 Nullable<WindowProxyHolder> GetContent(ErrorResult& aError) override;
105 already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) override;
106 already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
108 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
110 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override {
111 aVisitor.mForceContentDispatch = true;
114 // Dispatch a runnable related to the global.
115 nsresult Dispatch(already_AddRefed<nsIRunnable>&& aRunnable) const;
117 RefPtr<BrowserChild> mBrowserChild;
119 protected:
120 ~BrowserChildMessageManager();
124 * BrowserChild implements the child actor part of the PBrowser protocol. See
125 * PBrowser for more information.
127 class BrowserChild final : public nsMessageManagerScriptExecutor,
128 public ipc::MessageManagerCallback,
129 public PBrowserChild,
130 public nsIWebBrowserChrome,
131 public nsIWebBrowserChromeFocus,
132 public nsIInterfaceRequestor,
133 public nsIWindowProvider,
134 public nsSupportsWeakReference,
135 public nsIBrowserChild,
136 public nsIObserver,
137 public nsIWebProgressListener2,
138 public TabContext,
139 public nsITooltipListener,
140 public mozilla::ipc::IShmemAllocator {
141 using PuppetWidget = mozilla::widget::PuppetWidget;
142 using ClonedMessageData = mozilla::dom::ClonedMessageData;
143 using CoalescedMouseData = mozilla::dom::CoalescedMouseData;
144 using CoalescedWheelData = mozilla::dom::CoalescedWheelData;
145 using APZEventState = mozilla::layers::APZEventState;
146 using TouchBehaviorFlags = mozilla::layers::TouchBehaviorFlags;
148 friend class PBrowserChild;
150 public:
152 * Find BrowserChild of aTabId in the same content process of the
153 * caller.
155 static already_AddRefed<BrowserChild> FindBrowserChild(const TabId& aTabId);
157 // Return a list of all active BrowserChildren.
158 static nsTArray<RefPtr<BrowserChild>> GetAll();
160 public:
162 * Create a new BrowserChild object.
164 BrowserChild(ContentChild* aManager, const TabId& aTabId,
165 const TabContext& aContext,
166 dom::BrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
167 bool aIsTopLevel);
169 MOZ_CAN_RUN_SCRIPT nsresult Init(mozIDOMWindowProxy* aParent,
170 WindowGlobalChild* aInitialWindowChild);
172 /** Return a BrowserChild with the given attributes. */
173 static already_AddRefed<BrowserChild> Create(
174 ContentChild* aManager, const TabId& aTabId, const TabContext& aContext,
175 BrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
176 bool aIsTopLevel);
178 // Let managees query if it is safe to send messages.
179 bool IsDestroyed() const { return mDestroyed; }
181 TabId GetTabId() const {
182 MOZ_ASSERT(mUniqueId != 0);
183 return mUniqueId;
186 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
187 NS_DECL_NSIWEBBROWSERCHROME
188 NS_DECL_NSIWEBBROWSERCHROMEFOCUS
189 NS_DECL_NSIINTERFACEREQUESTOR
190 NS_DECL_NSIWINDOWPROVIDER
191 NS_DECL_NSIBROWSERCHILD
192 NS_DECL_NSIOBSERVER
193 NS_DECL_NSIWEBPROGRESSLISTENER
194 NS_DECL_NSIWEBPROGRESSLISTENER2
195 NS_DECL_NSITOOLTIPLISTENER
197 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(BrowserChild,
198 nsIBrowserChild)
200 FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild)
202 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
203 return mBrowserChildMessageManager->WrapObject(aCx, aGivenProto);
206 // Get the Document for the top-level window in this tab.
207 already_AddRefed<Document> GetTopLevelDocument() const;
209 // Get the pres-shell of the document for the top-level window in this tab.
210 PresShell* GetTopLevelPresShell() const;
212 BrowserChildMessageManager* GetMessageManager() {
213 return mBrowserChildMessageManager;
216 bool IsTopLevel() const { return mIsTopLevel; }
218 bool ShouldSendWebProgressEventsToParent() const {
219 return mShouldSendWebProgressEventsToParent;
223 * MessageManagerCallback methods that we override.
225 virtual bool DoSendBlockingMessage(
226 const nsAString& aMessage, StructuredCloneData& aData,
227 nsTArray<StructuredCloneData>* aRetVal) override;
229 virtual nsresult DoSendAsyncMessage(const nsAString& aMessage,
230 StructuredCloneData& aData) override;
232 bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
233 const ViewID& aViewId,
234 const Maybe<ZoomConstraints>& aConstraints);
236 mozilla::ipc::IPCResult RecvLoadURL(nsDocShellLoadState* aLoadState,
237 const ParentShowInfo& aInfo);
239 mozilla::ipc::IPCResult RecvCreateAboutBlankDocumentViewer(
240 nsIPrincipal* aPrincipal, nsIPrincipal* aPartitionedPrincipal);
242 mozilla::ipc::IPCResult RecvResumeLoad(const uint64_t& aPendingSwitchID,
243 const ParentShowInfo&);
245 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult
246 RecvCloneDocumentTreeIntoSelf(
247 const MaybeDiscarded<BrowsingContext>& aSourceBC,
248 const embedding::PrintData& aPrintData,
249 CloneDocumentTreeIntoSelfResolver&& aResolve);
251 MOZ_CAN_RUN_SCRIPT_BOUNDARY
252 mozilla::ipc::IPCResult RecvUpdateRemotePrintSettings(
253 const embedding::PrintData& aPrintData);
255 MOZ_CAN_RUN_SCRIPT_BOUNDARY
256 mozilla::ipc::IPCResult RecvShow(const ParentShowInfo&, const OwnerShowInfo&);
258 mozilla::ipc::IPCResult RecvInitRendering(
259 const TextureFactoryIdentifier& aTextureFactoryIdentifier,
260 const layers::LayersId& aLayersId,
261 const mozilla::layers::CompositorOptions& aCompositorOptions,
262 const bool& aLayersConnected);
264 mozilla::ipc::IPCResult RecvCompositorOptionsChanged(
265 const mozilla::layers::CompositorOptions& aNewOptions);
267 mozilla::ipc::IPCResult RecvUpdateDimensions(
268 const mozilla::dom::DimensionInfo& aDimensionInfo);
269 mozilla::ipc::IPCResult RecvSizeModeChanged(const nsSizeMode& aSizeMode);
271 mozilla::ipc::IPCResult RecvChildToParentMatrix(
272 const mozilla::Maybe<mozilla::gfx::Matrix4x4>& aMatrix,
273 const mozilla::ScreenRect& aTopLevelViewportVisibleRectInBrowserCoords);
275 MOZ_CAN_RUN_SCRIPT_BOUNDARY
276 mozilla::ipc::IPCResult RecvDynamicToolbarMaxHeightChanged(
277 const mozilla::ScreenIntCoord& aHeight);
279 mozilla::ipc::IPCResult RecvDynamicToolbarOffsetChanged(
280 const mozilla::ScreenIntCoord& aOffset);
282 mozilla::ipc::IPCResult RecvActivate(uint64_t aActionId);
284 mozilla::ipc::IPCResult RecvDeactivate(uint64_t aActionId);
286 mozilla::ipc::IPCResult RecvRealMouseMoveEvent(
287 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
288 const uint64_t& aInputBlockId);
289 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEvent(
290 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
291 const uint64_t& aInputBlockId);
292 mozilla::ipc::IPCResult RecvRealMouseMoveEventForTests(
293 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
294 const uint64_t& aInputBlockId);
295 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEventForTests(
296 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
297 const uint64_t& aInputBlockId);
299 mozilla::ipc::IPCResult RecvSynthMouseMoveEvent(
300 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
301 const uint64_t& aInputBlockId);
302 mozilla::ipc::IPCResult RecvNormalPrioritySynthMouseMoveEvent(
303 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
304 const uint64_t& aInputBlockId);
306 mozilla::ipc::IPCResult RecvRealMouseButtonEvent(
307 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
308 const uint64_t& aInputBlockId);
309 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseButtonEvent(
310 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
311 const uint64_t& aInputBlockId);
313 mozilla::ipc::IPCResult RecvRealMouseEnterExitWidgetEvent(
314 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
315 const uint64_t& aInputBlockId);
316 mozilla::ipc::IPCResult RecvNormalPriorityRealMouseEnterExitWidgetEvent(
317 const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
318 const uint64_t& aInputBlockId);
320 MOZ_CAN_RUN_SCRIPT_BOUNDARY
321 mozilla::ipc::IPCResult RecvRealDragEvent(const WidgetDragEvent& aEvent,
322 const uint32_t& aDragAction,
323 const uint32_t& aDropEffect,
324 nsIPrincipal* aPrincipal,
325 nsIContentSecurityPolicy* aCsp);
327 mozilla::ipc::IPCResult RecvRealKeyEvent(
328 const mozilla::WidgetKeyboardEvent& aEvent, const nsID& aUUID);
330 mozilla::ipc::IPCResult RecvNormalPriorityRealKeyEvent(
331 const mozilla::WidgetKeyboardEvent& aEvent, const nsID& aUUID);
333 mozilla::ipc::IPCResult RecvMouseWheelEvent(
334 const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
335 const uint64_t& aInputBlockId);
337 mozilla::ipc::IPCResult RecvNormalPriorityMouseWheelEvent(
338 const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
339 const uint64_t& aInputBlockId);
341 mozilla::ipc::IPCResult RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
342 const ScrollableLayerGuid& aGuid,
343 const uint64_t& aInputBlockId,
344 const nsEventStatus& aApzResponse);
346 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchEvent(
347 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
348 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
350 mozilla::ipc::IPCResult RecvRealTouchMoveEvent(
351 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
352 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
354 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent(
355 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
356 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
358 mozilla::ipc::IPCResult RecvRealTouchMoveEvent2(
359 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
360 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
361 return RecvRealTouchMoveEvent(aEvent, aGuid, aInputBlockId, aApzResponse);
364 mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent2(
365 const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
366 const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
367 return RecvNormalPriorityRealTouchMoveEvent(aEvent, aGuid, aInputBlockId,
368 aApzResponse);
371 mozilla::ipc::IPCResult RecvUpdateSHistory();
373 mozilla::ipc::IPCResult RecvNativeSynthesisResponse(
374 const uint64_t& aObserverId, const nsCString& aResponse);
376 mozilla::ipc::IPCResult RecvCompositionEvent(
377 const mozilla::WidgetCompositionEvent& aEvent);
379 mozilla::ipc::IPCResult RecvNormalPriorityCompositionEvent(
380 const mozilla::WidgetCompositionEvent& aEvent);
382 mozilla::ipc::IPCResult RecvSelectionEvent(
383 const mozilla::WidgetSelectionEvent& aEvent);
385 mozilla::ipc::IPCResult RecvNormalPrioritySelectionEvent(
386 const mozilla::WidgetSelectionEvent& aEvent);
388 mozilla::ipc::IPCResult RecvInsertText(const nsAString& aStringToInsert);
390 mozilla::ipc::IPCResult RecvUpdateRemoteStyle(
391 const StyleImageRendering& aImageRendering);
393 mozilla::ipc::IPCResult RecvNormalPriorityInsertText(
394 const nsAString& aStringToInsert);
396 MOZ_CAN_RUN_SCRIPT_BOUNDARY
397 mozilla::ipc::IPCResult RecvPasteTransferable(
398 const IPCTransferable& aTransferable);
400 mozilla::ipc::IPCResult RecvLoadRemoteScript(const nsAString& aURL,
401 const bool& aRunInGlobalScope);
403 mozilla::ipc::IPCResult RecvAsyncMessage(const nsAString& aMessage,
404 const ClonedMessageData& aData);
405 mozilla::ipc::IPCResult RecvSwappedWithOtherRemoteLoader(
406 const IPCTabContext& aContext);
408 mozilla::ipc::IPCResult RecvSafeAreaInsetsChanged(
409 const mozilla::ScreenIntMargin& aSafeAreaInsets);
411 #ifdef ACCESSIBILITY
412 PDocAccessibleChild* AllocPDocAccessibleChild(
413 PDocAccessibleChild*, const uint64_t&,
414 const MaybeDiscardedBrowsingContext&);
415 bool DeallocPDocAccessibleChild(PDocAccessibleChild*);
416 #endif
418 RefPtr<VsyncMainChild> GetVsyncChild();
420 nsIWebNavigation* WebNavigation() const { return mWebNav; }
422 PuppetWidget* WebWidget() { return mPuppetWidget; }
424 bool IsTransparent() const { return mIsTransparent; }
426 const EffectsInfo& GetEffectsInfo() const { return mEffectsInfo; }
428 void SetBackgroundColor(const nscolor& aColor);
430 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual mozilla::ipc::IPCResult RecvUpdateEffects(
431 const EffectsInfo& aEffects);
433 void RequestEditCommands(NativeKeyBindingsType aType,
434 const WidgetKeyboardEvent& aEvent,
435 nsTArray<CommandInt>& aCommands);
437 bool IsVisible();
438 bool IsPreservingLayers() const { return mIsPreservingLayers; }
441 * Signal to this BrowserChild that it should be made visible:
442 * activated widget, retained layer tree, etc. (Respectively,
443 * made not visible.)
445 void UpdateVisibility();
446 void MakeVisible();
447 void MakeHidden();
448 void PresShellActivenessMaybeChanged();
450 ContentChild* Manager() const { return mManager; }
452 static inline BrowserChild* GetFrom(nsIDocShell* aDocShell) {
453 if (!aDocShell) {
454 return nullptr;
457 nsCOMPtr<nsIBrowserChild> tc = aDocShell->GetBrowserChild();
458 return static_cast<BrowserChild*>(tc.get());
461 static inline BrowserChild* GetFrom(mozIDOMWindow* aWindow) {
462 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
463 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
464 return GetFrom(docShell);
467 static inline BrowserChild* GetFrom(mozIDOMWindowProxy* aWindow) {
468 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
469 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
470 return GetFrom(docShell);
473 static BrowserChild* GetFrom(PresShell* aPresShell);
474 static BrowserChild* GetFrom(layers::LayersId aLayersId);
476 layers::LayersId GetLayersId() { return mLayersId; }
477 Maybe<bool> IsLayersConnected() { return mLayersConnected; }
479 void DidComposite(mozilla::layers::TransactionId aTransactionId,
480 const TimeStamp& aCompositeStart,
481 const TimeStamp& aCompositeEnd);
483 void ClearCachedResources();
484 void SchedulePaint();
485 void ReinitRendering();
486 void ReinitRenderingForDeviceReset();
488 void NotifyJankedAnimations(const nsTArray<uint64_t>& aJankedAnimations);
490 static inline BrowserChild* GetFrom(nsIDOMWindow* aWindow) {
491 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
492 nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
493 return GetFrom(docShell);
496 mozilla::ipc::IPCResult RecvUIResolutionChanged(const float& aDpi,
497 const int32_t& aRounding,
498 const double& aScale);
500 mozilla::ipc::IPCResult RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
501 nsTArray<uint32_t>&& aCharCodes);
502 MOZ_CAN_RUN_SCRIPT_BOUNDARY
503 mozilla::ipc::IPCResult RecvPrintPreview(const PrintData& aPrintData,
504 const MaybeDiscardedBrowsingContext&,
505 PrintPreviewResolver&& aCallback);
507 mozilla::ipc::IPCResult RecvExitPrintPreview();
509 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvPrint(
510 const MaybeDiscardedBrowsingContext&, const PrintData&, bool,
511 PrintResolver&&);
513 MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvPrintClonedPage(
514 const MaybeDiscardedBrowsingContext&, const PrintData&,
515 const MaybeDiscardedBrowsingContext&);
517 mozilla::ipc::IPCResult RecvDestroyPrintClone(
518 const MaybeDiscardedBrowsingContext&);
520 mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(
521 const uintptr_t& aNewHandle);
523 mozilla::ipc::IPCResult RecvWillChangeProcess();
525 PPaymentRequestChild* AllocPPaymentRequestChild();
527 bool DeallocPPaymentRequestChild(PPaymentRequestChild* aActor);
529 LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
530 LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
531 ScreenIntCoord GetDynamicToolbarMaxHeight() const {
532 return mDynamicToolbarMaxHeight;
535 bool IPCOpen() const { return mIPCOpen; }
537 const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
538 bool AsyncPanZoomEnabled() const;
540 ScreenIntSize GetInnerSize();
541 CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; }
543 Maybe<nsRect> GetVisibleRect() const;
545 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
546 void DoFakeShow(const ParentShowInfo&);
548 void ContentReceivedInputBlock(uint64_t aInputBlockId,
549 bool aPreventDefault) const;
550 void SetTargetAPZC(
551 uint64_t aInputBlockId,
552 const nsTArray<layers::ScrollableLayerGuid>& aTargets) const;
553 MOZ_CAN_RUN_SCRIPT_BOUNDARY
554 mozilla::ipc::IPCResult RecvHandleTap(
555 const layers::GeckoContentController_TapType& aType,
556 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
557 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
558 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
560 MOZ_CAN_RUN_SCRIPT_BOUNDARY
561 mozilla::ipc::IPCResult RecvNormalPriorityHandleTap(
562 const layers::GeckoContentController_TapType& aType,
563 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
564 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
565 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
567 bool UpdateFrame(const layers::RepaintRequest& aRequest);
568 void NotifyAPZStateChange(
569 const ViewID& aViewId,
570 const layers::GeckoContentController_APZStateChange& aChange,
571 const int& aArg, Maybe<uint64_t> aInputBlockId);
572 void StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics);
573 void ZoomToRect(const uint32_t& aPresShellId,
574 const ScrollableLayerGuid::ViewID& aViewId,
575 const CSSRect& aRect, const uint32_t& aFlags);
577 // Request that the docshell be marked as active.
578 void PaintWhileInterruptingJS();
580 void UnloadLayersWhileInterruptingJS();
582 nsresult CanCancelContentJS(nsIRemoteTab::NavigationType aNavigationType,
583 int32_t aNavigationIndex, nsIURI* aNavigationURI,
584 int32_t aEpoch, bool* aCanCancel);
586 #if defined(XP_WIN) && defined(ACCESSIBILITY)
587 uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
588 #endif
590 BrowsingContext* GetBrowsingContext() const { return mBrowsingContext; }
592 // The transform from the coordinate space of this BrowserChild to the
593 // coordinate space of the native window its BrowserParent is in.
594 mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
595 GetChildToParentConversionMatrix() const;
597 // Returns the portion of the visible rect of this remote document in the
598 // top browser window coordinate system. This is the result of being
599 // clipped by all ancestor viewports.
600 Maybe<ScreenRect> GetTopLevelViewportVisibleRectInBrowserCoords() const;
602 // Similar to above GetTopLevelViewportVisibleRectInBrowserCoords(), but
603 // in this out-of-process document's coordinate system.
604 Maybe<LayoutDeviceRect> GetTopLevelViewportVisibleRectInSelfCoords() const;
606 // Prepare to dispatch all coalesced mousemove events. We'll move all data
607 // in mCoalescedMouseData to a nsDeque; then we start processing them. We
608 // can't fetch the coalesced event one by one and dispatch it because we
609 // may reentry the event loop and access to the same hashtable. It's
610 // called when dispatching some mouse events other than mousemove.
611 void FlushAllCoalescedMouseData();
612 void ProcessPendingCoalescedMouseDataAndDispatchEvents();
614 void ProcessPendingCoalescedTouchData();
616 void HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
617 const ScrollableLayerGuid& aGuid,
618 const uint64_t& aInputBlockId);
620 void SetCancelContentJSEpoch(int32_t aEpoch) {
621 mCancelContentJSEpoch = aEpoch;
624 void UpdateSessionStore();
626 mozilla::dom::SessionStoreChild* GetSessionStoreChild() {
627 return mSessionStoreChild;
630 #ifdef XP_WIN
631 // Check if the window this BrowserChild is associated with supports
632 // protected media (EME) or not.
633 // Returns a promise the will resolve true if the window supports
634 // protected media or false if it does not. The promise will be rejected
635 // with an ResponseRejectReason if the IPC needed to do the check fails.
636 // Callers should treat the reject case as if the window does not support
637 // protected media to ensure robust handling.
638 RefPtr<IsWindowSupportingProtectedMediaPromise>
639 DoesWindowSupportProtectedMedia();
640 #endif
642 // Notify the content blocking event in the parent process. This sends an
643 // IPC message to the BrowserParent in the parent. The BrowserParent will
644 // find the top-level WindowGlobalParent and notify the event from it.
645 void NotifyContentBlockingEvent(
646 uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
647 const nsACString& aTrackingOrigin,
648 const nsTArray<nsCString>& aTrackingFullHashes,
649 const Maybe<
650 ContentBlockingNotifier::StorageAccessPermissionGrantedReason>&
651 aReason,
652 const Maybe<ContentBlockingNotifier::CanvasFingerprinter>&
653 aCanvasFingerprinter,
654 const Maybe<bool> aCanvasFingerprinterKnownText);
656 protected:
657 virtual ~BrowserChild();
659 mozilla::ipc::IPCResult RecvDestroy();
661 MOZ_CAN_RUN_SCRIPT_BOUNDARY
662 mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled);
664 mozilla::ipc::IPCResult RecvPreserveLayers(bool);
666 mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
667 const bool& aForDocumentNavigation);
669 mozilla::ipc::IPCResult RecvSuppressDisplayport(const bool& aEnabled);
671 mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference);
673 mozilla::ipc::IPCResult RecvStopIMEStateManagement();
675 mozilla::ipc::IPCResult RecvAllowScriptsToClose();
677 mozilla::ipc::IPCResult RecvReleaseAllPointerCapture();
679 private:
680 void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
681 const ScrollableLayerGuid& aGuid,
682 const DoubleTapToZoomMetrics& aMetrics);
684 void ActorDestroy(ActorDestroyReason why) override;
686 bool InitBrowserChildMessageManager();
688 void InitRenderingState(
689 const TextureFactoryIdentifier& aTextureFactoryIdentifier,
690 const layers::LayersId& aLayersId,
691 const mozilla::layers::CompositorOptions& aCompositorOptions);
692 void InitAPZState();
694 void DestroyWindow();
696 void ApplyParentShowInfo(const ParentShowInfo&);
698 bool HasValidInnerSize();
700 ScreenIntRect GetOuterRect();
702 void SetUnscaledInnerSize(const CSSSize& aSize) {
703 mUnscaledInnerSize = aSize;
706 bool SkipRepeatedKeyEvent(const WidgetKeyboardEvent& aEvent);
708 void UpdateRepeatedKeyEventEndTime(const WidgetKeyboardEvent& aEvent);
710 void DispatchCoalescedWheelEvent();
713 * Dispatch aEvent on aEvent.mWidget.
715 nsEventStatus DispatchWidgetEventViaAPZ(WidgetGUIEvent& aEvent);
717 void DispatchWheelEvent(const WidgetWheelEvent& aEvent,
718 const ScrollableLayerGuid& aGuid,
719 const uint64_t& aInputBlockId);
721 void InternalSetDocShellIsActive(bool aIsActive);
723 MOZ_CAN_RUN_SCRIPT
724 mozilla::ipc::IPCResult CommonPrint(
725 const MaybeDiscardedBrowsingContext& aBc, const PrintData& aPrintData,
726 RefPtr<BrowsingContext>* aCachedBrowsingContext);
728 bool CreateRemoteLayerManager(
729 mozilla::layers::PCompositorBridgeChild* aCompositorChild);
731 nsresult PrepareRequestData(nsIRequest* aRequest, RequestData& aRequestData);
732 nsresult PrepareProgressListenerData(nsIWebProgress* aWebProgress,
733 nsIRequest* aRequest,
734 WebProgressData& aWebProgressData,
735 RequestData& aRequestData);
737 MOZ_CAN_RUN_SCRIPT_BOUNDARY
738 nsresult UpdateRemotePrintSettings(const embedding::PrintData& aPrintData);
740 MOZ_CAN_RUN_SCRIPT_BOUNDARY
741 nsresult CloneDocumentTreeIntoSelf(
742 const MaybeDiscarded<BrowsingContext>& aSourceBC,
743 const embedding::PrintData& aPrintData);
745 class DelayedDeleteRunnable;
747 RefPtr<BrowserChildMessageManager> mBrowserChildMessageManager;
748 TextureFactoryIdentifier mTextureFactoryIdentifier;
749 RefPtr<nsWebBrowser> mWebBrowser;
750 nsCOMPtr<nsIWebNavigation> mWebNav;
751 RefPtr<PuppetWidget> mPuppetWidget;
752 nsCOMPtr<nsIURI> mLastURI;
753 RefPtr<ContentChild> mManager;
754 RefPtr<BrowsingContext> mBrowsingContext;
755 RefPtr<nsBrowserStatusFilter> mStatusFilter;
756 uint32_t mChromeFlags;
757 uint32_t mMaxTouchPoints;
758 layers::LayersId mLayersId;
759 CSSRect mUnscaledOuterRect;
760 Maybe<bool> mLayersConnected;
761 Maybe<bool> mLayersConnectRequested;
762 EffectsInfo mEffectsInfo;
764 RefPtr<VsyncMainChild> mVsyncChild;
766 RefPtr<APZEventState> mAPZEventState;
768 // Position of client area relative to the outer window
769 LayoutDeviceIntPoint mClientOffset;
770 // Position of tab, relative to parent widget (typically the window)
771 // NOTE: This value is valuable only for the top level browser.
772 LayoutDeviceIntPoint mChromeOffset;
773 ScreenIntCoord mDynamicToolbarMaxHeight;
774 TabId mUniqueId;
776 bool mDidFakeShow : 1;
777 bool mTriedBrowserInit : 1;
778 bool mIgnoreKeyPressEvent : 1;
779 bool mHasValidInnerSize : 1;
780 bool mDestroyed : 1;
782 // Whether or not this browser is the child part of the top level PBrowser
783 // actor in a remote browser.
784 bool mIsTopLevel : 1;
786 bool mIsTransparent : 1;
787 bool mIPCOpen : 1;
789 bool mDidSetRealShowInfo : 1;
790 bool mDidLoadURLInit : 1;
792 bool mSkipKeyPress : 1;
794 bool mCoalesceMouseMoveEvents : 1;
796 bool mShouldSendWebProgressEventsToParent : 1;
798 // Whether we are rendering to the compositor or not.
799 bool mRenderLayers : 1;
801 // Whether we're artificially preserving layers.
802 bool mIsPreservingLayers : 1;
804 // Holds the compositor options for the compositor rendering this tab,
805 // once we find out which compositor that is.
806 Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
808 friend class ContentChild;
810 CSSSize mUnscaledInnerSize;
812 // Store the end time of the handling of the last repeated
813 // keydown/keypress event so that in case event handling takes time, some
814 // repeated events can be skipped to not flood child process.
815 mozilla::TimeStamp mRepeatedKeyEventTime;
817 // Similar to mRepeatedKeyEventTime, store the end time (from parent
818 // process) of handling the last repeated wheel event so that in case
819 // event handling takes time, some repeated events can be skipped to not
820 // flood child process.
821 mozilla::TimeStamp mLastWheelProcessedTimeFromParent;
822 mozilla::TimeDuration mLastWheelProcessingDuration;
824 // Hash table to track coalesced mousemove events for different pointers.
825 nsClassHashtable<nsUint32HashKey, CoalescedMouseData> mCoalescedMouseData;
827 nsDeque<CoalescedMouseData> mToBeDispatchedMouseData;
829 CoalescedWheelData mCoalescedWheelData;
830 CoalescedTouchData mCoalescedTouchData;
832 RefPtr<CoalescedMouseMoveFlusher> mCoalescedMouseEventFlusher;
833 RefPtr<CoalescedTouchMoveFlusher> mCoalescedTouchMoveEventFlusher;
835 RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
836 RefPtr<SessionStoreChild> mSessionStoreChild;
838 #if defined(XP_WIN) && defined(ACCESSIBILITY)
839 // The handle associated with the native window that contains this tab
840 uintptr_t mNativeWindowHandle;
841 #endif // defined(XP_WIN)
843 int32_t mCancelContentJSEpoch;
845 Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
846 // When mChildToParentConversionMatrix is Nothing() this value is invalid.
847 ScreenRect mTopLevelViewportVisibleRectInBrowserCoords;
849 #ifdef XP_WIN
850 // Should only be accessed on main thread.
851 Maybe<bool> mWindowSupportsProtectedMedia;
852 #endif
854 // If set, resolve when we receive ChildToParentMatrix.
855 RefPtr<dom::Promise> mContentTransformPromise;
857 DISALLOW_EVIL_CONSTRUCTORS(BrowserChild);
860 } // namespace dom
861 } // namespace mozilla
863 #endif // mozilla_dom_BrowserChild_h