Updating popups. (No, they're still not turned on.)

This commit is contained in:
hyatt%netscape.com 1999-09-09 01:07:06 +00:00
Родитель 99ffb08c28
Коммит ac0a81e522
4 изменённых файлов: 67 добавлений и 6 удалений

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

@ -74,6 +74,7 @@ XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without n
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(menupopupset, "menupopupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(key, "key") // A key element
XUL_ATOM(broadcaster, "broadcaster") // A broadcaster

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

@ -371,17 +371,75 @@ nsPopupSetFrame::CreatePopup(nsIFrame* aElementFrame, nsIContent* aPopupContent,
const nsString& aPopupAlignment)
{
// Generate the popup.
//MarkAsGenerated(aPopupContent);
MarkAsGenerated(aPopupContent);
// Now we'll have it in our child frame list. Make it our active child.
//SetActiveChild(aPopupContent);
SetActiveChild(aPopupContent);
// Show the popup at the specified position.
mXPos = aXPos;
mYPos = aYPos;
// Mark the view as active.
//ActivateMenuPopup(PR_TRUE);
ActivateMenuPopup(PR_TRUE);
return NS_OK;
}
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->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
value);
if (value == "true") {
// Ungenerate this element.
childContent->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
PR_TRUE);
}
}
// Set our attribute, but only if we aren't already generated.
// Retrieve the menugenerated attribute.
nsAutoString value;
aPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
value);
if (value != "true") {
// Ungenerate this element.
aPopupContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated, "true",
PR_TRUE);
}
}
void
nsPopupSetFrame::SetActiveChild(nsIContent* aPopupContent)
{
mActiveContent = aPopupContent; // Weak ref
nsIFrame* frame = mPopupFrames.FirstChild();
while (frame) {
nsCOMPtr<nsIContent> childContent;
frame->GetContent(getter_AddRefs(childContent));
if (childContent.get() == mActiveContent) {
mActiveChild = frame;
break;
}
frame->GetNextSibling(&frame);
}
}
void
nsPopupSetFrame::ActivateMenuPopup(PRBool aActivateFlag)
{
}

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

@ -95,15 +95,16 @@ public:
const nsString& aPopupAlignment);
//void ActivateMenuPopup(PRBool aActivateFlag);
void ActivateMenuPopup(PRBool aActivateFlag);
protected:
//void MarkAsGenerated();
//void SetActiveChild(nsIContent* aPopupContent);
void MarkAsGenerated(nsIContent* aPopupContent);
void SetActiveChild(nsIContent* aPopupContent);
protected:
nsFrameList mPopupFrames;
nsIFrame* mActiveChild;
nsIContent* mActiveContent; // [WEAK]
nsIPresContext* mPresContext; // Our pres context.
PRInt32 mXPos; // Active child's x position

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

@ -74,6 +74,7 @@ XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without n
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(menupopupset, "menupopupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(key, "key") // A key element
XUL_ATOM(broadcaster, "broadcaster") // A broadcaster