зеркало из https://github.com/mozilla/gecko-dev.git
fix win32 compiler errors (can't do (nsnull != foop) where foop is a nsCOMPtr, which is fine by me) and fix command hookup code to actually work for multiple toolbars. I dunno what I was smoking with the last checkin.
This commit is contained in:
Родитель
160af16727
Коммит
f7c2c5bb3c
|
@ -422,10 +422,10 @@ void nsWebShellWindow::LoadCommands(nsIWebShell * aWebShell, nsIDOMDocument * aD
|
||||||
// load up commands
|
// load up commands
|
||||||
int endCount = 0;
|
int endCount = 0;
|
||||||
nsCOMPtr<nsIDOMNode> parentCmd ( dont_AddRef(FindNamedDOMNode(nsAutoString("commands"), window, endCount, 1)) );
|
nsCOMPtr<nsIDOMNode> parentCmd ( dont_AddRef(FindNamedDOMNode(nsAutoString("commands"), window, endCount, 1)) );
|
||||||
if (nsnull != parentCmd) {
|
if ( parentCmd ) {
|
||||||
nsCOMPtr<nsIDOMNode> node;
|
nsCOMPtr<nsIDOMNode> node;
|
||||||
parentCmd->GetFirstChild(getter_AddRefs(node));
|
parentCmd->GetFirstChild(getter_AddRefs(node));
|
||||||
while (nsnull != node) {
|
while ( node ) {
|
||||||
nsString value;
|
nsString value;
|
||||||
nsString nodeType;
|
nsString nodeType;
|
||||||
nsString name;
|
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
|
// Now install the commands onto the Toolbar GUI Nodes for each toolbar in the toolbox
|
||||||
PRUint32 count = 1;
|
int count = 1;
|
||||||
nsCOMPtr<nsIDOMNode> toolbar;
|
endCount = 0;
|
||||||
do {
|
nsCOMPtr<nsIDOMNode> toolbar ( dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count)) );
|
||||||
toolbar = dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count));
|
while ( toolbar ) {
|
||||||
if (nsnull != toolbar) {
|
nsAutoString cmdAtom("cmd");
|
||||||
nsAutoString cmdAtom("cmd");
|
nsCOMPtr<nsIDOMNode> node;
|
||||||
nsCOMPtr<nsIDOMNode> node;
|
toolbar->GetFirstChild(getter_AddRefs(node));
|
||||||
toolbar->GetFirstChild(getter_AddRefs(node));
|
while ( node ) {
|
||||||
while (nsnull != node) {
|
nsAutoString value;
|
||||||
nsAutoString value;
|
nsString nodeCmd;
|
||||||
nsString nodeCmd;
|
nsCOMPtr<nsIDOMElement> element ( node );
|
||||||
nsCOMPtr<nsIDOMElement> element ( node );
|
if ( element ) {
|
||||||
if ( element ) {
|
nsString name;
|
||||||
nsString name;
|
element->GetNodeName(name);
|
||||||
element->GetNodeName(name);
|
if (name.Equals(nsAutoString("BUTTON"))) {
|
||||||
if (name.Equals(nsAutoString("BUTTON"))) {
|
element->GetAttribute(cmdAtom, nodeCmd);
|
||||||
element->GetAttribute(cmdAtom, nodeCmd);
|
PRInt32 i, n = mCommands.Count();
|
||||||
PRInt32 i, n = mCommands.Count();
|
for (i = 0; i < n; i++) {
|
||||||
for (i = 0; i < n; i++) {
|
nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i);
|
||||||
nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i);
|
nsAutoString cmdName;
|
||||||
nsAutoString cmdName;
|
cmd->GetName(cmdName);
|
||||||
cmd->GetName(cmdName);
|
//printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString());
|
||||||
//printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString());
|
if (nodeCmd.Equals(cmdName)) {
|
||||||
if (nodeCmd.Equals(cmdName)) {
|
printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString());
|
||||||
printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString());
|
cmd->AddUINode(node);
|
||||||
cmd->AddUINode(node);
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (name.Equals(nsAutoString("INPUT"))) {
|
||||||
} else if (name.Equals(nsAutoString("INPUT"))) {
|
nsXULCommand * xulCmd = new nsXULCommand();
|
||||||
nsXULCommand * xulCmd = new nsXULCommand();
|
xulCmd->SetName(name);
|
||||||
xulCmd->SetName(name);
|
xulCmd->SetCommand(value);
|
||||||
xulCmd->SetCommand(value);
|
xulCmd->SetWebShell(aWebShell);
|
||||||
xulCmd->SetWebShell(aWebShell);
|
xulCmd->SetDOMElement(element);
|
||||||
xulCmd->SetDOMElement(element);
|
nsIXULCommand * icmd;
|
||||||
nsIXULCommand * icmd;
|
if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) {
|
||||||
if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) {
|
mCommands.AppendElement(icmd);
|
||||||
mCommands.AppendElement(icmd);
|
}
|
||||||
}
|
xulCmd->AddUINode(node);
|
||||||
xulCmd->AddUINode(node);
|
//printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString());
|
||||||
//printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> oldNode ( node );
|
nsCOMPtr<nsIDOMNode> oldNode ( node );
|
||||||
oldNode->GetNextSibling(getter_AddRefs(node));
|
oldNode->GetNextSibling(getter_AddRefs(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// find the next toolbar
|
||||||
|
endCount = 0;
|
||||||
|
toolbar = dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count));
|
||||||
|
++count;
|
||||||
|
|
||||||
++count;
|
} // for each toolbar
|
||||||
|
|
||||||
} while ( toolbar ) ;
|
|
||||||
|
|
||||||
/*PRInt32 i, n = mCommands.Count();
|
/*PRInt32 i, n = mCommands.Count();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
@ -529,7 +529,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
int endCount = 0;
|
int endCount = 0;
|
||||||
nsCOMPtr<nsIDOMNode> menubarNode ( dont_AddRef(FindNamedDOMNode(nsAutoString("menubar"), window, endCount, 1)) );
|
nsCOMPtr<nsIDOMNode> menubarNode ( dont_AddRef(FindNamedDOMNode(nsAutoString("menubar"), window, endCount, 1)) );
|
||||||
if (nsnull != menubarNode) {
|
if (menubarNode) {
|
||||||
nsIMenuBar * pnsMenuBar = nsnull;
|
nsIMenuBar * pnsMenuBar = nsnull;
|
||||||
rv = nsRepository::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID,
|
rv = nsRepository::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID,
|
||||||
(void**)&pnsMenuBar);
|
(void**)&pnsMenuBar);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче