Fix for 94943. r=jag, sr=blake

This commit is contained in:
hyatt%netscape.com 2001-08-18 01:04:47 +00:00
parent 2061286828
commit 5583aaa00b
36 changed files with 981 additions and 826 deletions

View File

@ -2357,8 +2357,9 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
contractID += "-iframe";
else if (tag.get() == nsXULAtoms::menu)
contractID += "-menu";
else if (tag.get() == nsXULAtoms::popupset)
contractID += "-popupset";
else if (tag.get() == nsXULAtoms::popup || tag.get() == nsXULAtoms::menupopup ||
tag.get() == nsXULAtoms::tooltip)
contractID += "-popup";
else if (tag.get() == nsXULAtoms::tree)
contractID += "-tree";
else if (tag.get() == nsXULAtoms::scrollbox)

View File

@ -104,7 +104,7 @@ XUL_ATOM(menutobedisplayed, "menutobedisplayed") // The menu is about to be disp
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
XUL_ATOM(popupset, "popupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(popupgroup, "popupgroup") // Contains popup menus, context menus, and tooltips
XUL_ATOM(popup, "popup") // The popup for a context menu, popup menu, or tooltip
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(popupanchor, "popupanchor") // Anchor for popups

View File

@ -2065,7 +2065,7 @@ static PRBool CanHaveBinding(nsIAtom* aTag) {
// for display: none elts anyway, so we're getting into a real edge
// case.
return (aTag != nsXULAtoms::broadcaster) && (aTag != nsXULAtoms::commandset) &&
(aTag != nsXULAtoms::commands) && (aTag != nsXULAtoms::command) && (aTag != nsXULAtoms::popupset) &&
(aTag != nsXULAtoms::commands) && (aTag != nsXULAtoms::command) && (aTag != nsXULAtoms::popupgroup) &&
(aTag != nsXULAtoms::broadcasterset) && (aTag != nsXULAtoms::templateAtom) &&
(aTag != nsXULAtoms::box) && (aTag != nsXULAtoms::hbox) && (aTag != nsXULAtoms::vbox) &&
(aTag != nsXULAtoms::stack) && (aTag != nsXULAtoms::spring);

View File

@ -56,7 +56,7 @@
#include "nsIDOMEventTarget.h"
#include "nsIBoxObject.h"
#include "nsIPopupSetBoxObject.h"
#include "nsIPopupBoxObject.h"
#include "nsIMenuBoxObject.h"
// for event firing in context menus
@ -613,15 +613,13 @@ XULPopupListenerImpl :: ClosePopup ( )
}
if ( mPopupContent ) {
nsCOMPtr<nsIDOMNode> parent;
mPopupContent->GetParentNode(getter_AddRefs(parent));
nsCOMPtr<nsIDOMXULElement> popupSetElement(do_QueryInterface(parent));
nsCOMPtr<nsIDOMXULElement> popupElement(do_QueryInterface(mPopupContent));
nsCOMPtr<nsIBoxObject> boxObject;
if (popupSetElement)
popupSetElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsIPopupSetBoxObject> popupSetObject(do_QueryInterface(boxObject));
if (popupSetObject)
popupSetObject->DestroyPopup();
if (popupElement)
popupElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsIPopupBoxObject> popupObject(do_QueryInterface(boxObject));
if (popupObject)
popupObject->HidePopup();
mPopupContent = nsnull; // release the popup
@ -791,8 +789,12 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
nsAutoString identifier;
mElement->GetAttribute(type, identifier);
if (identifier.IsEmpty())
return rv;
if (identifier.IsEmpty()) {
if (type.EqualsIgnoreCase("popup"))
mElement->GetAttribute(NS_LITERAL_STRING("menu"), identifier);
if (identifier.IsEmpty())
return rv;
}
// Try to find the popup content and the document. We don't use FindDocumentForNode()
// in this case because we need the nsIDocument interface anyway for the script
@ -815,18 +817,17 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
nsCOMPtr<nsIDOMElement> popupContent;
if (identifier == NS_LITERAL_STRING("_child")) {
nsCOMPtr<nsIContent> popupset;
nsCOMPtr<nsIContent> popup;
GetImmediateChild(content, nsXULAtoms::popupset, getter_AddRefs(popupset));
if (popupset) {
GetImmediateChild(popupset, nsXULAtoms::popup, getter_AddRefs(popup));
if (popup)
popupContent = do_QueryInterface(popup);
} else {
nsIAtom* tag = (popupType == eXULPopupType_tooltip) ? nsXULAtoms::tooltip : nsXULAtoms::menupopup;
GetImmediateChild(content, tag, getter_AddRefs(popup));
if (popup)
popupContent = do_QueryInterface(popup);
else {
nsCOMPtr<nsIDOMDocumentXBL> nsDoc(do_QueryInterface(xulDocument));
nsCOMPtr<nsIDOMXULElement> xulElement(do_QueryInterface(content));
nsCOMPtr<nsIDOMNodeList> list;
nsDoc->GetAnonymousNodes(xulElement, getter_AddRefs(list));
nsDoc->GetAnonymousNodes(mElement, getter_AddRefs(list));
if (list) {
PRUint32 ctr,listLength;
nsCOMPtr<nsIDOMNode> node;
@ -836,10 +837,8 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
nsCOMPtr<nsIContent> childContent(do_QueryInterface(node));
nsCOMPtr<nsIAtom> childTag;
childContent->GetTag(*getter_AddRefs(childTag));
if (childTag.get() == nsXULAtoms::popupset) {
GetImmediateChild(childContent, nsXULAtoms::popup, getter_AddRefs(popup));
if (popup)
popupContent = do_QueryInterface(popup);
if (childTag.get() == tag) {
popupContent = do_QueryInterface(childContent);
break;
}
}
@ -879,20 +878,14 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
if (!anchorAlignment.IsEmpty() && !popupAlignment.IsEmpty())
xPos = yPos = -1;
nsCOMPtr<nsIDOMNode> parent;
mPopupContent->GetParentNode(getter_AddRefs(parent));
nsCOMPtr<nsIDOMXULElement> popupSetElement(do_QueryInterface(parent));
nsCOMPtr<nsIBoxObject> boxObject;
if (popupSetElement)
popupSetElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsIPopupSetBoxObject> popupSetObject(do_QueryInterface(boxObject));
nsCOMPtr<nsIMenuBoxObject> menuObject(do_QueryInterface(boxObject));
if (popupSetObject)
popupSetObject->CreatePopup(mElement, mPopupContent, xPos, yPos,
type.get(), anchorAlignment.get(),
popupAlignment.get());
else if (menuObject)
menuObject->OpenMenu(PR_TRUE);
nsCOMPtr<nsIBoxObject> popupBox;
nsCOMPtr<nsIDOMXULElement> xulPopupElt(do_QueryInterface(mPopupContent));
xulPopupElt->GetBoxObject(getter_AddRefs(popupBox));
nsCOMPtr<nsIPopupBoxObject> popupBoxObject(do_QueryInterface(popupBox));
if (popupBoxObject)
popupBoxObject->ShowPopup(mElement, mPopupContent, xPos, yPos,
type.get(), anchorAlignment.get(),
popupAlignment.get());
}
}
}

View File

@ -6580,8 +6580,9 @@ nsXULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
contractID += "-iframe";
else if (tag.get() == nsXULAtoms::menu)
contractID += "-menu";
else if (tag.get() == nsXULAtoms::popupset)
contractID += "-popupset";
else if (tag.get() == nsXULAtoms::popup || tag.get() == nsXULAtoms::menupopup ||
tag.get() == nsXULAtoms::tooltip)
contractID += "-popup";
else if (tag.get() == nsXULAtoms::tree)
contractID += "-tree";
else if (tag.get() == nsXULAtoms::scrollbox)

View File

@ -55,16 +55,16 @@
<button id="clearButton" label="&removeall.label;" oncommand="ClearAll()"/>
</vbox>
<iframe id="panelFrame" name="panelFrame" style="width:0px" flex="7"/>
<script type="application/x-javascript">
<![CDATA[
document.getElementById("panelFrame").setAttribute("src", "chrome://communicator-region/locale/wallet/WalletName.xul");
document.getElementById("panelFrame").setAttribute("tag", "" );
]]>
</script>
</hbox>
<separator/>
<hbox id="okCancelButtonsRight" />
<script type="application/x-javascript">
<![CDATA[
document.getElementById("panelFrame").setAttribute("src", "chrome://communicator-region/locale/wallet/WalletName.xul");
document.getElementById("panelFrame").setAttribute("tag", "" );
]]>
</script>
</window>

View File

@ -55,16 +55,16 @@
<button id="clearButton" label="&removeall.label;" oncommand="ClearAll()"/>
</vbox>
<iframe id="panelFrame" name="panelFrame" style="width:0px" flex="7"/>
<script type="application/x-javascript">
<![CDATA[
document.getElementById("panelFrame").setAttribute("src", "chrome://communicator-region/locale/wallet/WalletName.xul");
document.getElementById("panelFrame").setAttribute("tag", "" );
]]>
</script>
</hbox>
<separator/>
<hbox id="okCancelButtonsRight" />
<script type="application/x-javascript">
<![CDATA[
document.getElementById("panelFrame").setAttribute("src", "chrome://communicator-region/locale/wallet/WalletName.xul");
document.getElementById("panelFrame").setAttribute("tag", "" );
]]>
</script>
</window>

View File

@ -100,6 +100,7 @@ static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID);
#include "nsBox.h"
#ifdef INCLUDE_XUL
#include "nsIRootBox.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#endif
@ -5389,6 +5390,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
nsresult rv = NS_OK;
PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isFixedPositioned = PR_FALSE;
PRBool isPopup = PR_FALSE;
PRBool isReplaced = PR_FALSE;
PRBool frameHasBeenInitialized = PR_FALSE;
@ -5562,12 +5564,22 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
rv = NS_NewMenuBarFrame(aPresShell, &newFrame);
#endif
}
else if (aTag == nsXULAtoms::popupset) {
else if (aTag == nsXULAtoms::popupgroup) {
// This frame contains child popups
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewPopupSetFrame(aPresShell, &newFrame);
((nsPopupSetFrame*) newFrame)->SetFrameConstructor(this);
// Locate the root frame and tell it about the popupgroup.
nsIFrame* rootFrame;
aState.mFrameManager->GetRootFrame(&rootFrame);
if (rootFrame)
rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (rootBox)
rootBox->SetPopupSetFrame(newFrame);
}
else if (aTag == nsXULAtoms::scrollbox) {
rv = NS_NewScrollBoxFrame(aPresShell, &newFrame);
@ -5871,6 +5883,16 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewMenuPopupFrame(aPresShell, &newFrame);
// If a popup is inside a menu, then the menu understands the complex
// rules/behavior governing the cascade of multiple menu popups and can handle
// having the real popup frame placed under it as a child.
// If, however, the parent is *not* a menu frame, then we need to create
// a placeholder frame for the popup, and then we add the popup frame to the
// root popup set (that manages all such "detached" popups).
nsCOMPtr<nsIMenuFrame> menuFrame(do_QueryInterface(aParentFrame));
if (!menuFrame)
isPopup = PR_TRUE;
}
}
}
@ -5948,11 +5970,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
}
// Add the new frame to our list of frame items.
aFrameItems.AddChild(topFrame);
// If the frame is absolutely positioned, then create a placeholder frame
if (isAbsolutelyPositioned || isFixedPositioned) {
if (isAbsolutelyPositioned || isFixedPositioned || isPopup) {
nsIFrame* placeholderFrame;
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aContent,
@ -5961,13 +5980,33 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
// Add the positioned frame to its containing block's list of child frames
if (isAbsolutelyPositioned) {
aState.mAbsoluteItems.AddChild(newFrame);
} else {
} else if (isFixedPositioned) {
aState.mFixedItems.AddChild(newFrame);
} else if (isPopup) {
// Locate the root popup set and add ourselves to the popup set's list
// of popup frames.
nsIFrame* rootFrame;
aState.mFrameManager->GetRootFrame(&rootFrame);
if (rootFrame)
rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (rootBox) {
nsIFrame* popupSetFrame;
rootBox->GetPopupSetFrame(&popupSetFrame);
if (popupSetFrame) {
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
if (popupSet)
popupSet->AddPopupFrame(newFrame);
}
}
}
// Add the placeholder frame to the flow
aFrameItems.AddChild(placeholderFrame);
}
else
// Add the new frame to our list of frame items.
aFrameItems.AddChild(topFrame);
}
// addToHashTable:
@ -9355,6 +9394,24 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
const nsStyleDisplay* display;
childFrame->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)display);
if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) {
// Get the placeholder frame
nsIFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame, &placeholderFrame);
// Remove the mapping from the frame to its placeholder
frameManager->SetPlaceholderFrameFor(childFrame, nsnull);
// Now we remove the popup frame
if (placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
nsnull, placeholderFrame);
return NS_OK;
}
}
if (display->IsFloating()) {
#ifdef NOISY_FIRST_LETTER
printf(" ==> child display is still floating!\n");

View File

@ -183,9 +183,9 @@
#define NS_MENUBOXOBJECT_CID \
{ 0xaa40253b, 0x4c42, 0x4056, { 0x81, 0x32, 0x37, 0xbc, 0xd0, 0x78, 0x62, 0xfd } }
// {21726976-AC6D-4e2a-BE25-5AB683D67D25}
#define NS_POPUPSETBOXOBJECT_CID \
{ 0x21726976, 0xac6d, 0x4e2a, { 0xbe, 0x25, 0x5a, 0xb6, 0x83, 0xd6, 0x7d, 0x25 } }
// {6C392C62-1AB1-4de7-BFC6-ED4F9FC7749A}
#define NS_POPUPBOXOBJECT_CID \
{ 0x6c392c62, 0x1ab1, 0x4de7, { 0xbf, 0xc6, 0xed, 0x4f, 0x9f, 0xc7, 0x74, 0x9a } }
// {31246420-A2F7-4933-AE71-79BBD5D94B04}
#define NS_BROWSERBOXOBJECT_CID \

View File

@ -155,7 +155,7 @@ extern nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewEditorBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewPopupSetBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult);
extern nsresult NS_NewOutlinerBoxObject(nsIBoxObject** aResult);
@ -196,7 +196,7 @@ MAKE_CTOR(CreateNewPrintContext, nsIPrintContext, NS_NewPrintConte
MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject)
MAKE_CTOR(CreateNewTreeBoxObject, nsIBoxObject, NS_NewTreeBoxObject)
MAKE_CTOR(CreateNewMenuBoxObject, nsIBoxObject, NS_NewMenuBoxObject)
MAKE_CTOR(CreateNewPopupSetBoxObject, nsIBoxObject, NS_NewPopupSetBoxObject)
MAKE_CTOR(CreateNewPopupBoxObject, nsIBoxObject, NS_NewPopupBoxObject)
MAKE_CTOR(CreateNewBrowserBoxObject, nsIBoxObject, NS_NewBrowserBoxObject)
MAKE_CTOR(CreateNewEditorBoxObject, nsIBoxObject, NS_NewEditorBoxObject)
MAKE_CTOR(CreateNewIFrameBoxObject, nsIBoxObject, NS_NewIFrameBoxObject)
@ -275,10 +275,10 @@ static nsModuleComponentInfo gComponents[] = {
"@mozilla.org/layout/xul-boxobject-menu;1",
CreateNewMenuBoxObject },
{ "XUL PopupSet Box Object",
NS_POPUPSETBOXOBJECT_CID,
"@mozilla.org/layout/xul-boxobject-popupset;1",
CreateNewPopupSetBoxObject },
{ "XUL Popup Box Object",
NS_POPUPBOXOBJECT_CID,
"@mozilla.org/layout/xul-boxobject-popup;1",
CreateNewPopupBoxObject },
{ "XUL Browser Box Object",
NS_BROWSERBOXOBJECT_CID,

View File

@ -100,6 +100,7 @@ static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID);
#include "nsBox.h"
#ifdef INCLUDE_XUL
#include "nsIRootBox.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#endif
@ -5389,6 +5390,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
nsresult rv = NS_OK;
PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isFixedPositioned = PR_FALSE;
PRBool isPopup = PR_FALSE;
PRBool isReplaced = PR_FALSE;
PRBool frameHasBeenInitialized = PR_FALSE;
@ -5562,12 +5564,22 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
rv = NS_NewMenuBarFrame(aPresShell, &newFrame);
#endif
}
else if (aTag == nsXULAtoms::popupset) {
else if (aTag == nsXULAtoms::popupgroup) {
// This frame contains child popups
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewPopupSetFrame(aPresShell, &newFrame);
((nsPopupSetFrame*) newFrame)->SetFrameConstructor(this);
// Locate the root frame and tell it about the popupgroup.
nsIFrame* rootFrame;
aState.mFrameManager->GetRootFrame(&rootFrame);
if (rootFrame)
rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (rootBox)
rootBox->SetPopupSetFrame(newFrame);
}
else if (aTag == nsXULAtoms::scrollbox) {
rv = NS_NewScrollBoxFrame(aPresShell, &newFrame);
@ -5871,6 +5883,16 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewMenuPopupFrame(aPresShell, &newFrame);
// If a popup is inside a menu, then the menu understands the complex
// rules/behavior governing the cascade of multiple menu popups and can handle
// having the real popup frame placed under it as a child.
// If, however, the parent is *not* a menu frame, then we need to create
// a placeholder frame for the popup, and then we add the popup frame to the
// root popup set (that manages all such "detached" popups).
nsCOMPtr<nsIMenuFrame> menuFrame(do_QueryInterface(aParentFrame));
if (!menuFrame)
isPopup = PR_TRUE;
}
}
}
@ -5948,11 +5970,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
}
// Add the new frame to our list of frame items.
aFrameItems.AddChild(topFrame);
// If the frame is absolutely positioned, then create a placeholder frame
if (isAbsolutelyPositioned || isFixedPositioned) {
if (isAbsolutelyPositioned || isFixedPositioned || isPopup) {
nsIFrame* placeholderFrame;
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aContent,
@ -5961,13 +5980,33 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
// Add the positioned frame to its containing block's list of child frames
if (isAbsolutelyPositioned) {
aState.mAbsoluteItems.AddChild(newFrame);
} else {
} else if (isFixedPositioned) {
aState.mFixedItems.AddChild(newFrame);
} else if (isPopup) {
// Locate the root popup set and add ourselves to the popup set's list
// of popup frames.
nsIFrame* rootFrame;
aState.mFrameManager->GetRootFrame(&rootFrame);
if (rootFrame)
rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (rootBox) {
nsIFrame* popupSetFrame;
rootBox->GetPopupSetFrame(&popupSetFrame);
if (popupSetFrame) {
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
if (popupSet)
popupSet->AddPopupFrame(newFrame);
}
}
}
// Add the placeholder frame to the flow
aFrameItems.AddChild(placeholderFrame);
}
else
// Add the new frame to our list of frame items.
aFrameItems.AddChild(topFrame);
}
// addToHashTable:
@ -9355,6 +9394,24 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
const nsStyleDisplay* display;
childFrame->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)display);
if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) {
// Get the placeholder frame
nsIFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame, &placeholderFrame);
// Remove the mapping from the frame to its placeholder
frameManager->SetPlaceholderFrameFor(childFrame, nsnull);
// Now we remove the popup frame
if (placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
DeletingFrameSubtree(aPresContext, shell, frameManager, placeholderFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
nsnull, placeholderFrame);
return NS_OK;
}
}
if (display->IsFloating()) {
#ifdef NOISY_FIRST_LETTER
printf(" ==> child display is still floating!\n");

View File

@ -42,7 +42,7 @@ XPIDLSRCS= nsIBoxObject.idl \
nsIBoxPaintManager.idl \
nsITreeBoxObject.idl \
nsIScrollBoxObject.idl \
nsIPopupSetBoxObject.idl \
nsIPopupBoxObject.idl \
nsIMenuBoxObject.idl \
nsIBrowserBoxObject.idl \
nsIIFrameBoxObject.idl \

View File

@ -33,7 +33,7 @@ XPIDLSRCS= .\nsIBoxObject.idl \
.\nsIBoxPaintManager.idl \
.\nsITreeBoxObject.idl \
.\nsIScrollBoxObject.idl \
.\nsIPopupSetBoxObject.idl \
.\nsIPopupBoxObject.idl \
.\nsIMenuBoxObject.idl \
.\nsIBrowserBoxObject.idl \
.\nsIIFrameBoxObject.idl \

View File

@ -27,22 +27,18 @@
interface nsIDOMElement;
[scriptable, uuid(A56A6F82-5BE4-4c47-930B-10BDB0F4F854)]
interface nsIPopupSetBoxObject : nsISupports
[scriptable, uuid(33C60E14-5150-4876-9A96-2732557E6895)]
interface nsIPopupBoxObject : nsISupports
{
void createPopup(in nsIDOMElement srcContent, in nsIDOMElement popupContent,
in long xpos, in long ypos,
in wstring popupType, in wstring anchorAlignment,
in wstring popupAlignment);
void showPopup(in nsIDOMElement srcContent, in nsIDOMElement popupContent,
in long xpos, in long ypos,
in wstring popupType, in wstring anchorAlignment,
in wstring popupAlignment);
void hidePopup();
void destroyPopup();
attribute nsIDOMElement activeChild;
};
%{C++
nsresult
NS_NewPopupSetBoxObject(nsIBoxObject** aResult);
NS_NewPopupBoxObject(nsIBoxObject** aResult);
%}

View File

@ -38,16 +38,14 @@ class nsIPopupSetFrame : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPOPUPSETFRAME_IID; return iid; }
NS_IMETHOD CreatePopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment) = 0;
NS_IMETHOD ShowPopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment) = 0;
NS_IMETHOD HidePopup(nsIFrame* aPopup) = 0;
NS_IMETHOD DestroyPopup(nsIFrame* aPopup) = 0;
NS_IMETHOD HidePopup() = 0;
NS_IMETHOD DestroyPopup() = 0;
NS_IMETHOD GetActiveChild(nsIDOMElement** aResult)=0;
NS_IMETHOD SetActiveChild(nsIDOMElement* aChild)=0;
NS_IMETHOD AddPopupFrame(nsIFrame* aPopup) = 0;
};
#endif

