dom/xbl/nsXBLWindowKeyHandler.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsXBLWindowKeyHandler_h__
     7 #define nsXBLWindowKeyHandler_h__
     9 #include "nsWeakPtr.h"
    10 #include "nsIDOMEventListener.h"
    12 class nsIAtom;
    13 class nsIDOMElement;
    14 class nsIDOMKeyEvent;
    15 class nsXBLSpecialDocInfo;
    16 class nsXBLPrototypeHandler;
    18 namespace mozilla {
    19 namespace dom {
    20 class Element;
    21 class EventTarget;
    22 }
    23 }
    25 class nsXBLWindowKeyHandler : public nsIDOMEventListener
    26 {
    27 public:
    28   nsXBLWindowKeyHandler(nsIDOMElement* aElement, mozilla::dom::EventTarget* aTarget);
    29   virtual ~nsXBLWindowKeyHandler();
    31   NS_DECL_ISUPPORTS
    32   NS_DECL_NSIDOMEVENTLISTENER
    34 protected:
    35   nsresult WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType);
    37   // walk the handlers, looking for one to handle the event
    38   bool WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent,
    39                             nsIAtom* aEventType,
    40                             nsXBLPrototypeHandler* aHandler,
    41                             bool aExecute);
    43   // walk the handlers for aEvent, aCharCode and aIgnoreShiftKey. Execute it
    44   // if aExecute = true.
    45   bool WalkHandlersAndExecute(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType,
    46                               nsXBLPrototypeHandler* aHandler,
    47                               uint32_t aCharCode, bool aIgnoreShiftKey,
    48                               bool aExecute);
    50   // HandleEvent function for the capturing phase.
    51   void HandleEventOnCapture(nsIDOMKeyEvent* aEvent);
    53   // Check if any handler would handle the given event.
    54   bool HasHandlerForEvent(nsIDOMKeyEvent* aEvent);
    56   // lazily load the handlers. Overridden to handle being attached
    57   // to a particular element rather than the document
    58   nsresult EnsureHandlers();
    60   // check if the given handler cares about the given key event
    61   bool EventMatched(nsXBLPrototypeHandler* inHandler, nsIAtom* inEventType,
    62                       nsIDOMKeyEvent* inEvent, uint32_t aCharCode,
    63                       bool aIgnoreShiftKey);
    65   // Is an HTML editable element focused
    66   bool IsHTMLEditableFieldFocused();
    68   // Returns the element which was passed as a parameter to the constructor,
    69   // unless the element has been removed from the document. Optionally returns
    70   // whether the disabled attribute is set on the element (assuming the element
    71   // is non-null).
    72   already_AddRefed<mozilla::dom::Element> GetElement(bool* aIsDisabled = nullptr);
    73   // Using weak pointer to the DOM Element.
    74   nsWeakPtr              mWeakPtrForElement;
    75   mozilla::dom::EventTarget* mTarget; // weak ref
    77   // these are not owning references; the prototype handlers are owned
    78   // by the prototype bindings which are owned by the docinfo.
    79   nsXBLPrototypeHandler* mHandler;     // platform bindings
    80   nsXBLPrototypeHandler* mUserHandler; // user-specific bindings
    82   // holds document info about bindings
    83   static nsXBLSpecialDocInfo* sXBLSpecialDocInfo;
    84   static uint32_t sRefCnt;
    85 };
    87 already_AddRefed<nsXBLWindowKeyHandler>
    88 NS_NewXBLWindowKeyHandler(nsIDOMElement* aElement,
    89                           mozilla::dom::EventTarget* aTarget);
    91 #endif

mercurial