From 5d60d056251a845bdfb70451664fce1a8683172a Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Wed, 27 Jan 1999 15:15:21 +0000 Subject: [PATCH] Added Throbber git-svn-id: svn://10.0.0.236/trunk@18771 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/appshell/src/nsWebShellWindow.cpp | 30 +++++++++++++++++-- mozilla/xpfe/appshell/src/nsWebShellWindow.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 2b2cf9c2d69..056b89b0da5 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -49,6 +49,7 @@ #include "nsIDOMElement.h" #include "nsIDocumentLoader.h" #include "nsIDOMHTMLInputElement.h" +#include "nsIDOMHTMLImageElement.h" /* Define Class IDs */ static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID); @@ -74,13 +75,16 @@ static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIXULCommandIID, NS_IXULCOMMAND_IID); static NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID); static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); +static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID); static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID); -//static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); +//static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); #include "nsIWebShell.h" +const char * kThrobberOnStr = "resource:/res/throbber/anims07.gif"; +const char * kThrobberOffStr = "resource:/res/throbber/anims00.gif"; nsWebShellWindow::nsWebShellWindow() { @@ -91,6 +95,7 @@ nsWebShellWindow::nsWebShellWindow() mController = nsnull; mStatusText = nsnull; mURLBarText = nsnull; + mThrobber = nsnull; } @@ -105,6 +110,7 @@ nsWebShellWindow::~nsWebShellWindow() NS_IF_RELEASE(mController); NS_IF_RELEASE(mStatusText); NS_IF_RELEASE(mURLBarText); + NS_IF_RELEASE(mThrobber); } @@ -310,6 +316,10 @@ NS_IMETHODIMP nsWebShellWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) { + if (nsnull != mThrobber) { + mThrobber->SetSrc(kThrobberOnStr); + } + nsAutoString url(aURL); nsAutoString gecko("Gecko - "); gecko.Append(url); @@ -356,6 +366,9 @@ NS_IMETHODIMP nsWebShellWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) { + if (nsnull != mThrobber) { + mThrobber->SetSrc(kThrobberOffStr); + } UpdateButtonStatus(PR_FALSE); if (nsnull != mStatusText) { @@ -379,7 +392,7 @@ nsIDOMNode * nsWebShellWindow::FindNamedParentFromDoc(nsIDOMDocument * aDomDoc, while (nsnull != node) { nsString name; node->GetNodeName(name); - //printf("[%s]\n", name.ToNewCString()); + printf("[%s]\n", name.ToNewCString()); if (name.Equals(aName)) { NS_ADDREF(node); NS_RELEASE(parent); @@ -654,7 +667,7 @@ nsIDOMNode * nsWebShellWindow::FindNamedDOMNode(const nsString &aName, nsIDOMNo while (nsnull != node) { nsString name; node->GetNodeName(name); - //printf("FindNamedDOMNode[%s] %d == %d\n", name.ToNewCString(), aCount, aEndCount); + printf("FindNamedDOMNode[%s] %d == %d\n", name.ToNewCString(), aCount, aEndCount); if (name.Equals(aName)) { aCount++; if (aCount == aEndCount) { @@ -778,6 +791,17 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete() if (nsnull != contentWS) { LoadCommands(contentWS, toolbarDOMDoc); PRInt32 count = 0; + nsIDOMNode * imgNode = FindNamedDOMNode(nsAutoString("IMG"), parent, count, 7); + if (nsnull != imgNode) { + if (NS_OK == imgNode->QueryInterface(kIDOMHTMLImageElementIID, (void**) &mThrobber)) { + nsAutoString srcStr; + mThrobber->GetSrc(srcStr); + //printf("src: %s\n", srcStr.ToNewCString()); + } + NS_RELEASE(imgNode); + } + + count = 0; nsIDOMNode * node = FindNamedDOMNode(nsAutoString("INPUT"), parent, count, 1); if (nsnull != node) { if (NS_OK == node->QueryInterface(kIDOMHTMLInputElementIID, (void**) &mURLBarText)) { diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index d566b1cd87e..5f358475d0b 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -37,6 +37,7 @@ class nsIXULCommand; class nsIDOMCharacterData; class nsIDOMDocument; class nsIDOMHTMLInputElement; +class nsIDOMHTMLImageElement; class nsWebShellWindow : public nsIWebShellContainer, public nsIDocumentLoaderObserver @@ -103,6 +104,7 @@ protected: nsIWidgetController* mController; nsIDOMCharacterData* mStatusText; nsIDOMHTMLInputElement* mURLBarText; + nsIDOMHTMLImageElement* mThrobber; nsVoidArray mCommands; };