Bug 130778 - fixing Txul regression from changing 'menuactive' attribute to :-moz-menuactive pseudoclass. Get the menuactive state from the frame instead of the content node so that we don't have to call through xpconnect and js. r=dbaron, sr=hyatt, a=asa.

This commit is contained in:
bryner%netscape.com 2002-03-20 22:48:24 +00:00
Родитель 749065c0c1
Коммит 93114688c3
18 изменённых файлов: 66 добавлений и 221 удалений

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

@ -41,8 +41,9 @@
#include "nsAccessible.h"
#include "nsIAccessible.h"
#include "nsIDOMElement.h"
#include "nsIDOMXULPopupElement.h"
#include "nsIDOMXULMenuBarElement.h"
#include "nsIFrame.h"
#include "nsIMenuFrame.h"
#include "nsIMenuParent.h"
// ------------------------ Menu Item -----------------------------
@ -57,26 +58,30 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetAccState(PRUint32 *_retval)
nsAccessible::GetAccState(_retval);
// Focused?
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No DOM element for menu node!");
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
if (parentNode) {
nsCOMPtr<nsIDOMElement> currentItem;
nsCOMPtr<nsIDOMXULPopupElement> popupEl = do_QueryInterface(parentNode);
if (popupEl)
popupEl->GetActiveItem(getter_AddRefs(currentItem));
else {
nsCOMPtr<nsIDOMXULMenuBarElement> menubar = do_QueryInterface(parentNode);
if (menubar)
menubar->GetActiveMenu(getter_AddRefs(currentItem));
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
if (shell) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
nsIFrame* itemFrame;
shell->GetPrimaryFrameFor(content, &itemFrame);
if (itemFrame) {
nsIMenuFrame* menuFrame = nsnull;
CallQueryInterface(itemFrame, &menuFrame);
if (menuFrame) {
nsIMenuParent* menuParent;
menuFrame->GetMenuParent(&menuParent);
if (menuParent) {
nsIMenuFrame* currentMenuFrame;
menuParent->GetCurrentMenuItem(&currentMenuFrame);
if (currentMenuFrame == menuFrame)
*_retval |= STATE_FOCUSED;
}
}
}
if (currentItem == element)
*_retval |= STATE_FOCUSED;
}
// Has Popup?
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No DOM element for menu node!");
nsAutoString tagName;
element->GetLocalName(tagName);
if (tagName.Equals(NS_LITERAL_STRING("menu")))

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

@ -95,8 +95,8 @@
#include "nsQuickSort.h"
#ifdef MOZ_XUL
#include "nsIXULContent.h"
#include "nsIDOMXULPopupElement.h"
#include "nsIDOMXULMenuBarElement.h"
#include "nsIMenuParent.h"
#include "nsIMenuFrame.h"
#include "nsXULAtoms.h"
#endif
@ -3327,20 +3327,22 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
(mContent->IsContentOfType(nsIContent::eXUL) &&
(mContentTag == nsXULAtoms::menuitem || mContentTag == nsXULAtoms::menu))) {
nsCOMPtr<nsIDOMElement> currentItem;
nsCOMPtr<nsIDOMXULPopupElement> popupEl = do_QueryInterface(mParentContent);
if (popupEl)
popupEl->GetActiveItem(getter_AddRefs(currentItem));
else {
nsCOMPtr<nsIDOMXULMenuBarElement> menubar = do_QueryInterface(mParentContent);
if (menubar)
menubar->GetActiveMenu(getter_AddRefs(currentItem));
}
if (currentItem) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mContent);
if (currentItem == element)
mIsMenuActive = PR_TRUE;
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
if (shell) {
nsIFrame* optionFrame = nsnull;
nsIMenuFrame* itemFrame = nsnull;
shell->GetPrimaryFrameFor(mContent, &optionFrame);
if (optionFrame &&
NS_SUCCEEDED(CallQueryInterface(optionFrame, &itemFrame))) {
nsIMenuParent* menuParent;
itemFrame->GetMenuParent(&menuParent);
nsIMenuFrame* currentItemFrame = nsnull;
if (menuParent &&
NS_SUCCEEDED(menuParent->GetCurrentMenuItem(&currentItemFrame)) &&
currentItemFrame == itemFrame)
mIsMenuActive = PR_TRUE;
}
}
}
}

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

