no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / ipc / BrowserChild.h
blobddbf8f0b74fd632a9ee3d335d442e9f7c8515b40
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&);
512 mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(
513 const uintptr_t& aNewHandle);
515 mozilla::ipc::IPCResult RecvWillChangeProcess();
517 PPaymentRequestChild* AllocPPaymentRequestChild();
519 bool DeallocPPaymentRequestChild(PPaymentRequestChild* aActor);
521 LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
522 LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
523 ScreenIntCoord GetDynamicToolbarMaxHeight() const {
524 return mDynamicToolbarMaxHeight;
527 bool IPCOpen() const { return mIPCOpen; }
529 const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
530 bool AsyncPanZoomEnabled() const;
532 ScreenIntSize GetInnerSize();
533 CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; }
535 Maybe<nsRect> GetVisibleRect() const;
537 // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
538 void DoFakeShow(const ParentShowInfo&);
540 void ContentReceivedInputBlock(uint64_t aInputBlockId,
541 bool aPreventDefault) const;
542 void SetTargetAPZC(
543 uint64_t aInputBlockId,
544 const nsTArray<layers::ScrollableLayerGuid>& aTargets) const;
545 MOZ_CAN_RUN_SCRIPT_BOUNDARY
546 mozilla::ipc::IPCResult RecvHandleTap(
547 const layers::GeckoContentController_TapType& aType,
548 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
549 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
550 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
552 MOZ_CAN_RUN_SCRIPT_BOUNDARY
553 mozilla::ipc::IPCResult RecvNormalPriorityHandleTap(
554 const layers::GeckoContentController_TapType& aType,
555 const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
556 const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
557 const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics);
559 bool UpdateFrame(const layers::RepaintRequest& aRequest);
560 void NotifyAPZStateChange(
561 const ViewID& aViewId,
562 const layers::GeckoContentController_APZStateChange& aChange,
563 const int& aArg, Maybe<uint64_t> aInputBlockId);
564 void StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics);
565 void ZoomToRect(const uint32_t& aPresShellId,
566 const ScrollableLayerGuid::ViewID& aViewId,
567 const CSSRect& aRect, const uint32_t& aFlags);
569 // Request that the docshell be marked as active.
570 void PaintWhileInterruptingJS();
572 void UnloadLayersWhileInterruptingJS();
574 nsresult CanCancelContentJS(nsIRemoteTab::NavigationType aNavigationType,
575 int32_t aNavigationIndex, nsIURI* aNavigationURI,
576 int32_t aEpoch, bool* aCanCancel);
578 #if defined(XP_WIN) && defined(ACCESSIBILITY)
579 uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
580 #endif
582 BrowsingContext* GetBrowsingContext() const { return mBrowsingContext; }
584 // The transform from the coordinate space of this BrowserChild to the
585 // coordinate space of the native window its BrowserParent is in.
586 mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
587 GetChildToParentConversionMatrix() const;
589 // Returns the portion of the visible rect of this remote document in the
590 // top browser window coordinate system. This is the result of being
591 // clipped by all ancestor viewports.
592 Maybe<ScreenRect> GetTopLevelViewportVisibleRectInBrowserCoords() const;
594 // Similar to above GetTopLevelViewportVisibleRectInBrowserCoords(), but
595 // in this out-of-process document's coordinate system.
596 Maybe<LayoutDeviceRect> GetTopLevelViewportVisibleRectInSelfCoords() const;
598 // Prepare to dispatch all coalesced mousemove events. We'll move all data
599 // in mCoalescedMouseData to a nsDeque; then we start processing them. We
600 // can't fetch the coalesced event one by one and dispatch it because we
601 // may reentry the event loop and access to the same hashtable. It's
602 // called when dispatching some mouse events other than mousemove.
603 void FlushAllCoalescedMouseData();
604 void ProcessPendingCoalescedMouseDataAndDispatchEvents();
606 void ProcessPendingCoalescedTouchData();
608 void HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
609 const ScrollableLayerGuid& aGuid,
610 const uint64_t& aInputBlockId);
612 void SetCancelContentJSEpoch(int32_t aEpoch) {
613 mCancelContentJSEpoch = aEpoch;
616 void UpdateSessionStore();
618 mozilla::dom::SessionStoreChild* GetSessionStoreChild() {
619 return mSessionStoreChild;
622 #ifdef XP_WIN
623 // Check if the window this BrowserChild is associated with supports
624 // protected media (EME) or not.
625 // Returns a promise the will resolve true if the window supports
626 // protected media or false if it does not. The promise will be rejected
627 // with an ResponseRejectReason if the IPC needed to do the check fails.
628 // Callers should treat the reject case as if the window does not support
629 // protected media to ensure robust handling.
630 RefPtr<IsWindowSupportingProtectedMediaPromise>
631 DoesWindowSupportProtectedMedia();
632 #endif
634 // Notify the content blocking event in the parent process. This sends an
635 // IPC message to the BrowserParent in the parent. The BrowserParent will
636 // find the top-level WindowGlobalParent and notify the event from it.
637 void NotifyContentBlockingEvent(
638 uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
639 const nsACString& aTrackingOrigin,
640 const nsTArray<nsCString>& aTrackingFullHashes,
641 const Maybe<
642 ContentBlockingNotifier::StorageAccessPermissionGrantedReason>&
643 aReason,
644 const Maybe<ContentBlockingNotifier::CanvasFingerprinter>&
645 aCanvasFingerprinter,
646 const Maybe<bool> aCanvasFingerprinterKnownText);
648 protected:
649 virtual ~BrowserChild();
651 mozilla::ipc::IPCResult RecvDestroy();
653 MOZ_CAN_RUN_SCRIPT_BOUNDARY
654 mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled);
656 mozilla::ipc::IPCResult RecvPreserveLayers(bool);
658 mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
659 const bool& aForDocumentNavigation);
661 mozilla::ipc::IPCResult RecvSuppressDisplayport(const bool& aEnabled);
663 mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference);
665 mozilla::ipc::IPCResult RecvStopIMEStateManagement();
667 mozilla::ipc::IPCResult RecvAllowScriptsToClose();
669 mozilla::ipc::IPCResult RecvReleaseAllPointerCapture();
671 private:
672 void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
673 const ScrollableLayerGuid& aGuid,
674 const DoubleTapToZoomMetrics& aMetrics);
676 void ActorDestroy(ActorDestroyReason why) override;
678 bool InitBrowserChildMessageManager();
680 void InitRenderingState(
681 const TextureFactoryIdentifier& aTextureFactoryIdentifier,
682 const layers::LayersId& aLayersId,
683 const mozilla::layers::CompositorOptions& aCompositorOptions);
684 void InitAPZState();
686 void DestroyWindow();
688 void ApplyParentShowInfo(const ParentShowInfo&);
690 bool HasValidInnerSize();
692 ScreenIntRect GetOuterRect();
694 void SetUnscaledInnerSize(const CSSSize& aSize) {
695 mUnscaledInnerSize = aSize;
698 bool SkipRepeatedKeyEvent(const WidgetKeyboardEvent& aEvent);
700 void UpdateRepeatedKeyEventEndTime(const WidgetKeyboardEvent& aEvent);
702 void DispatchCoalescedWheelEvent();
705 * Dispatch aEvent on aEvent.mWidget.
707 nsEventStatus DispatchWidgetEventViaAPZ(WidgetGUIEvent& aEvent);
709 void DispatchWheelEvent(const WidgetWheelEvent& aEvent,
710 const ScrollableLayerGuid& aGuid,
711 const uint64_t& aInputBlockId);
713 void InternalSetDocShellIsActive(bool aIsActive);
715 bool CreateRemoteLayerManager(
716 mozilla::layers::PCompositorBridgeChild* aCompositorChild);
718 nsresult PrepareRequestData(nsIRequest* aRequest, RequestData& aRequestData);
719 nsresult PrepareProgressListenerData(nsIWebProgress* aWebProgress,
720 nsIRequest* aRequest,
721 WebProgressData& aWebProgressData,
722 RequestData& aRequestData);
724 MOZ_CAN_RUN_SCRIPT_BOUNDARY
725 nsresult UpdateRemotePrintSettings(const embedding::PrintData& aPrintData);
727 MOZ_CAN_RUN_SCRIPT_BOUNDARY
728 nsresult CloneDocumentTreeIntoSelf(
729 const MaybeDiscarded<BrowsingContext>& aSourceBC,
730 const embedding::PrintData& aPrintData);
732 class DelayedDeleteRunnable;
734 RefPtr<BrowserChildMessageManager> mBrowserChildMessageManager;
735 TextureFactoryIdentifier mTextureFactoryIdentifier;
736 RefPtr<nsWebBrowser> mWebBrowser;
737 nsCOMPtr<nsIWebNavigation> mWebNav;
738 RefPtr<PuppetWidget> mPuppetWidget;
739 nsCOMPtr<nsIURI> mLastURI;
740 RefPtr<ContentChild> mManager;
741 RefPtr<BrowsingContext> mBrowsingContext;
742 RefPtr<nsBrowserStatusFilter> mStatusFilter;
743 uint32_t mChromeFlags;
744 uint32_t mMaxTouchPoints;
745 layers::LayersId mLayersId;
746 CSSRect mUnscaledOuterRect;
747 Maybe<bool> mLayersConnected;
748 Maybe<bool> mLayersConnectRequested;
749 EffectsInfo mEffectsInfo;
751 RefPtr<VsyncMainChild> mVsyncChild;
753 RefPtr<APZEventState> mAPZEventState;
755 // Position of client area relative to the outer window
756 LayoutDeviceIntPoint mClientOffset;
757 // Position of tab, relative to parent widget (typically the window)
758 // NOTE: This value is valuable only for the top level browser.
759 LayoutDeviceIntPoint mChromeOffset;
760 ScreenIntCoord mDynamicToolbarMaxHeight;
761 TabId mUniqueId;
763 bool mDidFakeShow : 1;
764 bool mTriedBrowserInit : 1;
765 bool mIgnoreKeyPressEvent : 1;
766 bool mHasValidInnerSize : 1;
767 bool mDestroyed : 1;
769 // Whether or not this browser is the child part of the top level PBrowser
770 // actor in a remote browser.
771 bool mIsTopLevel : 1;
773 bool mIsTransparent : 1;
774 bool mIPCOpen : 1;
776 bool mDidSetRealShowInfo : 1;
777 bool mDidLoadURLInit : 1;
779 bool mSkipKeyPress : 1;
781 bool mCoalesceMouseMoveEvents : 1;
783 bool mShouldSendWebProgressEventsToParent : 1;
785 // Whether we are rendering to the compositor or not.
786 bool mRenderLayers : 1;
788 // Whether we're artificially preserving layers.
789 bool mIsPreservingLayers : 1;
791 // Holds the compositor options for the compositor rendering this tab,
792 // once we find out which compositor that is.
793 Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
795 friend class ContentChild;
797 CSSSize mUnscaledInnerSize;
799 // Store the end time of the handling of the last repeated
800 // keydown/keypress event so that in case event handling takes time, some
801 // repeated events can be skipped to not flood child process.
802 mozilla::TimeStamp mRepeatedKeyEventTime;
804 // Similar to mRepeatedKeyEventTime, store the end time (from parent
805 // process) of handling the last repeated wheel event so that in case
806 // event handling takes time, some repeated events can be skipped to not
807 // flood child process.
808 mozilla::TimeStamp mLastWheelProcessedTimeFromParent;
809 mozilla::TimeDuration mLastWheelProcessingDuration;
811 // Hash table to track coalesced mousemove events for different pointers.
812 nsClassHashtable<nsUint32HashKey, CoalescedMouseData> mCoalescedMouseData;
814 nsDeque<CoalescedMouseData> mToBeDispatchedMouseData;
816 CoalescedWheelData mCoalescedWheelData;
817 CoalescedTouchData mCoalescedTouchData;
819 RefPtr<CoalescedMouseMoveFlusher> mCoalescedMouseEventFlusher;
820 RefPtr<CoalescedTouchMoveFlusher> mCoalescedTouchMoveEventFlusher;
822 RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
823 RefPtr<SessionStoreChild> mSessionStoreChild;
825 #if defined(XP_WIN) && defined(ACCESSIBILITY)
826 // The handle associated with the native window that contains this tab
827 uintptr_t mNativeWindowHandle;
828 #endif // defined(XP_WIN)
830 int32_t mCancelContentJSEpoch;
832 Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
833 // When mChildToParentConversionMatrix is Nothing() this value is invalid.
834 ScreenRect mTopLevelViewportVisibleRectInBrowserCoords;
836 #ifdef XP_WIN
837 // Should only be accessed on main thread.
838 Maybe<bool> mWindowSupportsProtectedMedia;
839 #endif
841 // If set, resolve when we receive ChildToParentMatrix.
842 RefPtr<dom::Promise> mContentTransformPromise;
844 DISALLOW_EVIL_CONSTRUCTORS(BrowserChild);
847 } // namespace dom
848 } // namespace mozilla
850 #endif // mozilla_dom_BrowserChild_h