View File

@ -47,7 +47,7 @@ CPPSRCS = \
nsEditorBoxObject.cpp \
nsMenuBoxObject.cpp \
nsTreeBoxObject.cpp \
nsPopupSetBoxObject.cpp \
nsPopupBoxObject.cpp \
nsBoxObject.cpp \
nsGridLayout.cpp \
nsObeliskLayout.cpp \

View File

@ -35,7 +35,7 @@ CPPSRCS= \
nsBrowserBoxObject.cpp \
nsTreeBoxObject.cpp \
nsScrollBoxObject.cpp \
nsPopupSetBoxObject.cpp \
nsPopupBoxObject.cpp \
nsMenuBoxObject.cpp \
nsBoxObject.cpp \
nsGridLayout.cpp \
@ -94,7 +94,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsBrowserBoxObject.obj \
.\$(OBJDIR)\nsTreeBoxObject.obj \
.\$(OBJDIR)\nsScrollBoxObject.obj \
.\$(OBJDIR)\nsPopupSetBoxObject.obj \
.\$(OBJDIR)\nsPopupBoxObject.obj \
.\$(OBJDIR)\nsMenuBoxObject.obj \
.\$(OBJDIR)\nsBoxObject.obj \
.\$(OBJDIR)\nsGridLayout.obj \

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt (hyatt@netscape.com)
*/
#ifndef nsIRootBox_h___
#define nsIRootBox_h___
#include "nsISupports.h"
class nsIFrame;
// {DF05F6AB-320B-4e06-AFB3-E39E632A7555}
#define NS_IROOTBOX_IID \
{ 0xdf05f6ab, 0x320b, 0x4e06, { 0xaf, 0xb3, 0xe3, 0x9e, 0x63, 0x2a, 0x75, 0x55 } }
class nsIRootBox : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IROOTBOX_IID; return iid; }
NS_IMETHOD GetPopupSetFrame(nsIFrame** aResult)=0;
NS_IMETHOD SetPopupSetFrame(nsIFrame* aPopupSet)=0;
};
#endif

