зеркало из https://github.com/mozilla/pjs.git
rest of fix for bug 132175 - move windowlist part of the window mediator into a seperate object (nsWindowDataSource) so that appshell is no longer dependent on RDF.
r=bnesse, sr=waterson
This commit is contained in:
Родитель
f455bfa5ac
Коммит
6d986e360e
|
@ -41,6 +41,7 @@ XPIDLSRCS = \
|
|||
nsICmdLineService.idl \
|
||||
nsICmdLineHandler.idl \
|
||||
nsIWindowMediator.idl \
|
||||
nsIWindowMediatorListener.idl \
|
||||
nsIXULWindow.idl \
|
||||
nsIUserInfo.idl \
|
||||
nsITimingService.idl \
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
interface nsIXULWindow;
|
||||
interface nsIWidget;
|
||||
interface nsIDOMWindowInternal;
|
||||
|
||||
interface nsIWindowMediatorListener;
|
||||
|
||||
[scriptable, uuid(0659cb81-faad-11d2-8e19-b206620a657c)]
|
||||
interface nsIWindowMediator: nsISupports
|
||||
|
@ -87,11 +87,6 @@ interface nsIWindowMediator: nsISupports
|
|||
*/
|
||||
nsIDOMWindowInternal getMostRecentWindow( in wstring inType );
|
||||
|
||||
/*
|
||||
Get window given an RDF resource.
|
||||
*/
|
||||
nsIDOMWindowInternal getWindowForResource( in wstring inResource );
|
||||
|
||||
/* Add the webshellwindow to the list */
|
||||
[noscript] void registerWindow( in nsIXULWindow inWindow);
|
||||
|
||||
|
@ -157,4 +152,16 @@ interface nsIWindowMediator: nsISupports
|
|||
[noscript] void setZPosition(in nsIXULWindow inWindow,
|
||||
in unsigned long inPosition,
|
||||
in nsIXULWindow inBelow);
|
||||
|
||||
/**
|
||||
* addListener
|
||||
* keeps strong ref? (to be decided)
|
||||
*/
|
||||
void addListener(in nsIWindowMediatorListener listener);
|
||||
|
||||
/**
|
||||
* removeListener
|
||||
*/
|
||||
void removeListener(in nsIWindowMediatorListener listener);
|
||||
|
||||
};
|
||||
|
|
|
@ -46,7 +46,6 @@ REQUIRES = xpcom \
|
|||
js \
|
||||
locale \
|
||||
webbrwsr \
|
||||
rdf \
|
||||
pref \
|
||||
xpconnect \
|
||||
intl \
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsAppShellCIDs.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "rdf.h"
|
||||
#include "nsAbout.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
|
@ -87,11 +86,6 @@ static const nsModuleComponentInfo gAppShellModuleInfo[] =
|
|||
NS_WINDOWMEDIATOR_CONTRACTID,
|
||||
nsWindowMediatorConstructor,
|
||||
},
|
||||
{ "Window Mediator",
|
||||
NS_WINDOWMEDIATOR_CID,
|
||||
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator",
|
||||
nsWindowMediatorConstructor,
|
||||
},
|
||||
{ "kAboutModuleCID",
|
||||
NS_ABOUT_CID,
|
||||
NS_ABOUT_MODULE_CONTRACTID_PREFIX,
|
||||
|
|
|
@ -216,13 +216,13 @@ nsAppShellWindowEnumerator::nsAppShellWindowEnumerator (
|
|||
NS_INIT_REFCNT();
|
||||
|
||||
mWindowMediator->AddEnumerator(this);
|
||||
mWindowMediator->AddRef();
|
||||
NS_ADDREF(mWindowMediator);
|
||||
}
|
||||
|
||||
nsAppShellWindowEnumerator::~nsAppShellWindowEnumerator() {
|
||||
|
||||
mWindowMediator->RemoveEnumerator(this);
|
||||
mWindowMediator->Release();
|
||||
NS_RELEASE(mWindowMediator);
|
||||
}
|
||||
|
||||
// after mCurrentPosition has been initialized to point to the beginning
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
||||
|
@ -53,7 +52,6 @@ struct nsWindowInfo
|
|||
nsWindowInfo(nsIXULWindow* inWindow, PRInt32 inTimeStamp);
|
||||
~nsWindowInfo();
|
||||
|
||||
nsCOMPtr<nsIRDFResource> mRDFID;
|
||||
nsCOMPtr<nsIXULWindow> mWindow;
|
||||
PRInt32 mTimeStamp;
|
||||
|
||||
|
|
|
@ -330,9 +330,7 @@ NS_IMETHODIMP nsChromeTreeOwner::GetTitle(PRUnichar** aTitle)
|
|||
|
||||
NS_IMETHODIMP nsChromeTreeOwner::SetTitle(const PRUnichar* aTitle)
|
||||
{
|
||||
// XXX Don't need to fully qualify this once I remove nsWebShellWindow::SetTitle
|
||||
// return mXULWindow->SetTitle(title.get());
|
||||
return mXULWindow->nsXULWindow::SetTitle(aTitle);
|
||||
return mXULWindow->SetTitle(aTitle);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
|
|
@ -345,8 +345,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnicha
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
nsAutoString xulBrowserWinId(NS_LITERAL_STRING("XULBrowserWindow"));
|
||||
piDOMWindow->GetObjectProperty(xulBrowserWinId.get(), getter_AddRefs(xpConnectObj));
|
||||
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("XULBrowserWindow").get(), getter_AddRefs(xpConnectObj));
|
||||
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
|
||||
|
||||
if (xulBrowserWindow)
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
|
||||
#include "nsIXULPopupListener.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
@ -137,10 +136,6 @@
|
|||
#include "nsIDOMXULDocument.h"
|
||||
// End hack
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#define USE_NATIVE_MENUS
|
||||
#endif
|
||||
|
||||
#include "nsIPopupSetFrame.h"
|
||||
|
||||
/* Define Class IDs */
|
||||
|
@ -201,8 +196,7 @@ struct nsWebShellInfo {
|
|||
|
||||
nsWebShellWindow::nsWebShellWindow() : nsXULWindow()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// refcnt initted by parent class
|
||||
mWebShell = nsnull;
|
||||
mWindow = nsnull;
|
||||
mLockedUntilChromeLoad = PR_FALSE;
|
||||
|
@ -232,19 +226,14 @@ nsWebShellWindow::~nsWebShellWindow()
|
|||
PR_DestroyLock(mSPTimerLock);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsWebShellWindow);
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsWebShellWindow);
|
||||
NS_IMPL_ADDREF_INHERITED(nsWebShellWindow, nsXULWindow);
|
||||
NS_IMPL_RELEASE_INHERITED(nsWebShellWindow, nsXULWindow);
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsWebShellWindow)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebShellContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebShellWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsXULWindow)
|
||||
|
||||
nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||
nsIAppShell* aShell, nsIURI* aUrl,
|
||||
|
@ -626,298 +615,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
|||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//----------------------------------------
|
||||
NS_IMETHODIMP nsWebShellWindow::CreateMenu(nsIMenuBar * aMenuBar,
|
||||
nsIDOMNode * aMenuNode,
|
||||
nsString & aMenuName)
|
||||
{
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
aMenuBar->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pnsMenu->Create(supports, aMenuName);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
// Set nsMenu Name
|
||||
pnsMenu->SetLabel(aMenuName);
|
||||
// Make nsMenu a child of nsMenuBar
|
||||
aMenuBar->AddMenu(pnsMenu);
|
||||
|
||||
// Open the node so that the contents are visible.
|
||||
nsCOMPtr<nsIDOMElement> menuElement = do_QueryInterface(aMenuNode);
|
||||
if (menuElement)
|
||||
menuElement->SetAttribute(NS_LITERAL_STRING("open"), NS_LITERAL_STRING("true"));
|
||||
|
||||
// Begin menuitem inner loop
|
||||
|
||||
// Now get the kids. Retrieve our menupopup child.
|
||||
nsCOMPtr<nsIDOMNode> menuPopupNode;
|
||||
aMenuNode->GetFirstChild(getter_AddRefs(menuPopupNode));
|
||||
while (menuPopupNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuPopupElement(do_QueryInterface(menuPopupNode));
|
||||
if (menuPopupElement) {
|
||||
nsString menuPopupNodeType;
|
||||
menuPopupElement->GetNodeName(menuPopupNodeType);
|
||||
if (menuPopupNodeType.Equals(NS_LITERAL_STRING("menupopup")))
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldMenuPopupNode(menuPopupNode);
|
||||
oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode));
|
||||
}
|
||||
|
||||
if (!menuPopupNode)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuitemNode;
|
||||
menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
||||
|
||||
while (menuitemNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
|
||||
if (menuitemElement) {
|
||||
nsString menuitemNodeType;
|
||||
nsString menuitemName;
|
||||
menuitemElement->GetNodeName(menuitemNodeType);
|
||||
if (menuitemNodeType.Equals(NS_LITERAL_STRING("menuitem"))) {
|
||||
// LoadMenuItem
|
||||
LoadMenuItem(pnsMenu, menuitemElement, menuitemNode);
|
||||
} else if (menuitemNodeType.Equals(NS_LITERAL_STRING("menuseparator"))) {
|
||||
pnsMenu->AddSeparator();
|
||||
} else if (menuitemNodeType.Equals(NS_LITERAL_STRING("menu"))) {
|
||||
// Load a submenu
|
||||
LoadSubMenu(pnsMenu, menuitemElement, menuitemNode);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
|
||||
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
|
||||
} // end menu item innner loop
|
||||
// The parent owns us, so we can release
|
||||
NS_RELEASE(pnsMenu);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
NS_IMETHODIMP nsWebShellWindow::LoadMenuItem(
|
||||
nsIMenu * pParentMenu,
|
||||
nsIDOMElement * menuitemElement,
|
||||
nsIDOMNode * menuitemNode)
|
||||
{
|
||||
nsString menuitemName;
|
||||
nsString menuitemCmd;
|
||||
|
||||
menuitemElement->GetAttribute(NS_LITERAL_STRING("label"), menuitemName);
|
||||
menuitemElement->GetAttribute(NS_LITERAL_STRING("cmd"), menuitemCmd);
|
||||
// Create nsMenuItem
|
||||
nsIMenuItem * pnsMenuItem = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, NS_GET_IID(nsIMenuItem), (void**)&pnsMenuItem);
|
||||
if (NS_OK == rv) {
|
||||
// Create MenuDelegate - this is the intermediator inbetween
|
||||
// the DOM node and the nsIMenuItem
|
||||
// The nsWebShellWindow wacthes for Document changes and then notifies the
|
||||
// the appropriate nsMenuDelegate object
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(menuitemNode));
|
||||
if (!domElement) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
pnsMenuItem->Create(pParentMenu, menuitemName, 0);
|
||||
// Set nsMenuItem Name
|
||||
//pnsMenuItem->SetLabel(menuitemName);
|
||||
|
||||
// Set key shortcut and modifiers
|
||||
nsAutoString keyAtom(NS_LITERAL_STRING("key"));
|
||||
nsString keyValue;
|
||||
domElement->GetAttribute(keyAtom, keyValue);
|
||||
|
||||
// Try to find the key node.
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(domElement);
|
||||
if (NS_FAILED(rv = content->GetDocument(*getter_AddRefs(document)))) {
|
||||
NS_ERROR("Unable to retrieve the document.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Turn the document into a XUL document so we can use getElementById
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDocument = do_QueryInterface(document);
|
||||
if (xulDocument == nsnull) {
|
||||
NS_ERROR("not XUL!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> keyElement;
|
||||
xulDocument->GetElementById(keyValue, getter_AddRefs(keyElement));
|
||||
|
||||
if(keyElement){
|
||||
PRUint8 modifiers = knsMenuItemNoModifier;
|
||||
nsAutoString shiftAtom(NS_LITERAL_STRING("shift"));
|
||||
nsAutoString altAtom(NS_LITERAL_STRING("alt"));
|
||||
nsAutoString commandAtom(NS_LITERAL_STRING("command"));
|
||||
nsString shiftValue;
|
||||
nsString altValue;
|
||||
nsString commandValue;
|
||||
nsString keyChar(NS_LITERAL_STRING(" "));
|
||||
|
||||
keyElement->GetAttribute(keyAtom, keyChar);
|
||||
keyElement->GetAttribute(shiftAtom, shiftValue);
|
||||
keyElement->GetAttribute(altAtom, altValue);
|
||||
keyElement->GetAttribute(commandAtom, commandValue);
|
||||
|
||||
if(!keyChar.Equals(NS_LITERAL_STRING(" ")))
|
||||
pnsMenuItem->SetShortcutChar(keyChar);
|
||||
|
||||
if(shiftValue.Equals(NS_LITERAL_STRING("true")))
|
||||
modifiers |= knsMenuItemShiftModifier;
|
||||
|
||||
if(altValue.Equals(NS_LITERAL_STRING("true")))
|
||||
modifiers |= knsMenuItemAltModifier;
|
||||
|
||||
if(commandValue.Equals(NS_LITERAL_STRING("false")))
|
||||
modifiers |= knsMenuItemCommandModifier;
|
||||
|
||||
pnsMenuItem->SetModifiers(modifiers);
|
||||
}
|
||||
|
||||
// Make nsMenuItem a child of nsMenu
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
||||
|
||||
nsAutoString cmdAtom(NS_LITERAL_STRING("onaction"));
|
||||
nsString cmdName;
|
||||
|
||||
domElement->GetAttribute(cmdAtom, cmdName);
|
||||
|
||||
nsXULCommand * menuDelegate = new nsXULCommand();
|
||||
if ( menuDelegate ) {
|
||||
menuDelegate->SetCommand(cmdName);
|
||||
menuDelegate->SetDocShell(mDocShell);
|
||||
menuDelegate->SetDOMElement(domElement);
|
||||
menuDelegate->SetMenuItem(pnsMenuItem);
|
||||
} else {
|
||||
NS_RELEASE( pnsMenuItem );
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsIXULCommand * icmd;
|
||||
if (NS_OK == menuDelegate->QueryInterface(NS_GET_IID(nsIXULCommand), (void**) &icmd)) {
|
||||
nsCOMPtr<nsIMenuListener> listener(do_QueryInterface(menuDelegate));
|
||||
|
||||
if (listener)
|
||||
{
|
||||
pnsMenuItem->AddMenuListener(listener);
|
||||
|
||||
#ifdef DEBUG_MENUSDEL
|
||||
printf("Adding menu listener to [%s]\n", NS_LossyConvertUCS2toASCII(menuitemName).get());
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_MENUSDEL
|
||||
else
|
||||
{
|
||||
printf("*** NOT Adding menu listener to [%s]\n", NS_LossyConvertUCS2toASCII(menuitemName).get());
|
||||
}
|
||||
#endif
|
||||
NS_RELEASE(icmd);
|
||||
}
|
||||
|
||||
// The parent owns us, so we can release
|
||||
NS_RELEASE(pnsMenuItem);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
void nsWebShellWindow::LoadSubMenu(
|
||||
nsIMenu * pParentMenu,
|
||||
nsIDOMElement * menuElement,
|
||||
nsIDOMNode * menuNode)
|
||||
{
|
||||
nsString menuName;
|
||||
menuElement->GetAttribute(NS_LITERAL_STRING("label"), menuName);
|
||||
//printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get());
|
||||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pParentMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports); // Balance QI
|
||||
|
||||
// Open the node so that the contents are visible.
|
||||
menuElement->SetAttribute(NS_LITERAL_STRING("open"), NS_LITERAL_STRING("true"));
|
||||
|
||||
// Set nsMenu Name
|
||||
pnsMenu->SetLabel(menuName);
|
||||
// Make nsMenu a child of parent nsMenu
|
||||
//pParentMenu->AddMenu(pnsMenu);
|
||||
supports = nsnull;
|
||||
pnsMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
// Begin menuitem inner loop
|
||||
|
||||
// Now get the kids. Retrieve our menupopup child.
|
||||
nsCOMPtr<nsIDOMNode> menuPopupNode;
|
||||
menuNode->GetFirstChild(getter_AddRefs(menuPopupNode));
|
||||
while (menuPopupNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuPopupElement(do_QueryInterface(menuPopupNode));
|
||||
if (menuPopupElement) {
|
||||
nsString menuPopupNodeType;
|
||||
menuPopupElement->GetNodeName(menuPopupNodeType);
|
||||
if (menuPopupNodeType.Equals(NS_LITERAL_STRING("menupopup")))
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldMenuPopupNode(menuPopupNode);
|
||||
oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode));
|
||||
}
|
||||
|
||||
if (!menuPopupNode)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuitemNode;
|
||||
menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
||||
|
||||
while (menuitemNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
|
||||
if (menuitemElement) {
|
||||
nsString menuitemNodeType;
|
||||
menuitemElement->GetNodeName(menuitemNodeType);
|
||||
|
||||
#ifdef DEBUG_saari
|
||||
printf("Type [%s] %d\n", NS_LossyConvertUCS2toASCII(menuitemNodeType).get(), menuitemNodeType.Equals("menuseparator"));
|
||||
#endif
|
||||
|
||||
if (menuitemNodeType.Equals(NS_LITERAL_STRING("menuitem"))) {
|
||||
// Load a menuitem
|
||||
LoadMenuItem(pnsMenu, menuitemElement, menuitemNode);
|
||||
} else if (menuitemNodeType.Equals(NS_LITERAL_STRING("menuseparator"))) {
|
||||
pnsMenu->AddSeparator();
|
||||
} else if (menuitemNodeType.Equals(NS_LITERAL_STRING("menu"))) {
|
||||
// Add a submenu
|
||||
LoadSubMenu(pnsMenu, menuitemElement, menuitemNode);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
|
||||
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
|
||||
} // end menu item innner loop
|
||||
|
||||
// The parent owns us, so we can release
|
||||
NS_RELEASE(pnsMenu);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_DYNAMIC_MENUS
|
||||
//----------------------------------------
|
||||
void nsWebShellWindow::DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow)
|
||||
{
|
||||
|
@ -1002,78 +700,7 @@ void nsWebShellWindow::DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aP
|
|||
}
|
||||
} // end if (menuBar)
|
||||
} // nsWebShellWindow::DynamicLoadMenus
|
||||
|
||||
#if 0
|
||||
//----------------------------------------
|
||||
void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow)
|
||||
{
|
||||
// locate the window element which holds toolbars and menus and commands
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
|
||||
|
||||
nsresult rv;
|
||||
int endCount = 0;
|
||||
nsCOMPtr<nsIDOMNode> menubarNode(FindNamedDOMNode(NS_LITERAL_STRING("menubar"), window, endCount, 1));
|
||||
if (menubarNode) {
|
||||
nsIMenuBar * pnsMenuBar = nsnull;
|
||||
rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, NS_GET_IID(nsIMenuBar), (void**)&pnsMenuBar);
|
||||
if (NS_OK == rv) {
|
||||
if (nsnull != pnsMenuBar) {
|
||||
pnsMenuBar->Create(aParentWindow);
|
||||
|
||||
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
||||
nsCOMPtr<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuNode;
|
||||
menubarNode->GetFirstChild(getter_AddRefs(menuNode));
|
||||
while (menuNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
|
||||
if (menuElement) {
|
||||
nsString menuNodeType;
|
||||
nsString menuName;
|
||||
menuElement->GetNodeName(menuNodeType);
|
||||
if (menuNodeType.Equals(NS_LITERAL_STRING("menu"))) {
|
||||
menuElement->GetAttribute(NS_LITERAL_STRING("label"), menuName);
|
||||
|
||||
#ifdef DEBUG_rods
|
||||
printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get());
|
||||
#endif
|
||||
CreateMenu(pnsMenuBar, menuNode, menuName);
|
||||
}
|
||||
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuNode(menuNode);
|
||||
oldmenuNode->GetNextSibling(getter_AddRefs(menuNode));
|
||||
} // end while (nsnull != menuNode)
|
||||
|
||||
// Give the aParentWindow this nsMenuBar to own.
|
||||
aParentWindow->SetMenuBar(pnsMenuBar);
|
||||
|
||||
// HACK: force a paint for now
|
||||
pnsMenuBar->Paint();
|
||||
|
||||
// HACK for M4, should be removed by M5
|
||||
// ... it is now M15
|
||||
#ifdef USE_NATIVE_MENUS
|
||||
Handle tempMenuBar = ::GetMenuBar(); // Get a copy of the menu list
|
||||
pnsMenuBar->SetNativeData((void*)tempMenuBar);
|
||||
#endif
|
||||
|
||||
// The parent owns the menubar, so we can release it
|
||||
NS_RELEASE(pnsMenuBar);
|
||||
} // end if ( nsnull != pnsMenuBar )
|
||||
}
|
||||
} // end if (menuBar)
|
||||
|
||||
} // nsWebShellWindow::LoadMenus
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
|
@ -1284,19 +911,7 @@ nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress,
|
|||
nsCOMPtr<nsIDOMDocument> menubarDOMDoc(GetNamedDOMDoc(NS_LITERAL_STRING("this"))); // XXX "this" is a small kludge for code reused
|
||||
if (menubarDOMDoc)
|
||||
{
|
||||
#ifdef SOME_PLATFORM // Anyone using native non-dynamic menus should add themselves here.
|
||||
LoadMenus(menubarDOMDoc, mWindow);
|
||||
// Context Menu test
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
menubarDOMDoc->GetDocumentElement(getter_AddRefs(element));
|
||||
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
|
||||
|
||||
int endCount = 0;
|
||||
contextMenuTest = FindNamedDOMNode(NS_LITERAL_STRING("contextmenu"), window, endCount, 1);
|
||||
// End Context Menu test
|
||||
#else
|
||||
DynamicLoadMenus(menubarDOMDoc, mWindow);
|
||||
#endif
|
||||
}
|
||||
#endif // USE_NATIVE_MENUS
|
||||
|
||||
|
@ -1334,7 +949,7 @@ nsWebShellWindow::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_NATIVE_MENUS
|
||||
//----------------------------------------
|
||||
nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedDOMNode(const nsAString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount)
|
||||
{
|
||||
|
@ -1403,6 +1018,8 @@ nsCOMPtr<nsIDOMDocument> nsWebShellWindow::GetNamedDOMDoc(const nsAString & aWeb
|
|||
return domDoc;
|
||||
} // nsWebShellWindow::GetNamedDOMDoc
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
// if the main document URL specified URLs for any content areas, start them loading
|
||||
|
@ -1589,26 +1206,6 @@ nsWebShellWindow::AttributeChanged(nsIDocument *aDocument,
|
|||
PRInt32 aModType,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
#if 0
|
||||
//printf("AttributeChanged\n");
|
||||
PRInt32 i;
|
||||
for (i=0;i<mMenuDelegates.Count();i++) {
|
||||
nsIXULCommand * cmd = (nsIXULCommand *)mMenuDelegates[i];
|
||||
nsIDOMElement * node;
|
||||
cmd->GetDOMElement(&node);
|
||||
//nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||
// Doing this for the must speed
|
||||
nsIContent * content;
|
||||
if (NS_OK == node->QueryInterface(NS_GET_IID(nsIContent), (void**) &content)) {
|
||||
if (content == aContent) {
|
||||
nsAutoString attr;
|
||||
aAttribute->ToString(attr);
|
||||
cmd->AttributeHasBeenSet(attr);
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsXULWindow.h"
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#define USE_NATIVE_MENUS
|
||||
#endif
|
||||
|
||||
/* Forward declarations.... */
|
||||
struct PLEvent;
|
||||
|
||||
|
@ -83,7 +87,7 @@ public:
|
|||
nsWebShellWindow();
|
||||
|
||||
// nsISupports interface...
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; return NS_OK; }
|
||||
NS_IMETHOD GetLockedState(PRBool& aResult) { aResult = mLockedUntilChromeLoad; return NS_OK; }
|
||||
|
@ -173,18 +177,12 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
#ifdef USE_NATIVE_MENUS
|
||||
nsCOMPtr<nsIDOMNode> FindNamedDOMNode(const nsAString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount);
|
||||
nsCOMPtr<nsIDOMDocument> GetNamedDOMDoc(const nsAString & aWebShellName);
|
||||
void DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);
|
||||
#if 0
|
||||
void LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);
|
||||
NS_IMETHOD CreateMenu(nsIMenuBar * aMenuBar, nsIDOMNode * aMenuNode, nsString & aMenuName);
|
||||
void LoadSubMenu(nsIMenu * pParentMenu, nsIDOMElement * menuElement,nsIDOMNode * menuNode);
|
||||
NS_IMETHOD LoadMenuItem(nsIMenu * pParentMenu, nsIDOMElement * menuitemElement, nsIDOMNode * menuitemNode);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMNode> GetDOMNodeFromWebShell(nsIWebShell *aShell);
|
||||
void ExecuteStartupCode();
|
||||
void LoadContentAreas();
|
||||
PRBool ExecuteCloseHandler();
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -41,13 +41,10 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
|
||||
class nsAppShellWindowEnumerator;
|
||||
class nsASXULWindowEarlyToLateEnumerator;
|
||||
|
@ -59,9 +56,7 @@ class nsASXULWindowBackToFrontEnumerator;
|
|||
struct nsWindowInfo;
|
||||
struct PRLock;
|
||||
|
||||
class nsWindowMediator : public nsIWindowMediator,
|
||||
public nsIRDFDataSource,
|
||||
public nsIRDFObserver
|
||||
class nsWindowMediator : public nsIWindowMediator
|
||||
{
|
||||
friend class nsAppShellWindowEnumerator;
|
||||
friend class nsASXULWindowEarlyToLateEnumerator;
|
||||
|
@ -78,22 +73,14 @@ public:
|
|||
|
||||
NS_DECL_NSIWINDOWMEDIATOR
|
||||
|
||||
// COM and RDF
|
||||
// COM
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFDataSource
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
|
||||
// nsIRDFObserver
|
||||
NS_DECL_NSIRDFOBSERVER
|
||||
|
||||
private:
|
||||
// Helper functions
|
||||
nsresult AddWindowToRDF( nsWindowInfo* ioWindowInfo );
|
||||
PRInt32 AddEnumerator( nsAppShellWindowEnumerator* inEnumerator );
|
||||
PRInt32 RemoveEnumerator( nsAppShellWindowEnumerator* inEnumerator);
|
||||
nsWindowInfo *MostRecentWindowInfo(const PRUnichar* inType);
|
||||
nsresult RemoveAndUpdateSynthetics(nsIRDFNode *node);
|
||||
|
||||
NS_IMETHOD UnregisterWindow( nsWindowInfo *inInfo );
|
||||
|
||||
|
@ -104,16 +91,9 @@ private:
|
|||
PRInt32 mUpdateBatchNest;
|
||||
PRLock *mListLock;
|
||||
nsCOMPtr<nsIWindowWatcher> mWatcher;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
nsCOMPtr<nsISupportsArray> mListeners;
|
||||
|
||||
// pseudo-constants for RDF
|
||||
static nsIRDFResource* kNC_WindowMediatorRoot;
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_URL;
|
||||
static nsIRDFResource* kNC_KeyIndex;
|
||||
static PRInt32 gRefCnt;
|
||||
static nsIRDFContainer* mContainer;
|
||||
static nsIRDFDataSource* mInner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -118,14 +118,15 @@ nsXULWindow::~nsXULWindow()
|
|||
// nsXULWindow::nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsXULWindow)
|
||||
NS_IMPL_RELEASE(nsXULWindow)
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsXULWindow)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsXULWindow)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXULWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -49,9 +49,10 @@
|
|||
|
||||
// nsXULWindow
|
||||
|
||||
class nsXULWindow : public nsIXULWindow, public nsIBaseWindow,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsSupportsWeakReference
|
||||
class nsXULWindow : public nsIBaseWindow,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIXULWindow,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsChromeTreeOwner;
|
||||
friend class nsContentTreeOwner;
|
||||
|
|
|
@ -26,7 +26,29 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = bookmarks directory download-manager filepicker find history search sidebar related regviewer xfer prefwindow shistory timebomb console autocomplete updates urlbarhistory intl resetPref killAll
|
||||
DIRS = \
|
||||
bookmarks \
|
||||
directory \
|
||||
download-manager \
|
||||
filepicker \
|
||||
find history \
|
||||
search \
|
||||
sidebar \
|
||||
related \
|
||||
regviewer \
|
||||
xfer \
|
||||
prefwindow \
|
||||
shistory \
|
||||
timebomb \
|
||||
console \
|
||||
autocomplete \
|
||||
updates \
|
||||
urlbarhistory \
|
||||
intl \
|
||||
resetPref \
|
||||
killAll \
|
||||
windowds \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_XREMOTE
|
||||
DIRS += xremote
|
||||
|
|
|
@ -51,6 +51,8 @@ REQUIRES = xpcom \
|
|||
pref \
|
||||
docshell \
|
||||
webshell \
|
||||
appshell \
|
||||
history \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsModule.cpp
|
||||
|
@ -75,6 +77,7 @@ SHARED_LIBRARY_LIBS = \
|
|||
$(DIST)/lib/$(LIB_PREFIX)search_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)urlbarhistory_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)timebomb_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)windowds_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
@ -87,6 +90,7 @@ LOCAL_INCLUDES = \
|
|||
-I$(srcdir)/../search/src \
|
||||
-I$(srcdir)/../timebomb \
|
||||
-I$(srcdir)/../urlbarhistory/src \
|
||||
-I$(srcdir)/../windowds \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsCharsetMenu.h"
|
||||
#include "nsFontPackageHandler.h"
|
||||
#include "nsWindowDataSource.h"
|
||||
#if defined(XP_WIN)
|
||||
#include "nsAlertsService.h"
|
||||
#include "nsUrlWidget.h"
|
||||
|
@ -75,6 +76,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(RelatedLinksHandlerImpl, Init)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimeBomb)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlbarHistory)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontPackageHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowDataSource, Init)
|
||||
#if defined(XP_WIN)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlWidget, Init)
|
||||
|
@ -184,6 +186,10 @@ static const nsModuleComponentInfo components[] = {
|
|||
{ "nsFontPackageHandler", NS_FONTPACKAGEHANDLER_CID,
|
||||
"@mozilla.org/locale/default-font-package-handler;1",
|
||||
nsFontPackageHandlerConstructor },
|
||||
{ "nsWindowDataSource",
|
||||
NS_WINDOWDATASOURCE_CID,
|
||||
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator",
|
||||
nsWindowDataSourceConstructor },
|
||||
#if defined(XP_WIN)
|
||||
{ NS_IURLWIDGET_CLASSNAME, NS_IURLWIDGET_CID, NS_IURLWIDGET_CONTRACTID,
|
||||
nsUrlWidgetConstructor },
|
||||
|
|
|
@ -46,6 +46,7 @@ DIRS= \
|
|||
resetPref \
|
||||
killAll \
|
||||
alerts \
|
||||
windowds \
|
||||
build \
|
||||
$(NULL)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче