diff --git a/mozilla/content/shared/public/nsXULAtomList.h b/mozilla/content/shared/public/nsXULAtomList.h index f37135d2bc7..e8bcfb84cef 100644 --- a/mozilla/content/shared/public/nsXULAtomList.h +++ b/mozilla/content/shared/public/nsXULAtomList.h @@ -63,22 +63,20 @@ XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view XUL_ATOM(treefoot, "treefoot") // The footer of the tree view XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view -XUL_ATOM(menuitem, "menuitem") // The menu element -XUL_ATOM(menubar, "menubar") // The menubar element -XUL_ATOM(menu, "menu") // A single menu item - XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open -XUL_ATOM(xpmenubar, "xpmenubar") // An XP menu bar. -XUL_ATOM(xpmenu, "xpmenu") // Represents an XP menu -XUL_ATOM(xpmenuitem, "xpmenuitem") // Represents an XP menu item -XUL_ATOM(xpmenubutton, "xpmenubutton") // A titled button (with improved behavior) inside an XP menu. -XUL_ATOM(xpmenuchildren, "xpmenuchildren") // The XP menu's children. +XUL_ATOM(menubar, "menubar") // An XP menu bar. +XUL_ATOM(menu, "menu") // Represents an XP menu +XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item +XUL_ATOM(menupopup, "menupopup") // The XP menu's children. 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(key, "key") // A key element +XUL_ATOM(broadcaster, "broadcaster") // A broadcaster +XUL_ATOM(observes, "observes") // The observes element +XUL_ATOM(templateAtom, "template") // A XUL template XUL_ATOM(progressmeter, "progressmeter") XUL_ATOM(titledbutton, "titledbutton") diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 597b0f4df20..bae517ce512 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -1826,10 +1826,10 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treecolgroup == tag.get()) || (nsXULAtoms::treefoot == tag.get()) || (nsXULAtoms::treepusher == tag.get()) || - (nsXULAtoms::xpmenu == tag.get()) || - (nsXULAtoms::xpmenuitem == tag.get()) || - (nsXULAtoms::xpmenubar == tag.get()) || - (nsXULAtoms::xpmenubutton == tag.get()) || + (nsXULAtoms::menu == tag.get()) || + (nsXULAtoms::menuitem == tag.get()) || + (nsXULAtoms::menubar == tag.get()) || + (nsXULAtoms::menupopup == tag.get()) || (nsXULAtoms::toolbox == tag.get()) || (nsXULAtoms::toolbar == tag.get()) || (nsXULAtoms::toolbaritem == tag.get()) || @@ -2781,8 +2781,8 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresContext* aPresConte aTag != nsXULAtoms::slider && aTag != nsXULAtoms::splitter && aTag != nsXULAtoms::scrollbar && - aTag != nsXULAtoms::xpmenu && - aTag != nsXULAtoms::xpmenuitem + aTag != nsXULAtoms::menu && + aTag != nsXULAtoms::menuitem ) { return NS_OK; @@ -2823,53 +2823,6 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresContext* aPresConte ConstructFrame(aPresContext, aState, content, aNewFrame, PR_FALSE, aChildItems); } -#ifdef XP_MENUS - if (aTag == nsXULAtoms::menu) { - // Create a menu button child if the menu has no children or - // only a menuchildren tag as its child. - PRInt32 childCount; - aContent->ChildCount(childCount); - PRBool createButton = PR_FALSE; - if (childCount == 0) - createButton = PR_TRUE; - else if (childCount == 1) { - // Figure out if our child is a menuchildren tag. - nsCOMPtr childContent; - aContent->ChildAt(0, *getter_AddRefs(childContent)); - nsCOMPtr tag; - childContent->GetTag(*getter_AddRefs(tag)); - if (tag.get() == nsXULAtoms::menuchildren) - createButton = PR_TRUE; - } - - if (createButton) { - nsCOMPtr idocument; - aContent->GetDocument(*getter_AddRefs(idocument)); - - nsCOMPtr document(do_QueryInterface(idocument)); - - // create a child button - nsCOMPtr node; - document->CreateElement("menubutton",getter_AddRefs(node)); - nsCOMPtr content; - //content->SetNameSpaceID(nsXULAtoms::nameSpaceID); - - content = do_QueryInterface(node); - - nsCOMPtr nameAtom = dont_AddRef(NS_NewAtom("name")); - nsCOMPtr valueAtom = dont_AddRef(NS_NewAtom("value")); - - nsString result; - aContent->GetAttribute(kNameSpaceID_None, nameAtom, result); - - content->SetAttribute(kNameSpaceID_None, valueAtom, result, PR_TRUE); - content->SetParent(aContent); - - ConstructFrame(aPresContext, aState, content, aParentFrame, PR_FALSE, aChildItems); - } - } -#endif // XP_MENUS - return NS_OK; } @@ -3036,27 +2989,25 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // End of PROGRESS METER CONSTRUCTION logic // Menu Construction - else if (aTag == nsXULAtoms::xpmenu || - aTag == nsXULAtoms::xpmenuitem) { + else if (aTag == nsXULAtoms::menu || + aTag == nsXULAtoms::menuitem) { // A derived class box frame // that has custom reflow to prevent menu children // from becoming part of the flow. processChildren = PR_TRUE; // Will need this to be custom. isReplaced = PR_TRUE; - rv = NS_NewMenuFrame(&newFrame, (aTag == nsXULAtoms::xpmenu)); + rv = NS_NewMenuFrame(&newFrame, (aTag == nsXULAtoms::menu)); } - else if (aTag == nsXULAtoms::xpmenubar) { - // XXX Will be a derived class toolbar frame. + else if (aTag == nsXULAtoms::menubar) { +#ifdef XP_MAC // The Mac uses its native menu bar. + haltProcessing = PR_TRUE; + return NS_OK; +#else processChildren = PR_TRUE; rv = NS_NewMenuBarFrame(&newFrame); +#endif } - else if (aTag == nsXULAtoms::xpmenubutton) { - // XXX Will be a derived class titledbutton frame - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - rv = NS_NewTitledButtonFrame(&newFrame); - } - else if (aTag == nsXULAtoms::xpmenuchildren) { + else if (aTag == nsXULAtoms::menupopup) { // This is its own frame that derives from // box. processChildren = PR_TRUE; diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 597b0f4df20..bae517ce512 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1826,10 +1826,10 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treecolgroup == tag.get()) || (nsXULAtoms::treefoot == tag.get()) || (nsXULAtoms::treepusher == tag.get()) || - (nsXULAtoms::xpmenu == tag.get()) || - (nsXULAtoms::xpmenuitem == tag.get()) || - (nsXULAtoms::xpmenubar == tag.get()) || - (nsXULAtoms::xpmenubutton == tag.get()) || + (nsXULAtoms::menu == tag.get()) || + (nsXULAtoms::menuitem == tag.get()) || + (nsXULAtoms::menubar == tag.get()) || + (nsXULAtoms::menupopup == tag.get()) || (nsXULAtoms::toolbox == tag.get()) || (nsXULAtoms::toolbar == tag.get()) || (nsXULAtoms::toolbaritem == tag.get()) || @@ -2781,8 +2781,8 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresContext* aPresConte aTag != nsXULAtoms::slider && aTag != nsXULAtoms::splitter && aTag != nsXULAtoms::scrollbar && - aTag != nsXULAtoms::xpmenu && - aTag != nsXULAtoms::xpmenuitem + aTag != nsXULAtoms::menu && + aTag != nsXULAtoms::menuitem ) { return NS_OK; @@ -2823,53 +2823,6 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresContext* aPresConte ConstructFrame(aPresContext, aState, content, aNewFrame, PR_FALSE, aChildItems); } -#ifdef XP_MENUS - if (aTag == nsXULAtoms::menu) { - // Create a menu button child if the menu has no children or - // only a menuchildren tag as its child. - PRInt32 childCount; - aContent->ChildCount(childCount); - PRBool createButton = PR_FALSE; - if (childCount == 0) - createButton = PR_TRUE; - else if (childCount == 1) { - // Figure out if our child is a menuchildren tag. - nsCOMPtr childContent; - aContent->ChildAt(0, *getter_AddRefs(childContent)); - nsCOMPtr tag; - childContent->GetTag(*getter_AddRefs(tag)); - if (tag.get() == nsXULAtoms::menuchildren) - createButton = PR_TRUE; - } - - if (createButton) { - nsCOMPtr idocument; - aContent->GetDocument(*getter_AddRefs(idocument)); - - nsCOMPtr document(do_QueryInterface(idocument)); - - // create a child button - nsCOMPtr node; - document->CreateElement("menubutton",getter_AddRefs(node)); - nsCOMPtr content; - //content->SetNameSpaceID(nsXULAtoms::nameSpaceID); - - content = do_QueryInterface(node); - - nsCOMPtr nameAtom = dont_AddRef(NS_NewAtom("name")); - nsCOMPtr valueAtom = dont_AddRef(NS_NewAtom("value")); - - nsString result; - aContent->GetAttribute(kNameSpaceID_None, nameAtom, result); - - content->SetAttribute(kNameSpaceID_None, valueAtom, result, PR_TRUE); - content->SetParent(aContent); - - ConstructFrame(aPresContext, aState, content, aParentFrame, PR_FALSE, aChildItems); - } - } -#endif // XP_MENUS - return NS_OK; } @@ -3036,27 +2989,25 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // End of PROGRESS METER CONSTRUCTION logic // Menu Construction - else if (aTag == nsXULAtoms::xpmenu || - aTag == nsXULAtoms::xpmenuitem) { + else if (aTag == nsXULAtoms::menu || + aTag == nsXULAtoms::menuitem) { // A derived class box frame // that has custom reflow to prevent menu children // from becoming part of the flow. processChildren = PR_TRUE; // Will need this to be custom. isReplaced = PR_TRUE; - rv = NS_NewMenuFrame(&newFrame, (aTag == nsXULAtoms::xpmenu)); + rv = NS_NewMenuFrame(&newFrame, (aTag == nsXULAtoms::menu)); } - else if (aTag == nsXULAtoms::xpmenubar) { - // XXX Will be a derived class toolbar frame. + else if (aTag == nsXULAtoms::menubar) { +#ifdef XP_MAC // The Mac uses its native menu bar. + haltProcessing = PR_TRUE; + return NS_OK; +#else processChildren = PR_TRUE; rv = NS_NewMenuBarFrame(&newFrame); +#endif } - else if (aTag == nsXULAtoms::xpmenubutton) { - // XXX Will be a derived class titledbutton frame - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - rv = NS_NewTitledButtonFrame(&newFrame); - } - else if (aTag == nsXULAtoms::xpmenuchildren) { + else if (aTag == nsXULAtoms::menupopup) { // This is its own frame that derives from // box. processChildren = PR_TRUE; diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index ac245329af1..cbed85a4e67 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -429,8 +429,8 @@ nsMenuBarFrame::IsValidItem(nsIContent* aContent) { nsCOMPtr tag; aContent->GetTag(*getter_AddRefs(tag)); - if (tag && (tag.get() == nsXULAtoms::xpmenu || - tag.get() == nsXULAtoms::xpmenuitem) && + if (tag && (tag.get() == nsXULAtoms::menu || + tag.get() == nsXULAtoms::menuitem) && !IsDisabled(aContent)) return PR_TRUE; diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 97e77afc83c..31d08e93e49 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -123,7 +123,7 @@ nsMenuFrame::Init(nsIPresContext& aPresContext, return rv; } -// The following methods are all overridden to ensure that the xpmenuchildren frame +// The following methods are all overridden to ensure that the menupopup frame // is placed in the appropriate list. NS_IMETHODIMP nsMenuFrame::FirstChild(nsIAtom* aListName, @@ -149,7 +149,7 @@ nsMenuFrame::SetInitialChildList(nsIPresContext& aPresContext, nsFrameList frames(aChildList); - // We may have an xpmenuchildren in here. Get it out, and move it into + // We may have a menupopup in here. Get it out, and move it into // the popup frame list. nsIFrame* frame = frames.FirstChild(); while (frame) { @@ -157,15 +157,18 @@ nsMenuFrame::SetInitialChildList(nsIPresContext& aPresContext, frame->GetContent(getter_AddRefs(content)); nsCOMPtr tag; content->GetTag(*getter_AddRefs(tag)); - if (tag.get() == nsXULAtoms::xpmenuchildren) { + if (tag.get() == nsXULAtoms::menupopup) { // Remove this frame from the list and place it in the other list. frames.RemoveFrame(frame); mPopupFrames.AppendFrame(this, frame); - rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList); + 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; @@ -222,17 +225,15 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext, if (mMenuParent) mMenuParent->IsMenuBar(isMenuBar); - if (isMenuBar) { + if (isMenuBar && mIsMenu) { // The menu item was selected. Bring up the menu. - nsIFrame* frame = mPopupFrames.FirstChild(); - if (frame) { - // We have children. - ToggleMenuState(); - if (!IsOpen()) { - // We closed up. The menu bar should always be - // deactivated when this happens. - mMenuParent->SetActive(PR_FALSE); - } + + // We have children. + ToggleMenuState(); + if (!IsOpen()) { + // We closed up. The menu bar should always be + // deactivated when this happens. + mMenuParent->SetActive(PR_FALSE); } } } @@ -327,22 +328,25 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag) nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); + // Generate the menu if it hasn't been generated already. This + // takes it from display: none to display: block and gives us + // a menu forevermore. + if (child) { + nsCOMPtr generated = dont_AddRef(NS_NewAtom("menugenerated")); + nsString genVal; + child->GetAttribute(kNameSpaceID_None, generated, genVal); + if (genVal == "") + child->SetAttribute(kNameSpaceID_None, generated, "true", PR_TRUE); + } + nsIFrame* frame = mPopupFrames.FirstChild(); nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame; - + if (aActivateFlag) { // Execute the oncreate handler if (!OnCreate()) return; - // Sync up the view. - PRBool onMenuBar = PR_TRUE; - if (mMenuParent) - mMenuParent->IsMenuBar(onMenuBar); - - if (menuPopup) - menuPopup->SyncViewWithFrame(onMenuBar); - // Open the menu. mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE); if (child) { @@ -351,6 +355,13 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag) // Tell the menu bar we're active. mMenuParent->SetActive(PR_TRUE); + + // Sync up the view. + PRBool onMenuBar = PR_FALSE; + if (mMenuParent) + mMenuParent->IsMenuBar(onMenuBar); + + menuPopup->SyncViewWithFrame(onMenuBar); } mMenuOpen = PR_TRUE; @@ -363,15 +374,15 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag) if (!OnDestroy()) return; + // Make sure we clear out our own items. + if (menuPopup) + menuPopup->SetCurrentMenuItem(nsnull); + mContent->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::open, PR_TRUE); if (child) child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE); mMenuOpen = PR_FALSE; - // Make sure we clear out our own items. - if (menuPopup) - menuPopup->SetCurrentMenuItem(nsnull); - // Set the focus back to our view's widget. nsIView* view; GetView(&view); @@ -388,10 +399,19 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag) void nsMenuFrame::GetMenuChildrenElement(nsIContent** aResult) { - *aResult = nsnull; - nsIFrame* frame = mPopupFrames.FirstChild(); - if (frame) { - frame->GetContent(aResult); + PRInt32 count; + mContent->ChildCount(count); + + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr child; + mContent->ChildAt(i, *getter_AddRefs(child)); + nsCOMPtr tag; + child->GetTag(*getter_AddRefs(tag)); + if (tag && tag.get() == nsXULAtoms::menupopup) { + *aResult = child.get(); + NS_ADDREF(*aResult); + return; + } } } @@ -434,6 +454,24 @@ nsMenuFrame::Reflow(nsIPresContext& aPresContext, return rv; } + +NS_IMETHODIMP +nsMenuFrame::DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus) +{ + // Sync up the view. + PRBool onMenuBar = PR_FALSE; + if (mMenuParent) + mMenuParent->IsMenuBar(onMenuBar); + + nsIFrame* frame = mPopupFrames.FirstChild(); + nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame; + if (menuPopup && mMenuOpen) + menuPopup->SyncViewWithFrame(onMenuBar); + + return nsBoxFrame::DidReflow(aPresContext, aStatus); +} + // Overridden Box method. NS_IMETHODIMP nsMenuFrame::Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild) @@ -444,6 +482,10 @@ nsMenuFrame::Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& incremental // Dirty any children that need it. nsIFrame* frame; aReflowState.reflowCommand->GetNext(frame, PR_FALSE); + if (frame == nsnull) { + incrementalChild = this; + return rv; + } // Now call our original box frame method rv = nsBoxFrame::Dirty(aReflowState, incrementalChild); @@ -543,7 +585,7 @@ nsMenuFrame::IsMenu() { nsCOMPtr tag; mContent->GetTag(*getter_AddRefs(tag)); - if (tag.get() == nsXULAtoms::xpmenu) + if (tag.get() == nsXULAtoms::menu) return PR_TRUE; return PR_FALSE; } @@ -587,17 +629,20 @@ nsMenuFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren) PRInt32 childCount; mContent->ChildCount(childCount); - PRBool createContent = PR_FALSE; - if (childCount == 0) - createContent = PR_TRUE; - else if (childCount == 1) { - // Figure out if our child is a menuchildren tag. + PRBool createContent = PR_TRUE; + for (PRInt32 i = 0; i < childCount; i++) { + // XXX Should optimize this to look for a display type of none. + // Not sure how to do this. For now screen out some known tags. nsCOMPtr childContent; - mContent->ChildAt(0, *getter_AddRefs(childContent)); + mContent->ChildAt(i, *getter_AddRefs(childContent)); nsCOMPtr tag; childContent->GetTag(*getter_AddRefs(tag)); - if (tag.get() == nsXULAtoms::xpmenuchildren) - createContent = PR_TRUE; + if (tag.get() != nsXULAtoms::menupopup && + tag.get() != nsXULAtoms::templateAtom && + tag.get() != nsXULAtoms::observes) { + createContent = PR_FALSE; + break; + } } if (!createContent) @@ -672,33 +717,55 @@ nsMenuFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren) // Create a spring that serves as padding between the text and the // accelerator. - nsDocument->CreateElementWithNameSpace("spring", xulNamespace, getter_AddRefs(node)); - content = do_QueryInterface(node); - content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "100", PR_FALSE); - aAnonymousChildren.AppendElement(content); - - // Build the accelerator out of the corresponding key node. - nsString accelString; - BuildAcceleratorText(accelString); - if (accelString != "") { - // Create the accelerator (it's a div) - nsDocument->CreateElementWithNameSpace("div", htmlNamespace, getter_AddRefs(node)); + if (!onMenuBar) { + nsDocument->CreateElementWithNameSpace("spring", xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); + content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "100", PR_FALSE); aAnonymousChildren.AppendElement(content); + + // Build the accelerator out of the corresponding key node. + nsString accelString; + BuildAcceleratorText(accelString); + if (accelString != "") { + // Create the accelerator (it's a div) + nsDocument->CreateElementWithNameSpace("div", htmlNamespace, getter_AddRefs(node)); + content = do_QueryInterface(node); + aAnonymousChildren.AppendElement(content); - nsCOMPtr accelNode; - document->CreateTextNode(accelString, getter_AddRefs(accelNode)); - node->AppendChild(accelNode, getter_AddRefs(dummyResult)); - } + nsCOMPtr accelNode; + document->CreateTextNode(accelString, getter_AddRefs(accelNode)); + node->AppendChild(accelNode, getter_AddRefs(dummyResult)); + } - // Create the "menu-right" object. It's a titledbutton. - if (!onMenuBar) { // XXX Maybe we should make one for a .menubar-right class so that the option exists + // Create the "menu-right" object. It's a titledbutton. + // XXX Maybe we should make one for a .menubar-right class so that the option exists nsDocument->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node)); content = do_QueryInterface(node); content->SetAttribute(kNameSpaceID_None, classAtom, "menu-right", PR_FALSE); aAnonymousChildren.AppendElement(content); } + // Make this insertion explicit. + /*PRUint32 count = 0; + aAnonymousChildren.Count(&count); + + PRUint32 i; + for (i=0; i < count; i++) + { + // get our child's content and set its parent to our content + nsCOMPtr node; + aAnonymousChildren.GetElementAt(i,getter_AddRefs(node)); + nsCOMPtr content(do_QueryInterface(node)); + mContent->AppendChildTo(content, PR_TRUE); + } + + // Empty the array. + for (i=0; i < count; i++) + { + aAnonymousChildren.RemoveElementAt(0); + } +*/ + return NS_OK; } @@ -845,4 +912,69 @@ nsMenuFrame::OnDestroy() if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) return PR_FALSE; return PR_TRUE; +} + +NS_IMETHODIMP +nsMenuFrame::RemoveFrame(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aOldFrame) +{ + // need to rebuild all the springs. + for (int i=0; i < mSpringCount; i++) + mSprings[i].clear(); + + nsIFrame* popup = mPopupFrames.FirstChild(); + if (popup == aOldFrame) { + // Go ahead and remove this frame. + nsHTMLContainerFrame::RemoveFrame(aPresContext, aPresShell, nsLayoutAtoms::popupList, aOldFrame); + mPopupFrames.DestroyFrame(aPresContext, aOldFrame); + return NS_OK; + } + + return nsBoxFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame); +} + +NS_IMETHODIMP +nsMenuFrame::InsertFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aPrevFrame, + nsIFrame* aFrameList) +{ + // need to rebuild all the springs. + for (int i=0; i < mSpringCount; i++) + mSprings[i].clear(); + + nsCOMPtr menuChildren; + nsCOMPtr frameChild; + GetMenuChildrenElement(getter_AddRefs(menuChildren)); + aFrameList->GetContent(getter_AddRefs(frameChild)); + + if (menuChildren.get() == frameChild.get()) { + mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList); + } + return nsHTMLContainerFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList); +} + +NS_IMETHODIMP +nsMenuFrame::AppendFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aFrameList) +{ + // need to rebuild all the springs. + for (int i=0; i < mSpringCount; i++) + mSprings[i].clear(); + + nsCOMPtr menuChildren; + nsCOMPtr frameChild; + GetMenuChildrenElement(getter_AddRefs(menuChildren)); + aFrameList->GetContent(getter_AddRefs(frameChild)); + + if (menuChildren.get() == frameChild.get()) { + mPopupFrames.AppendFrames(nsnull, aFrameList); + } + + return nsHTMLContainerFrame::AppendFrames(aPresContext, aPresShell, aListName, aFrameList); } \ No newline at end of file diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.h b/mozilla/layout/xul/base/src/nsMenuFrame.h index b217a9f6f66..dbc2f3a3d79 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuFrame.h @@ -86,8 +86,27 @@ public: nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); + NS_IMETHOD DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus); + NS_IMETHOD Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild); + 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); + void KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag); void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag); void Escape(PRBool& aHandledFlag); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 1f0afec3d5c..b8fa5b1ec9b 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -533,8 +533,8 @@ nsMenuPopupFrame::IsValidItem(nsIContent* aContent) { nsCOMPtr tag; aContent->GetTag(*getter_AddRefs(tag)); - if (tag && (tag.get() == nsXULAtoms::xpmenu || - tag.get() == nsXULAtoms::xpmenuitem) && + if (tag && (tag.get() == nsXULAtoms::menu || + tag.get() == nsXULAtoms::menuitem) && !IsDisabled(aContent)) return PR_TRUE; diff --git a/mozilla/layout/xul/content/src/nsXULAtomList.h b/mozilla/layout/xul/content/src/nsXULAtomList.h index f37135d2bc7..e8bcfb84cef 100644 --- a/mozilla/layout/xul/content/src/nsXULAtomList.h +++ b/mozilla/layout/xul/content/src/nsXULAtomList.h @@ -63,22 +63,20 @@ XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view XUL_ATOM(treefoot, "treefoot") // The footer of the tree view XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view -XUL_ATOM(menuitem, "menuitem") // The menu element -XUL_ATOM(menubar, "menubar") // The menubar element -XUL_ATOM(menu, "menu") // A single menu item - XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open -XUL_ATOM(xpmenubar, "xpmenubar") // An XP menu bar. -XUL_ATOM(xpmenu, "xpmenu") // Represents an XP menu -XUL_ATOM(xpmenuitem, "xpmenuitem") // Represents an XP menu item -XUL_ATOM(xpmenubutton, "xpmenubutton") // A titled button (with improved behavior) inside an XP menu. -XUL_ATOM(xpmenuchildren, "xpmenuchildren") // The XP menu's children. +XUL_ATOM(menubar, "menubar") // An XP menu bar. +XUL_ATOM(menu, "menu") // Represents an XP menu +XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item +XUL_ATOM(menupopup, "menupopup") // The XP menu's children. 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(key, "key") // A key element +XUL_ATOM(broadcaster, "broadcaster") // A broadcaster +XUL_ATOM(observes, "observes") // The observes element +XUL_ATOM(templateAtom, "template") // A XUL template XUL_ATOM(progressmeter, "progressmeter") XUL_ATOM(titledbutton, "titledbutton") diff --git a/mozilla/suite/browser/navigator.xul b/mozilla/suite/browser/navigator.xul index 1e55eb400fd..a74b0af6c99 100644 --- a/mozilla/suite/browser/navigator.xul +++ b/mozilla/suite/browser/navigator.xul @@ -400,12 +400,12 @@ Contributor(s): ______________________________________. --> Please do be so kind as to reflect any changes made into that file as well, in anticipation of the happy day when the parser will let us use included files. --> - - + + - + @@ -435,7 +435,8 @@ Contributor(s): ______________________________________. --> - + + @@ -648,7 +649,7 @@ Contributor(s): ______________________________________. --> // Menu for testing. - // Build verification sites. + @@ -679,7 +680,7 @@ Contributor(s): ______________________________________. --> - // Viewer tests. + @@ -701,7 +702,7 @@ Contributor(s): ______________________________________. --> - // XPToolkit tests. + @@ -717,7 +718,7 @@ Contributor(s): ______________________________________. --> - // QA tests. + @@ -727,10 +728,8 @@ Contributor(s): ______________________________________. --> - + - - diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 94a56288950..364ea5b5ae3 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1812,6 +1812,7 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, mLockedUntilChromeLoad = PR_FALSE; } +#ifdef XP_MAC // register as document listener // this is needed for menus nsCOMPtr cv; @@ -1838,7 +1839,7 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, nsCOMPtr menubarDOMDoc(GetNamedDOMDoc(nsAutoString("this"))); // XXX "this" is a small kludge for code reused if (menubarDOMDoc) { -#if defined XP_MAC || defined XP_BEOS +#ifdef XP_MAC LoadMenus(menubarDOMDoc, mWindow); // Context Menu test nsCOMPtr element; @@ -1850,8 +1851,9 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, // End Context Menu test #else DynamicLoadMenus(menubarDOMDoc, mWindow); -#endif +#endif // XP_MAC } +#endif // XP_MAC SetTitleFromXUL(); ShowAppropriateChrome(); diff --git a/mozilla/xpfe/browser/resources/content/navigator.xul b/mozilla/xpfe/browser/resources/content/navigator.xul index 1e55eb400fd..a74b0af6c99 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.xul +++ b/mozilla/xpfe/browser/resources/content/navigator.xul @@ -400,12 +400,12 @@ Contributor(s): ______________________________________. --> Please do be so kind as to reflect any changes made into that file as well, in anticipation of the happy day when the parser will let us use included files. --> - - + + - + @@ -435,7 +435,8 @@ Contributor(s): ______________________________________. --> - + + @@ -648,7 +649,7 @@ Contributor(s): ______________________________________. --> // Menu for testing. - // Build verification sites. + @@ -679,7 +680,7 @@ Contributor(s): ______________________________________. --> - // Viewer tests. + @@ -701,7 +702,7 @@ Contributor(s): ______________________________________. --> - // XPToolkit tests. + @@ -717,7 +718,7 @@ Contributor(s): ______________________________________. --> - // QA tests. + @@ -727,10 +728,8 @@ Contributor(s): ______________________________________. --> - + - - diff --git a/mozilla/xpfe/browser/samples/xpmenu.xul b/mozilla/xpfe/browser/samples/xpmenu.xul index 969ccfd10e8..dde4cdc031d 100644 --- a/mozilla/xpfe/browser/samples/xpmenu.xul +++ b/mozilla/xpfe/browser/samples/xpmenu.xul @@ -28,108 +28,108 @@ Contributor(s): ______________________________________. --> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" align="vertical"> - - + + File - - + + New Ctrl+N - - - - - - + + + + + + Open... Ctrl+O - - + + Close - - - + + + Save Ctrl+S - - + + Save as... - - + + Quit Ctrl+Q - - + + - - + + Edit - - Sample Item - - - + + Sample Item + + + View - - Sample Item - - - + + Sample Item + + + Search - - Sample Item - - - + + Sample Item + + + Go - - Sample Item - - - + + Sample Item + + + Bookmarks - - Sample Item - - - + + Sample Item + + + Tasks - - Sample Item - - - + + Sample Item + + + Debug - - Sample Item - - - + + Sample Item + + + QA - - Sample Item - - + + Sample Item + + - + diff --git a/mozilla/xpfe/global/resources/skin/xul.css b/mozilla/xpfe/global/resources/skin/xul.css index e5e55ac81fe..ce819ac1819 100644 --- a/mozilla/xpfe/global/resources/skin/xul.css +++ b/mozilla/xpfe/global/resources/skin/xul.css @@ -40,6 +40,10 @@ popup { display: none; } +template { + display: none; +} + div { background-color:inherit; background-image:inherit; @@ -270,75 +274,72 @@ observes { } menubar { - display: none; -} - -menu { - display: none; -} - -menuitem { - display: none; -} - -xpmenubar { display:block; background-color: #CCCCDD; border-bottom: 1px solid #9999cc; font: inherit; } -xpmenubar[collapsed="true"] { +menubar[collapsed="true"] { display:none; } -xpmenubar[hidden="true"] { +menubar[hidden="true"] { display:none; } -xpmenu { +menu { display: block; font: inherit; + color: black; } -xpmenu[disabled="true"] { +menu[disabled="true"] { color: #999999; } -xpmenuitem { +menuitem { display: block; font: inherit; + color: black; } -xpmenuitem[disabled="true"] { +menuitem[disabled="true"] { color: #999999; } -xpmenuchildren { +menupopup { + display: none; +} + +menupopup[menugenerated="true"] { display: block; +} + +menupopup { font: inherit; - visibility:hidden; + visibility: hidden; background-color: #CCCCDD; color: inherit; border: 1px white outset; } -xpmenuchildren[menuactive="true"] { +menupopup[menuactive="true"] { visibility: visible; } -xpmenuchildren xpmenu { +menupopup menu { max-width: 400px; min-width: 125px; margin: 1px; } -xpmenuchildren xpmenuitem { +menupopup menuitem { max-width: 400px; min-width: 125px; margin: 1px; } -xpmenuseparator { +menuseparator { display: block; border-bottom: 1px white solid; border-top: 1px gray solid; @@ -1124,7 +1125,7 @@ treeitem [open="true"]> treerow > treecell > titledbutton.twisty { } -xpmenubar > xpmenu { +menubar > menu { border: 1px solid transparent; padding-top: 2px; padding-bottom: 2px; @@ -1134,31 +1135,31 @@ xpmenubar > xpmenu { margin-bottom: 2px; } -xpmenuchildren > xpmenu { +menupopup > menu { border: 1px solid transparent; padding: 2px; } -xpmenuchildren > xpmenuitem { +menupopup > menuitem { border: 1px solid transparent; padding: 2px; } -xpmenubar > xpmenu[menuactive="true"] { +menubar > menu[menuactive="true"] { border: 1px outset white; color:#333366; } -xpmenubar > xpmenu[menuactive="true"][open="true"] { +menubar > menu[menuactive="true"][open="true"] { border: 1px inset; } -xpmenuchildren > xpmenu[menuactive="true"] { +menupopup > menu[menuactive="true"] { background-color: #666699; color: white; } -xpmenuchildren > xpmenuitem[menuactive="true"] { +menupopup > menuitem[menuactive="true"] { background-color: #666699; color: white; } @@ -1178,18 +1179,18 @@ xpmenuchildren > xpmenuitem[menuactive="true"] { margin-right: 2px; } -xpmenuitem > .menu-right { +menuitem > .menu-right { list-style-image: none; } -xpmenuitem > .menu-left { +menuitem > .menu-left { list-style-image: none; } -xpmenu > .menu-right { +menu > .menu-right { list-style-image: url(chrome://global/skin/menuArrow.gif); } -xpmenu[menuactive="true"] > .menu-right { +menu[menuactive="true"] > .menu-right { list-style-image: url(chrome://global/skin/menuArrow_mo.gif); }