LCOV - code coverage report
Current view: top level - layout/xul - nsMenuBarListener.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : #ifndef nsMenuBarListener_h
       6             : #define nsMenuBarListener_h
       7             : 
       8             : #include "mozilla/Attributes.h"
       9             : #include "mozilla/EventForwards.h"
      10             : #include "nsIDOMEventListener.h"
      11             : 
      12             : // X.h defines KeyPress
      13             : #ifdef KeyPress
      14             : #undef KeyPress
      15             : #endif
      16             : 
      17             : class nsMenuBarFrame;
      18             : class nsIDOMKeyEvent;
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : class EventTarget;
      23             : } // namespace dom
      24             : } // namespace mozilla
      25             : 
      26             : /**
      27             :  * EventListener implementation for menubar.
      28             :  */
      29             : class nsMenuBarListener final : public nsIDOMEventListener
      30             : {
      31             : public:
      32             :   explicit nsMenuBarListener(nsMenuBarFrame* aMenuBarFrame,
      33             :                              nsIContent* aMenuBarContent);
      34             : 
      35             :   NS_DECL_ISUPPORTS
      36             : 
      37             :   /**
      38             :    * nsIDOMEventListener interface method.
      39             :    */
      40             :   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
      41             : 
      42             :   /**
      43             :    * When mMenuBarFrame is being destroyed, this should be called.
      44             :    */
      45             :   void OnDestroyMenuBarFrame();
      46             : 
      47             :   static void InitializeStatics();
      48             : 
      49             :   /**
      50             :    * GetMenuAccessKey() returns keyCode value of a modifier key which is
      51             :    * used for accesskey.  Returns 0 if the platform doesn't support access key.
      52             :    */
      53             :   static nsresult GetMenuAccessKey(int32_t* aAccessKey);
      54             : 
      55             :   /**
      56             :    * IsAccessKeyPressed() returns true if the modifier state of aEvent matches
      57             :    * the modifier state of access key.
      58             :    */
      59             :   static bool IsAccessKeyPressed(nsIDOMKeyEvent* aEvent);
      60             : 
      61             : protected:
      62             :   virtual ~nsMenuBarListener();
      63             : 
      64             :   nsresult KeyUp(nsIDOMEvent* aMouseEvent);
      65             :   nsresult KeyDown(nsIDOMEvent* aMouseEvent);
      66             :   nsresult KeyPress(nsIDOMEvent* aMouseEvent);
      67             :   nsresult Blur(nsIDOMEvent* aEvent);
      68             :   nsresult OnWindowDeactivated(nsIDOMEvent* aEvent);
      69             :   nsresult MouseDown(nsIDOMEvent* aMouseEvent);
      70             :   nsresult Fullscreen(nsIDOMEvent* aEvent);
      71             : 
      72             :   static void InitAccessKey();
      73             : 
      74             :   static mozilla::Modifiers GetModifiersForAccessKey(nsIDOMKeyEvent* event);
      75             : 
      76             :   // This should only be called by the nsMenuBarListener during event dispatch,
      77             :   // thus ensuring that this doesn't get destroyed during the process.
      78             :   void ToggleMenuActiveState();
      79             : 
      80           0 :   bool Destroyed() const { return !mMenuBarFrame; }
      81             : 
      82             :   // The menu bar object.
      83             :   nsMenuBarFrame* mMenuBarFrame;
      84             :   // The event target to listen to the events.
      85             :   // XXX Should this store this as strong reference?  However,
      86             :   //     OnDestroyMenuBarFrame() should be called at destroying mMenuBarFrame.
      87             :   //     So, weak reference must be safe.
      88             :   mozilla::dom::EventTarget* mEventTarget;
      89             :   // The top window as EventTarget.
      90             :   mozilla::dom::EventTarget* mTopWindowEventTarget;
      91             :   // Whether or not the ALT key is currently down.
      92             :   bool mAccessKeyDown;
      93             :   // Whether or not the ALT key down is canceled by other action.
      94             :   bool mAccessKeyDownCanceled;
      95             :   // Does the access key by itself focus the menubar?
      96             :   static bool mAccessKeyFocuses;
      97             :   // See nsIDOMKeyEvent.h for sample values.
      98             :   static int32_t mAccessKey;
      99             :   // Modifier mask for the access key.
     100             :   static mozilla::Modifiers mAccessKeyMask;
     101             : };
     102             : 
     103             : #endif // #ifndef nsMenuBarListener_h

Generated by: LCOV version 1.13