@ -815,13 +815,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULMenuBarElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -899,11 +892,6 @@
<PATH>nsIDOMXULPopupElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULMenuBarElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
<TARGET>
@ -1668,13 +1656,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULMenuBarElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -1752,11 +1733,6 @@
<PATH>nsIDOMXULPopupElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULMenuBarElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
</TARGETLIST>
@ -1845,12 +1821,6 @@
<PATH>nsIDOMXULPopupElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULMenuBarElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

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

@ -1,4 +1,3 @@
nsIDOMXULCommandDispatcher.idl
nsIDOMXULDocument.idl
nsIDOMXULElement.idl
nsIDOMXULMenuBarElement.idl

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

@ -45,7 +45,6 @@ XPIDLSRCS = \
nsIDOMXULSelectCntrlEl.idl \
nsIDOMXULSelectCntrlItemEl.idl \
nsIDOMXULMultSelectCntrlEl.idl \
nsIDOMXULMenuBarElement.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -41,7 +41,6 @@ XPIDLSRCS = \
.\nsIDOMXULSelectCntrlEl.idl \
.\nsIDOMXULSelectCntrlItemEl.idl \
.\nsIDOMXULMultSelectCntrlEl.idl \
.\nsIDOMXULMenuBarElement.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

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

@ -54,8 +54,7 @@ interface nsIDOMXULPopupElement : nsIDOMXULElement {
const unsigned short AFTER_POINTER = 11;
attribute DOMString position;
attribute nsIDOMElement activeItem;
void showPopup(in unsigned short alignment,
in nsIDOMElement target,
in nsIDOMElement anchor);

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

@ -95,8 +95,8 @@
#include "nsQuickSort.h"
#ifdef MOZ_XUL
#include "nsIXULContent.h"
#include "nsIDOMXULPopupElement.h"
#include "nsIDOMXULMenuBarElement.h"
#include "nsIMenuParent.h"
#include "nsIMenuFrame.h"
#include "nsXULAtoms.h"
#endif
@ -3327,20 +3327,22 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
(mContent->IsContentOfType(nsIContent::eXUL) &&
(mContentTag == nsXULAtoms::menuitem || mContentTag == nsXULAtoms::menu))) {
nsCOMPtr<nsIDOMElement> currentItem;
nsCOMPtr<nsIDOMXULPopupElement> popupEl = do_QueryInterface(mParentContent);
if (popupEl)
popupEl->GetActiveItem(getter_AddRefs(currentItem));
else {
nsCOMPtr<nsIDOMXULMenuBarElement> menubar = do_QueryInterface(mParentContent);
if (menubar)
menubar->GetActiveMenu(getter_AddRefs(currentItem));
}
if (currentItem) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mContent);
if (currentItem == element)
mIsMenuActive = PR_TRUE;
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
if (shell) {
nsIFrame* optionFrame = nsnull;
nsIMenuFrame* itemFrame = nsnull;
shell->GetPrimaryFrameFor(mContent, &optionFrame);
if (optionFrame &&
NS_SUCCEEDED(CallQueryInterface(optionFrame, &itemFrame))) {
nsIMenuParent* menuParent;
itemFrame->GetMenuParent(&menuParent);
nsIMenuFrame* currentItemFrame = nsnull;
if (menuParent &&
NS_SUCCEEDED(menuParent->GetCurrentMenuItem(&currentItemFrame)) &&
currentItemFrame == itemFrame)
mIsMenuActive = PR_TRUE;
}
}
}
}

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

@ -32,6 +32,7 @@ XPIDL_MODULE = layout_xul
EXPORTS = \
nsPIBoxObject.h \
nsIMenuFrame.h \
nsIMenuParent.h \
nsIPopupSetFrame.h \
nsITreeFrame.h \
$(NULL)

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

@ -1,5 +1,6 @@
nsPIBoxObject.h
nsIMenuFrame.h
nsIMenuParent.h
nsIPopupSetFrame.h
nsITreeFrame.h

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

@ -23,9 +23,10 @@ DEPTH=..\..\..\..
EXPORTS = \
nsIMenuFrame.h \
nsIMenuParent.h \
nsIPopupSetFrame.h \
nsITreeFrame.h \
nsPIBoxObject.h \
nsPIBoxObject.h \
$(NULL)
XPIDLSRCS= .\nsIBoxObject.idl \

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

