LCOV - code coverage report
Current view: top level - dom/events - EventTarget.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 9 44.4 %
Date: 2017-07-14 16:53:18 Functions: 5 8 62.5 %
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_EventTarget_h_
       8             : #define mozilla_dom_EventTarget_h_
       9             : 
      10             : #include "mozilla/dom/BindingDeclarations.h"
      11             : #include "nsIDOMEventTarget.h"
      12             : #include "nsWrapperCache.h"
      13             : #include "nsIAtom.h"
      14             : 
      15             : class nsPIDOMWindowOuter;
      16             : class nsIGlobalObject;
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : class AsyncEventDispatcher;
      21             : class ErrorResult;
      22             : class EventListenerManager;
      23             : 
      24             : namespace dom {
      25             : 
      26             : class AddEventListenerOptionsOrBoolean;
      27             : class Event;
      28             : class EventListener;
      29             : class EventListenerOptionsOrBoolean;
      30             : class EventHandlerNonNull;
      31             : 
      32             : template <class T> struct Nullable;
      33             : 
      34             : // IID for the dom::EventTarget interface
      35             : #define NS_EVENTTARGET_IID \
      36             : { 0xde651c36, 0x0053, 0x4c67, \
      37             :   { 0xb1, 0x3d, 0x67, 0xb9, 0x40, 0xfc, 0x82, 0xe4 } }
      38             : 
      39        3704 : class EventTarget : public nsIDOMEventTarget,
      40             :                     public nsWrapperCache
      41             : {
      42             : public:
      43             :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID)
      44             : 
      45             :   // WebIDL API
      46             :   using nsIDOMEventTarget::AddEventListener;
      47             :   using nsIDOMEventTarget::RemoveEventListener;
      48             :   using nsIDOMEventTarget::DispatchEvent;
      49             :   virtual void AddEventListener(const nsAString& aType,
      50             :                                 EventListener* aCallback,
      51             :                                 const AddEventListenerOptionsOrBoolean& aOptions,
      52             :                                 const Nullable<bool>& aWantsUntrusted,
      53             :                                 ErrorResult& aRv) = 0;
      54             :   virtual void RemoveEventListener(const nsAString& aType,
      55             :                                    EventListener* aCallback,
      56             :                                    const EventListenerOptionsOrBoolean& aOptions,
      57             :                                    ErrorResult& aRv);
      58             :   bool DispatchEvent(Event& aEvent, CallerType aCallerType, ErrorResult& aRv);
      59             : 
      60             :   // Note, this takes the type in onfoo form!
      61           0 :   EventHandlerNonNull* GetEventHandler(const nsAString& aType)
      62             :   {
      63           0 :     nsCOMPtr<nsIAtom> type = NS_Atomize(aType);
      64           0 :     return GetEventHandler(type, EmptyString());
      65             :   }
      66             : 
      67             :   // Note, this takes the type in onfoo form!
      68             :   void SetEventHandler(const nsAString& aType, EventHandlerNonNull* aHandler,
      69             :                        ErrorResult& rv);
      70             : 
      71             :   // Note, for an event 'foo' aType will be 'onfoo'.
      72        1699 :   virtual void EventListenerAdded(nsIAtom* aType) {}
      73           0 :   virtual void EventListenerAdded(const nsAString& aType) {}
      74             : 
      75         146 :   virtual void EventListenerRemoved(nsIAtom* aType) {}
      76           0 :   virtual void EventListenerRemoved(const nsAString& aType) {}
      77             : 
      78             :   // Returns an outer window that corresponds to the inner window this event
      79             :   // target is associated with.  Will return null if the inner window is not the
      80             :   // current inner or if there is no window around at all.
      81             :   virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() = 0;
      82             : 
      83             :   // The global object this event target is associated with, if any.
      84             :   // This may be an inner window or some other global object.  This
      85             :   // will never be an outer window.
      86             :   virtual nsIGlobalObject* GetOwnerGlobal() const = 0;
      87             : 
      88             :   /**
      89             :    * Get the event listener manager, creating it if it does not already exist.
      90             :    */
      91             :   virtual EventListenerManager* GetOrCreateListenerManager() = 0;
      92             : 
      93             :   /**
      94             :    * Get the event listener manager, returning null if it does not already
      95             :    * exist.
      96             :    */
      97             :   virtual EventListenerManager* GetExistingListenerManager() const = 0;
      98             : 
      99             :   // Called from AsyncEventDispatcher to notify it is running.
     100         113 :   virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) {}
     101             : 
     102             :   // Used by FocusTarget to determine whether this event target has listeners
     103             :   // for untrusted or non system group key events.
     104             :   bool HasUntrustedOrNonSystemGroupKeyEventListeners() const;
     105             : 
     106             :   virtual bool IsApzAware() const;
     107             : 
     108             : protected:
     109             :   EventHandlerNonNull* GetEventHandler(nsIAtom* aType,
     110             :                                        const nsAString& aTypeString);
     111             :   void SetEventHandler(nsIAtom* aType, const nsAString& aTypeString,
     112             :                        EventHandlerNonNull* aHandler);
     113             : };
     114             : 
     115             : NS_DEFINE_STATIC_IID_ACCESSOR(EventTarget, NS_EVENTTARGET_IID)
     116             : 
     117             : } // namespace dom
     118             : } // namespace mozilla
     119             : 
     120             : #endif // mozilla_dom_EventTarget_h_

Generated by: LCOV version 1.13