зеркало из https://github.com/mozilla/pjs.git
--NOT PART OF DEFAULT BUILD--
XMLterm changes only. Changed non-owning references in mozXMLTerminal to weak references to avoid crash in mozXMLTerminal::Finalize when exiting xmlterm.
This commit is contained in:
Родитель
91f816e482
Коммит
14cc97b073
|
@ -131,6 +131,16 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetPresShell(nsIPresShell** aPresShell) = 0;
|
||||
|
||||
/** Gets DOM document associated with XMLterm
|
||||
* @param aDOMDocumentl (output) DOM document
|
||||
*/
|
||||
NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument) = 0;
|
||||
|
||||
/** Gets selection controller associated with XMLterm
|
||||
* @param aSelectionControllerl (output) DOM document
|
||||
*/
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController** aSelectionController) = 0;
|
||||
|
||||
/** Gets flag denoting whether terminal is in full screen mode
|
||||
* @param aFlag (output) screen mode flag
|
||||
*/
|
||||
|
|
|
@ -108,8 +108,6 @@ const char* const mozXMLTermSession::treeActionNames[] = {
|
|||
mozXMLTermSession::mozXMLTermSession() :
|
||||
mInitialized(PR_FALSE),
|
||||
mXMLTerminal(nsnull),
|
||||
mPresShell(nsnull),
|
||||
mDOMDocument(nsnull),
|
||||
|
||||
mBodyNode(nsnull),
|
||||
mSessionNode(nsnull),
|
||||
|
@ -177,6 +175,8 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal,
|
|||
nsIDOMDocument* aDOMDocument,
|
||||
PRInt32 nRows, PRInt32 nCols)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
XMLT_LOG(mozXMLTermSession::Init,30,("\n"));
|
||||
|
||||
if (mInitialized)
|
||||
|
@ -186,8 +186,6 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal,
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mXMLTerminal = aXMLTerminal; // containing XMLTerminal; no addref
|
||||
mPresShell = aPresShell; // presentation shell; no addref
|
||||
mDOMDocument = aDOMDocument; // DOM document; no addref
|
||||
|
||||
mInitialized = PR_TRUE;
|
||||
|
||||
|
@ -196,10 +194,13 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal,
|
|||
mTopScrollRow = mScreenRows - 1;
|
||||
mBotScrollRow = 0;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLDocument> vDOMHTMLDocument
|
||||
(do_QueryInterface(mDOMDocument));
|
||||
(do_QueryInterface(domDoc));
|
||||
if (!vDOMHTMLDocument)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -283,8 +284,6 @@ NS_IMETHODIMP mozXMLTermSession::Finalize(void)
|
|||
mCurrentDebugNode = nsnull;
|
||||
|
||||
mXMLTerminal = nsnull;
|
||||
mPresShell = nsnull;
|
||||
mDOMDocument = nsnull;
|
||||
|
||||
XMLT_LOG(mozXMLTermSession::Finalize,32,("END\n"));
|
||||
|
||||
|
@ -874,6 +873,11 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
|
|||
nsAutoString metaCommandOutput;
|
||||
metaCommandOutput.SetLength(0);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
break;
|
||||
|
||||
switch (mMetaCommandType) {
|
||||
|
||||
case DEFAULT_META_COMMAND:
|
||||
|
@ -885,7 +889,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
|
|||
JSCommand.AppendWithConversion("\");");
|
||||
|
||||
// Execute JavaScript command
|
||||
result = mozXMLTermUtils::ExecuteScript(mDOMDocument,
|
||||
result = mozXMLTermUtils::ExecuteScript(domDoc,
|
||||
JSCommand,
|
||||
metaCommandOutput);
|
||||
if (NS_FAILED(result))
|
||||
|
@ -919,7 +923,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
|
|||
case JS_META_COMMAND:
|
||||
{
|
||||
// Execute JavaScript command
|
||||
result = mozXMLTermUtils::ExecuteScript(mDOMDocument,
|
||||
result = mozXMLTermUtils::ExecuteScript(domDoc,
|
||||
commandArgs,
|
||||
metaCommandOutput);
|
||||
if (NS_FAILED(result))
|
||||
|
@ -1091,9 +1095,13 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
|
|||
if (mEntryHasOutput)
|
||||
PositionOutputCursor(lineTermAux);
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(mPresShell);
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
|
||||
nsISelectionController::SELECTION_FOCUS_REGION);
|
||||
nsISelectionController::SELECTION_FOCUS_REGION);
|
||||
}
|
||||
|
||||
// Show caret
|
||||
|
@ -1136,9 +1144,10 @@ NS_IMETHODIMP mozXMLTermSession::Abort(mozILineTermAux* lineTermAux,
|
|||
|
||||
// Collapse selection and position cursor
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(selection));
|
||||
|
@ -1179,9 +1188,10 @@ NS_IMETHODIMP mozXMLTermSession::DisplayInput(const nsString& aString,
|
|||
|
||||
// Collapse selection and position cursor
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
|
||||
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
|
@ -1430,6 +1440,11 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow)
|
|||
if (!mEntryHasOutput)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
switch (mOutputMarkupType) {
|
||||
|
||||
case INSECURE_FRAGMENT:
|
||||
|
@ -1480,7 +1495,7 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow)
|
|||
// Execute JS fragment
|
||||
nsAutoString jsOutput;
|
||||
jsOutput.SetLength(0);
|
||||
result = mozXMLTermUtils::ExecuteScript(mDOMDocument,
|
||||
result = mozXMLTermUtils::ExecuteScript(domDoc,
|
||||
mFragmentBuffer,
|
||||
jsOutput);
|
||||
if (NS_FAILED(result))
|
||||
|
@ -2197,10 +2212,16 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString,
|
|||
result = InsertFragment(markupString, mOutputDisplayNode,
|
||||
mCurrentEntryNumber, mOutputTextNode.get());
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Insert text node containing newline only
|
||||
nsCOMPtr<nsIDOMText> newText;
|
||||
nsAutoString newlineStr; newlineStr.AssignWithConversion("\n");
|
||||
result = mDOMDocument->CreateTextNode(newlineStr, getter_AddRefs(newText));
|
||||
|
||||
result = domDoc->CreateTextNode(newlineStr, getter_AddRefs(newText));
|
||||
if (NS_FAILED(result) || !newText)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -2253,9 +2274,10 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString,
|
|||
nsCOMPtr<nsISelection> selection;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(selection));
|
||||
if (NS_FAILED(result) || !selection)
|
||||
|
@ -2852,9 +2874,10 @@ void mozXMLTermSession::PositionOutputCursor(mozILineTermAux* lineTermAux)
|
|||
nsCOMPtr<nsISelection> selection;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
return ;; // NS_ERROR_FAILURE;
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return; // NS_ERROR_FAILURE
|
||||
|
||||
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result) && selection) {
|
||||
|
@ -2897,7 +2920,12 @@ NS_IMETHODIMP mozXMLTermSession::ScrollToBottomLeft(void)
|
|||
if (NS_FAILED(result) || !domWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mPresShell->FlushPendingNotifications();
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
result = mXMLTerminal->GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_FAILED(result) || !presShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
presShell->FlushPendingNotifications();
|
||||
|
||||
// Scroll to bottom left of screen
|
||||
domWindow->ScrollBy(-99999,99999);
|
||||
|
@ -3155,10 +3183,15 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt)
|
|||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Create IMG element
|
||||
tagName.AssignWithConversion("img");
|
||||
nsCOMPtr<nsIDOMElement> imgElement;
|
||||
result = mDOMDocument->CreateElement(tagName, getter_AddRefs(imgElement));
|
||||
result = domDoc->CreateElement(tagName, getter_AddRefs(imgElement));
|
||||
if (NS_FAILED(result) || !imgElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3187,7 +3220,7 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt)
|
|||
// Append text node containing single space
|
||||
nsCOMPtr<nsIDOMText> stubText;
|
||||
nsAutoString spaceStr; spaceStr.AssignWithConversion(" ");
|
||||
result = mDOMDocument->CreateTextNode(spaceStr, getter_AddRefs(stubText));
|
||||
result = domDoc->CreateTextNode(spaceStr, getter_AddRefs(stubText));
|
||||
if (NS_FAILED(result) || !stubText)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3296,9 +3329,11 @@ NS_IMETHODIMP mozXMLTermSession::NewScreen(void)
|
|||
result = PositionScreenCursor(0, 0);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
result = selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
|
||||
nsISelectionController::SELECTION_FOCUS_REGION);
|
||||
}
|
||||
|
@ -3428,9 +3463,10 @@ NS_IMETHODIMP mozXMLTermSession::PositionScreenCursor(PRInt32 aRow,
|
|||
nsCOMPtr<nsISelection> selection;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
selCon = do_QueryInterface(mPresShell);
|
||||
if (!selCon)
|
||||
result = mXMLTerminal->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (NS_FAILED(result) || !selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(selection));
|
||||
|
||||
|
@ -3728,9 +3764,14 @@ NS_IMETHODIMP mozXMLTermSession::NewAnchor(const nsString& classAttribute,
|
|||
|
||||
XMLT_LOG(mozXMLTermSession::NewAnchor,80,("\n"));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Create anchor
|
||||
nsCOMPtr<nsIDOMElement> newElement;
|
||||
result = mDOMDocument->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
result = domDoc->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
if (NS_FAILED(result) || !newElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3785,9 +3826,14 @@ NS_IMETHODIMP mozXMLTermSession::NewElement(const nsString& tagName,
|
|||
|
||||
XMLT_LOG(mozXMLTermSession::NewElement,80,("\n"));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Create element
|
||||
nsCOMPtr<nsIDOMElement> newElement;
|
||||
result = mDOMDocument->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
result = domDoc->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
if (NS_FAILED(result) || !newElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3841,10 +3887,15 @@ NS_IMETHODIMP mozXMLTermSession::NewTextNode( nsIDOMNode* parentNode,
|
|||
|
||||
XMLT_LOG(mozXMLTermSession::NewTextNode,80,("\n"));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Create text node
|
||||
nsCOMPtr<nsIDOMText> newText;
|
||||
nsAutoString nullStr; nullStr.SetLength(0);
|
||||
result = mDOMDocument->CreateTextNode(nullStr, getter_AddRefs(newText));
|
||||
result = domDoc->CreateTextNode(nullStr, getter_AddRefs(newText));
|
||||
if (NS_FAILED(result) || !newText)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3881,6 +3932,11 @@ NS_IMETHODIMP mozXMLTermSession::NewIFrame(nsIDOMNode* parentNode,
|
|||
|
||||
XMLT_LOG(mozXMLTermSession::NewIFrame,80,("\n"));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
result = mXMLTerminal->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(result) || !domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#if 0
|
||||
nsAutoString iframeFrag("<iframe name='iframe");
|
||||
iframeFrag.Append(number,10);
|
||||
|
@ -3898,7 +3954,7 @@ NS_IMETHODIMP mozXMLTermSession::NewIFrame(nsIDOMNode* parentNode,
|
|||
// Create IFRAME element
|
||||
nsCOMPtr<nsIDOMElement> newElement;
|
||||
nsAutoString tagName; tagName.AssignWithConversion("iframe");
|
||||
result = mDOMDocument->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
result = domDoc->CreateElement(tagName, getter_AddRefs(newElement));
|
||||
if (NS_FAILED(result) || !newElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -236,7 +236,8 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell,
|
|||
// Initialization flag
|
||||
mInitialized = PR_TRUE;
|
||||
|
||||
mDocShell = aDocShell; // containing docshell; no addref
|
||||
// Containing docshell
|
||||
mDocShell = getter_AddRefs(NS_GetWeakReference(aDocShell)); // weak ref
|
||||
|
||||
mXMLTermShell = aXMLTermShell; // containing xmlterm shell; no addref
|
||||
|
||||
|
@ -244,7 +245,7 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell,
|
|||
|
||||
printf("mozXMLTerminal::Init, check1\n");
|
||||
nsCOMPtr<nsIContentViewer> contViewer;
|
||||
result = mDocShell->GetContentViewer(getter_AddRefs(contViewer));
|
||||
result = aDocShell->GetContentViewer(getter_AddRefs(contViewer));
|
||||
printf("mozXMLTerminal::Init, check2, result=%x, contViewer=%x\n",
|
||||
result, (unsigned int) contViewer.get());
|
||||
|
||||
|
@ -258,7 +259,7 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell,
|
|||
XMLT_LOG(mozXMLTerminal::Init,22,("setting DocLoaderObs\n"));
|
||||
|
||||
// About to create owning reference to this
|
||||
result = mDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver*)this);
|
||||
result = aDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver*)this);
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -273,7 +274,7 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell,
|
|||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
result = mDocShell->LoadURI(uri, nsnull, nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
result = aDocShell->LoadURI(uri, nsnull, nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -306,10 +307,12 @@ NS_IMETHODIMP mozXMLTerminal::Finalize(void)
|
|||
mXMLTermSession = nsnull;
|
||||
}
|
||||
|
||||
if (mDOMDocument) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryReferent(mDOMDocument);
|
||||
|
||||
if (domDoc) {
|
||||
// Release any event listeners for the document
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver;
|
||||
nsresult result = mDOMDocument->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(eventReceiver));
|
||||
nsresult result = domDoc->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(eventReceiver));
|
||||
|
||||
if (NS_SUCCEEDED(result) && eventReceiver) {
|
||||
if (mKeyListener) {
|
||||
|
@ -336,20 +339,22 @@ NS_IMETHODIMP mozXMLTerminal::Finalize(void)
|
|||
mDragListener = nsnull;
|
||||
}
|
||||
}
|
||||
mDOMDocument = nsnull;
|
||||
}
|
||||
|
||||
mDOMDocument = nsnull;
|
||||
|
||||
if (mLineTermAux) {
|
||||
// Finalize and release reference to LineTerm object owned by us
|
||||
mLineTermAux->CloseAux();
|
||||
mLineTermAux = nsnull;
|
||||
}
|
||||
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
if (docShell) {
|
||||
// Stop observing document loading
|
||||
mDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)nsnull);
|
||||
mDocShell = nsnull;
|
||||
docShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)nsnull);
|
||||
}
|
||||
mDocShell = nsnull;
|
||||
|
||||
mPresShell = nsnull;
|
||||
mXMLTermShell = nsnull;
|
||||
|
@ -386,8 +391,12 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
if (!docShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> outerDOMWindow;
|
||||
result = mozXMLTermUtils::ConvertDocShellToDOMWindow(mDocShell,
|
||||
result = mozXMLTermUtils::ConvertDocShellToDOMWindow(docShell,
|
||||
getter_AddRefs(outerDOMWindow));
|
||||
|
||||
if (NS_FAILED(result) || !outerDOMWindow) {
|
||||
|
@ -426,14 +435,18 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
if ((mDOMDocument != nsnull) || (mPresShell != nsnull))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
if (!docShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get reference to presentation shell
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
result = mDocShell->GetPresContext(getter_AddRefs(presContext));
|
||||
result = docShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (NS_FAILED(result) || !presContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
result = mDocShell->GetPresShell(getter_AddRefs(presShell));
|
||||
result = docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_FAILED(result) || !presShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -444,14 +457,13 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
if (NS_FAILED(result) || !document)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(document);
|
||||
if (!domDocument)
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(document);
|
||||
if (!domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Save references to presentation shell and DOMDocument
|
||||
// (SVN: Should these be addref'ed and released in the destructor?)
|
||||
mPresShell = presShell; // no addref
|
||||
mDOMDocument = domDocument; // no addref
|
||||
// Save weak references to presentation shell and DOMDocument
|
||||
mPresShell = getter_AddRefs(NS_GetWeakReference(presShell)); // weak ref
|
||||
mDOMDocument = getter_AddRefs(NS_GetWeakReference(domDoc)); // weak ref
|
||||
|
||||
// Show caret
|
||||
ShowCaret();
|
||||
|
@ -477,7 +489,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = mXMLTermSession->Init(this, mPresShell, mDOMDocument, nRows, nCols);
|
||||
result = mXMLTermSession->Init(this, presShell, domDoc, nRows, nCols);
|
||||
if (NS_FAILED(result)) {
|
||||
XMLT_WARNING("mozXMLTerminal::Activate: Warning - Failed to initialize XMLTermSession\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -507,7 +519,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
mPromptExpr.GetUnicode(),
|
||||
options, LTERM_DETERMINE_PROCESS,
|
||||
nRows, nCols, xPixels, yPixels,
|
||||
mDOMDocument, anObserver, cookie);
|
||||
domDoc, anObserver, cookie);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
XMLT_WARNING("mozXMLTerminal::Activate: Warning - Failed to open LineTermAux\n");
|
||||
|
@ -520,7 +532,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
|
|||
|
||||
// Get the DOM event receiver for document
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver;
|
||||
result = mDOMDocument->QueryInterface(NS_GET_IID(nsIDOMEventReceiver),
|
||||
result = domDoc->QueryInterface(NS_GET_IID(nsIDOMEventReceiver),
|
||||
getter_AddRefs(eventReceiver));
|
||||
if (NS_FAILED(result)) {
|
||||
XMLT_WARNING("mozXMLTerminal::Activate: Warning - Failed to get DOM receiver\n");
|
||||
|
@ -605,9 +617,13 @@ NS_IMETHODIMP mozXMLTerminal::ScreenSize(PRInt32& rows, PRInt32& cols,
|
|||
|
||||
XMLT_LOG(mozXMLTerminal::ScreenSize,70,("\n"));
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get presentation context
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
result = mPresShell->GetPresContext( getter_AddRefs(presContext) );
|
||||
result = presShell->GetPresContext( getter_AddRefs(presContext) );
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
|
@ -724,7 +740,11 @@ NS_IMETHODIMP mozXMLTerminal::ShowCaret(void)
|
|||
if (!mPresShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(mPresShell);
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
||||
|
||||
if (!selCon) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -746,7 +766,7 @@ NS_IMETHODIMP mozXMLTerminal::ShowCaret(void)
|
|||
selCon->SetCaretReadOnly(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsICaret> caret;
|
||||
if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret)))) {
|
||||
if (NS_SUCCEEDED(presShell->GetCaret(getter_AddRefs(caret)))) {
|
||||
|
||||
caret->SetCaretVisible(PR_TRUE);
|
||||
caret->SetCaretReadOnly(PR_FALSE);
|
||||
|
@ -869,7 +889,12 @@ NS_IMETHODIMP mozXMLTerminal::GetDocument(nsIDOMDocument** aDoc)
|
|||
NS_PRECONDITION(mDOMDocument, "bad state, null mDOMDocument");
|
||||
if (!mDOMDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return mDOMDocument->QueryInterface(NS_GET_IID(nsIDOMDocument),
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryReferent(mDOMDocument);
|
||||
if (!domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return domDoc->QueryInterface(NS_GET_IID(nsIDOMDocument),
|
||||
(void **)aDoc);
|
||||
}
|
||||
|
||||
|
@ -885,7 +910,14 @@ NS_IMETHODIMP mozXMLTerminal::GetDocShell(nsIDocShell** aDocShell)
|
|||
NS_PRECONDITION(mDocShell, "bad state, null mDocShell");
|
||||
if (!mDocShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return mDocShell->QueryInterface(NS_GET_IID(nsIDocShell),
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
if (!docShell) {
|
||||
XMLT_ERROR("mozXMLTerminal::GetDocShell: Error - Invalid weak reference\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return docShell->QueryInterface(NS_GET_IID(nsIDocShell),
|
||||
(void **)aDocShell);
|
||||
}
|
||||
|
||||
|
@ -901,11 +933,64 @@ NS_IMETHODIMP mozXMLTerminal::GetPresShell(nsIPresShell** aPresShell)
|
|||
NS_PRECONDITION(mPresShell, "bad state, null mPresShell");
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return mPresShell->QueryInterface(NS_GET_IID(nsIPresShell),
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell) {
|
||||
XMLT_ERROR("mozXMLTerminal::GetPresShell: Error - Invalid weak reference\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return presShell->QueryInterface(NS_GET_IID(nsIPresShell),
|
||||
(void **)aPresShell);
|
||||
}
|
||||
|
||||
|
||||
// Returns DOMDocument associated with XMLTerm
|
||||
NS_IMETHODIMP mozXMLTerminal::GetDOMDocument(nsIDOMDocument** aDOMDocument)
|
||||
{
|
||||
if (!aDOMDocument)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aDOMDocument = nsnull;
|
||||
|
||||
NS_PRECONDITION(mDOMDocument, "bad state, null mDOMDocument");
|
||||
if (!mDOMDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryReferent(mDOMDocument);
|
||||
if (!domDoc) {
|
||||
XMLT_ERROR("mozXMLTerminal::GetDOMDocument: Error - Invalid weak reference\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return domDoc->QueryInterface(NS_GET_IID(nsIDOMDocument),
|
||||
(void **)aDOMDocument);
|
||||
}
|
||||
|
||||
|
||||
// Returns SelectionController associated with XMLTerm
|
||||
NS_IMETHODIMP mozXMLTerminal::GetSelectionController(nsISelectionController** aSelectionController)
|
||||
{
|
||||
if (!aSelectionController)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aSelectionController = nsnull;
|
||||
|
||||
NS_PRECONDITION(mPresShell, "bad state, null mPresShell");
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell) {
|
||||
XMLT_ERROR("mozXMLTerminal::GetSelectionControlle: Error - Invalid weak reference\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return presShell->QueryInterface(NS_GET_IID(nsISelectionController),
|
||||
(void **)aSelectionController);
|
||||
}
|
||||
|
||||
|
||||
/** Gets flag denoting whether terminal is in full screen mode
|
||||
* @param aFlag (output) screen mode flag
|
||||
*/
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nspr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "mozXMLT.h"
|
||||
|
@ -79,6 +80,10 @@ class mozXMLTerminal : public mozIXMLTerminal,
|
|||
|
||||
NS_IMETHOD GetPresShell(nsIPresShell** aPresShell);
|
||||
|
||||
NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument);
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController** aSelectionController);
|
||||
|
||||
NS_IMETHOD GetScreenMode(PRBool* aFlag);
|
||||
|
||||
NS_IMETHOD MatchesCookie(const PRUnichar* aCookie, PRBool *_retval);
|
||||
|
@ -121,14 +126,14 @@ class mozXMLTerminal : public mozIXMLTerminal,
|
|||
/** non-owning reference to containing XMLTermShell object */
|
||||
mozIXMLTermShell* mXMLTermShell;
|
||||
|
||||
/** non-owning reference to containing doc shell */
|
||||
nsIDocShell* mDocShell;
|
||||
/** weak reference to containing doc shell */
|
||||
nsWeakPtr mDocShell;
|
||||
|
||||
/** non-owning (??) reference to presentation shell for XMLterm */
|
||||
nsIPresShell* mPresShell;
|
||||
/** weak reference to presentation shell for XMLterm */
|
||||
nsWeakPtr mPresShell;
|
||||
|
||||
/** non-owning (??) reference to DOM document containing XMLterm */
|
||||
nsIDOMDocument* mDOMDocument;
|
||||
/** weak reference to DOM document containing XMLterm */
|
||||
nsWeakPtr mDOMDocument;
|
||||
|
||||
/** XMLTermSession object created by us (not reference counted) */
|
||||
mozXMLTermSession* mXMLTermSession;
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
Known bugs
|
||||
----------
|
||||
|
||||
23 Oct 2000
|
||||
|
||||
1. Mozilla bug (Solaris only): The cursor has disappeared! (also in Composer)
|
||||
|
||||
2. DOM/IFRAME bug: window.document object not defined for dynamically
|
||||
created IFRAME elements using DOM. Currently prevent the use of IFRAMEs
|
||||
for inline display of HTML documents
|
||||
|
||||
3. XMLterm bug: Typing text in text input element causes input to be duplicated
|
||||
in the command line. Controlled by Javascript WORKAROUND in xmlterm.html
|
||||
to detect onFocus and onBlur events and suspend key event handling by
|
||||
mozXMLTermKeyListener
|
||||
|
||||
4. DOM/Layout bug: When cursor is at leftmost position on the line, clicking
|
||||
on the window moves it up (very annoying). Mitigated by a WORKAROUND in
|
||||
mozXMLTermMouseListener::MouseClick.
|
||||
|
||||
5. XMLterm/DOM bug: As new commands are typed in, scrolling is jerky. For
|
||||
example, type a few non-trivial commands interspersed with several
|
||||
trivial commands (i.e., just pressing ENTER key). The output from the
|
||||
earlier non-trivial commands sometimes jumps downwards instead of moving
|
||||
monotonically upwards. (Does it have anything to do with deletion of
|
||||
earlier DOM entries?)
|
||||
|
||||
6. XMLterm bug: Arrow keys are hard-wired to particular escape sequences.
|
||||
|
||||
7. 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.
|
||||
|
||||
8. "Here document" input positions cursor incorrectly in the previous line.
|
||||
|
||||
9. "yes" command causes xmlterm to hang!
|
||||
|
||||
10. F1 key sometimes blanks out whole screen and makes it unresponsive.
|
||||
|
||||
11. Style changes have become fickle, e.g., prompt underlining doesn't seem
|
||||
to work properly.
|
||||
|
||||
12. cd /usr/share/pixmaps/mc
|
||||
xcat i-symlink.png
|
||||
|
||||
causes crash (seems to be related to GTK event callback)
|
||||
Switching to XP event posting may remove this bug
|
||||
|
||||
13. xmlterm termination not clean, segfaults
|
||||
|
||||
in mozXMLTerminal, mPresShell and mDOMDocument need to addref'ed?
|
Загрузка…
Ссылка в новой задаче