View File

@ -54,12 +54,40 @@
#include "nsIScrollableView.h"
#include "nsIFrameManager.h"
#include "nsGUIEvent.h"
#include "nsIRootBox.h"
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
static nsIPopupSetFrame*
GetPopupSetFrame(nsIPresContext* aPresContext)
{
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsIFrame* rootFrame;
shell->GetRootFrame(&rootFrame);
if (!rootFrame)
return nsnull;
if (rootFrame)
rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (!rootBox)
return NS_OK;
nsIFrame* popupSetFrame;
rootBox->GetPopupSetFrame(&popupSetFrame);
if (!popupSetFrame)
return nsnull;
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
return popupSet;
}
// NS_NewMenuPopupFrame
//
// Wrapper for creating a new menu popup container
@ -191,6 +219,143 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
return rv;
}
NS_IMETHODIMP
nsMenuPopupFrame::MarkStyleChange(nsBoxLayoutState& aState)
{
NeedsRecalc();
if (HasStyleChange())
return NS_OK;
// iterate through all children making them dirty
MarkChildrenStyleChange();
nsCOMPtr<nsIBoxLayout> layout;
GetLayoutManager(getter_AddRefs(layout));
if (layout)
layout->BecameDirty(this, aState);
nsIBox* parent = nsnull;
GetParentBox(&parent);
if (parent)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsCOMPtr<nsIBox> box(do_QueryInterface(popupSet));
if (box) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
nsIFrame* frame = nsnull;
GetFrame(&frame);
nsIFrame* parentFrame = nsnull;
frame->GetParent(&parentFrame);
nsCOMPtr<nsIPresShell> shell;
aState.GetPresShell(getter_AddRefs(shell));
return parentFrame->ReflowDirtyChild(shell, frame);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState)
{
NeedsRecalc();
nsFrameState state;
nsIFrame* frame;
GetFrame(&frame);
frame->GetFrameState(&state);
// only reflow if we aren't already dirty.
if (state & NS_FRAME_IS_DIRTY) {
#ifdef DEBUG_COELESCED
Coelesced();
#endif
return NS_OK;
}
state |= NS_FRAME_IS_DIRTY;
frame->SetFrameState(state);
nsCOMPtr<nsIBoxLayout> layout;
GetLayoutManager(getter_AddRefs(layout));
if (layout)
layout->BecameDirty(this, aState);
if (state & NS_FRAME_HAS_DIRTY_CHILDREN) {
#ifdef DEBUG_COELESCED
Coelesced();
#endif
return NS_OK;
}
nsIBox* parent = nsnull;
GetParentBox(&parent);
if (parent)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsCOMPtr<nsIBox> box(do_QueryInterface(popupSet));
if (box) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
nsIFrame* parentFrame = nsnull;
frame->GetParent(&parentFrame);
nsCOMPtr<nsIPresShell> shell;
aState.GetPresShell(getter_AddRefs(shell));
return parentFrame->ReflowDirtyChild(shell, frame);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
{
nsFrameState state;
nsIFrame* frame;
GetFrame(&frame);
frame->GetFrameState(&state);
if (aChild != nsnull) {
nsCOMPtr<nsIBoxLayout> layout;
GetLayoutManager(getter_AddRefs(layout));
if (layout)
layout->ChildBecameDirty(this, aState, aChild);
}
// if we are not dirty mark ourselves dirty and tell our parent we are dirty too.
if (!(state & NS_FRAME_HAS_DIRTY_CHILDREN)) {
// Mark yourself as dirty and needing to be recalculated
state |= NS_FRAME_HAS_DIRTY_CHILDREN;
frame->SetFrameState(state);
NeedsRecalc();
nsIBox* parentBox = nsnull;
GetParentBox(&parentBox);
if (parentBox)
return parentBox->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsCOMPtr<nsIBox> box(do_QueryInterface(popupSet));
if (box) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else
return nsBox::RelayoutDirtyChild(aState, aChild);
}
}
return NS_OK;
}
void
nsMenuPopupFrame::GetLayoutFlags(PRUint32& aFlags)
{
@ -1385,17 +1550,15 @@ nsMenuPopupFrame::HideChain()
nsIFrame* frame;
GetParent(&frame);
if (frame) {
nsCOMPtr<nsIPopupSetFrame> popupSetFrame = do_QueryInterface(frame);
if (popupSetFrame) {
// Destroy the popup.
popupSetFrame->HidePopup();
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame) {
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext);
if (popupSetFrame)
// Hide the popup.
popupSetFrame->HidePopup(this);
return NS_OK;
}
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame)
return NS_OK;
menuFrame->ActivateMenu(PR_FALSE);
menuFrame->SelectMenu(PR_FALSE);
@ -1420,17 +1583,15 @@ nsMenuPopupFrame::DismissChain()
nsIFrame* frame;
GetParent(&frame);
if (frame) {
nsCOMPtr<nsIPopupSetFrame> popupSetFrame = do_QueryInterface(frame);
if (popupSetFrame) {
// Destroy the popup.
popupSetFrame->DestroyPopup();
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame) {
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext);
if (popupSetFrame)
// Destroy the popup.
popupSetFrame->DestroyPopup(this);
return NS_OK;
}
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame)
return NS_OK;
menuFrame->OpenMenu(PR_FALSE);
// Get the parent.

