layout/xul/nsMenuBarFrame.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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 //
     7 // nsMenuBarFrame
     8 //
    10 #ifndef nsMenuBarFrame_h__
    11 #define nsMenuBarFrame_h__
    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"
    21 class nsIContent;
    23 nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    25 class nsMenuBarFrame : public nsBoxFrame, public nsMenuParent
    26 {
    27 public:
    28   NS_DECL_QUERYFRAME_TARGET(nsMenuBarFrame)
    29   NS_DECL_QUERYFRAME
    30   NS_DECL_FRAMEARENA_HELPERS
    32   nsMenuBarFrame(nsIPresShell* aShell, nsStyleContext* aContext);
    34   // nsMenuParent interface
    35   virtual nsMenuFrame* GetCurrentMenuItem() MOZ_OVERRIDE;
    36   NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) MOZ_OVERRIDE;
    37   virtual void CurrentMenuIsBeingDestroyed() MOZ_OVERRIDE;
    38   NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem) MOZ_OVERRIDE;
    40   NS_IMETHOD SetActive(bool aActiveFlag) MOZ_OVERRIDE; 
    42   virtual bool IsMenuBar() MOZ_OVERRIDE { return true; }
    43   virtual bool IsContextMenu() MOZ_OVERRIDE { return false; }
    44   virtual bool IsActive() MOZ_OVERRIDE { return mIsActive; }
    45   virtual bool IsMenu() MOZ_OVERRIDE { return false; }
    46   virtual bool IsOpen() MOZ_OVERRIDE { return true; } // menubars are considered always open
    48   bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
    50   void InstallKeyboardNavigator();
    51   void RemoveKeyboardNavigator();
    53   virtual void Init(nsIContent*      aContent,
    54                     nsIFrame*        aParent,
    55                     nsIFrame*        aPrevInFlow) MOZ_OVERRIDE;
    57   virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    59   virtual void LockMenuUntilClosed(bool aLock) MOZ_OVERRIDE {}
    60   virtual bool IsMenuLocked() MOZ_OVERRIDE { return false; }
    62 // Non-interface helpers
    64   // The 'stay active' flag is set when navigating from one top-level menu
    65   // to another, to prevent the menubar from deactivating and submenus from
    66   // firing extra DOMMenuItemActive events.
    67   bool GetStayActive() { return mStayActive; }
    68   void SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
    70   // Called when a menu on the menu bar is clicked on. Returns a menu if one
    71   // needs to be closed.
    72   nsMenuFrame* ToggleMenuActiveState();
    74   bool IsActiveByKeyboard() { return mActiveByKeyboard; }
    75   void SetActiveByKeyboard() { mActiveByKeyboard = true; }
    77   // indicate that a menu on the menubar was closed. Returns true if the caller
    78   // may deselect the menuitem.
    79   virtual bool MenuClosed() MOZ_OVERRIDE;
    81   // Called when Enter is pressed while the menubar is focused. If the current
    82   // menu is open, let the child handle the key.
    83   nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
    85   // Used to handle ALT+key combos
    86   nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
    88   virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
    89   {
    90     // Override bogus IsFrameOfType in nsBoxFrame.
    91     if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
    92       return false;
    93     return nsBoxFrame::IsFrameOfType(aFlags);
    94   }
    96 #ifdef DEBUG_FRAME_DUMP
    97   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
    98   {
    99       return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
   100   }
   101 #endif
   103 protected:
   104   nsMenuBarListener* mMenuBarListener; // The listener that tells us about key and mouse events.
   106   // flag that is temporarily set when switching from one menu on the menubar to another
   107   // to indicate that the menubar should not be deactivated.
   108   bool mStayActive;
   110   bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
   112   // whether the menubar was made active via the keyboard.
   113   bool mActiveByKeyboard;
   115   // The current menu that is active (highlighted), which may not be open. This will
   116   // be null if no menu is active.
   117   nsMenuFrame* mCurrentMenu;
   119   mozilla::dom::EventTarget* mTarget;
   121 }; // class nsMenuBarFrame
   123 #endif

mercurial