This commit is contained in:
Robert Sayre 2010-09-21 13:56:39 -04:00
Родитель 8265f591cb ca29659ecd
Коммит 0d75348ba7
4 изменённых файлов: 29 добавлений и 2 удалений

Просмотреть файл

@ -43,7 +43,7 @@ interface nsIDOMElement;
interface nsIDOMNode;
interface nsIDOMEvent;
[scriptable, uuid(e4c3845b-97d2-4fdf-860e-949746d15fb9)]
[scriptable, uuid(548a9e3f-af78-42b0-a260-035ece15c19f)]
interface nsIPopupBoxObject : nsISupports
{
/**
@ -177,6 +177,12 @@ interface nsIPopupBoxObject : nsISupports
* null.
*/
readonly attribute nsIDOMNode triggerNode;
/**
* Retrieve the anchor that was specified to openPopup or for menupopups in a
* menu, the parent menu.
*/
readonly attribute nsIDOMElement anchorNode;
};
%{C++

Просмотреть файл

@ -325,6 +325,9 @@ public:
// Return true if the popup is positioned relative to an anchor.
PRBool IsAnchored() const { return mScreenXPos == -1 && mScreenYPos == -1; }
// Return the anchor if there is one.
nsIContent* GetAnchor() const { return mAnchorContent; }
// Return the screen coordinates of the popup, or (-1, -1) if anchored.
nsIntPoint ScreenPosition() const { return nsIntPoint(mScreenXPos, mScreenYPos); }

Просмотреть файл

@ -51,7 +51,6 @@
#include "nsGkAtoms.h"
#include "nsMenuPopupFrame.h"
class nsPopupBoxObject : public nsBoxObject,
public nsIPopupBoxObject
{
@ -275,6 +274,22 @@ nsPopupBoxObject::GetTriggerNode(nsIDOMNode** aTriggerNode)
return NS_OK;
}
NS_IMETHODIMP
nsPopupBoxObject::GetAnchorNode(nsIDOMElement** aAnchor)
{
*aAnchor = nsnull;
nsMenuPopupFrame *menuPopupFrame = GetMenuPopupFrame();
if (!menuPopupFrame)
return NS_OK;
nsIContent* anchor = menuPopupFrame->GetAnchor();
if (anchor)
CallQueryInterface(anchor, aAnchor);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult

Просмотреть файл

@ -27,6 +27,9 @@
<property name="triggerNode" readonly="true"
onget="return this.popupBoxObject.triggerNode"/>
<property name="anchorNode" readonly="true"
onget="return this.popupBoxObject.anchorNode"/>
<method name="openPopup">
<parameter name="aAnchorElement"/>
<parameter name="aPosition"/>