LCOV - code coverage report
Current view: top level - layout/xul - nsMenuBarFrame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 5 20 25.0 %
Date: 2017-07-14 16:53:18 Functions: 3 17 17.6 %
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             : 
       6             : //
       7             : // nsMenuBarFrame
       8             : //
       9             : 
      10             : #ifndef nsMenuBarFrame_h__
      11             : #define nsMenuBarFrame_h__
      12             : 
      13             : #include "mozilla/Attributes.h"
      14             : #include "nsIAtom.h"
      15             : #include "nsCOMPtr.h"
      16             : #include "nsBoxFrame.h"
      17             : #include "nsMenuFrame.h"
      18             : #include "nsMenuBarListener.h"
      19             : #include "nsMenuParent.h"
      20             : 
      21             : class nsIContent;
      22             : 
      23             : nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      24             : 
      25           0 : class nsMenuBarFrame final : public nsBoxFrame, public nsMenuParent
      26             : {
      27             : public:
      28             :   NS_DECL_QUERYFRAME
      29         235 :   NS_DECL_FRAMEARENA_HELPERS(nsMenuBarFrame)
      30             : 
      31             :   explicit nsMenuBarFrame(nsStyleContext* aContext);
      32             : 
      33             :   // nsMenuParent interface
      34             :   virtual nsMenuFrame* GetCurrentMenuItem() override;
      35             :   NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) override;
      36             :   virtual void CurrentMenuIsBeingDestroyed() override;
      37             :   NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem,
      38             :                             bool aSelectFirstItem,
      39             :                             bool aFromKey) override;
      40             : 
      41             :   NS_IMETHOD SetActive(bool aActiveFlag) override;
      42             : 
      43         231 :   virtual bool IsMenuBar() override { return true; }
      44           0 :   virtual bool IsContextMenu() override { return false; }
      45           0 :   virtual bool IsActive() override { return mIsActive; }
      46           0 :   virtual bool IsMenu() override { return false; }
      47           0 :   virtual bool IsOpen() override { return true; } // menubars are considered always open
      48             : 
      49           0 :   bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
      50             : 
      51             :   void InstallKeyboardNavigator();
      52             :   void RemoveKeyboardNavigator();
      53             : 
      54             :   virtual void Init(nsIContent*       aContent,
      55             :                     nsContainerFrame* aParent,
      56             :                     nsIFrame*         aPrevInFlow) override;
      57             : 
      58             :   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
      59             : 
      60           0 :   virtual void LockMenuUntilClosed(bool aLock) override {}
      61           0 :   virtual bool IsMenuLocked() override { return false; }
      62             : 
      63             : // Non-interface helpers
      64             : 
      65             :   // The 'stay active' flag is set when navigating from one top-level menu
      66             :   // to another, to prevent the menubar from deactivating and submenus from
      67             :   // firing extra DOMMenuItemActive events.
      68           0 :   bool GetStayActive() { return mStayActive; }
      69           0 :   void SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
      70             : 
      71             :   // Called when a menu on the menu bar is clicked on. Returns a menu if one
      72             :   // needs to be closed.
      73             :   nsMenuFrame* ToggleMenuActiveState();
      74             : 
      75           0 :   bool IsActiveByKeyboard() { return mActiveByKeyboard; }
      76           0 :   void SetActiveByKeyboard() { mActiveByKeyboard = true; }
      77             : 
      78             :   // indicate that a menu on the menubar was closed. Returns true if the caller
      79             :   // may deselect the menuitem.
      80             :   virtual bool MenuClosed() override;
      81             : 
      82             :   // Called when Enter is pressed while the menubar is focused. If the current
      83             :   // menu is open, let the child handle the key.
      84             :   nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
      85             : 
      86             :   // Used to handle ALT+key combos
      87             :   nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
      88             : 
      89         146 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
      90             :   {
      91             :     // Override bogus IsFrameOfType in nsBoxFrame.
      92         146 :     if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
      93           0 :       return false;
      94         146 :     return nsBoxFrame::IsFrameOfType(aFlags);
      95             :   }
      96             : 
      97             : #ifdef DEBUG_FRAME_DUMP
      98           0 :   virtual nsresult GetFrameName(nsAString& aResult) const override
      99             :   {
     100           0 :       return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
     101             :   }
     102             : #endif
     103             : 
     104             : protected:
     105             :   RefPtr<nsMenuBarListener> mMenuBarListener; // The listener that tells us about key and mouse events.
     106             : 
     107             :   // flag that is temporarily set when switching from one menu on the menubar to another
     108             :   // to indicate that the menubar should not be deactivated.
     109             :   bool mStayActive;
     110             : 
     111             :   bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
     112             : 
     113             :   // whether the menubar was made active via the keyboard.
     114             :   bool mActiveByKeyboard;
     115             : 
     116             :   // The current menu that is active (highlighted), which may not be open. This will
     117             :   // be null if no menu is active.
     118             :   nsMenuFrame* mCurrentMenu;
     119             : }; // class nsMenuBarFrame
     120             : 
     121             : #endif

Generated by: LCOV version 1.13