LCOV - code coverage report
Current view: top level - dom/base - nsWindowRoot.h (source / functions) Hit Total Coverage
Test: output.info Lines: 14 15 93.3 %
Date: 2017-07-14 16:53:18 Functions: 7 13 53.8 %
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 nsWindowRoot_h__
       8             : #define nsWindowRoot_h__
       9             : 
      10             : class nsIDOMEvent;
      11             : class nsIGlobalObject;
      12             : 
      13             : #include "mozilla/Attributes.h"
      14             : #include "mozilla/EventListenerManager.h"
      15             : #include "nsIDOMEventTarget.h"
      16             : #include "nsIWeakReferenceUtils.h"
      17             : #include "nsPIWindowRoot.h"
      18             : #include "nsCycleCollectionParticipant.h"
      19             : #include "nsTHashtable.h"
      20             : #include "nsHashKeys.h"
      21             : 
      22             : class nsWindowRoot final : public nsPIWindowRoot
      23             : {
      24             : public:
      25             :   explicit nsWindowRoot(nsPIDOMWindowOuter* aWindow);
      26             : 
      27             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      28             :   NS_DECL_NSIDOMEVENTTARGET
      29             : 
      30             :   virtual mozilla::EventListenerManager*
      31             :     GetExistingListenerManager() const override;
      32             :   virtual mozilla::EventListenerManager*
      33             :     GetOrCreateListenerManager() override;
      34             : 
      35             :   using mozilla::dom::EventTarget::RemoveEventListener;
      36             :   virtual void AddEventListener(const nsAString& aType,
      37             :                                 mozilla::dom::EventListener* aListener,
      38             :                                 const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions,
      39             :                                 const mozilla::dom::Nullable<bool>& aWantsUntrusted,
      40             :                                 mozilla::ErrorResult& aRv) override;
      41             : 
      42             :   // nsPIWindowRoot
      43             : 
      44             :   virtual nsPIDOMWindowOuter* GetWindow() override;
      45             : 
      46             :   virtual nsresult GetControllers(nsIControllers** aResult) override;
      47             :   virtual nsresult GetControllerForCommand(const char * aCommand,
      48             :                                            nsIController** _retval) override;
      49             : 
      50             :   virtual void GetEnabledDisabledCommands(nsTArray<nsCString>& aEnabledCommands,
      51             :                                           nsTArray<nsCString>& aDisabledCommands) override;
      52             : 
      53             :   virtual nsIDOMNode* GetPopupNode() override;
      54             :   virtual void SetPopupNode(nsIDOMNode* aNode) override;
      55             : 
      56           1 :   virtual void SetParentTarget(mozilla::dom::EventTarget* aTarget) override
      57             :   {
      58           1 :     mParent = aTarget;
      59           1 :   }
      60           0 :   virtual mozilla::dom::EventTarget* GetParentTarget() override { return mParent; }
      61             :   virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
      62             :   virtual nsIGlobalObject* GetOwnerGlobal() const override;
      63             : 
      64             :   nsIGlobalObject* GetParentObject();
      65             : 
      66             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
      67             : 
      68        1455 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot,
      69             :                                                          nsIDOMEventTarget)
      70             : 
      71             :   virtual void AddBrowser(mozilla::dom::TabParent* aBrowser) override;
      72             :   virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser) override;
      73             :   virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void *aArg) override;
      74             : 
      75           1 :   virtual bool ShowAccelerators() override
      76             :   {
      77           1 :     return mShowAccelerators;
      78             :   }
      79             : 
      80           1 :   virtual bool ShowFocusRings() override
      81             :   {
      82           1 :     return mShowFocusRings;
      83             :   }
      84             : 
      85           1 :   virtual void SetShowAccelerators(bool aEnable) override
      86             :   {
      87           1 :     mShowAccelerators = aEnable;
      88           1 :   }
      89             : 
      90           1 :   virtual void SetShowFocusRings(bool aEnable) override
      91             :   {
      92           1 :     mShowFocusRings = aEnable;
      93           1 :   }
      94             : 
      95             : protected:
      96             :   virtual ~nsWindowRoot();
      97             : 
      98             :   void GetEnabledDisabledCommandsForControllers(nsIControllers* aControllers,
      99             :                                                 nsTHashtable<nsCharPtrHashKey>& aCommandsHandled,
     100             :                                                 nsTArray<nsCString>& aEnabledCommands,
     101             :                                                 nsTArray<nsCString>& aDisabledCommands);
     102             : 
     103             :   // Members
     104             :   nsCOMPtr<nsPIDOMWindowOuter> mWindow;
     105             :   // We own the manager, which owns event listeners attached to us.
     106             :   RefPtr<mozilla::EventListenerManager> mListenerManager; // [Strong]
     107             :   nsWeakPtr mPopupNode;
     108             : 
     109             :   // True if focus rings and accelerators are enabled for this
     110             :   // window hierarchy.
     111             :   bool mShowAccelerators;
     112             :   bool mShowFocusRings;
     113             : 
     114             :   nsCOMPtr<mozilla::dom::EventTarget> mParent;
     115             : 
     116             :   // The TabParents that are currently registered with this top-level window.
     117             :   typedef nsTHashtable<nsRefPtrHashKey<nsIWeakReference>> WeakBrowserTable;
     118             :   WeakBrowserTable mWeakBrowsers;
     119             : };
     120             : 
     121             : extern already_AddRefed<mozilla::dom::EventTarget>
     122             : NS_NewWindowRoot(nsPIDOMWindowOuter* aWindow);
     123             : 
     124             : #endif

Generated by: LCOV version 1.13