gecko-dev/layout/xul/nsMenuBarFrame.h

123 строки
4.1 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2012-05-21 15:12:37 +04:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
1999-07-18 11:07:55 +04:00
//
// nsMenuBarFrame
//
#ifndef nsMenuBarFrame_h__
#define nsMenuBarFrame_h__
#include "mozilla/Attributes.h"
1999-07-18 11:07:55 +04:00
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsBoxFrame.h"
#include "nsMenuFrame.h"
1999-07-19 06:02:38 +04:00
#include "nsMenuBarListener.h"
#include "nsMenuParent.h"
1999-07-18 11:07:55 +04:00
class nsIContent;
nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
1999-07-18 11:07:55 +04:00
class nsMenuBarFrame final : public nsBoxFrame, public nsMenuParent
1999-07-18 11:07:55 +04:00
{
public:
NS_DECL_QUERYFRAME_TARGET(nsMenuBarFrame)
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
explicit nsMenuBarFrame(nsStyleContext* aContext);
// nsMenuParent interface
virtual nsMenuFrame* GetCurrentMenuItem() override;
NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) override;
virtual void CurrentMenuIsBeingDestroyed() override;
NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem,
bool aSelectFirstItem,
bool aFromKey) override;
NS_IMETHOD SetActive(bool aActiveFlag) override;
virtual bool IsMenuBar() override { return true; }
virtual bool IsContextMenu() override { return false; }
virtual bool IsActive() override { return mIsActive; }
virtual bool IsMenu() override { return false; }
virtual bool IsOpen() override { return true; } // menubars are considered always open
bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
void InstallKeyboardNavigator();
void RemoveKeyboardNavigator();
1999-09-21 05:03:00 +04:00
virtual void Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) override;
1999-07-19 06:02:38 +04:00
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
1999-08-22 11:44:00 +04:00
virtual void LockMenuUntilClosed(bool aLock) override {}
virtual bool IsMenuLocked() override { return false; }
// Non-interface helpers
// The 'stay active' flag is set when navigating from one top-level menu
// to another, to prevent the menubar from deactivating and submenus from
// firing extra DOMMenuItemActive events.
bool GetStayActive() { return mStayActive; }
void SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
// Called when a menu on the menu bar is clicked on. Returns a menu if one
// needs to be closed.
nsMenuFrame* ToggleMenuActiveState();
bool IsActiveByKeyboard() { return mActiveByKeyboard; }
void SetActiveByKeyboard() { mActiveByKeyboard = true; }
// indicate that a menu on the menubar was closed. Returns true if the caller
// may deselect the menuitem.
virtual bool MenuClosed() override;
// Called when Enter is pressed while the menubar is focused. If the current
// menu is open, let the child handle the key.
nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
// Used to handle ALT+key combos
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
virtual bool IsFrameOfType(uint32_t aFlags) const override
{
// Override bogus IsFrameOfType in nsBoxFrame.
if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
return false;
return nsBoxFrame::IsFrameOfType(aFlags);
}
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override
{
return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
}
#endif
1999-07-18 11:07:55 +04:00
protected:
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<nsMenuBarListener> mMenuBarListener; // The listener that tells us about key and mouse events.
// flag that is temporarily set when switching from one menu on the menubar to another
// to indicate that the menubar should not be deactivated.
bool mStayActive;
bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
// whether the menubar was made active via the keyboard.
bool mActiveByKeyboard;
// The current menu that is active (highlighted), which may not be open. This will
// be null if no menu is active.
nsMenuFrame* mCurrentMenu;
1999-07-18 11:07:55 +04:00
}; // class nsMenuBarFrame
#endif