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 nsXBLWindowKeyHandler_h__ |
michael@0 | 7 | #define nsXBLWindowKeyHandler_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsWeakPtr.h" |
michael@0 | 10 | #include "nsIDOMEventListener.h" |
michael@0 | 11 | |
michael@0 | 12 | class nsIAtom; |
michael@0 | 13 | class nsIDOMElement; |
michael@0 | 14 | class nsIDOMKeyEvent; |
michael@0 | 15 | class nsXBLSpecialDocInfo; |
michael@0 | 16 | class nsXBLPrototypeHandler; |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | namespace dom { |
michael@0 | 20 | class Element; |
michael@0 | 21 | class EventTarget; |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | class nsXBLWindowKeyHandler : public nsIDOMEventListener |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | nsXBLWindowKeyHandler(nsIDOMElement* aElement, mozilla::dom::EventTarget* aTarget); |
michael@0 | 29 | virtual ~nsXBLWindowKeyHandler(); |
michael@0 | 30 | |
michael@0 | 31 | NS_DECL_ISUPPORTS |
michael@0 | 32 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 33 | |
michael@0 | 34 | protected: |
michael@0 | 35 | nsresult WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType); |
michael@0 | 36 | |
michael@0 | 37 | // walk the handlers, looking for one to handle the event |
michael@0 | 38 | bool WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent, |
michael@0 | 39 | nsIAtom* aEventType, |
michael@0 | 40 | nsXBLPrototypeHandler* aHandler, |
michael@0 | 41 | bool aExecute); |
michael@0 | 42 | |
michael@0 | 43 | // walk the handlers for aEvent, aCharCode and aIgnoreShiftKey. Execute it |
michael@0 | 44 | // if aExecute = true. |
michael@0 | 45 | bool WalkHandlersAndExecute(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType, |
michael@0 | 46 | nsXBLPrototypeHandler* aHandler, |
michael@0 | 47 | uint32_t aCharCode, bool aIgnoreShiftKey, |
michael@0 | 48 | bool aExecute); |
michael@0 | 49 | |
michael@0 | 50 | // HandleEvent function for the capturing phase. |
michael@0 | 51 | void HandleEventOnCapture(nsIDOMKeyEvent* aEvent); |
michael@0 | 52 | |
michael@0 | 53 | // Check if any handler would handle the given event. |
michael@0 | 54 | bool HasHandlerForEvent(nsIDOMKeyEvent* aEvent); |
michael@0 | 55 | |
michael@0 | 56 | // lazily load the handlers. Overridden to handle being attached |
michael@0 | 57 | // to a particular element rather than the document |
michael@0 | 58 | nsresult EnsureHandlers(); |
michael@0 | 59 | |
michael@0 | 60 | // check if the given handler cares about the given key event |
michael@0 | 61 | bool EventMatched(nsXBLPrototypeHandler* inHandler, nsIAtom* inEventType, |
michael@0 | 62 | nsIDOMKeyEvent* inEvent, uint32_t aCharCode, |
michael@0 | 63 | bool aIgnoreShiftKey); |
michael@0 | 64 | |
michael@0 | 65 | // Is an HTML editable element focused |
michael@0 | 66 | bool IsHTMLEditableFieldFocused(); |
michael@0 | 67 | |
michael@0 | 68 | // Returns the element which was passed as a parameter to the constructor, |
michael@0 | 69 | // unless the element has been removed from the document. Optionally returns |
michael@0 | 70 | // whether the disabled attribute is set on the element (assuming the element |
michael@0 | 71 | // is non-null). |
michael@0 | 72 | already_AddRefed<mozilla::dom::Element> GetElement(bool* aIsDisabled = nullptr); |
michael@0 | 73 | // Using weak pointer to the DOM Element. |
michael@0 | 74 | nsWeakPtr mWeakPtrForElement; |
michael@0 | 75 | mozilla::dom::EventTarget* mTarget; // weak ref |
michael@0 | 76 | |
michael@0 | 77 | // these are not owning references; the prototype handlers are owned |
michael@0 | 78 | // by the prototype bindings which are owned by the docinfo. |
michael@0 | 79 | nsXBLPrototypeHandler* mHandler; // platform bindings |
michael@0 | 80 | nsXBLPrototypeHandler* mUserHandler; // user-specific bindings |
michael@0 | 81 | |
michael@0 | 82 | // holds document info about bindings |
michael@0 | 83 | static nsXBLSpecialDocInfo* sXBLSpecialDocInfo; |
michael@0 | 84 | static uint32_t sRefCnt; |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | already_AddRefed<nsXBLWindowKeyHandler> |
michael@0 | 88 | NS_NewXBLWindowKeyHandler(nsIDOMElement* aElement, |
michael@0 | 89 | mozilla::dom::EventTarget* aTarget); |
michael@0 | 90 | |
michael@0 | 91 | #endif |