diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 87a632506111..a4b5cde0fb2c 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -422,10 +422,10 @@ void nsWebShellWindow::LoadCommands(nsIWebShell * aWebShell, nsIDOMDocument * aD // load up commands int endCount = 0; nsCOMPtr parentCmd ( dont_AddRef(FindNamedDOMNode(nsAutoString("commands"), window, endCount, 1)) ); - if (nsnull != parentCmd) { + if ( parentCmd ) { nsCOMPtr node; parentCmd->GetFirstChild(getter_AddRefs(node)); - while (nsnull != node) { + while ( node ) { nsString value; nsString nodeType; nsString name; @@ -455,58 +455,58 @@ void nsWebShellWindow::LoadCommands(nsIWebShell * aWebShell, nsIDOMDocument * aD } // Now install the commands onto the Toolbar GUI Nodes for each toolbar in the toolbox - PRUint32 count = 1; - nsCOMPtr toolbar; - do { - toolbar = dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count)); - if (nsnull != toolbar) { - nsAutoString cmdAtom("cmd"); - nsCOMPtr node; - toolbar->GetFirstChild(getter_AddRefs(node)); - while (nsnull != node) { - nsAutoString value; - nsString nodeCmd; - nsCOMPtr element ( node ); - if ( element ) { - nsString name; - element->GetNodeName(name); - if (name.Equals(nsAutoString("BUTTON"))) { - element->GetAttribute(cmdAtom, nodeCmd); - PRInt32 i, n = mCommands.Count(); - for (i = 0; i < n; i++) { - nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i); - nsAutoString cmdName; - cmd->GetName(cmdName); - //printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString()); - if (nodeCmd.Equals(cmdName)) { - printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); - cmd->AddUINode(node); - } - } - } else if (name.Equals(nsAutoString("INPUT"))) { - nsXULCommand * xulCmd = new nsXULCommand(); - xulCmd->SetName(name); - xulCmd->SetCommand(value); - xulCmd->SetWebShell(aWebShell); - xulCmd->SetDOMElement(element); - nsIXULCommand * icmd; - if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) { - mCommands.AppendElement(icmd); - } - xulCmd->AddUINode(node); - //printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); - } - } + int count = 1; + endCount = 0; + nsCOMPtr toolbar ( dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count)) ); + while ( toolbar ) { + nsAutoString cmdAtom("cmd"); + nsCOMPtr node; + toolbar->GetFirstChild(getter_AddRefs(node)); + while ( node ) { + nsAutoString value; + nsString nodeCmd; + nsCOMPtr element ( node ); + if ( element ) { + nsString name; + element->GetNodeName(name); + if (name.Equals(nsAutoString("BUTTON"))) { + element->GetAttribute(cmdAtom, nodeCmd); + PRInt32 i, n = mCommands.Count(); + for (i = 0; i < n; i++) { + nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i); + nsAutoString cmdName; + cmd->GetName(cmdName); + //printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString()); + if (nodeCmd.Equals(cmdName)) { + printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); + cmd->AddUINode(node); + } + } + } else if (name.Equals(nsAutoString("INPUT"))) { + nsXULCommand * xulCmd = new nsXULCommand(); + xulCmd->SetName(name); + xulCmd->SetCommand(value); + xulCmd->SetWebShell(aWebShell); + xulCmd->SetDOMElement(element); + nsIXULCommand * icmd; + if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) { + mCommands.AppendElement(icmd); + } + xulCmd->AddUINode(node); + //printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); + } + } - nsCOMPtr oldNode ( node ); - oldNode->GetNextSibling(getter_AddRefs(node)); - } + nsCOMPtr oldNode ( node ); + oldNode->GetNextSibling(getter_AddRefs(node)); + } - } + // find the next toolbar + endCount = 0; + toolbar = dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count)); + ++count; - ++count; - - } while ( toolbar ) ; + } // for each toolbar /*PRInt32 i, n = mCommands.Count(); for (i = 0; i < n; i++) { @@ -529,7 +529,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi nsresult rv; int endCount = 0; nsCOMPtr menubarNode ( dont_AddRef(FindNamedDOMNode(nsAutoString("menubar"), window, endCount, 1)) ); - if (nsnull != menubarNode) { + if (menubarNode) { nsIMenuBar * pnsMenuBar = nsnull; rv = nsRepository::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&pnsMenuBar);