LCOV - code coverage report
Current view: top level - dom/ipc - TabChild.h (source / functions) Hit Total Coverage
Test: output.info Lines: 30 72 41.7 %
Date: 2017-07-14 16:53:18 Functions: 18 56 32.1 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       6             : 
       7             : #ifndef mozilla_dom_TabChild_h
       8             : #define mozilla_dom_TabChild_h
       9             : 
      10             : #include "mozilla/dom/PBrowserChild.h"
      11             : #include "nsIWebNavigation.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "nsAutoPtr.h"
      14             : #include "nsIWebBrowserChrome2.h"
      15             : #include "nsIEmbeddingSiteWindow.h"
      16             : #include "nsIWebBrowserChromeFocus.h"
      17             : #include "nsIDOMEventListener.h"
      18             : #include "nsIInterfaceRequestor.h"
      19             : #include "nsIWindowProvider.h"
      20             : #include "nsIDOMWindow.h"
      21             : #include "nsIDocShell.h"
      22             : #include "nsIInterfaceRequestorUtils.h"
      23             : #include "nsFrameMessageManager.h"
      24             : #include "nsIPresShell.h"
      25             : #include "nsIScriptObjectPrincipal.h"
      26             : #include "nsWeakReference.h"
      27             : #include "nsITabChild.h"
      28             : #include "nsITooltipListener.h"
      29             : #include "mozilla/Attributes.h"
      30             : #include "mozilla/dom/TabContext.h"
      31             : #include "mozilla/dom/CoalescedWheelData.h"
      32             : #include "mozilla/DOMEventTargetHelper.h"
      33             : #include "mozilla/EventDispatcher.h"
      34             : #include "mozilla/EventForwards.h"
      35             : #include "mozilla/layers/CompositorTypes.h"
      36             : #include "mozilla/layers/APZCCallbackHelper.h"
      37             : #include "mozilla/layers/CompositorOptions.h"
      38             : #include "nsIWebBrowserChrome3.h"
      39             : #include "mozilla/dom/ipc/IdType.h"
      40             : #include "AudioChannelService.h"
      41             : #include "PuppetWidget.h"
      42             : #include "mozilla/layers/GeckoContentController.h"
      43             : #include "nsISHistoryListener.h"
      44             : #include "nsIPartialSHistoryListener.h"
      45             : 
      46             : class nsIDOMWindowUtils;
      47             : class nsIHttpChannel;
      48             : class nsISerialEventTarget;
      49             : 
      50             : namespace mozilla {
      51             : class AbstractThread;
      52             : namespace layout {
      53             : class RenderFrameChild;
      54             : } // namespace layout
      55             : 
      56             : namespace layers {
      57             : class APZChild;
      58             : class APZEventState;
      59             : class AsyncDragMetrics;
      60             : class IAPZCTreeManager;
      61             : class ImageCompositeNotification;
      62             : } // namespace layers
      63             : 
      64             : namespace widget {
      65             : struct AutoCacheNativeKeyCommands;
      66             : } // namespace widget
      67             : 
      68             : namespace dom {
      69             : 
      70             : class TabChild;
      71             : class TabGroup;
      72             : class ClonedMessageData;
      73             : class CoalescedWheelData;
      74             : 
      75             : class TabChildGlobal : public DOMEventTargetHelper,
      76             :                        public nsIContentFrameMessageManager,
      77             :                        public nsIScriptObjectPrincipal,
      78             :                        public nsIGlobalObject,
      79             :                        public nsSupportsWeakReference
      80             : {
      81             : public:
      82             :   explicit TabChildGlobal(TabChild* aTabChild);
      83             :   void Init();
      84             :   NS_DECL_ISUPPORTS_INHERITED
      85           1 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper)
      86         102 :   NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
      87          30 :   NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
      88           0 :   NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
      89           0 :   NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
      90             :                              JS::Handle<JS::Value> aObject,
      91             :                              JS::Handle<JS::Value> aRemote,
      92             :                              nsIPrincipal* aPrincipal,
      93             :                              JSContext* aCx,
      94             :                              uint8_t aArgc,
      95             :                              JS::MutableHandle<JS::Value> aRetval) override
      96             :   {
      97             :     return mMessageManager
      98           0 :       ? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
      99           0 :                                          aPrincipal, aCx, aArgc, aRetval)
     100           0 :       : NS_ERROR_NULL_POINTER;
     101             :   }
     102           0 :   NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
     103             :                             JS::Handle<JS::Value> aObject,
     104             :                             JS::Handle<JS::Value> aRemote,
     105             :                             nsIPrincipal* aPrincipal,
     106             :                             JSContext* aCx,
     107             :                             uint8_t aArgc,
     108             :                             JS::MutableHandle<JS::Value> aRetval) override
     109             :   {
     110             :     return mMessageManager
     111           0 :       ? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
     112           0 :                                         aPrincipal, aCx, aArgc, aRetval)
     113           0 :       : NS_ERROR_NULL_POINTER;
     114             :   }
     115             :   NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
     116             :   NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
     117             : 
     118             :   nsresult AddEventListener(const nsAString& aType,
     119             :                             nsIDOMEventListener* aListener,
     120             :                             bool aUseCapture)
     121             :   {
     122             :     // By default add listeners only for trusted events!
     123             :     return DOMEventTargetHelper::AddEventListener(aType, aListener,
     124             :                                                   aUseCapture, false, 2);
     125             :   }
     126             :   using DOMEventTargetHelper::AddEventListener;
     127          96 :   NS_IMETHOD AddEventListener(const nsAString& aType,
     128             :                               nsIDOMEventListener* aListener,
     129             :                               bool aUseCapture, bool aWantsUntrusted,
     130             :                               uint8_t optional_argc) override
     131             :   {
     132          96 :     return DOMEventTargetHelper::AddEventListener(aType, aListener,
     133             :                                                   aUseCapture,
     134             :                                                   aWantsUntrusted,
     135          96 :                                                   optional_argc);
     136             :   }
     137             : 
     138             :   nsresult
     139          44 :   GetEventTargetParent(EventChainPreVisitor& aVisitor) override
     140             :   {
     141          44 :     aVisitor.mForceContentDispatch = true;
     142          44 :     return NS_OK;
     143             :   }
     144             : 
     145             :   virtual nsIPrincipal* GetPrincipal() override;
     146             :   virtual JSObject* GetGlobalJSObject() override;
     147             : 
     148           0 :   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
     149             :   {
     150           0 :     MOZ_CRASH("TabChildGlobal doesn't use DOM bindings!");
     151             :   }
     152             : 
     153             :   // Dispatch a runnable related to the global.
     154             :   virtual nsresult Dispatch(const char* aName,
     155             :                             mozilla::TaskCategory aCategory,
     156             :                             already_AddRefed<nsIRunnable>&& aRunnable) override;
     157             : 
     158             :   virtual nsISerialEventTarget*
     159             :   EventTargetFor(mozilla::TaskCategory aCategory) const override;
     160             : 
     161             :   virtual AbstractThread*
     162             :   AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
     163             : 
     164             :   nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
     165             :   RefPtr<TabChild> mTabChild;
     166             : 
     167             : protected:
     168             :   ~TabChildGlobal();
     169             : };
     170             : 
     171             : class ContentListener final : public nsIDOMEventListener
     172             : {
     173             : public:
     174           0 :   explicit ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
     175             :   NS_DECL_ISUPPORTS
     176             :   NS_DECL_NSIDOMEVENTLISTENER
     177             : protected:
     178           0 :   ~ContentListener() {}
     179             :   TabChild* mTabChild;
     180             : };
     181             : 
     182             : /**
     183             :  * Listens on session history change, and sends NotifySessionHistoryChange to
     184             :  * parent process.
     185             :  */
     186             : class TabChildSHistoryListener final : public nsISHistoryListener,
     187             :                                        public nsIPartialSHistoryListener,
     188             :                                        public nsSupportsWeakReference
     189             : {
     190             : public:
     191           0 :   explicit TabChildSHistoryListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
     192           0 :   void ClearTabChild() { mTabChild = nullptr; }
     193             : 
     194             :   NS_DECL_ISUPPORTS
     195             :   NS_DECL_NSISHISTORYLISTENER
     196             :   NS_DECL_NSIPARTIALSHISTORYLISTENER
     197             : 
     198             : private:
     199             :   nsresult SHistoryDidUpdate(bool aTruncate = false);
     200             : 
     201           0 :   ~TabChildSHistoryListener() {}
     202             :   TabChild* mTabChild;
     203             : };
     204             : 
     205             : // This is base clase which helps to share Viewport and touch related
     206             : // functionality between b2g/android FF/embedlite clients implementation.
     207             : // It make sense to place in this class all helper functions, and functionality
     208             : // which could be shared between Cross-process/Cross-thread implmentations.
     209             : class TabChildBase : public nsISupports,
     210             :                      public nsMessageManagerScriptExecutor,
     211             :                      public ipc::MessageManagerCallback
     212             : {
     213             : protected:
     214             :   typedef mozilla::widget::PuppetWidget PuppetWidget;
     215             : 
     216             : public:
     217             :   TabChildBase();
     218             : 
     219             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     220         410 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase)
     221             : 
     222             :   virtual nsIWebNavigation* WebNavigation() const = 0;
     223             :   virtual PuppetWidget* WebWidget() = 0;
     224           0 :   nsIPrincipal* GetPrincipal() { return mPrincipal; }
     225             :   virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
     226             :                                        const mozilla::layers::FrameMetrics::ViewID& aViewId,
     227             :                                        const Maybe<mozilla::layers::ZoomConstraints>& aConstraints) = 0;
     228             : 
     229             :   virtual ScreenIntSize GetInnerSize() = 0;
     230             : 
     231             :   // Get the Document for the top-level window in this tab.
     232             :   already_AddRefed<nsIDocument> GetDocument() const;
     233             : 
     234             :   // Get the pres-shell of the document for the top-level window in this tab.
     235             :   already_AddRefed<nsIPresShell> GetPresShell() const;
     236             : 
     237             : protected:
     238             :   virtual ~TabChildBase();
     239             : 
     240             :   // Wraps up a JSON object as a structured clone and sends it to the browser
     241             :   // chrome script.
     242             :   //
     243             :   // XXX/bug 780335: Do the work the browser chrome script does in C++ instead
     244             :   // so we don't need things like this.
     245             :   void DispatchMessageManagerMessage(const nsAString& aMessageName,
     246             :                                      const nsAString& aJSONData);
     247             : 
     248             :   void ProcessUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics);
     249             : 
     250             :   bool UpdateFrameHandler(const mozilla::layers::FrameMetrics& aFrameMetrics);
     251             : 
     252             : protected:
     253             :   RefPtr<TabChildGlobal> mTabChildGlobal;
     254             :   nsCOMPtr<nsIWebBrowserChrome3> mWebBrowserChrome;
     255             : };
     256             : 
     257             : class TabChild final : public TabChildBase,
     258             :                        public PBrowserChild,
     259             :                        public nsIWebBrowserChrome2,
     260             :                        public nsIEmbeddingSiteWindow,
     261             :                        public nsIWebBrowserChromeFocus,
     262             :                        public nsIInterfaceRequestor,
     263             :                        public nsIWindowProvider,
     264             :                        public nsSupportsWeakReference,
     265             :                        public nsITabChild,
     266             :                        public nsIObserver,
     267             :                        public TabContext,
     268             :                        public nsITooltipListener,
     269             :                        public mozilla::ipc::IShmemAllocator
     270             : {
     271             :   typedef mozilla::dom::ClonedMessageData ClonedMessageData;
     272             :   typedef mozilla::dom::CoalescedWheelData CoalescedWheelData;
     273             :   typedef mozilla::layout::RenderFrameChild RenderFrameChild;
     274             :   typedef mozilla::layers::APZEventState APZEventState;
     275             :   typedef mozilla::layers::SetAllowedTouchBehaviorCallback SetAllowedTouchBehaviorCallback;
     276             : 
     277             : public:
     278             :   /**
     279             :    * Find TabChild of aTabId in the same content process of the
     280             :    * caller.
     281             :    */
     282             :   static already_AddRefed<TabChild> FindTabChild(const TabId& aTabId);
     283             : 
     284             :   // Return a list of all active TabChildren.
     285             :   static nsTArray<RefPtr<TabChild>> GetAll();
     286             : 
     287             : public:
     288             :   /**
     289             :    * Create a new TabChild object.
     290             :    */
     291             :   TabChild(nsIContentChild* aManager,
     292             :            const TabId& aTabId,
     293             :            TabGroup* aTabGroup,
     294             :            const TabContext& aContext,
     295             :            uint32_t aChromeFlags);
     296             : 
     297             :   nsresult Init();
     298             : 
     299             :   /** Return a TabChild with the given attributes. */
     300             :   static already_AddRefed<TabChild>
     301             :   Create(nsIContentChild* aManager, const TabId& aTabId,
     302             :          const TabId& aSameTabGroupAs,
     303             :          const TabContext& aContext, uint32_t aChromeFlags);
     304             : 
     305             :   // Let managees query if it is safe to send messages.
     306           0 :   bool IsDestroyed() const{ return mDestroyed; }
     307             : 
     308           0 :   const TabId GetTabId() const
     309             :   {
     310           0 :     MOZ_ASSERT(mUniqueId != 0);
     311           0 :     return mUniqueId;
     312             :   }
     313             : 
     314             :   NS_DECL_ISUPPORTS_INHERITED
     315             :   NS_DECL_NSIWEBBROWSERCHROME
     316             :   NS_DECL_NSIWEBBROWSERCHROME2
     317             :   NS_DECL_NSIEMBEDDINGSITEWINDOW
     318             :   NS_DECL_NSIWEBBROWSERCHROMEFOCUS
     319             :   NS_DECL_NSIINTERFACEREQUESTOR
     320             :   NS_DECL_NSIWINDOWPROVIDER
     321             :   NS_DECL_NSITABCHILD
     322             :   NS_DECL_NSIOBSERVER
     323             :   NS_DECL_NSITOOLTIPLISTENER
     324             : 
     325           0 :   FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild)
     326             : 
     327             :   /**
     328             :    * MessageManagerCallback methods that we override.
     329             :    */
     330             :   virtual bool DoSendBlockingMessage(JSContext* aCx,
     331             :                                      const nsAString& aMessage,
     332             :                                      StructuredCloneData& aData,
     333             :                                      JS::Handle<JSObject *> aCpows,
     334             :                                      nsIPrincipal* aPrincipal,
     335             :                                      nsTArray<StructuredCloneData>* aRetVal,
     336             :                                      bool aIsSync) override;
     337             : 
     338             :   virtual nsresult DoSendAsyncMessage(JSContext* aCx,
     339             :                                       const nsAString& aMessage,
     340             :                                       StructuredCloneData& aData,
     341             :                                       JS::Handle<JSObject *> aCpows,
     342             :                                       nsIPrincipal* aPrincipal) override;
     343             : 
     344             :   virtual bool
     345             :   DoUpdateZoomConstraints(const uint32_t& aPresShellId,
     346             :                           const ViewID& aViewId,
     347             :                           const Maybe<ZoomConstraints>& aConstraints) override;
     348             : 
     349             :   virtual mozilla::ipc::IPCResult RecvLoadURL(const nsCString& aURI,
     350             :                                               const ShowInfo& aInfo) override;
     351             :   virtual mozilla::ipc::IPCResult
     352             :   RecvShow(const ScreenIntSize& aSize,
     353             :            const ShowInfo& aInfo,
     354             :            const bool& aParentIsActive,
     355             :            const nsSizeMode& aSizeMode) override;
     356             : 
     357             :   virtual mozilla::ipc::IPCResult
     358             :   RecvInitRendering(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
     359             :                     const uint64_t& aLayersId,
     360             :                     const mozilla::layers::CompositorOptions& aCompositorOptions,
     361             :                     const bool& aLayersConnected,
     362             :                     PRenderFrameChild* aRenderFrame) override;
     363             : 
     364             :   virtual mozilla::ipc::IPCResult
     365             :   RecvUpdateDimensions(const mozilla::dom::DimensionInfo& aDimensionInfo) override;
     366             :   virtual mozilla::ipc::IPCResult
     367             :   RecvSizeModeChanged(const nsSizeMode& aSizeMode) override;
     368             : 
     369             :   mozilla::ipc::IPCResult RecvActivate();
     370             : 
     371             :   mozilla::ipc::IPCResult RecvDeactivate();
     372             : 
     373             :   mozilla::ipc::IPCResult RecvParentActivated(const bool& aActivated);
     374             : 
     375             :   virtual mozilla::ipc::IPCResult RecvMouseEvent(const nsString& aType,
     376             :                                                  const float& aX,
     377             :                                                  const float& aY,
     378             :                                                  const int32_t& aButton,
     379             :                                                  const int32_t& aClickCount,
     380             :                                                  const int32_t& aModifiers,
     381             :                                                  const bool& aIgnoreRootScrollFrame) override;
     382             : 
     383             :   virtual mozilla::ipc::IPCResult RecvRealMouseMoveEvent(const mozilla::WidgetMouseEvent& aEvent,
     384             :                                                          const ScrollableLayerGuid& aGuid,
     385             :                                                          const uint64_t& aInputBlockId) override;
     386             : 
     387             :   virtual mozilla::ipc::IPCResult RecvSynthMouseMoveEvent(const mozilla::WidgetMouseEvent& aEvent,
     388             :                                                           const ScrollableLayerGuid& aGuid,
     389             :                                                           const uint64_t& aInputBlockId) override;
     390             : 
     391             :   virtual mozilla::ipc::IPCResult RecvRealMouseButtonEvent(const mozilla::WidgetMouseEvent& aEvent,
     392             :                                                            const ScrollableLayerGuid& aGuid,
     393             :                                                            const uint64_t& aInputBlockId) override;
     394             : 
     395             :   virtual mozilla::ipc::IPCResult RecvRealDragEvent(const WidgetDragEvent& aEvent,
     396             :                                                     const uint32_t& aDragAction,
     397             :                                                     const uint32_t& aDropEffect) override;
     398             : 
     399             :   virtual mozilla::ipc::IPCResult
     400             :   RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& aEvent) override;
     401             : 
     402             :   virtual mozilla::ipc::IPCResult RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& aEvent,
     403             :                                                       const ScrollableLayerGuid& aGuid,
     404             :                                                       const uint64_t& aInputBlockId) override;
     405             : 
     406             :   virtual mozilla::ipc::IPCResult RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
     407             :                                                      const ScrollableLayerGuid& aGuid,
     408             :                                                      const uint64_t& aInputBlockId,
     409             :                                                      const nsEventStatus& aApzResponse) override;
     410             : 
     411             :   virtual mozilla::ipc::IPCResult
     412             :   RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent,
     413             :                          const ScrollableLayerGuid& aGuid,
     414             :                          const uint64_t& aInputBlockId,
     415             :                          const nsEventStatus& aApzResponse) override;
     416             : 
     417             :   virtual mozilla::ipc::IPCResult RecvKeyEvent(const nsString& aType,
     418             :                                                const int32_t& aKeyCode,
     419             :                                                const int32_t& aCharCode,
     420             :                                                const int32_t& aModifiers,
     421             :                                                const bool& aPreventDefault) override;
     422             : 
     423             :   virtual mozilla::ipc::IPCResult RecvNativeSynthesisResponse(const uint64_t& aObserverId,
     424             :                                                               const nsCString& aResponse) override;
     425             : 
     426             :   virtual mozilla::ipc::IPCResult RecvPluginEvent(const WidgetPluginEvent& aEvent) override;
     427             : 
     428             :   virtual mozilla::ipc::IPCResult
     429             :   RecvCompositionEvent(const mozilla::WidgetCompositionEvent& aEvent) override;
     430             : 
     431             :   virtual mozilla::ipc::IPCResult
     432             :   RecvSelectionEvent(const mozilla::WidgetSelectionEvent& aEvent) override;
     433             : 
     434             :   virtual mozilla::ipc::IPCResult
     435             :   RecvPasteTransferable(const IPCDataTransfer& aDataTransfer,
     436             :                         const bool& aIsPrivateData,
     437             :                         const IPC::Principal& aRequestingPrincipal) override;
     438             : 
     439             :   virtual mozilla::ipc::IPCResult
     440             :   RecvActivateFrameEvent(const nsString& aType, const bool& aCapture) override;
     441             : 
     442             :   virtual mozilla::ipc::IPCResult RecvLoadRemoteScript(const nsString& aURL,
     443             :                                                        const bool& aRunInGlobalScope) override;
     444             : 
     445             :   virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMessage,
     446             :                                                    InfallibleTArray<CpowEntry>&& aCpows,
     447             :                                                    const IPC::Principal& aPrincipal,
     448             :                                                    const ClonedMessageData& aData) override;
     449             : 
     450             :   virtual mozilla::ipc::IPCResult
     451             :   RecvSwappedWithOtherRemoteLoader(const IPCTabContext& aContext) override;
     452             : 
     453             :   virtual PDocAccessibleChild*
     454             :   AllocPDocAccessibleChild(PDocAccessibleChild*, const uint64_t&,
     455             :                            const uint32_t&, const IAccessibleHolder&) override;
     456             : 
     457             :   virtual bool DeallocPDocAccessibleChild(PDocAccessibleChild*) override;
     458             : 
     459             :   virtual PDocumentRendererChild*
     460             :   AllocPDocumentRendererChild(const nsRect& aDocumentRect,
     461             :                               const gfx::Matrix& aTransform,
     462             :                               const nsString& aBggcolor,
     463             :                               const uint32_t& aRenderFlags,
     464             :                               const bool& aFlushLayout,
     465             :                               const nsIntSize& arenderSize) override;
     466             : 
     467             :   virtual bool
     468             :   DeallocPDocumentRendererChild(PDocumentRendererChild* aCctor) override;
     469             : 
     470             :   virtual mozilla::ipc::IPCResult
     471             :   RecvPDocumentRendererConstructor(PDocumentRendererChild* aActor,
     472             :                                    const nsRect& aDocumentRect,
     473             :                                    const gfx::Matrix& aTransform,
     474             :                                    const nsString& aBgcolor,
     475             :                                    const uint32_t& aRenderFlags,
     476             :                                    const bool& aFlushLayout,
     477             :                                    const nsIntSize& aRenderSize) override;
     478             : 
     479             : 
     480             :   virtual PColorPickerChild*
     481             :   AllocPColorPickerChild(const nsString& aTitle,
     482             :                          const nsString& aInitialColor) override;
     483             : 
     484             :   virtual bool DeallocPColorPickerChild(PColorPickerChild* aActor) override;
     485             : 
     486             :   virtual PFilePickerChild*
     487             :   AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) override;
     488             : 
     489             :   virtual bool
     490             :   DeallocPFilePickerChild(PFilePickerChild* aActor) override;
     491             : 
     492             :   virtual PIndexedDBPermissionRequestChild*
     493             :   AllocPIndexedDBPermissionRequestChild(const Principal& aPrincipal) override;
     494             : 
     495             :   virtual bool
     496             :   DeallocPIndexedDBPermissionRequestChild(PIndexedDBPermissionRequestChild* aActor) override;
     497             : 
     498         155 :   virtual nsIWebNavigation* WebNavigation() const override
     499             :   {
     500         155 :     return mWebNav;
     501             :   }
     502             : 
     503           0 :   virtual PuppetWidget* WebWidget() override { return mPuppetWidget; }
     504             : 
     505             :   /** Return the DPI of the widget this TabChild draws to. */
     506             :   void GetDPI(float* aDPI);
     507             : 
     508             :   void GetDefaultScale(double *aScale);
     509             : 
     510             :   void GetWidgetRounding(int32_t* aRounding);
     511             : 
     512           2 :   bool IsTransparent() const { return mIsTransparent; }
     513             : 
     514           0 :   void GetMaxTouchPoints(uint32_t* aTouchPoints)
     515             :   {
     516           0 :     *aTouchPoints = mMaxTouchPoints;
     517           0 :   }
     518             : 
     519           0 :   void SetMaxTouchPoints(uint32_t aMaxTouchPoints)
     520             :   {
     521           0 :     mMaxTouchPoints = aMaxTouchPoints;
     522           0 :   }
     523             : 
     524           4 :   ScreenOrientationInternal GetOrientation() const { return mOrientation; }
     525             : 
     526             :   void SetBackgroundColor(const nscolor& aColor);
     527             : 
     528             :   void NotifyPainted();
     529             : 
     530             :   void RequestEditCommands(nsIWidget::NativeKeyBindingsType aType,
     531             :                            const WidgetKeyboardEvent& aEvent,
     532             :                            nsTArray<CommandInt>& aCommands);
     533             : 
     534             :   /**
     535             :    * Signal to this TabChild that it should be made visible:
     536             :    * activated widget, retained layer tree, etc.  (Respectively,
     537             :    * made not visible.)
     538             :    */
     539             :   void MakeVisible();
     540             :   void MakeHidden();
     541             : 
     542          53 :   nsIContentChild* Manager() const { return mManager; }
     543             : 
     544             :   static inline TabChild*
     545          10 :   GetFrom(nsIDocShell* aDocShell)
     546             :   {
     547          10 :     if (!aDocShell) {
     548           0 :       return nullptr;
     549             :     }
     550             : 
     551          20 :     nsCOMPtr<nsITabChild> tc = aDocShell->GetTabChild();
     552          10 :     return static_cast<TabChild*>(tc.get());
     553             :   }
     554             : 
     555             :   static inline TabChild*
     556           0 :   GetFrom(mozIDOMWindow* aWindow)
     557             :   {
     558           0 :     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     559           0 :     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     560           0 :     return GetFrom(docShell);
     561             :   }
     562             : 
     563             :   static inline TabChild*
     564           7 :   GetFrom(mozIDOMWindowProxy* aWindow)
     565             :   {
     566          14 :     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     567          14 :     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     568          14 :     return GetFrom(docShell);
     569             :   }
     570             : 
     571             :   static TabChild* GetFrom(nsIPresShell* aPresShell);
     572             :   static TabChild* GetFrom(uint64_t aLayersId);
     573             : 
     574           0 :   uint64_t LayersId() { return mLayersId; }
     575           1 :   bool IsLayersConnected() { return mLayersConnected; }
     576             : 
     577             :   void DidComposite(uint64_t aTransactionId,
     578             :                     const TimeStamp& aCompositeStart,
     579             :                     const TimeStamp& aCompositeEnd);
     580             : 
     581             :   void DidRequestComposite(const TimeStamp& aCompositeReqStart,
     582             :                            const TimeStamp& aCompositeReqEnd);
     583             : 
     584             :   void ClearCachedResources();
     585             :   void InvalidateLayers();
     586             :   void ReinitRendering();
     587             :   void ReinitRenderingForDeviceReset();
     588             :   void CompositorUpdated(const TextureFactoryIdentifier& aNewIdentifier,
     589             :                          uint64_t aDeviceResetSeqNo);
     590             : 
     591             :   static inline TabChild* GetFrom(nsIDOMWindow* aWindow)
     592             :   {
     593             :     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     594             :     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     595             :     return GetFrom(docShell);
     596             :   }
     597             : 
     598             :   virtual mozilla::ipc::IPCResult RecvUIResolutionChanged(const float& aDpi,
     599             :                                                           const int32_t& aRounding,
     600             :                                                           const double& aScale) override;
     601             : 
     602             :   virtual mozilla::ipc::IPCResult
     603             :   RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;
     604             : 
     605             :   virtual mozilla::ipc::IPCResult RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
     606             :                                                       nsTArray<uint32_t>&& aCharCodes,
     607             :                                                       const int32_t& aModifierMask) override;
     608             : 
     609             :   virtual mozilla::ipc::IPCResult RecvSetUseGlobalHistory(const bool& aUse) override;
     610             : 
     611             :   virtual mozilla::ipc::IPCResult RecvHandledWindowedPluginKeyEvent(
     612             :     const mozilla::NativeEventData& aKeyEventData,
     613             :     const bool& aIsConsumed) override;
     614             : 
     615             :   virtual mozilla::ipc::IPCResult RecvPrint(const uint64_t& aOuterWindowID,
     616             :                                             const PrintData& aPrintData) override;
     617             : 
     618             :   virtual mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle) override;
     619             : 
     620             :   /**
     621             :    * Native widget remoting protocol for use with windowed plugins with e10s.
     622             :    */
     623             :   PPluginWidgetChild* AllocPPluginWidgetChild() override;
     624             : 
     625             :   bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override;
     626             : 
     627             : #ifdef XP_WIN
     628             :   nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut);
     629             : #endif
     630             : 
     631             :   virtual PPaymentRequestChild*
     632             :   AllocPPaymentRequestChild() override;
     633             : 
     634             :   virtual bool
     635             :   DeallocPPaymentRequestChild(PPaymentRequestChild* aActor) override;
     636             : 
     637           0 :   LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
     638           0 :   LayoutDeviceIntPoint GetChromeDisplacement() const { return mChromeDisp; };
     639             : 
     640           6 :   bool IPCOpen() const { return mIPCOpen; }
     641             : 
     642           1 :   bool ParentIsActive() const
     643             :   {
     644           1 :     return mParentIsActive;
     645             :   }
     646             : 
     647             :   bool AsyncPanZoomEnabled() const;
     648             : 
     649             :   virtual ScreenIntSize GetInnerSize() override;
     650             : 
     651             :   // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
     652             :   void DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
     653             :                   const uint64_t& aLayersId,
     654             :                   const mozilla::layers::CompositorOptions& aCompositorOptions,
     655             :                   PRenderFrameChild* aRenderFrame,
     656             :                   const ShowInfo& aShowInfo);
     657             : 
     658             :   void ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
     659             :                                  uint64_t aInputBlockId,
     660             :                                  bool aPreventDefault) const;
     661             :   void SetTargetAPZC(uint64_t aInputBlockId,
     662             :                     const nsTArray<ScrollableLayerGuid>& aTargets) const;
     663             :   mozilla::ipc::IPCResult RecvHandleTap(const layers::GeckoContentController::TapType& aType,
     664             :                                         const LayoutDevicePoint& aPoint,
     665             :                                         const Modifiers& aModifiers,
     666             :                                         const ScrollableLayerGuid& aGuid,
     667             :                                         const uint64_t& aInputBlockId) override;
     668             :   void SetAllowedTouchBehavior(uint64_t aInputBlockId,
     669             :                                const nsTArray<TouchBehaviorFlags>& aFlags) const;
     670             : 
     671             :   bool UpdateFrame(const FrameMetrics& aFrameMetrics);
     672             :   bool NotifyAPZStateChange(const ViewID& aViewId,
     673             :                             const layers::GeckoContentController::APZStateChange& aChange,
     674             :                             const int& aArg);
     675             :   void StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics);
     676             :   void ZoomToRect(const uint32_t& aPresShellId,
     677             :                   const FrameMetrics::ViewID& aViewId,
     678             :                   const CSSRect& aRect,
     679             :                   const uint32_t& aFlags);
     680             : 
     681             :   // Request that the docshell be marked as active.
     682             :   void ForcePaint(uint64_t aLayerObserverEpoch);
     683             : 
     684             : #if defined(XP_WIN) && defined(ACCESSIBILITY)
     685             :   uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
     686             : #endif
     687             : 
     688             :   // These methods return `true` if this TabChild is currently awaiting a
     689             :   // Large-Allocation header.
     690             :   bool StopAwaitingLargeAlloc();
     691             :   bool IsAwaitingLargeAlloc();
     692             : 
     693             :   already_AddRefed<nsISHistory> GetRelatedSHistory();
     694             : 
     695             :   mozilla::dom::TabGroup* TabGroup();
     696             : 
     697             : #if defined(ACCESSIBILITY)
     698           0 :   void SetTopLevelDocAccessibleChild(PDocAccessibleChild* aTopLevelChild)
     699             :   {
     700           0 :     mTopLevelDocAccessibleChild = aTopLevelChild;
     701           0 :   }
     702             : 
     703             :   PDocAccessibleChild* GetTopLevelDocAccessibleChild()
     704             :   {
     705             :     return mTopLevelDocAccessibleChild;
     706             :   }
     707             : #endif
     708             : 
     709             :   void AddPendingDocShellBlocker();
     710             :   void RemovePendingDocShellBlocker();
     711             : 
     712             :   // The HANDLE object for the widget this TabChild in.
     713           0 :   WindowsHandle WidgetNativeData()
     714             :   {
     715           0 :     return mWidgetNativeData;
     716             :   }
     717             : 
     718             : protected:
     719             :   virtual ~TabChild();
     720             : 
     721             :   virtual PRenderFrameChild* AllocPRenderFrameChild() override;
     722             : 
     723             :   virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) override;
     724             : 
     725             :   virtual mozilla::ipc::IPCResult RecvDestroy() override;
     726             : 
     727             :   virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive,
     728             :                                                           const bool& aIsHidden,
     729             :                                                           const uint64_t& aLayerObserverEpoch) override;
     730             : 
     731             :   virtual mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
     732             :                                                     const bool& aForDocumentNavigation) override;
     733             : 
     734             :   virtual mozilla::ipc::IPCResult RecvRequestNotifyAfterRemotePaint() override;
     735             : 
     736             :   virtual mozilla::ipc::IPCResult RecvSuppressDisplayport(const bool& aEnabled) override;
     737             : 
     738             :   virtual mozilla::ipc::IPCResult RecvSetKeyboardIndicators(const UIStateChangeType& aShowAccelerators,
     739             :                                                             const UIStateChangeType& aShowFocusRings) override;
     740             : 
     741             :   virtual mozilla::ipc::IPCResult RecvStopIMEStateManagement() override;
     742             : 
     743             :   virtual mozilla::ipc::IPCResult RecvMenuKeyboardListenerInstalled(
     744             :     const bool& aInstalled) override;
     745             : 
     746             :   virtual mozilla::ipc::IPCResult RecvNotifyAttachGroupedSHistory(const uint32_t& aOffset) override;
     747             : 
     748             :   virtual mozilla::ipc::IPCResult RecvNotifyPartialSHistoryActive(const uint32_t& aGlobalLength,
     749             :                                                                   const uint32_t& aTargetLocalIndex) override;
     750             : 
     751             :   virtual mozilla::ipc::IPCResult RecvNotifyPartialSHistoryDeactive() override;
     752             : 
     753             :   virtual mozilla::ipc::IPCResult RecvAwaitLargeAlloc() override;
     754             : 
     755             :   virtual mozilla::ipc::IPCResult RecvSetWindowName(const nsString& aName) override;
     756             : 
     757             :   virtual mozilla::ipc::IPCResult RecvSetOriginAttributes(const OriginAttributes& aOriginAttributes) override;
     758             : 
     759             :   virtual mozilla::ipc::IPCResult RecvSetWidgetNativeData(const WindowsHandle& aWidgetNativeData) override;
     760             : 
     761             : private:
     762             :   void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
     763             :                        const ScrollableLayerGuid& aGuid);
     764             : 
     765             :   // Notify others that our TabContext has been updated.
     766             :   //
     767             :   // You should call this after calling TabContext::SetTabContext().  We also
     768             :   // call this during Init().
     769             :   //
     770             :   // @param aIsPreallocated  true if this is called for Preallocated Tab.
     771             :   void NotifyTabContextUpdated(bool aIsPreallocated);
     772             : 
     773             :   // Update the frameType on our docshell.
     774             :   void UpdateFrameType();
     775             : 
     776             :   void ActorDestroy(ActorDestroyReason why) override;
     777             : 
     778             :   bool InitTabChildGlobal();
     779             : 
     780             :   void InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
     781             :                           const uint64_t& aLayersId,
     782             :                           const mozilla::layers::CompositorOptions& aCompositorOptions,
     783             :                           PRenderFrameChild* aRenderFrame);
     784             :   void InitAPZState();
     785             : 
     786             :   void DestroyWindow();
     787             : 
     788             :   void ApplyShowInfo(const ShowInfo& aInfo);
     789             : 
     790             :   bool HasValidInnerSize();
     791             : 
     792             :   void SetTabId(const TabId& aTabId);
     793             : 
     794             :   ScreenIntRect GetOuterRect();
     795             : 
     796           3 :   void SetUnscaledInnerSize(const CSSSize& aSize)
     797             :   {
     798           3 :     mUnscaledInnerSize = aSize;
     799           3 :   }
     800             : 
     801             :   bool SkipRepeatedKeyEvent(const WidgetKeyboardEvent& aEvent);
     802             : 
     803             :   void UpdateRepeatedKeyEventEndTime(const WidgetKeyboardEvent& aEvent);
     804             : 
     805             :   bool MaybeCoalesceWheelEvent(const WidgetWheelEvent& aEvent,
     806             :                                const ScrollableLayerGuid& aGuid,
     807             :                                const uint64_t& aInputBlockId,
     808             :                                bool* aIsNextWheelEvent);
     809             : 
     810             :   void MaybeDispatchCoalescedWheelEvent();
     811             : 
     812             :   void DispatchWheelEvent(const WidgetWheelEvent& aEvent,
     813             :                           const ScrollableLayerGuid& aGuid,
     814             :                           const uint64_t& aInputBlockId);
     815             : 
     816             :   void InternalSetDocShellIsActive(bool aIsActive,
     817             :                                    bool aPreserveLayers);
     818             : 
     819             :   class DelayedDeleteRunnable;
     820             : 
     821             :   TextureFactoryIdentifier mTextureFactoryIdentifier;
     822             :   nsCOMPtr<nsIWebNavigation> mWebNav;
     823             :   RefPtr<mozilla::dom::TabGroup> mTabGroup;
     824             :   RefPtr<PuppetWidget> mPuppetWidget;
     825             :   nsCOMPtr<nsIURI> mLastURI;
     826             :   RenderFrameChild* mRemoteFrame;
     827             :   RefPtr<nsIContentChild> mManager;
     828             :   RefPtr<TabChildSHistoryListener> mHistoryListener;
     829             :   uint32_t mChromeFlags;
     830             :   uint32_t mMaxTouchPoints;
     831             :   int32_t mActiveSuppressDisplayport;
     832             :   uint64_t mLayersId;
     833             :   int64_t mBeforeUnloadListeners;
     834             :   CSSRect mUnscaledOuterRect;
     835             :   nscolor mLastBackgroundColor;
     836             :   bool mLayersConnected;
     837             :   bool mDidFakeShow;
     838             :   bool mNotified;
     839             :   bool mTriedBrowserInit;
     840             :   ScreenOrientationInternal mOrientation;
     841             : 
     842             :   bool mIgnoreKeyPressEvent;
     843             :   RefPtr<APZEventState> mAPZEventState;
     844             :   SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback;
     845             :   bool mHasValidInnerSize;
     846             :   bool mDestroyed;
     847             :   // Position of client area relative to the outer window
     848             :   LayoutDeviceIntPoint mClientOffset;
     849             :   // Position of tab, relative to parent widget (typically the window)
     850             :   LayoutDeviceIntPoint mChromeDisp;
     851             :   TabId mUniqueId;
     852             : 
     853             :   // Holds the compositor options for the compositor rendering this tab,
     854             :   // once we find out which compositor that is.
     855             :   Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
     856             : 
     857             :   friend class ContentChild;
     858             :   float mDPI;
     859             :   int32_t mRounding;
     860             :   double mDefaultScale;
     861             : 
     862             :   bool mIsTransparent;
     863             : 
     864             :   bool mIPCOpen;
     865             :   bool mParentIsActive;
     866             :   CSSSize mUnscaledInnerSize;
     867             :   bool mDidSetRealShowInfo;
     868             :   bool mDidLoadURLInit;
     869             :   bool mAwaitingLA;
     870             : 
     871             :   bool mSkipKeyPress;
     872             : 
     873             :   // Store the end time of the handling of the last repeated keydown/keypress
     874             :   // event so that in case event handling takes time, some repeated events can
     875             :   // be skipped to not flood child process.
     876             :   mozilla::TimeStamp mRepeatedKeyEventTime;
     877             : 
     878             :   // Similar to mRepeatedKeyEventTime, store the end time (from parent process)
     879             :   // of handling the last repeated wheel event so that in case event handling
     880             :   // takes time, some repeated events can be skipped to not flood child process.
     881             :   mozilla::TimeStamp mLastWheelProcessedTimeFromParent;
     882             :   mozilla::TimeDuration mLastWheelProcessingDuration;
     883             :   CoalescedWheelData mCoalescedWheelData;
     884             : 
     885             :   RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
     886             : 
     887             :   // The most recently seen layer observer epoch in RecvSetDocShellIsActive.
     888             :   uint64_t mLayerObserverEpoch;
     889             : 
     890             : #if defined(XP_WIN) && defined(ACCESSIBILITY)
     891             :   // The handle associated with the native window that contains this tab
     892             :   uintptr_t mNativeWindowHandle;
     893             : #endif // defined(XP_WIN)
     894             : 
     895             : #if defined(ACCESSIBILITY)
     896             :   PDocAccessibleChild* mTopLevelDocAccessibleChild;
     897             : #endif
     898             : 
     899             :   bool mPendingDocShellIsActive;
     900             :   bool mPendingDocShellPreserveLayers;
     901             :   bool mPendingDocShellReceivedMessage;
     902             :   uint32_t mPendingDocShellBlockers;
     903             : 
     904             :   WindowsHandle mWidgetNativeData;
     905             : 
     906             :   DISALLOW_EVIL_CONSTRUCTORS(TabChild);
     907             : };
     908             : 
     909             : } // namespace dom
     910             : } // namespace mozilla
     911             : 
     912             : #endif // mozilla_dom_TabChild_h

Generated by: LCOV version 1.13