XMLterm changes only; NOT PART OF DEFAULT SEAMONKEY BUILD.

Migrated from WebShell to DocShell; compiles with Feb12 tree.
(WebShell still used by mozSimpleContainer, as in viewer/nsBrowserWindow.cpp)


git-svn-id: svn://10.0.0.236/trunk@60671 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
svn%xmlterm.org
2000-02-14 01:17:55 +00:00
parent 32a405424b
commit af05cfd052
21 changed files with 277 additions and 560 deletions

View File

@@ -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) */

View File

@@ -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",

View File

@@ -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) */

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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

View File

@@ -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<nsIWebShell> webShell;
result = mXMLTerminal->GetWebShell(getter_AddRefs(webShell));
nsCOMPtr<nsIDocShell> webShell;
result = mXMLTerminal->GetDocShell(getter_AddRefs(webShell));
if (NS_FAILED(result) || !webShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMWindow> 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) {

View File

@@ -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<nsIWebShell> webShell;
globalObj->GetWebShell(getter_AddRefs(webShell));
if (!webShell)
nsCOMPtr<nsIDocShell> 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<mozIXMLTerminal> 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;
}

View File

@@ -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<mozIXMLTerminal> mXMLTerminal;

View File

@@ -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<nsIWebShell> webShell;
result = mozXMLTermUtils::ConvertDOMWindowToWebShell(mDOMWindow,
getter_AddRefs(webShell));
if (NS_FAILED(result) || !webShell)
// Get docshell for DOM window
nsCOMPtr<nsIDocShell> 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<nsIContentViewerContainer> contViewContainer =
do_QueryInterface(webShell);
do_QueryInterface(docShell);
result = contentViewer->SetContainer(contViewContainer);
if (NS_FAILED(result))
return result;
nsCOMPtr<nsIWebShell> 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<nsIDOMDocument> 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<nsIWebShell> webShell;
result = mozXMLTermUtils::ConvertDOMWindowToWebShell(mDOMWindow,
getter_AddRefs(webShell));
if (NS_FAILED(result) || !webShell)
// Get docshell
nsCOMPtr<nsIDocShell> docShell;
result = mozXMLTermUtils::ConvertDOMWindowToDocShell(mDOMWindow,
getter_AddRefs(docShell));
if (NS_FAILED(result) || !docShell)
return NS_ERROR_FAILURE;
// Get pres context
nsCOMPtr<nsIPresContext> 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 = "";

View File

@@ -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<nsIContentViewer> contViewer;
result = aWebShell->GetContentViewer(getter_AddRefs(contViewer));
if (NS_FAILED(result) || !contViewer)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocumentViewer> docViewer;
result = contViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer),
(void**)getter_AddRefs(docViewer));
if (NS_FAILED(result) || !docViewer)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresContext> 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<nsIContentViewer> contViewer;
result = aWebShell->GetContentViewer(getter_AddRefs(contViewer));
if (NS_FAILED(result) || !contViewer)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocumentViewer> docViewer;
result = contViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer),
(void**)getter_AddRefs(docViewer));
if (NS_FAILED(result) || !docViewer)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> document;
result = docViewer->GetDocument(*getter_AddRefs(document));
if (NS_FAILED(result) || !document)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMDocument> 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<nsIScriptGlobalObject> scriptGlobalObject(do_GetInterface(aWebShell));
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject(do_GetInterface(aDocShell));
nsCOMPtr<nsIDOMWindow> 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<nsIScriptGlobalObject> 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;

View File

@@ -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)

View File

@@ -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<nsIContentViewer> 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<nsIURI> uri;
result = uri->SetSpec(urlCString.GetBuffer());
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresContext> 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<nsIDOMWindow> 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<nsIDOMDocument> 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<nsIPresContext> presContext;
result = mozXMLTermUtils::GetWebShellPresContext(mWebShell,
getter_AddRefs(presContext));
result = mDocShell->GetPresContext(getter_AddRefs(presContext));
if (NS_FAILED(result) || !presContext)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> 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);
}

View File

@@ -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;

View File

@@ -160,15 +160,15 @@ void ucsprint(FILE* stream, const UNICHAR* us, int nus)
for (k=0; k<nus; k++) {
uch = us[k];
if (uch < U_SPACE) {
if (uch < (UNICHAR)U_SPACE) {
/* ASCII control character */
fprintf(stream, "^%c", (char) uch+U_ATSIGN);
} else if (uch == U_CARET) {
} else if (uch == (UNICHAR)U_CARET) {
/* Caret */
fprintf(stream, "^^");
} else if (uch < U_DEL) {
} else if (uch < (UNICHAR)U_DEL) {
/* Printable ASCII character */
fprintf(stream, "%c", (char) uch);

View File

@@ -264,10 +264,13 @@ void ucsprint(FILE* stream, const UNICHAR* us, int nus);
#define U_NOBRKSPACE 0xA0U /* no-break space */
#define U_LATIN1HI 0xFFU /* highest Latin1 extension character */
#define IS_ASCII_LETTER(x) ( (((x) >= 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

View File

@@ -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)

View File

@@ -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 = &GTK_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<nsIWebShell> webShell;
result = gSimpleContainer->GetWebShell(*getter_AddRefs(webShell));
// Get reference to doc shell embedded in a simple container
nsCOMPtr<nsIDocShell> 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<nsIDOMWindow> 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();

View File

@@ -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 \

View File

@@ -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<nsIBaseWindow> 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<nsIDOMSelection> selection;
nsresult result;
if (aShell == mWebShell.get()) {
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIPresShell> 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<nsIWebShell> 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<nsIBaseWindow> 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<nsIDOMDocument> domDoc;
result = mDocShell->GetDocument(getter_AddRefs(domDoc));
if (NS_FAILED(result) || !domDoc)
return result;
nsCOMPtr<nsIPresShell> 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<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->SetPositionAndSize(0, 0, aWidth, aHeight, PR_FALSE);
nsCOMPtr<nsIBaseWindow> 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<nsIWebShell> 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;
}

View File

@@ -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<nsIWebShell> mWebShell;
/** owning reference to doc shell created by us */
nsCOMPtr<nsIDocShell> mDocShell;
};