2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPopupBoxObject.h"
|
|
|
|
#include "nsIRootBox.h"
|
|
|
|
#include "nsBoxObject.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsMenuPopupFrame.h"
|
2011-06-03 12:38:23 -07:00
|
|
|
#include "nsClientRect.h"
|
2013-06-10 14:00:00 -07:00
|
|
|
#include "nsView.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsPopupBoxObject : public nsBoxObject,
|
|
|
|
public nsIPopupBoxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIPOPUPBOXOBJECT
|
|
|
|
|
|
|
|
nsPopupBoxObject() {}
|
|
|
|
protected:
|
|
|
|
virtual ~nsPopupBoxObject() {}
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
nsPopupSetFrame* GetPopupSetFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsPopupBoxObject, nsBoxObject, nsIPopupBoxObject)
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
nsPopupSetFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPopupBoxObject::GetPopupSetFrame()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
nsIRootBox* rootBox = nsIRootBox::GetRootBox(GetPresShell(false));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!rootBox)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
return rootBox->GetPopupSetFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::HidePopup()
|
|
|
|
{
|
2007-07-04 08:49:38 -07:00
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
2008-08-18 10:58:13 -07:00
|
|
|
if (pm && mContent)
|
2011-10-17 07:59:28 -07:00
|
|
|
pm->HidePopup(mContent, false, true, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2007-07-04 08:49:38 -07:00
|
|
|
nsPopupBoxObject::ShowPopup(nsIDOMElement* aAnchorElement,
|
|
|
|
nsIDOMElement* aPopupElement,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aXPos, int32_t aYPos,
|
2007-03-22 10:30:00 -07:00
|
|
|
const PRUnichar *aPopupType,
|
2007-07-04 08:49:38 -07:00
|
|
|
const PRUnichar *aAnchorAlignment,
|
2007-03-22 10:30:00 -07:00
|
|
|
const PRUnichar *aPopupAlignment)
|
|
|
|
{
|
2007-07-04 08:49:38 -07:00
|
|
|
NS_ENSURE_TRUE(aPopupElement, NS_ERROR_INVALID_ARG);
|
2007-06-29 15:15:59 -07:00
|
|
|
// srcContent can be null.
|
2007-06-29 12:04:45 -07:00
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
2008-08-18 10:58:13 -07:00
|
|
|
if (pm && mContent) {
|
2007-07-04 08:49:38 -07:00
|
|
|
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
|
|
|
|
nsAutoString popupType(aPopupType);
|
|
|
|
nsAutoString anchor(aAnchorAlignment);
|
|
|
|
nsAutoString align(aPopupAlignment);
|
|
|
|
pm->ShowPopupWithAnchorAlign(mContent, anchorContent, anchor, align,
|
|
|
|
aXPos, aYPos, popupType.EqualsLiteral("context"));
|
2007-06-29 15:15:59 -07:00
|
|
|
}
|
2007-07-04 08:49:38 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::OpenPopup(nsIDOMElement* aAnchorElement,
|
|
|
|
const nsAString& aPosition,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aXPos, int32_t aYPos,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsContextMenu,
|
|
|
|
bool aAttributesOverride,
|
2010-08-09 09:17:19 -07:00
|
|
|
nsIDOMEvent* aTriggerEvent)
|
2007-07-04 08:49:38 -07:00
|
|
|
{
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
2008-08-18 10:58:13 -07:00
|
|
|
if (pm && mContent) {
|
2007-07-04 08:49:38 -07:00
|
|
|
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
|
|
|
|
pm->ShowPopup(mContent, anchorContent, aPosition, aXPos, aYPos,
|
2011-10-17 07:59:28 -07:00
|
|
|
aIsContextMenu, aAttributesOverride, false, aTriggerEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPopupBoxObject::OpenPopupAtScreen(int32_t aXPos, int32_t aYPos,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsContextMenu,
|
2010-08-09 09:17:19 -07:00
|
|
|
nsIDOMEvent* aTriggerEvent)
|
2007-07-04 08:49:38 -07:00
|
|
|
{
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
2008-08-18 10:58:13 -07:00
|
|
|
if (pm && mContent)
|
2010-08-09 09:17:19 -07:00
|
|
|
pm->ShowPopupAtScreen(mContent, aXPos, aYPos, aIsContextMenu, aTriggerEvent);
|
2007-07-04 08:49:38 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPopupBoxObject::MoveTo(int32_t aLeft, int32_t aTop)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-23 05:11:09 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (menuPopupFrame) {
|
2011-10-17 07:59:28 -07:00
|
|
|
menuPopupFrame->MoveTo(aLeft, aTop, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-23 05:11:13 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::MoveToAnchor(nsIDOMElement* aAnchorElement,
|
|
|
|
const nsAString& aPosition,
|
|
|
|
int32_t aXPos, int32_t aYPos,
|
|
|
|
bool aAttributesOverride)
|
|
|
|
{
|
2012-10-30 12:55:00 -07:00
|
|
|
if (mContent) {
|
2012-10-23 05:11:13 -07:00
|
|
|
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
|
|
|
|
|
|
|
|
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(mContent->GetPrimaryFrame());
|
|
|
|
if (menuPopupFrame && menuPopupFrame->PopupState() == ePopupOpenAndVisible) {
|
|
|
|
menuPopupFrame->MoveToAnchor(anchorContent, aPosition, aXPos, aYPos, aAttributesOverride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPopupBoxObject::SizeTo(int32_t aWidth, int32_t aHeight)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-08-18 10:58:13 -07:00
|
|
|
if (!mContent)
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString width, height;
|
|
|
|
width.AppendInt(aWidth);
|
|
|
|
height.AppendInt(aHeight);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = mContent;
|
2012-11-06 16:58:01 -08:00
|
|
|
|
|
|
|
// We only want to pass aNotify=true to SetAttr once, but must make sure
|
|
|
|
// we pass it when a value is being changed. Thus, we check if the height
|
2012-11-16 18:04:39 -08:00
|
|
|
// is the same and if so, pass true when setting the width.
|
2012-11-06 16:58:01 -08:00
|
|
|
bool heightSame = content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::height, height, eCaseMatters);
|
|
|
|
|
|
|
|
content->SetAttr(kNameSpaceID_None, nsGkAtoms::width, width, heightSame);
|
2011-10-17 07:59:28 -07:00
|
|
|
content->SetAttr(kNameSpaceID_None, nsGkAtoms::height, height, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsPopupBoxObject::GetAutoPosition(bool* aShouldAutoPosition)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-23 05:11:09 -07:00
|
|
|
*aShouldAutoPosition = true;
|
|
|
|
|
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (menuPopupFrame) {
|
2007-11-28 12:18:11 -08:00
|
|
|
*aShouldAutoPosition = menuPopupFrame->GetAutoPosition();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsPopupBoxObject::SetAutoPosition(bool aShouldAutoPosition)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-23 05:11:09 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (menuPopupFrame) {
|
|
|
|
menuPopupFrame->SetAutoPosition(aShouldAutoPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsPopupBoxObject::EnableRollup(bool aShouldRollup)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-08-18 10:58:13 -07:00
|
|
|
// this does nothing now
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPopupBoxObject::SetConsumeRollupEvent(uint32_t aConsume)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 17:43:28 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (menuPopupFrame) {
|
|
|
|
menuPopupFrame->SetConsumeRollupEvent(aConsume);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsPopupBoxObject::EnableKeyboardNavigator(bool aEnableKeyboardNavigator)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-08-18 10:58:13 -07:00
|
|
|
if (!mContent)
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
// Use ignorekeys="true" on the popup instead of using this function.
|
|
|
|
if (aEnableKeyboardNavigator)
|
2011-10-17 07:59:28 -07:00
|
|
|
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, true);
|
2007-10-01 08:20:32 -07:00
|
|
|
else
|
2007-07-04 08:49:38 -07:00
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys,
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_LITERAL_STRING("true"), true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-08-15 16:52:47 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetPopupState(nsAString& aState)
|
|
|
|
{
|
2009-08-26 09:19:38 -07:00
|
|
|
// set this here in case there's no frame for the popup
|
|
|
|
aState.AssignLiteral("closed");
|
|
|
|
|
2012-10-23 05:11:09 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2007-08-15 16:52:47 -07:00
|
|
|
if (menuPopupFrame) {
|
|
|
|
switch (menuPopupFrame->PopupState()) {
|
|
|
|
case ePopupShowing:
|
|
|
|
case ePopupOpen:
|
|
|
|
aState.AssignLiteral("showing");
|
|
|
|
break;
|
|
|
|
case ePopupOpenAndVisible:
|
|
|
|
aState.AssignLiteral("open");
|
|
|
|
break;
|
|
|
|
case ePopupHiding:
|
|
|
|
case ePopupInvisible:
|
|
|
|
aState.AssignLiteral("hiding");
|
|
|
|
break;
|
2008-09-16 04:25:35 -07:00
|
|
|
case ePopupClosed:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Bad popup state");
|
|
|
|
break;
|
2007-08-15 16:52:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-09 09:17:19 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetTriggerNode(nsIDOMNode** aTriggerNode)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aTriggerNode = nullptr;
|
2010-08-09 09:17:19 -07:00
|
|
|
|
2012-10-23 05:11:09 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2012-07-30 17:43:28 -07:00
|
|
|
nsIContent* triggerContent = nsMenuPopupFrame::GetTriggerContent(menuPopupFrame);
|
2010-09-10 13:24:25 -07:00
|
|
|
if (triggerContent)
|
|
|
|
CallQueryInterface(triggerContent, aTriggerNode);
|
2010-08-09 09:17:19 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-08-15 16:52:47 -07:00
|
|
|
|
2010-09-21 10:53:01 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetAnchorNode(nsIDOMElement** aAnchor)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aAnchor = nullptr;
|
2010-09-21 10:53:01 -07:00
|
|
|
|
2012-10-23 05:11:09 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
|
2010-09-21 10:53:01 -07:00
|
|
|
if (!menuPopupFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsIContent* anchor = menuPopupFrame->GetAnchor();
|
|
|
|
if (anchor)
|
|
|
|
CallQueryInterface(anchor, aAnchor);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-03 12:38:23 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetOuterScreenRect(nsIDOMClientRect** aRect)
|
|
|
|
{
|
2013-03-17 00:55:17 -07:00
|
|
|
nsClientRect* rect = new nsClientRect(mContent);
|
2011-06-03 12:38:23 -07:00
|
|
|
|
|
|
|
NS_ADDREF(*aRect = rect);
|
|
|
|
|
2012-07-30 17:43:28 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
|
2011-06-03 12:38:23 -07:00
|
|
|
if (!menuPopupFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// Return an empty rectangle if the popup is not open.
|
|
|
|
nsPopupState state = menuPopupFrame->PopupState();
|
|
|
|
if (state != ePopupOpen && state != ePopupOpenAndVisible)
|
|
|
|
return NS_OK;
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = menuPopupFrame->GetView();
|
2011-06-03 12:38:23 -07:00
|
|
|
if (view) {
|
|
|
|
nsIWidget* widget = view->GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
nsIntRect screenRect;
|
|
|
|
widget->GetScreenBounds(screenRect);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t pp = menuPopupFrame->PresContext()->AppUnitsPerDevPixel();
|
2011-06-03 12:38:23 -07:00
|
|
|
rect->SetLayoutRect(screenRect.ToAppUnits(pp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-18 17:47:27 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetAlignmentPosition(nsAString& positionStr)
|
|
|
|
{
|
|
|
|
positionStr.Truncate();
|
|
|
|
|
|
|
|
// This needs to flush layout.
|
|
|
|
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(true));
|
|
|
|
if (!menuPopupFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
int8_t position = menuPopupFrame->GetAlignmentPosition();
|
|
|
|
switch (position) {
|
|
|
|
case POPUPPOSITION_AFTERSTART:
|
|
|
|
positionStr.AssignLiteral("after_start");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_AFTEREND:
|
|
|
|
positionStr.AssignLiteral("after_end");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_BEFORESTART:
|
|
|
|
positionStr.AssignLiteral("before_start");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_BEFOREEND:
|
|
|
|
positionStr.AssignLiteral("before_end");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_STARTBEFORE:
|
|
|
|
positionStr.AssignLiteral("start_before");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_ENDBEFORE:
|
|
|
|
positionStr.AssignLiteral("end_before");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_STARTAFTER:
|
|
|
|
positionStr.AssignLiteral("start_after");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_ENDAFTER:
|
|
|
|
positionStr.AssignLiteral("end_after");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_OVERLAP:
|
|
|
|
positionStr.AssignLiteral("overlap");
|
|
|
|
break;
|
|
|
|
case POPUPPOSITION_AFTERPOINTER:
|
|
|
|
positionStr.AssignLiteral("after_pointer");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Leave as an empty string.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-08 15:59:03 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPopupBoxObject::GetAlignmentOffset(int32_t *aAlignmentOffset)
|
|
|
|
{
|
2013-06-24 14:06:56 -07:00
|
|
|
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
|
2013-05-08 15:59:03 -07:00
|
|
|
if (!menuPopupFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
int32_t pp = nsDeviceContext::AppUnitsPerCSSPixel();
|
|
|
|
// Note that the offset might be along either the X or Y axis, but for the
|
|
|
|
// sake of simplicity we use a point with only the X axis set so we can
|
|
|
|
// use ToNearestPixels().
|
|
|
|
nsPoint appOffset(menuPopupFrame->GetAlignmentOffset(), 0);
|
|
|
|
nsIntPoint popupOffset = appOffset.ToNearestPixels(pp);
|
|
|
|
*aAlignmentOffset = popupOffset.x;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewPopupBoxObject(nsIBoxObject** aResult)
|
|
|
|
{
|
|
|
|
*aResult = new nsPopupBoxObject;
|
|
|
|
if (!*aResult)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|