diff --git a/mozilla/extensions/xmlterm/base/ltermEscape.c b/mozilla/extensions/xmlterm/base/ltermEscape.c index 31b4e6b326e..6fed6ad1f0a 100644 --- a/mozilla/extensions/xmlterm/base/ltermEscape.c +++ b/mozilla/extensions/xmlterm/base/ltermEscape.c @@ -264,14 +264,16 @@ static int ltermProcessCSISequence(struct lterms *lts, const UNICHAR *buf, /* Process numerical parameters */ paramCount = 0; while ((offset < count) && - ((buf[offset] >= U_ZERO) && (buf[offset] <= U_NINE)) ) { + ((buf[offset] >= (UNICHAR)U_ZERO) && + (buf[offset] <= (UNICHAR)U_NINE)) ) { /* Starts with a digit */ value = buf[offset] - U_ZERO; offset++; /* Process all contiguous digits */ while ((offset < count) && - ((buf[offset] >= U_ZERO) && (buf[offset] <= U_NINE)) ) { + ((buf[offset] >= (UNICHAR)U_ZERO) && + (buf[offset] <= (UNICHAR)U_NINE)) ) { value = value * 10 + buf[offset] - U_ZERO; offset++; } @@ -931,7 +933,8 @@ static int ltermProcessXTERMSequence(struct lterms *lts, const UNICHAR *buf, /* Process numerical parameter */ paramValue = 0; while ((offset < count) && - ((buf[offset] >= U_ZERO) && (buf[offset] <= U_NINE)) ) { + ((buf[offset] >= (UNICHAR)U_ZERO) && + (buf[offset] <= (UNICHAR)U_NINE)) ) { paramValue = paramValue * 10 + buf[offset] - U_ZERO; offset++; } @@ -1023,14 +1026,16 @@ static int ltermProcessXMLTermSequence(struct lterms *lts, const UNICHAR *buf, /* Process numerical parameters */ paramCount = 0; while ((offset < count) && - ((buf[offset] >= U_ZERO) && (buf[offset] <= U_NINE)) ) { + ((buf[offset] >= (UNICHAR)U_ZERO) && + (buf[offset] <= (UNICHAR)U_NINE)) ) { /* Starts with a digit */ value = buf[offset] - U_ZERO; offset++; /* Process all contiguous digits */ while ((offset < count) && - ((buf[offset] >= U_ZERO) && (buf[offset] <= U_NINE)) ) { + ((buf[offset] >= (UNICHAR)U_ZERO) && + (buf[offset] <= (UNICHAR)U_NINE)) ) { value = value * 10 + buf[offset] - U_ZERO; offset++; } @@ -1460,6 +1465,11 @@ int ltermInsDelEraseLine(struct lterms *lts, int count, int row, int action) } break; + + default: + kblank1 = 0; + kblank2 = -1; + break; } /* Blank out lines (assumed to be displayed already) */ diff --git a/mozilla/extensions/xmlterm/base/ltermIO.c b/mozilla/extensions/xmlterm/base/ltermIO.c index 12d453c5e74..2b4b436ce3e 100644 --- a/mozilla/extensions/xmlterm/base/ltermIO.c +++ b/mozilla/extensions/xmlterm/base/ltermIO.c @@ -283,8 +283,8 @@ int ltermWrite(struct lterms *lts, int *opcodes) lti->inputBufBytes/sizeof(UNICHAR))); /* Check if one or more complete records is now available in buffer */ - lts->inputBufRecord = (lti->inputBufBytes >= sizeof(UNICHAR)) && - (lti->inputBufBytes >= (PIPEHEADER+lti->inputBuf[0])*sizeof(UNICHAR)); + lts->inputBufRecord = (lti->inputBufBytes >= (int)sizeof(UNICHAR)) && + (lti->inputBufBytes >= (PIPEHEADER+lti->inputBuf[0])*((int)sizeof(UNICHAR))); if (!lts->inputBufRecord) { /* Incomplete input record; return */ @@ -424,8 +424,8 @@ int ltermWrite(struct lterms *lts, int *opcodes) lti->inputBufBytes -= processedChars*sizeof(UNICHAR); /* Check if one or more complete records is now left in buffer */ - lts->inputBufRecord = (lti->inputBufBytes >= sizeof(UNICHAR)) && - (lti->inputBufBytes >= (PIPEHEADER+lti->inputBuf[0])*sizeof(UNICHAR)); + lts->inputBufRecord = (lti->inputBufBytes >= (int)sizeof(UNICHAR)) && + (lti->inputBufBytes >= (PIPEHEADER+lti->inputBuf[0])*((int)sizeof(UNICHAR))); LTERM_LOG(ltermWrite,21, ("return opcodes=0x%x, inputBufBytes=%d, inputBufRecord=%d\n", diff --git a/mozilla/extensions/xmlterm/base/ltermInput.c b/mozilla/extensions/xmlterm/base/ltermInput.c index 5337c37c74b..325dd5d945b 100644 --- a/mozilla/extensions/xmlterm/base/ltermInput.c +++ b/mozilla/extensions/xmlterm/base/ltermInput.c @@ -377,7 +377,7 @@ static int ltermLineInput(struct lterms *lts, } else if (lti->escapeCSIFlag) { /* Character part of escape code sequence */ - if ((uch >= U_ZERO && uch <= U_NINE)) { + if ((uch >= (UNICHAR)U_ZERO && uch <= (UNICHAR)U_NINE)) { /* Process numerical argument to escape code sequence */ lti->escapeCSIArg = lti->escapeCSIArg*10 + (uch - U_ZERO); uch = U_NUL; @@ -406,8 +406,8 @@ static int ltermLineInput(struct lterms *lts, } } - if ( ((uch >= U_SPACE) && (uch != U_DEL)) || - ((uch == U_TAB) && (lti->inputMode <= LTERM2_EDIT_MODE)) ) { + if ( ((uch >= (UNICHAR)U_SPACE) && (uch != (UNICHAR)U_DEL)) || + ((uch == (UNICHAR)U_TAB) && (lti->inputMode <= LTERM2_EDIT_MODE)) ) { /* printable character or non-completion mode TAB; insert in buffer */ /* (NEED TO UPDATE THIS CHECK FOR UNICODE PRINTABILITY) */ diff --git a/mozilla/extensions/xmlterm/base/ltermManager.c b/mozilla/extensions/xmlterm/base/ltermManager.c index 8c5f347a273..59b5ddc1ac5 100644 --- a/mozilla/extensions/xmlterm/base/ltermManager.c +++ b/mozilla/extensions/xmlterm/base/ltermManager.c @@ -933,7 +933,8 @@ int lterm_write(int lterm, const UNICHAR *buf, int count, int dataType) uch = buf[j+sentCount]; temLine[j+PIPEHEADER] = uch; - if ((uch < U_SPACE) && ((uch != U_ESCAPE) || (j > 0))) + if ((uch < (UNICHAR)U_SPACE) && + ((uch != (UNICHAR)U_ESCAPE) || (j > 0))) break; } diff --git a/mozilla/extensions/xmlterm/base/ltermOutput.c b/mozilla/extensions/xmlterm/base/ltermOutput.c index 1b93825af80..7defc29408a 100644 --- a/mozilla/extensions/xmlterm/base/ltermOutput.c +++ b/mozilla/extensions/xmlterm/base/ltermOutput.c @@ -121,7 +121,7 @@ int ltermProcessOutput(struct lterms *lts, int *opcodes, int *opvals, } else if (lto->outputMode == LTERM1_SCREEN_MODE) { /* Screen mode processing */ - if ((uch >= U_SPACE) && (uch != U_DEL)) { + if ((uch >= (UNICHAR)U_SPACE) && (uch != (UNICHAR)U_DEL)) { /* Printable non-TAB character */ LTERM_LOG(ltermProcessOutput,39,("Screen mode, printable char - %c\n", @@ -198,8 +198,8 @@ int ltermProcessOutput(struct lterms *lts, int *opcodes, int *opvals, } else { /* Line mode processing */ - if ( ((uch >= U_SPACE) && (uch != U_DEL)) || - (uch == U_TAB)) { + if ( ((uch >= (UNICHAR)U_SPACE) && (uch != (UNICHAR)U_DEL)) || + (uch == (UNICHAR)U_TAB)) { /* Printable/TAB character; replace/insert at current cursor location or append to end of line */ diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h index 0d77438932a..f85249d9bd1 100644 --- a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h @@ -28,7 +28,7 @@ #include "nsISupports.h" #include "nsIDOMDocument.h" -#include "nsIWebShell.h" +#include "nsIDocShell.h" #include "nsIPresShell.h" #include "nsIScriptContext.h" @@ -46,14 +46,14 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(MOZIXMLTERMINAL_IID) /** Initializes XMLterm in specified web shell - * @param aWebShell web shell in which to embed XMLterm + * @param aDocShell web shell in which to embed XMLterm * @param aXMLTermShell scriptable wrapper shell for XMLterm * @param URL URL of document to be loaded in the window * (set to null string if document is already loaded in window) * @param args argument string to be passed to XMLterm * (at the moment this just contains any initial input data) */ - NS_IMETHOD Init(nsIWebShell* aWebShell, + NS_IMETHOD Init(nsIDocShell* aDocShell, mozIXMLTermShell* aXMLTermShell, const PRUnichar* aURL, const PRUnichar* args) = 0; @@ -112,9 +112,9 @@ public: NS_IMETHOD GetDocument(nsIDOMDocument** aDoc) = 0; /** Gets web shell associated with XMLterm - * @param aWebShell (output) web shell + * @param aDocShell (output) web shell */ - NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0; + NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) = 0; /** Gets presentation shell associated with XMLterm * @param aPresShell (output) presentation shell diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index 88fbd8f7b09..d79280dacd9 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -823,6 +823,7 @@ NS_IMETHODIMP mozXMLTermSession::DisplayInput(const nsString& aString, return NS_ERROR_FAILURE; if ((cursorCol > 0) || (mPromptHTML.Length() > 0)) { + // Collapse selection to new cursor location result = selection->Collapse(mInputTextNode, cursorCol); } else { @@ -981,13 +982,13 @@ NS_IMETHODIMP mozXMLTermSession::InitStream(const nsString& streamURL, return result; - nsCOMPtr webShell; - result = mXMLTerminal->GetWebShell(getter_AddRefs(webShell)); + nsCOMPtr webShell; + result = mXMLTerminal->GetDocShell(getter_AddRefs(webShell)); if (NS_FAILED(result) || !webShell) return NS_ERROR_FAILURE; nsCOMPtr outerDOMWindow; - result = mozXMLTermUtils::ConvertWebShellToDOMWindow(webShell, + result = mozXMLTermUtils::ConvertDocShellToDOMWindow(webShell, getter_AddRefs(outerDOMWindow)); if (NS_FAILED(result) || !outerDOMWindow) { @@ -997,8 +998,12 @@ NS_IMETHODIMP mozXMLTermSession::InitStream(const nsString& streamURL, } // Initialize markup handling - nsCAutoString iframeName = "iframet"; - //iframeName.Append(mCurrentEntryNumber,10); + nsCAutoString iframeName = "iframe"; +#if 0 + iframeName.Append("t"); +#else + iframeName.Append(mCurrentEntryNumber,10); +#endif nsCAutoString contentType; switch (streamMarkupType) { diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp index 450f916ee34..94773f16bd6 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp @@ -32,8 +32,7 @@ #include "nsIDocumentViewer.h" #include "nsIDocument.h" -#include "nsIWebShell.h" -#include "nsIWebShellWindow.h" +#include "nsIDocShell.h" #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIScriptGlobalObject.h" @@ -42,9 +41,7 @@ #include "nsIAppShellService.h" #include "nsAppShellCIDs.h" -#include "nsAppCoresCIDs.h" -#include "nsIDOMToolkitCore.h" #include "nsIDOMDocument.h" #include "nsIDOMSelection.h" #include "nsIDOMWindow.h" @@ -54,7 +51,6 @@ // Define Class IDs static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); -static NS_DEFINE_CID(kToolkitCoreCID, NS_TOOLKITCORE_CID); // Define Interface IDs static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -86,7 +82,7 @@ NS_NewXMLTermShell(mozIXMLTermShell** aXMLTermShell) mozXMLTermShell::mozXMLTermShell() : mInitialized(PR_FALSE), mContentWindow(nsnull), - mContentAreaWebShell(nsnull), + mContentAreaDocShell(nsnull), mXMLTerminal(nsnull) { NS_INIT_REFCNT(); @@ -205,12 +201,12 @@ mozXMLTermShell::Init(nsIDOMWindow* aContentWin, if (NS_FAILED(result) || !globalObj) return NS_ERROR_FAILURE; - nsCOMPtr webShell; - globalObj->GetWebShell(getter_AddRefs(webShell)); - if (!webShell) + nsCOMPtr docShell; + globalObj->GetDocShell(getter_AddRefs(docShell)); + if (!docShell) return NS_ERROR_FAILURE; - mContentAreaWebShell = webShell; // SVN: does this assignment addref? + mContentAreaDocShell = docShell; // SVN: does this assignment addref? // Create XMLTerminal nsCOMPtr newXMLTerminal; @@ -221,7 +217,7 @@ mozXMLTermShell::Init(nsIDOMWindow* aContentWin, if (NS_SUCCEEDED(result)) { // Initialize XMLTerminal with non-owning reference to us - result = newXMLTerminal->Init(mContentAreaWebShell, this, URL, args); + result = newXMLTerminal->Init(mContentAreaDocShell, this, URL, args); if (NS_SUCCEEDED(result)) { mXMLTerminal = newXMLTerminal; @@ -244,7 +240,7 @@ mozXMLTermShell::Finalize(void) mXMLTerminal = nsnull; } - mContentAreaWebShell = nsnull; + mContentAreaDocShell = nsnull; mContentWindow = nsnull; mInitialized = PR_FALSE; @@ -286,23 +282,6 @@ mozXMLTermShell::NewXMLTermWindow(const PRUnichar* args) XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,10,("\n")); - // Create the toolkit core instance... - nsIDOMToolkitCore* toolkit = nsnull; - result = nsServiceManager::GetService(kToolkitCoreCID, - NS_GET_IID(nsIDOMToolkitCore), - (nsISupports**)&toolkit); - if (NS_FAILED(result)) - return result; - - nsAutoString argStr (args); - toolkit->ShowWindowWithArgs( "chrome://xmlterm/content/XMLTermFrame.xul", - nsnull, argStr ); - - /* Release the toolkit... */ - if (nsnull != toolkit) { - nsServiceManager::ReleaseService(kToolkitCoreCID, toolkit); - } - return result; } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h index e1b72da5238..abd588f5553 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h @@ -73,8 +73,8 @@ protected: /** non-owning reference to content window for XMLterm */ nsIDOMWindow* mContentWindow; - /** non-owning reference (??) to web shell for content window */ - nsIWebShell* mContentAreaWebShell; + /** non-owning reference (??) to doc shell for content window */ + nsIDocShell* mContentAreaDocShell; /** owning reference to XMLTerminal object created by us */ nsCOMPtr mXMLTerminal; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp index 5816c9f0e4a..2cee0191843 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp @@ -36,6 +36,7 @@ #include "nsIDocumentViewer.h" #include "nsIPresContext.h" #include "nsIPresShell.h" +#include "nsIDocumentLoaderFactory.h" #include "nsIViewManager.h" #include "nsIScrollableView.h" @@ -244,11 +245,11 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, mDOMWindow = aDOMWindow; } - // Get webshell for DOM window - nsCOMPtr webShell; - result = mozXMLTermUtils::ConvertDOMWindowToWebShell(mDOMWindow, - getter_AddRefs(webShell)); - if (NS_FAILED(result) || !webShell) + // Get docshell for DOM window + nsCOMPtr docShell; + result = mozXMLTermUtils::ConvertDOMWindowToDocShell(mDOMWindow, + getter_AddRefs(docShell)); + if (NS_FAILED(result) || !docShell) return NS_ERROR_FAILURE; #ifdef NO_WORKAROUND @@ -300,7 +301,7 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, mChannel, mLoadGroup, contentType, - webShell, + docShell, nsnull, getter_AddRefs(mStreamListener), getter_AddRefs(contentViewer) ); @@ -308,11 +309,12 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, return result; nsCOMPtr contViewContainer = - do_QueryInterface(webShell); + do_QueryInterface(docShell); result = contentViewer->SetContainer(contViewContainer); if (NS_FAILED(result)) return result; + nsCOMPtr webShell(do_QueryInterface(docShell)); result = webShell->Embed(contentViewer, command, (nsISupports*) nsnull); if (NS_FAILED(result)) return result; @@ -325,7 +327,8 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, nsCOMPtr innerDOMDoc; result = mDOMWindow->GetDocument(getter_AddRefs(innerDOMDoc)); - printf("mozXMLTermStream::Open,check1, 0x%x\n", result); + printf("mozXMLTermStream::Open,check1, 0x%x, 0x%x\n", + result, (int) innerDOMDoc.get()); if (NS_FAILED(result) || !innerDOMDoc) return NS_ERROR_FAILURE; @@ -404,17 +407,16 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) { nsresult result; - // Get webshell - nsCOMPtr webShell; - result = mozXMLTermUtils::ConvertDOMWindowToWebShell(mDOMWindow, - getter_AddRefs(webShell)); - if (NS_FAILED(result) || !webShell) + // Get docshell + nsCOMPtr docShell; + result = mozXMLTermUtils::ConvertDOMWindowToDocShell(mDOMWindow, + getter_AddRefs(docShell)); + if (NS_FAILED(result) || !docShell) return NS_ERROR_FAILURE; // Get pres context nsCOMPtr presContext; - result = mozXMLTermUtils::GetWebShellPresContext(webShell, - getter_AddRefs(presContext)); + result = docShell->GetPresContext(getter_AddRefs(presContext)); if (NS_FAILED(result) || !presContext) return NS_ERROR_FAILURE; @@ -442,7 +444,7 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) PRInt32 scrollBarWidth = PRInt32(sbWidth*pixelScale); PRInt32 scrollBarHeight = PRInt32(sbHeight*pixelScale); - // Determine webshell size in pixels + // Determine docshell size in pixels nsRect shellArea; result = presContext->GetVisibleArea(shellArea); if (NS_FAILED(result)) @@ -469,7 +471,7 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) pageWidth, pageHeight, pixelScale); if ((pageHeight > shellHeight) || (pageWidth > shellWidth)) { - // Page larger than webshell + // Page larger than docshell nsAutoString attHeight = "height"; nsAutoString attWidth = "width"; nsAutoString attValue = ""; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp index bca3390d9f3..7a1cde30c73 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp @@ -45,110 +45,23 @@ ///////////////////////////////////////////////////////////////////////// -/** Gets presentation context for web shell - * @param aWebShell web shell - * @param aPresContext returned presentation context - * @return NS_OK on success - */ -NS_EXPORT nsresult -mozXMLTermUtils::GetWebShellPresContext(nsIWebShell* aWebShell, - nsIPresContext** aPresContext) -{ - nsresult result; - - XMLT_LOG(mozXMLTermUtils::GetWebShellPresContext,30,("\n")); - - if (!aPresContext) - return NS_ERROR_FAILURE; - - *aPresContext = nsnull; - - nsCOMPtr contViewer; - result = aWebShell->GetContentViewer(getter_AddRefs(contViewer)); - if (NS_FAILED(result) || !contViewer) - return NS_ERROR_FAILURE; - - nsCOMPtr docViewer; - result = contViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer), - (void**)getter_AddRefs(docViewer)); - if (NS_FAILED(result) || !docViewer) - return NS_ERROR_FAILURE; - - nsCOMPtr presContext; - result = docViewer->GetPresContext(*getter_AddRefs(presContext)); - if (NS_FAILED(result) || !presContext) - return NS_ERROR_FAILURE; - - *aPresContext = presContext.get(); - NS_ADDREF(*aPresContext); - - return NS_OK; -} - - -/** Gets DOM document for web shell - * @param aWebShell web shell - * @param aDOMDocument returned DOM document - * @return NS_OK on success - */ -NS_EXPORT nsresult -mozXMLTermUtils::GetWebShellDOMDocument(nsIWebShell* aWebShell, - nsIDOMDocument** aDOMDocument) -{ - nsresult result; - - XMLT_LOG(mozXMLTermUtils::GetWebShellDOMDocument,30,("\n")); - - if (!aDOMDocument) - return NS_ERROR_FAILURE; - - *aDOMDocument = nsnull; - - nsCOMPtr contViewer; - result = aWebShell->GetContentViewer(getter_AddRefs(contViewer)); - if (NS_FAILED(result) || !contViewer) - return NS_ERROR_FAILURE; - - nsCOMPtr docViewer; - result = contViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer), - (void**)getter_AddRefs(docViewer)); - if (NS_FAILED(result) || !docViewer) - return NS_ERROR_FAILURE; - - nsCOMPtr document; - result = docViewer->GetDocument(*getter_AddRefs(document)); - - if (NS_FAILED(result) || !document) - return NS_ERROR_FAILURE; - - nsCOMPtr domDocument = do_QueryInterface(document); - if (!domDocument) - return NS_ERROR_FAILURE; - - *aDOMDocument = domDocument.get(); - NS_ADDREF(*aDOMDocument); - - return NS_OK; -} - - -/** Gets DOM window for web shell - * @param aWebShell web shell +/** Gets DOM window for doc shell + * @param aDocShell doc shell * @param aDOMWindow returned DOM window (frame) * @return NS_OK on success */ NS_EXPORT nsresult -mozXMLTermUtils::ConvertWebShellToDOMWindow(nsIWebShell* aWebShell, +mozXMLTermUtils::ConvertDocShellToDOMWindow(nsIDocShell* aDocShell, nsIDOMWindow** aDOMWindow) { - XMLT_LOG(mozXMLTermUtils::ConvertWebShellToDOMWindow,30,("\n")); + XMLT_LOG(mozXMLTermUtils::ConvertDocShellToDOMWindow,30,("\n")); if (!aDOMWindow) return NS_ERROR_FAILURE; *aDOMWindow = nsnull; - nsCOMPtr scriptGlobalObject(do_GetInterface(aWebShell)); + nsCOMPtr scriptGlobalObject(do_GetInterface(aDocShell)); nsCOMPtr domWindow(do_QueryInterface(scriptGlobalObject)); if (!domWindow) @@ -161,24 +74,24 @@ mozXMLTermUtils::ConvertWebShellToDOMWindow(nsIWebShell* aWebShell, } -/** Gets web shell for DOM window +/** Gets doc shell for DOM window * @param aDOMWindow DOM window (frame) - * @param aWebShell returned web shell + * @param aDocShell returned doc shell * @return NS_OK on success */ NS_EXPORT nsresult -mozXMLTermUtils::ConvertDOMWindowToWebShell(nsIDOMWindow* aDOMWindow, - nsIWebShell** aWebShell) +mozXMLTermUtils::ConvertDOMWindowToDocShell(nsIDOMWindow* aDOMWindow, + nsIDocShell** aDocShell) { - XMLT_LOG(mozXMLTermUtils::ConvertDOMWindowToWebShell,30,("\n")); + XMLT_LOG(mozXMLTermUtils::ConvertDOMWindowToDocShell,30,("\n")); nsCOMPtr globalObject = do_QueryInterface(aDOMWindow); if (!globalObject) return NS_ERROR_FAILURE; - globalObject->GetWebShell(aWebShell); + globalObject->GetDocShell(aDocShell); - if (!*aWebShell) + if (!*aDocShell) return NS_ERROR_FAILURE; return NS_OK; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.h b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.h index d1bde6ee356..d7aa8494631 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.h @@ -28,48 +28,31 @@ #include "nsString.h" -#include "nsIWebShell.h" +#include "nsIDocShell.h" #include "nsIDOMWindow.h" #include "nsIDOMDocument.h" class mozXMLTermUtils { public: - /** Gets presentation context for web shell - * @param aWebShell web shell - * @param aPresContext returned presentation context - * @return NS_OK on success - */ - static NS_EXPORT nsresult - GetWebShellPresContext(nsIWebShell* aWebShell, - nsIPresContext** aPresContext); - /** Gets DOM document for web shell - * @param aWebShell web shell - * @param aDOMDocument returned DOM document - * @return NS_OK on success - */ - static NS_EXPORT nsresult - GetWebShellDOMDocument(nsIWebShell* aWebShell, - nsIDOMDocument** aDOMDocument); - - /** Gets DOM window for web shell - * @param aWebShell web shell + /** Gets DOM window for doc shell + * @param aDocShell doc shell * @param aDOMWindow returned DOM window (frame) * @return NS_OK on success */ static NS_EXPORT nsresult - ConvertWebShellToDOMWindow(nsIWebShell* aWebShell, + ConvertDocShellToDOMWindow(nsIDocShell* aDocShell, nsIDOMWindow** aDOMWindow); - /** Gets web shell for DOM window + /** Gets doc shell for DOM window * @param aDOMWindow DOM window (frame) - * @param aWebShell returned web shell + * @param aDocShell returned doc shell * @return NS_OK on success */ static NS_EXPORT nsresult - ConvertDOMWindowToWebShell(nsIDOMWindow* aDOMWindow, - nsIWebShell** aWebShell); + ConvertDOMWindowToDocShell(nsIDOMWindow* aDOMWindow, + nsIDocShell** aDocShell); /** Locates named inner DOM window (frame) inside outer DOM window * @param outerDOMWindow outer DOM window (frame) diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index ba49ee7326a..d4c6aeedd50 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -97,7 +97,7 @@ mozXMLTerminal::mozXMLTerminal() : mFirstInput(""), mXMLTermShell(nsnull), - mWebShell(nsnull), + mDocShell(nsnull), mPresShell(nsnull), mDOMDocument(nsnull), @@ -195,20 +195,20 @@ NS_IMETHODIMP mozXMLTerminal::SetPrompt(const PRUnichar* aPrompt) // Initialize by starting load of Init page for XMLTerm -NS_IMETHODIMP mozXMLTerminal::Init(nsIWebShell* aWebShell, +NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell, mozIXMLTermShell* aXMLTermShell, const PRUnichar* aURL, const PRUnichar* args) { XMLT_LOG(mozXMLTerminal::Init,20,("\n")); - if (!aWebShell) + if (!aDocShell) return NS_ERROR_NULL_POINTER; - if (mWebShell) + if (mDocShell) return NS_ERROR_ALREADY_INITIALIZED; - mWebShell = aWebShell; // containing webshell; no addref + mDocShell = aDocShell; // containing docshell; no addref mXMLTermShell = aXMLTermShell; // containing xmlterm shell; no addref @@ -216,9 +216,9 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIWebShell* aWebShell, printf("mozXMLTerminal::Init, check1\n"); nsCOMPtr contViewer; - result = mWebShell->GetContentViewer(getter_AddRefs(contViewer)); + result = mDocShell->GetContentViewer(getter_AddRefs(contViewer)); printf("mozXMLTerminal::Init, check2, result=%x, contViewer=%x\n", - result, contViewer.get()); + result, (unsigned int) contViewer.get()); // NOTE: Need to parse args string!!! mCommand = ""; @@ -233,16 +233,26 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIWebShell* aWebShell, XMLT_LOG(mozXMLTerminal::Init,22,("setting DocLoaderObs\n")); // About to create owning reference to this - result = mWebShell->SetDocLoaderObserver((nsIDocumentLoaderObserver*)this); + result = mDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver*)this); if (NS_FAILED(result)) return NS_ERROR_FAILURE; XMLT_LOG(mozXMLTerminal::Init,22,("done setting DocLoaderObs\n")); // Load initial XMLterm background document - nsAutoString urlString(aURL); + nsCAutoString urlCString(aURL); - result = mWebShell->LoadURL(urlString.GetUnicode()); + nsCOMPtr uri; + result = uri->SetSpec(urlCString.GetBuffer()); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + + nsCOMPtr presContext; + result = mDocShell->GetPresContext(getter_AddRefs(presContext)); + if (NS_FAILED(result) || !presContext) + return NS_ERROR_FAILURE; + + result = mDocShell->LoadURI(uri, presContext); if (NS_FAILED(result)) return NS_ERROR_FAILURE; @@ -307,10 +317,10 @@ NS_IMETHODIMP mozXMLTerminal::Finalize(void) mLineTermAux = nsnull; } - if (mWebShell) { + if (mDocShell) { // Stop observing document loading - mWebShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)nsnull); - mWebShell = nsnull; + mDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)nsnull); + mDocShell = nsnull; } mPresShell = nsnull; @@ -349,11 +359,11 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) } nsCOMPtr outerDOMWindow; - result = mozXMLTermUtils::ConvertWebShellToDOMWindow(mWebShell, + result = mozXMLTermUtils::ConvertDocShellToDOMWindow(mDocShell, getter_AddRefs(outerDOMWindow)); if (NS_FAILED(result) || !outerDOMWindow) { - fprintf(stderr, "mozXMLTerminal::Activate: Failed to convert webshell\n"); + fprintf(stderr, "mozXMLTerminal::Activate: Failed to convert docshell\n"); return NS_ERROR_FAILURE; } @@ -383,15 +393,14 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) if (!mInitialized) return NS_ERROR_NOT_INITIALIZED; - PR_ASSERT(mWebShell != nsnull); + PR_ASSERT(mDocShell != nsnull); if ((mDOMDocument != nsnull) || (mPresShell != nsnull)) return NS_ERROR_FAILURE; // Get reference to DOMDocument nsCOMPtr domDocument; - result = mozXMLTermUtils::GetWebShellDOMDocument(mWebShell, - getter_AddRefs(domDocument)); + result = mDocShell->GetDocument(getter_AddRefs(domDocument)); if (NS_FAILED(result) || !domDocument) return NS_ERROR_FAILURE; @@ -401,14 +410,12 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) return NS_ERROR_FAILURE; nsCOMPtr presContext; - result = mozXMLTermUtils::GetWebShellPresContext(mWebShell, - getter_AddRefs(presContext)); + result = mDocShell->GetPresContext(getter_AddRefs(presContext)); if (NS_FAILED(result) || !presContext) return NS_ERROR_FAILURE; nsCOMPtr presShell; - result = presContext->GetShell(getter_AddRefs(presShell)); - + result = mDocShell->GetPresShell(getter_AddRefs(presShell)); if (NS_FAILED(result) || !presShell) return NS_ERROR_FAILURE; @@ -707,18 +714,18 @@ NS_IMETHODIMP mozXMLTerminal::GetDocument(nsIDOMDocument** aDoc) } -// Returns web shell associated with XMLTerm -NS_IMETHODIMP mozXMLTerminal::GetWebShell(nsIWebShell** aWebShell) +// Returns doc shell associated with XMLTerm +NS_IMETHODIMP mozXMLTerminal::GetDocShell(nsIDocShell** aDocShell) { - if (!aWebShell) + if (!aDocShell) return NS_ERROR_NULL_POINTER; - *aWebShell = nsnull; + *aDocShell = nsnull; - NS_PRECONDITION(mWebShell, "bad state, null mWebShell"); - if (!mWebShell) + NS_PRECONDITION(mDocShell, "bad state, null mDocShell"); + if (!mDocShell) return NS_ERROR_NOT_INITIALIZED; - return mWebShell->QueryInterface(NS_GET_IID(nsIWebShell), - (void **)aWebShell); + return mDocShell->QueryInterface(NS_GET_IID(nsIDocShell), + (void **)aDocShell); } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h index 9d0c03803f4..ce5fd2922bc 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h @@ -52,7 +52,7 @@ class mozXMLTerminal : public mozIXMLTerminal, // mozIXMLTerminal interface - NS_IMETHOD Init(nsIWebShell* aWebShell, + NS_IMETHOD Init(nsIDocShell* aDocShell, mozIXMLTermShell* aXMLTermShell, const PRUnichar* aURL, const PRUnichar* args); @@ -74,7 +74,7 @@ class mozXMLTerminal : public mozIXMLTerminal, NS_IMETHOD GetDocument(nsIDOMDocument** aDoc); - NS_IMETHOD GetWebShell(nsIWebShell** aWebShell); + NS_IMETHOD GetDocShell(nsIDocShell** aDocShell); NS_IMETHOD GetPresShell(nsIPresShell** aPresShell); @@ -128,8 +128,8 @@ class mozXMLTerminal : public mozIXMLTerminal, /** non-owning reference to containing XMLTermShell object */ mozIXMLTermShell* mXMLTermShell; - /** non-owning reference to containing web shell */ - nsIWebShell* mWebShell; + /** non-owning reference to containing doc shell */ + nsIDocShell* mDocShell; /** non-owning (??) reference to presentation shell for XMLterm */ nsIPresShell* mPresShell; diff --git a/mozilla/extensions/xmlterm/base/unistring.c b/mozilla/extensions/xmlterm/base/unistring.c index a1f1900f657..9846969ed28 100644 --- a/mozilla/extensions/xmlterm/base/unistring.c +++ b/mozilla/extensions/xmlterm/base/unistring.c @@ -160,15 +160,15 @@ void ucsprint(FILE* stream, const UNICHAR* us, int nus) for (k=0; k= U_A_CHAR) && ((x) <= U_Z_CHAR)) || \ - (((x) >= U_a_CHAR) && ((x) <= U_z_CHAR)) ) +#define IS_ASCII_LETTER(x) ( (((x) >= (UNICHAR)U_A_CHAR) && \ + ((x) <= (UNICHAR)U_Z_CHAR)) || \ + (((x) >= (UNICHAR)U_a_CHAR) && \ + ((x) <= (UNICHAR)U_z_CHAR)) ) -#define IS_ASCII_DIGIT(x) ( ((x) >= U_ZERO) && ((x) <= U_NINE) ) +#define IS_ASCII_DIGIT(x) ( ((x) >= (UNICHAR)U_ZERO) && \ + ((x) <= (UNICHAR)U_NINE) ) #ifdef __cplusplus diff --git a/mozilla/extensions/xmlterm/doc/BUGS b/mozilla/extensions/xmlterm/doc/BUGS index 2883df8c459..5225af93126 100644 --- a/mozilla/extensions/xmlterm/doc/BUGS +++ b/mozilla/extensions/xmlterm/doc/BUGS @@ -1,17 +1,21 @@ Known bugs ---------- -11 Jan 2000 +13 Feb 2000 -1. Early use of "xls -i" does not scroll properly +1. XMLterm bug: Early use of "xls -i" does not scroll properly 2. DOM/IFRAME bug: window.document object not defined for dynamically created IFRAME elements using DOM -3. Typing text in text input element causes input to be duplicated +3. XMLterm bug: Typing text in text input element causes input to be duplicated in the command line -4. Executing "emacs -nw" in the NCURSES version of LTERM results in - LTERM exiting abnormally when user exits emacs. An interrupt error - seems to occur while polling for output in ltermRead. +4. LTERM/NCURSES bug: Executing "emacs -nw" in the NCURSES version of LTERM + results in LTERM exiting abnormally when user exits emacs. An interrupt + error seems to occur while polling for output in ltermRead. + +5. Mozilla bug?: Typing backspace/delete at end of input line aborts XMLterm + Bug in collapsing selection to cursor location? + (nsDOMSelection::Collapse called from mozXMLtermSession::DisplayInput) diff --git a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp index 77bfc7c1d8d..19f5f5c346e 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp +++ b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp @@ -77,7 +77,7 @@ static void event_processor_configure(GtkWidget *window, //fprintf(stderr, "event_processor_configure:\n"); - // Resize web shell window + // Resize doc shell window gSimpleContainer->Resize(alloc->width, alloc->height); return; @@ -215,7 +215,7 @@ int main( int argc, char *argv[] ) // Determine window dimensions GtkAllocation *alloc = >K_WIDGET(mainWin)->allocation; - // Initialize container it to hold a web shell + // Initialize container it to hold a doc shell result = gSimpleContainer->Init((nsNativeWidget *) superWin, alloc->width, alloc->height, mPref); @@ -223,11 +223,11 @@ int main( int argc, char *argv[] ) return result; // Exit main program } - // Get reference to web shell embedded in a simple container - nsCOMPtr webShell; - result = gSimpleContainer->GetWebShell(*getter_AddRefs(webShell)); + // Get reference to doc shell embedded in a simple container + nsCOMPtr docShell; + result = gSimpleContainer->GetDocShell(*getter_AddRefs(docShell)); - if (NS_FAILED(result) || !webShell) { + if (NS_FAILED(result) || !docShell) { return result; // Exit main program } @@ -249,7 +249,7 @@ int main( int argc, char *argv[] ) } nsCOMPtr outerDOMWindow; - result = mozXMLTermUtils::ConvertWebShellToDOMWindow(webShell, + result = mozXMLTermUtils::ConvertDocShellToDOMWindow(docShell, getter_AddRefs(outerDOMWindow)); if (NS_FAILED(result) || !outerDOMWindow) @@ -289,12 +289,12 @@ int main( int argc, char *argv[] ) result = NS_ERROR_OUT_OF_MEMORY; if (NS_SUCCEEDED(result)) { - result = gXMLTerminal->Init(webShell, nsnull, nsnull); + result = gXMLTerminal->Init(docShell, nsnull, nsnull); } #endif // Discard reference to web shell - webShell = nsnull; + docShell = nsnull; // GTK event loop gtk_main(); diff --git a/mozilla/extensions/xmlterm/geckoterm/mozISimpleContainer.h b/mozilla/extensions/xmlterm/geckoterm/mozISimpleContainer.h index bd0cfd40b7d..1ffc5a5fef1 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozISimpleContainer.h +++ b/mozilla/extensions/xmlterm/geckoterm/mozISimpleContainer.h @@ -18,7 +18,7 @@ * Contributor(s): */ -// mozISimpleContainer.h: a simple WebShell container interface +// mozISimpleContainer.h: a simple DocShell container interface // for use in simple programs using the layout engine // (unregistered interface) @@ -28,7 +28,7 @@ #include "nscore.h" #include "nsISupports.h" -#include "nsIWebShell.h" +#include "nsIDocShell.h" #include "nsIPref.h" #include "nsIPresShell.h" #include "nsIDOMDocument.h" @@ -41,50 +41,11 @@ {0x0eb82bF0, 0x43a2, 0x11d3, \ { 0x8e, 0x76, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5 }} -class mozISimpleContainer : public nsIWebShellContainer { +class mozISimpleContainer : public nsIDocumentLoaderObserver { public: NS_DEFINE_STATIC_IID_ACCESSOR(MOZISIMPLE_CONTAINER_IID) - // nsIWebShellContainer interface - NS_IMETHOD WillLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - nsLoadType aReason) = 0; - - NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL) = 0; - - - NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) = 0; - - NS_IMETHOD EndLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - nsresult aStatus) = 0; - - NS_IMETHOD NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell *&aNewWebShell) = 0; - - NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, - nsIWebShell*& aResult) = 0; - - NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, - nsIContent* frameNode) = 0; - - NS_IMETHOD CreatePopup(nsIDOMElement* aElement, - nsIDOMElement* aPopupContent, - PRInt32 aXPos, PRInt32 aYPos, - const nsString& aPopupType, - const nsString& anAnchorAlignment, - const nsString& aPopupAlignment, - nsIDOMWindow* aWindow, nsIDOMWindow** outPopup) = 0; - - NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, - PRBool& aFocusTaken) = 0; - // other /** Initializes simple container for native window widget @@ -109,19 +70,9 @@ public: NS_IMETHOD LoadURL(const char* aURL) = 0; /** Gets web shell in container - * @param aWebShell (output) web shell object + * @param aDocShell (output) web shell object */ - NS_IMETHOD GetWebShell(nsIWebShell*& aWebShell) = 0; - - /** Gets DOM document in container - * @param aDocument (output) DOM document - */ - NS_IMETHOD GetDocument(nsIDOMDocument*& aDocument) = 0; - - /** Gets presentation shell associated with container - * @param aPresShell (output) presentation shell - */ - NS_IMETHOD GetPresShell(nsIPresShell*& aPresShell) = 0; + NS_IMETHOD GetDocShell(nsIDocShell*& aDocShell) = 0; }; #define MOZSIMPLE_CONTAINER_CID \ diff --git a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp index 2b6eea436e2..112d922f072 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp +++ b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp @@ -20,24 +20,26 @@ */ // mozSimpleContainer.cpp: Implements mozISimpleContainer -// which provides a WebShell container for use in simple programs +// which provides a DocShell container for use in simple programs // using the layout engine #include "nscore.h" #include "nsCOMPtr.h" +#include "nsISupports.h" #include "nsRepository.h" -#include "nsISupports.h" - -#include "nsIWebShell.h" -#include "nsIBaseWindow.h" +#include "nsIURI.h" +#include "nsIDocShell.h" #include "nsIDOMDocument.h" #include "nsIDocumentViewer.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIDocument.h" +#include "nsIWebShell.h" +#include "nsIBaseWindow.h" + #include "mozSimpleContainer.h" @@ -46,9 +48,6 @@ static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); // Define Interface IDs static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); -static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID); ///////////////////////////////////////////////////////////////////////// // mozSimpleContainer factory @@ -74,7 +73,7 @@ NS_NewSimpleContainer(mozISimpleContainer** aSimpleContainer) ///////////////////////////////////////////////////////////////////////// mozSimpleContainer::mozSimpleContainer() : - mWebShell(nsnull) + mDocShell(nsnull) { NS_INIT_REFCNT(); } @@ -82,7 +81,7 @@ mozSimpleContainer::mozSimpleContainer() : mozSimpleContainer::~mozSimpleContainer() { - mWebShell = nsnull; + mDocShell = nsnull; } #define NS_IMPL_ADDREF_TRACE(_class) \ @@ -129,8 +128,8 @@ mozSimpleContainer::QueryInterface(REFNSIID aIID,void** aInstancePtr) } else if ( aIID.Equals(NS_GET_IID(mozISimpleContainer)) ) { *aInstancePtr = NS_STATIC_CAST(mozISimpleContainer*,this); - } else if ( aIID.Equals(NS_GET_IID(nsIWebShellContainer)) ) { - *aInstancePtr = NS_STATIC_CAST(nsIWebShellContainer*,this); + } else if ( aIID.Equals(NS_GET_IID(nsIDocumentLoaderObserver)) ) { + *aInstancePtr = NS_STATIC_CAST(nsIDocumentLoaderObserver*,this); } else { return NS_ERROR_NO_INTERFACE; @@ -154,135 +153,105 @@ NS_IMETHODIMP mozSimpleContainer::Init(nsNativeWidget aNativeWidget, PRInt32 width, PRInt32 height, nsIPref* aPref) { - // Create web shell and show it - nsresult result = nsRepository::CreateInstance(kWebShellCID, nsnull, - kIWebShellIID, - getter_AddRefs(mWebShell)); - - if (NS_FAILED(result) || !mWebShell) { - fprintf(stderr, "Failed to create create web shell\n"); - return NS_ERROR_FAILURE; - } - - mWebShell->Init(aNativeWidget, 0, 0, width, height); - - mWebShell->SetContainer(this); - if (aPref) { - mWebShell->SetPrefs(aPref); - } - - nsCOMPtr window = do_QueryInterface(mWebShell); - if (window) { - window->SetVisibility(PR_TRUE); - } - - return NS_OK; -} - - -NS_IMETHODIMP mozSimpleContainer::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) -{ - return NS_OK; -} - - -NS_IMETHODIMP mozSimpleContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) -{ - return NS_OK; -} - - -NS_IMETHODIMP mozSimpleContainer::ProgressLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax) -{ - return NS_OK; -} - - -NS_IMETHODIMP mozSimpleContainer::EndLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - nsresult aStatus) -{ - nsCOMPtr selection; nsresult result; - if (aShell == mWebShell.get()) { - nsCOMPtr domDoc; - nsCOMPtr presShell; + // Create doc shell and show it + result = nsComponentManager::CreateInstance(kWebShellCID, nsnull, + NS_GET_IID(nsIDocShell), + getter_AddRefs(mDocShell)); - result = GetDocument(*getter_AddRefs(domDoc)); - if (NS_FAILED(result) || !domDoc) return result; - - result = GetPresShell(*getter_AddRefs(presShell)); - if (NS_FAILED(result) || !presShell) return result; + if (NS_FAILED(result) || !mDocShell) { + fprintf(stderr, "Failed to create create doc shell\n"); + return NS_ERROR_FAILURE; } - return NS_OK; -} + // We are the document loader observer for the doc shell + mDocShell->SetDocLoaderObserver(this); + // Initialize web shell and show it + nsCOMPtr webShell(do_QueryInterface(mDocShell)); + webShell->Init(aNativeWidget, 0, 0, width, height); -NS_IMETHODIMP mozSimpleContainer::NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell*& aNewWebShell) -{ - aNewWebShell = nsnull; - return NS_ERROR_FAILURE; -} - - -NS_IMETHODIMP mozSimpleContainer::FindWebShellWithName(const PRUnichar* aName, - nsIWebShell*& aResult) -{ - aResult = nsnull; - nsString aNameStr(aName); - - nsIWebShell *aWebShell; - - if (NS_OK == GetWebShell(aWebShell)) { - const PRUnichar *name; - if (NS_OK == aWebShell->GetName(&name)) { - if (aNameStr.Equals(name)) { - aResult = aWebShell; - NS_ADDREF(aResult); - return NS_OK; - } - } + if (aPref) { + mDocShell->SetPrefs(aPref); } - if (NS_OK == aWebShell->FindChildWithName(aName, aResult)) { - if (nsnull != aResult) { - return NS_OK; - } - } + nsCOMPtr docShellWin(do_QueryInterface(mDocShell)); + docShellWin->SetVisibility(PR_TRUE); return NS_OK; } -NS_IMETHODIMP -mozSimpleContainer::ContentShellAdded(nsIWebShell* aChildShell, - nsIContent* frameNode) +// nsIDocumentLoaderObserver interface + +NS_IMETHODIMP mozSimpleContainer::OnStartDocumentLoad( + nsIDocumentLoader *aLoader, + nsIURI *aURL, + const char *aCommand) { return NS_OK; } -NS_IMETHODIMP -mozSimpleContainer::CreatePopup(nsIDOMElement* aElement, - nsIDOMElement* aPopupContent, - PRInt32 aXPos, PRInt32 aYPos, - const nsString& aPopupType, - const nsString& anAnchorAlignment, - const nsString& aPopupAlignment, - nsIDOMWindow* aWindow, nsIDOMWindow** outPopup) +NS_IMETHODIMP mozSimpleContainer::OnEndDocumentLoad(nsIDocumentLoader *loader, + nsIChannel *aChannel, + PRUint32 aStatus) +{ + nsresult result; + + fprintf(stderr, "mozSimpleContainer::OnEndDocumentLoad\n"); + + nsCOMPtr domDoc; + result = mDocShell->GetDocument(getter_AddRefs(domDoc)); + if (NS_FAILED(result) || !domDoc) + return result; + + nsCOMPtr presShell; + result = mDocShell->GetPresShell(getter_AddRefs(presShell)); + if (NS_FAILED(result) || !presShell) + return result; + + return NS_OK; +} + + +NS_IMETHODIMP mozSimpleContainer::OnStartURLLoad(nsIDocumentLoader *aLoader, + nsIChannel *channel) { return NS_OK; } -NS_IMETHODIMP -mozSimpleContainer::FocusAvailable(nsIWebShell* aFocusedWebShell, - PRBool& aFocusTaken) +NS_IMETHODIMP mozSimpleContainer::OnProgressURLLoad(nsIDocumentLoader *aLoader, + nsIChannel *aChannel, + PRUint32 aProgress, + PRUint32 aProgressMax) +{ + return NS_OK; +} + + +NS_IMETHODIMP mozSimpleContainer::OnStatusURLLoad(nsIDocumentLoader *loader, + nsIChannel *channel, + nsString & aMsg) +{ + return NS_OK; +} + + +NS_IMETHODIMP mozSimpleContainer::OnEndURLLoad(nsIDocumentLoader *aLoader, + nsIChannel *aChannel, + PRUint32 aStatus) +{ + return NS_OK; +} + + +NS_IMETHODIMP mozSimpleContainer::HandleUnknownContentType( + nsIDocumentLoader *aLoader, + nsIChannel *aChannel, + const char *aContentType, const char *aCommand) { return NS_OK; } @@ -294,12 +263,14 @@ mozSimpleContainer::FocusAvailable(nsIWebShell* aFocusedWebShell, */ NS_IMETHODIMP mozSimpleContainer::Resize(PRInt32 aWidth, PRInt32 aHeight) { - if (!mWebShell) return NS_ERROR_FAILURE; + fprintf(stderr, "mozSimpleContainer::Resize\n"); + + if (!mDocShell) + return NS_ERROR_FAILURE; + + nsCOMPtr docShellWin(do_QueryInterface(mDocShell)); + docShellWin->SetPositionAndSize(0, 0, aWidth, aHeight, PR_FALSE); - nsCOMPtr window = do_QueryInterface(mWebShell); - if (window) { - window->SetPositionAndSize(0, 0, aWidth, aHeight, PR_FALSE); - } return NS_OK; } @@ -309,97 +280,25 @@ NS_IMETHODIMP mozSimpleContainer::Resize(PRInt32 aWidth, PRInt32 aHeight) */ NS_IMETHODIMP mozSimpleContainer::LoadURL(const char* aURL) { - if (!mWebShell) return NS_ERROR_FAILURE; + nsresult result; + + if (!mDocShell) + return NS_ERROR_FAILURE; + + nsCOMPtr webShell(do_QueryInterface(mDocShell)); nsString aStr(aURL); - mWebShell->LoadURL(aStr.GetUnicode()); - return NS_OK; + result = webShell->LoadURL(aStr.GetUnicode()); + return result; } -/** Gets web shell in container - * @param aWebShell (output) web shell object +/** Gets doc shell in container + * @param aDocShell (output) doc shell object */ -NS_IMETHODIMP mozSimpleContainer::GetWebShell(nsIWebShell*& aWebShell) +NS_IMETHODIMP mozSimpleContainer::GetDocShell(nsIDocShell*& aDocShell) { - aWebShell = mWebShell.get(); - NS_IF_ADDREF(aWebShell); // Add ref'ed; needs to be released - return NS_OK; -} - - -/** Gets DOM document in container - * @param aDocument (output) DOM document - */ -NS_IMETHODIMP mozSimpleContainer::GetDocument(nsIDOMDocument*& aDocument) -{ - - aDocument = nsnull; - - if (mWebShell) { - nsIContentViewer* contViewer; - mWebShell->GetContentViewer(&contViewer); - - if (nsnull != contViewer) { - nsIDocumentViewer* docViewer; - if (NS_OK == contViewer->QueryInterface(kIDocumentViewerIID, - (void**) &docViewer)) - { - nsIDocument* vDoc; - docViewer->GetDocument(vDoc); - - if (nsnull != vDoc) { - nsIDOMDocument* vDOMDoc; - if (NS_OK == vDoc->QueryInterface(kIDOMDocumentIID, - (void**) &vDOMDoc)) - { - aDocument = vDOMDoc; // Add ref'ed; needs to be released - } - NS_RELEASE(vDoc); - } - - NS_RELEASE(docViewer); - } - - NS_RELEASE(contViewer); - } - } - return NS_OK; -} - - -/** Gets presentation shell associated with container - * @param aPresShell (output) presentation shell - */ -NS_IMETHODIMP mozSimpleContainer::GetPresShell(nsIPresShell*& aPresShell) -{ - aPresShell = nsnull; - - nsIPresShell* presShell = nsnull; - - if (mWebShell) { - nsIContentViewer* contViewer = nsnull; - mWebShell->GetContentViewer(&contViewer); - - if (nsnull != contViewer) { - nsIDocumentViewer* docViewer = nsnull; - contViewer->QueryInterface(kIDocumentViewerIID, (void**) &docViewer); - - if (nsnull != docViewer) { - nsIPresContext* presContext; - docViewer->GetPresContext(presContext); - - if (nsnull != presContext) { - presContext->GetShell(&presShell); // Add ref'ed - aPresShell = presShell; - NS_RELEASE(presContext); - } - - NS_RELEASE(docViewer); - } - - NS_RELEASE(contViewer); - } - } + aDocShell = mDocShell.get(); + NS_IF_ADDREF(aDocShell); // Add ref'ed; needs to be released return NS_OK; } diff --git a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.h b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.h index 9a9f4a4191a..7934c93b07a 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.h +++ b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.h @@ -20,7 +20,7 @@ // mozSimpleContainer.h: declaration of mozSimpleContainer class // implementing mozISimpleContainer, -// which provides a WebShell container for use in simple programs +// which provides a DocShell container for use in simple programs // using the layout engine #include "nscore.h" @@ -38,44 +38,8 @@ public: // nsISupports NS_DECL_ISUPPORTS - // nsIWebShellContainer interface - NS_IMETHOD WillLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - nsLoadType aReason); - - NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL); - - - NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax); - - NS_IMETHOD EndLoadURL(nsIWebShell* aShell, - const PRUnichar* aURL, - nsresult aStatus); - - NS_IMETHOD NewWebShell(PRUint32 aChromeMask, - PRBool aVisible, - nsIWebShell *&aNewWebShell); - - NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, - nsIWebShell*& aResult); - - NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, - nsIContent* frameNode); - - NS_IMETHOD CreatePopup(nsIDOMElement* aElement, - nsIDOMElement* aPopupContent, - PRInt32 aXPos, PRInt32 aYPos, - const nsString& aPopupType, - const nsString& anAnchorAlignment, - const nsString& aPopupAlignment, - nsIDOMWindow* aWindow, nsIDOMWindow** outPopup); - - NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, - PRBool& aFocusTaken); + // nsIDocumentLoaderObserver interface + NS_DECL_NSIDOCUMENTLOADEROBSERVER \ // other NS_IMETHOD Init(nsNativeWidget aNativeWidget, @@ -86,15 +50,11 @@ public: NS_IMETHOD LoadURL(const char* aURL); - NS_IMETHOD GetWebShell(nsIWebShell*& aWebShell); - - NS_IMETHOD GetDocument(nsIDOMDocument*& aDocument); - - NS_IMETHOD GetPresShell(nsIPresShell*& aPresShell); + NS_IMETHOD GetDocShell(nsIDocShell*& aDocShell); protected: - /** owning reference to web shell created by us */ - nsCOMPtr mWebShell; + /** owning reference to doc shell created by us */ + nsCOMPtr mDocShell; };