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 nsXBLEventHandler_h__ |
michael@0 | 7 | #define nsXBLEventHandler_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsIDOMEventListener.h" |
michael@0 | 12 | #include "nsTArray.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIAtom; |
michael@0 | 15 | class nsIDOMKeyEvent; |
michael@0 | 16 | class nsXBLPrototypeHandler; |
michael@0 | 17 | |
michael@0 | 18 | class nsXBLEventHandler : public nsIDOMEventListener |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | nsXBLEventHandler(nsXBLPrototypeHandler* aHandler); |
michael@0 | 22 | virtual ~nsXBLEventHandler(); |
michael@0 | 23 | |
michael@0 | 24 | NS_DECL_ISUPPORTS |
michael@0 | 25 | |
michael@0 | 26 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 27 | |
michael@0 | 28 | protected: |
michael@0 | 29 | nsXBLPrototypeHandler* mProtoHandler; |
michael@0 | 30 | |
michael@0 | 31 | private: |
michael@0 | 32 | nsXBLEventHandler(); |
michael@0 | 33 | virtual bool EventMatched(nsIDOMEvent* aEvent) |
michael@0 | 34 | { |
michael@0 | 35 | return true; |
michael@0 | 36 | } |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | class nsXBLMouseEventHandler : public nsXBLEventHandler |
michael@0 | 40 | { |
michael@0 | 41 | public: |
michael@0 | 42 | nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler); |
michael@0 | 43 | virtual ~nsXBLMouseEventHandler(); |
michael@0 | 44 | |
michael@0 | 45 | private: |
michael@0 | 46 | bool EventMatched(nsIDOMEvent* aEvent) MOZ_OVERRIDE; |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | class nsXBLKeyEventHandler : public nsIDOMEventListener |
michael@0 | 50 | { |
michael@0 | 51 | public: |
michael@0 | 52 | nsXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType); |
michael@0 | 53 | virtual ~nsXBLKeyEventHandler(); |
michael@0 | 54 | |
michael@0 | 55 | NS_DECL_ISUPPORTS |
michael@0 | 56 | |
michael@0 | 57 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 58 | |
michael@0 | 59 | void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler) |
michael@0 | 60 | { |
michael@0 | 61 | mProtoHandlers.AppendElement(aProtoHandler); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | bool Matches(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType) const |
michael@0 | 65 | { |
michael@0 | 66 | return (mEventType == aEventType && mPhase == aPhase && mType == aType); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | void GetEventName(nsAString& aString) const |
michael@0 | 70 | { |
michael@0 | 71 | mEventType->ToString(aString); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | uint8_t GetPhase() const |
michael@0 | 75 | { |
michael@0 | 76 | return mPhase; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | uint8_t GetType() const |
michael@0 | 80 | { |
michael@0 | 81 | return mType; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | void SetIsBoundToChrome(bool aIsBoundToChrome) |
michael@0 | 85 | { |
michael@0 | 86 | mIsBoundToChrome = aIsBoundToChrome; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | void SetUsingXBLScope(bool aUsingXBLScope) |
michael@0 | 90 | { |
michael@0 | 91 | mUsingXBLScope = aUsingXBLScope; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | private: |
michael@0 | 95 | nsXBLKeyEventHandler(); |
michael@0 | 96 | bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, uint32_t aCharCode, |
michael@0 | 97 | bool aIgnoreShiftKey); |
michael@0 | 98 | |
michael@0 | 99 | nsTArray<nsXBLPrototypeHandler*> mProtoHandlers; |
michael@0 | 100 | nsCOMPtr<nsIAtom> mEventType; |
michael@0 | 101 | uint8_t mPhase; |
michael@0 | 102 | uint8_t mType; |
michael@0 | 103 | bool mIsBoundToChrome; |
michael@0 | 104 | bool mUsingXBLScope; |
michael@0 | 105 | }; |
michael@0 | 106 | |
michael@0 | 107 | nsresult |
michael@0 | 108 | NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler, |
michael@0 | 109 | nsIAtom* aEventType, |
michael@0 | 110 | nsXBLEventHandler** aResult); |
michael@0 | 111 | |
michael@0 | 112 | nsresult |
michael@0 | 113 | NS_NewXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase, |
michael@0 | 114 | uint8_t aType, nsXBLKeyEventHandler** aResult); |
michael@0 | 115 | |
michael@0 | 116 | #endif |