From 0d030280908d9ceb465a2ce2e74a3acc2b5f5180 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 27 Mar 2002 07:01:26 +0000 Subject: [PATCH] Revert to using an attribute for menuactive (bug 133610). r=ben/jkeiser, sr=jst, a=asa. git-svn-id: svn://10.0.0.236/trunk@117621 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/xul/nsXULMenuAccessible.cpp | 18 ++--- mozilla/content/base/public/MANIFEST | 1 - mozilla/content/base/public/Makefile.in | 1 - mozilla/content/base/public/makefile.win | 1 - mozilla/content/base/public/nsIMenuElement.h | 73 ------------------- .../base/public/nsIStyleRuleProcessor.h | 1 - .../content/src/nsHTMLOptGroupElement.cpp | 25 +------ .../html/content/src/nsHTMLSelectElement.cpp | 22 +----- .../content/html/style/src/nsCSSParser.cpp | 1 - .../html/style/src/nsCSSStyleSheet.cpp | 23 ------ mozilla/content/shared/public/nsCSSAtomList.h | 1 - mozilla/content/shared/public/nsXULAtomList.h | 2 +- mozilla/content/xul/content/src/Makefile.in | 1 - mozilla/content/xul/content/src/makefile.win | 1 - .../content/xul/content/src/nsXULElement.cpp | 12 +-- mozilla/layout/style/nsCSSParser.cpp | 1 - mozilla/layout/style/nsCSSStyleSheet.cpp | 23 ------ mozilla/layout/style/nsIStyleRuleProcessor.h | 1 - mozilla/layout/xul/base/public/nsIMenuFrame.h | 2 - .../layout/xul/base/src/nsMenuBarFrame.cpp | 42 +---------- mozilla/layout/xul/base/src/nsMenuFrame.cpp | 29 ++------ mozilla/layout/xul/base/src/nsMenuFrame.h | 2 - .../layout/xul/base/src/nsMenuPopupFrame.cpp | 30 -------- mozilla/themes/classic/global/mac/menu.css | 28 +++---- mozilla/themes/classic/global/win/menu.css | 24 +++--- mozilla/themes/modern/global/menu.css | 24 +++--- .../resources/content/bindings/menu.xml | 6 +- 27 files changed, 62 insertions(+), 333 deletions(-) delete mode 100644 mozilla/content/base/public/nsIMenuElement.h diff --git a/mozilla/accessible/src/xul/nsXULMenuAccessible.cpp b/mozilla/accessible/src/xul/nsXULMenuAccessible.cpp index 84c29d0d5ec..fa92beb36a2 100644 --- a/mozilla/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/mozilla/accessible/src/xul/nsXULMenuAccessible.cpp @@ -41,7 +41,7 @@ #include "nsAccessible.h" #include "nsIAccessible.h" #include "nsIDOMElement.h" -#include "nsIMenuElement.h" +#include "nsIDOMXULPopupElement.h" // ------------------------ Menu Item ----------------------------- @@ -56,18 +56,14 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetAccState(PRUint32 *_retval) nsAccessible::GetAccState(_retval); // Focused? - nsCOMPtr content = do_QueryInterface(mDOMNode); - nsCOMPtr parent; - content->GetParent(*getter_AddRefs(parent)); - if (parent) { - nsCOMPtr menuEl = do_QueryInterface(parent); - if (content == menuEl->GetActiveItem()) - *_retval |= STATE_FOCUSED; - } - - // Has Popup? nsCOMPtr element(do_QueryInterface(mDOMNode)); NS_ASSERTION(element, "No DOM element for menu node!"); + PRBool isFocused = PR_FALSE; + element->HasAttribute(NS_LITERAL_STRING("_moz-menuactive"), &isFocused); + if (isFocused) + *_retval |= STATE_FOCUSED; + + // Has Popup? nsAutoString tagName; element->GetLocalName(tagName); if (tagName.Equals(NS_LITERAL_STRING("menu"))) diff --git a/mozilla/content/base/public/MANIFEST b/mozilla/content/base/public/MANIFEST index 1c752b356b1..805b3c61427 100644 --- a/mozilla/content/base/public/MANIFEST +++ b/mozilla/content/base/public/MANIFEST @@ -27,4 +27,3 @@ nsIStyleSheet.h nsIStyleSheetLinkingElement.h nsITextContent.h nsIContentList.h -nsIMenuElement.h diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in index 25d676cafe5..3179cbb90aa 100644 --- a/mozilla/content/base/public/Makefile.in +++ b/mozilla/content/base/public/Makefile.in @@ -56,7 +56,6 @@ nsIPrivateDOMImplementation.h \ nsIContentSerializer.h \ nsIHTMLToTextSink.h \ nsIContentList.h \ -nsIMenuElement.h \ $(NULL) XPIDLSRCS = \ diff --git a/mozilla/content/base/public/makefile.win b/mozilla/content/base/public/makefile.win index 4a97d098542..74d364afd98 100644 --- a/mozilla/content/base/public/makefile.win +++ b/mozilla/content/base/public/makefile.win @@ -48,7 +48,6 @@ EXPORTS = \ nsIContentSerializer.h \ nsIHTMLToTextSink.h \ nsIContentList.h \ - nsIMenuElement.h \ $(NULL) MODULE=content diff --git a/mozilla/content/base/public/nsIMenuElement.h b/mozilla/content/base/public/nsIMenuElement.h deleted file mode 100644 index 0809132acd3..00000000000 --- a/mozilla/content/base/public/nsIMenuElement.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla 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/MPL/ - * - * 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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Brian Ryner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * nsIMenuElement is an interface to be implemented on the - * parent nodes of elements which can be in the :-moz-menuactive - * state (this corresponds to hovering over the item or going to - * it with the arrow keys). It is used by the CSS pseudoclass - * matching code to decide if a menu item matches :-moz-menuactive. - */ - -#ifndef _nsIMenuElement_h_ -#define _nsIMenuElement_h_ - -#include "nsISupports.h" - -// IID for the nsIMenuElement interface -#define NS_IMENUELEMENT_IID \ - { 0xbfede654, 0x1dd1, 0x11b2, \ - { 0x89, 0x35, 0x87, 0x92, 0xfc, 0xb7, 0xc9, 0xa1 } } - -class nsIMenuElement : public nsISupports { -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUELEMENT_IID); - - /** - * Get the current active item for this menu. - */ - virtual const nsIContent* GetActiveItem() const = 0; - - /** - * Set the active item for this menu. - * @ param aItem The new active item - */ - virtual void SetActiveItem(const nsIContent* aItem) = 0; -}; - -#endif diff --git a/mozilla/content/base/public/nsIStyleRuleProcessor.h b/mozilla/content/base/public/nsIStyleRuleProcessor.h index 01066ca7542..7079ad111cc 100644 --- a/mozilla/content/base/public/nsIStyleRuleProcessor.h +++ b/mozilla/content/base/public/nsIStyleRuleProcessor.h @@ -93,7 +93,6 @@ struct RuleProcessorData { PRPackedBool mIsQuirkMode; // Possibly remove use of this in SelectorMatches? PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0 PRPackedBool mIsChecked; // checked/selected attribute for option and select elements - PRPackedBool mIsMenuActive; // menuactive state for options/menus/menuitems nsLinkState mLinkState; // if a link, this is the state, otherwise unknown PRInt32 mEventState; // if content, eventStateMgr->GetContentState() PRInt32 mNameSpaceID; // if content, content->GetNameSapce() diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp index 93ae0cb581a..6ca47a6e39e 100644 --- a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp @@ -49,12 +49,10 @@ #include "nsISelectElement.h" #include "nsIDOMHTMLSelectElement.h" -#include "nsIMenuElement.h" class nsHTMLOptGroupElement : public nsGenericHTMLContainerElement, - public nsIDOMHTMLOptGroupElement, - public nsIMenuElement + public nsIDOMHTMLOptGroupElement { public: nsHTMLOptGroupElement(); @@ -87,11 +85,6 @@ public: NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsEventStatus* aEventStatus); - - // nsIMenuElement - virtual const nsIContent* GetActiveItem() const; - virtual void SetActiveItem(const nsIContent* aItem); - #ifdef DEBUG NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const; #endif @@ -99,8 +92,6 @@ public: protected: nsresult GetSelect(nsISelectElement **aSelectElement); - - const nsIContent* mActiveItem; }; nsresult @@ -131,7 +122,6 @@ NS_NewHTMLOptGroupElement(nsIHTMLContent** aInstancePtrResult, nsHTMLOptGroupElement::nsHTMLOptGroupElement() - : mActiveItem(nsnull) { } @@ -148,7 +138,6 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLOptGroupElement, nsGenericElement); NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLOptGroupElement, nsGenericHTMLContainerElement) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLOptGroupElement) - NS_INTERFACE_MAP_ENTRY(nsIMenuElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLOptGroupElement) NS_HTML_CONTENT_INTERFACE_MAP_END @@ -323,15 +312,3 @@ nsHTMLOptGroupElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) return rv; } - -const nsIContent* -nsHTMLOptGroupElement::GetActiveItem() const -{ - return mActiveItem; -} - -void -nsHTMLOptGroupElement::SetActiveItem(const nsIContent* aItem) -{ - mActiveItem = aItem; -} diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 13c5b8fe2e7..c9b693160a5 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -79,7 +79,7 @@ #include "nsIPresShell.h" #include "nsIFormControlFrame.h" #include "nsIFrame.h" -#include "nsIMenuElement.h" + #include "nsRuleNode.h" @@ -125,8 +125,7 @@ class nsHTMLSelectElement : public nsGenericHTMLContainerFormElement, public nsIDOMHTMLSelectElement, public nsIDOMNSHTMLSelectElement, public nsIDOMNSXBLFormControl, - public nsISelectElement, - public nsIMenuElement + public nsISelectElement { public: nsHTMLSelectElement(); @@ -190,9 +189,6 @@ public: NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, PRInt32& aHint) const; - // nsIMenuElement - virtual const nsIContent* GetActiveItem() const; - virtual void SetActiveItem(const nsIContent* aItem); protected: // Helper Methods @@ -246,7 +242,6 @@ protected: PRUint32 mArtifactsAtTopLevel; PRInt32 mSelectedIndex; nsString* mRestoreState; - const nsIContent* mActiveItem; }; @@ -294,7 +289,6 @@ nsHTMLSelectElement::nsHTMLSelectElement() mRestoreState = nsnull; mSelectedIndex = -1; - mActiveItem = nsnull; } nsHTMLSelectElement::~nsHTMLSelectElement() @@ -324,7 +318,6 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLSelectElement, NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLSelectElement) NS_INTERFACE_MAP_ENTRY(nsIDOMNSXBLFormControl) NS_INTERFACE_MAP_ENTRY(nsISelectElement) - NS_INTERFACE_MAP_ENTRY(nsIMenuElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLSelectElement) NS_HTML_CONTENT_INTERFACE_MAP_END @@ -2043,17 +2036,6 @@ nsHTMLSelectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, return NS_OK; } -const nsIContent* -nsHTMLSelectElement::GetActiveItem() const -{ - return mActiveItem; -} - -void -nsHTMLSelectElement::SetActiveItem(const nsIContent* aItem) -{ - mActiveItem = aItem; -} //---------------------------------------------------------------------- // diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 2eb79c08ddf..8b8a56cbdaa 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -1557,7 +1557,6 @@ static PRBool IsPseudoClass(const nsIAtom* aAtom) (nsCSSAtoms::lastChildPseudo == aAtom) || (nsCSSAtoms::lastNodePseudo == aAtom) || (nsCSSAtoms::linkPseudo == aAtom) || - (nsCSSAtoms::menuActivePseudo == aAtom) || (nsCSSAtoms::rootPseudo == aAtom) || (nsCSSAtoms::xblBoundElementPseudo == aAtom) || (nsCSSAtoms::visitedPseudo == aAtom)); diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index 8be8f7a8873..0bdc6d98e1f 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -98,10 +98,8 @@ #include "nsISizeOfHandler.h" #include "nsStyleUtil.h" #include "nsQuickSort.h" -#include "nsIMenuElement.h" #ifdef MOZ_XUL #include "nsIXULContent.h" -#include "nsXULAtoms.h" #endif #include "nsContentUtils.h" @@ -3252,7 +3250,6 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, mIsHTMLLink = PR_FALSE; mIsSimpleXLink = PR_FALSE; mIsChecked = PR_FALSE; - mIsMenuActive = PR_FALSE; mLinkState = eLinkState_Unknown; mEventState = NS_EVENT_STATE_UNSPECIFIED; mNameSpaceID = kNameSpaceID_Unknown; @@ -3321,7 +3318,6 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, mIsSimpleXLink = PR_TRUE; } - // The :checked pseudoclass applies to input and option elements if (mIsHTMLContent) { PRBool isChecked = PR_FALSE; if (mContentTag == nsHTMLAtoms::option) { @@ -3331,20 +3327,8 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, nsCOMPtr inputEl = do_QueryInterface(mContent); inputEl->GetChecked(&isChecked); } - mIsChecked = isChecked; } - - // The :-moz-menuactive pseudoclass applies to HTML option elements, - // XUL menuitem elements, and XUL menu elements. - if ((mIsHTMLContent && mContentTag == nsHTMLAtoms::option) || - (mContent->IsContentOfType(nsIContent::eXUL) && - (mContentTag == nsXULAtoms::menuitem || mContentTag == nsXULAtoms::menu))) { - - nsCOMPtr menuEl = do_QueryInterface(mParentContent); - if (menuEl) - mIsMenuActive = (mContent == menuEl->GetActiveItem()); - } } } @@ -3644,12 +3628,6 @@ static PRBool SelectorMatches(RuleProcessorData &data, if (aTestState) result = data.mIsChecked ? localTrue : localFalse; } - else if (nsCSSAtoms::menuActivePseudo == pseudoClass->mAtom) { - // This pseudoclass will match on at most one child of - // a menupopup. - if (aTestState) - result = data.mIsMenuActive ? localTrue : localFalse; - } else { result = localFalse; // unknown pseudo class } @@ -4286,7 +4264,6 @@ PRBool IsStateSelector(nsCSSSelector& aSelector) (pseudoClass->mAtom == nsCSSAtoms::focusPseudo) || (pseudoClass->mAtom == nsCSSAtoms::hoverPseudo) || (pseudoClass->mAtom == nsCSSAtoms::linkPseudo) || - (pseudoClass->mAtom == nsCSSAtoms::menuActivePseudo) || (pseudoClass->mAtom == nsCSSAtoms::selectionPseudo) || (pseudoClass->mAtom == nsCSSAtoms::visitedPseudo)) { return PR_TRUE; diff --git a/mozilla/content/shared/public/nsCSSAtomList.h b/mozilla/content/shared/public/nsCSSAtomList.h index b9dc94648e3..78b03221176 100644 --- a/mozilla/content/shared/public/nsCSSAtomList.h +++ b/mozilla/content/shared/public/nsCSSAtomList.h @@ -85,7 +85,6 @@ CSS_ATOM(langPseudo, ":lang") CSS_ATOM(linkPseudo, ":link") CSS_ATOM(menuPseudo, ":menu") -CSS_ATOM(menuActivePseudo, ":-moz-menuactive") CSS_ATOM(notPseudo, ":not") diff --git a/mozilla/content/shared/public/nsXULAtomList.h b/mozilla/content/shared/public/nsXULAtomList.h index fdde3fbb02b..f833c8faaeb 100644 --- a/mozilla/content/shared/public/nsXULAtomList.h +++ b/mozilla/content/shared/public/nsXULAtomList.h @@ -129,7 +129,7 @@ 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(menutobedisplayed, "menutobedisplayed") // The menu is about to be displayed at the next sync w/ frame -XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open) +XUL_ATOM(menuactive, "_moz-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(popupgroup, "popupgroup") // Contains popup menus, context menus, and tooltips diff --git a/mozilla/content/xul/content/src/Makefile.in b/mozilla/content/xul/content/src/Makefile.in index c2867fb65df..ba1e56f1f2c 100644 --- a/mozilla/content/xul/content/src/Makefile.in +++ b/mozilla/content/xul/content/src/Makefile.in @@ -55,7 +55,6 @@ CPPSRCS = \ nsXULAttributes.cpp \ nsXULElement.cpp \ nsXULPopupListener.cpp \ - nsXULMenuElement.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/content/xul/content/src/makefile.win b/mozilla/content/xul/content/src/makefile.win index 2f66fa1d24f..b8430a0c398 100644 --- a/mozilla/content/xul/content/src/makefile.win +++ b/mozilla/content/xul/content/src/makefile.win @@ -51,7 +51,6 @@ CPP_OBJS= \ .\$(OBJDIR)\nsXULAttributes.obj \ .\$(OBJDIR)\nsXULElement.obj \ .\$(OBJDIR)\nsXULPopupListener.obj \ - .\$(OBJDIR)\nsXULMenuElement.obj \ $(NULL) LINCS= \ diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 6a934b1408a..44a1413990b 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -129,7 +129,6 @@ #include "nsITreeBoxObject.h" #include "nsContentUtils.h" #include "nsGenericElement.h" -#include "nsXULMenuElement.h" #include "nsMutationEvent.h" #include "nsIDOMMutationEvent.h" @@ -561,16 +560,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, if (! aResult) return NS_ERROR_NULL_POINTER; - nsXULElement* element; - - if (aPrototype->mNodeInfo && - (aPrototype->mNodeInfo->Equals(nsXULAtoms::menubar) || - aPrototype->mNodeInfo->Equals(nsXULAtoms::menupopup) || - aPrototype->mNodeInfo->Equals(nsXULAtoms::popup))) - element = new nsXULMenuElement(); - else - element = new nsXULElement(); - + nsXULElement* element = new nsXULElement(); if (! element) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/style/nsCSSParser.cpp b/mozilla/layout/style/nsCSSParser.cpp index 2eb79c08ddf..8b8a56cbdaa 100644 --- a/mozilla/layout/style/nsCSSParser.cpp +++ b/mozilla/layout/style/nsCSSParser.cpp @@ -1557,7 +1557,6 @@ static PRBool IsPseudoClass(const nsIAtom* aAtom) (nsCSSAtoms::lastChildPseudo == aAtom) || (nsCSSAtoms::lastNodePseudo == aAtom) || (nsCSSAtoms::linkPseudo == aAtom) || - (nsCSSAtoms::menuActivePseudo == aAtom) || (nsCSSAtoms::rootPseudo == aAtom) || (nsCSSAtoms::xblBoundElementPseudo == aAtom) || (nsCSSAtoms::visitedPseudo == aAtom)); diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index 8be8f7a8873..0bdc6d98e1f 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -98,10 +98,8 @@ #include "nsISizeOfHandler.h" #include "nsStyleUtil.h" #include "nsQuickSort.h" -#include "nsIMenuElement.h" #ifdef MOZ_XUL #include "nsIXULContent.h" -#include "nsXULAtoms.h" #endif #include "nsContentUtils.h" @@ -3252,7 +3250,6 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, mIsHTMLLink = PR_FALSE; mIsSimpleXLink = PR_FALSE; mIsChecked = PR_FALSE; - mIsMenuActive = PR_FALSE; mLinkState = eLinkState_Unknown; mEventState = NS_EVENT_STATE_UNSPECIFIED; mNameSpaceID = kNameSpaceID_Unknown; @@ -3321,7 +3318,6 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, mIsSimpleXLink = PR_TRUE; } - // The :checked pseudoclass applies to input and option elements if (mIsHTMLContent) { PRBool isChecked = PR_FALSE; if (mContentTag == nsHTMLAtoms::option) { @@ -3331,20 +3327,8 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext, nsCOMPtr inputEl = do_QueryInterface(mContent); inputEl->GetChecked(&isChecked); } - mIsChecked = isChecked; } - - // The :-moz-menuactive pseudoclass applies to HTML option elements, - // XUL menuitem elements, and XUL menu elements. - if ((mIsHTMLContent && mContentTag == nsHTMLAtoms::option) || - (mContent->IsContentOfType(nsIContent::eXUL) && - (mContentTag == nsXULAtoms::menuitem || mContentTag == nsXULAtoms::menu))) { - - nsCOMPtr menuEl = do_QueryInterface(mParentContent); - if (menuEl) - mIsMenuActive = (mContent == menuEl->GetActiveItem()); - } } } @@ -3644,12 +3628,6 @@ static PRBool SelectorMatches(RuleProcessorData &data, if (aTestState) result = data.mIsChecked ? localTrue : localFalse; } - else if (nsCSSAtoms::menuActivePseudo == pseudoClass->mAtom) { - // This pseudoclass will match on at most one child of - // a menupopup. - if (aTestState) - result = data.mIsMenuActive ? localTrue : localFalse; - } else { result = localFalse; // unknown pseudo class } @@ -4286,7 +4264,6 @@ PRBool IsStateSelector(nsCSSSelector& aSelector) (pseudoClass->mAtom == nsCSSAtoms::focusPseudo) || (pseudoClass->mAtom == nsCSSAtoms::hoverPseudo) || (pseudoClass->mAtom == nsCSSAtoms::linkPseudo) || - (pseudoClass->mAtom == nsCSSAtoms::menuActivePseudo) || (pseudoClass->mAtom == nsCSSAtoms::selectionPseudo) || (pseudoClass->mAtom == nsCSSAtoms::visitedPseudo)) { return PR_TRUE; diff --git a/mozilla/layout/style/nsIStyleRuleProcessor.h b/mozilla/layout/style/nsIStyleRuleProcessor.h index 01066ca7542..7079ad111cc 100644 --- a/mozilla/layout/style/nsIStyleRuleProcessor.h +++ b/mozilla/layout/style/nsIStyleRuleProcessor.h @@ -93,7 +93,6 @@ struct RuleProcessorData { PRPackedBool mIsQuirkMode; // Possibly remove use of this in SelectorMatches? PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0 PRPackedBool mIsChecked; // checked/selected attribute for option and select elements - PRPackedBool mIsMenuActive; // menuactive state for options/menus/menuitems nsLinkState mLinkState; // if a link, this is the state, otherwise unknown PRInt32 mEventState; // if content, eventStateMgr->GetContentState() PRInt32 mNameSpaceID; // if content, content->GetNameSapce() diff --git a/mozilla/layout/xul/base/public/nsIMenuFrame.h b/mozilla/layout/xul/base/public/nsIMenuFrame.h index 68141a33bc5..30643013e1e 100644 --- a/mozilla/layout/xul/base/public/nsIMenuFrame.h +++ b/mozilla/layout/xul/base/public/nsIMenuFrame.h @@ -84,8 +84,6 @@ public: NS_IMETHOD GetActiveChild(nsIDOMElement** aResult)=0; NS_IMETHOD SetActiveChild(nsIDOMElement* aChild)=0; - - NS_IMETHOD NotifyStateChanged(nsIMenuFrame* aOtherMenuFrame) = 0; }; #endif diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index 935143d7aba..b74e5b1f34b 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -58,7 +58,6 @@ #include "nsMenuPopupFrame.h" #include "nsGUIEvent.h" #include "nsUnicharUtils.h" -#include "nsIMenuElement.h" #ifdef XP_WIN #include "nsISound.h" #include "nsWidgetsCID.h" @@ -200,8 +199,6 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag) void nsMenuBarFrame::ToggleMenuActiveState() { - nsIMenuFrame* oldCurrent = mCurrentMenu; - if (mIsActive) { // Deactivate the menu bar mIsActive = PR_FALSE; @@ -224,7 +221,8 @@ nsMenuBarFrame::ToggleMenuActiveState() InstallKeyboardNavigator(); // Set the active menu to be the top left item (e.g., the File menu). - // We use the -moz-menuactive pseudoclass to track the current active menu. + // We use an attribute called "_moz-menuactive" to track the current + // active menu. nsIMenuFrame* firstFrame; GetNextMenuItem(nsnull, &firstFrame); if (firstFrame) { @@ -234,23 +232,6 @@ nsMenuBarFrame::ToggleMenuActiveState() mCurrentMenu = firstFrame; } } - - // Update the state on the menubar content node - nsCOMPtr menubar = do_QueryInterface(mContent); - nsCOMPtr newActive; - if (mCurrentMenu) { - nsIFrame* frame = nsnull; - CallQueryInterface(mCurrentMenu, &frame); - frame->GetContent(getter_AddRefs(newActive)); - } - menubar->SetActiveItem(newActive); - - // Now send a CSS state change notification - if (mCurrentMenu) - mCurrentMenu->NotifyStateChanged(oldCurrent); - else if (oldCurrent) - oldCurrent->NotifyStateChanged(nsnull); - } static void GetInsertionPoint(nsIPresShell* aShell, nsIFrame* aFrame, nsIFrame* aChild, @@ -535,8 +516,6 @@ NS_IMETHODIMP nsMenuBarFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) PRBool wasOpen = PR_FALSE; // Unset the current child. - nsIMenuFrame* oldMenuFrame = mCurrentMenu; - if (mCurrentMenu) { mCurrentMenu->MenuIsOpen(wasOpen); mCurrentMenu->SelectMenu(PR_FALSE); @@ -555,23 +534,6 @@ NS_IMETHODIMP nsMenuBarFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) mCurrentMenu = aMenuItem; - // Update the menubar content node - nsCOMPtr menubar = do_QueryInterface(mContent); - nsCOMPtr newActive; - if (mCurrentMenu) { - nsIFrame* frame = nsnull; - CallQueryInterface(mCurrentMenu, &frame); - frame->GetContent(getter_AddRefs(newActive)); - } - - menubar->SetActiveItem(newActive); - - // Now send a CSS state change notification - if (mCurrentMenu) - mCurrentMenu->NotifyStateChanged(oldMenuFrame); - else if (oldMenuFrame) - oldMenuFrame->NotifyStateChanged(nsnull); - return NS_OK; } diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 4269fa427ae..be2db45383a 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -85,7 +85,6 @@ #include "nsGUIEvent.h" #include "nsIEventListenerManager.h" #include "nsIEventStateManager.h" -#include "nsCSSAtoms.h" #define NS_MENU_POPUP_LIST_INDEX 0 @@ -584,10 +583,14 @@ nsMenuFrame::SelectMenu(PRBool aActivateFlag) nsAutoString domEventToFire; if (aActivateFlag) { + // Highlight the menu. + mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, NS_LITERAL_STRING("true"), PR_TRUE); // The menuactivated event is used by accessibility to track the user's movements through menus domEventToFire.Assign(NS_LITERAL_STRING("DOMMenuItemActive")); } else { + // Unhighlight the menu. + mContent->UnsetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE); domEventToFire.Assign(NS_LITERAL_STRING("DOMMenuItemInactive")); } @@ -1319,9 +1322,9 @@ nsMenuFrame::Notify(nsITimer* aTimer) // Our timer has fired. if (aTimer == mOpenTimer.get()) { if (!mMenuOpen && mMenuParent) { - nsIMenuFrame* activeMenu = nsnull; - mMenuParent->GetCurrentMenuItem(&activeMenu); - if (activeMenu == this) { + nsAutoString active; + mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, active); + if (active.Equals(NS_LITERAL_STRING("true"))) { // We're still the active menu. Make sure all submenus/timers are closed // before opening this one mMenuParent->KillPendingTimers(); @@ -2101,24 +2104,6 @@ nsMenuFrame::GetScrollableView(nsIScrollableView** aView) return NS_OK; } -NS_IMETHODIMP -nsMenuFrame::NotifyStateChanged(nsIMenuFrame* aOtherMenuFrame) -{ - nsCOMPtr otherContent; - if (aOtherMenuFrame) { - nsIFrame* otherFrame = nsnull; - CallQueryInterface(aOtherMenuFrame, &otherFrame); - otherFrame->GetContent(getter_AddRefs(otherContent)); - } - - nsCOMPtr document; - mContent->GetDocument(*getter_AddRefs(document)); - if (document) - document->ContentStatesChanged(mContent, otherContent, nsCSSAtoms::menuActivePseudo); - - return NS_OK; -} - /* Need to figure out what this does. NS_IMETHODIMP nsMenuFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize) diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.h b/mozilla/layout/xul/base/src/nsMenuFrame.h index f7bcdcf2de5..f8d7433207e 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuFrame.h @@ -167,8 +167,6 @@ public: NS_IMETHOD MarkChildrenStyleChange(); NS_IMETHOD MarkAsGenerated(); - NS_IMETHOD NotifyStateChanged(nsIMenuFrame* aOtherFrame); - // nsIScrollableViewProvider methods NS_IMETHOD GetScrollableView(nsIScrollableView** aView); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 6faf78ee106..7e06c3e9daf 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -69,7 +69,6 @@ #include "nsIFrameManager.h" #include "nsGUIEvent.h" #include "nsIRootBox.h" -#include "nsIMenuElement.h" #ifdef XP_WIN #include "nsISound.h" #endif @@ -1398,8 +1397,6 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) return NS_OK; // Unset the current child. - nsIMenuFrame* oldMenuFrame = nsnull; - if (mCurrentMenu) { PRBool isOpen = PR_FALSE; mCurrentMenu->MenuIsOpen(isOpen); @@ -1422,8 +1419,6 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) mCloseTimer->Init(this, menuDelay, NS_PRIORITY_HIGHEST); mTimerMenu = mCurrentMenu; } - - oldMenuFrame = mCurrentMenu; } // Set the new child. @@ -1434,26 +1429,6 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) mCurrentMenu = aMenuItem; - // Update the content node's idea of the current item. - nsCOMPtr newContent; - if (mCurrentMenu) { - nsIFrame* frame = nsnull; - CallQueryInterface(mCurrentMenu, &frame); - frame->GetContent(getter_AddRefs(newContent)); - } - - nsCOMPtr popupEl = do_QueryInterface(mContent); - NS_ASSERTION(popupEl, "a MenuPopupFrame's content does not implement nsIMenuElement!"); - if (!popupEl) - return NS_OK; - popupEl->SetActiveItem(newContent); - - // Send menuactive state notification. - if (mCurrentMenu) - mCurrentMenu->NotifyStateChanged(oldMenuFrame); - else if (oldMenuFrame) - oldMenuFrame->NotifyStateChanged(nsnull); - return NS_OK; } @@ -1881,11 +1856,6 @@ nsMenuPopupFrame::HandleEvent(nsIPresContext* aPresContext, NS_IMETHODIMP nsMenuPopupFrame::Destroy(nsIPresContext* aPresContext) { - // Make sure the content node doesn't think we still have an active item. - nsCOMPtr popupEl = do_QueryInterface(mContent); - if (popupEl) - popupEl->SetActiveItem(nsnull); - return nsBoxFrame::Destroy(aPresContext); } diff --git a/mozilla/themes/classic/global/mac/menu.css b/mozilla/themes/classic/global/mac/menu.css index 67d7ed02be1..ec3faf3f0d5 100644 --- a/mozilla/themes/classic/global/mac/menu.css +++ b/mozilla/themes/classic/global/mac/menu.css @@ -45,8 +45,8 @@ menuitem[default="true"] { menu[disabled="true"], menuitem[disabled="true"], -menu[disabled="true"]:-moz-menuactive, -menuitem[disabled="true"]:-moz-menuactive { +menu[_moz-menuactive="true"][disabled="true"], +menuitem[_moz-menuactive="true"][disabled="true"] { background-color: transparent !important; color: GrayText !important; } @@ -92,11 +92,11 @@ menuitem[disabled="true"]:-moz-menuactive { } .menu-right[disabled="true"], -menu:-moz-menuactive > .menu-right[disabled="true"] { +.menu-right[_moz-menuactive="true"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-arrow-dis.gif); } -menu:-moz-menuactive > .menu-right { +.menu-right[_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-arrow-hov.gif"); } @@ -108,14 +108,14 @@ menubar > menu { margin: 1px 0px 1px 0px; } -menubar > menu:-moz-menuactive { +menubar > menu[_moz-menuactive="true"] { border-top: 1px solid ThreeDHighlight; border-right: 1px solid ThreeDShadow; border-bottom: 1px solid ThreeDShadow; border-left: 1px solid ThreeDHighlight; } -menubar > menu[open="true"]:-moz-menuactive { +menubar > menu[_moz-menuactive="true"][open="true"] { border-top: 1px solid ThreeDShadow; border-right: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreeDHighlight; @@ -144,10 +144,10 @@ popup > menuitem { max-width: 42em; } -menupopup > menu:-moz-menuactive, -menupopup > menuitem:-moz-menuactive, -popup > menu:-moz-menuactive, -popup > menuitem:-moz-menuactive { +menupopup > menu[_moz-menuactive="true"], +menupopup > menuitem[_moz-menuactive="true"], +popup > menu[_moz-menuactive="true"], +popup > menuitem[_moz-menuactive="true"] { background-color: -moz-mac-menuselect; color: -moz-mac-menutextselect; } @@ -162,7 +162,7 @@ menuitem[checked="true"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-dis.gif"); } -menuitem[checked="true"]:-moz-menuactive { +menuitem[checked="true"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-hov.gif"); } @@ -172,7 +172,7 @@ menuitem[checked="true"][type="radio"] { list-style-image: url("chrome://global/skin/menu/menu-radio.gif"); } -menuitem[checked="true"][type="radio"]:-moz-menuactive { +menuitem[checked="true"][type="radio"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-hov.gif"); } @@ -194,8 +194,8 @@ menulist > menupopup > menuitem[selected="true"], list-style-image: url("chrome://global/skin/menu/menu-radio.gif"); } -menulist > menupopup > menuitem[selected="true"]:-moz-menuactive, -.menulist-menupopup > menuitem[selected="true"]:-moz-menuactive { +menulist > menupopup > menuitem[_moz-menuactive="true"][selected="true"], +.menulist-menupopup > menuitem[_moz-menuactive="true"][selected="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-hov.gif"); } diff --git a/mozilla/themes/classic/global/win/menu.css b/mozilla/themes/classic/global/win/menu.css index 939e34bb57f..5868b1588d7 100644 --- a/mozilla/themes/classic/global/win/menu.css +++ b/mozilla/themes/classic/global/win/menu.css @@ -43,8 +43,8 @@ menuitem[default="true"] { } menu[disabled="true"], menuitem[disabled="true"], -menu[disabled="true"]:-moz-menuactive, -menuitem[disabled="true"]:-moz-menuactive { +menu[_moz-menuactive="true"][disabled="true"], +menuitem[_moz-menuactive="true"][disabled="true"] { color: GrayText; } @@ -88,7 +88,7 @@ menuitem[disabled="true"]:-moz-menuactive { list-style-image: url("chrome://global/skin/menu/menu-arrow.gif"); } -menu:-moz-menuactive > .menu-right { +.menu-right[_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-arrow-hover.gif"); } @@ -104,14 +104,14 @@ menubar > menu { margin: 1px 0px 1px 0px; } -menubar > menu:-moz-menuactive { +menubar > menu[_moz-menuactive="true"] { border-top: 1px solid ThreeDHighlight; border-right: 1px solid ThreeDShadow; border-bottom: 1px solid ThreeDShadow; border-left: 1px solid ThreeDHighlight; } -menubar > menu[open="true"]:-moz-menuactive { +menubar > menu[_moz-menuactive="true"][open="true"] { border-top: 1px solid ThreeDShadow; border-right: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreeDHighlight; @@ -140,10 +140,10 @@ popup > menuitem { max-width: 42em; } -menupopup > menu:-moz-menuactive, -menupopup > menuitem:-moz-menuactive, -popup > menu:-moz-menuactive, -popup > menuitem:-moz-menuactive { +menupopup > menu[_moz-menuactive="true"], +menupopup > menuitem[_moz-menuactive="true"], +popup > menu[_moz-menuactive="true"], +popup > menuitem[_moz-menuactive="true"] { background-color: Highlight; color: HighlightText; } @@ -168,7 +168,7 @@ menulist > menupopup > menu > .menu-iconic-left { display: none; } -menulist > menupopup > menuitem:-moz-menuactive { +menulist > menupopup > menuitem[_moz-menuactive="true"] { border: 1px dotted #F5DB95; } @@ -182,7 +182,7 @@ menuitem[checked="true"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-disabled.gif"); } -menuitem[checked="true"]:-moz-menuactive { +menuitem[checked="true"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-hover.gif"); } @@ -196,7 +196,7 @@ menuitem[checked="true"][type="radio"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-disabled.gif"); } -menuitem[checked="true"][type="radio"]:-moz-menuactive { +menuitem[checked="true"][type="radio"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-hover.gif"); } diff --git a/mozilla/themes/modern/global/menu.css b/mozilla/themes/modern/global/menu.css index a8f51850810..4480b74dac9 100644 --- a/mozilla/themes/modern/global/menu.css +++ b/mozilla/themes/modern/global/menu.css @@ -57,8 +57,8 @@ menuitem[default="true"] { menu[disabled="true"], menuitem[disabled="true"], -menu[menuactive="true"][disabled="true"], -menuitem[menuactive="true"][disabled="true"] { +menu[_moz-menuactive="true"][disabled="true"], +menuitem[_moz-menuactive="true"][disabled="true"] { color: #8C99AB; } @@ -102,7 +102,7 @@ menuitem[menuactive="true"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-arrow.gif"); } -menu:-moz-menuactive > .menu-right { +.menu-right[_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-arrow-hov.gif"); } @@ -118,11 +118,11 @@ menubar > menu { margin: 1px 0px 1px 0px; } -menubar > menu:-moz-menuactive { +menubar > menu[_moz-menuactive="true"] { border: 1px outset #DDE3EB; } -menubar > menu[open="true"]:-moz-menuactive { +menubar > menu[_moz-menuactive="true"][open="true"] { border-style: inset; } @@ -148,10 +148,10 @@ popup > menuitem { max-width: 42em; } -menupopup > menu:-moz-menuactive, -menupopup > menuitem:-moz-menuactive, -popup > menu:-moz-menuactive, -popup > menuitem:-moz-menuactive { +menupopup > menu[_moz-menuactive="true"], +menupopup > menuitem[_moz-menuactive="true"], +popup > menu[_moz-menuactive="true"], +popup > menuitem[_moz-menuactive="true"] { background-color: #424F63; color: #FFFFFF; } @@ -175,7 +175,7 @@ menulist > menupopup > menuitem[selected="true"] { list-style-image: url("chrome://global/skin/menu/menu-check.gif"); } -menulist > menupopup > menuitem[selected="true"]:-moz-menuactive { +menulist > menupopup > menuitem[_moz-menuactive="true"][selected="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-hov.gif"); } @@ -189,7 +189,7 @@ menuitem[checked="true"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-dis.gif"); } -menuitem[checked="true"]:-moz-menuactive { +menuitem[checked="true"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-check-hov.gif"); } @@ -203,7 +203,7 @@ menuitem[checked="true"][type="radio"][disabled="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-dis.gif"); } -menuitem[checked="true"][type="radio"]:-moz-menuactive { +menuitem[checked="true"][type="radio"][_moz-menuactive="true"] { list-style-image: url("chrome://global/skin/menu/menu-radio-hov.gif"); } diff --git a/mozilla/xpfe/global/resources/content/bindings/menu.xml b/mozilla/xpfe/global/resources/content/bindings/menu.xml index 4e1fd55df74..9f7a90534e7 100644 --- a/mozilla/xpfe/global/resources/content/bindings/menu.xml +++ b/mozilla/xpfe/global/resources/content/bindings/menu.xml @@ -29,7 +29,7 @@ - + @@ -71,7 +71,7 @@ + inherits="selected,_moz-menuactive,disabled,checked"> @@ -96,7 +96,7 @@ - +