View File

@ -110,6 +110,10 @@ public:
nsFramePaintLayer aWhichLayer,
nsIFrame** aFrame);
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState);
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState);
NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild);
void GetViewOffset(nsIView* aView, nsPoint& aPoint);
static void GetRootViewForPopup(nsIPresContext* aPresContext, nsIFrame* aStartFrame, nsIView** aResult);

View File

@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsIPopupBoxObject.h"
#include "nsIPopupSetFrame.h"
#include "nsIRootBox.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIFrame.h"
class nsPopupBoxObject : public nsIPopupBoxObject, public nsBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPOPUPBOXOBJECT
nsPopupBoxObject();
virtual ~nsPopupBoxObject();
protected:
};
/* Implementation file */
NS_IMPL_ADDREF(nsPopupBoxObject)
NS_IMPL_RELEASE(nsPopupBoxObject)
NS_IMETHODIMP
nsPopupBoxObject::QueryInterface(REFNSIID iid, void** aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(NS_GET_IID(nsIPopupBoxObject))) {
*aResult = (nsIPopupBoxObject*)this;
NS_ADDREF(this);
return NS_OK;
}
return nsBoxObject::QueryInterface(iid, aResult);
}
nsPopupBoxObject::nsPopupBoxObject()
{
NS_INIT_ISUPPORTS();
}
nsPopupBoxObject::~nsPopupBoxObject()
{
/* destructor code */
}
/* void openPopup (in boolean openFlag); */
NS_IMETHODIMP
nsPopupBoxObject::HidePopup()
{
nsIFrame* ourFrame = GetFrame();
if (!ourFrame)
return NS_OK;
nsIFrame* rootFrame;
mPresShell->GetRootFrame(&rootFrame);
if (!rootFrame)
return NS_OK;
if (rootFrame) {
nsCOMPtr<nsIPresContext> presContext;
mPresShell->GetPresContext(getter_AddRefs(presContext));
rootFrame->FirstChild(presContext, nsnull, &rootFrame);
}
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (!rootBox)
return NS_OK;
nsIFrame* popupSetFrame;
rootBox->GetPopupSetFrame(&popupSetFrame);
if (!popupSetFrame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
if (!popupSet)
return NS_OK;
popupSet->HidePopup(ourFrame);
popupSet->DestroyPopup(ourFrame);
return NS_OK;
}
NS_IMETHODIMP
nsPopupBoxObject::ShowPopup(nsIDOMElement* aSrcContent,
nsIDOMElement* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const PRUnichar *aPopupType, const PRUnichar *anAnchorAlignment,
const PRUnichar *aPopupAlignment)
{
nsIFrame* rootFrame;
mPresShell->GetRootFrame(&rootFrame);
if (!rootFrame)
return NS_OK;
if (rootFrame) {
nsCOMPtr<nsIPresContext> presContext;
mPresShell->GetPresContext(getter_AddRefs(presContext));
rootFrame->FirstChild(presContext, nsnull, &rootFrame);
}
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
if (!rootBox)
return NS_OK;
nsIFrame* popupSetFrame;
rootBox->GetPopupSetFrame(&popupSetFrame);
if (!popupSetFrame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));
if (!popupSet)
return NS_OK;
nsCOMPtr<nsIContent> srcContent(do_QueryInterface(aSrcContent));
nsCOMPtr<nsIContent> popupContent(do_QueryInterface(aPopupContent));
nsAutoString popupType(aPopupType);
nsAutoString anchorAlign(anAnchorAlignment);
nsAutoString popupAlign(aPopupAlignment);
return popupSet->ShowPopup(srcContent, popupContent, aXPos, aYPos, popupType, anchorAlign,
popupAlign);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewPopupBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsPopupBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

View File

@ -1,180 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsIPopupSetBoxObject.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIPopupSetFrame.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIFrame.h"
class nsPopupSetBoxObject : public nsIPopupSetBoxObject, public nsBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPOPUPSETBOXOBJECT
nsPopupSetBoxObject();
virtual ~nsPopupSetBoxObject();
protected:
};
/* Implementation file */
NS_IMPL_ADDREF(nsPopupSetBoxObject)
NS_IMPL_RELEASE(nsPopupSetBoxObject)
NS_IMETHODIMP
nsPopupSetBoxObject::QueryInterface(REFNSIID iid, void** aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(NS_GET_IID(nsIPopupSetBoxObject))) {
*aResult = (nsIPopupSetBoxObject*)this;
NS_ADDREF(this);
return NS_OK;
}
return nsBoxObject::QueryInterface(iid, aResult);
}
nsPopupSetBoxObject::nsPopupSetBoxObject()
{
NS_INIT_ISUPPORTS();
}
nsPopupSetBoxObject::~nsPopupSetBoxObject()
{
/* destructor code */
}
/* void openPopupSet (in boolean openFlag); */
NS_IMETHODIMP
nsPopupSetBoxObject::HidePopup()
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupFrame(do_QueryInterface(frame));
if (!popupFrame)
return NS_OK;
return popupFrame->HidePopup();
}
NS_IMETHODIMP
nsPopupSetBoxObject::DestroyPopup()
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupFrame(do_QueryInterface(frame));
if (!popupFrame)
return NS_OK;
return popupFrame->DestroyPopup();
}
NS_IMETHODIMP
nsPopupSetBoxObject::CreatePopup(nsIDOMElement* aSrcContent,
nsIDOMElement* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const PRUnichar *aPopupType, const PRUnichar *anAnchorAlignment,
const PRUnichar *aPopupAlignment)
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupFrame(do_QueryInterface(frame));
if (!popupFrame)
return NS_OK;
nsCOMPtr<nsIContent> popupContent(do_QueryInterface(aPopupContent));
if (!popupContent)
return NS_OK;
nsCOMPtr<nsIContent> srcContent(do_QueryInterface(aSrcContent));
if (!srcContent)
return NS_OK;
nsCOMPtr<nsIDOMDocument> doc;
aSrcContent->GetOwnerDocument(getter_AddRefs(doc));
if (!doc)
return NS_OK;
nsCOMPtr<nsIDocument> document(do_QueryInterface(doc));
nsCOMPtr<nsIPresShell> shell;
document->GetShellAt(0, getter_AddRefs(shell));
if (!shell)
return NS_OK;
return popupFrame->CreatePopup(srcContent, popupContent, aXPos, aYPos, nsAutoString(aPopupType), nsAutoString(anAnchorAlignment), nsAutoString(aPopupAlignment));
}
NS_IMETHODIMP nsPopupSetBoxObject::GetActiveChild(nsIDOMElement** aResult)
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupFrame(do_QueryInterface(frame));
if (!popupFrame)
return NS_OK;
return popupFrame->GetActiveChild(aResult);
}
NS_IMETHODIMP nsPopupSetBoxObject::SetActiveChild(nsIDOMElement* aResult)
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsIPopupSetFrame> popupFrame(do_QueryInterface(frame));
if (!popupFrame)
return NS_OK;
return popupFrame->SetActiveChild(aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewPopupSetBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsPopupSetBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

View File

@ -57,6 +57,35 @@
#define NS_MENU_POPUP_LIST_INDEX 0
nsPopupFrameList::nsPopupFrameList(nsIContent* aPopupContent, nsPopupFrameList* aNext)
:mNextPopup(aNext),
mElementContent(nsnull),
mPopupContent(aPopupContent),
mPopupFrame(nsnull),
mCreateHandlerSucceeded(PR_FALSE),
mLastPref(-1,-1)
{
}
nsPopupFrameList* nsPopupFrameList::GetEntry(nsIContent* aPopupContent) {
if (aPopupContent == mPopupContent)
return this;
if (mNextPopup)
return mNextPopup->GetEntry(aPopupContent);
return nsnull;
}
nsPopupFrameList* nsPopupFrameList::GetEntryByFrame(nsIFrame* aPopupFrame) {
if (aPopupFrame == mPopupFrame)
return this;
if (mNextPopup)
return mNextPopup->GetEntryByFrame(aPopupFrame);
return nsnull;
}
//
// NS_NewPopupSetFrame
@ -102,20 +131,11 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
//
nsPopupSetFrame::nsPopupSetFrame(nsIPresShell* aShell):nsBoxFrame(aShell),
mPresContext(nsnull),
mElementContent(nsnull),
mCreateHandlerSucceeded(PR_FALSE),
mLastPref(-1,-1),
mFrameConstructor(nsnull)
{
} // cntr
nsIFrame*
nsPopupSetFrame::GetActiveChild()
{
return mPopupFrames.FirstChild();
}
NS_IMETHODIMP
nsPopupSetFrame::Init(nsIPresContext* aPresContext,
nsIContent* aContent,
@ -128,96 +148,20 @@ nsPopupSetFrame::Init(nsIPresContext* aPresContext,
return rv;
}
// The following methods are all overridden to ensure that the menupopup frames
// are placed in the appropriate list.
NS_IMETHODIMP
nsPopupSetFrame::FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const
{
if (nsLayoutAtoms::popupList == aListName) {
*aFirstChild = mPopupFrames.FirstChild();
} else {
nsBoxFrame::FirstChild(aPresContext, aListName, aFirstChild);
}
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult rv = NS_OK;
if (nsLayoutAtoms::popupList == aListName) {
mPopupFrames.SetFrames(aChildList);
} else {
nsFrameList frames(aChildList);
// We may have menupopups in here. Get them out, and move them into
// the popup frame list.
nsIFrame* frame = frames.FirstChild();
while (frame) {
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::popup) {
// Remove this frame from the list and place it in the other list.
frames.RemoveFrame(frame);
mPopupFrames.AppendFrame(this, frame);
nsIFrame* first = frames.FirstChild();
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, first);
return rv;
}
frame->GetNextSibling(&frame);
}
// Didn't find it.
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const
{
// Maintain a separate child list for the menu contents.
// This is necessary because we don't want the menu contents to be included in the layout
// of the menu's single item because it would take up space, when it is supposed to
// be floating above the display.
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
*aListName = nsnull;
// don't expose the child frame list, it slows things down
#if 0
if (NS_MENU_POPUP_LIST_INDEX == aIndex) {
*aListName = nsLayoutAtoms::popupList;
NS_ADDREF(*aListName);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::Destroy(nsIPresContext* aPresContext)
{
// Remove our frame mappings
// Remove our frame list.
if (mFrameConstructor) {
nsIFrame* curFrame = mPopupFrames.FirstChild();
nsPopupFrameList* curFrame = mPopupList;
while (curFrame) {
mFrameConstructor->RemoveMappingsForFrameSubtree(aPresContext, curFrame, nsnull);
curFrame->GetNextSibling(&curFrame);
nsPopupFrameList* temp = curFrame;
curFrame = curFrame->mNextPopup;
temp->mNextPopup = nsnull;
delete temp;
}
}
// Cleanup frames in popup child list
mPopupFrames.DestroyFrames(aPresContext);
return nsBoxFrame::Destroy(aPresContext);
}
@ -227,76 +171,81 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
// lay us out
nsresult rv = nsBoxFrame::DoLayout(aState);
// layout the popup. First we need to get it.
nsIFrame* popupChild = GetActiveChild();
if (popupChild) {
nsIBox* ibox = nsnull;
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
// lay out all of our currently open popups.
nsPopupFrameList* currEntry = mPopupList;
while (currEntry) {
nsIFrame* popupChild = currEntry->mPopupFrame;
if (popupChild) {
nsIBox* ibox = nsnull;
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
// then get its preferred size
nsSize prefSize(0,0);
nsSize minSize(0,0);
nsSize maxSize(0,0);
// then get its preferred size
nsSize prefSize(0,0);
nsSize minSize(0,0);
nsSize maxSize(0,0);
ibox->GetPrefSize(aState, prefSize);
ibox->GetMinSize(aState, minSize);
ibox->GetMaxSize(aState, maxSize);
ibox->GetPrefSize(aState, prefSize);
ibox->GetMinSize(aState, minSize);
ibox->GetMaxSize(aState, maxSize);
BoundsCheck(minSize, prefSize, maxSize);
BoundsCheck(minSize, prefSize, maxSize);
// if the pref size changed then set bounds to be the pref size
// and sync the view. And set new pref size.
if (mLastPref != prefSize) {
ibox->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
RePositionPopup(aState);
mLastPref = prefSize;
}
// if the pref size changed then set bounds to be the pref size
// and sync the view. Also set new pref size.
// if (currEntry->mLastPref != prefSize) {
ibox->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
RepositionPopup(currEntry, aState);
currEntry->mLastPref = prefSize;
// }
// is the new size too small? Make sure we handle scrollbars correctly
nsIBox* child;
ibox->GetChildBox(&child);
// is the new size too small? Make sure we handle scrollbars correctly
nsIBox* child;
ibox->GetChildBox(&child);
nsRect bounds(0,0,0,0);
ibox->GetBounds(bounds);
nsRect bounds(0,0,0,0);
ibox->GetBounds(bounds);
nsCOMPtr<nsIScrollableFrame> scrollframe = do_QueryInterface(child);
if (scrollframe) {
nsIScrollableFrame::nsScrollPref pref;
scrollframe->GetScrollPreference(aState.GetPresContext(), &pref);
nsCOMPtr<nsIScrollableFrame> scrollframe = do_QueryInterface(child);
if (scrollframe) {
nsIScrollableFrame::nsScrollPref pref;
scrollframe->GetScrollPreference(aState.GetPresContext(), &pref);
if (pref == nsIScrollableFrame::Auto)
{
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
if (pref == nsIScrollableFrame::Auto)
{
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
nscoord width;
nscoord height;
scrollframe->GetScrollbarSizes(aState.GetPresContext(), &width, &height);
if (bounds.width < prefSize.width + width)
{
bounds.width += width;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
}
nscoord width;
nscoord height;
scrollframe->GetScrollbarSizes(aState.GetPresContext(), &width, &height);
if (bounds.width < prefSize.width + width)
{
bounds.width += width;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
}
}
}
}
}
// layout the child
ibox->Layout(aState);
// layout the child
ibox->Layout(aState);
// only size popup if open
if (mCreateHandlerSucceeded) {
nsIView* view = nsnull;
popupChild->GetView(aState.GetPresContext(), &view);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, bounds.width, bounds.height);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
// only size popup if open
if (currEntry->mCreateHandlerSucceeded) {
nsIView* view = nsnull;
popupChild->GetView(aState.GetPresContext(), &view);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, bounds.width, bounds.height);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
}
}
currEntry = currEntry->mNextPopup;
}
SyncLayout(aState);
@ -315,8 +264,7 @@ nsPopupSetFrame::SetDebug(nsBoxLayoutState& aState, PRBool aDebug)
// if it doesn't then tell each child below us the new debug state
if (debugChanged)
{
nsBoxFrame::SetDebug(aState, aDebug);
SetDebug(aState, mPopupFrames.FirstChild(), aDebug);
// XXXdwh fix later. nobody uses this anymore anyway.
}
return NS_OK;
@ -343,112 +291,51 @@ nsPopupSetFrame::SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDeb
void
nsPopupSetFrame::RePositionPopup(nsBoxLayoutState& aState)
nsPopupSetFrame::RepositionPopup(nsPopupFrameList* aEntry, nsBoxLayoutState& aState)
{
// Sync up the view.
nsIFrame* activeChild = GetActiveChild();
if (activeChild && mElementContent) {
if (aEntry && aEntry->mElementContent) {
nsIFrame* frameToSyncTo = nsnull;
nsCOMPtr<nsIPresShell> presShell;
nsIPresContext* presContext = aState.GetPresContext();
presContext->GetShell(getter_AddRefs(presShell));
presShell->GetPrimaryFrameFor ( mElementContent, &frameToSyncTo );
((nsMenuPopupFrame*)activeChild)->SyncViewWithFrame(presContext, mPopupAnchor, mPopupAlign, frameToSyncTo, mXPos, mYPos);
presShell->GetPrimaryFrameFor(aEntry->mElementContent, &frameToSyncTo );
((nsMenuPopupFrame*)(aEntry->mPopupFrame))->SyncViewWithFrame(presContext,
aEntry->mPopupAnchor, aEntry->mPopupAlign, frameToSyncTo, aEntry->mXPos, aEntry->mYPos);
}
}
NS_IMETHODIMP
nsPopupSetFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment)
{
nsresult rv;
if (mPopupFrames.ContainsFrame(aOldFrame)) {
// Go ahead and remove this frame.
mPopupFrames.DestroyFrame(aPresContext, aOldFrame);
nsBoxLayoutState state(aPresContext);
rv = MarkDirtyChildren(state);
} else {
rv = nsBoxFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::popup) {
mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList);
nsBoxLayoutState state(aPresContext);
SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG);
rv = MarkDirtyChildren(state);
} else {
rv = nsBoxFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
if (!aFrameList)
return NS_OK;
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::popup) {
mPopupFrames.AppendFrames(nsnull, aFrameList);
nsBoxLayoutState state(aPresContext);
SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG);
rv = MarkDirtyChildren(state);
} else {
rv = nsBoxFrame::AppendFrames(aPresContext, aPresShell, aListName, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::CreatePopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment)
{
// Cache the element content we're supposed to sync to
mPopupType = aPopupType;
mElementContent = aElementContent;
mPopupAlign = aPopupAlignment;
mPopupAnchor = anAnchorAlignment;
// Show the popup at the specified position.
mXPos = aXPos;
mYPos = aYPos;
// First fire the popupshowing event.
if (!OnCreate(aPopupContent))
return NS_OK;
// See if we already have an entry in our list. We must create a new one on a miss.
nsPopupFrameList* entry = nsnull;
if (mPopupList)
entry = mPopupList->GetEntry(aPopupContent);
if (!entry) {
entry = new nsPopupFrameList(aPopupContent, mPopupList);
mPopupList = entry;
}
// Cache the element content we're supposed to sync to
entry->mPopupType = aPopupType;
entry->mElementContent = aElementContent;
entry->mPopupAlign = aPopupAlignment;
entry->mPopupAnchor = anAnchorAlignment;
entry->mXPos = aXPos;
entry->mYPos = aYPos;
// If a frame exists already, go ahead and use it.
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
shell->GetPrimaryFrameFor(aPopupContent, &entry->mPopupFrame);
#ifdef DEBUG_PINK
printf("X Pos: %d\n", mXPos);
@ -456,47 +343,59 @@ nsPopupSetFrame::CreatePopup(nsIContent* aElementContent, nsIContent* aPopupCont
#endif
// Generate the popup.
mCreateHandlerSucceeded = PR_TRUE;
entry->mCreateHandlerSucceeded = PR_TRUE;
MarkAsGenerated(aPopupContent);
// determine if this menu is a context menu and flag it
nsIFrame* activeChild = GetActiveChild();
nsIFrame* activeChild = entry->mPopupFrame;
nsCOMPtr<nsIMenuParent> childPopup ( do_QueryInterface(activeChild) );
if ( childPopup && aPopupType == NS_LITERAL_STRING("context") )
childPopup->SetIsContextMenu(PR_TRUE);
// Now we'll have it in our child frame list.
// Now open the popup.
OpenPopup(PR_TRUE);
OpenPopup(entry, PR_TRUE);
// Now fire the popupshown event.
OnCreated(aPopupContent);
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::HidePopup()
nsPopupSetFrame::HidePopup(nsIFrame* aPopup)
{
if ( mCreateHandlerSucceeded )
ActivatePopup(PR_FALSE);
if (!mPopupList)
return NS_OK; // No active popups
nsPopupFrameList* entry = mPopupList->GetEntryByFrame(aPopup);
if (entry && entry->mCreateHandlerSucceeded)
ActivatePopup(entry, PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::DestroyPopup()
nsPopupSetFrame::DestroyPopup(nsIFrame* aPopup)
{
if ( mCreateHandlerSucceeded ) { // ensure the popup was created before we try to destroy it
OpenPopup(PR_FALSE);
mPopupType.SetLength(0);
}
if (!mPopupList)
return NS_OK; // No active popups
// clear things out for next time
mCreateHandlerSucceeded = PR_FALSE;
mElementContent = nsnull;
mXPos = mYPos = 0;
mLastPref.width = -1;
mLastPref.height = -1;
nsPopupFrameList* entry = mPopupList->GetEntryByFrame(aPopup);
if (entry && entry->mCreateHandlerSucceeded) { // ensure the popup was created before we try to destroy it
OpenPopup(entry, PR_FALSE);
entry->mPopupType.SetLength(0);
// clear things out for next time
entry->mCreateHandlerSucceeded = PR_FALSE;
entry->mElementContent = nsnull;
entry->mXPos = entry->mYPos = 0;
entry->mLastPref.width = -1;
entry->mLastPref.height = -1;
// remove the frame and ungenerate the popup.
entry->mPopupFrame = nsnull;
entry->mPopupContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated, PR_TRUE);
}
return NS_OK;
}
@ -504,25 +403,6 @@ nsPopupSetFrame::DestroyPopup()
void
nsPopupSetFrame::MarkAsGenerated(nsIContent* aPopupContent)
{
// Ungenerate all other popups in the set. No more than one can exist
// at any point in time.
PRInt32 childCount;
mContent->ChildCount(childCount);
for (PRInt32 i = 0; i < childCount; i++) {
nsCOMPtr<nsIContent> childContent;
mContent->ChildAt(i, *getter_AddRefs(childContent));
// Retrieve the menugenerated attribute.
nsAutoString value;
childContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated,
value);
if (value == NS_LITERAL_STRING("true")) {
// Ungenerate this element.
childContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menugenerated,
PR_TRUE);
}
}
// Set our attribute, but only if we aren't already generated.
// Retrieve the menugenerated attribute.
nsAutoString value;
@ -536,84 +416,81 @@ nsPopupSetFrame::MarkAsGenerated(nsIContent* aPopupContent)
}
void
nsPopupSetFrame::OpenPopup(PRBool aActivateFlag)
nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
{
if (aActivateFlag) {
ActivatePopup(PR_TRUE);
ActivatePopup(aEntry, PR_TRUE);
// register the rollup listeners, etc, but not if we're a tooltip
nsIFrame* activeChild = GetActiveChild();
nsIFrame* activeChild = aEntry->mPopupFrame;
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(activeChild);
if ( mPopupType != NS_LITERAL_STRING("tooltip") )
if (aEntry->mPopupType != NS_LITERAL_STRING("tooltip"))
UpdateDismissalListener(childPopup);
// First check and make sure this popup wants keyboard navigation
nsCOMPtr<nsIContent> content;
GetContent(getter_AddRefs(content));
nsAutoString property;
// Tooltips don't get keyboard navigation
content->GetAttr(kNameSpaceID_None, nsXULAtoms::ignorekeys, property);
if ( property != NS_LITERAL_STRING("true") &&
childPopup &&
mPopupType != NS_LITERAL_STRING("tooltip") )
aEntry->mPopupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::ignorekeys, property);
if (property != NS_LITERAL_STRING("true") &&
childPopup &&
aEntry->mPopupType != NS_LITERAL_STRING("tooltip"))
childPopup->InstallKeyboardNavigator();
}
else {
if (mCreateHandlerSucceeded && !OnDestroy())
if (aEntry->mCreateHandlerSucceeded && !OnDestroy(aEntry->mPopupContent))
return;
// Unregister, but not if we're a tooltip
if ( mPopupType != NS_LITERAL_STRING("tooltip") ) {
if (aEntry->mPopupType != NS_LITERAL_STRING("tooltip") ) {
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
}
// Remove any keyboard navigators
nsIFrame* activeChild = GetActiveChild();
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(activeChild);
if ( childPopup )
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(aEntry->mPopupFrame);
if (childPopup)
childPopup->RemoveKeyboardNavigator();
ActivatePopup(PR_FALSE);
ActivatePopup(aEntry, PR_FALSE);
OnDestroyed();
OnDestroyed(aEntry->mPopupContent);
}
nsBoxLayoutState state(mPresContext);
MarkDirtyChildren(state); // Mark ourselves dirty.
}
void
nsPopupSetFrame::ActivatePopup(PRBool aActivateFlag)
nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
{
nsCOMPtr<nsIContent> content;
GetActiveChildElement(getter_AddRefs(content));
if (content) {
if (aEntry->mPopupContent) {
// When we sync the popup view with the frame, we'll show the popup if |menutobedisplayed|
// is set by setting the |menuactive| attribute. This used to trip css into showing the menu
// but now we do it ourselves.
if (aActivateFlag)
content->SetAttr(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, NS_LITERAL_STRING("true"), PR_TRUE);
aEntry->mPopupContent->SetAttr(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, NS_LITERAL_STRING("true"), PR_TRUE);
else {
content->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
content->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, PR_TRUE);
aEntry->mPopupContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
aEntry->mPopupContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, PR_TRUE);
// get rid of the reflows we just created. If we leave them hanging around, we
// can get into trouble if a dialog with a modal event loop comes along and
// processes the reflows before we get to call DestroyChain(). Processing the
// reflow will cause the popup to show itself again. (bug 71219)
nsCOMPtr<nsIDocument> doc;
content->GetDocument(*getter_AddRefs(doc));
if ( doc )
aEntry->mPopupContent->GetDocument(*getter_AddRefs(doc));
if (doc)
doc->FlushPendingNotifications();
// make sure we hide the popup. We can't assume that we'll have a view
// since we could be cleaning up after someone that didn't correctly
// destroy the popup.
nsIFrame* activeChild = GetActiveChild();
nsIFrame* activeChild = aEntry->mPopupFrame;
nsIView* view = nsnull;
if ( activeChild ) {
if (activeChild) {
activeChild->GetView(mPresContext, &view);
NS_ASSERTION ( view, "View is gone, looks like someone forgot to rollup the popup!" );
if ( view ) {
NS_ASSERTION(view, "View is gone, looks like someone forgot to roll up the popup!");
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
@ -732,7 +609,7 @@ nsPopupSetFrame::OnCreated(nsIContent* aPopupContent)
}
PRBool
nsPopupSetFrame::OnDestroy()
nsPopupSetFrame::OnDestroy(nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
@ -744,15 +621,12 @@ nsPopupSetFrame::OnDestroy()
event.isMeta = PR_FALSE;
event.clickCount = 0;
event.widget = nsnull;
nsCOMPtr<nsIContent> content;
GetActiveChildElement(getter_AddRefs(content));
if (content) {
if (aPopupContent) {
nsCOMPtr<nsIPresShell> shell;
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
rv = shell->HandleDOMEventWithTarget(content, &event, &status);
rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status);
}
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
@ -761,7 +635,7 @@ nsPopupSetFrame::OnDestroy()
}
PRBool
nsPopupSetFrame::OnDestroyed()
nsPopupSetFrame::OnDestroyed(nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
@ -774,14 +648,11 @@ nsPopupSetFrame::OnDestroyed()
event.clickCount = 0;
event.widget = nsnull;
nsCOMPtr<nsIContent> content;
GetActiveChildElement(getter_AddRefs(content));
if (content) {
if (aPopupContent) {
nsCOMPtr<nsIPresShell> shell;
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
rv = shell->HandleDOMEventWithTarget(content, &event, &status);
rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status);
}
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
@ -789,16 +660,6 @@ nsPopupSetFrame::OnDestroyed()
return PR_TRUE;
}
void
nsPopupSetFrame::GetActiveChildElement(nsIContent** aResult)
{
*aResult = nsnull;
nsIFrame* child = GetActiveChild();
if (child) {
child->GetContent(aResult);
}
}
void
nsPopupSetFrame::UpdateDismissalListener(nsIMenuParent* aMenuParent)
{
@ -815,64 +676,27 @@ nsPopupSetFrame::UpdateDismissalListener(nsIMenuParent* aMenuParent)
}
NS_IMETHODIMP
nsPopupSetFrame::GetActiveChild(nsIDOMElement** aResult)
nsPopupSetFrame::AddPopupFrame(nsIFrame* aPopup)
{
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
if (!frame)
return NS_ERROR_FAILURE;
// The entry should already exist, but might not (if someone decided to make their
// popup visible straightaway, e.g., the autocomplete widget).
nsIMenuFrame* menuFrame;
menuPopup->GetCurrentMenuItem(&menuFrame);
// First look for an entry by content.
nsCOMPtr<nsIContent> content;
aPopup->GetContent(getter_AddRefs(content));
nsPopupFrameList* entry = nsnull;
if (mPopupList)
entry = mPopupList->GetEntry(content);
if (!entry) {
entry = new nsPopupFrameList(content, mPopupList);
mPopupList = entry;
}
if (!menuFrame) {
*aResult = nsnull;
}
else {
nsIFrame* f;
menuFrame->QueryInterface(NS_GET_IID(nsIFrame), (void**)&f);
nsCOMPtr<nsIContent> c;
f->GetContent(getter_AddRefs(c));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(c));
*aResult = elt;
NS_IF_ADDREF(*aResult);
}
// Set the frame connection.
entry->mPopupFrame = aPopup;
// Now return. The remaining entry values will be filled in if/when showPopup is
// called for this popup.
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::SetActiveChild(nsIDOMElement* aChild)
{
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
if (!frame)
return NS_ERROR_FAILURE;
if (!aChild) {
// Remove the current selection
menuPopup->SetCurrentMenuItem(nsnull);
return NS_OK;
}
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
nsCOMPtr<nsIContent> par;
child->GetParent(*getter_AddRefs(par));
nsCOMPtr<nsIContent> menuPopupContent;
menuPopup->GetContent(getter_AddRefs(menuPopupContent));
if (menuPopupContent != par)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
nsIFrame* kid;
shell->GetPrimaryFrameFor(child, &kid);
if (!kid)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMenuFrame> menuFrame(do_QueryInterface(kid));
if (!menuFrame)
return NS_ERROR_FAILURE;
menuPopup->SetCurrentMenuItem(menuFrame);
return NS_OK;
}

View File

@ -43,6 +43,29 @@ nsresult NS_NewPopupSetFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ;
class nsCSSFrameConstructor;
struct nsPopupFrameList {
nsPopupFrameList* mNextPopup; // The next popup in the list.
nsIFrame* mPopupFrame; // Our popup.
nsIContent* mPopupContent; // The content element for the <popup> itself.
nsIContent* mElementContent; // The content that is having something popped up over it <weak>
PRInt32 mXPos; // This child's x position
PRInt32 mYPos; // This child's y position
nsAutoString mPopupAnchor; // This child's anchor.
nsAutoString mPopupAlign; // This child's align.
nsAutoString mPopupType;
PRBool mCreateHandlerSucceeded; // Did the create handler succeed?
nsSize mLastPref;
public:
nsPopupFrameList(nsIContent* aPopupContent, nsPopupFrameList* aNext);
nsPopupFrameList* GetEntry(nsIContent* aPopupContent);
nsPopupFrameList* GetEntryByFrame(nsIFrame* aPopupFrame);
};
class nsPopupSetFrame : public nsBoxFrame, public nsIPopupSetFrame
{
public:
@ -60,58 +83,28 @@ public:
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug);
// The following four methods are all overridden so that the menu children
// can be stored in a separate list (so that they don't impact reflow of the
// actual menu item at all).
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const;
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
// Used to destroy our popup frames.
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
// Reflow methods
virtual void RePositionPopup(nsBoxLayoutState& aState);
virtual void RepositionPopup(nsPopupFrameList* aEntry, nsBoxLayoutState& aState);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD CreatePopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment);
NS_IMETHOD HidePopup();
NS_IMETHOD DestroyPopup();
NS_IMETHOD GetActiveChild(nsIDOMElement** aResult);
NS_IMETHOD SetActiveChild(nsIDOMElement* aChild);
NS_IMETHOD ShowPopup(nsIContent* aElementContent, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment);
NS_IMETHOD HidePopup(nsIFrame* aPopup);
NS_IMETHOD DestroyPopup(nsIFrame* aPopup);
NS_IMETHOD AddPopupFrame(nsIFrame* aPopup);
PRBool OnCreate(nsIContent* aPopupContent);
PRBool OnDestroy();
PRBool OnDestroy(nsIContent* aPopupContent);
PRBool OnCreated(nsIContent* aPopupContent);
PRBool OnDestroyed();
PRBool OnDestroyed(nsIContent* aPopupContent);
void ActivatePopup(PRBool aActivateFlag);
void OpenPopup(PRBool aOpenFlag);
nsIFrame* GetActiveChild();
void GetActiveChildElement(nsIContent** aResult);
void ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag);
void OpenPopup(nsPopupFrameList* aEntry, PRBool aOpenFlag);
NS_IMETHOD GetFrameName(nsString& aResult) const
{
@ -131,20 +124,10 @@ protected:
protected:
nsresult SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDebug);
nsFrameList mPopupFrames;
nsPopupFrameList* mPopupList;
nsIPresContext* mPresContext; // Our pres context.
nsIContent* mElementContent; // The content that is having something popped up over it <weak>
PRInt32 mXPos; // Active child's x position
PRInt32 mYPos; // Active child's y position
nsString mPopupAnchor; // Active child's anchor.
nsString mPopupAlign; // Active child's align.
nsAutoString mPopupType;
PRBool mCreateHandlerSucceeded; // Did the create handler succeed?
nsSize mLastPref;
private:
nsCSSFrameConstructor* mFrameConstructor;
}; // class nsPopupSetFrame

View File

@ -45,18 +45,24 @@
#include "nsIPresShell.h"
#include "nsBoxFrame.h"
#include "nsStackLayout.h"
#include "nsIRootBox.h"
// Interface IDs
//#define DEBUG_REFLOW
class nsRootBoxFrame : public nsBoxFrame {
class nsRootBoxFrame : public nsBoxFrame, public nsIRootBox {
public:
friend nsresult NS_NewBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
nsRootBoxFrame(nsIPresShell* aShell);
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetPopupSetFrame(nsIFrame** aResult);
NS_IMETHOD SetPopupSetFrame(nsIFrame* aPopupSet);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
@ -99,6 +105,8 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
#endif
nsIFrame* mPopupSetFrame;
};
//----------------------------------------------------------------------
@ -122,6 +130,8 @@ NS_NewRootBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
nsRootBoxFrame::nsRootBoxFrame(nsIPresShell* aShell):nsBoxFrame(aShell, PR_TRUE)
{
mPopupSetFrame = nsnull;
nsCOMPtr<nsIBoxLayout> layout;
NS_NewStackLayout(aShell, layout);
SetLayoutManager(layout);
@ -262,6 +272,38 @@ nsRootBoxFrame::Paint(nsIPresContext* aPresContext,
return nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
NS_IMETHODIMP
nsRootBoxFrame::GetPopupSetFrame(nsIFrame** aResult)
{
*aResult = mPopupSetFrame;
return NS_OK;
}
NS_IMETHODIMP
nsRootBoxFrame::SetPopupSetFrame(nsIFrame* aPopupSet)
{
NS_ASSERTION(!mPopupSetFrame, "Popup set is already defined! Only 1 allowed.");
if (!mPopupSetFrame)
mPopupSetFrame = aPopupSet;
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsRootBoxFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsRootBoxFrame::Release(void)
{
return NS_OK;
}
NS_INTERFACE_MAP_BEGIN(nsRootBoxFrame)
NS_INTERFACE_MAP_ENTRY(nsIRootBox)
NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
#ifdef DEBUG
NS_IMETHODIMP
nsRootBoxFrame::GetFrameName(nsString& aResult) const

View File

@ -8,10 +8,10 @@ menupopup, popup
-moz-user-focus : ignore;
}
/** Tooltips (tooltip <popup> element)
/** Tooltips (tooltip <popup> element is deprecated. USE <tooltip> instead!)
* class="tooltip"
**/
.tooltip
.tooltip, tooltip
{
background-color : InfoBackground;
border : 1px solid #000000;
@ -21,7 +21,8 @@ menupopup, popup
margin : 0px;
}
.tooltip > .popup-internal-box
.tooltip > .popup-internal-box,
tooltip > .popup-internal-box
{
border: none;
padding: 0px;

View File

@ -26,10 +26,10 @@ menupopup, popup
padding : 1px;
}
/** Tooltips (tooltip <popup> element)
/** Tooltips (tooltip <popup> element is deprecated! Use <tooltip> instead!)
* class="tooltip"
**/
.tooltip
.tooltip, tooltip
{
border : 1px solid WindowFrame;
padding : 2px;
@ -39,7 +39,8 @@ menupopup, popup
font : message-box;
}
.tooltip > .popup-internal-box
.tooltip > .popup-internal-box,
tooltip > .popup-internal-box
{
border : 0px;
padding : 0px;

View File

@ -46,14 +46,15 @@ popup {
/* ::::: tooltip popup ::::: */
.tooltip {
.tooltip, tooltip {
border: 1px solid #000000;
padding: 2px 3px 2px 3px;
background-color: #FFFFE7;
color: #000000;
}
.tooltip > .popup-internal-box {
.tooltip > .popup-internal-box,
tooltip > .popup-internal-box {
border: none;
}

View File

@ -111,9 +111,9 @@ Contributor(s): ______________________________________. -->
</keyset>
<popupset id="aHTMLTooltipSet">
<popup id="aHTMLTooltip" class="tooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);" >
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);" >
<vbox id="HTML_TOOLTIP_tooltipBox"/>
</popup>
</tooltip>
<popup id="backMenu" position="after_start" onpopupshowing="return BrowserBackMenu(event);" oncommand="gotoHistoryIndex(event);"/>
<popup id="forwardMenu" position="after_start" onpopupshowing="return BrowserForwardMenu(event);" oncommand="gotoHistoryIndex(event);"/>
<popup id="sidebarPopup"/>

View File

@ -35,8 +35,8 @@
</xul:hbox>
</xul:hbox>
<xul:popupset anonid="popupset" ignorekeys="true">
<xul:popup anonid="popup" class="autocomplete-result-popup" inherits="for=id,nomatch"/>
<xul:popupset anonid="popupset">
<xul:popup ignorekeys="true" anonid="popup" class="autocomplete-result-popup" inherits="for=id,nomatch"/>
</xul:popupset>
<children includes="menupopup"/>
@ -860,8 +860,6 @@
<method name="closeResultPopup">
<body><![CDATA[
if (this.resultsPopup && this.mMenuOpen) {
//var boxObject = this.mPopupSetElt.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
//boxObject.hidePopup();
this.resultsPopup.closePopup();
this.mMenuOpen = false;
}
@ -1367,8 +1365,7 @@
<binding id="autocomplete-internal-box">
<content context="_child">
<children/>
<xul:popupset>
<xul:popup onpopupshowing="this.parentNode.parentNode.doPopupItemEnabling(this);">
<xul:menupopup onpopupshowing="this.parentNode.doPopupItemEnabling(this);">
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"
oncommand="var controller = document.commandDispatcher.getControllerForCommand('cmd_undo');
controller.doCommand('cmd_undo');"/>
@ -1389,8 +1386,7 @@
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" command="cmd_selectAll"
oncommand="var controller = document.commandDispatcher.getControllerForCommand('cmd_selectAll');
controller.doCommand('cmd_selectAll');"/>
</xul:popup>
</xul:popupset>
</xul:menupopup>
</content>
<implementation>

View File

@ -62,9 +62,16 @@
</vbox>
<iframe id="panelFrame" name="panelFrame" style="width:0px" flex="81"/>
<script type="application/x-javascript">
</hbox>
<separator/>
<hbox id="okCancelHelpButtonsRight" />
<script type="application/x-javascript">
<![CDATA[
if( window.arguments && window.arguments[0] ) {
if(window.arguments && window.arguments[0]) {
document.getElementById("panelFrame").setAttribute("src", window.arguments[0] );
document.getElementById("panelFrame").setAttribute("tag", window.arguments[0] );
}
@ -74,10 +81,5 @@
}
]]>
</script>
</hbox>
<separator/>
<hbox id="okCancelHelpButtonsRight" />
</window>

View File

@ -8,6 +8,30 @@
<resources>
<stylesheet src="chrome://global/skin/button.css"/>
</resources>
<implementation>
<constructor>
<![CDATA[
if (this.menu == "") {
var children = this.childNodes;
for (var i = 0; i < children.length; i++) {
if (children[i].localName == "menupopup") {
this.menu = "_child";
break;
}
}
}
if (this.tooltip == "") {
var children = this.childNodes;
for (var i = 0; i < children.length; i++) {
if (children[i].localName == "tooltip") {
this.tooltip = "_child";
break;
}
}
}
]]>
</constructor>
</implementation>
</binding>
<binding id="buttonleft" extends="chrome://global/content/bindings/button.xml#button-base">

View File

@ -4,6 +4,13 @@
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="basewindow">
<content>
<children/>
<xul:popupgroup/>
</content>
</binding>
<binding id="basetext">
<implementation>
<!-- public implementation -->
@ -16,12 +23,10 @@
return val;"
onget="var v = this.getAttribute('disabled');
if (v == 'true') return true; return false;"/>
<property name="src" onset="return this.setAttribute('src',val);"
onget="return this.getAttribute('src');"/>
<property name="image" onset="return this.setAttribute('image',val);"
onget="return this.getAttribute('image');"/>
<property name="accesskey" onset="return this.setAttribute('accesskey',val);"
onget="return this.getAttribute('accesskey');"/>
<property name="imgalign" onset="return this.setAttribute('imgalign',val);"
onget="return this.getAttribute('imgalign');"/>
</implementation>
</binding>

View File

@ -30,15 +30,15 @@
<body>
<![CDATA[
try {
var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
var popupBox = this.boxObject.QueryInterface(Components.interfaces.nsIPopupBoxObject);
} catch(e) {}
try {
var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
} catch(e) {}
if (popupSetBox)
popupSetBox.createPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
else if (menuBox)
if (menuBox)
menuBox.openMenu(true);
else if (popupBox)
popupBox.showPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
]]>
</body>
</method>
@ -46,52 +46,18 @@
<body>
<![CDATA[
try {
var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
var popupBox = this.boxObject.QueryInterface(Components.interfaces.nsIPopupBoxObject);
} catch(e) {}
try {
var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
} catch(e) {}
if (popupSetBox)
popupSetBox.destroyPopup();
else if (menuBox)
if (menuBox)
menuBox.openMenu(false);
else if (popupBox)
popupBox.hidePopup();
]]>
</body>
</method>
<property name="activeChild">
<getter>
<![CDATA[
try {
var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
} catch(e) {}
try {
var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
} catch(e) {}
if (popupSetBox)
return popupSetBox.activeChild;
else if (menuBox)
return menuBox.activeChild;
else
return null;
]]>
</getter>
<setter>
<![CDATA[
try {
var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
} catch(e) {}
try {
var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
} catch(e) {}
if (popupSetBox)
return popupSetBox.activeChild = val;
else if (menuBox)
return menuBox.activeChild = val;
else
return null;
]]>
</setter>
</property>
</implementation>
<handlers>

View File

@ -19,8 +19,7 @@
<xul:hbox class="textbox-internal-box" flex="1">
<html:input class="textbox-input" flex="1" inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly"/>
</xul:hbox>
<xul:popupset>
<xul:popup onpopupshowing="this.parentNode.parentNode.doPopupItemEnabling(this); this.focus();">
<xul:menupopup onpopupshowing="this.parentNode.doPopupItemEnabling(this); this.focus();">
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo" oncommand="
var controller = document.commandDispatcher.getControllerForCommand('cmd_undo');
controller.doCommand('cmd_undo');"/>
@ -41,8 +40,7 @@
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll" oncommand="
var controller = document.commandDispatcher.getControllerForCommand('cmd_selectAll');
controller.doCommand('cmd_selectAll');"/>
</xul:popup>
</xul:popupset>
</xul:menupopup>
</content>
<implementation>

View File

@ -48,7 +48,7 @@ outliner {
}
menulist[editable="true"],
popup, menupopup,
popup, menupopup, tooltip,
scrollbar, scrollbarbutton, slider, thumb, autorepeater,
splitter, statusbar, statusbarpanel,
toolbox, menubar, toolbar, spinbuttons {
@ -70,6 +70,10 @@ window {
overflow: hidden;
}
window,wizard,dialog,page {
-moz-binding: url(chrome://global/content/bindings/general.xml#basewindow);
}
/******** box *******/
vbox {
@ -223,8 +227,11 @@ menuseparator {
/********* popup & menupopup ***********/
/* POPUP is deprecated. Only <menupopup> and <tooltip> are still valid. */
popup,
menupopup {
menupopup,
tooltip {
-moz-binding: url("chrome://global/content/bindings/popup.xml#popup");
-moz-box-orient: vertical;
display: none;
@ -232,12 +239,15 @@ menupopup {
}
menupopup[menugenerated="true"],
popup[menugenerated="true"] {
popup[menugenerated="true"],
tooltip[menugenerated="true"] {
display: -moz-popup;
}
/* Everything here is deprecated except the tooltip tag */
popup.tooltip,
.popup-infopopup {
.popup-infopopup,
tooltip {
-moz-binding: url("chrome://global/content/bindings/popup.xml#tooltips");
}