2001-09-29 00:14:13 +04:00
|
|
|
/* -*- 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 10:35:03 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// nsMenuPopupFrame
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef nsMenuPopupFrame_h__
|
|
|
|
#define nsMenuPopupFrame_h__
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-07-18 10:35:03 +04:00
|
|
|
#include "nsIAtom.h"
|
2007-07-04 19:49:38 +04:00
|
|
|
#include "nsGkAtoms.h"
|
1999-07-18 10:35:03 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2007-07-04 19:49:38 +04:00
|
|
|
#include "nsMenuFrame.h"
|
1999-07-18 10:35:03 +04:00
|
|
|
|
1999-07-21 06:56:23 +04:00
|
|
|
#include "nsBoxFrame.h"
|
2008-12-05 19:37:31 +03:00
|
|
|
#include "nsMenuParent.h"
|
1999-07-18 10:35:03 +04:00
|
|
|
|
2000-02-13 11:33:39 +03:00
|
|
|
#include "nsITimer.h"
|
|
|
|
|
2009-04-02 01:59:02 +04:00
|
|
|
class nsIWidget;
|
|
|
|
|
2007-08-03 18:05:07 +04:00
|
|
|
// XUL popups can be in several different states. When opening a popup, the
|
|
|
|
// state changes as follows:
|
|
|
|
// ePopupClosed - initial state
|
|
|
|
// ePopupShowing - during the period when the popupshowing event fires
|
|
|
|
// ePopupOpen - between the popupshowing event and being visible. Creation
|
|
|
|
// of the child frames, layout and reflow occurs in this state.
|
2010-09-06 07:30:17 +04:00
|
|
|
// ePopupOpenAndVisible - layout is done and the popup's view and widget are
|
|
|
|
// made visible. The popupshown event fires.
|
2007-08-03 18:05:07 +04:00
|
|
|
// When closing a popup:
|
|
|
|
// ePopupHidden - during the period when the popuphiding event fires and
|
|
|
|
// the popup is removed.
|
|
|
|
// ePopupClosed - the popup's widget is made invisible.
|
|
|
|
enum nsPopupState {
|
|
|
|
// state when a popup is not open
|
|
|
|
ePopupClosed,
|
|
|
|
// state from when a popup is requested to be shown to after the
|
|
|
|
// popupshowing event has been fired.
|
|
|
|
ePopupShowing,
|
|
|
|
// state while a popup is open but the widget is not yet visible
|
|
|
|
ePopupOpen,
|
|
|
|
// state while a popup is open and visible on screen
|
|
|
|
ePopupOpenAndVisible,
|
|
|
|
// state from when a popup is requested to be hidden to when it is closed.
|
|
|
|
ePopupHiding,
|
|
|
|
// state which indicates that the popup was hidden without firing the
|
|
|
|
// popuphiding or popuphidden events. It is used when executing a menu
|
|
|
|
// command because the menu needs to be hidden before the command event
|
|
|
|
// fires, yet the popuphiding and popuphidden events are fired after. This
|
|
|
|
// state can also occur when the popup is removed because the document is
|
|
|
|
// unloaded.
|
|
|
|
ePopupInvisible
|
|
|
|
};
|
|
|
|
|
2010-10-13 23:41:37 +04:00
|
|
|
// How a popup may be flipped. Flipping to the outside edge is like how
|
|
|
|
// a submenu would work. The entire popup is flipped to the opposite side
|
|
|
|
// of the anchor.
|
|
|
|
enum FlipStyle {
|
|
|
|
FlipStyle_None = 0,
|
|
|
|
FlipStyle_Outside = 1,
|
|
|
|
FlipStyle_Inside = 2
|
|
|
|
};
|
|
|
|
|
2014-01-23 00:09:03 +04:00
|
|
|
// Values for the flip attribute
|
|
|
|
enum FlipType {
|
|
|
|
FlipType_Default = 0,
|
|
|
|
FlipType_None = 1, // don't try to flip or translate to stay onscreen
|
|
|
|
FlipType_Both = 2, // flip in both directions
|
|
|
|
FlipType_Slide = 3 // allow the arrow to "slide" instead of resizing
|
|
|
|
};
|
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// values are selected so that the direction can be flipped just by
|
|
|
|
// changing the sign
|
|
|
|
#define POPUPALIGNMENT_NONE 0
|
|
|
|
#define POPUPALIGNMENT_TOPLEFT 1
|
|
|
|
#define POPUPALIGNMENT_TOPRIGHT -1
|
|
|
|
#define POPUPALIGNMENT_BOTTOMLEFT 2
|
|
|
|
#define POPUPALIGNMENT_BOTTOMRIGHT -2
|
|
|
|
|
2010-12-06 01:09:36 +03:00
|
|
|
#define POPUPALIGNMENT_LEFTCENTER 16
|
2012-12-18 21:08:08 +04:00
|
|
|
#define POPUPALIGNMENT_RIGHTCENTER -16
|
|
|
|
#define POPUPALIGNMENT_TOPCENTER 17
|
|
|
|
#define POPUPALIGNMENT_BOTTOMCENTER 18
|
2010-12-06 01:09:36 +03:00
|
|
|
|
2013-04-19 04:47:27 +04:00
|
|
|
// The constants here are selected so that horizontally and vertically flipping
|
|
|
|
// can be easily handled using the two flip macros below.
|
|
|
|
#define POPUPPOSITION_UNKNOWN -1
|
|
|
|
#define POPUPPOSITION_BEFORESTART 0
|
|
|
|
#define POPUPPOSITION_BEFOREEND 1
|
|
|
|
#define POPUPPOSITION_AFTERSTART 2
|
|
|
|
#define POPUPPOSITION_AFTEREND 3
|
|
|
|
#define POPUPPOSITION_STARTBEFORE 4
|
|
|
|
#define POPUPPOSITION_ENDBEFORE 5
|
|
|
|
#define POPUPPOSITION_STARTAFTER 6
|
|
|
|
#define POPUPPOSITION_ENDAFTER 7
|
|
|
|
#define POPUPPOSITION_OVERLAP 8
|
|
|
|
#define POPUPPOSITION_AFTERPOINTER 9
|
|
|
|
|
|
|
|
#define POPUPPOSITION_HFLIP(v) (v ^ 1)
|
|
|
|
#define POPUPPOSITION_VFLIP(v) (v ^ 2)
|
|
|
|
|
2002-09-20 06:12:12 +04:00
|
|
|
#define INC_TYP_INTERVAL 1000 // 1s. If the interval between two keypresses is shorter than this,
|
2002-04-24 11:15:35 +04:00
|
|
|
// treat as a continue typing
|
2002-09-20 06:12:12 +04:00
|
|
|
// XXX, kyle.yuan@sun.com, there are 4 definitions for the same purpose:
|
|
|
|
// nsMenuPopupFrame.h, nsListControlFrame.cpp, listbox.xml, tree.xml
|
|
|
|
// need to find a good place to put them together.
|
|
|
|
// if someone changes one, please also change the other.
|
2002-04-24 11:15:35 +04:00
|
|
|
|
2012-09-15 01:17:08 +04:00
|
|
|
#define CONTEXT_MENU_OFFSET_PIXELS 2
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
1999-07-18 10:35:03 +04:00
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
class nsViewManager;
|
2013-01-03 17:23:11 +04:00
|
|
|
class nsView;
|
2006-03-15 01:48:09 +03:00
|
|
|
class nsMenuPopupFrame;
|
|
|
|
|
2008-12-05 19:37:31 +03:00
|
|
|
class nsMenuPopupFrame : public nsBoxFrame, public nsMenuParent
|
1999-07-18 10:35:03 +04:00
|
|
|
{
|
|
|
|
public:
|
2011-09-28 05:46:11 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsMenuPopupFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContext);
|
1999-07-18 10:35:03 +04:00
|
|
|
|
2008-12-05 19:37:31 +03:00
|
|
|
// nsMenuParent interface
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual nsMenuFrame* GetCurrentMenuItem() MOZ_OVERRIDE;
|
2012-09-14 20:10:08 +04:00
|
|
|
NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) MOZ_OVERRIDE;
|
|
|
|
virtual void CurrentMenuIsBeingDestroyed() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem) MOZ_OVERRIDE;
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// as popups are opened asynchronously, the popup pending state is used to
|
|
|
|
// prevent multiple requests from attempting to open the same popup twice
|
2007-08-03 18:05:07 +04:00
|
|
|
nsPopupState PopupState() { return mPopupState; }
|
|
|
|
void SetPopupState(nsPopupState aPopupState) { mPopupState = aPopupState; }
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
NS_IMETHOD SetActive(bool aActiveFlag) MOZ_OVERRIDE { return NS_OK; } // We don't care.
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual bool IsActive() MOZ_OVERRIDE { return false; }
|
|
|
|
virtual bool IsMenuBar() MOZ_OVERRIDE { return false; }
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When this popup is open, should clicks outside of it be consumed?
|
2011-10-17 18:59:28 +04:00
|
|
|
* Return true if the popup should rollup on an outside click,
|
2007-07-04 19:49:38 +04:00
|
|
|
* but consume that click so it can't be used for anything else.
|
2011-10-17 18:59:28 +04:00
|
|
|
* Return false to allow clicks outside the popup to activate content
|
2007-07-04 19:49:38 +04:00
|
|
|
* even when the popup is open.
|
|
|
|
* ---------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Should clicks outside of a popup be eaten?
|
|
|
|
*
|
|
|
|
* Menus Autocomplete Comboboxes
|
|
|
|
* Mac Eat No Eat
|
|
|
|
* Win No No Eat
|
|
|
|
* Unix Eat No Eat
|
|
|
|
*
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ConsumeOutsideClicks();
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual bool IsContextMenu() MOZ_OVERRIDE { return mIsContextMenu; }
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual bool MenuClosed() MOZ_OVERRIDE { return true; }
|
2000-02-09 12:34:35 +03:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void LockMenuUntilClosed(bool aLock) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsMenuLocked() MOZ_OVERRIDE { return mIsMenuLocked; }
|
2010-04-19 18:12:58 +04:00
|
|
|
|
2011-12-02 01:35:42 +04:00
|
|
|
nsIWidget* GetWidget();
|
1999-09-25 07:39:35 +04:00
|
|
|
|
1999-09-21 05:03:00 +04:00
|
|
|
// The dismissal listener gets created and attached to the window.
|
2007-07-04 19:49:38 +04:00
|
|
|
void AttachedDismissalListener();
|
1999-09-21 05:03:00 +04:00
|
|
|
|
1999-07-21 11:42:16 +04:00
|
|
|
// Overridden methods
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2001-09-10 11:34:54 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
1999-07-20 11:28:39 +04:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
1999-09-10 12:47:12 +04:00
|
|
|
|
2007-11-28 23:18:11 +03:00
|
|
|
// returns true if the popup is a panel with the noautohide attribute set to
|
|
|
|
// true. These panels do not roll up automatically.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsNoAutoHide() const;
|
2007-11-28 23:18:11 +03:00
|
|
|
|
2010-07-27 17:38:03 +04:00
|
|
|
nsPopupLevel PopupLevel() const
|
|
|
|
{
|
|
|
|
return PopupLevel(IsNoAutoHide());
|
|
|
|
}
|
2008-09-08 16:58:07 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
void EnsureWidget();
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
nsresult CreateWidgetForView(nsView* aView);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t GetShadowStyle();
|
1999-07-26 05:35:39 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void SetInitialChildList(ChildListID aListID,
|
2014-05-28 23:36:58 +04:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
2002-10-04 04:56:43 +04:00
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE;
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2010-05-13 17:42:57 +04:00
|
|
|
// layout, position and display the popup as needed
|
2014-01-28 20:28:45 +04:00
|
|
|
void LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu,
|
|
|
|
nsIFrame* aAnchor, bool aSizedToPopup);
|
2010-05-13 17:42:57 +04:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* GetRootViewForPopup(nsIFrame* aStartFrame);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// set the position of the popup either relative to the anchor aAnchorFrame
|
|
|
|
// (or the frame for mAnchorContent if aAnchorFrame is null) or at a specific
|
|
|
|
// point if a screen position (mScreenXPos and mScreenYPos) are set. The popup
|
2010-02-01 18:11:08 +03:00
|
|
|
// will be adjusted so that it is on screen. If aIsMove is true, then the popup
|
|
|
|
// is being moved, and should not be flipped.
|
2014-01-28 20:28:45 +04:00
|
|
|
nsresult SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aSizedToPopup);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasGeneratedChildren() { return mGeneratedChildren; }
|
2011-10-17 18:59:28 +04:00
|
|
|
void SetGeneratedChildren() { mGeneratedChildren = true; }
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// called when the Enter key is pressed while the popup is open. This will
|
2007-11-17 18:47:38 +03:00
|
|
|
// just pass the call down to the current menu, if any. If a current menu
|
|
|
|
// should be opened as a result, this method should return the frame for
|
|
|
|
// that menu, or null if no menu should be opened. Also, calling Enter will
|
|
|
|
// reset the current incremental search string, calculated in
|
|
|
|
// FindMenuWithShortcut.
|
2013-10-02 07:46:03 +04:00
|
|
|
nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2007-08-16 05:09:58 +04:00
|
|
|
nsPopupType PopupType() const { return mPopupType; }
|
2013-05-14 20:33:23 +04:00
|
|
|
bool IsMenu() MOZ_OVERRIDE { return mPopupType == ePopupTypeMenu; }
|
2012-09-14 20:10:08 +04:00
|
|
|
bool IsOpen() MOZ_OVERRIDE { return mPopupState == ePopupOpen || mPopupState == ePopupOpenAndVisible; }
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2014-01-31 17:27:43 +04:00
|
|
|
bool IsMouseTransparent() { return mMouseTransparent; }
|
2011-04-26 05:37:20 +04:00
|
|
|
|
2010-09-11 00:24:25 +04:00
|
|
|
static nsIContent* GetTriggerContent(nsMenuPopupFrame* aMenuPopupFrame);
|
2012-07-30 18:20:58 +04:00
|
|
|
void ClearTriggerContent() { mTriggerContent = nullptr; }
|
2010-08-09 20:17:19 +04:00
|
|
|
|
2007-08-03 18:05:07 +04:00
|
|
|
// returns true if the popup is in a content shell, or false for a popup in
|
|
|
|
// a chrome shell
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsInContentShell() { return mInContentShell; }
|
2007-08-03 18:05:07 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// the Initialize methods are used to set the anchor position for
|
|
|
|
// each way of opening a popup.
|
|
|
|
void InitializePopup(nsIContent* aAnchorContent,
|
2010-08-09 20:17:19 +04:00
|
|
|
nsIContent* aTriggerContent,
|
2007-07-04 19:49:38 +04:00
|
|
|
const nsAString& aPosition,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aXPos, int32_t aYPos,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAttributesOverride);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2008-04-24 01:25:34 +04:00
|
|
|
/**
|
|
|
|
* @param aIsContextMenu if true, then the popup is
|
|
|
|
* positioned at a slight offset from aXPos/aYPos to ensure the
|
|
|
|
* (presumed) mouse position is not over the menu.
|
|
|
|
*/
|
2010-08-09 20:17:19 +04:00
|
|
|
void InitializePopupAtScreen(nsIContent* aTriggerContent,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aXPos, int32_t aYPos,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsContextMenu);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
void InitializePopupWithAnchorAlign(nsIContent* aAnchorContent,
|
|
|
|
nsAString& aAnchor,
|
|
|
|
nsAString& aAlign,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aXPos, int32_t aYPos);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// indicate that the popup should be opened
|
2011-09-29 10:19:26 +04:00
|
|
|
void ShowPopup(bool aIsContextMenu, bool aSelectFirstItem);
|
2007-08-03 18:05:07 +04:00
|
|
|
// indicate that the popup should be hidden. The new state should either be
|
|
|
|
// ePopupClosed or ePopupInvisible.
|
2011-09-29 10:19:26 +04:00
|
|
|
void HidePopup(bool aDeselectMenu, nsPopupState aNewState);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// locate and return the menu frame that should be activated for the
|
|
|
|
// supplied key event. If doAction is set to true by this method,
|
|
|
|
// then the menu's action should be carried out, as if the user had pressed
|
|
|
|
// the Enter key. If doAction is false, the menu should just be highlighted.
|
|
|
|
// This method also handles incremental searching in menus so the user can
|
|
|
|
// type the first few letters of an item/s name to select it.
|
2011-09-29 10:19:26 +04:00
|
|
|
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool& doAction);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
void ClearIncrementalString() { mIncrementalString.Truncate(); }
|
2000-02-13 11:33:39 +03:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE { return nsGkAtoms::menuPopupFrame; }
|
2007-04-20 14:56:49 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("MenuPopup"), aResult);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
void EnsureMenuItemIsVisible(nsMenuFrame* aMenuFrame);
|
2001-06-05 03:03:24 +04:00
|
|
|
|
2012-09-29 15:36:09 +04:00
|
|
|
// Move the popup to the screen coordinate (aLeft, aTop) in CSS pixels.
|
|
|
|
// If aUpdateAttrs is true, and the popup already has left or top attributes,
|
|
|
|
// then those attributes are updated to the new location.
|
2009-02-17 18:51:11 +03:00
|
|
|
// The frame may be destroyed by this method.
|
2012-08-22 19:56:38 +04:00
|
|
|
void MoveTo(int32_t aLeft, int32_t aTop, bool aUpdateAttrs);
|
2001-09-10 11:34:54 +04:00
|
|
|
|
2012-10-23 16:11:13 +04:00
|
|
|
void MoveToAnchor(nsIContent* aAnchorContent,
|
|
|
|
const nsAString& aPosition,
|
|
|
|
int32_t aXPos, int32_t aYPos,
|
|
|
|
bool aAttributesOverride);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetAutoPosition();
|
|
|
|
void SetAutoPosition(bool aShouldAutoPosition);
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetConsumeRollupEvent(uint32_t aConsumeMode);
|
2001-09-10 11:34:54 +04:00
|
|
|
|
2009-09-01 15:22:31 +04:00
|
|
|
nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart);
|
2007-12-19 19:37:32 +03:00
|
|
|
|
2010-08-02 19:06:04 +04:00
|
|
|
// For a popup that should appear anchored at the given rect, determine
|
2009-12-23 21:45:44 +03:00
|
|
|
// the screen area that it is constrained by. This will be the available
|
|
|
|
// area of the screen the popup should be displayed on. Content popups,
|
|
|
|
// however, will also be constrained by the content area, given by
|
|
|
|
// aRootScreenRect. All coordinates are in app units.
|
2014-02-07 21:35:09 +04:00
|
|
|
// For non-toplevel popups (which will always be panels), we will also
|
|
|
|
// constrain them to the available screen rect, ie they will not fall
|
|
|
|
// underneath the taskbar, dock or other fixed OS elements.
|
|
|
|
nsRect GetConstraintRect(const nsRect& aAnchorRect, const nsRect& aRootScreenRect,
|
|
|
|
nsPopupLevel aPopupLevel);
|
2009-12-23 21:45:44 +03:00
|
|
|
|
|
|
|
// Determines whether the given edges of the popup may be moved, where
|
|
|
|
// aHorizontalSide and aVerticalSide are one of the NS_SIDE_* constants, or
|
|
|
|
// 0 for no movement in that direction. aChange is the distance to move on
|
|
|
|
// those sides. If will be reset to 0 if the side cannot be adjusted at all
|
|
|
|
// in that direction. For example, a popup cannot be moved if it is anchored
|
|
|
|
// on a particular side.
|
|
|
|
//
|
|
|
|
// Later, when bug 357725 is implemented, we can make this adjust aChange by
|
|
|
|
// the amount that the side can be resized, so that minimums and maximums
|
|
|
|
// can be taken into account.
|
2012-08-22 19:56:38 +04:00
|
|
|
void CanAdjustEdges(int8_t aHorizontalSide, int8_t aVerticalSide, nsIntPoint& aChange);
|
2009-12-23 21:45:44 +03:00
|
|
|
|
2010-07-27 17:38:02 +04:00
|
|
|
// Return true if the popup is positioned relative to an anchor.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAnchored() const { return mScreenXPos == -1 && mScreenYPos == -1; }
|
2010-07-27 17:38:02 +04:00
|
|
|
|
2010-09-21 21:53:01 +04:00
|
|
|
// Return the anchor if there is one.
|
|
|
|
nsIContent* GetAnchor() const { return mAnchorContent; }
|
|
|
|
|
2010-07-27 17:38:02 +04:00
|
|
|
// Return the screen coordinates of the popup, or (-1, -1) if anchored.
|
2012-09-29 15:36:09 +04:00
|
|
|
// This position is in CSS pixels.
|
2010-07-27 17:38:02 +04:00
|
|
|
nsIntPoint ScreenPosition() const { return nsIntPoint(mScreenXPos, mScreenYPos); }
|
|
|
|
|
2011-12-02 01:35:42 +04:00
|
|
|
nsIntPoint GetLastClientOffset() const { return mLastClientOffset; }
|
|
|
|
|
2013-04-19 04:47:27 +04:00
|
|
|
// Return the alignment of the popup
|
|
|
|
int8_t GetAlignmentPosition() const;
|
|
|
|
|
2013-05-09 02:59:03 +04:00
|
|
|
// Return the offset applied to the alignment of the popup
|
|
|
|
nscoord GetAlignmentOffset() const { return mAlignmentOffset; }
|
1999-07-18 10:35:03 +04:00
|
|
|
protected:
|
2006-03-15 01:48:09 +03:00
|
|
|
|
2010-07-27 17:38:03 +04:00
|
|
|
// returns the popup's level.
|
2011-09-29 10:19:26 +04:00
|
|
|
nsPopupLevel PopupLevel(bool aIsNoAutoHide) const;
|
2010-07-27 17:38:03 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// redefine to tell the box system not to move the views.
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual void GetLayoutFlags(uint32_t& aFlags) MOZ_OVERRIDE;
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
void InitPositionFromAnchorAlign(const nsAString& aAnchor,
|
|
|
|
const nsAString& aAlign);
|
2000-02-08 12:30:15 +03:00
|
|
|
|
2008-12-10 18:19:16 +03:00
|
|
|
// return the position where the popup should be, when it should be
|
|
|
|
// anchored at anchorRect. aHFlip and aVFlip will be set if the popup may be
|
|
|
|
// flipped in that direction if there is not enough space available.
|
2010-12-06 01:09:36 +03:00
|
|
|
nsPoint AdjustPositionForAnchorAlign(nsRect& anchorRect,
|
2010-10-13 23:41:37 +04:00
|
|
|
FlipStyle& aHFlip, FlipStyle& aVFlip);
|
2008-12-10 18:19:16 +03:00
|
|
|
|
|
|
|
// check if the popup will fit into the available space and resize it. This
|
|
|
|
// method handles only one axis at a time so is called twice, once for
|
|
|
|
// horizontal and once for vertical. All arguments are specified for this
|
|
|
|
// one axis. All coordinates are in app units relative to the screen.
|
|
|
|
// aScreenPoint - the point where the popup should appear
|
|
|
|
// aSize - the size of the popup
|
|
|
|
// aScreenBegin - the left or top edge of the screen
|
|
|
|
// aScreenEnd - the right or bottom edge of the screen
|
|
|
|
// aAnchorBegin - the left or top edge of the anchor rectangle
|
|
|
|
// aAnchorEnd - the right or bottom edge of the anchor rectangle
|
|
|
|
// aMarginBegin - the left or top margin of the popup
|
|
|
|
// aMarginEnd - the right or bottom margin of the popup
|
|
|
|
// aOffsetForContextMenu - the additional offset to add for context menus
|
2010-10-13 23:41:37 +04:00
|
|
|
// aFlip - how to flip or resize the popup when there isn't space
|
2009-12-23 21:45:44 +03:00
|
|
|
// aFlipSide - pointer to where current flip mode is stored
|
2008-12-10 18:19:16 +03:00
|
|
|
nscoord FlipOrResize(nscoord& aScreenPoint, nscoord aSize,
|
|
|
|
nscoord aScreenBegin, nscoord aScreenEnd,
|
|
|
|
nscoord aAnchorBegin, nscoord aAnchorEnd,
|
|
|
|
nscoord aMarginBegin, nscoord aMarginEnd,
|
2010-10-13 23:41:37 +04:00
|
|
|
nscoord aOffsetForContextMenu, FlipStyle aFlip,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aFlipSide);
|
2000-03-02 07:08:04 +03:00
|
|
|
|
2013-05-09 02:59:03 +04:00
|
|
|
// check if the popup can fit into the available space by "sliding" (i.e.,
|
|
|
|
// by having the anchor arrow slide along one axis and only resizing if that
|
|
|
|
// can't provide the requested size). Only one axis can be slid - the other
|
|
|
|
// axis is "flipped" as normal. This method can handle either axis, but is
|
|
|
|
// only called for the sliding axis. All coordinates are in app units
|
|
|
|
// relative to the screen.
|
|
|
|
// aScreenPoint - the point where the popup should appear
|
|
|
|
// aSize - the size of the popup
|
|
|
|
// aScreenBegin - the left or top edge of the screen
|
|
|
|
// aScreenEnd - the right or bottom edge of the screen
|
|
|
|
// aOffset - the amount by which the arrow must be slid such that it is
|
|
|
|
// still aligned with the anchor.
|
|
|
|
// Result is the new size of the popup, which will typically be the same
|
|
|
|
// as aSize, unless aSize is greater than the screen width/height.
|
|
|
|
nscoord SlideOrResize(nscoord& aScreenPoint, nscoord aSize,
|
|
|
|
nscoord aScreenBegin, nscoord aScreenEnd,
|
|
|
|
nscoord *aOffset);
|
|
|
|
|
2001-09-10 11:34:54 +04:00
|
|
|
// Move the popup to the position specified in its |left| and |top| attributes.
|
|
|
|
void MoveToAttributePosition();
|
|
|
|
|
2011-01-13 17:02:20 +03:00
|
|
|
/**
|
|
|
|
* Return whether the popup direction should be RTL.
|
|
|
|
* If the popup has an anchor, its direction is the anchor direction.
|
|
|
|
* Otherwise, its the general direction of the UI.
|
|
|
|
*
|
|
|
|
* Return whether the popup direction should be RTL.
|
|
|
|
*/
|
|
|
|
bool IsDirectionRTL() const {
|
|
|
|
return mAnchorContent && mAnchorContent->GetPrimaryFrame()
|
2013-02-17 01:51:02 +04:00
|
|
|
? mAnchorContent->GetPrimaryFrame()->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL
|
|
|
|
: StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
2011-01-13 17:02:20 +03:00
|
|
|
}
|
|
|
|
|
2011-04-29 17:51:05 +04:00
|
|
|
// Create a popup view for this frame. The view is added a child of the root
|
|
|
|
// view, and is initially hidden.
|
2013-03-20 05:47:48 +04:00
|
|
|
void CreatePopupView();
|
2011-04-29 17:51:05 +04:00
|
|
|
|
2009-05-12 14:13:09 +04:00
|
|
|
nsString mIncrementalString; // for incremental typing navigation
|
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// the content that the popup is anchored to, if any, which may be in a
|
|
|
|
// different document than the popup.
|
|
|
|
nsCOMPtr<nsIContent> mAnchorContent;
|
2000-02-09 12:34:35 +03:00
|
|
|
|
2010-08-09 20:17:19 +04:00
|
|
|
// the content that triggered the popup, typically the node where the mouse
|
|
|
|
// was clicked. It will be cleared when the popup is hidden.
|
|
|
|
nsCOMPtr<nsIContent> mTriggerContent;
|
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
nsMenuFrame* mCurrentMenu; // The current menu that is active.
|
2000-02-09 12:34:35 +03:00
|
|
|
|
2009-05-12 14:13:09 +04:00
|
|
|
// A popup's preferred size may be different than its actual size stored in
|
|
|
|
// mRect in the case where the popup was resized because it was too large
|
|
|
|
// for the screen. The preferred size mPrefSize holds the full size the popup
|
|
|
|
// would be before resizing. Computations are performed using this size.
|
|
|
|
nsSize mPrefSize;
|
2000-02-13 11:33:39 +03:00
|
|
|
|
2012-09-29 15:36:09 +04:00
|
|
|
// The position of the popup, in CSS pixels.
|
|
|
|
// The screen coordinates, if set to values other than -1,
|
|
|
|
// override mXPos and mYPos.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mXPos;
|
|
|
|
int32_t mYPos;
|
|
|
|
int32_t mScreenXPos;
|
|
|
|
int32_t mScreenYPos;
|
2013-05-09 02:59:03 +04:00
|
|
|
|
|
|
|
// If the panel prefers to "slide" rather than resize, then the arrow gets
|
|
|
|
// positioned at this offset (along either the x or y axis, depending on
|
|
|
|
// mPosition)
|
|
|
|
nscoord mAlignmentOffset;
|
|
|
|
|
2011-12-02 01:35:42 +04:00
|
|
|
// The value of the client offset of our widget the last time we positioned
|
|
|
|
// ourselves. We store this so that we can detect when it changes but the
|
|
|
|
// position of our widget didn't change.
|
|
|
|
nsIntPoint mLastClientOffset;
|
2006-03-15 01:48:09 +03:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
nsPopupType mPopupType; // type of popup
|
2007-08-03 18:05:07 +04:00
|
|
|
nsPopupState mPopupState; // open state of the popup
|
2000-03-01 06:12:51 +03:00
|
|
|
|
2009-05-12 14:13:09 +04:00
|
|
|
// popup alignment relative to the anchor node
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t mPopupAlignment;
|
|
|
|
int8_t mPopupAnchor;
|
2013-04-19 04:47:27 +04:00
|
|
|
int8_t mPosition;
|
|
|
|
|
2011-07-27 10:43:37 +04:00
|
|
|
// One of nsIPopupBoxObject::ROLLUP_DEFAULT/ROLLUP_CONSUME/ROLLUP_NO_CONSUME
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t mConsumeRollupEvent;
|
2014-01-23 00:09:03 +04:00
|
|
|
FlipType mFlip; // Whether to flip
|
2009-05-12 14:13:09 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsOpenChanged; // true if the open state changed since the last layout
|
|
|
|
bool mIsContextMenu; // true for context menus
|
2008-04-24 01:25:34 +04:00
|
|
|
// true if we need to offset the popup to ensure it's not under the mouse
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAdjustOffsetForContextMenu;
|
|
|
|
bool mGeneratedChildren; // true if the contents have been created
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mMenuCanOverlapOSBar; // can we appear over the taskbar/menubar?
|
|
|
|
bool mShouldAutoPosition; // Should SetPopupPosition be allowed to auto position popup?
|
|
|
|
bool mInContentShell; // True if the popup is in a content shell
|
|
|
|
bool mIsMenuLocked; // Should events inside this menu be ignored?
|
2014-01-31 17:27:43 +04:00
|
|
|
bool mMouseTransparent; // True if this is a popup is transparent to mouse events
|
2001-09-10 11:34:54 +04:00
|
|
|
|
2009-12-23 21:45:44 +03:00
|
|
|
// the flip modes that were used when the popup was opened
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHFlip;
|
|
|
|
bool mVFlip;
|
2009-12-23 21:45:44 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int8_t sDefaultLevelIsTop;
|
1999-07-18 10:35:03 +04:00
|
|
|
}; // class nsMenuPopupFrame
|
|
|
|
|
|
|
|
#endif
|