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
This commit is contained in:
bryner%netscape.com
2002-03-27 07:01:26 +00:00
parent 9a06e90f57
commit 0d03028090
27 changed files with 62 additions and 333 deletions

View File

@@ -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<nsIContent> content = do_QueryInterface(mDOMNode);
nsCOMPtr<nsIContent> parent;
content->GetParent(*getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsIMenuElement> menuEl = do_QueryInterface(parent);
if (content == menuEl->GetActiveItem())
*_retval |= STATE_FOCUSED;
}
// Has Popup?
nsCOMPtr<nsIDOMElement> 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")))

View File

@@ -27,4 +27,3 @@ nsIStyleSheet.h
nsIStyleSheetLinkingElement.h
nsITextContent.h
nsIContentList.h
nsIMenuElement.h

View File

@@ -56,7 +56,6 @@ nsIPrivateDOMImplementation.h \
nsIContentSerializer.h \
nsIHTMLToTextSink.h \
nsIContentList.h \
nsIMenuElement.h \
$(NULL)
XPIDLSRCS = \

View File

@@ -48,7 +48,6 @@ EXPORTS = \
nsIContentSerializer.h \
nsIHTMLToTextSink.h \
nsIContentList.h \
nsIMenuElement.h \
$(NULL)
MODULE=content

View File

@@ -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 <bryner@netscape.com>
*
* 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

View File

@@ -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()

View File

@@ -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;
}

View File

@@ -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;
}
//----------------------------------------------------------------------
//

View File

@@ -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));

View File

@@ -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<nsIDOMHTMLInputElement> 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<nsIMenuElement> 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;

View File

@@ -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")

View File

@@ -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

View File

@@ -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.

View File

@@ -51,7 +51,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsXULAttributes.obj \
.\$(OBJDIR)\nsXULElement.obj \
.\$(OBJDIR)\nsXULPopupListener.obj \
.\$(OBJDIR)\nsXULMenuElement.obj \
$(NULL)
LINCS= \

View File

@@ -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;

View File

@@ -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));

View File

@@ -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<nsIDOMHTMLInputElement> 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<nsIMenuElement> 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;

View File

@@ -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()

View File

@@ -84,8 +84,6 @@ public:
NS_IMETHOD GetActiveChild(nsIDOMElement** aResult)=0;
NS_IMETHOD SetActiveChild(nsIDOMElement* aChild)=0;
NS_IMETHOD NotifyStateChanged(nsIMenuFrame* aOtherMenuFrame) = 0;
};
#endif

View File

@@ -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<nsIMenuElement> menubar = do_QueryInterface(mContent);
nsCOMPtr<nsIContent> 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<nsIMenuElement> menubar = do_QueryInterface(mContent);
nsCOMPtr<nsIContent> 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;
}

View File

@@ -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<nsIContent> otherContent;
if (aOtherMenuFrame) {
nsIFrame* otherFrame = nsnull;
CallQueryInterface(aOtherMenuFrame, &otherFrame);
otherFrame->GetContent(getter_AddRefs(otherContent));
}
nsCOMPtr<nsIDocument> 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)

View File

@@ -167,8 +167,6 @@ public:
NS_IMETHOD MarkChildrenStyleChange();
NS_IMETHOD MarkAsGenerated();
NS_IMETHOD NotifyStateChanged(nsIMenuFrame* aOtherFrame);
// nsIScrollableViewProvider methods
NS_IMETHOD GetScrollableView(nsIScrollableView** aView);

View File

@@ -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<nsIContent> newContent;
if (mCurrentMenu) {
nsIFrame* frame = nsnull;
CallQueryInterface(mCurrentMenu, &frame);
frame->GetContent(getter_AddRefs(newContent));
}
nsCOMPtr<nsIMenuElement> 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<nsIMenuElement> popupEl = do_QueryInterface(mContent);
if (popupEl)
popupEl->SetActiveItem(nsnull);
return nsBoxFrame::Destroy(aPresContext);
}

View File

@@ -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");
}

View File

@@ -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");
}

View File

@@ -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");
}

View File

@@ -29,7 +29,7 @@
<content>
<xul:label class="menu-text" flex="1" inherits="value=label,accesskey,crop" crop="right"/>
<xul:label class="menu-accel" inherits="value=acceltext"/>
<xul:hbox align="center" class="menu-right" inherits="disabled">
<xul:hbox align="center" class="menu-right" inherits="_moz-menuactive,disabled">
<xul:image/>
</xul:hbox>
<children includes="menupopup"/>
@@ -71,7 +71,7 @@
<binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
<content>
<xul:hbox class="menu-iconic-left" align="center" pack="center"
inherits="selected,disabled,checked">
inherits="selected,_moz-menuactive,disabled,checked">
<xul:image class="menu-iconic-icon" inherits="validate,src"/>
</xul:hbox>
<xul:label class="menu-iconic-text" flex="1" inherits="value=label,accesskey,crop" crop="right"/>
@@ -96,7 +96,7 @@
</xul:hbox>
<xul:label class="menu-iconic-text" flex="1" inherits="value=label,accesskey,crop" crop="right"/>
<xul:label class="menu-iconic-accel" inherits="value=acceltext"/>
<xul:hbox class="menu-right" inherits="disabled" align="center" pack="center">
<xul:hbox class="menu-right" inherits="_moz-menuactive,disabled" align="center" pack="center">
<xul:image/>
</xul:hbox>
<children includes="menupopup|template"/>