Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_EventTarget_h_ |
michael@0 | 7 | #define mozilla_dom_EventTarget_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIDOMEventTarget.h" |
michael@0 | 10 | #include "nsWrapperCache.h" |
michael@0 | 11 | #include "nsIAtom.h" |
michael@0 | 12 | |
michael@0 | 13 | class nsIDOMWindow; |
michael@0 | 14 | class nsIDOMEventListener; |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | |
michael@0 | 18 | class ErrorResult; |
michael@0 | 19 | class EventListenerManager; |
michael@0 | 20 | |
michael@0 | 21 | namespace dom { |
michael@0 | 22 | |
michael@0 | 23 | class Event; |
michael@0 | 24 | class EventListener; |
michael@0 | 25 | class EventHandlerNonNull; |
michael@0 | 26 | template <class T> struct Nullable; |
michael@0 | 27 | |
michael@0 | 28 | // IID for the dom::EventTarget interface |
michael@0 | 29 | #define NS_EVENTTARGET_IID \ |
michael@0 | 30 | { 0xce3817d0, 0x177b, 0x402f, \ |
michael@0 | 31 | { 0xae, 0x75, 0xf8, 0x4e, 0xbe, 0x5a, 0x07, 0xc3 } } |
michael@0 | 32 | |
michael@0 | 33 | class EventTarget : public nsIDOMEventTarget, |
michael@0 | 34 | public nsWrapperCache |
michael@0 | 35 | { |
michael@0 | 36 | public: |
michael@0 | 37 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID) |
michael@0 | 38 | |
michael@0 | 39 | // WebIDL API |
michael@0 | 40 | using nsIDOMEventTarget::AddEventListener; |
michael@0 | 41 | using nsIDOMEventTarget::RemoveEventListener; |
michael@0 | 42 | using nsIDOMEventTarget::DispatchEvent; |
michael@0 | 43 | virtual void AddEventListener(const nsAString& aType, |
michael@0 | 44 | EventListener* aCallback, |
michael@0 | 45 | bool aCapture, |
michael@0 | 46 | const Nullable<bool>& aWantsUntrusted, |
michael@0 | 47 | ErrorResult& aRv) = 0; |
michael@0 | 48 | virtual void RemoveEventListener(const nsAString& aType, |
michael@0 | 49 | EventListener* aCallback, |
michael@0 | 50 | bool aCapture, |
michael@0 | 51 | ErrorResult& aRv); |
michael@0 | 52 | bool DispatchEvent(Event& aEvent, ErrorResult& aRv); |
michael@0 | 53 | |
michael@0 | 54 | // Note, this takes the type in onfoo form! |
michael@0 | 55 | EventHandlerNonNull* GetEventHandler(const nsAString& aType) |
michael@0 | 56 | { |
michael@0 | 57 | nsCOMPtr<nsIAtom> type = do_GetAtom(aType); |
michael@0 | 58 | return GetEventHandler(type, EmptyString()); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Note, this takes the type in onfoo form! |
michael@0 | 62 | void SetEventHandler(const nsAString& aType, EventHandlerNonNull* aHandler, |
michael@0 | 63 | ErrorResult& rv); |
michael@0 | 64 | |
michael@0 | 65 | // Note, for an event 'foo' aType will be 'onfoo'. |
michael@0 | 66 | virtual void EventListenerAdded(nsIAtom* aType) {} |
michael@0 | 67 | virtual void EventListenerRemoved(nsIAtom* aType) {} |
michael@0 | 68 | |
michael@0 | 69 | // Returns an outer window that corresponds to the inner window this event |
michael@0 | 70 | // target is associated with. Will return null if the inner window is not the |
michael@0 | 71 | // current inner or if there is no window around at all. |
michael@0 | 72 | virtual nsIDOMWindow* GetOwnerGlobal() = 0; |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * Get the event listener manager, creating it if it does not already exist. |
michael@0 | 76 | */ |
michael@0 | 77 | virtual EventListenerManager* GetOrCreateListenerManager() = 0; |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * Get the event listener manager, returning null if it does not already |
michael@0 | 81 | * exist. |
michael@0 | 82 | */ |
michael@0 | 83 | virtual EventListenerManager* GetExistingListenerManager() const = 0; |
michael@0 | 84 | |
michael@0 | 85 | protected: |
michael@0 | 86 | EventHandlerNonNull* GetEventHandler(nsIAtom* aType, |
michael@0 | 87 | const nsAString& aTypeString); |
michael@0 | 88 | void SetEventHandler(nsIAtom* aType, const nsAString& aTypeString, |
michael@0 | 89 | EventHandlerNonNull* aHandler); |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | NS_DEFINE_STATIC_IID_ACCESSOR(EventTarget, NS_EVENTTARGET_IID) |
michael@0 | 93 | |
michael@0 | 94 | } // namespace dom |
michael@0 | 95 | } // namespace mozilla |
michael@0 | 96 | |
michael@0 | 97 | #endif // mozilla_dom_EventTarget_h_ |