dom/xbl/nsXBLWindowKeyHandler.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xbl/nsXBLWindowKeyHandler.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsXBLWindowKeyHandler_h__
    1.10 +#define nsXBLWindowKeyHandler_h__
    1.11 +
    1.12 +#include "nsWeakPtr.h"
    1.13 +#include "nsIDOMEventListener.h"
    1.14 +
    1.15 +class nsIAtom;
    1.16 +class nsIDOMElement;
    1.17 +class nsIDOMKeyEvent;
    1.18 +class nsXBLSpecialDocInfo;
    1.19 +class nsXBLPrototypeHandler;
    1.20 +
    1.21 +namespace mozilla {
    1.22 +namespace dom {
    1.23 +class Element;
    1.24 +class EventTarget;
    1.25 +}
    1.26 +}
    1.27 +
    1.28 +class nsXBLWindowKeyHandler : public nsIDOMEventListener
    1.29 +{
    1.30 +public:
    1.31 +  nsXBLWindowKeyHandler(nsIDOMElement* aElement, mozilla::dom::EventTarget* aTarget);
    1.32 +  virtual ~nsXBLWindowKeyHandler();
    1.33 +
    1.34 +  NS_DECL_ISUPPORTS
    1.35 +  NS_DECL_NSIDOMEVENTLISTENER
    1.36 +
    1.37 +protected:
    1.38 +  nsresult WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType);
    1.39 +
    1.40 +  // walk the handlers, looking for one to handle the event
    1.41 +  bool WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent,
    1.42 +                            nsIAtom* aEventType,
    1.43 +                            nsXBLPrototypeHandler* aHandler,
    1.44 +                            bool aExecute);
    1.45 +
    1.46 +  // walk the handlers for aEvent, aCharCode and aIgnoreShiftKey. Execute it
    1.47 +  // if aExecute = true.
    1.48 +  bool WalkHandlersAndExecute(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType,
    1.49 +                              nsXBLPrototypeHandler* aHandler,
    1.50 +                              uint32_t aCharCode, bool aIgnoreShiftKey,
    1.51 +                              bool aExecute);
    1.52 +
    1.53 +  // HandleEvent function for the capturing phase.
    1.54 +  void HandleEventOnCapture(nsIDOMKeyEvent* aEvent);
    1.55 +
    1.56 +  // Check if any handler would handle the given event.
    1.57 +  bool HasHandlerForEvent(nsIDOMKeyEvent* aEvent);
    1.58 +
    1.59 +  // lazily load the handlers. Overridden to handle being attached
    1.60 +  // to a particular element rather than the document
    1.61 +  nsresult EnsureHandlers();
    1.62 +
    1.63 +  // check if the given handler cares about the given key event
    1.64 +  bool EventMatched(nsXBLPrototypeHandler* inHandler, nsIAtom* inEventType,
    1.65 +                      nsIDOMKeyEvent* inEvent, uint32_t aCharCode,
    1.66 +                      bool aIgnoreShiftKey);
    1.67 +
    1.68 +  // Is an HTML editable element focused
    1.69 +  bool IsHTMLEditableFieldFocused();
    1.70 +
    1.71 +  // Returns the element which was passed as a parameter to the constructor,
    1.72 +  // unless the element has been removed from the document. Optionally returns
    1.73 +  // whether the disabled attribute is set on the element (assuming the element
    1.74 +  // is non-null).
    1.75 +  already_AddRefed<mozilla::dom::Element> GetElement(bool* aIsDisabled = nullptr);
    1.76 +  // Using weak pointer to the DOM Element.
    1.77 +  nsWeakPtr              mWeakPtrForElement;
    1.78 +  mozilla::dom::EventTarget* mTarget; // weak ref
    1.79 +
    1.80 +  // these are not owning references; the prototype handlers are owned
    1.81 +  // by the prototype bindings which are owned by the docinfo.
    1.82 +  nsXBLPrototypeHandler* mHandler;     // platform bindings
    1.83 +  nsXBLPrototypeHandler* mUserHandler; // user-specific bindings
    1.84 +
    1.85 +  // holds document info about bindings
    1.86 +  static nsXBLSpecialDocInfo* sXBLSpecialDocInfo;
    1.87 +  static uint32_t sRefCnt;
    1.88 +};
    1.89 +
    1.90 +already_AddRefed<nsXBLWindowKeyHandler>
    1.91 +NS_NewXBLWindowKeyHandler(nsIDOMElement* aElement,
    1.92 +                          mozilla::dom::EventTarget* aTarget);
    1.93 +
    1.94 +#endif

mercurial