@ -45,6 +45,7 @@
{ 0xd407bf61, 0x3efa, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
class nsIMenuFrame;
class nsIWidget;
class nsIMenuParent : public nsISupports {

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

@ -1,88 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dean Tessman <dean_tessman@hotmail.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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIMenuParent_h___
#define nsIMenuParent_h___
// {D407BF61-3EFA-11d3-97FA-00400553EEF0}
#define NS_IMENUPARENT_IID \
{ 0xd407bf61, 0x3efa, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
class nsIMenuFrame;
class nsIMenuParent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMENUPARENT_IID; return iid; }
NS_IMETHOD GetCurrentMenuItem(nsIMenuFrame** aMenuItem) = 0;
NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem) = 0;
NS_IMETHOD GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
NS_IMETHOD DismissChain() = 0;
NS_IMETHOD HideChain() = 0;
NS_IMETHOD KillPendingTimers() = 0;
NS_IMETHOD CreateDismissalListener() = 0;
NS_IMETHOD InstallKeyboardNavigator() = 0;
NS_IMETHOD RemoveKeyboardNavigator() = 0;
// Used to move up, down, left, and right in menus.
NS_IMETHOD KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag) = 0;
NS_IMETHOD ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag) = 0;
// Called when the ESC key is held down to close levels of menus.
NS_IMETHOD Escape(PRBool& aHandledFlag) = 0;
// Called to execute a menu item.
NS_IMETHOD Enter() = 0;
NS_IMETHOD SetIsContextMenu(PRBool aIsContextMenu) = 0;
NS_IMETHOD GetIsContextMenu(PRBool& aIsContextMenu) = 0;
};
#endif

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

@ -58,7 +58,6 @@
#include "nsMenuPopupFrame.h"
#include "nsGUIEvent.h"
#include "nsUnicharUtils.h"
#include "nsIDOMXULMenuBarElement.h"
#ifdef XP_WIN
#include "nsISound.h"
#include "nsWidgetsCID.h"
@ -235,18 +234,6 @@ nsMenuBarFrame::ToggleMenuActiveState()
}
}
// Update the state on the menubar content node
nsCOMPtr<nsIDOMXULMenuBarElement> menubar = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMElement> newActive;
if (mCurrentMenu) {
nsIFrame* frame = nsnull;
CallQueryInterface(mCurrentMenu, &frame);
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
newActive = do_QueryInterface(content);
}
menubar->SetActiveMenu(newActive);
// Now send a CSS state change notification
if (mCurrentMenu)
mCurrentMenu->NotifyStateChanged(oldCurrent);
@ -557,19 +544,6 @@ NS_IMETHODIMP nsMenuBarFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
mCurrentMenu = aMenuItem;
// Update the menubar content node
nsCOMPtr<nsIDOMXULMenuBarElement> menubar = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMElement> newActive;
if (mCurrentMenu) {
nsIFrame* frame = nsnull;
CallQueryInterface(mCurrentMenu, &frame);
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
newActive = do_QueryInterface(content);
}
menubar->SetActiveMenu(newActive);
// Now send a CSS state change notification
if (mCurrentMenu)
mCurrentMenu->NotifyStateChanged(oldMenuFrame);

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

@ -69,7 +69,6 @@
#include "nsIFrameManager.h"
#include "nsGUIEvent.h"
#include "nsIRootBox.h"
#include "nsIDOMXULPopupElement.h"
#ifdef XP_WIN
#include "nsISound.h"
#endif
@ -1434,18 +1433,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<nsIDOMXULPopupElement> popupEl = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMElement> domEl = do_QueryInterface(newContent);
popupEl->SetActiveItem(domEl);
// Send menuactive state notification.
if (mCurrentMenu)
mCurrentMenu->NotifyStateChanged(oldMenuFrame);
@ -1870,11 +1857,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<nsIDOMXULPopupElement> popupEl = do_QueryInterface(mContent);
if (popupEl)
popupEl->SetActiveItem(nsnull);
return nsBoxFrame::Destroy(aPresContext);
}

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

@ -18,7 +18,6 @@
</content>
<implementation implements="nsIDOMXULPopupElement, nsIAccessibleProvider">
<field name="activeItem"/>
<property name="accessible">
<getter>
<![CDATA[

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

@ -177,8 +177,7 @@
</xul:hbox>
</content>
<implementation implements="nsIDOMXULMenuBarElement, nsIAccessibleProvider">
<field name="activeMenu"/>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[